Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

ngfactory does not get created for the production build #553

Closed
otruffer opened this issue Dec 15, 2016 · 9 comments
Closed

ngfactory does not get created for the production build #553

otruffer opened this issue Dec 15, 2016 · 9 comments

Comments

@otruffer
Copy link

otruffer commented Dec 15, 2016

Working with RC3 and build scripts 0.0.47. I can't get the prduction build running, saw several people with similar issues, none of the solutions seem to work for me. As far as I can tell ngc doesn't compile the ngfactory. Development build works fine.

ionic run android --prod

> ilias-app@ ionic:build /home/otruffer/ionic/ILIAS-App2
> ionic-app-scripts build "--prod"

[11:27:45]  ionic-app-scripts 0.0.47 
[11:27:45]  build prod started ... 
[11:27:45]  clean started ... 
[11:27:45]  clean finished in 1 ms 
[11:27:45]  copy started ... 
[11:27:45]  ngc started ... 
[11:27:58]  ngc finished in 13.80 s 
[11:27:58]  webpack started ... 
[11:27:59]  copy finished in 14.05 s 
[11:28:01]  webpack finished in 2.30 s 
[11:28:01]  uglifyjs started ... 
[11:28:01]  sass started ... 
[11:28:02]  sass finished in 1.36 s 
[11:28:02]  cleancss started ... 
[11:28:03]  cleancss finished in 537 ms 
[11:28:05]  uglifyjs finished in 4.00 s 
[11:28:05]  build prod finished in 20.16 s 
Running command: /home/otruffer/ionic/ILIAS-App2/hooks/after_prepare/010_add_platform_class.js /home/otruffer/ionic/ILIAS-App2

add to body class: platform-android

[...]

The error message I get on the phones console:

Uncaught Error: Cannot find module "./app.module.ngfactory"
    at Object.<anonymous> (main.js:7)
    at e (main.js:1)
    at main.js:1
    at main.js:1
Your system information:

Cordova CLI: 5.4.1 
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.13
Node Version: v6.6.0
Xcode version: Not installed

EDIT: Maybe it's important to know that I have this issue ever since updating from RC1 to RC3. Later on I updated to the build scripts 0.0.47 (from 0.0.45) as this was suggested to resolve the issue, but it didn't help either.

EDIT2: I could get it working by downgrading build scripts to 0.0.45 and fixing a type error in some pipe. I think the problem in 0.0.47 was mainly due to:

[starting ngc manually, with npm run ngc]
[14:22:14]  ngc started ... 
[14:22:14]  ionic-app-script task: "ngc" 
[14:22:14]  TypeError: Cannot read property 'fileCache' of undefined 
``
Building the app failed silently though.
@brianwang
Copy link

i got same issue.

@danbucholtz
Copy link
Contributor

Hmmm, can you try to track it down? I haven't seen this issue. Can you remove declarations.d.ts and see if you have any errors? declarations.d.ts potentially masks a lot of bugs but we can't get rid of it until TypeScript 2.1 works with Angular.

Thanks,
Dan

@danbucholtz
Copy link
Contributor

Can you try npm run ionic:build --aot and see if that works? Then just open the index.html file in Chrome or something.

Can you also update typescript in package.json to ensure it is 2.0.9? TypeScript 2.1 is the new default but it doesn't work with Angular AoT yet.

I think minification may be breaking something. Please let me know how it goes.

Thanks,
Dan

@danbucholtz
Copy link
Contributor

Can you try again with npm install @ionic/app-scripts@nightly? Please make sure it is Webpack beta 27 and NOT the RC release. The RC release broke us and Angular CLI.

Thanks,
Dan

@jayeshanandani
Copy link

ionic run ios --prod has no issues with nightly version of app-scripts with typescript 2.0.9 and ionic 2.0.rc4

@duydao
Copy link

duydao commented Dec 16, 2016

I had the same error when using --prod in package.json:

"ionic:build": "ionic-app-scripts build --prod",

Removing it from package.json and adding it as CLI paramter worked for me.

ionic build android --prod

@duydao
Copy link

duydao commented Dec 18, 2016

This seems related to angular/angular#13344. Use TypeScript 2.0.X to make it work again.

@danbucholtz
Copy link
Contributor

Hi all,

This is resolved in 0.0.48 which was just published.

Please let me know if you have any issues.

Thanks,
Dan

@trkoch
Copy link

trkoch commented Dec 20, 2016

I got the same error, even with 0.0.48, and fixed it by updating my custom webpack.config.js to use the ionicWebpackFactory.getIonicEnvironmentPlugin() plugin.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants