Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #8085 #8086

Merged
merged 1 commit into from Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -1364,12 +1364,20 @@ class HarmonyExportExpressionDependencyConcatenatedTemplate {
}

if (dep.range) {
source.replace(dep.rangeStatement[0], dep.range[0] - 1, content + "(");
source.replace(
dep.rangeStatement[0],
dep.range[0] - 1,
content + "(" + dep.prefix
);
source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
return;
}

source.replace(dep.rangeStatement[0], dep.rangeStatement[1] - 1, content);
source.replace(
dep.rangeStatement[0],
dep.rangeStatement[1] - 1,
content + dep.prefix
);
}
}

Expand Down
15 changes: 15 additions & 0 deletions test/configCases/scope-hoisting/harmony-pure-default/index.js
@@ -0,0 +1,15 @@
import x1, { value as v1 } from "./module1";
import x2, { value as v2 } from "./module2";
import { value as v3 } from "./module3";
import x4, { value as v4 } from "./module4";

it("should not execute exports when annotated with pure comment", () => {
expect(v1).toBe(42);
expect(v2).toBe(42);
expect(v3).toBe(42);
expect(v4).toBe(42);
});

var x = /*#__PURE__*/(function() {
return x1 + x2 + x4;
});
@@ -0,0 +1,9 @@
let value = 42;

const inc = () => {
value++;
};

export default /*#__PURE__*/inc();

export { value };
@@ -0,0 +1,9 @@
let value = 42;

const inc = () => {
value++;
};

export default (/*#__PURE__*/inc());

export { value };
@@ -0,0 +1,9 @@
let value = 42;

const inc = () => {
value++;
};

export default /*#__PURE__*/(inc());

export { value };
15 changes: 15 additions & 0 deletions test/configCases/scope-hoisting/harmony-pure-default/module4.js
@@ -0,0 +1,15 @@
let value = 42;

const inc = () => {
value++;
};

export
// hello
default
// world
/*#__PURE__*/
inc()
;

export { value };
@@ -0,0 +1,7 @@
module.exports = {
mode: "production",
optimization: {
minimize: true,
concatenateModules: true
}
};