Skip to content
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

Chunk file error in lazy loading #213

Open
Asadullah213 opened this issue Dec 17, 2021 · 5 comments
Open

Chunk file error in lazy loading #213

Asadullah213 opened this issue Dec 17, 2021 · 5 comments
Assignees

Comments

@Asadullah213
Copy link

Asadullah213 commented Dec 17, 2021

Describe the bug
I have implemented lazy loading in my new app. It is creating the app with its lazy load chunk file. But when I click the link, it gives error message "Error: Uncaught (in promise): ChunkLoadError: Loading chunk projects_app4_src_app_component-two_component-two_module_ts failed."

Expected behavior
It should run the same way as app1 uses lazy loading on the user component

Screenshots
lazyload-error

  • OS: [Windows 10]
  • Browser [chrome]
@walkerkay
Copy link
Contributor

What is your angular version? Can you provide a demo?

@Asadullah213
Copy link
Author

Angular version 12

@why520crazy
Copy link
Member

it is a bug when one sub app enable lazy module and sandbox, you can set sandbox to "false" try it?

@why520crazy
Copy link
Member

why520crazy commented May 16, 2022

Possible reasons for this error are as follows:

  1. optimization.runtimeChunk is not set or set to true;
  2. vendorChunk of app's serve in angular.json set to true
  3. deploy-url is not set or set incorrectly, if app name is "app2" and route prefix is app2, should set it to /static/app2/ that same as proxy.conf.js, thestatic is a prefix that distinguished from router, it can be set to any value.
PROXY_CONFIG['/static/app2'] = {
    target: 'http://localhost:3002',
    secure: false,
    changeOrigin: true
};

Angular CLI deploy-url is deprecated for ng build and removed for ng serve in version 13, so need to use serve-path instead for ng serve and use output.publicPath instead for lazy load.

@qyjs
Copy link

qyjs commented Dec 9, 2022

Angular version 14

Describe the bug
I have implemented lazy loading in my new app. It is creating the app with its lazy load chunk file. But when I click the link, it gives error message "Error: Uncaught (in promise): ChunkLoadError: Loading chunk projects_app4_src_app_component-two_component-two_module_ts failed."

Expected behavior
It should run the same way as app1 uses lazy loading on the user component

Error: Uncaught (in promise): ChunkLoadError: Loading chunk projects_app1_src_app_user_user_module_ts failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants