Skip to content

Commit

Permalink
Merge pull request #7387 from webpack/bugfix/record-string-ids
Browse files Browse the repository at this point in the history
only record number ids
  • Loading branch information
sokra committed May 25, 2018
2 parents 8af0320 + 69567a1 commit 70c608c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/RecordIdsPlugin.js
Expand Up @@ -21,6 +21,7 @@ class RecordIdsPlugin {
if (!records.modules.byIdentifier) records.modules.byIdentifier = {};
if (!records.modules.usedIds) records.modules.usedIds = {};
for (const module of modules) {
if (typeof module.id !== "number") continue;
const identifier = portableIds
? identifierUtils.makePathsRelative(
compiler.context,
Expand Down Expand Up @@ -110,6 +111,7 @@ class RecordIdsPlugin {
if (!records.chunks.bySource) records.chunks.bySource = {};
const usedIds = new Set();
for (const chunk of chunks) {
if (typeof chunk.id !== "number") continue;
const name = chunk.name;
if (name) records.chunks.byName[name] = chunk.id;
const sources = getChunkSources(chunk);
Expand Down
2 changes: 1 addition & 1 deletion test/configCases/records/stable-sort/test.js
Expand Up @@ -10,5 +10,5 @@ it("sorts the usedIds array to prevent churn", function() {
var fs = require("fs");
var path = require("path");
var records = JSON.parse(fs.readFileSync(path.join(__dirname, "records.json"), "utf-8"));
expect(records.chunks.usedIds).toEqual([0, "main", "split"]);
expect(records.chunks.usedIds).toEqual([0, 1, 2]);
});
3 changes: 3 additions & 0 deletions test/configCases/records/stable-sort/webpack.config.js
Expand Up @@ -7,6 +7,9 @@ module.exports = {
__dirname,
"../../../js/config/records/stable-sort/records.json"
),
optimization: {
namedChunks: false
},
target: "node",
node: {
__dirname: false
Expand Down

0 comments on commit 70c608c

Please sign in to comment.