Unable to build for production after updating to Ionic 2.2.0

Hello,

so I’ve updated my ionic version to 2.2.0 (from RC5) to use some of the new features. Unfortunately the production build keeps failing without error while compiling the app. Only when starting the app (on android or in browser) I get the error Uncaught ReferenceError: AppModuleNgFactory is not defined and a blank screen. Surely I’m missing some change I had to do. Does someone has a clue?

My package.json looks like this:

  "dependencies": {
    "@angular/common": "2.4.8",
    "@angular/compiler": "2.4.8",
    "@angular/compiler-cli": "2.4.8",
    "@angular/core": "2.4.8",
    "@angular/forms": "2.4.8",
    "@angular/http": "2.4.8",
    "@angular/platform-browser": "2.4.8",
    "@angular/platform-browser-dynamic": "2.4.8",
    "@angular/platform-server": "2.4.8",
    "@ionic/storage": "2.0.0",
    "ionic-angular": "2.2.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "rxjs": "5.0.1",
    "sw-toolbox": "3.4.0",
    "zone.js": "0.7.2"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.1.4",
    "electron": "^1.4.14",
    "typescript": "2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard"
  ]
}

Also I am using ionic-storage and updated it in my app.module:

@NgModule({
	declarations: [
		//...
	],
	imports: [
		IonicModule.forRoot(DrubbedApp,
			{
				mode: 'md',
				swipeBackEnabled: false,
				pageTransition: 'ios'
			},
			{
                // for dev purposes only
				links: [
					{component: StartscreenComponent, name: 'Startscreen', segment: 'home'},
					// some other links
				]
			}),
		IonicStorageModule.forRoot({
			driverOrder: ['sqlite', 'websql', 'indexeddb']
		})
	],
	bootstrap: [IonicApp],
	entryComponents: [
		//...
	],
	providers: [
		//...
	]
})
export class DrubbedAppModule { }

And finally in my main.ts:

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { DrubbedAppModule } from './app.module';

platformBrowserDynamic().bootstrapModule(DrubbedAppModule);

I would try renaming your app module back to the stock AppModule and seeing if that has any effect.

1 Like

Hi, sorry for the late response. We went back to version 2.0.1 until I had more time for trying the 2.2.0 update. And you are totally right. Renaming the app module to the original AppModule did the work. So, thanks for help!

Maybe this should be documented somewhere? Or is it already?

1 Like

Thank you so mush, I faced the same issue because I changed AppModule to my custom name. After I changed back to “AppModule”, it worked via "build --prod’.