angular-cli: Angular app runs fine via "ng serve -aot" and "ng build -aot" but once --prod is appended, build is successful but console errors in browser..
Versions
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.6.4
Node: 8.9.1
OS: darwin x64
Angular: 5.2.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.4
@angular-devkit/build-optimizer: 0.0.38
@angular-devkit/core: 0.0.25
@angular-devkit/schematics: 0.0.48
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.4
@schematics/angular: 0.1.13
@schematics/schematics: 0.0.13
typescript: 2.6.2
webpack: 3.10.0
Observed behavior
-
Running via
ng serve --aot --progress=false --proxy-config proxy.conf.json
and no errors in the console, everything works well. -
Running a build via
ng build --aot
and the output files work just like ng serve above. -
Running via
ng serve --aot --prod
and the application won’t render and the following console messages appears. -
Running via
ng build --aot --prod
and the application won’t render with the same console messages asng serve --aot --prod
.
FireFox Error:
TypeError: t[r] is undefined main.1eda0feb0dddc7c4747b.bundle.js:1:791705
Chrome Error:
Uncaught TypeError: Cannot read property 'call' of undefined main.d8cd32d2ec09f8365918.bundle.js:1
at n (main.d8cd32d2ec09f8365918.bundle.js:1)
at Object.t.exports (main.d8cd32d2ec09f8365918.bundle.js:1)
at n (main.d8cd32d2ec09f8365918.bundle.js:1)
at Object.t.exports (main.d8cd32d2ec09f8365918.bundle.js:1)
at n (main.d8cd32d2ec09f8365918.bundle.js:1)
at Object.t.exports (main.d8cd32d2ec09f8365918.bundle.js:1)
at n (main.d8cd32d2ec09f8365918.bundle.js:1)
at Object.t.exports (main.d8cd32d2ec09f8365918.bundle.js:1)
at n (main.d8cd32d2ec09f8365918.bundle.js:1)
at Object.<anonymous> (main.d8cd32d2ec09f8365918.bundle.js:1)
Desired behavior
when appending --prod no errors should be produced
Mention any other details that might be useful (optional)
I’m at a bit of a loss as I have no idea how to debug this. Is is the compiler or something I’m doing? I can provide the repo if needed.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 9
- Comments: 21
Seems the issue is back in 1.7.1 (and also 1.7.3)! We had to apply the workaround with –build-optimizer=false and this worked.
Yes, it looks like the issue is still present in 1.6.5.
It is my understanding that
--aot
is true by default on a--prod
build which is why you see the issue with or without it.I managed to make it work and it seemed to be related to a dependency which got updated … 3 days ago (coincidence ?)
The package is
reflect-metadata
which got a new version0.1.12
. When I restore the older version which is0.1.10
(0.1.11
got deprecated within a day) things start to work again with the following flags.When doing an
npm list reflect-metadata
, it seems that@angular/compiler-cli
is using this dependency.Yes, that does look like the same issue. I’ve deconstructed my project trying to determine the peice of code that is causing this without success. I have found that if I add the flag
--aot=false
to the build, this problem is no longer present. So it appears related to AOT.