Angular 2 Aot Error: 'ToastsManager' is not exported
Asked Answered
R

2

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

Radioman answered 13/12, 2016 at 5:41 Comment(0)
P
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()
       ]
Piccadilly answered 19/1, 2017 at 12:28 Comment(1)
Yea it will work but bit late.I already implemented this ;-)Radioman
F
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.
Felton answered 14/12, 2016 at 9:29 Comment(2)
How to do that ??Radioman
The third party vendors would have published the .metadata.json file, check for that.Felton

© 2022 - 2024 — McMap. All rights reserved.