Skip to content

Commit f392dee

Browse files
test: small refactor
1 parent de13ec9 commit f392dee

3 files changed

Lines changed: 12 additions & 6 deletions

File tree

.changeset/public-horses-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"webpack": patch
3+
---
4+
5+
Hash initial chunks before runtime chunks.

test/watchCases/cache/stale-runtime-chunk-filename-map/0/service-worker.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import "./shared.js";
22

33
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");
4+
const currentChunkFile = STATS_JSON.assetsByChunkName.js[0];
5+
const serviceWorkerSource = getServiceWorkerSource();
86

97
expect(currentChunkFile).toBeTruthy();
108

test/watchCases/cache/stale-runtime-chunk-filename-map/test.config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ module.exports = {
88
return "./service-worker.js";
99
},
1010
moduleScope(scope, options) {
11-
scope.readOutputFile = (filename) =>
12-
fs.readFileSync(path.join(options.output.path, filename), "utf8");
11+
scope.getServiceWorkerSource = () =>
12+
fs.readFileSync(
13+
path.join(options.output.path, "service-worker.js"),
14+
"utf8"
15+
);
1316
}
1417
};

0 commit comments

Comments
 (0)