-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Runtime compiler breaks in --prod builds when CommonModule in imports #27584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a duplicate of #27405, with the same resolution - this is not supported in Angular today, but will likely work in Ivy. |
That's because Angular changed how it distributes artefacts in 6.1.8 version. Compare: 6.1.7 https://unpkg.com/@angular/common@6.1.7/fesm5/common.js
6.1.8 https://unpkg.com/@angular/common@6.1.8/fesm5/common.js
So to make it work you have to use reflect polyfills. Try adding |
@alexzuza - that completely solves my problem! Thank you!! Adding For others: Note that running dynamically compiled components with "buildOptimizer": false, in the I've updated https://github.com/johncrim/angular-dynamic-styleguide in the hopes this can help others with dynamic components in AOT/--prod builds. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
bug report
Affected Package
This issue is most likely caused by @angular/common; could be @angular/compiler
Is this a regression?
Don't know - I have not tested this issue in previous versions. I can repro it in the latest versions of angular: 7.1.0
Description
Use case: Using dynamic components and modules in --prod builds fails as follows. Non-prod builds are fine.
I have a pared-down repro site here:
https://github.com/johncrim/angular-dynamic-styleguide
It uses components that are compiled at runtime to display template markup next to working examples of the template markup.
This is an @angular/cli created project.
The
AppComponent
displays a sequence of 3 dynamically compiled components, which are all included in a single dynamically compiled module listed below. AppComponent renders fine in --prod mode whenCommonModule
is not imported by the dynamic module. WhenCommonModule
is imported:... the below exception is thrown.
🔬 Minimal Reproduction
git clone https://github.com/johncrim/angular-dynamic-styleguide
yarn
yarn start --prod
(launch browser - works)
In
template-examples.service.ts
, line 66, uncomment the//imports: [MatIconModule, CommonModule]
line, and comment out the previousimports:
line - error occurs.🔥 Exception or Error
🌍 Your Environment
Angular Version:
Anything else relevant?
Additional Background:
https://blog.angularindepth.com/here-is-what-you-need-to-know-about-dynamic-components-in-angular-ac1e96167f9e
https://github.com/apoterenko/ngx-dynamic-template
I've tested examples based on the article, and the ngx-dynamic-template component. They fail in the same way in --prod builds.
The text was updated successfully, but these errors were encountered: