Can't apply plugins to worker
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 28/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, webpack
- Domain
- build-system, tooling
Research direction
Start in src/index.js around the createChildCompiler call at line 59 and review webpack's Compiler.js child-compiler behavior at the linked lines. Trace how worker child compilers are created and determine how a plugin list could be supplied without affecting unrelated child compilers. Done means worker builds can receive plugins such as CompressionPlugin, with coverage for the supported configuration.
Written by the indexing model from the issue text.
Description
Currently there is no way to pass plugins to workerize-loader.
Webpack's documentation is wrong when it states that child compilers inherit all hooks and plugins from the parent compiler. They infact do not inherit plugins at all; they copy over a number of hooks from the parent compiler -- where some plugins may have added them -- to the child compiler.
Several hooks are blacklisted. Banned from this copy process are: make, compile, emit, afterEmit, invalid, done, and thisCompilation. There are ofcourse good reasons not to copy those hooks - as doing so would mess with the control flow for the child compilation and parent compilation. However, it does mean the child compiler has to be fed its own instances of plugins such as the CompressionPlugin which attach to those hooks.
This is what the third plugins argument to the createChildCompiler method is for, but having a look at how the child compiler that creates the body of the worker is called:
it doesn't link up that third parameter. So right now there is no well-defined way to e.g. apply CompressionPlugin and get Gzip or Brotli compressed workers.
It may still be possible to achieve this by tapping the childCompiler hook on the parent compilation, as it does get passed the created child compiler.
This requires people write their own custom "plugin to apply plugins" - which is well beyond the comfort zone of most Webpack users. (Most webpack users don't write their own plugins. That's something you typically only do if you really; really know what you're doing. )
It's also not exactly trivial to get right, as you'd still also need to filter by the child compiler's name to ensure they're only adding plugins to the correct child compilers created by the workerize-loader and not to e.g. those created by the MiniCssExtractPlugin. Making this worse is the fact that those child compiler names are internal implementation details and not part of any public API, i.e. are subject to change over time.
I.e. this is a short-term workaround at best.
- Dominant language
- JavaScript
- Stars
- 2.3k
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from developit/workerize-loader
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
developit/workerize-loader#131 · 6 comments · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
developit/workerize-loader#130 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
developit/workerize-loader#129 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
developit/workerize-loader#128 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
developit/workerize-loader#126 · 4 comments ·
All issues in developit/workerize-loader
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
mksglu/context-mode#1200 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
neondatabase/website#5944 ·
-
module: core
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
bigbluebutton/bigbluebutton#25849 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
jaegertracing/jaeger-ui#4506 ·