Skip to content

Angular generates chunks with no content on production build causes deployment issues related to MIME type #30376

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

Open
tibin-carestack opened this issue May 22, 2025 · 2 comments
Labels
needs: repro steps We cannot reproduce the issue with the information given

Comments

@tibin-carestack
Copy link

Which @angular/* package(s) are the source of the bug?

Don't known / other

Is this a regression?

Yes

Description

Angular 19 production builds (ng build --configuration production) are sometimes generating empty (0-byte) or malformed JavaScript chunk files (chunk-XXXXX.js). When deployed, browsers attempt to load these, resulting in "Failed to load module script: The server responded with a non-JavaScript MIME type" errors because the server serves an incorrect MIME type (e.g., text/html). This prevents the application from loading and causes significant deployment issues.

Impact: Application failure to load in production, broken user experience, difficult debugging due to misleading MIME type errors.

Expected Behavior: All production build chunks should contain valid JavaScript content and be served with text/javascript MIME type.

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)

Angular CLI: 19.2.13
Node: 20.18.0
Package Manager: npm 11.1.0
OS: win32 x64

Angular: 19.2.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1402.13
@angular-devkit/build-angular   19.2.13
@angular-devkit/core            19.2.13
@angular-devkit/schematics      19.2.13
@angular/cdk                    19.2.8
@angular/cli                    19.2.13
@schematics/angular             19.2.13
rxjs                            7.8.2
typescript                      5.8.2
zone.js                         0.15.0

Anything else?

No response

@JeanMeche JeanMeche transferred this issue from angular/angular May 22, 2025
@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label May 22, 2025
@alan-agius4
Copy link
Collaborator

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

@clydin
Copy link
Member

clydin commented May 22, 2025

Content types are not controlled by the Angular application. Rather they are produced as response headers by the server and/or service hosting the application files.
Errors such as shown above typically indicate a misconfigured server and/or SPA fallback rule.

As mentioned in the previous comment, please provide a minimal reproduction demonstrating the output file issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: repro steps We cannot reproduce the issue with the information given
Projects
None yet
Development

No branches or pull requests

3 participants