[path] replacer token passed to workerize-loader has stopped working in Webpack 5
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 38/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, webpack
- 領域
- build-system, tooling
研究方向
使用此處描述的裸 loader URL 和 [path][name].[contenthash] 範本,在 Webpack 5 下重現 workerize-loader 的問題。追蹤 loader 如何處理其 name 選項,並將 [path] 與可正常運作的 [name] 和 [contenthash] token 進行比較;當 worker 輸出能保留相對於來源檔案的路徑,且不需要從外部注入選項時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Used to be the case with Webpack 4 that we could pass [path][name].[contenthash] as the name template for workerize-loader to use; and we'd get workers output into a folder structure mirroring their original source location.
This was nice for debugging purposes to easily identify workers, because the entry point file for esp. larger workers is usually some kind of index.js file. [path] means you don't need to inspect every separate worker named index.[hash].worker.js - and it prevented name collisions when you would generate names in development builds without hash fingerprints in them.
As of Webpack 5, that functionality appears to be broken. It resolves [name] and [contenthash] just fine, but doesn't know how to deal with [path].
I'm using a plugin to dynamically inject options into loaders to configure bare loader URLs such as
import worker from "workerize-loader!./path-to/worker"
centrally, and luckily I was able to extend the logic there to use the current compilation context and module context to compute a relative path, but yeah... this is not very ergonomic, easily understood or maintainable:
new InjectOptionsPlugin({
loaders : {
"workerize-loader" : ( module, compilation ) => {
const context = path
.relative( compilation.options.context, module.context );
.replace( /\\/g, "/" );
return {
name : dev ? `${context}[name]` : "${context}[name].[contenthash]`
};
}
}
})
compared to what it used to be:
new InjectOptionsPlugin({
loaders : {
"workerize-loader" : {
name : dev ? "[path][name]" : "[path][name].[contenthash]"
}
}
})
- 主要語言
- JavaScript
- 星號
- 2.3k
- 分支
- 85
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
developit/workerize-loader 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 25/100
developit/workerize-loader#131 · 6 則留言 · 1 個 reaction ·
-
難度 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 則留言 ·
-
難度 4/5 3-5 天 新手友好度 25/100
developit/workerize-loader#125 · 2 則留言 · 1 個 reaction ·
查看 developit/workerize-loader 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
woocommerce/woocommerce-google-analytics-integration#699 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
t0ggles
難度 2/5 1-3 小時 新手友好度 70/100
nolimits4web/swiper#8240 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 62/100
Inter-Actief/amelink#131 ·