Skip to content

Commit

Permalink
fix concatenated version of reexport dependency for sideEffects
Browse files Browse the repository at this point in the history
fixes #9159
  • Loading branch information
sokra committed May 22, 2019
1 parent 6ca9167 commit fec26a9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -521,7 +521,7 @@ class ConcatenatedModule extends Module {
dep instanceof HarmonyExportImportedSpecifierDependency
) {
const exportName = dep.name;
const importName = dep.id;
const importName = dep._id;
const importedModule = dep._module;
if (exportName && importName) {
if (!reexportMap.has(exportName)) {
Expand Down Expand Up @@ -1390,12 +1390,12 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate {

getExports(dep) {
const importModule = dep._module;
if (dep.id) {
if (dep._id) {
// export { named } from "module"
return [
{
name: dep.name,
id: dep.id,
id: dep._id,
module: importModule
}
];
Expand Down
5 changes: 5 additions & 0 deletions test/cases/scope-hoisting/side-effects-9159/index.js
@@ -0,0 +1,5 @@
it("should reexport from side-effect-free scope-hoisted module", () => {
const m = require("./reexport");
expect(m.value).toBe(42);
expect(m.ns.default).toBe(42);
});
4 changes: 4 additions & 0 deletions test/cases/scope-hoisting/side-effects-9159/package/index.js
@@ -0,0 +1,4 @@
export { default as value } from "./module";

import * as ns from "./module";
export { ns };
@@ -0,0 +1 @@
export default 42;
@@ -0,0 +1,3 @@
{
"sideEffects": false
}
1 change: 1 addition & 0 deletions test/cases/scope-hoisting/side-effects-9159/reexport.js
@@ -0,0 +1 @@
export { value, ns } from "./package";

0 comments on commit fec26a9

Please sign in to comment.