Skip to content

Commit 8b0160c

Browse files
test: type the foreign runtime module case against the public entry
`tsc -p tsconfig.types.test.json` reads a test's webpack imports as the generated types, so importing `RuntimeModule` from `lib/` made the instance unassignable to `addRuntimeModule`. Shadowing the method on the instance rather than defining it away on the prototype types cleanly too.
1 parent bddf2bd commit 8b0160c

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

‎test/configCases/runtime/foreign-runtime-module-dispatch/webpack.config.js‎

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use strict";
22

3-
const RuntimeGlobals = require("../../../../lib/RuntimeGlobals");
4-
const RuntimeModule = require("../../../../lib/RuntimeModule");
3+
const RuntimeGlobals = require("../../../../").RuntimeGlobals;
4+
const RuntimeModule = require("../../../../").RuntimeModule;
55

66
const PLUGIN_NAME = "ForeignRuntimeModuleTestPlugin";
77

@@ -19,11 +19,6 @@ class ForeignChunkHandlerRuntimeModule extends RuntimeModule {
1919
}
2020
}
2121

22-
// A module built against an older webpack extends a base class predating
23-
// `getInstalledChunkHandlers`, so looking it up on the instance finds nothing.
24-
ForeignChunkHandlerRuntimeModule.prototype.getInstalledChunkHandlers =
25-
undefined;
26-
2722
/** @type {import("../../../../").Configuration} */
2823
module.exports = {
2924
target: "node",
@@ -37,10 +32,12 @@ module.exports = {
3732
PLUGIN_NAME,
3833
(chunk, set) => {
3934
set.add(RuntimeGlobals.ensureChunkHandlers);
40-
compilation.addRuntimeModule(
41-
chunk,
42-
new ForeignChunkHandlerRuntimeModule()
43-
);
35+
const foreign = new ForeignChunkHandlerRuntimeModule();
36+
// A module built against an older webpack extends a base class
37+
// predating this, so looking it up on the instance finds nothing.
38+
/** @type {Partial<RuntimeModule>} */
39+
(foreign).getInstalledChunkHandlers = undefined;
40+
compilation.addRuntimeModule(chunk, foreign);
4441
}
4542
);
4643
});

0 commit comments

Comments
 (0)