Can't build with --prod flag. Webpack seems to be missing a module


#1

My app runs fine on local webserver and on android, but fails when I try to make a production build. I am using angular2-notifications and it seems that for some reason webpack is not copying/instantiating the simple-notifications.component.

I tried with app-scripts@1.3.7 & 1.3.8 and I get the following error:

[DEBUG] !!! ERROR ENCOUNTERED !!! Error: ./~/angular2-notifications/src/simple-notifications.module.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 25:0-83 @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/services/notifications.service.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 41:0-107 @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/components/simple-notifications.component.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./src/app/app.component.ngfactory.js 38:0-118 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/components/notification.component.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./~/angular2-notifications/src/simple-notifications/components/simple-notifications.component.ngfactory.js 9:0-109 @ ./src/app/app.component.ngfactory.js @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/pipes/max.pipe.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./~/angular2-notifications/src/simple-notifications/components/notification.component.ngfactory.js 9:0-90 @ ./~/angular2-notifications/src/simple-notifications/components/simple-notifications.component.ngfactory.js @ ./src/app/app.component.ngfactory.js @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts [DEBUG] Error: ./~/angular2-notifications/src/simple-notifications.module.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 25:0-83 @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/services/notifications.service.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./src/app/app.module.ngfactory.js 41:0-107 @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/components/simple-notifications.component.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./src/app/app.component.ngfactory.js 38:0-118 @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/components/notification.component.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./~/angular2-notifications/src/simple-notifications/components/simple-notifications.component.ngfactory.js 9:0-109 @ ./src/app/app.component.ngfactory.js @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts,./~/angular2-notifications/src/simple-notifications/pipes/max.pipe.ts Module build failed: TypeError: Cannot read property 'content' of undefined at Object.optimizationLoader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader-impl.js:14:24) at Object.loader (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\webpack\optimization-loader.js:5:32) @ ./~/angular2-notifications/src/simple-notifications/components/notification.component.ngfactory.js 9:0-90 @ ./~/angular2-notifications/src/simple-notifications/components/simple-notifications.component.ngfactory.js @ ./src/app/app.component.ngfactory.js @ ./src/app/app.module.ngfactory.js @ ./src/app/main.ts at BuildError.Error (native) at new BuildError (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28) at E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\preprocess.js:18:21 at process._tickCallback (internal/process/next_tick.js:109:7)

If I try with app-scripts@1.3.4 I get a different error:

[DEBUG] !!! ERROR ENCOUNTERED !!! Error: Unexpected token: name (TabsPageModuleInjector) in E:\dev\circles_testnet\www\build\0.main.js at line 50, col 6, pos 2766 [DEBUG] Error: Unexpected token: name (TabsPageModuleInjector) in E:\dev\circles_testnet\www\build\0.main.js at line 50, col 6, pos 2766 at BuildError.Error (native) at new BuildError (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\util\errors.js:16:28) at taskReject (E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\worker-process.js:36:22) at E:\dev\circles_testnet\node_modules\@ionic\app-scripts\dist\worker-process.js:14:13 at process._tickCallback (internal/process/next_tick.js:109:7)

The reference is to this:

class TabsPageModuleInjector extends __WEBPACK_IMPORTED_MODULE_0__angular_core__["ɵNgModuleInjector"] { constructor(parent) { super(parent, [ __WEBPACK_IMPORTED_MODULE_6__node_modules_ionic_angular_components_action_sheet_action_sheet_component_ngfactory__["a" /* ActionSheetCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_7__node_modules_ionic_angular_components_alert_alert_component_ngfactory__["a" /* AlertCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_8__node_modules_ionic_angular_components_app_app_root_ngfactory__["a" /* IonicAppNgFactory */], __WEBPACK_IMPORTED_MODULE_9__node_modules_ionic_angular_components_loading_loading_component_ngfactory__["a" /* LoadingCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_10__node_modules_ionic_angular_components_modal_modal_component_ngfactory__["a" /* ModalCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_11__node_modules_ionic_angular_components_picker_picker_component_ngfactory__["a" /* PickerCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_12__node_modules_ionic_angular_components_popover_popover_component_ngfactory__["a" /* PopoverCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_13__node_modules_ionic_angular_components_select_select_popover_component_ngfactory__["a" /* SelectPopoverNgFactory */], __WEBPACK_IMPORTED_MODULE_14__node_modules_ionic_angular_components_toast_toast_component_ngfactory__["a" /* ToastCmpNgFactory */], __WEBPACK_IMPORTED_MODULE_15__tabs_ngfactory__["a" /* TabsPageNgFactory */] ], []); }

I don’t have a good idea what is going on here so any help would be appreciated. thanks


#2