From 31abdc28c2d5a860e74d2f56c0d89678702bc617 Mon Sep 17 00:00:00 2001 From: Boopathi Rajaa Date: Fri, 17 Feb 2017 01:04:18 +0100 Subject: [PATCH] Fix minify-builtins memberExpression name --- packages/babel-plugin-minify-builtins/src/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/babel-plugin-minify-builtins/src/index.js b/packages/babel-plugin-minify-builtins/src/index.js index 4f0921400..9c96d1d6d 100644 --- a/packages/babel-plugin-minify-builtins/src/index.js +++ b/packages/babel-plugin-minify-builtins/src/index.js @@ -28,8 +28,9 @@ module.exports = function({ types: t }) { return; } - const expName = memberToString(path); if (!isComputed(path) && isBuiltin(path)) { + const expName = memberToString(path.node); + if (!context.pathsToUpdate.has(expName)) { context.pathsToUpdate.set(expName, []); } @@ -44,7 +45,6 @@ module.exports = function({ types: t }) { return; } - const expName = memberToString(callee); // computed property should be not optimized // Math[max]() -> Math.max() if (!isComputed(callee) && isBuiltin(callee)) { @@ -55,6 +55,8 @@ module.exports = function({ types: t }) { if (result.confident && hasPureArgs(path)) { path.replaceWith(t.valueToNode(result.value)); } else { + const expName = memberToString(callee.node); + if (!context.pathsToUpdate.has(expName)) { context.pathsToUpdate.set(expName, []); } @@ -98,7 +100,7 @@ module.exports = function({ types: t }) { }; function memberToString(memberExpr) { - const { object, property } = memberExpr.node; + const { object, property } = memberExpr; let result = ""; if (t.isIdentifier(object)) result += object.name;