1

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

sudhir
  • 1,387
  • 3
  • 25
  • 43

2 Answers2

4

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()
       ]
Steve Rash
  • 261
  • 2
  • 7
1

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.
Ignatius Andrew
  • 8,012
  • 3
  • 54
  • 54