optimization: true breaks transitiveCompileScopes for jit compiled components
See original GitHub issueπ bug report
Affected Package
I believe This issue is caused by @angular/compiler
Is this a regression?
This was working on Angular version 6.1.10
Description
I am trying to compile a simple component
<form>
<input type="text"
name="value"
[(ngModel)]="value"> {{value}}
</form>
with some logic
ngOnInit() { setInterval(() => this.value++, 1000);
inside of a module
{
imports: [CommonModule, FormsModule],
declarations: [RuntimeComponent],
}
on the client with JIT compiler with the help of compiler.compileModuleAndAllComponentsSync.
with optimization: false set in angular.json everything works perfectly fine: both input and interpolation are updated with every tick of setInterval and typing inside of an input also updates the value.
with optimization: true ngModel directive is just lost. i.e. interpolated value updates every second, but input neither shows values nor causes updates when you type in it.
Iβve tried to compare the compiled components and modules in optimized vs unoptimized code and here are the differenced that Iβve found:
- RuntimeComponentModule.Ι΅mod.transitiveCompileScopes.compilation contains only my RuntimeComponent in optimized version versus 33 directives and 13 pipes in unoptimized one.
- RuntimeComponent.Ι΅cmp.tView contains significantly more items in unoptimized version
In our app far more complex components are compiled, this is just a simpler example with a reproducable issue. At the moment any workarounds would be useful.
Note: you can notice
import { publishFacade } from '@angular/compiler';
publishFacade(window);
in the code. Without this piece compiler is eliminated from the bundle, but this bothers us much less as it could be workarounded
π¬ Minimal Reproduction
it is impossible to reproduce on a stackblitz. Here is a repository with minimal reproduction example described above https://github.com/AndreyAusianik/ivy-dynamic-problem/
π₯ Exception or Error
error can be generated if you add something specific to directives to the template. for example #model=βngModelβ then it wonβt be rendered at all, as the compiler finds nothing exported as ngModel.
π Your Environment
Angular Version:
Angular CLI: 9.1.5
Node: 13.1.0
OS: win32 x64
Angular: 9.1.6
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.901.5
@angular-devkit/build-angular 0.901.5
@angular-devkit/build-optimizer 0.901.5
@angular-devkit/build-webpack 0.901.5
@angular-devkit/core 9.1.5
@angular-devkit/schematics 9.1.5
@angular/cli 9.1.5
@ngtools/webpack 9.1.5
@schematics/angular 9.1.5
@schematics/update 0.901.5
rxjs 6.5.5
typescript 3.8.3
webpack 4.42.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:9 (4 by maintainers)
Top GitHub Comments
Thanks @alxhub ! is JIT-compatible omptimization mode planned to be implemented?
Seems Terser drop moduleMetadata defined by ngtsc marked as pure
become after Terser with side_effects