Providing __system_context__ when an entry point sets library.type = 'system'
See original GitHub issueBug report
What is the current behavior?
When setting library.type
per entry point, __system_context__
is not set for SystemJS entry points and compilation sometimes fails.
If the current behavior is a bug, please provide the steps to reproduce.
The easiest way to reproduce this is by changing the test in configCases/target/system-context
.
The original config:
/** @type {import("../../../../").Configuration} */
module.exports = {
output: {
library: {
type: "system"
}
},
node: {
__dirname: false,
__filename: false
}
};
I would expect the following config to behave the same:
/** @type {import("../../../../").Configuration} */
module.exports = {
entry: {
main: {
import: "./index.js",
library: {
type: "system"
}
}
},
node: {
__dirname: false,
__filename: false
}
};
But it causes an error:
TypeError: Cannot read property 'type' of undefined
219 | .for(RuntimeGlobals.systemContext)
220 | .tap("RuntimePlugin", chunk => {
> 221 | if (compilation.outputOptions.library.type === "system") {
| ^
222 | compilation.addRuntimeModule(
223 | chunk,
224 | new SystemContextRuntimeModule()
at lib/RuntimePlugin.js:221:44
at Hook.eval (eval at create (node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:13:16)
at Hook.CALL_DELEGATE [as _call] (node_modules/tapable/lib/Hook.js:14:14)
at Compilation.processRuntimeRequirements (lib/Compilation.js:2848:7)
at lib/Compilation.js:2477:12
at lib/Compilation.js:2680:5
at node_modules/neo-async/async.js:2818:7
at done (node_modules/neo-async/async.js:3522:9)
at lib/Compilation.js:2660:7
at lib/Compilation.js:2748:32
If there is another library.type
set under output
then the compilation is successful, but __system_context__
is undefined when running the application.
What is the expected behavior?
Compilation does not fail when output.library.type
is not set. __system_context__
is available for entry points with library.type = 'system'
.
Other relevant information: webpack version: 5.40.0 Node.js version: 14.17.0 Operating System: macOS 11.4 Additional tools:
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top GitHub Comments
It looks like the docs already mentioned that it’s deprecated. I think the test was written before that though.
bump