Skip to content

Commit c4d64ab

Browse files
committed
Set null prototype on perf-critical classes
1 parent 94c0f0b commit c4d64ab

6 files changed

+22
-3
lines changed

lib/BasicEvaluatedExpression.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,6 @@ class BasicEvaluatedExpression {
208208
}
209209
}
210210

211+
Object.setPrototypeOf(BasicEvaluatedExpression.prototype, null);
212+
211213
module.exports = BasicEvaluatedExpression;

lib/Chunk.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,8 @@ class Chunk {
694694
}
695695
}
696696

697+
Object.setPrototypeOf(Chunk.prototype, null);
698+
697699
// TODO remove in webpack 5
698700
Object.defineProperty(Chunk.prototype, "forEachModule", {
699701
configurable: false,

lib/ChunkGroup.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,4 +470,6 @@ class ChunkGroup {
470470
}
471471
}
472472

473+
Object.setPrototypeOf(ChunkGroup.prototype, null);
474+
473475
module.exports = ChunkGroup;

lib/DependenciesBlock.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class DependenciesBlock {
5858
}
5959

6060
unseal() {
61-
for (const block of this.blocks) block.unseal();
61+
for (const block of this.blocks) {
62+
block.unseal();
63+
}
6264
}
6365

6466
hasDependencies(filter) {
@@ -82,8 +84,12 @@ class DependenciesBlock {
8284
}
8385

8486
sortItems() {
85-
for (const block of this.blocks) block.sortItems();
87+
for (const block of this.blocks) {
88+
block.sortItems();
89+
}
8690
}
8791
}
8892

93+
Object.setPrototypeOf(DependenciesBlock.prototype, null);
94+
8995
module.exports = DependenciesBlock;

lib/DependenciesBlockVariable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ class DependenciesBlockVariable {
4949
}
5050
}
5151

52+
Object.setPrototypeOf(DependenciesBlockVariable.prototype, null);
53+
5254
module.exports = DependenciesBlockVariable;

lib/Dependency.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ class Dependency {
1515
this.loc = undefined;
1616
}
1717

18+
static compare(a, b) {
19+
return compareLocations(a.loc, b.loc);
20+
}
21+
1822
getResourceIdentifier() {
1923
return null;
2024
}
@@ -46,6 +50,7 @@ class Dependency {
4650
this.module = null;
4751
}
4852
}
49-
Dependency.compare = (a, b) => compareLocations(a.loc, b.loc);
53+
54+
Object.setPrototypeOf(Dependency.prototype, null);
5055

5156
module.exports = Dependency;

0 commit comments

Comments
 (0)