Koby Douek
Koby Douek

Reputation: 16675

TypeScript [Warning] transpiling to CommonJS, consider setting module: "system" in typescript Options

Using Angular 2, I'm getting a warning in Chrome console:

TypeScript [Warning] transpiling to CommonJS, consider setting module: "system" in typescriptOptions to transpile directly to System.register format

I've serached the web thoroughly but couldn't find a solution or an article about this issue.

I did find this site, that mentions using:

--allowSyntheticDefaultImports  (boolean)   

as

module === "system"

I added to my tsconfig.json file:

{
  "compilerOptions": {
    "target": "es5",
    //"module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noEmitHelpers": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true,
    "allowSyntheticDefaultImports": true,
    "module": "system"
  }
}

But it did not help.

Any suggestions ?

Upvotes: 2

Views: 893

Answers (2)

Pankaj Parkar
Pankaj Parkar

Reputation: 136144

You could set module to system option by setting compilerOptions of of tsconfig.json option.

tsconfig.json

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "module": "system",
        "noImplicitAny": true,
        "removeComments": true,
        "preserveConstEnums": true,
        "sourceMap": true
    }
}

Find tsconfig.json docs here

Also you can do the same via command line by adding --module system in your command args.

Upvotes: 3

Suraj Rao
Suraj Rao

Reputation: 29624

It should go into tsconfig.json They contain the settings and configurations for typescript transpilation Check here.

 "compilerOptions": {
    "allowSyntheticDefaultImports": true,
         "module": "system",

    //other settings
   }

Upvotes: 0

Related Questions