Skip to content

Commit

Permalink
make order of exports determinism for hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 27, 2019
1 parent 2671b0b commit 4453c96
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/dependencies/HarmonyExportImportedSpecifierDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
let checked;

if (noExtraImports) {
for (const exportInfo of exportsInfo.exports) {
for (const exportInfo of exportsInfo.orderedExports) {
if (ignoredExports.has(exportInfo.name)) continue;
if (exportInfo.used !== UsageState.Unused) {
imports.add(exportInfo.name);
Expand All @@ -303,7 +303,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {

if (noExtraExports) {
checked = new Set();
for (const exportInfo of importedExportsInfo.exports) {
for (const exportInfo of importedExportsInfo.orderedExports) {
if (ignoredExports.has(exportInfo.name)) continue;
switch (exportInfo.provided) {
case true:
Expand Down
3 changes: 2 additions & 1 deletion test/HotTestCases.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const path = require("path");
const fs = require("graceful-fs");
const vm = require("vm");
const rimraf = require("rimraf");
const checkArrayExpectation = require("./checkArrayExpectation");
const createLazyTestEnv = require("./helpers/createLazyTestEnv");

Expand Down Expand Up @@ -42,8 +43,8 @@ const describeCases = config => {
category.name,
testName
);
rimraf.sync(outputDirectory);
const recordsPath = path.join(outputDirectory, "records.json");
if (fs.existsSync(recordsPath)) fs.unlinkSync(recordsPath);
const fakeUpdateLoaderOptions = {
updateIndex: 0
};
Expand Down
1 change: 1 addition & 0 deletions test/hotCases/determinism/issue-10174/deps/a.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './b'
5 changes: 5 additions & 0 deletions test/hotCases/determinism/issue-10174/deps/b.js
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function c() {
return 42;
}
3 changes: 3 additions & 0 deletions test/hotCases/determinism/issue-10174/hot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default 1;
---
export default 2;
14 changes: 14 additions & 0 deletions test/hotCases/determinism/issue-10174/index.js
Original file line number Diff line number Diff line change
@@ -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 4453c96

Please sign in to comment.