I want to compile Angular 2 project as commonjs
module.
I have this tsconfig.json
:
{
"compilerOptions": {
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"mapRoot": "./",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../dist/lib",
"sourceMap": true,
"target": "es5",
"removeComments": true
}
}
I use ntsc
and I got these kind of errors:
node_modules/@angular/common/src/directives/ng_class.d.ts(46,34): error TS2304: Cannot find name 'Set'.
node_modules/@angular/common/src/pipes/async_pipe.d.ts(44,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(32,38): error TS2304: Cannot find name 'Promise'.
node_modules/@angular/compiler/src/aot/compiler.d.ts(44,32): error TS2304: Cannot find name 'Map'.
I have npm
version 4.0.5
, node
v7.3.0
and ntsc
Version 2.1.0
For transpiling to es5 you have to add the following reference in your main ts file:
///<reference path="node_modules/angular2/typings/browser.d.ts"/>