[path] replacer token passed to workerize-loader has stopped working in Webpack 5
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 38/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, webpack
- Domain
- build-system, tooling
Research direction
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.
Written by the indexing model from the issue text.
Description
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]"
}
}
})
- 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 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 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
developit/workerize-loader#125 · 2 comments · 1 reaction ·
All issues in developit/workerize-loader
Similar issues
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/safe-publish#594 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
dream-num/dsh-univer-office#104 ·
-
comp/dashboard invalid P3
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
NousResearch/hermes-agent#121143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
avniproject/avni-webapp#1811 ·
-
area/auroraboot area/webui bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100