Skip to content

Commit 8a0dac1

Browse files
authored
Merge pull request #10185 from webpack/bugfix/non-deterministic-provided-exports
make order of exports in providedExports deterministic
2 parents 4e31587 + 8e4749e commit 8a0dac1

6 files changed

Lines changed: 30 additions & 11 deletions

File tree

lib/FlagDependencyExportsPlugin.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77
const Queue = require("./util/Queue");
88

99
const addToSet = (a, b) => {
10-
let changed = false;
10+
const size = a.size;
1111
for (const item of b) {
12-
if (!a.has(item)) {
13-
a.add(item);
14-
changed = true;
15-
}
12+
a.add(item);
1613
}
17-
return changed;
14+
return a.size !== size;
1815
};
1916

2017
class FlagDependencyExportsPlugin {
@@ -114,11 +111,7 @@ class FlagDependencyExportsPlugin {
114111
if (module.buildMeta.providedExports !== true) {
115112
moduleWithExports =
116113
module.buildMeta && module.buildMeta.exportsType;
117-
moduleProvidedExports = Array.isArray(
118-
module.buildMeta.providedExports
119-
)
120-
? new Set(module.buildMeta.providedExports)
121-
: new Set();
114+
moduleProvidedExports = new Set();
122115
providedExportsAreTemporary = false;
123116
processDependenciesBlock(module);
124117
module.buildInfo.temporaryProvidedExports = providedExportsAreTemporary;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './b'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './c'
2+
3+
export function b() {
4+
// this extra export is needed for the issue to reproduce
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function c() {
2+
return 42;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default 1;
2+
---
3+
export default 2;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { c } from "./deps/a";
2+
import hot from "./hot";
3+
4+
it("should only register changes for the changed module", done => {
5+
expect(hot).toBe(1);
6+
expect(c()).toBe(42);
7+
module.hot.accept("./hot", () => {
8+
expect(hot).toBe(2);
9+
expect(c()).toBe(42);
10+
done();
11+
});
12+
13+
NEXT(require("../../update")(done));
14+
});

0 commit comments

Comments
 (0)