Comparing version 3.0.4 to 3.0.5
"use strict"; | ||
var util = require("../../../util"); | ||
var t = require("../../../types"); | ||
var traverse = require("../../../traverse"); | ||
var util = require("../../../util"); | ||
var t = require("../../../types"); | ||
@@ -13,2 +14,11 @@ var hasDefaults = function (node) { | ||
var iifeVisitor = { | ||
enter: function (node, parent, scope, context, state) { | ||
if (t.isReferencedIdentifier(node, parent) && scope.hasOwn(node.name)) { | ||
state.iife = true; | ||
context.stop(); | ||
} | ||
} | ||
}; | ||
exports.Function = function (node, parent, scope) { | ||
@@ -19,3 +29,2 @@ if (!hasDefaults(node)) return; | ||
var iife = false; | ||
var body = []; | ||
@@ -28,2 +37,4 @@ | ||
var state = { iife: false, scope: scope }; | ||
for (var i = 0; i < node.params.length; i++) { | ||
@@ -42,6 +53,8 @@ var param = node.params[i]; | ||
// we're accessing a variable that's already defined within this function | ||
var localDeclar = scope.get(left.name, true); | ||
if (localDeclar !== left) { | ||
iife = true; | ||
if (!state.iife) { | ||
if (t.isIdentifier(right) && scope.hasOwn(right.name)) { | ||
state.iife = true; | ||
} else { | ||
traverse(right, iifeVisitor, scope, state); | ||
} | ||
} | ||
@@ -62,3 +75,3 @@ | ||
if (iife) { | ||
if (state.iife) { | ||
var container = t.functionExpression(null, [], node.body, node.generator); | ||
@@ -65,0 +78,0 @@ container._aliasFunction = true; |
{ | ||
"name": "6to5-core", | ||
"description": "Turn ES6 code into readable vanilla ES5 with source maps", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
@@ -6,0 +6,0 @@ "homepage": "https://6to5.org/", |
Sorry, the diff of this file is too big to display
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
1355466
11344