这是我的 tsconfig.js
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"target": "es5",
"module": "system",
"noImplicitAny": false,
"outDir": "built",
"rootDir": ".",
"sourceMap": false
},
"exclude": [
"node_modules"
]
我正在使用 tsc
命令将我的“hello-angular.ts”转译为“hello-angular.js”。并通过 System.import ('built/hello-angular')
当我启动服务器时,我在浏览器中遇到了错误
Unable to dynamically transpile ES module A loader plugin needs to be configured via
SystemJS.config({ transpiler: 'transpiler-module' })``
我不明白,为什么 systemjs 试图转译 es5 文件..我设置了 system.config({transpiler: false}) ,但它没有帮助..
最佳答案
您需要按照以下答案中的说明添加转译器:
Angular 2 - Unable to dynamically transpile ES module, angular2-google-map-auto-complete
在我的 systemjs.config.js 中它看起来像这样:
map: {
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
'systemjs-babel-build': 'npm:systemjs-plugin-babel/systemjs-babel-browser.js'
},
transpiler: 'plugin-babel',
关于javascript - 无法动态转译 ES 模块 System.config({ transpile : 'transpile-module' }),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41914913/