-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Labels
questionFurther information is requestedFurther information is requestedupstreamThe issue is controlled by an upstream dependencyThe issue is controlled by an upstream dependency
Description
According to the docs:
By default, WorkerPlugin doesn't run any of your configured Webpack plugins when bundling worker code
However, this doesn't seem to be true. Consider the following partial config:
plugins: [
new webpack.DefinePlugin({
_A_: JSON.stringify('this text should never appear in worker'),
}),
new WorkerPlugin({
plugins: [
new webpack.DefinePlugin({
_B_: JSON.stringify('this text should definitely appear in worker'),
}),
],
}),
]Given the documentation, the expectation would be that:
- In the worker:
_A_is untouched_B_is replaced with'this text should definitely appear in worker'
- Everywhere else:
_A_is replaced with'this text should never appear in worker'_B_is untouched
However, in all code _A_ is replaced with 'this text should never appear in worker' and _B_ is untouched.
This is apparently because the DefinePlugin is using hooks that are copied into the child compiler created by WorkerPlugin (see createChildCompiler()).
For background, my actual use case is to use ProvidesPlugin (not DefinePlugin) to replace a free variable with a different implementation (module) in workers vs elsewhere.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requestedupstreamThe issue is controlled by an upstream dependencyThe issue is controlled by an upstream dependency