babel-plugin-closure-elimination
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -48,2 +48,7 @@ 'use strict'; | ||
function _ref8(_ref7) { | ||
var path = _ref7.path; | ||
return !path.isProgram() || path.node.sourceType === 'module'; | ||
} | ||
function _getAllParentScopes(scope) { | ||
@@ -88,3 +93,3 @@ var scopes = []; | ||
var bestParentScope = getHighestCompatibleHoistedScope(path); | ||
if (bestParentScope !== path.scope.parent) { | ||
if (bestParentScope) { | ||
var attachPath = _getAttachmentPositio(bestParentScope.path, path); | ||
@@ -121,3 +126,5 @@ moveToNewPosition(path, attachPath); | ||
} | ||
return parentScopes.pop(); | ||
return parentScopes.filter(_ref8).filter(function (scope) { | ||
return scope !== path.scope.parent; | ||
}).pop(); | ||
}function moveToNewPosition(path, attachPath) { | ||
@@ -124,0 +131,0 @@ var node = path.node, |
{ | ||
"name": "babel-plugin-closure-elimination", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "Removes closures from your JavaScript in the name of performance.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -10,3 +10,3 @@ import 'babel-polyfill'; | ||
export default function build(babel:Object):Object { | ||
export default function build(babel: Object): Object { | ||
const {types: t} = babel; | ||
@@ -27,3 +27,3 @@ | ||
const bestParentScope = getHighestCompatibleHoistedScope(path); | ||
if (bestParentScope !== path.scope.parent) { | ||
if (bestParentScope) { | ||
const attachPath = getAttachmentPosition(bestParentScope.path, path); | ||
@@ -45,3 +45,3 @@ moveToNewPosition(path, attachPath); | ||
enter(path) { | ||
if(path.node.name === 'eval' && path.parentPath.type === 'CallExpression') { | ||
if (path.node.name === 'eval' && path.parentPath.type === 'CallExpression') { | ||
path.getAncestry() | ||
@@ -73,3 +73,6 @@ .filter(path=>path.isFunction()) | ||
} | ||
return parentScopes.pop(); | ||
return parentScopes | ||
.filter(({path}) => !path.isProgram() || path.node.sourceType === 'module') | ||
.filter(scope => scope !== path.scope.parent) | ||
.pop(); | ||
} | ||
@@ -126,3 +129,3 @@ | ||
*/ | ||
function normalizeFunctionBody(node:Object):Object { | ||
function normalizeFunctionBody(node: Object): Object { | ||
if (node.type !== 'BlockStatement') { | ||
@@ -129,0 +132,0 @@ return t.blockStatement([ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12427
264