javascript - 无法动态转译 ES 模块 System.config({ transpile : 'transpile-module' })

标签 javascript angularjs

这是我的 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 viaSystemJS.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/

相关文章:

javascript - 创建一个带有持久标签的网页

javascript - 动态添加的语义 ui 复选框/ radio /评级事件未触发

javascript - AngularJS - 相同级别的指令错误地使用相同的名称方法

javascript - JPA ng-repeat 过滤器 - 多个 id 作为一个

jquery - 将 jQuery 与backbone.js/angular.js/ember.js 混合使用有什么问题?

javascript - 使用 javascript 将外部 .html 加载到 div 中

javascript - 如何让 Formik 返回一个 bool 值?

javascript - 当您将 javascript 放在结束 body 标记之后会发生什么?

angularjs - 在 Angular 指令中观察元素的高度

javascript - 从 ng-options 中为 AngularJS 中的另一个选择语句选择值