Angular 2 - 无法动态转换ES模块,angular2-google-map-auto-complete

nik*_*ila 2 angular

我正在开展一个有角度的项目.我使用angular2-google-map-auto-complete模块进行谷歌位置自动完成功能.为此,我在Systemjs.config.js中包含了以下行

            var map ={ 'angular2-google-map-auto-complete' : 'node_modules/angular2-google-map-auto-complete'};
            var packages = {'angular2-google-map-auto-complete' : {defaultExtension:'js'}};
Run Code Online (Sandbox Code Playgroud)

但是在启动npm服务器时,我在控制台上收到以下错误.

Error: Unable to dynamically transpile ES module
   A loader plugin needs to be configured via `SystemJS.config({ transpiler: 'transpiler-module' })`.
  Instantiating http://localhost:3000/node_modules/angular2-google-map-auto-complete/directives/googleplace.directive.js
  Loading http://localhost:3000/app/app.module.js
  Loading main.js
    at transpile (instantiate.js:463)
    at instantiate.js:241
    at ZoneDelegate.invoke (zone.js:365)
    at Zone.run (zone.js:125)
    at zone.js:760
    at ZoneDelegate.invokeTask (zone.js:398)
    at Zone.runTask (zone.js:165)
    at drainMicroTaskQueue (zone.js:593)
    at <anonymous>
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

nik*_*ila 6

经过研究,我找到了解决方案.我刚刚安装了babel插件.

npm i systemjs-plugin-babel 
Run Code Online (Sandbox Code Playgroud)

然后更新了systemjs.config.js文件.

SystemJS.config({
  map: {
    'plugin-babel': 'path/to/systemjs-plugin-babel/plugin-babel.js',
    'systemjs-babel-build': 'path/to/systemjs-plugin-babel/systemjs-babel-browser.js'
  },
  transpiler: 'plugin-babel'
});
Run Code Online (Sandbox Code Playgroud)

重新启动了npm及其工作.