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
-
bug confirmed issue
難度 2/5 1-3 小時 新手友好度 75/100
open-webui/open-webui#30750 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 75/100
-
難度 2/5 1-3 小時 新手友好度 70/100
-
難度 2/5 1-3 小時 新手友好度 75/100
-
Mend: dependency security vulnerability untriaged
難度 2/5 1-3 小時 新手友好度 70/100