6to5
Advanced tools
Comparing version 3.6.2 to 3.6.3
@@ -19,3 +19,5 @@ var outputFileSync = require("output-file-sync"); | ||
var data = util.compile(src, { sourceMapName: dest }); | ||
var data = util.compile(src, { | ||
sourceFileName: path.relative(dest + "/..", src) | ||
}); | ||
@@ -22,0 +24,0 @@ if (commander.sourceMaps) { |
@@ -24,3 +24,3 @@ var readdir = require("fs-readdir-recursive"); | ||
exports.transform = function (filename, code, opts) { | ||
opts = _.extend(opts || {}, index.opts); | ||
opts = _.defaults(opts || {}, index.opts); | ||
opts.filename = filename; | ||
@@ -27,0 +27,0 @@ |
@@ -21,5 +21,6 @@ "use strict"; | ||
function File(opts) { | ||
this.dynamicImportIds = {}; | ||
this.dynamicImported = []; | ||
this.dynamicImports = []; | ||
this.dynamicImportedNoDefault = []; | ||
this.dynamicImportIds = {}; | ||
this.dynamicImported = []; | ||
this.dynamicImports = []; | ||
@@ -277,3 +278,3 @@ this.dynamicData = {}; | ||
File.prototype.addImport = function (source, name) { | ||
File.prototype.addImport = function (source, name, noDefault) { | ||
name = name || source; | ||
@@ -288,3 +289,5 @@ var id = this.dynamicImportIds[name]; | ||
declar._blockHoist = 3; | ||
this.dynamicImported.push(declar); | ||
if (noDefault) this.dynamicImportedNoDefault.push(declar); | ||
@@ -291,0 +294,0 @@ this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports); |
@@ -7,6 +7,6 @@ "use strict"; | ||
var CommonFormatter = require("./common"); | ||
var includes = require("lodash/collection/includes"); | ||
var values = require("lodash/object/values"); | ||
var util = require("../../util"); | ||
var t = require("../../types"); | ||
var includes = require("lodash/collection/includes"); | ||
var values = require("lodash/object/values"); | ||
@@ -85,3 +85,3 @@ function AMDFormatter() { | ||
if (includes(this.file.dynamicImported, node)) { | ||
if (includes(this.file.dynamicImportedNoDefault, node)) { | ||
// Prevent unnecessary renaming of dynamic imports. | ||
@@ -91,3 +91,3 @@ this.ids[node.source.value] = ref; | ||
// import * as bar from "foo"; | ||
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) { | ||
} else if (!includes(this.file.dynamicImported, node) && t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) { | ||
// import foo from "foo"; | ||
@@ -94,0 +94,0 @@ ref = t.callExpression(this.file.addHelper("interop-require"), [ref]); |
@@ -34,4 +34,4 @@ "use strict"; | ||
if (t.isSpecifierDefault(specifier)) { | ||
if (!includes(this.file.dynamicImported, node)) { | ||
if (this.noInteropRequireImport) { | ||
if (!includes(this.file.dynamicImportedNoDefault, node)) { | ||
if (this.noInteropRequireImport || includes(this.file.dynamicImported, node)) { | ||
ref = t.memberExpression(ref, t.identifier("default")); | ||
@@ -38,0 +38,0 @@ } else { |
@@ -58,2 +58,4 @@ "use strict"; | ||
if (type === "enter" || type === "exit") return; | ||
if (isFunction(fns)) fns = { enter: fns }; | ||
@@ -60,0 +62,0 @@ |
@@ -13,4 +13,2 @@ "use strict"; | ||
if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) { | ||
if (t.isMemberExpression(node.left || node.argument)) return; | ||
var ids = t.getBindingIdentifiers(node); | ||
@@ -17,0 +15,0 @@ |
@@ -89,3 +89,2 @@ module.exports = { | ||
_aliasFunctions: require("./internal/alias-functions"), | ||
_moduleFormatter: require("./internal/module-formatter"), | ||
@@ -95,2 +94,4 @@ "spec.typeofSymbol": require("./spec/typeof-symbol"), | ||
_moduleFormatter: require("./internal/module-formatter"), | ||
"es3.propertyLiterals": require("./es3/property-literals"), | ||
@@ -97,0 +98,0 @@ "es3.memberExpressionLiterals": require("./es3/member-expression-literals"), |
@@ -5,7 +5,5 @@ "use strict"; | ||
exports.post = function (file) { | ||
exports.Program = function (program, parent, scope, file) { | ||
if (!file.transformers["es6.modules"].canRun()) return; | ||
var program = file.ast.program; | ||
useStrict.wrap(program, function () { | ||
@@ -12,0 +10,0 @@ program.body = file.dynamicImports.concat(program.body); |
@@ -18,5 +18,5 @@ "use strict"; | ||
node, | ||
t.memberExpression(file.addImport("bluebird"), t.identifier("coroutine")), | ||
t.memberExpression(file.addImport("bluebird", null, true), t.identifier("coroutine")), | ||
scope | ||
); | ||
}; |
@@ -81,4 +81,4 @@ "use strict"; | ||
exports.post = function (file) { | ||
file.scope.traverse(file.ast, astVisitor, file); | ||
exports.Program = function (node, parent, scope, file) { | ||
scope.traverse(node, astVisitor, file); | ||
}; | ||
@@ -85,0 +85,0 @@ |
@@ -6,4 +6,3 @@ "use strict"; | ||
exports.post = function (file) { | ||
var program = file.ast.program; | ||
exports.Program = function (program) { | ||
if (!useStrict.has(program)) { | ||
@@ -10,0 +9,0 @@ program.body.unshift(t.expressionStatement(t.literal("use strict"))); |
@@ -112,3 +112,3 @@ "use strict"; | ||
var opts = this.opts; | ||
var fn = opts[key]; | ||
var fn = opts[key] || opts; | ||
if (opts[node.type]) fn = opts[node.type][key] || fn; | ||
@@ -115,0 +115,0 @@ |
@@ -617,3 +617,2 @@ "use strict"; | ||
ClassDeclaration: ["id"], | ||
MemberExpression: ["object"], | ||
SpreadElement: ["argument"], | ||
@@ -620,0 +619,0 @@ RestElement: ["argument"], |
@@ -112,2 +112,4 @@ "use strict"; | ||
if (template.body.length > 1) return template.body; | ||
var node = template.body[0]; | ||
@@ -114,0 +116,0 @@ |
{ | ||
"name": "6to5", | ||
"description": "Turn ES6 code into readable vanilla ES5 with source maps", | ||
"version": "3.6.2", | ||
"version": "3.6.3", | ||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
@@ -36,3 +36,3 @@ "homepage": "https://6to5.org/", | ||
"dependencies": { | ||
"acorn-6to5": "0.11.1-30", | ||
"acorn-6to5": "0.11.1-31", | ||
"ast-types": "~0.6.1", | ||
@@ -39,0 +39,0 @@ "chalk": "^0.5.1", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1566868
13264
+ Addedacorn-6to5@0.11.1-31(transitive)
- Removedacorn-6to5@0.11.1-30(transitive)
Updatedacorn-6to5@0.11.1-31