Merge pull request #10185 from webpack/bugfix/non-deterministic-provided-exports

make order of exports in providedExports deterministic
This commit is contained in:
Tobias Koppers 2019-12-27 22:07:27 +01:00 committed by GitHub
commit 8a0dac1793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 11 deletions

View File

@ -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 {
@ -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;

View File

@ -0,0 +1 @@
export * from './b'

View File

@ -0,0 +1,5 @@
export * from './c'
export function b() {
// this extra export is needed for the issue to reproduce
}

View File

@ -0,0 +1,3 @@
export function c() {
return 42;
}

View File

@ -0,0 +1,3 @@
export default 1;
---
export default 2;

View File

@ -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));
});