Skip to content

Commit 73834df

Browse files
committed
test: switch hash-order regression to watch case
1 parent 1818881 commit 73834df

7 files changed

Lines changed: 67 additions & 161 deletions

File tree

test/RealContentHashPlugin.test.js

Lines changed: 0 additions & 161 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./shared.js";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import "./shared.js";
2+
3+
it("should update the runtime chunk filename map on rebuild", () => {
4+
const currentChunkFile = Array.isArray(STATS_JSON.assetsByChunkName.js)
5+
? STATS_JSON.assetsByChunkName.js[0]
6+
: STATS_JSON.assetsByChunkName.js;
7+
const serviceWorkerSource = readOutputFile("service-worker.js");
8+
9+
expect(currentChunkFile).toBeTruthy();
10+
11+
if (WATCH_STEP === "0") {
12+
STATE.previousChunkFile = currentChunkFile;
13+
} else {
14+
expect(currentChunkFile).not.toBe(STATE.previousChunkFile);
15+
}
16+
17+
expect(serviceWorkerSource).toContain(currentChunkFile);
18+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const sharedValue = "__SHARED__";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const sharedValue = "__SHARED__CHANGED";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use strict";
2+
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
module.exports = {
7+
findBundle() {
8+
return "./service-worker.js";
9+
},
10+
moduleScope(scope, options) {
11+
scope.readOutputFile = (filename) =>
12+
fs.readFileSync(path.join(options.output.path, filename), "utf8");
13+
}
14+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use strict";
2+
3+
/** @type {import("../../../../").Configuration} */
4+
module.exports = {
5+
mode: "production",
6+
target: "webworker",
7+
cache: {
8+
type: "memory"
9+
},
10+
entry: {
11+
"service-worker": {
12+
import: "./service-worker.js",
13+
chunkLoading: "import-scripts",
14+
filename: "service-worker.js"
15+
},
16+
offscreen: "./offscreen.js"
17+
},
18+
output: {
19+
clean: false,
20+
filename: "[name].[contenthash].js",
21+
pathinfo: false
22+
},
23+
optimization: {
24+
realContentHash: false,
25+
sideEffects: false,
26+
splitChunks: {
27+
chunks: "all",
28+
minSize: 1,
29+
name: "js"
30+
}
31+
}
32+
};

0 commit comments

Comments
 (0)