Closed sindilevich closed 7 years ago
I think the solution to this is probably to use the es module version of tslib: https://github.com/Microsoft/tslib/blob/master/tslib.es6.js
packages: {
...
'tslib': {main: 'tslib.es6.js'}
}
@frankwallis, thanks to your help, I came up with the SystemJS configuration as follows, which allows both making TypeScript produce modules in the System.register
format and using the importHelpers: true
option with the TypeScript compiler.
System.config({
transpiler: 'ts',
typescriptOptions: {
emitDecoratorMetadata: true,
experimentalDecorators: true,
importHelpers: true,
target: 'ES5',
module: 'system'
},
map: {
'@angular': 'node_modules/@angular',
'rxjs' : 'node_modules/rxjs',
'tslib' : 'node_modules/tslib'
},
paths: {
'ts': 'node_modules/plugin-typescript/lib',
'typescript': 'node_modules/typescript'
},
meta: {
'@angular/*': {esModule: true}
},
packages: {
'app' : {main: 'main', defaultExtension: 'ts'},
'rxjs' : {main: 'Rx'},
'@angular/core' : {main: 'bundles/core.umd.min'},
'@angular/common' : {main: 'bundles/common.umd.min'},
'@angular/compiler' : {main: 'bundles/compiler.umd.min'},
'@angular/router' : {main: 'bundles/router.umd.min'},
'@angular/platform-browser' : {main: 'bundles/platform-browser.umd.min'},
'@angular/platform-browser-dynamic': {main: 'bundles/platform-browser-dynamic.umd.min'},
'ts' : {main: 'plugin'},
'typescript' : {main: 'lib/typescript', meta: {'lib/typescript.js': {exports: 'ts'}}},
'tslib' : {main: 'tslib.es6'}
}
});
Using SystemJS 0.20.9 set to transpile
.ts
files on the fly with TypeScript 2.2.1 withimportHelpers: true
produces the following error in run-time:The SystemJS config is as follows
The
package.json
Setting
module: 'commonjs'
in thetypescriptOptions
object, fixes the issue and does not produce any errors.However, when the
typescriptOptions
object configured withmodule: 'commonjs'
, there are warnings in the console:I believe there should be a solution to both make TypeScript produce modules in the
System.register
format and using the much anticipatedimportHelpers: true
option with the TypeScript compiler.Thank you in advance for any leads and help!