-
Notifications
You must be signed in to change notification settings - Fork 12k
ChunkLoadError After updating Angular 13.1 #22358
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
Could you please share a reproduction? |
I am facing the same issue. One lazy loaded module can not be loaded by the browser. What I see is a difference in which chunks "ng serve" is creating. With cli 13.0.4 it looks like this Chunk: With cli 13.1.1 it looks like this Chunk: However, the browser still tries to load the chunk, which is missing then |
@imario42, maybe you can try to copy the problematic lazy module in a new project and see if the problem persists? If it does, clean it up as much as you can. I suspect that this issue is being caused by #22239 or #22297 but we’ll need a reproduction to find the root cause unless someone wants to debug 😀 |
I tried to narrow it down as much as I can now. Trying to create a reproducible tomorrow. What I found out is: That module is using the monaco editor. As soon as I start to directly use its enums like If I replace the enums using their integer representation in my code the bundle size drops to 200k and it works again correctly. |
This project can be used to reproduce that issue https://github.com/imario42/largeChunk.git In With the large chunk, the navigation will fail with an error in the browser. With the small chunk it works. |
The root cause of the issue seems to be that certain libraries import css files as if they were ECMA modules Example: import './foo.css'; But in a browser/node this is non valid syntax as this syntax is highly dependent on Webpack being used as a bundler. This also happened to work by accident in the CLI and like other Webpack specific features are not supported. Please file an issue with the author of the library to remove the dependency on Webpack specific features as this would break if another bundler is used. Libraries should not be dependent on a specific bundler feature to work. The fact that the CLI is using Webpack is an implementation detail that can change in the future. |
@alan-agius4 thank you for your hard work! Do you have any guidelines on what lib authors should do instead? The fullcalendar-angular authors, for example, seem to have some challenges in terms of importing CSS. See https://github.com/fullcalendar/fullcalendar-angular/blob/master/projects/fullcalendar/src/lib/fullcalendar.component.scss Thanks! |
@nunoarruda, I am not familiar with fullcalendar and typically there are 3 ways how to consume CSS.
The problem with |
…specified in `styles` option This fixes an issue were in some cases when importing CSS in the compilation using import syntax caused CSS to be extracted which causes a runtime error. In general this is not something that we fully support since this is a specific webpack features and importing CSS as if they were ES modules not supported by the browsers. However, certain widely using libraries such as Monaco editor depend on this specific Webpack feature. Note: This non-standard unsupported behaviour will no longer be possible in the next major version. Closes #22358 (cherry picked from commit f1d2873)
…specified in `styles` option This fixes an issue were in some cases when importing CSS in the compilation using import syntax caused CSS to be extracted which causes a runtime error. In general this is not something that we fully support since this is a specific webpack features and importing CSS as if they were ES modules not supported by the browsers. However, certain widely using libraries such as Monaco editor depend on this specific Webpack feature. Note: This non-standard unsupported behaviour will no longer be possible in the next major version. Closes #22358
but why it was working before? |
For the time being we did a workaround to allow the above behaviour, but this potentially it will be removed in the future via #22363. Because it worked, it doesn’t mean it is a supported. The above works because the underlying bundling tool is Webpack which allows such behaviour. The Angular CLI doesn’t support Webpack specific features. |
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. |
Which @angular/* package(s) are the source of the bug?
compiler-cli, compiler
Is this a regression?
Yes
Description
After updating to Angular 13.1, CunkLoadError occurs when loading some modules.
It looks like the wrong js file was exported at build time.
css,
looks wrong...Below is the exported file name
Below is the code for the applicable Routes
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: