aboutsummaryrefslogtreecommitdiff
path: root/node_modules/babel-generator/lib/node
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-04-20 03:09:25 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-04-24 16:14:29 +0200
commit82f2b76e25a4a67e01ec67e5ebe39d14ad771ea8 (patch)
tree965f6eb89b84d65a62b49008fd972c004832ccd1 /node_modules/babel-generator/lib/node
parente6e0cbc387c2a77b48e4065c229daa65bf1aa0fa (diff)
Reorganize module loading.
We now use webpack instead of SystemJS, effectively bundling modules into one file (plus commons chunks) for every entry point. This results in a much smaller extension size (almost half). Furthermore we use yarn/npm even for extension run-time dependencies. This relieves us from manually vendoring and building dependencies. It's also easier to understand for new developers familiar with node.
Diffstat (limited to 'node_modules/babel-generator/lib/node')
-rw-r--r--node_modules/babel-generator/lib/node/parentheses.js119
-rw-r--r--node_modules/babel-generator/lib/node/whitespace.js25
2 files changed, 25 insertions, 119 deletions
diff --git a/node_modules/babel-generator/lib/node/parentheses.js b/node_modules/babel-generator/lib/node/parentheses.js
index 10eba8e2c..471af71cb 100644
--- a/node_modules/babel-generator/lib/node/parentheses.js
+++ b/node_modules/babel-generator/lib/node/parentheses.js
@@ -5,6 +5,7 @@ exports.AwaitExpression = exports.FunctionTypeAnnotation = undefined;
exports.NullableTypeAnnotation = NullableTypeAnnotation;
exports.UpdateExpression = UpdateExpression;
exports.ObjectExpression = ObjectExpression;
+exports.DoExpression = DoExpression;
exports.Binary = Binary;
exports.BinaryExpression = BinaryExpression;
exports.SequenceExpression = SequenceExpression;
@@ -55,27 +56,19 @@ function NullableTypeAnnotation(node, parent) {
exports.FunctionTypeAnnotation = NullableTypeAnnotation;
function UpdateExpression(node, parent) {
- if (t.isMemberExpression(parent) && parent.object === node) {
- return true;
- }
-
- return false;
+ return t.isMemberExpression(parent) && parent.object === node;
}
function ObjectExpression(node, parent, printStack) {
return isFirstInStatement(printStack, { considerArrow: true });
}
-function Binary(node, parent) {
- if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
- return true;
- }
-
- if (t.isUnaryLike(parent)) {
- return true;
- }
+function DoExpression(node, parent, printStack) {
+ return isFirstInStatement(printStack);
+}
- if (t.isMemberExpression(parent) && parent.object === node) {
+function Binary(node, parent) {
+ if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node || t.isUnaryLike(parent) || t.isMemberExpression(parent) && parent.object === node || t.isAwaitExpression(parent)) {
return true;
}
@@ -86,11 +79,7 @@ function Binary(node, parent) {
var nodeOp = node.operator;
var nodePos = PRECEDENCE[nodeOp];
- if (parentPos > nodePos) {
- return true;
- }
-
- if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent)) {
+ if (parentPos === nodePos && parent.right === node && !t.isLogicalExpression(parent) || parentPos > nodePos) {
return true;
}
}
@@ -99,49 +88,12 @@ function Binary(node, parent) {
}
function BinaryExpression(node, parent) {
- if (node.operator === "in") {
- if (t.isVariableDeclarator(parent)) {
- return true;
- }
-
- if (t.isFor(parent)) {
- return true;
- }
- }
-
- return false;
+ return node.operator === "in" && (t.isVariableDeclarator(parent) || t.isFor(parent));
}
function SequenceExpression(node, parent) {
- if (t.isForStatement(parent)) {
- return false;
- }
-
- if (t.isExpressionStatement(parent) && parent.expression === node) {
- return false;
- }
-
- if (t.isReturnStatement(parent)) {
- return false;
- }
-
- if (t.isThrowStatement(parent)) {
- return false;
- }
-
- if (t.isSwitchStatement(parent) && parent.discriminant === node) {
- return false;
- }
-
- if (t.isWhileStatement(parent) && parent.test === node) {
- return false;
- }
- if (t.isIfStatement(parent) && parent.test === node) {
- return false;
- }
-
- if (t.isForInStatement(parent) && parent.right === node) {
+ if (t.isForStatement(parent) || t.isThrowStatement(parent) || t.isReturnStatement(parent) || t.isIfStatement(parent) && parent.test === node || t.isWhileStatement(parent) && parent.test === node || t.isForInStatement(parent) && parent.right === node || t.isSwitchStatement(parent) && parent.discriminant === node || t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
@@ -158,15 +110,7 @@ function ClassExpression(node, parent, printStack) {
}
function UnaryLike(node, parent) {
- if (t.isMemberExpression(parent, { object: node })) {
- return true;
- }
-
- if (t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node })) {
- return true;
- }
-
- return false;
+ return t.isMemberExpression(parent, { object: node }) || t.isCallExpression(parent, { callee: node }) || t.isNewExpression(parent, { callee: node });
}
function FunctionExpression(node, parent, printStack) {
@@ -174,15 +118,7 @@ function FunctionExpression(node, parent, printStack) {
}
function ArrowFunctionExpression(node, parent) {
- if (t.isExportDeclaration(parent)) {
- return true;
- }
-
- if (t.isBinaryExpression(parent) || t.isLogicalExpression(parent)) {
- return true;
- }
-
- if (t.isUnaryExpression(parent)) {
+ if (t.isExportDeclaration(parent) || t.isBinaryExpression(parent) || t.isLogicalExpression(parent) || t.isUnaryExpression(parent) || t.isTaggedTemplateExpression(parent)) {
return true;
}
@@ -190,15 +126,7 @@ function ArrowFunctionExpression(node, parent) {
}
function ConditionalExpression(node, parent) {
- if (t.isUnaryLike(parent)) {
- return true;
- }
-
- if (t.isBinary(parent)) {
- return true;
- }
-
- if (t.isConditionalExpression(parent, { test: node })) {
+ if (t.isUnaryLike(parent) || t.isBinary(parent) || t.isConditionalExpression(parent, { test: node }) || t.isAwaitExpression(parent)) {
return true;
}
@@ -214,27 +142,18 @@ function AssignmentExpression(node) {
}
function isFirstInStatement(printStack) {
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
-
- var _ref$considerArrow = _ref.considerArrow;
- var considerArrow = _ref$considerArrow === undefined ? false : _ref$considerArrow;
- var _ref$considerDefaultE = _ref.considerDefaultExports;
- var considerDefaultExports = _ref$considerDefaultE === undefined ? false : _ref$considerDefaultE;
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
+ _ref$considerArrow = _ref.considerArrow,
+ considerArrow = _ref$considerArrow === undefined ? false : _ref$considerArrow,
+ _ref$considerDefaultE = _ref.considerDefaultExports,
+ considerDefaultExports = _ref$considerDefaultE === undefined ? false : _ref$considerDefaultE;
var i = printStack.length - 1;
var node = printStack[i];
i--;
var parent = printStack[i];
while (i > 0) {
- if (t.isExpressionStatement(parent, { expression: node })) {
- return true;
- }
-
- if (considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node })) {
- return true;
- }
-
- if (considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
+ if (t.isExpressionStatement(parent, { expression: node }) || t.isTaggedTemplateExpression(parent) || considerDefaultExports && t.isExportDefaultDeclaration(parent, { declaration: node }) || considerArrow && t.isArrowFunctionExpression(parent, { body: node })) {
return true;
}
diff --git a/node_modules/babel-generator/lib/node/whitespace.js b/node_modules/babel-generator/lib/node/whitespace.js
index d3690a84a..f39e75525 100644
--- a/node_modules/babel-generator/lib/node/whitespace.js
+++ b/node_modules/babel-generator/lib/node/whitespace.js
@@ -1,13 +1,5 @@
"use strict";
-var _isBoolean = require("lodash/isBoolean");
-
-var _isBoolean2 = _interopRequireDefault(_isBoolean);
-
-var _each = require("lodash/each");
-
-var _each2 = _interopRequireDefault(_each);
-
var _map = require("lodash/map");
var _map2 = _interopRequireDefault(_map);
@@ -144,19 +136,14 @@ exports.list = {
}
};
-(0, _each2.default)({
- Function: true,
- Class: true,
- Loop: true,
- LabeledStatement: true,
- SwitchStatement: true,
- TryStatement: true
-}, function (amounts, type) {
- if ((0, _isBoolean2.default)(amounts)) {
+[["Function", true], ["Class", true], ["Loop", true], ["LabeledStatement", true], ["SwitchStatement", true], ["TryStatement", true]].forEach(function (_ref) {
+ var type = _ref[0],
+ amounts = _ref[1];
+
+ if (typeof amounts === "boolean") {
amounts = { after: amounts, before: amounts };
}
-
- (0, _each2.default)([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
+ [type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) {
exports.nodes[type] = function () {
return amounts;
};