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

fix(const-folding): do not evaluate identifier in export specifiers #828

Merged
merged 1 commit into from May 2, 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
@@ -0,0 +1,3 @@
const a = "a";
const b = "b";
export { a, b };
@@ -0,0 +1,3 @@
{
"sourceType": "module"
}
@@ -0,0 +1,3 @@
const a = "a";
const b = "b";
export { a, b };
Expand Up @@ -102,7 +102,7 @@ module.exports = babel => {

// TODO: look into evaluating binding too (could result in more code, but gzip?)
Expression(path, { opts: { tdz = false } = {} }) {
const { node } = path;
const { node, parent } = path;

if (node[seen]) {
return;
Expand All @@ -116,6 +116,11 @@ module.exports = babel => {
return;
}

// Avoid replacing the values for identifiers in exports
if (t.isExportSpecifier(parent)) {
return;
}

// -0 maybe compared via dividing and then checking against -Infinity
// Also -X will always be -X.
if (
Expand Down