Search code examples
angularaotangular2-aot

Angular 2 Aot Error: 'ToastsManager' is not exported


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


Solution

  • 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()
           ]