Skip to content

Commit

Permalink
fix(const-folding): do not evaluate identifier in export specifiers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam authored and boopathi committed May 2, 2018
1 parent b428527 commit 8b90599
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
@@ -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 };
7 changes: 6 additions & 1 deletion packages/babel-plugin-minify-constant-folding/src/index.js
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

0 comments on commit 8b90599

Please sign in to comment.