-
Notifications
You must be signed in to change notification settings - Fork 156
bug(build-optimizer): initial Map values are stripped unnecessarily #364
Comments
Running Build Optimizer over the following code:
will return
This is expected behaviour since Build Optimizer consider all code in But that code is actually not side effect free. Those function calls cause a side effect. I suppose that's why there's a comment there about the Closure compiler as well. So I'm not really sure what to do in this case. We can remove I think the Angular packages are actually meant to be side-effect free so maybe that code should be modified. @IgorMinar WDYT? |
What's doing this transpilation though?
I think Angular itself uses TS 2.6 and according to the TS Playground it's correctly compiled to
|
This was an issue with |
Ahah. I think we may not yet be on latest
…On Tue, 9 Jan 2018, 16:03 clydin, ***@***.***> wrote:
This was an issue with @angular/animations less then 5.1.1.
This commit fixed the issue: ***@***.***
<angular/angular@661fdcd>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#364 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAA9JymRlQlmXbtu_mtX2TImBnqQ2AJ7ks5tI43HgaJpZM4RX2S_>
.
|
@petebacondarwin I have a PR pending that updates aio to the latest rc |
The interesting thing about this issue is that while the source code has no non-local side effects, the transpiled code no longer has that property because what used to be a single statement, got transpiled into three statements. |
@IgorMinar I think the transpiled code shown was not transpiled from the current code in master, as per @clydin's comment (angular/angular@661fdcd). I tried transpiling with TS 2.6 and 2.4 and it yielded the correct JS code with no side effects. The source before that commit really did have side effects. |
I can concur. The code we are using in AIO is currently from 5.1.0-beta.2 so it is before the fix that moves those side-effect calls into constructor parameters. |
I think we can close this. |
This code in the
@angular/animations
package gets compiled incorrectly when the build optimizer is turned on:WITHOUT optimization:
WITH optimization:
You can see that the initialization is being stripped out causing animations that rely upon boolean values not to match, and so not run.
This use case was identified in the AIO application, where we wanted to use boolean based animation states.
You could see the animations working without the optmizer
ng start --prod --build-optimizer=false
but as soon as you ran in production modeng start --prod
the animation was not matching and so not being played.We worked around it by using string based animation states instead:
Bug Report or Feature Request (mark with an
x
)Area
Versions
The text was updated successfully, but these errors were encountered: