-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Worker() imports chunks further imports #11768
Comments
For maintainers only:
|
Why do you need that? Webpack is optimizing lodash into a shared chunk between main and worker so you don't have to download it twice. The optimization.splitChunks option allows to control that. |
The extra request is not necessary since there is no code shared between the two bundles.
It's not used by the main thread code ( However, having looked into this, I think this issue may be invalid, assuming my understanding of the following is correct.
Is that correct? |
yes except optimization.splitChunks.maxSize sets the maximum size in bytes treshold to split a chunk and has a default of 0 not 1. @birtles i just checked out your test repo and saw that you already fixed it 👍 i think we may close the issue? |
Yes, sorry, I meant
Yes, sorry for the noise! |
Ah I see. So this is vendor splitting for better long term caching. You can disable it with |
Bug report
What is the current behavior?
When using webpack's native Worker loader, imports from within the worker are split into chunks.
If the current behavior is a bug, please provide the steps to reproduce.
git clone https://github.com/birtles/webpack-worker-test
yarn install
cd webpack-worker-test
npx webpack
ls -al dist
worker.js
) has been split into a separate chunk.What is the expected behavior?
There should be a single worker bundle.
The background is I have a project where I produce exactly two files: the main thread JS, and the worker bundle.
Previously I was using GoogleChromeLabs/worker-plugin for this but it no longer works after upgrading to webpack 5 (#88).
I have tried to replace worker-plugin with webpack 5's native
Worker()
support but I cannot get it to produce a single worker bundle (despite successfully producing a single main thread bundle). I have tried all the optionswebpackEntrypoints
,workerChunkLoading
etc.(I have tried to produce a minimal test case but I may not have accurately recreated the original problem in the process. The original file is something more like this one.)
Other relevant information:
webpack version: 5.1.3 (CLI: 4.0.0)
Node.js version: 12.14.0
Operating System: Windows 10 Pro (WSL)
Additional tools: (Although likely unrelated to this issue the project I am working on also uses TypeScript, html-webpack-plugin, copy-webpack-plugin, clean-webpack-plugin, mini-css-extract-css-plugin, purge-css)
The text was updated successfully, but these errors were encountered: