developit / developit/workerize-loader
[path] replacer token passed to workerize-loader has stopped working in Webpack 5
- 主要言語
- JavaScript
- スター
- 2.3k
- フォーク
- 85
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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
```js
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:
```js
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:
```js
new InjectOptionsPlugin({
loaders : {
"workerize-loader" : {
name : dev ? "[path][name]" : "[path][name].[contenthash]"
}
}
})
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Reproduce the issue with workerize-loader under Webpack 5 using the bare loader URL and the `[path][name].[contenthash]` template described here. Trace how the loader handles its name option and compare `[path]` with the working `[name]` and `[contenthash]` tokens; done means worker output preserves source-relative paths without requiring external option injection.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript, webpack
- 領域
- build-system, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100