Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36423f2e78 | ||
|
|
06eaba5ad1 | ||
|
|
7e8cd2ca8a | ||
|
|
2541dcf960 | ||
|
|
5d45e1475c | ||
|
|
9964de9b2f | ||
|
|
5b75b11628 | ||
|
|
1890fb5bd3 | ||
|
|
df20b3df5a | ||
|
|
56e74dfd10 | ||
|
|
513d05143a |
@@ -3,6 +3,7 @@ language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
|
||||
branches:
|
||||
except:
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* **Bug Fix**
|
||||
* Fix temp variables not being properly pushed inside of `while` loops.
|
||||
* **New Feature**
|
||||
* Add `auxilaryComment`/`--auxilary-comment` option that prepends comments to auxilary helpers.
|
||||
* Add `auxiliaryComment`/`--auxiliary-comment` option that prepends comments to auxiliary helpers.
|
||||
|
||||
## 3.6.5
|
||||
|
||||
|
||||
@@ -13,6 +13,13 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
||||
|
||||
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
|
||||
## 4.2.0
|
||||
|
||||
* **Polish**
|
||||
* Use an assignment instead of a define for `__esModule` in loose mode.
|
||||
* **Internal**
|
||||
* Add error for `eval();` usage and enable strict mode for parsing.
|
||||
|
||||
## 4.1.0
|
||||
|
||||
* **New Feature**
|
||||
|
||||
@@ -26,7 +26,7 @@ commander.option("-c, --remove-comments", "Remove comments from the compiled cod
|
||||
commander.option("-M, --module-ids", "Insert module id in modules", false);
|
||||
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
|
||||
commander.option("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
|
||||
commander.option("-a, --auxilary-comment [comment]", "Comment text to prepend to all auxilary code");
|
||||
commander.option("-a, --auxiliary-comment [comment]", "Comment text to prepend to all auxiliary code");
|
||||
|
||||
commander.on("--help", function () {
|
||||
var outKeys = function (title, obj) {
|
||||
@@ -100,7 +100,7 @@ if (errors.length) {
|
||||
|
||||
exports.opts = {
|
||||
keepModuleIdExtensions: commander.keepModuleIdExtensions,
|
||||
auxilaryComment: commander.auxilaryComment,
|
||||
auxiliaryComment: commander.auxiliaryComment,
|
||||
externalHelpers: commander.externalHelpers,
|
||||
sourceMapName: commander.outFile,
|
||||
experimental: commander.experimental,
|
||||
|
||||
@@ -16,7 +16,8 @@ exports.messages = {
|
||||
readOnly: "$1 is read-only",
|
||||
modulesIllegalExportName: "Illegal export $1",
|
||||
unknownForHead: "Unknown node type $1 in ForStatement",
|
||||
didYouMean: "Did you mean $1?"
|
||||
didYouMean: "Did you mean $1?",
|
||||
evalInStrictMode: "eval is not allowed in strict mode"
|
||||
};
|
||||
|
||||
exports.get = function (key) {
|
||||
|
||||
@@ -87,7 +87,7 @@ File.validOptions = [
|
||||
"experimental",
|
||||
"resolveModuleSource",
|
||||
"externalHelpers",
|
||||
"auxilaryComment",
|
||||
"auxiliaryComment",
|
||||
|
||||
// these are used by plugins
|
||||
"ignore",
|
||||
@@ -302,8 +302,8 @@ File.prototype.isConsequenceExpressionStatement = function (node) {
|
||||
return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0;
|
||||
};
|
||||
|
||||
File.prototype.attachAuxilaryComment = function (node) {
|
||||
var comment = this.opts.auxilaryComment;
|
||||
File.prototype.attachAuxiliaryComment = function (node) {
|
||||
var comment = this.opts.auxiliaryComment;
|
||||
if (comment) {
|
||||
node.leadingComments = node.leadingComments || [];
|
||||
node.leadingComments.push({
|
||||
@@ -368,7 +368,7 @@ File.prototype.parse = function (code) {
|
||||
var opts = this.opts;
|
||||
|
||||
opts.allowImportExportEverywhere = this.isLoose("es6.modules");
|
||||
//opts.strictMode = this.transformers.useStrict.canRun();
|
||||
opts.strictMode = this.transformers.useStrict.canRun();
|
||||
|
||||
return parse(opts, code, function (tree) {
|
||||
self.transform(tree);
|
||||
|
||||
@@ -41,12 +41,7 @@ transform._ensureTransformerNames = function (type, rawKeys) {
|
||||
keys = keys.concat(transform.namespaces[key]);
|
||||
} else {
|
||||
// invalid key
|
||||
throw new ReferenceError(
|
||||
"Unknown transformer " + key + " specified in " + type + " - " +
|
||||
"transformer key names have been changed in 3.0.0 see " +
|
||||
"the changelog for more info " +
|
||||
"https://github.com/babel/babel/blob/master/CHANGELOG.md#300"
|
||||
);
|
||||
throw new ReferenceError("Unknown transformer " + key + " specified in " + type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ CommonJSFormatter.prototype.init = function () {
|
||||
scope.rename("module");
|
||||
|
||||
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
|
||||
file.ast.program.body.push(util.template("exports-module-declaration", true));
|
||||
var templateName = "exports-module-declaration";
|
||||
if (this.file.isLoose("es6.modules")) templateName += "-loose";
|
||||
file.ast.program.body.push(util.template(templateName, true));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
exports.__esModule = true;
|
||||
@@ -20,7 +20,7 @@ exports.Program = function (node, parent, scope, file) {
|
||||
var declarNode = t.variableDeclarator(declar.id, declar.init);
|
||||
|
||||
if (declar.init) {
|
||||
node.body.unshift(file.attachAuxilaryComment(t.variableDeclaration(kind, [declarNode])));
|
||||
node.body.unshift(file.attachAuxiliaryComment(t.variableDeclaration(kind, [declarNode])));
|
||||
} else {
|
||||
kinds[kind] = kinds[kind] || [];
|
||||
kinds[kind].push(declarNode);
|
||||
@@ -28,7 +28,7 @@ exports.Program = function (node, parent, scope, file) {
|
||||
}
|
||||
|
||||
for (kind in kinds) {
|
||||
node.body.unshift(file.attachAuxilaryComment(t.variableDeclaration(kind, kinds[kind])));
|
||||
node.body.unshift(file.attachAuxiliaryComment(t.variableDeclaration(kind, kinds[kind])));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var useStrict = require("../../helpers/use-strict");
|
||||
var messages = require("../../../messages");
|
||||
var t = require("../../../types");
|
||||
|
||||
exports.Program = function (program) {
|
||||
@@ -17,3 +18,9 @@ exports.FunctionExpression = function () {
|
||||
exports.ThisExpression = function () {
|
||||
return t.identifier("undefined");
|
||||
};
|
||||
|
||||
exports.CallExpression = function (node, parent, scope, file) {
|
||||
if (t.isIdentifier(node.callee, { name: "eval" })) {
|
||||
throw file.errorWithNode(node, messages.get("evalInStrictMode"));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "4.1.1",
|
||||
"version": "4.2.0",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"repository": "babel/babel",
|
||||
@@ -38,7 +38,7 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn-babel": "0.11.1-32",
|
||||
"acorn-babel": "0.11.1-33",
|
||||
"ast-types": "~0.6.1",
|
||||
"chalk": "^0.5.1",
|
||||
"chokidar": "^0.12.6",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "babel-runtime",
|
||||
"description": "babel selfContained runtime",
|
||||
"version": "4.0.2",
|
||||
"version": "4.1.1",
|
||||
"repository": "babel/babel",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||
}
|
||||
1
test/fixtures/transformation/es6-modules-common/loose/actual.js
vendored
Normal file
1
test/fixtures/transformation/es6-modules-common/loose/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export var foo = 5;
|
||||
4
test/fixtures/transformation/es6-modules-common/loose/expected.js
vendored
Normal file
4
test/fixtures/transformation/es6-modules-common/loose/expected.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
"use strict";
|
||||
|
||||
var foo = exports.foo = 5;
|
||||
exports.__esModule = true;
|
||||
3
test/fixtures/transformation/es6-modules-common/loose/options.json
vendored
Normal file
3
test/fixtures/transformation/es6-modules-common/loose/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"loose": "es6.modules"
|
||||
}
|
||||
Reference in New Issue
Block a user