webpack error on publish with third-party Angular 4 npm package #477

Closed
opened 2025-08-09 17:16:26 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @rballentine on 8/24/2017

I added a third-party npm package to the Angular template. I put the following in webpack.config.vendor.js:

'ng2-toasty', 'ng2-toasty/bundles/style-bootstrap.css'

And everything works in development mode. But when I publish, I get an error executing this command:

node node_modules/webpack/bin/webpack.js --env.prod

The error:

ERROR in ./$$_gendir/~/ng2-toasty/src/toasty.component.ngfactory.ts
Module parse failed: C:\App\$$_gendir\node_modules\ng2-toasty\src\toasty.component.ngfactory.ts Unexpected token (15:28)
You may need an appropriate loader to handle this file type.
| import * as i4 from 'ng2-toasty/src/toasty.component';
| import * as i5 from 'ng2-toasty/src/toasty.service';
| const styles_ToastyComponent:any[] = ([] as any[]);
| export const RenderType_ToastyComponent:i0.RendererType2 = i0.╔╡crt({encapsulation:2,
| styles:styles_ToastyComponent,data:{}});
@ ./$$_gendir/ClientApp/app/components/app/app.component.ngfactory.ts 9:0-102
@ ./$$_gendir/ClientApp/app/app.module.browser.ngfactory.ts
@ ./ClientApp/boot.browser.ts

I suspect there's some additional webpack configuration I need to do, but I don't know enough about webpack. Any help is appreciated. Thanks.

*Originally created by @rballentine on 8/24/2017* I added a third-party npm package to the Angular template. I put the following in webpack.config.vendor.js: `'ng2-toasty', 'ng2-toasty/bundles/style-bootstrap.css'` And everything works in development mode. But when I publish, I get an error executing this command: `node node_modules/webpack/bin/webpack.js --env.prod` The error: > ERROR in ./$$_gendir/~/ng2-toasty/src/toasty.component.ngfactory.ts Module parse failed: C:\App\\$$_gendir\node_modules\ng2-toasty\src\toasty.component.ngfactory.ts Unexpected token (15:28) You may need an appropriate loader to handle this file type. | import * as i4 from 'ng2-toasty/src/toasty.component'; | import * as i5 from 'ng2-toasty/src/toasty.service'; | const styles_ToastyComponent:any[] = ([] as any[]); | export const RenderType_ToastyComponent:i0.RendererType2 = i0.╔╡crt({encapsulation:2, | styles:styles_ToastyComponent,data:{}}); @ ./$$_gendir/ClientApp/app/components/app/app.component.ngfactory.ts 9:0-102 @ ./$$_gendir/ClientApp/app/app.module.browser.ngfactory.ts @ ./ClientApp/boot.browser.ts I suspect there's some additional webpack configuration I need to do, but I don't know enough about webpack. Any help is appreciated. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#477
No description provided.