Socket
Socket
Sign inDemoInstall

babel

Package Overview
Dependencies
Maintainers
1
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel - npm Package Compare versions

Comparing version 4.6.3 to 4.6.4

lib/babel/transformation/transformers/minification/inline-environment-variables.js

8

CHANGELOG.md

@@ -16,2 +16,10 @@ # Changelog

## 4.6.3
* **Bug Fix**
* Fix `arguments` being incorrectly aliased in arrow function rest parameter optimisation.
* Make deoptimisation trigger safer.
* **New Feature**
* Flow types are now retained when blacklisting the `flow` transformer.
## 4.6.1

@@ -18,0 +26,0 @@

6

lib/babel/transformation/transformers/deprecated.json
{
"selfContained": "runtime",
"unicode-regex": "regex.unicode"
"unicode-regex": "regex.unicode",
"minification.deadCodeElimination": "utility.deadCodeElimination",
"minification.removeConsoleCalls": "utility.removeConsole",
"minification.removeDebugger": "utility.removeDebugger"
}

2

lib/babel/transformation/transformers/es6/block-scoping.js

@@ -349,3 +349,3 @@ "use strict";

if (this.scope.hasGlobal(id.name)) {
if (this.scope.hasGlobal(id.name) || this.scope.parentHasBinding(id.name)) {
delete outsideRefs[id.name];

@@ -352,0 +352,0 @@ delete this.letReferences[id.name];

@@ -191,3 +191,3 @@ "use strict";

// we have no constructor, we have a super, and the super doesn't appear to be falsy
if (!this.hasConstructor && this.hasSuper && !t.isFalsyExpression(superName)) {
if (!this.hasConstructor && this.hasSuper && t.evaluateTruthy(superName) !== false) {
var helperName = "class-super-constructor-call";

@@ -194,0 +194,0 @@ if (this.isLoose) helperName += "-loose";

@@ -45,3 +45,7 @@ "use strict";

return build.node;
if (build.replaceParent) {
this.parentPath.node = build.node;
} else {
return build.node;
}
}

@@ -107,6 +111,7 @@

iteratorKey: iteratorKey,
label: t.isLabeledStatement(parent) && parent.label.name,
wrapReturn: function wrapReturn(node) {
return t.ifStatement(t.logicalExpression("&&", t.unaryExpression("!", isArrayKey, true), t.memberExpression(iteratorKey, t.identifier("return"))), node);
},
label: t.isLabeledStatement(parent) && parent.label.name
}
});

@@ -124,2 +129,3 @@

