1

在执行 AOT 时,我遇到了我正在使用的 ng2-toastr 的问题

ToastsManager' is not exported by 'node_modules\ng2-toastr\src\toast-manager.js


 'ToastModule' is not exported by 'node_modules\ng2-toastr\src\toast.module.js'.



'ToastOptions' is not exported by 'node_modules\ng2-toastr\src\toast-options.js'.

关于如何解决这个问题的任何想法?我检查了所有提到的文件,他们有出口声明关键字,甚至检查了这个网站

https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module

4

2 回答 2

4

您可以通过更改汇总配置 js 文件来解决此问题。您需要对 commonjs 插件配置进行 2 处更改。

这是我更改后的。请注意,您需要同时添加额外的 include 和 namedExports。

      plugins: [
          nodeResolve({jsnext: true, module: true}),
          commonjs({
             include: [ 
                'node_modules/rxjs/**',
                'node_modules/ng2-toastr/**'
             ],
             namedExports : { 
                'node_modules/ng2-toastr/ng2-toastr.js': [ 'ToastModule', 'ToastsManager' ] 
             }
          }),
          uglify()
       ]
于 2017-01-19T12:28:20.873 回答
1

您是否使用任何第三方库?如果是这样,请注意以下事项

  • 第三方库必须是 AoT 自己编译的。
  • 第三方库必须导出 JS 源、d.ts 文件和所有生成的 metadata.json 文件。
于 2016-12-14T09:29:53.657 回答