Socket
Socket
Sign inDemoInstall

6to5

Package Overview
Dependencies
Maintainers
1
Versions
257
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

6to5 - npm Package Compare versions

Comparing version 3.3.12 to 3.4.0

lib/6to5/api/browser.js

2

bin/6to5/index.js

@@ -26,3 +26,3 @@ #!/usr/bin/env node

commander.option("-c, --remove-comments", "Remove comments from the compiled code", false);
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-i, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");

@@ -29,0 +29,0 @@ commander.option("--keep-module-id-extensions", "Keep extensions when generating module ids", false);

@@ -5,3 +5,3 @@ var readdir = require("fs-readdir-recursive");

var path = require("path");
var to5 = require("../../lib/6to5");
var to5 = require("../../lib/6to5/api/node");
var fs = require("fs");

@@ -8,0 +8,0 @@ var _ = require("lodash");

@@ -1,2 +0,2 @@

var File = require("./file");
var File = require("./transformation/file");
var util = require("./util");

@@ -3,0 +3,0 @@ var each = require("lodash/collection/each");

module.exports = detect;
var SYNTAX_KEYS = require("./syntax-keys");
var traverse = require("../traverse");
var traverse = require("../traversal");
var visitors = traverse.explode(require("./visitors"));

@@ -6,0 +6,0 @@

@@ -5,6 +5,6 @@ "use strict";

var util = require("../util");
var isNumber = require("lodash/lang/isNumber");
var isBoolean = require("lodash/lang/isBoolean");
var contains = require("lodash/collection/contains");
var isNumber = require("lodash/lang/isNumber");
var util = require("../util");

@@ -11,0 +11,0 @@ function Buffer(position, format) {

@@ -15,8 +15,8 @@ "use strict";

var Buffer = require("./buffer");
var extend = require("lodash/object/extend");
var merge = require("lodash/object/merge");
var each = require("lodash/collection/each");
var util = require("../util");
var n = require("./node");
var t = require("../types");
var each = require("lodash/collection/each");
var extend = require("lodash/object/extend");
var merge = require("lodash/object/merge");

@@ -29,2 +29,3 @@ function CodeGenerator(ast, opts, code) {

this.format = CodeGenerator.normalizeOptions(code, opts);
this.opts = opts;
this.ast = ast;

@@ -31,0 +32,0 @@

"use strict";
var extend = require("lodash/object/extend");
var t = require("./types");
var extend = require("lodash/object/extend");

@@ -6,0 +6,0 @@ require("./types/node");

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

exports.ExpressionStatement = function (node, parent, scope, context, file) {
exports.ExpressionStatement = function (node, parent, scope, file) {
// hit the `AssignmentExpression` one below

@@ -33,3 +33,3 @@ if (file.isConsequenceExpressionStatement(node)) return;

exports.AssignmentExpression = function (node, parent, scope, context, file) {
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!isAssignment(node)) return;

@@ -36,0 +36,0 @@

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

exports.ExpressionStatement = function (node, parent, scope, context, file) {
exports.ExpressionStatement = function (node, parent, scope, file) {
// hit the `AssignmentExpression` one below

@@ -31,3 +31,3 @@ if (file.isConsequenceExpressionStatement(node)) return;

exports.AssignmentExpression = function (node, parent, scope, context, file) {
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!opts.is(node, file)) return;

@@ -34,0 +34,0 @@

var cloneDeep = require("lodash/lang/cloneDeep");
var traverse = require("../../traverse");
var clone = require("lodash/lang/clone");
var traverse = require("../../traversal");
var clone = require("lodash/lang/clone");
var each = require("lodash/collection/each");

@@ -5,0 +5,0 @@ var has = require("lodash/object/has");

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

var visitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
// check if this node is an identifier that matches the same as our function id

@@ -21,3 +21,3 @@ if (!t.isIdentifier(node, { name: state.id })) return;

state.selfReference = true;
context.stop();
this.stop();
}

@@ -24,0 +24,0 @@ };

@@ -6,4 +6,4 @@ "use strict";

var visitor = {
enter: function (node, parent, scope, context) {
if (t.isFunction(node)) context.skip();
enter: function (node) {
if (t.isFunction(node)) this.skip();

@@ -10,0 +10,0 @@ if (t.isAwaitExpression(node)) {

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

[
isStatic ? this.superName : t.memberExpression(this.superName, t.identifier("prototype")),
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),

@@ -67,3 +72,8 @@ value,

[
isStatic ? this.superName : t.memberExpression(this.superName, t.identifier("prototype")),
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),

@@ -84,3 +94,3 @@ thisExpression

var visitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
var topLevel = state.topLevel;

@@ -92,3 +102,3 @@ var self = state.self;

self.traverseLevel(node, false);
return context.skip();
return this.skip();
}

@@ -98,3 +108,3 @@

// break on object methods
return context.skip();
return this.skip();
}

@@ -220,9 +230,9 @@

if (t.isIdentifier(node, { name: "super" })) {
if (!(t.isMemberExpression(parent) && !parent.computed && parent.property === node)) {
throw this.file.errorWithNode(node, "illegal use of bare super");
}
} else if (t.isCallExpression(node)) {
if (isIllegalBareSuper(node, parent)) {
throw this.file.errorWithNode(node, "Illegal use of bare super");
}
if (t.isCallExpression(node)) {
var callee = node.callee;
if (t.isIdentifier(callee, { name: "super" })) {
if (isSuper(callee, node)) {
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);

@@ -240,6 +250,3 @@ property = methodNode.key;

}
} else {
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
} else if (t.isMemberExpression(callee) && isSuper(callee.object, callee)) {
// super.test(); -> _get(Object.getPrototypeOf(ClassName.prototype), "test", this).call(this);

@@ -250,15 +257,9 @@ property = callee.property;

}
} else if (t.isMemberExpression(node)) {
if (!t.isIdentifier(node.object, { name: "super" })) return;
} else if (t.isMemberExpression(node) && isSuper(node.object, node)) {
// super.name; -> _get(Object.getPrototypeOf(ClassName.prototype), "name", this);
property = node.property;
computed = node.computed;
} else if (t.isAssignmentExpression(node)) {
if (!t.isIdentifier(node.left.object, { name: "super" })) return;
if (methodNode.kind !== "set") return;
thisReference = getThisReference();
} else if (t.isAssignmentExpression(node) && isSuper(node.left.object, node.left) && methodNode.kind === "set") {
// super.name = "val"; -> _set(Object.getPrototypeOf(ClassName.prototype), "name", this);
return this.setSuperProperty(node.left.property, node.right, methodNode.static, node.left.computed, thisReference);
return this.setSuperProperty(node.left.property, node.right, methodNode.static, node.left.computed, getThisReference());
}

@@ -287,1 +288,12 @@

};
var isIllegalBareSuper = function (node, parent) {
if (!isSuper(node, parent)) return false;
if (t.isMemberExpression(parent, { computed: false })) return false;
if (t.isCallExpression(parent, { callee: node })) return false;
return true;
};
var isSuper = function (node, parent) {
return t.isIdentifier(node, { name: "super" }) && t.isReferenced(node, parent);
};

@@ -5,7 +5,7 @@ "use strict";

var Transformer = require("./transformer");
var object = require("../helpers/object");
var File = require("../file");
var util = require("../util");
var each = require("lodash/collection/each");
var normalizeAst = require("../helpers/normalize-ast");
var Transformer = require("./transformer");
var object = require("../helpers/object");
var File = require("./file");
var each = require("lodash/collection/each");

@@ -18,3 +18,3 @@ function transform(code, opts) {

transform.fromAst = function (ast, code, opts) {
ast = util.normalizeAst(ast);
ast = normalizeAst(ast);

@@ -21,0 +21,0 @@ var file = new File(opts);

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

DefaultFormatter.prototype.doDefaultExportInterop = function (node) {
return node.default && !this.noInteropRequire && !this.hasNonDefaultExports;
return node.default && !this.noInteropRequireExport && !this.hasNonDefaultExports;
};

@@ -42,3 +42,3 @@

var exportsVisitor = {
enter: function (node, parent, scope, context, formatter) {
enter: function (node, parent, scope, formatter) {
var declar = node && node.declaration;

@@ -68,3 +68,3 @@ if (t.isExportDeclaration(node)) {

var importsVisitor = {
enter: function (node, parent, scope, context, formatter) {
enter: function (node, parent, scope, formatter) {
if (t.isImportDeclaration(node)) {

@@ -83,5 +83,5 @@ formatter.hasLocalImports = true;

var remapVisitor = {
enter: function (node, parent, scope, context, formatter) {
enter: function (node, parent, scope, formatter) {
if (t.isUpdateExpression(node) && formatter.isLocalReference(node.argument, scope)) {
context.skip();
this.skip();

@@ -114,3 +114,3 @@ // expand to long file assignment expression

if (t.isAssignmentExpression(node) && formatter.isLocalReference(node.left, scope)) {
context.skip();
this.skip();
return formatter.remapExportAssignment(node);

@@ -236,3 +236,3 @@ }

} else {
if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
if (t.isSpecifierDefault(specifier) && !this.noInteropRequireExport) {
// importing a default so we need to normalize it

@@ -239,0 +239,0 @@ ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);

@@ -32,5 +32,4 @@ "use strict";

AMDFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
AMDFormatter.prototype.transform = function (program) {
var body = program.body;

@@ -91,3 +90,3 @@ // build an array of module names

// import * as bar from "foo";
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
// import foo from "foo";

@@ -94,0 +93,0 @@ ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);

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

CommonJSFormatter.prototype.init = function () {
if (this.hasNonDefaultExports) {
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
this.file.ast.program.body.push(util.template("exports-module-declaration", true));

@@ -31,3 +31,7 @@ }

if (!contains(this.file.dynamicImported, node)) {
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
if (this.noInteropRequireImport) {
ref = t.memberExpression(ref, t.identifier("default"));
} else {
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
}
}

@@ -37,10 +41,10 @@ nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)]));

if (specifier.type === "ImportBatchSpecifier") {
if (!this.noInteropRequireImport) {
ref = t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]);
}
// import * as bar from "foo";
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(
variableName,
t.callExpression(this.file.addHelper("interop-require-wildcard"), [
ref
])
)
t.variableDeclarator(variableName, ref)
]));

@@ -47,0 +51,0 @@ } else {

module.exports = {
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
commonStandard: require("./common-standard"),
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
};

@@ -16,3 +16,4 @@ "use strict";

this.exportIdentifier = file.generateUidIdentifier("export");
this.noInteropRequire = true;
this.noInteropRequireExport = true;
this.noInteropRequireImport = true;

@@ -72,3 +73,3 @@ DefaultFormatter.apply(this, arguments);

var runnerSettersVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (node._importSource === state.source) {

@@ -86,3 +87,3 @@ if (t.isVariableDeclaration(node)) {

context.remove();
this.remove();
}

@@ -109,6 +110,6 @@ }

var hoistVariablesVisitor = {
enter: function (node, parent, scope, context, hoistDeclarators) {
enter: function (node, parent, scope, hoistDeclarators) {
if (t.isFunction(node)) {
// nothing inside is accessible
return context.skip();
return this.skip();
}

@@ -155,8 +156,8 @@

var hoistFunctionsVisitor = {
enter: function (node, parent, scope, context, handlerBody) {
if (t.isFunction(node)) context.skip();
enter: function (node, parent, scope, handlerBody) {
if (t.isFunction(node)) this.skip();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
context.remove();
this.remove();
}

@@ -166,5 +167,3 @@ }

SystemFormatter.prototype.transform = function (ast) {
var program = ast.program;
SystemFormatter.prototype.transform = function (program) {
var hoistDeclarators = [];

@@ -171,0 +170,0 @@ var moduleName = this.getModuleName();

@@ -16,5 +16,4 @@ "use strict";

UMDFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
UMDFormatter.prototype.transform = function (program) {
var body = program.body;

@@ -21,0 +20,0 @@ // build an array of module names

module.exports = TransformerPass;
var util = require("../util");
var contains = require("lodash/collection/contains");

@@ -18,13 +17,2 @@

TransformerPass.prototype.astRun = function (key) {
if (!this.shouldRun) return;
var handlers = this.handlers;
var file = this.file;
if (handlers.ast && handlers.ast[key]) {
handlers.ast[key](file.ast, file);
}
};
TransformerPass.prototype.canRun = function () {

@@ -68,16 +56,2 @@ var transformer = this.transformer;

var transformVisitor = {
enter: function (node, parent, scope, context, state) {
var fns = state.handlers[node.type];
if (!fns) return;
return fns.enter(node, parent, scope, context, state.file, state.pass);
},
exit: function (node, parent, scope, context, state) {
var fns = state.handlers[node.type];
if (!fns) return;
return fns.exit(node, parent, scope, context, state.file, state.pass);
}
};
TransformerPass.prototype.transform = function () {

@@ -88,10 +62,5 @@ if (!this.shouldRun) return;

util.debug(file.opts.filename + ": Running transformer " + this.transformer.key);
file.debug("Running transformer " + this.transformer.key);
this.astRun("before");
var state = { file: file, handlers: this.handlers, pass: this };
file.scope.traverse(file.ast, transformVisitor, state);
this.astRun("after");
file.scope.traverse(file.ast, this.handlers, file);
};

@@ -7,4 +7,5 @@ "use strict";

var isFunction = require("lodash/lang/isFunction");
var traverse = require("../traverse");
var traverse = require("../traversal");
var isObject = require("lodash/lang/isObject");
var clone = require("../helpers/clone");
var each = require("lodash/collection/each");

@@ -19,10 +20,20 @@

function Transformer(key, transformer, opts) {
this.manipulateOptions = transformer.manipulateOptions;
this.check = transformer.check;
transformer = clone(transformer);
this.experimental = !!transformer.experimental;
this.playground = !!transformer.playground;
this.secondPass = !!transformer.secondPass;
this.optional = !!transformer.optional;
var take = function (key) {
var val = transformer[key];
delete transformer[key];
return val;
};
this.manipulateOptions = take("manipulateOptions");
this.check = take("check");
this.post = take("post");
this.pre = take("pre");
this.experimental = !!take("experimental");
this.playground = !!take("playground");
this.secondPass = !!take("secondPass");
this.optional = !!take("optional");
this.handlers = this.normalize(transformer);

@@ -29,0 +40,0 @@ this.opts = opts || {};

@@ -37,4 +37,6 @@ {

"undeclaredVariableCheck": "validation.undeclaredVariableCheck",
"specPropertyLiterals": "minification.propertyLiterals",
"specMemberExpressionLiterals": "minification.memberExpressionLiterals"
"specPropertyLiterals": "es3.propertyLiterals",
"specMemberExpressionLiterals": "es3.memberExpressionLiterals",
"minification.propertyLiterals": "es3.propertyLiterals",
"minification.memberExpressionLiterals": "es3.memberExpressionLiterals"
}

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

var visitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (!t.isReferencedIdentifier(node, parent)) return;

@@ -40,3 +40,3 @@

exports.Program =
exports.BlockStatement = function (node, parent, scope, context, file) {
exports.BlockStatement = function (node, parent, scope, file) {
var letRefs = node._letReferences;

@@ -43,0 +43,0 @@ if (!letRefs) return;

"use strict";
var traverse = require("../../../traverse");
var traverse = require("../../../traversal");
var object = require("../../../helpers/object");

@@ -46,3 +46,3 @@ var util = require("../../../util");

exports.Loop = function (node, parent, scope, context, file) {
exports.Loop = function (node, parent, scope, file) {
var init = node.left || node.init;

@@ -58,3 +58,3 @@ if (isLet(init, node)) {

exports.Program =
exports.BlockStatement = function (block, parent, scope, context, file) {
exports.BlockStatement = function (block, parent, scope, file) {
if (!t.isLoop(parent)) {

@@ -113,3 +113,3 @@ var blockScoping = new BlockScoping(false, block, parent, scope, file);

function replace(node, parent, scope, context, remaps) {
function replace(node, parent, scope, remaps) {
if (!t.isReferencedIdentifier(node, parent)) return;

@@ -126,3 +126,3 @@

// match the one we have a stored replacement for
if (context) context.skip();
if (this) this.skip();
}

@@ -136,3 +136,3 @@ }

function traverseReplace(node, parent, scope, remaps) {
replace(node, parent, scope, null, remaps);
replace(node, parent, scope, remaps);
scope.traverse(node, replaceVisitor, remaps);

@@ -233,3 +233,3 @@ }

var letReferenceFunctionVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
// not a direct reference

@@ -250,6 +250,6 @@ if (!t.isReferencedIdentifier(node, parent)) return;

var letReferenceBlockVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (t.isFunction(node)) {
scope.traverse(node, letReferenceFunctionVisitor, state);
return context.skip();
return this.skip();
}

@@ -320,3 +320,3 @@ }

var loopVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
var replace;

@@ -331,3 +331,3 @@

if (t.isFunction(node) || t.isLoop(node)) {
return context.skip();
return this.skip();
}

@@ -374,3 +374,3 @@

var loopLabelVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (t.isLabeledStatement(node)) {

@@ -408,3 +408,3 @@ state.innerLabels.push(node.label.name);

var hoistVarDeclarationsVisitor = {
enter: function (node, parent, scope, context, self) {
enter: function (node, parent, scope, self) {
if (t.isForStatement(node)) {

@@ -421,3 +421,3 @@ if (isVar(node.init, node)) {

} else if (t.isFunction(node)) {
return context.skip();
return this.skip();
}

@@ -424,0 +424,0 @@ }

@@ -11,7 +11,7 @@ "use strict";

exports.ClassDeclaration = function (node, parent, scope, context, file) {
exports.ClassDeclaration = function (node, parent, scope, file) {
return new Class(node, file, scope, true).run();
};
exports.ClassExpression = function (node, parent, scope, context, file) {
exports.ClassExpression = function (node, parent, scope, file) {
if (!node.id) {

@@ -18,0 +18,0 @@ if (t.isProperty(parent) && parent.value === node && !parent.computed && t.isIdentifier(parent.key)) {

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

var visitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) {

@@ -28,4 +28,4 @@ var ids = t.getBindingIdentifiers(node);

var localBinding = scope.getBinding(key);
if (localBinding !== constant) continue;
// check if there's been a local binding that shadows this constant
if (!scope.bindingEquals(key, constant)) continue;

@@ -35,3 +35,3 @@ throw state.file.errorWithNode(id, key + " is read-only");

} else if (t.isScope(node)) {
context.skip();
this.skip();
}

@@ -41,3 +41,3 @@ }

exports.Scope = function (node, parent, scope, context, file) {
exports.Scope = function (node, parent, scope, file) {
scope.traverse(node, visitor, {

@@ -44,0 +44,0 @@ constants: scope.getAllDeclarationsOfKind("const"),

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

exports.ForInStatement =
exports.ForOfStatement = function (node, parent, scope, context, file) {
exports.ForOfStatement = function (node, parent, scope, file) {
var declar = node.left;

@@ -211,3 +211,3 @@ if (!t.isVariableDeclaration(declar)) return;

exports.Function = function (node, parent, scope, context, file) {
exports.Function = function (node, parent, scope, file) {
var nodes = [];

@@ -243,3 +243,3 @@

exports.CatchClause = function (node, parent, scope, context, file) {
exports.CatchClause = function (node, parent, scope, file) {
var pattern = node.param;

@@ -264,3 +264,3 @@ if (!t.isPattern(pattern)) return;

exports.ExpressionStatement = function (node, parent, scope, context, file) {
exports.ExpressionStatement = function (node, parent, scope, file) {
var expr = node.expression;

@@ -289,3 +289,3 @@ if (expr.type !== "AssignmentExpression") return;

exports.AssignmentExpression = function (node, parent, scope, context, file) {
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!t.isPattern(node.left)) return;

@@ -324,3 +324,3 @@

exports.VariableDeclaration = function (node, parent, scope, context, file) {
exports.VariableDeclaration = function (node, parent, scope, file) {
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;

@@ -327,0 +327,0 @@ if (!variableDeclarationhasPattern(node)) return;

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

exports.ForOfStatement = function (node, parent, scope, context, file) {
exports.ForOfStatement = function (node, parent, scope, file) {
var callback = spec;
if (file.isLoose("es6.forOf")) callback = loose;
var build = callback(node, parent, scope, context, file);
var build = callback(node, parent, scope, file);
var declar = build.declar;

@@ -38,3 +38,3 @@ var loop = build.loop;

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

@@ -76,3 +76,3 @@ var declar, id;

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

@@ -79,0 +79,0 @@ var declar;

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

exports.ImportDeclaration = function (node, parent, scope, context, file) {
exports.ImportDeclaration = function (node, parent, scope, file) {
var nodes = [];

@@ -27,3 +27,3 @@

exports.ExportDeclaration = function (node, parent, scope, context, file) {
exports.ExportDeclaration = function (node, parent, scope, file) {
var nodes = [];

@@ -30,0 +30,0 @@ var i;

@@ -18,6 +18,6 @@ "use strict";

var iifeVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (t.isReferencedIdentifier(node, parent) && state.scope.hasOwnReference(node.name)) {
state.iife = true;
context.stop();
this.stop();
}

@@ -24,0 +24,0 @@ }

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

exports.ObjectExpression = function (node, parent, scope, context, file) {
exports.ObjectExpression = function (node, parent, scope, file) {
var hasComputed = false;

@@ -12,0 +12,0 @@

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

exports.Property = function (node, parent, scope, context, file) {
exports.Property = function (node, parent, scope, file) {
if (node.method) {

@@ -14,0 +14,0 @@ node.method = false;

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

exports.ArrayExpression = function (node, parent, scope, context, file) {
exports.ArrayExpression = function (node, parent, scope, file) {
var elements = node.elements;

@@ -63,3 +63,3 @@ if (!hasSpread(elements)) return;

exports.CallExpression = function (node, parent, scope, context, file) {
exports.CallExpression = function (node, parent, scope, file) {
var args = node.arguments;

@@ -104,3 +104,3 @@ if (!hasSpread(args)) return;

exports.NewExpression = function (node, parent, scope, context, file) {
exports.NewExpression = function (node, parent, scope, file) {
var args = node.arguments;

@@ -107,0 +107,0 @@ if (!hasSpread(args)) return;

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

exports.TaggedTemplateExpression = function (node, parent, scope, context, file) {
exports.TaggedTemplateExpression = function (node, parent, scope, file) {
var args = [];

@@ -16,0 +16,0 @@ var quasi = node.quasi;

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

exports.AssignmentExpression = function (node, parent, scope, context, file) {
exports.AssignmentExpression = function (node, parent, scope, file) {
var left = node.left;

@@ -67,3 +67,3 @@ if (!t.isVirtualPropertyExpression(left)) return;

exports.UnaryExpression = function (node, parent, scope, context, file) {
exports.UnaryExpression = function (node, parent, scope, file) {
var arg = node.argument;

@@ -70,0 +70,0 @@ if (!t.isVirtualPropertyExpression(arg)) return;

"use strict";
var buildComprehension = require("../../helpers/build-comprehension");
var traverse = require("../../../traverse");
var traverse = require("../../../traversal");
var util = require("../../../util");

@@ -10,3 +10,3 @@ var t = require("../../../types");

exports.ComprehensionExpression = function (node, parent, scope, context, file) {
exports.ComprehensionExpression = function (node, parent, scope, file) {
var callback = array;

@@ -13,0 +13,0 @@ if (node.generator) callback = generator;

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

exports.ObjectExpression = function (node, parent, scope, context, file) {
exports.ObjectExpression = function (node, parent, scope, file) {
if (!hasSpread(node)) return;

@@ -25,0 +25,0 @@

@@ -82,4 +82,4 @@ module.exports = {

"minification.propertyLiterals": require("./minification/property-literals"),
"minification.memberExpressionLiterals": require("./minification/member-expression-literals"),
"es3.propertyLiterals": require("./es3/property-literals"),
"es3.memberExpressionLiterals": require("./es3/member-expression-literals"),

@@ -86,0 +86,0 @@ "minification.removeDebugger": require("./minification/remove-debugger"),

@@ -6,8 +6,8 @@ "use strict";

var functionChildrenVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (t.isFunction(node) && !node._aliasFunction) {
return context.skip();
return this.skip();
}
if (node._ignoreAliasFunctions) return context.skip();
if (node._ignoreAliasFunctions) return this.skip();

@@ -29,7 +29,7 @@ var getId;

var functionVisitor = {
enter: function (node, parent, scope, context, state) {
enter: function (node, parent, scope, state) {
if (!node._aliasFunction) {
if (t.isFunction(node)) {
// stop traversal of this node as it'll be hit again by this transformer
return context.skip();
return this.skip();
} else {

@@ -43,3 +43,3 @@ return;

return context.skip();
return this.skip();
}

@@ -46,0 +46,0 @@ };

@@ -5,14 +5,14 @@ "use strict";

exports.ast = {
exit: function (ast, file) {
if (!file.transformers["es6.modules"].canRun()) return;
exports.post = function (file) {
if (!file.transformers["es6.modules"].canRun()) return;
useStrict.wrap(ast.program, function () {
ast.program.body = file.dynamicImports.concat(ast.program.body);
});
var program = file.ast.program;
if (file.moduleFormatter.transform) {
file.moduleFormatter.transform(ast);
}
useStrict.wrap(program, function () {
program.body = file.dynamicImports.concat(program.body);
});
if (file.moduleFormatter.transform) {
file.moduleFormatter.transform(program);
}
};

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

var resolveModuleSource = function (node, parent, scope, context, file) {
var resolveModuleSource = function (node, parent, scope, file) {
var resolveModuleSource = file.opts.resolveModuleSource;

@@ -14,0 +14,0 @@ if (node.source && resolveModuleSource) {

@@ -5,3 +5,3 @@ var t = require("../../../types");

exports.ExpressionStatement = function (node, parent, scope, context) {
exports.ExpressionStatement = function (node) {
// remove consequenceless expressions such as local variables and literals

@@ -15,3 +15,3 @@ //

if (t.isLiteral(expr) || (t.isIdentifier(node) && t.hasBinding(node.name))) {
context.remove();
this.remove();
}

@@ -21,3 +21,3 @@ };

exports.IfStatement = {
exit: function (node, parent, scope, context) {
exit: function (node) {
// todo: in scenarios where we can just return the consequent or

@@ -31,3 +31,3 @@ // alternate we should drop the block statement if it contains no

// we can check if a test will be truthy 100% and if so we can inline
// we can check if a test will be truthy 100% and if so then we can inline
// the consequent and completely ignore the alternate

@@ -43,4 +43,4 @@ //

// we can check if a test will be falsy 100% and if so we can inline
// the alternate if there is one and completely remove the consequent
// we can check if a test will be falsy 100% and if so we can inline the
// alternate if there is one and completely remove the consequent
//

@@ -55,3 +55,3 @@ // if ("") { bar; } else { foo; } -> { foo; }

} else {
return context.remove();
return this.remove();
}

@@ -69,7 +69,6 @@ }

// turn alternate blocks into a consequent and flip the test if the
// consequent block is empty
// if the consequent block is empty turn alternate blocks into a consequent
// and flip the test
//
// if (foo) {} else { bar; }
// if (!foo) { bar; }
// if (foo) {} else { bar; } -> if (!foo) { bar; }
//

@@ -76,0 +75,0 @@

@@ -9,6 +9,6 @@ "use strict";

exports.CallExpression = function (node, parent, scope, context) {
exports.CallExpression = function (node) {
if (isConsole(node.callee)) {
context.remove();
this.remove();
}
};

@@ -5,6 +5,6 @@ var t = require("../../../types");

exports.ExpressionStatement = function (node, parent, scope, context) {
exports.ExpressionStatement = function (node) {
if (t.isIdentifier(node.expression, { name: "debugger" })) {
context.remove();
this.remove();
}
};

@@ -8,4 +8,5 @@ //var t = require("../../../types");

// that wont collide and then call the remap identifier helper
// this transformer **has** to be ran last as it will absolutley
// destroy the scope tree
};

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

exports.Function = function (node, parent, scope, context, file) {
exports.Function = function (node, parent, scope, file) {
if (!node.async || node.generator) return;

@@ -13,0 +13,0 @@

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

exports.Function = function (node, parent, scope, context, file) {
exports.Function = function (node, parent, scope, file) {
if (!node.async || node.generator) return;

@@ -16,0 +16,0 @@

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

exports.JSXNamespacedName = function (node, parent, scope, context, file) {
exports.JSXNamespacedName = function (node, parent, scope, file) {
throw file.errorWithNode(node, "Namespace tags are not supported. ReactJSX is not XML.");

@@ -57,3 +57,3 @@ };

exports.JSXOpeningElement = {
exit: function (node, parent, scope, context, file) {
exit: function (node, parent, scope, file) {
var reactCompat = file.opts.reactCompat;

@@ -264,3 +264,3 @@ var tagExpr = node.name;

exports.ExportDeclaration = function (node, parent, scope, context, file) {
exports.ExportDeclaration = function (node, parent, scope, file) {
if (node.default && react.isCreateClass(node.declaration)) {

@@ -267,0 +267,0 @@ addDisplayName(file.opts.basename, node.declaration);

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

exports.ast = {
before: function (ast, file) {
regenerator.transform(ast, {
includeRuntime: file.opts.includeRegenerator && "if used"
});
exports.Program = {
enter: function (ast) {
regenerator.transform(ast);
this.stop();
}
};

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

var astVisitor = {
enter: function (node, parent, scope, context, file) {
enter: function (node, parent, scope, file) {
var prop;

@@ -35,3 +35,3 @@

if (!node.computed && coreHas(obj) && has(core[obj.name], prop.name) && !scope.getBinding(obj.name)) {
context.skip();
this.skip();
return t.prependToMemberExpression(node, file.get("coreIdentifier"));

@@ -69,23 +69,21 @@ }

exports.ast = {
enter: function (ast, file) {
file.setDynamic("runtimeIdentifier", function () {
return file.addImport("6to5-runtime/helpers", "to5Helpers");
});
exports.post = function (file) {
file.scope.traverse(file.ast, astVisitor, file);
};
file.setDynamic("coreIdentifier", function () {
return file.addImport("6to5-runtime/core-js", "core");
});
exports.pre = function (file) {
file.setDynamic("runtimeIdentifier", function () {
return file.addImport("6to5-runtime/helpers", "to5Helpers");
});
file.setDynamic("regeneratorIdentifier", function () {
return file.addImport("6to5-runtime/regenerator", "regeneratorRuntime");
});
},
file.setDynamic("coreIdentifier", function () {
return file.addImport("6to5-runtime/core-js", "core");
});
after: function (ast, file) {
file.scope.traverse(ast, astVisitor, file);
}
file.setDynamic("regeneratorIdentifier", function () {
return file.addImport("6to5-runtime/regenerator", "regeneratorRuntime");
});
};
exports.Identifier = function (node, parent, scope, context, file) {
exports.Identifier = function (node, parent, scope, file) {
if (node.name === "regeneratorRuntime" && t.isReferenced(node, parent)) {

@@ -92,0 +90,0 @@ return file.get("regeneratorIdentifier");

@@ -6,7 +6,6 @@ "use strict";

exports.ast = {
exit: function (ast) {
if (!useStrict.has(ast.program)) {
ast.program.body.unshift(t.expressionStatement(t.literal("use strict")));
}
exports.post = function (file) {
var program = file.ast.program;
if (!useStrict.has(program)) {
program.body.unshift(t.expressionStatement(t.literal("use strict")));
}

@@ -16,4 +15,4 @@ };

exports.FunctionDeclaration =
exports.FunctionExpression = function (node, parent, scope, context) {
context.skip();
exports.FunctionExpression = function () {
this.skip();
};

@@ -20,0 +19,0 @@

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

exports.BindFunctionExpression = function (node, parent, scope, context, file) {
exports.BindFunctionExpression = function (node, parent, scope, file) {
var buildCall = function (args) {

@@ -32,0 +32,0 @@ var param = scope.generateUidIdentifier("val");

@@ -8,4 +8,4 @@ "use strict";

var visitor = {
enter: function (node, parent, scope, context, state) {
if (t.isFunction(node)) return;
enter: function (node, parent, scope, state) {
if (t.isFunction(node)) return this.skip();

@@ -23,6 +23,5 @@ if (t.isReturnStatement(node) && node.argument) {

exports.Property =
exports.MethodDefinition = function (node, parent, scope, context, file) {
exports.MethodDefinition = function (node, parent, scope, file) {
if (node.kind !== "memo") return;
node.kind = "get";
file.checkNode(node, scope);

@@ -44,2 +43,4 @@ var value = node.value;

scope.traverse(value, visitor, state);
return node;
};

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

exports.AssignmentExpression = function (node, parent, scope, context, file) {
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!isProtoAssignmentExpression(node)) return;

@@ -37,3 +37,3 @@

exports.ExpressionStatement = function (node, parent, scope, context, file) {
exports.ExpressionStatement = function (node, parent, scope, file) {
var expr = node.expression;

@@ -47,3 +47,3 @@ if (!t.isAssignmentExpression(expr, { operator: "=" })) return;

exports.ObjectExpression = function (node, parent, scope, context, file) {
exports.ObjectExpression = function (node, parent, scope, file) {
var proto;

@@ -50,0 +50,0 @@

@@ -7,4 +7,4 @@ "use strict";

exports.UnaryExpression = function (node, parent, scope, context, file) {
context.skip();
exports.UnaryExpression = function (node, parent, scope, file) {
this.skip();

@@ -11,0 +11,0 @@ if (node.operator === "typeof") {

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

exports.ForInStatement =
exports.ForOfStatement = function (node, parent, scope, context, file) {
exports.ForOfStatement = function (node, parent, scope, file) {
var left = node.left;

@@ -9,0 +9,0 @@ if (t.isVariableDeclaration(left)) {

"use strict";
exports.MethodDefinition =
exports.Property = function (node, parent, scope, context, file) {
exports.Property = function (node, parent, scope, file) {
if (node.kind === "set" && node.value.params.length !== 1) {

@@ -6,0 +6,0 @@ throw file.errorWithNode(node.value, "Setters must have only one parameter");

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

exports.Identifier = function (node, parent, scope, context, file) {
exports.Identifier = function (node, parent, scope, file) {
if (!t.isReferenced(node, parent)) return;

@@ -11,0 +11,0 @@ if (scope.hasBinding(node.name)) return;

"use strict";
var toFastProperties = require("../helpers/to-fast-properties");
var defaults = require("lodash/object/defaults");
var isString = require("lodash/lang/isString");
var compact = require("lodash/array/compact");
var esutils = require("esutils");

@@ -9,5 +12,2 @@ var object = require("../helpers/object");

var uniq = require("lodash/array/uniq");
var compact = require("lodash/array/compact");
var defaults = require("lodash/object/defaults");
var isString = require("lodash/lang/isString");

@@ -14,0 +14,0 @@ var t = exports;

@@ -5,19 +5,17 @@ "use strict";

var estraverse = require("estraverse");
var codeFrame = require("./helpers/code-frame");
var traverse = require("./traverse");
var cloneDeep = require("lodash/lang/cloneDeep");
var contains = require("lodash/collection/contains");
var traverse = require("./traversal");
var isNumber = require("lodash/lang/isNumber");
var isString = require("lodash/lang/isString");
var isRegExp = require("lodash/lang/isRegExp");
var isEmpty = require("lodash/lang/isEmpty");
var parse = require("./helpers/parse");
var debug = require("debug/node");
var acorn = require("acorn-6to5");
var path = require("path");
var util = require("util");
var each = require("lodash/collection/each");
var has = require("lodash/object/has");
var fs = require("fs");
var t = require("./types");
var each = require("lodash/collection/each");
var isNumber = require("lodash/lang/isNumber");
var isString = require("lodash/lang/isString");
var isRegExp = require("lodash/lang/isRegExp");
var isEmpty = require("lodash/lang/isEmpty");
var cloneDeep = require("lodash/lang/cloneDeep");
var has = require("lodash/object/has");
var contains = require("lodash/collection/contains");

@@ -85,3 +83,3 @@ exports.inherits = util.inherits;

var templateVisitor = {
enter: function (node, parent, scope, context, nodes) {
enter: function (node, parent, scope, nodes) {
if (t.isIdentifier(node) && has(nodes, node.name)) {

@@ -128,57 +126,4 @@ return nodes[node.name];

exports.normalizeAst = function (ast, comments, tokens) {
if (ast && ast.type === "Program") {
return t.file(ast, comments || [], tokens || []);
} else {
throw new Error("Not a valid ast?");
}
};
exports.parse = function (opts, code, callback) {
try {
var comments = [];
var tokens = [];
var ast = acorn.parse(code, {
allowImportExportEverywhere: opts.allowImportExportEverywhere,
allowReturnOutsideFunction: !opts._anal,
ecmaVersion: opts.experimental ? 7 : 6,
playground: opts.playground,
strictMode: opts.strictMode,
onComment: comments,
locations: true,
onToken: tokens,
ranges: true
});
estraverse.attachComments(ast, comments, tokens);
ast = exports.normalizeAst(ast, comments, tokens);
if (callback) {
return callback(ast);
} else {
return ast;
}
} catch (err) {
if (!err._6to5) {
err._6to5 = true;
var message = opts.filename + ": " + err.message;
var loc = err.loc;
if (loc) {
var frame = codeFrame(code, loc.line, loc.column + 1);
message += frame;
}
if (err.stack) err.stack = err.stack.replace(err.message, message);
err.message = message;
}
throw err;
}
};
exports.parseTemplate = function (loc, code) {
var ast = exports.parse({ filename: loc }, code).program;
var ast = parse({ filename: loc }, code).program;
return traverse.removeProperties(ast);

@@ -185,0 +130,0 @@ };

{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "3.3.12",
"version": "3.4.0",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -9,3 +9,6 @@ "homepage": "https://6to5.org/",

"preferGlobal": true,
"main": "lib/6to5/index.js",
"main": "lib/6to5/api/node.js",
"browser": {
"./lib/6to5/api/register/node.js": "./lib/6to5/api/register/browser.js"
},
"bin": {

@@ -17,6 +20,2 @@ "6to5": "./bin/6to5/index.js",

},
"browser": {
"./lib/6to5/index.js": "./lib/6to5/browser.js",
"./lib/6to5/register.js": "./lib/6to5/register-browser.js"
},
"keywords": [

@@ -23,0 +22,0 @@ "harmony",

@@ -1,1 +0,1 @@

module.exports = require("./lib/6to5/register");
module.exports = require("./lib/6to5/api/register/node");

Sorry, the diff of this file is not supported yet

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

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