问题
While performing AOT I'm facing issue with ng2-toastr which I'm using
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'.
Any idea on how to resolve this? I checked all those mentioned files, they have export declare keywords with them, even checked with this site
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
回答1:
You can solve this by making a change to the rollup config js file. You need to make 2 changes to the commonjs plugin config.
Here is mine after the change. Note you need to add both the extra include and the 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()
]
回答2:
Are you using any third party libraries? If so take care of the following
- The third party library has to be AoT compiled itself.
- The third party library has to export the JS source, the d.ts files and all generated metadata.json files.
来源:https://stackoverflow.com/questions/41114379/angular-2-aot-error-toastsmanager-is-not-exported