Closed crysislinux closed 4 years ago
We've run into this exact same issue. Right now I'm also going through and replacing these shorthand instances with animations: animations
but it worries me that none of our CI builds caught this. It would be possible for one of these to slip in and we wouldn't know until something broke in prod.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.
π Bug report
Command (mark with an
x
)Is this a regression?
Yes
Our code ran without problem with
--prod
build flag in angular 7.But now it fails with the same flag in angular 9 with ivy enabled.
Description
We have some shared
animations
definitions like this:animations.ts
the animations are defined in a separate file
animations.ts
. And then it's referenced like this:Those codes look good to me and they works in
Angular 7
. Now withAngular 9
, the production build will throw runtime error:I have found 3 ways to workaround it:
"enableIvy": false,
"optimization": false,
in production configuration (aot
andbuildOptimizer
can still betrue
)property shorthand
foranimations
property, just change toanimations: animations
also fixes the problem.We went with option 3 but it looks confusing why valid typescript code doesn't work and the linter even tell me to use
property shorthand
. It's fine to be a compilation error but unacceptable to be a runtime error only.π¬ Minimal Reproduction
npm run build
to create production buildhttp-server dist/angular9-ext -p 4200
You should see some error messages in the console.
optimization
fromtrue
to false inangular.json
line43
2
to4
Now it loads without problem.
optimization
fromfalse
totrue
2
to4
Now you should see the problem again
src/app/notlazy/notlazycomp/notlazycomp.component.ts
, change line 8 fromanimations,
toanimations: animations,
2
to4
Now it loads without problem.
Turn off ivy also fix the problem but I have a lazy load route in the repo so it may not work. By the way, this problem also breaks the lazy loading if there is the same
animations
property shorthand usage in the lazy loaded module.π₯ Exception or Error
π Your Environment
Anything else relevant?
N/A