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

dependency-extraction-webpack-plugin breaks when using optimizations.runtimeChunk = 'single' #24352

Closed
stefanfisk opened this issue Aug 4, 2020 · 5 comments
Assignees
Labels
[Status] In Progress Tracking issues with work in progress [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin [Type] Build Tooling Issues or PRs related to build tooling

Comments

@stefanfisk
Copy link
Contributor

stefanfisk commented Aug 4, 2020

Describe the bug

@wordpress/dependency-extraction-webpack-plugin breaks in two ways when using optimizations.runtimeChunk = 'single'.

  1. The asset files are named based on the runtime chunk's name, i.e. runtime.asset.php.
  2. All asset files are added to the runtime chunk.

The first issue results in only the last entrypoint's asset being saved (as it overwrites the previous ones').

The second issue makes it impossible to correlate an asset file with its entrypoint.

To reproduce

I've created an example project here: https://github.com/stefanfisk/wordpress-dependency-extraction-webpack-plugin-runtimechunk-single-bug

Expected behavior

The asset files should be named according to the entrypoint names, and only be added to the entrypoint chunks.

Preferably it should be possible to configure the asset file names. For example it would be nice if using hashes in output.filename did not result in the asset filename containing a hash.

Plugin version:

  • @wordpress/dependency-extraction-webpack-plugin 2.8.0
  • webpack 4.44.1
@stefanfisk
Copy link
Contributor Author

I've got a quick and dirty fix going here: https://github.com/stefanfisk/gutenberg/tree/fix/24352-dependency-extraction-runtimechunk-single

Since I don't quite grok the internals of Webpack It's probably broken in ways I cannot fathom, so I'm refraining from opening a PR for now.

@ellatrix ellatrix added the [Type] Build Tooling Issues or PRs related to build tooling label Aug 17, 2020
@gziolo gziolo added the [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin label Oct 14, 2020
@gziolo
Copy link
Member

gziolo commented Oct 14, 2020

@sirreal, any chances you could have a look at this issue?

@sirreal
Copy link
Member

sirreal commented Oct 15, 2020

@stefanfisk if you have a working change would you like to open a PR? It would be nice to have something to start from.

I don't have much bandwidth to dedicate to this myself, but I'll support with guidance and reviews as much as possible.

@slightlyfaulty
Copy link

Actually, this breaks when any entrypoints share a runtime, e.g. when using dependOn. Because runtimeChunk is used to determine the output filename instead of entrypointChunk, the output filenames clash and get overridden.

I've tested @stefanfisk's PR and it works great. Would be amazing if we could finally get it merged.

Maybe it's just me, but I don't see how efficient code-splitting has ever been possible while this issue exists??

@gziolo
Copy link
Member

gziolo commented Nov 24, 2021

I've tested @stefanfisk's PR and it works great. Would be amazing if we could finally get it merged.

Thank you for the reminder and for testing the patch proposed. Let's see what we can do to move it forward 👍🏻

@gziolo gziolo closed this as completed in d2d673d Nov 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress [Tool] Dependency Extraction Webpack Plugin /packages/dependency-extraction-webpack-plugin [Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

No branches or pull requests

5 participants