mirror of https://github.com/webpack/webpack.git
fix: hotUpdate chunk modified with new runtime should have correct runtime
This commit is contained in:
parent
e237b580e2
commit
03f8bf71bf
|
@ -686,7 +686,9 @@ class HotModuleReplacementPlugin {
|
|||
if (backCompat)
|
||||
ChunkGraph.setChunkGraphForChunk(hotUpdateChunk, chunkGraph);
|
||||
hotUpdateChunk.id = chunkId;
|
||||
hotUpdateChunk.runtime = newRuntime;
|
||||
hotUpdateChunk.runtime = currentChunk
|
||||
? currentChunk.runtime
|
||||
: newRuntime;
|
||||
if (currentChunk) {
|
||||
for (const group of currentChunk.groupsIterable)
|
||||
hotUpdateChunk.addGroup(group);
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
let value = require("./module.js");
|
||||
import {a} from "./lib/a.js";
|
||||
|
||||
it("should compile", (done) => {
|
||||
expect(value).toBe(1);
|
||||
expect(a).toBe(1);
|
||||
module.hot.accept("./module.js", () => {
|
||||
value = require("./module");
|
||||
expect(value).toBe(2);
|
||||
done();
|
||||
});
|
||||
NEXT(require("../../update")(done));
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
export const a = 1
|
|
@ -0,0 +1 @@
|
|||
export const b = 1
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"sideEffects": true
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = 1;
|
||||
---
|
||||
new Worker(new URL('./worker.js', import.meta.url))
|
||||
module.exports = 2;
|
|
@ -0,0 +1,8 @@
|
|||
var supportsWorker = require("../../../helpers/supportsWorker");
|
||||
|
||||
module.exports = function (config) {
|
||||
if (config.target !== "web") {
|
||||
return false;
|
||||
}
|
||||
return supportsWorker();
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
module.exports = {
|
||||
optimization: {
|
||||
usedExports: true,
|
||||
// make 'lib' chunk runtime to be worker + entry
|
||||
splitChunks: {
|
||||
minSize: 0,
|
||||
chunks: "all",
|
||||
cacheGroups: {
|
||||
lib: {
|
||||
test: /[/\\]lib[/\\](a|b|index).js$/,
|
||||
name: "lib",
|
||||
filename: "bundle-lib.js"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
|
@ -0,0 +1,2 @@
|
|||
import {b} from "./lib/b.js";
|
||||
b;
|
Loading…
Reference in New Issue