Skip to content

Commit

Permalink
Merge pull request #10185 from webpack/bugfix/non-deterministic-provi…
Browse files Browse the repository at this point in the history
…ded-exports

make order of exports in providedExports deterministic
  • Loading branch information
sokra committed Dec 27, 2019
2 parents 4e31587 + 8e4749e commit 8a0dac1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/FlagDependencyExportsPlugin.js
Expand Up @@ -7,14 +7,11 @@
const Queue = require("./util/Queue");

const addToSet = (a, b) => {
let changed = false;
const size = a.size;
for (const item of b) {
if (!a.has(item)) {
a.add(item);
changed = true;
}
a.add(item);
}
return changed;
return a.size !== size;
};

class FlagDependencyExportsPlugin {
Expand Down Expand Up @@ -114,11 +111,7 @@ class FlagDependencyExportsPlugin {
if (module.buildMeta.providedExports !== true) {
moduleWithExports =
module.buildMeta && module.buildMeta.exportsType;
moduleProvidedExports = Array.isArray(
module.buildMeta.providedExports
)
? new Set(module.buildMeta.providedExports)
: new Set();
moduleProvidedExports = new Set();
providedExportsAreTemporary = false;
processDependenciesBlock(module);
module.buildInfo.temporaryProvidedExports = providedExportsAreTemporary;
Expand Down
1 change: 1 addition & 0 deletions test/hotCases/determinism/issue-10174/deps/a.js
@@ -0,0 +1 @@
export * from './b'
5 changes: 5 additions & 0 deletions test/hotCases/determinism/issue-10174/deps/b.js
@@ -0,0 +1,5 @@
export * from './c'

export function b() {
// this extra export is needed for the issue to reproduce
}
3 changes: 3 additions & 0 deletions test/hotCases/determinism/issue-10174/deps/c.js
@@ -0,0 +1,3 @@
export function c() {
return 42;
}
3 changes: 3 additions & 0 deletions test/hotCases/determinism/issue-10174/hot.js
@@ -0,0 +1,3 @@
export default 1;
---
export default 2;
14 changes: 14 additions & 0 deletions test/hotCases/determinism/issue-10174/index.js
@@ -0,0 +1,14 @@
import { c } from "./deps/a";
import hot from "./hot";

it("should only register changes for the changed module", done => {
expect(hot).toBe(1);
expect(c()).toBe(42);
module.hot.accept("./hot", () => {
expect(hot).toBe(2);
expect(c()).toBe(42);
done();
});

NEXT(require("../../update")(done));
});

0 comments on commit 8a0dac1

Please sign in to comment.