Skip to content

Commit 70c608c

Browse files
authored
Merge pull request webpack#7387 from webpack/bugfix/record-string-ids
only record number ids
2 parents 8af0320 + 69567a1 commit 70c608c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/RecordIdsPlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class RecordIdsPlugin {
2121
if (!records.modules.byIdentifier) records.modules.byIdentifier = {};
2222
if (!records.modules.usedIds) records.modules.usedIds = {};
2323
for (const module of modules) {
24+
if (typeof module.id !== "number") continue;
2425
const identifier = portableIds
2526
? identifierUtils.makePathsRelative(
2627
compiler.context,
@@ -110,6 +111,7 @@ class RecordIdsPlugin {
110111
if (!records.chunks.bySource) records.chunks.bySource = {};
111112
const usedIds = new Set();
112113
for (const chunk of chunks) {
114+
if (typeof chunk.id !== "number") continue;
113115
const name = chunk.name;
114116
if (name) records.chunks.byName[name] = chunk.id;
115117
const sources = getChunkSources(chunk);

test/configCases/records/stable-sort/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ it("sorts the usedIds array to prevent churn", function() {
1010
var fs = require("fs");
1111
var path = require("path");
1212
var records = JSON.parse(fs.readFileSync(path.join(__dirname, "records.json"), "utf-8"));
13-
expect(records.chunks.usedIds).toEqual([0, "main", "split"]);
13+
expect(records.chunks.usedIds).toEqual([0, 1, 2]);
1414
});

test/configCases/records/stable-sort/webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ module.exports = {
77
__dirname,
88
"../../../js/config/records/stable-sort/records.json"
99
),
10+
optimization: {
11+
namedChunks: false
12+
},
1013
target: "node",
1114
node: {
1215
__dirname: false

0 commit comments

Comments
 (0)