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

@wordpress/scripts: loading async chunks using import fails when they import styles and webpackChunkName is used (FixStyleWebpackPlugin?) #32203

Closed
tw-360vier opened this issue May 25, 2021 · 2 comments · Fixed by #33818
Labels
Needs Testing Needs further testing to be confirmed. [Tool] WP Scripts /packages/scripts

Comments

@tw-360vier
Copy link

Description

When building my project with @wordpress/scripts i encounter the following problem:
loading async chunks using import() fails when they import styles and webpackChunkName is used to give the chunk a proper name.

Step-by-step reproduction instructions

Here i have created a minimal project to reproduce the issue: https://github.com/tw-360vier/wp-scripts-FixStyleWebpackPlugin-chunk-load-error

Expected behaviour

I expect the chunk to be loaded without error.

Actual behaviour

i encounter the following error:

index.js:1 Uncaught (in promise) ChunkLoadError: Loading chunk 2 failed.
(error: http://127.0.0.1:8080/style-my-chunk.js)
    at Function.u.e (http://127.0.0.1:8080/index.js:1:1662)
    at Object.<anonymous> (http://127.0.0.1:8080/index.js:1:3148)
    at u (http://127.0.0.1:8080/index.js:1:369)
    at http://127.0.0.1:8080/index.js:1:3106
    at http://127.0.0.1:8080/index.js:1:3115
u.e @ index.js:1
(anonymous) @ index.js:1
u @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1
Promise.then (async)
(anonymous) @ index.js:1
u @ index.js:1
(anonymous) @ index.js:1
(anonymous) @ index.js:1

Removing "FixStyleWebpackPlugin" from the webpack config fixes the issue, so it seems like it is related to that.

@gziolo gziolo added [Tool] WP Scripts /packages/scripts Needs Testing Needs further testing to be confirmed. labels Jun 7, 2021
@gziolo
Copy link
Member

gziolo commented Jun 7, 2021

It's one of the issues that might get resolved when we upgrade to webpack 5. FixStyleWebpackPlugin is only necessary for webpack 4 and while it addresses some other concerns it might cause other issues.

@gziolo
Copy link
Member

gziolo commented Aug 3, 2021

We are in the process of upgrading webpack to the next major version v5 in #33818. FixStyleWebpackPlugin plugin is going to be removed so it should resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Testing Needs further testing to be confirmed. [Tool] WP Scripts /packages/scripts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants