Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Atom takes much time to compile typescript files for angular 2

I am working on the Angular 2 RC-6 from Angular2 Documentation. I find atom too slow to compile my '.ts' files. If I move my tsconfig.json from root folder to any other directory, it compiles fast but misses some DI such as 'rxjs/add/operator/toPromise'.

Please suggest how to make atom compile fast, or any modification on the tsconfig.json.

My project directory structure is as instructed in documentation.

Here is my tscongig.json file

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  }
}
like image 729
SSS Avatar asked Sep 09 '16 05:09

SSS


2 Answers

Like Daniel said you just need to exclude a few folders. Mainly the node_modules folder, since there are tons of TypeScript and Javascript files in there.

You can do so by adding the following exclude option to your tsconfig.json:

"exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
]

Adding this to your current config it would look like this:

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
like image 190
rinukkusu Avatar answered Sep 29 '22 21:09

rinukkusu


I'm adding this here in case anyone else has the same issue as me.

I tried excluding the node_modules folder as suggested in rinukkusu's answer but this ended up breaking the compiler altogether (Atom 1.12.9, Atom-Typescript 10.1.13).

After some hair pulling I added the include option to see what would happen. The documentation doesn't specifically say that both are required but it seemed to fix the problem.

So in my case the config would look like this:

 {
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false
    },
    "include": [
        "app/**/*"
    ],
    "exclude": [
        "node_modules",
        "typings/main",
        "typings/main.d.ts"
    ]
}
like image 39
spryce Avatar answered Sep 29 '22 22:09

spryce