Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,25 @@ class ReactFlightWebpackPlugin {
});
compilation.chunkGroups.forEach(function (chunkGroup) {
function recordModule(id, module) {
resolvedClientFiles.has(module.resource) &&
if (
resolvedClientFiles.has(module.resource) &&
((module = url.pathToFileURL(module.resource).href),
void 0 !== module &&
(filePathToModuleMetadata[module] = {
void 0 !== module)
)
if (filePathToModuleMetadata[module]) {
id = filePathToModuleMetadata[module];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable shadowing: reusing id parameter name to store metadata object reduces readability

Suggested change
id = filePathToModuleMetadata[module];
const existing = filePathToModuleMetadata[module];

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

module = new Set();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variable shadowing: reusing module parameter name to store Set object reduces readability

Suggested change
module = new Set();
const existingChunkIds = new Set();

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

for (var i = 0; i < id.chunks.length; i += 2)
module.add(id.chunks[i]);
Comment on lines +251 to +252
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use descriptive variable name in the merge loop

Suggested change
for (var i = 0; i < id.chunks.length; i += 2)
module.add(id.chunks[i]);
for (var existingIdx = 0; existingIdx < existing.chunks.length; existingIdx += 2)
existingChunkIds.add(existing.chunks[existingIdx]);

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

for (i = 0; i < chunks.length; i += 2)
module.has(chunks[i]) ||
id.chunks.push(chunks[i], chunks[i + 1]);
Comment on lines +253 to +255
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use descriptive variable name and clearer condition formatting

Suggested change
for (i = 0; i < chunks.length; i += 2)
module.has(chunks[i]) ||
id.chunks.push(chunks[i], chunks[i + 1]);
for (var newIdx = 0; newIdx < chunks.length; newIdx += 2) {
if (!existingChunkIds.has(chunks[newIdx])) {
existing.chunks.push(chunks[newIdx], chunks[newIdx + 1]);
}
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

} else
filePathToModuleMetadata[module] = {
id,
chunks,
chunks: chunks.slice(),
name: "*"
}));
};
}
const chunks = [];
chunkGroup.chunks.forEach(function (c) {
Expand Down