Comparing version 3.2.1 to 3.3.0
@@ -14,2 +14,3 @@ #!/usr/bin/env node | ||
commander.option("-w, --watch", "Recompile files on changes"); | ||
commander.option("-r, --runtime", "Replace 6to5 declarations with references to a runtime"); | ||
commander.option("-e, --experimental", "Enable experimental support for proposed ES7 features"); | ||
@@ -112,2 +113,3 @@ commander.option("-p, --playground", "Enable playground support"); | ||
comments: !commander.removeComments, | ||
runtime: commander.runtime, | ||
modules: commander.modules, | ||
@@ -114,0 +116,0 @@ loose: commander.loose |
module.exports = detect; | ||
//var useragent = require("useragent"); | ||
var traverse = require("../traverse"); | ||
var SYNTAX_KEYS = require("./syntax-keys"); | ||
var traverse = require("../traverse"); | ||
var visitors = traverse.explode(require("./visitors")); | ||
@@ -8,0 +6,0 @@ |
@@ -27,3 +27,3 @@ "use strict"; | ||
this.lastStatements = []; | ||
this.opts = File.normaliseOptions(opts); | ||
this.opts = this.normaliseOptions(opts); | ||
this.ast = {}; | ||
@@ -80,2 +80,3 @@ | ||
"resolveModuleSource", | ||
"runtime", | ||
@@ -89,3 +90,3 @@ // these are used by plugins | ||
File.normaliseOptions = function (opts) { | ||
File.prototype.normaliseOptions = function (opts) { | ||
opts = clone(opts); | ||
@@ -114,2 +115,3 @@ | ||
modules: "common", | ||
runtime: false, | ||
loose: [], | ||
@@ -153,2 +155,6 @@ code: true, | ||
if (opts.runtime) { | ||
this.set("runtimeIdentifier", t.identifier("to5Runtime")); | ||
} | ||
opts.blacklist = transform._ensureTransformerNames("blacklist", opts.blacklist); | ||
@@ -155,0 +161,0 @@ opts.whitelist = transform._ensureTransformerNames("whitelist", opts.whitelist); |
@@ -43,5 +43,7 @@ "use strict"; | ||
CodeGenerator.normaliseOptions = function (code, opts) { | ||
var indent = detectIndent(code); | ||
var style = indent.indent; | ||
if (!style || style === " ") style = " "; | ||
var style = " "; | ||
if (code) { | ||
var indent = detectIndent(code).indent; | ||
if (indent && indent !== " ") style = indent; | ||
} | ||
@@ -48,0 +50,0 @@ return merge({ |
@@ -10,2 +10,4 @@ "use strict"; | ||
exports.runtime = require("./build-runtime"); | ||
exports.types = require("./types"); | ||
@@ -12,0 +14,0 @@ |
@@ -6,5 +6,5 @@ "use strict"; | ||
var DefaultFormatter = require("./_default"); | ||
var contains = require("lodash/collection/contains"); | ||
var util = require("../../util"); | ||
var t = require("../../types"); | ||
var contains = require("lodash/collection/contains"); | ||
@@ -11,0 +11,0 @@ function CommonJSFormatter() { |
@@ -44,2 +44,4 @@ module.exports = TransformerPass; | ||
if (transformer.playground && !opts.playground) return false; | ||
return true; | ||
@@ -46,0 +48,0 @@ }; |
@@ -20,2 +20,3 @@ "use strict"; | ||
this.experimental = !!transformer.experimental; | ||
this.playground = !!transformer.playground; | ||
this.secondPass = !!transformer.secondPass; | ||
@@ -22,0 +23,0 @@ this.optional = !!transformer.optional; |
@@ -34,3 +34,3 @@ "use strict"; | ||
traverse(node, visitor, scope, { | ||
constants: scope.getAllOfKind("const"), | ||
constants: scope.getAllDeclarationsOfKind("const"), | ||
file: file | ||
@@ -37,0 +37,0 @@ }); |
@@ -61,13 +61,13 @@ "use strict"; | ||
node.body.body.unshift( | ||
util.template("rest", { | ||
ARGUMENTS: argsId, | ||
ARRAY_KEY: arrKey, | ||
ARRAY_LEN: arrLen, | ||
START: start, | ||
ARRAY: rest, | ||
KEY: key, | ||
LEN: len, | ||
}) | ||
); | ||
var loop = util.template("rest", { | ||
ARGUMENTS: argsId, | ||
ARRAY_KEY: arrKey, | ||
ARRAY_LEN: arrLen, | ||
START: start, | ||
ARRAY: rest, | ||
KEY: key, | ||
LEN: len, | ||
}); | ||
loop._blockHoist = node.params.length + 1; | ||
node.body.body.unshift(loop); | ||
}; |
@@ -55,5 +55,2 @@ module.exports = { | ||
// needs to be after block scoping since regenerator doesn't support it | ||
regenerator: require("./other/regenerator"), | ||
"es6.parameters.default": require("./es6/parameters.default"), | ||
@@ -64,2 +61,4 @@ "es6.parameters.rest": require("./es6/parameters.rest"), | ||
regenerator: require("./other/regenerator"), | ||
// needs to be after `regenerator` due to needing `regeneratorRuntime` references | ||
@@ -66,0 +65,0 @@ // needs to be after `es6.forOf` due to needing `Symbol.iterator` references |
"use strict"; | ||
var build = require("../../helpers/build-conditional-assignment-operator-transformer"); | ||
var t = require("../../../types"); | ||
var t = require("../../../types"); | ||
exports.playground = true; | ||
build(exports, { | ||
@@ -7,0 +9,0 @@ is: function (node, file) { |
@@ -6,2 +6,4 @@ "use strict"; | ||
exports.playground = true; | ||
build(exports, { | ||
@@ -8,0 +10,0 @@ is: function (node) { |
@@ -5,2 +5,4 @@ "use strict"; | ||
exports.playground = true; | ||
exports.BindMemberExpression = function (node, parent, scope) { | ||
@@ -7,0 +9,0 @@ var object = node.object; |
@@ -6,2 +6,4 @@ "use strict"; | ||
exports.playground = true; | ||
var visitor = { | ||
@@ -8,0 +10,0 @@ enter: function (node, parent, scope, context, state) { |
"use strict"; | ||
var levenshtein = require("../../../helpers/levenshtein"); | ||
var t = require("../../../types"); | ||
exports.optional = true; | ||
exports.Identifier = function (node, parent, scope, context, file) { | ||
if (!scope.has(node.name, true)) { | ||
throw file.errorWithNode(node, "Reference to undeclared variable", ReferenceError); | ||
if (!t.isReferenced(node, parent)) return; | ||
if (scope.has(node.name, true)) return; | ||
var msg = "Reference to undeclared variable"; | ||
// get the closest declaration to offer as a suggestion | ||
// the variable name may have just been mistyped | ||
var declarations = scope.getAllDeclarations(); | ||
var closest; | ||
var shortest = -1; | ||
for (var name in declarations) { | ||
var distance = levenshtein(node.name, name); | ||
if (distance <= 0 || distance > 3) continue; | ||
if (distance <= shortest) continue; | ||
closest = name; | ||
shortest = distance; | ||
} | ||
if (closest) { | ||
msg += " - Did you mean " + closest + "?"; | ||
} | ||
// | ||
throw file.errorWithNode(node, msg, ReferenceError); | ||
}; |
@@ -329,8 +329,27 @@ "use strict"; | ||
/** | ||
* Walks the scope tree and gathers **all** declarations. | ||
* | ||
* @returns {Object} | ||
*/ | ||
Scope.prototype.getAllDeclarations = function () { | ||
var ids = object(); | ||
var scope = this; | ||
do { | ||
defaults(ids, scope.declarations); | ||
scope = scope.parent; | ||
} while (scope); | ||
return ids; | ||
}; | ||
/** | ||
* Walks the scope tree and gathers all declarations of `kind`. | ||
* | ||
* @param {String} kind | ||
* @returns {Object} | ||
*/ | ||
Scope.prototype.getAllOfKind = function (kind) { | ||
Scope.prototype.getAllDeclarationsOfKind = function (kind) { | ||
var ids = object(); | ||
@@ -337,0 +356,0 @@ |
{ | ||
"name": "6to5-core", | ||
"description": "Turn ES6 code into readable vanilla ES5 with source maps", | ||
"version": "3.2.1", | ||
"version": "3.3.0", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
@@ -41,3 +41,3 @@ "homepage": "https://6to5.org/", | ||
"private": "0.1.6", | ||
"regenerator-6to5": "0.8.9-7", | ||
"regenerator-6to5": "0.8.9-8", | ||
"regexpu": "1.1.0", | ||
@@ -44,0 +44,0 @@ "roadrunner": "1.0.4", |
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
1388417
139
11723
+ Addedregenerator-6to5@0.8.9-8(transitive)
- Removedregenerator-6to5@0.8.9-7(transitive)
Updatedregenerator-6to5@0.8.9-8