Can't apply plugins to worker
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 28/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- javascript, webpack
- 领域
- build-system, tooling
调研方向
从 src/index.js 中第 59 行附近的 createChildCompiler 调用开始,检查链接行中 webpack's Compiler.js 的子编译器行为。跟踪 worker 子编译器的创建方式,并确定如何提供插件列表而不影响无关的子编译器。当 worker 构建可以接收 CompressionPlugin 等插件,并且对受支持的配置有覆盖时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- JavaScript
- 星标
- 2.3k
- 派生
- 85
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
developit/workerize-loader 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 25/100
developit/workerize-loader#131 · 6 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 38/100
developit/workerize-loader#130 ·
-
难度 2/5 1-3 小时 新手友好度 52/100
developit/workerize-loader#129 ·
-
难度 4/5 3-5 天 新手友好度 35/100
developit/workerize-loader#128 ·
-
难度 4/5 3-5 天 新手友好度 25/100
developit/workerize-loader#126 · 4 条评论 ·
查看 developit/workerize-loader 的全部 Issue
相似的 Issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 70/100
georgestephanis/p2026#40 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·