Skip to content

Commit

Permalink
fixes #7930
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 22, 2018
1 parent 6f1f18f commit a92c23e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -1447,9 +1447,9 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
if (!used) {
source.insert(
-1,
`/* unused concated harmony import ${dep.name} */\n`
`/* unused concated harmony import ${def.name} */\n`
);
return;
continue;
}
let finalName;
const strictFlag = dep.originModule.buildMeta.strictHarmonyModule
Expand All @@ -1466,9 +1466,11 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {
}_${exportData}${strictFlag}__`;
}
const exportsName = this.rootModule.exportsArgument;
const content = `/* concated harmony reexport */__webpack_require__.d(${exportsName}, ${JSON.stringify(
used
)}, function() { return ${finalName}; });\n`;
const content =
`/* concated harmony reexport ${def.name} */` +
`__webpack_require__.d(${exportsName}, ` +
`${JSON.stringify(used)}, ` +
`function() { return ${finalName}; });\n`;
source.insert(-1, content);
}
} else {
Expand Down
5 changes: 5 additions & 0 deletions test/cases/scope-hoisting/issue-7930/export.js
@@ -0,0 +1,5 @@
export var a = 1;

var value = 42;

export { value };
10 changes: 10 additions & 0 deletions test/cases/scope-hoisting/issue-7930/index.js
@@ -0,0 +1,10 @@
import { value } from "./module";

it("should export the correct value", () => {
expect(value).toBe(42);
});

// prevent scope hoisting
if(Math.random() < -1) {
console.log(module.id);
}
1 change: 1 addition & 0 deletions test/cases/scope-hoisting/issue-7930/module.js
@@ -0,0 +1 @@
export * from "./export";

0 comments on commit a92c23e

Please sign in to comment.