You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dynamic component broken when using Standalone + aot: false #47996
area: coreIssues related to the framework runtimeneeds: clarificationThis issue needs additional clarification from the reporter before the team can investigate.
I'm confused, this seems expected to me. The local, anonymous component declaration isn't supported for AOT compilation so it remains present for the JIT compiler to pick up, and the error is reported to indicate that the JIT compiler is not available.
Just the import from @angular/platform-browser-dynamic contains a transitive import for @angular/compiler, which contains a side-effectful module that makes the compiler available globally. So it's not because platformBrowserDynamic().bootstrapModule({} as any) is included in the bundle, but rather that an import for @angular/platform-browser-dynamic is present (the "dynamic" part in the platform-browser name refers to its behavior of bringing in the JIT compiler)
So this means, currently JIT compiling is not expected to work out of the box when using standalone components only.
I'm not sure what you mean by "standalone components", as it's not what Angular describes as its standalone components using the standalone: true flag.
How would one, only import the compiler into a project ?
Using a direct import of @angular/compiler. Please be aware that including the JIT compiler has bundle size and performance overhead, as well as requiring the use of eval which introduces a security risk.
area: coreIssues related to the framework runtimeneeds: clarificationThis issue needs additional clarification from the reporter before the team can investigate.
Activity
JoostK commentedon Nov 8, 2022
I'm confused, this seems expected to me. The local, anonymous component declaration isn't supported for AOT compilation so it remains present for the JIT compiler to pick up, and the error is reported to indicate that the JIT compiler is not available.
Just the import from
@angular/platform-browser-dynamiccontains a transitive import for@angular/compiler, which contains a side-effectful module that makes the compiler available globally. So it's not becauseplatformBrowserDynamic().bootstrapModule({} as any)is included in the bundle, but rather that an import for@angular/platform-browser-dynamicis present (the "dynamic" part in the platform-browser name refers to its behavior of bringing in the JIT compiler)JeanMeche commentedon Nov 8, 2022
Yeah, I had the feeling that a transitive import would be the underlying reason. Thx for pointing it out.
So this means, currently JIT compiling is not expected to work out of the box when using standalone components only.
How would one, only import the compiler into a project ?
JoostK commentedon Nov 8, 2022
I'm not sure what you mean by "standalone components", as it's not what Angular describes as its standalone components using the
standalone: trueflag.Using a direct import of
@angular/compiler. Please be aware that including the JIT compiler has bundle size and performance overhead, as well as requiring the use ofevalwhich introduces a security risk.alxhub commentedon Nov 15, 2022
This is working as intended - to disable AOT and use JIT compilation, the Angular compiler must be imported dynamically:
angular-automatic-lock-bot commentedon Dec 16, 2022
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.