AOT build fails
Bug Report or Feature Request (mark with an x)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.2.3
node: 6.11.1
os: darwin x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1
Repro steps.
$ ng new hello
$ cd hello
$ ng build --prod
The log given by the failure.
$ ng build --prod
Hash: edf6fb3ccb1b82fa940c
Time: 10775ms
chunk {0} polyfills.71b130084c52939ca448.bundle.js (polyfills) 177 kB {4} [initial] [rendered]
chunk {1} main.e81f19d3f6b27a436c79.bundle.js (main) 1.09 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.f7457d5ac1e9743fd76f.bundle.js (vendor) 849 kB [initial] [rendered]
chunk {4} inline.18e445e37a0efd4dcfa2.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'hello/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
Desired functionality.
aot build runs
Mention any other details that might be useful.
Maybe, enhanced-resolve 3.4.0 is cause. https://github.com/webpack/enhanced-resolve/issues/98
ng build --prod runs successfully after npm i [email protected] .
@filipesilva as per your comment on the issue #7125 I am using the latest cli. - Using latest rc1 - installed [email protected] still the same error.
using yarn it does not works , using npm it works.
yarn why v0.27.5
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Has been hoisted to "enhanced-resolve"
info This module exists because it's specified in "devDependencies".
Done in 0.82s.
yarn list v0.27.5
├─ [email protected]
└─ [email protected]
└─ [email protected]
Done in 0.78s.
The project is newly generated by the command
ng new my-prj --skip-install --skip-git -dir my-prj --style scss --routing
No other changes are done in the project excepting adding [email protected]
@filipesilva indeed, it seems like some yarn issue! I upgraded it to the next version (0.28.4), but the error was still there.
Now, I downgraded yarn to v0.24.6, same as yours, the module resolutions seems to be ok ([email protected]) but the error is still there.
$ node -v
v6.11.0
$ yarn list
yarn list v0.24.6
...
├─ @angular/[email protected]
...
├─ @ngtools/[email protected]
│ ├─ [email protected]
...
├─ [email protected]
...
├─ [email protected]
│ ├─ enhanced-resolve@^3.3.0
...
$ yarn why enhanced-resolve
yarn why v0.24.6
info Reasons this module exists
- "@angular/cli#@ngtools/webpack" depends on it
- "@angular/cli#webpack" depends on it
Same package.json as previously.
Fresh install w/o node_modules and yarn.lock with cleared yarn cache. The AoT build error is still there (see full dump). Weird...
@filipesilva Did you try to actually build it (with AoT), did it work? (as you didn't mention explicitly about build, just about the module resolution).
Could somebody maybe re-open this ticket or should we create a new one specific for yarn?
Yarn will keep installing the 3.4 version for package that want it (like webpack which uses a ^ in the version number). The only way I managed to fix it was to modify my yarn.lock by manually changing the version and resolved field for the enhanced-resolve ^3.4.0 entry to point to the 3.3.0 instead.
@kavi87 yes, that also worked for me. But it's obviously not a long-term solution :smile:
@BorntraegerMarc Wouldn't the long-term solution be waiting for enhanced-resolve to fix itself?
@stwic it seems like they already published a "fix". But I'm not sure if this really fixes it or is the cause...
@BorntraegerMarc https://github.com/webpack/enhanced-resolve/issues/98#issuecomment-317516344
Thanks a lot @cebor So it seems like we need to wait on a long-term fix from @ngtools/webpack side. The enhanced-resolve lib behaves correctly. When do you guys expect the correct implementation of WebpackCompilerHost in @ngtools/webpack? Maybe it makes more sense to focus on the actual fix then to try to get yarn running with the current setup. I'm quite sure yarn would work again if we would get the newest angular-cli version with the WebpackCompilerHost fix
@filipesilva: Can you take a look at my earlier comment, https://github.com/angular/angular-cli/issues/7113#issuecomment-317599036, and let me know if it looks like it's related to this issue? If not, I'll open a new issue with a minimal repro.
@samridh90 I don't think it's related. My browser executed my prod build without problems...
@BorntraegerMarc : Does your app have any lazy loaded routes?
@samridh90 yes
If npm install [email protected] isn't working and you're using webpack, you might also want to try npm install [email protected] too. Lost 3 hours today :(
@filipesilva did you have time to tinker already? :) I opened a but at yarn in the meantime https://github.com/yarnpkg/yarn/issues/4024
@filipesilva i have same issues,i used @ngtools/webpack,all package update to latest,see below:
"@angular/compiler-cli": "^4.3.1",
"@angular/platform-server": "^4.3.1",
"@ngtools/webpack": "^1.5.3",
"webpack": "^3.4.0",
"@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.1",
"@angular/core": "^4.3.1",
"@angular/forms": "^4.3.1",
"@angular/http": "^4.3.1",
"@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.1",
"@angular/router": "^4.3.1",
this seems like incopatibility with webpack > 3.3.0 and @ngtools/webpack.
npm install [email protected] [email protected]
resolves the issue.
Yes, @ngtools/webpack and [email protected] breaks build also with npm.
Shouldn't we reopen this issue again? Seems, that for many scenarios this is definitely not fixed.
Count me in to those who cannot get it to work with [email protected]. Thanks to @jpduckwo for sacrificing his 3 hours to save mine; downgrading to [email protected] works great.
my quick fix for installing with yarn: pinned enhanced-resolve to "3.3.0" in my package.json and added an "postinstall"-script, which deletes enhanced-resolve in webpack