var spec = function spec(node, parent, scope, file) {
var left = node.left;

@@ -155,4 +161,11 @@ var declar;

var loop = template[3].block.body[0];
var isLabeledParent = t.isLabeledStatement(parent);
var tryBody = template[3].block.body;
var loop = tryBody[0];
if (isLabeledParent) {
tryBody[0] = t.labeledStatement(parent.label, loop);
}
//

@@ -162,3 +175,4 @@

iteratorKey: iteratorKey,
label: t.isLabeledStatement(parent) && parent.label.name,
label: isLabeledParent && parent.label.name,
wrapReturn: function wrapReturn(node) {

@@ -172,2 +186,3 @@ return t.ifStatement(t.memberExpression(iteratorKey, t.identifier("return")), node);

return {
replaceParent: isLabeledParent,
declar: declar,

@@ -174,0 +189,0 @@ loop: loop,

@@ -108,8 +108,10 @@ "use strict";

"minification.removeDebugger": require("./minification/remove-debugger"),
"minification.removeConsoleCalls": require("./minification/remove-console-calls"),
"minification.deadCodeElimination": require("./minification/dead-code-elimination"),
"minification.renameLocalVariables": require("./minification/rename-local-variables"),
"utility.removeDebugger": require("./utility/remove-debugger"),
"utility.removeConsole": require("./utility/remove-console"),
"utility.inlineEnvironmentVariables": require("./utility/inline-environment-variables"),
"utility.inlineExpressions": require("./utility/inline-expressions"),
"utility.deadCodeElimination": require("./utility/dead-code-elimination"),
_cleanUp: require("./internal/cleanup")
};

@@ -25,2 +25,19 @@ "use strict";

function toStatements(node) {
if (t.isBlockStatement(node)) {
var hasBlockScoped = false;
for (var i = 0; i < node.body.length; i++) {
var bodyNode = node.body[i];
if (t.isBlockScoped(bodyNode)) hasBlockScoped = true;
}
if (!hasBlockScoped) {
return node.body;
}
}
return node;
}
var IfStatement = exports.IfStatement = {

@@ -36,2 +53,4 @@ exit: function exit(node) {

var evaluateTest = t.evaluateTruthy(test);
// we can check if a test will be truthy 100% and if so then we can inline

@@ -44,3 +63,3 @@ // the consequent and completely ignore the alternate

if (t.isLiteral(test) && test.value) {
if (evaluateTest === true) {
return consequent;

@@ -56,3 +75,3 @@ }

if (t.isFalsyExpression(test)) {
if (evaluateTest === false) {
if (alternate) {

@@ -59,0 +78,0 @@ return alternate;

@@ -8,2 +8,3 @@ "use strict";

exports.Class = Class;
exports.Function = Function;
exports.TypeCastExpression = TypeCastExpression;

@@ -28,2 +29,9 @@ exports.ImportDeclaration = ImportDeclaration;

function Function(node) {
for (var i = 0; i < node.params.length; i++) {
var param = node.params[i];
param.optional = false;
}
}
function TypeCastExpression(node) {

@@ -30,0 +38,0 @@ return node.expression;

@@ -87,2 +87,7 @@ {

"LabeledStatement": {
"label": null,
"body": null
},
"Literal": {

@@ -89,0 +94,0 @@ "value": null

@@ -7,2 +7,8 @@ "use strict";

var isPlainObject = _interopRequire(require("lodash/lang/isPlainObject"));
var isNumber = _interopRequire(require("lodash/lang/isNumber"));
var isRegExp = _interopRequire(require("lodash/lang/isRegExp"));
var isString = _interopRequire(require("lodash/lang/isString"));

@@ -820,3 +826,195 @@

/**
* Walk the input `node` and statically evaluate if it's truthy.
*
* Returning `true` when we're sure that the expression will evaluate to a
* truthy value, `false` if we're sure that it will evaluate to a falsy
* value and `undefined` if we aren't sure. Because of this please do not
* rely on coercion when using this method and check with === if it's false.
*
* For example do:
*
* if (t.evaluateTruthy(node) === false) falsyLogic();
*
* **AND NOT**
*
* if (!t.evaluateTruthy(node)) falsyLogic();
*
* @param {Node} node
* @returns {Boolean}
*/
t.evaluateTruthy = function (node) {
var res = t.evaluate(node);
if (res.confident) return !!res.value;
};
/**
* Walk the input `node` and statically evaluate it.
*
* Returns an pbject in the form `{ confident, value }`. `confident` indicates
* whether or not we had to drop out of evaluating the expression because of
* hitting an unknown node that we couldn't confidently find the value of.
*
* Example:
*
* t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
* t.evaluate(parse("!true")) // { confident: true, value: false }
* t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
*
* @param {Node} node
* @returns {Object}
*/
t.evaluate = function (node) {
var confident = true;
var value = evaluate(node);
if (!confident) value = undefined;
return {
confident: confident,
value: value
};
function evaluate(node) {
if (!confident) return;
if (t.isSequenceExpression(node)) {
return evaluate(node.expressions[node.expressions.length - 1]);
}
if (t.isLiteral(node)) {
if (node.regex && node.value === null) {} else {
return node.value;
}
}
if (t.isConditionalExpression(node)) {
if (evaluate(node.test)) {
return evaluate(node.consequent);
} else {
return evaluate(node.alternate);
}
}
if (t.isIdentifier(node, { name: "undefined" })) {
return undefined;
}
if (t.isUnaryExpression(node, { prefix: true })) {
switch (node.operator) {
case "void":
return undefined;
case "!":
return !evaluate(node.argument);
case "+":
return +evaluate(node.argument);
case "-":
return -evaluate(node.argument);
}
}
if (t.isArrayExpression(node)) {
// possible perf issues - could deopt on X elements
var values = [];
for (var i = 0; i < node.elements.length; i++) {
values.push(evaluate(node.elements[i]));
}
return values;
}
if (t.isObjectExpression(node)) {}
if (t.isLogicalExpression(node)) {
var left = evaluate(node.left);
var right = evaluate(node.right);
switch (node.operator) {
case "||":
return left || right;
case "&&":
return left && right;
}
}
if (t.isBinaryExpression(node)) {
var left = evaluate(node.left);
var right = evaluate(node.right);
switch (node.operator) {
case "-":
return left - right;
case "+":
return left + right;
case "/":
return left / right;
case "*":
return left * right;
case "%":
return left % right;
case "<":
return left < right;
case ">":
return left > right;
case "<=":
return left <= right;
case ">=":
return left >= right;
case "==":
return left == right;
case "!=":
return left != right;
case "===":
return left === right;
case "!==":
return left !== right;
}
}
confident = false;
}
};
/**
* Description
*
* @param value
* @returns {Node}
*/
t.valueToNode = function (value) {
if (value === undefined) {
return t.identifier("undefined");
}
if (value === true || value === false || value === null || isString(value) || isNumber(value) || isRegExp(value)) {
return t.literal(value);
}
if (Array.isArray(value)) {
return t.arrayExpression(value.map(t.valueToNode));
}
if (isPlainObject(value)) {
var props = [];
for (var key in value) {
var nodeKey;
if (t.isValidIdentifier(key)) {
nodeKey = t.identifier(key);
} else {
nodeKey = t.literal(key);
}
props.push(t.property("init", nodeKey, t.valueToNode(value[key])));
}
return t.objectExpression(props);
}
throw new Error("don't know how to turn this value into a node");
};
toFastProperties(t);
toFastProperties(t.VISITOR_KEYS);
toFastProperties(t.VISITOR_KEYS);
// we have a regex and we can't represent it natively
// todo: deopt on mutable computed property keys etc
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.6.3",
"version": "4.6.4",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -60,3 +60,3 @@ "homepage": "https://babeljs.io/",

"regenerator-babel": "0.8.13-1",
"regexpu": "^1.1.1",
"regexpu": "^1.1.2",
"repeating": "^1.1.2",

@@ -63,0 +63,0 @@ "shebang-regex": "^1.0.0",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc