Compare commits

...

34 Commits

Author SHA1 Message Date
Sebastian McKenzie
36423f2e78 v4.2.0 2015-02-18 11:28:53 +11:00
Sebastian McKenzie
06eaba5ad1 add 4.2.0 changelog 2015-02-18 11:26:46 +11:00
Sebastian McKenzie
7e8cd2ca8a i'm a terrible spellerer #777 2015-02-18 11:24:51 +11:00
Sebastian McKenzie
2541dcf960 bump acorn 2015-02-18 10:25:59 +11:00
Sebastian McKenzie
5d45e1475c Merge branch 'master' of github.com:6to5/6to5 2015-02-18 10:22:33 +11:00
Sebastian McKenzie
9964de9b2f remove redundant unknown transformer error message 2015-02-18 10:22:07 +11:00
Sebastian McKenzie
5b75b11628 add error message to use of eval(); and enable strict mode on the parser 2015-02-18 10:21:57 +11:00
Sebastian McKenzie
1890fb5bd3 add loose mode to __esModule 2015-02-18 10:21:32 +11:00
Sebastian McKenzie
df20b3df5a Merge pull request #815 from kolodny/iojs-test
add iojs to travis
2015-02-18 08:46:38 +11:00
Moshe Kolodny
56e74dfd10 add iojs to travis 2015-02-17 13:31:45 -05:00
Sebastian McKenzie
513d05143a 4.1.1 2015-02-18 00:01:55 +11:00
Sebastian McKenzie
84068943dd v4.1.1 2015-02-18 00:01:18 +11:00
Sebastian McKenzie
d3c75378ec v4.1.0 2015-02-17 23:59:38 +11:00
Sebastian McKenzie
ffe058bf69 add BABEL_CACHE_PATH and BABEL_DISABLE_CACHE environment variables 2015-02-17 23:06:19 +11:00
Sebastian McKenzie
765d95cd6f Merge branch 'master' of github.com:6to5/6to5 2015-02-17 16:57:26 +11:00
Sebastian McKenzie
33e82222ca remove 0.11 from travis.yml - #813, #807 2015-02-17 16:56:28 +11:00
Sebastian McKenzie
82d1c29696 Merge pull request #812 from sindresorhus/modularize-shebang-regex
modularize `SHEBANG_REGEX`
2015-02-17 16:33:12 +11:00
Sindre Sorhus
211c9802a5 modularize SHEBANG_REGEX
https://github.com/sindresorhus/shebang-regex
2015-02-17 12:26:36 +07:00
Sebastian McKenzie
f5a81e71bd Merge pull request #811 from sindresorhus/drop-helpers-clone
drop `helpers/clone`
2015-02-17 15:55:51 +11:00
Sindre Sorhus
4ea7a864fa drop helpers/clone
it's misleading as it doesn't actually do a deepClone, not even a clone
2015-02-17 11:42:24 +07:00
Sebastian McKenzie
d645659770 Merge pull request #810 from sindresorhus/modularize-normalisePathSeparator
modularize `normalisePathSeparator`
2015-02-17 15:24:06 +11:00
Sindre Sorhus
75ec9c8f2c modularize normalisePathSeparator
https://github.com/sindresorhus/slash
2015-02-17 11:19:12 +07:00
Sebastian McKenzie
3bffdc2be0 Merge pull request #809 from sindresorhus/modularize-isinteger
modularize `util.isInteger`
2015-02-17 15:12:18 +11:00
Sindre Sorhus
820db09613 modularize util.isInteger
https://github.com/parshap/js-is-integer
2015-02-17 11:10:00 +07:00
Sebastian McKenzie
f24ae6feab Merge pull request #808 from sindresorhus/modularize-trimright
modularize `util.trimRight`
2015-02-17 14:54:11 +11:00
Sindre Sorhus
5b09114b85 modularize util.trimRight
https://github.com/sindresorhus/trim-right
2015-02-17 10:51:02 +07:00
Sebastian McKenzie
28c948e5ea Merge pull request #806 from sindresorhus/modularize-isabsolute
modularize `util.isAbsolute`
2015-02-17 14:29:26 +11:00
Sindre Sorhus
bbf5a8f4aa modularize util.isAbsolute
by using a polyfill of the Node 0.12 `path.isAbsolute()` method

https://github.com/sindresorhus/path-is-absolute
2015-02-17 10:17:04 +07:00
Sebastian McKenzie
5f2865883b Merge branch 'master' of github.com:6to5/6to5 2015-02-17 14:09:49 +11:00
Sebastian McKenzie
c8433f950d fix 4.0.2 changelog... 2015-02-17 14:09:09 +11:00
Sebastian McKenzie
9135e700c6 Merge pull request #805 from sindresorhus/modularize-repeat
modularize `util.repeat`
2015-02-17 13:28:49 +11:00
Sindre Sorhus
eb17568c94 modularize util.repeat
https://github.com/sindresorhus/repeating
2015-02-17 09:25:00 +07:00
Sebastian McKenzie
407ff1e4a0 add 4.0.2 changelog 2015-02-17 13:12:31 +11:00
Sebastian McKenzie
fbaaf63c49 4.0.2 2015-02-17 13:11:15 +11:00
27 changed files with 110 additions and 116 deletions

View File

@@ -2,8 +2,8 @@ sudo: false
language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"
- "iojs"
branches:
except:

View File

@@ -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

View File

@@ -13,6 +13,28 @@ _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**
* Add `BABEL_CACHE_PATH` and `BABEL_DISABLE_CACHE` environment variables.
* **Internal**
* Replace many internal util functions with modules. Thanks [@sindresorhus](https://github.com/sindresorhus)!
## 4.0.2
* **Bug Fix**
* Fix generators not properly propagating their internal declarations.
* **Polish**
* Update setter param length error message.
* Use ranges on dependencies.
## 4.0.0
* 6to5 is now known as Babel.

View File

@@ -1,13 +1,14 @@
#!/usr/bin/env node
var commander = require("commander");
var Module = require("module");
var babel = require("../lib/babel/api/node");
var path = require("path");
var repl = require("repl");
var util = require("../lib/babel/util");
var vm = require("vm");
var _ = require("lodash");
var pathIsAbsolute = require("path-is-absolute");
var commander = require("commander");
var Module = require("module");
var babel = require("../lib/babel/api/node");
var path = require("path");
var repl = require("repl");
var util = require("../lib/babel/util");
var vm = require("vm");
var _ = require("lodash");
var program = new commander.Command("babel-node");
@@ -85,7 +86,7 @@ if (program.eval || program.print) {
// make the filename absolute
var filename = args[0]
if (!util.isAbsolute(filename)) args[0] = path.join(process.cwd(), filename);
if (!pathIsAbsolute(filename)) args[0] = path.join(process.cwd(), filename);
// add back on node and concat the sliced args
process.argv = ["node"].concat(args);

View File

@@ -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,

View File

@@ -4,7 +4,7 @@ var path = require("path");
var os = require("os");
var fs = require("fs");
var FILENAME = path.join(os.tmpdir(), "babel.json");
var FILENAME = process.env.BABEL_CACHE_PATH || path.join(os.tmpdir(), "babel.json");
var data = {};
exports.save = function () {
@@ -12,6 +12,8 @@ exports.save = function () {
};
exports.load = function () {
if (process.env.BABEL_DISABLE_CACHE) return;
process.on("exit", exports.save);
var sigint = function () {

View File

@@ -2,10 +2,11 @@
module.exports = Buffer;
var repeating = require("repeating");
var trimRight = require("trim-right");
var isBoolean = require("lodash/lang/isBoolean");
var includes = require("lodash/collection/includes");
var isNumber = require("lodash/lang/isNumber");
var util = require("../util");
function Buffer(position, format) {
this.position = position;
@@ -15,14 +16,14 @@ function Buffer(position, format) {
}
Buffer.prototype.get = function () {
return util.trimRight(this.buf);
return trimRight(this.buf);
};
Buffer.prototype.getIndent = function () {
if (this.format.compact || this.format.concise) {
return "";
} else {
return util.repeat(this._indent, this.format.indent.style);
return repeating(this.format.indent.style, this._indent);
}
};
@@ -81,7 +82,7 @@ Buffer.prototype.newline = function (i, removeLast) {
if (isNumber(i)) {
if (this.endsWith("{\n")) i--;
if (this.endsWith(util.repeat(i, "\n"))) return;
if (this.endsWith(repeating("\n", i > 0 ? i : 0))) return;
while (i--) {
this._newline(removeLast);
@@ -153,9 +154,9 @@ Buffer.prototype.endsWith = function (str) {
return d >= 0 && this.buf.lastIndexOf(str) === d;
};
Buffer.prototype.isLast = function (cha, trimRight) {
Buffer.prototype.isLast = function (cha, shouldTrimRight) {
var buf = this.buf;
if (trimRight) buf = util.trimRight(buf);
if (shouldTrimRight) buf = trimRight(buf);
var last = buf[buf.length - 1];
if (Array.isArray(cha)) {

View File

@@ -1,8 +1,8 @@
"use strict";
var util = require("../../util");
var t = require("../../types");
var isNumber = require("lodash/lang/isNumber");
var isInteger = require("is-integer");
var isNumber = require("lodash/lang/isNumber");
var t = require("../../types");
exports.UnaryExpression = function (node, print) {
var hasSpace = /[a-z]$/.test(node.operator);
@@ -146,7 +146,7 @@ exports.MemberExpression = function (node, print) {
this.push("]");
} else {
// 5..toFixed(2);
if (t.isLiteral(obj) && util.isInteger(obj.value) && !SCIENTIFIC_NOTATION.test(obj.value.toString())) {
if (t.isLiteral(obj) && isInteger(obj.value) && !SCIENTIFIC_NOTATION.test(obj.value.toString())) {
this.push(".");
}

View File

@@ -1,7 +1,7 @@
"use strict";
var util = require("../../util");
var t = require("../../types");
var repeating = require("repeating");
var t = require("../../types");
exports.WithStatement = function (node, print) {
this.keyword("with");
@@ -190,7 +190,7 @@ exports.VariableDeclaration = function (node, print, parent) {
var sep = ",";
if (hasInits) {
sep += "\n" + util.repeat(node.kind.length + 1);
sep += "\n" + repeating(" ", node.kind.length + 1);
} else {
sep += " ";
}

View File

@@ -9,13 +9,13 @@ module.exports.CodeGenerator = CodeGenerator;
var detectIndent = require("detect-indent");
var Whitespace = require("./whitespace");
var repeating = require("repeating");
var SourceMap = require("./source-map");
var Position = require("./position");
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");
@@ -344,7 +344,7 @@ CodeGenerator.prototype._printComments = function (comments) {
}
var indent = Math.max(self.indentSize(), column);
val = val.replace(/\n/g, "\n" + util.repeat(indent));
val = val.replace(/\n/g, "\n" + repeating(" ", indent));
}
if (column === 0) {

View File

@@ -1,12 +0,0 @@
"use strict";
module.exports = function cloneDeep(obj) {
var obj2 = {};
if (!obj) return obj2;
for (var key in obj) {
obj2[key] = obj[key];
}
return obj2;
};

View File

@@ -1,8 +1,8 @@
// syntax highlighting based on https://github.com/dominictarr/ansi-highlight by the fantastic Dominic Tarr
var tokenize = require("js-tokenizer");
var chalk = require("chalk");
var util = require("../util");
var repeating = require("repeating");
var tokenize = require("js-tokenizer");
var chalk = require("chalk");
var defs = {
string1: "red",
@@ -62,15 +62,15 @@ module.exports = function (lines, lineNumber, colNumber) {
var gutter = curr === lineNumber ? "> " : " ";
var sep = curr + util.repeat(width + 1);
var sep = curr + repeating(" ", width + 1);
gutter += sep + "| ";
var str = gutter + line;
if (colNumber && curr === lineNumber) {
str += "\n";
str += util.repeat(gutter.length - 2);
str += "|" + util.repeat(colNumber) + "^";
str += repeating(" ", gutter.length - 2);
str += "|" + repeating(" ", colNumber) + "^";
}
return str;

View File

@@ -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) {

View File

@@ -2,17 +2,17 @@
module.exports = File;
var SHEBANG_REGEX = /^\#\!.*/;
var sourceMapToComment = require("source-map-to-comment");
var shebangRegex = require("shebang-regex");
var isFunction = require("lodash/lang/isFunction");
var transform = require("./index");
var generate = require("../generation");
var defaults = require("lodash/object/defaults");
var includes = require("lodash/collection/includes");
var clone = require("../helpers/clone");
var assign = require("lodash/object/assign");
var parse = require("../helpers/parse");
var Scope = require("../traversal/scope");
var slash = require("slash");
var util = require("../util");
var path = require("path");
var each = require("lodash/collection/each");
@@ -87,7 +87,7 @@ File.validOptions = [
"experimental",
"resolveModuleSource",
"externalHelpers",
"auxilaryComment",
"auxiliaryComment",
// these are used by plugins
"ignore",
@@ -97,7 +97,7 @@ File.validOptions = [
];
File.prototype.normalizeOptions = function (opts) {
opts = clone(opts);
opts = assign({}, opts);
for (var key in opts) {
if (key[0] !== "_" && File.validOptions.indexOf(key) < 0) {
@@ -128,9 +128,9 @@ File.prototype.normalizeOptions = function (opts) {
});
// normalize windows path separators to unix
opts.filename = util.normalisePathSeparator(opts.filename);
opts.filename = slash(opts.filename);
if (opts.sourceRoot) {
opts.sourceRoot = util.normalisePathSeparator(opts.sourceRoot);
opts.sourceRoot = slash(opts.sourceRoot);
}
opts.basename = path.basename(opts.filename, path.extname(opts.filename));
@@ -246,12 +246,13 @@ File.prototype.getModuleFormatter = function (type) {
};
File.prototype.parseShebang = function (code) {
var shebangMatch = code.match(SHEBANG_REGEX);
var shebangMatch = shebangRegex.exec(code);
if (shebangMatch) {
this.shebang = shebangMatch[0];
// remove shebang
code = code.replace(SHEBANG_REGEX, "");
code = code.replace(shebangRegex, "");
}
return code;
@@ -301,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({
@@ -367,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);

View File

@@ -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);
}
}

View File

@@ -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));
}
};

View File

@@ -0,0 +1 @@
exports.__esModule = true;

View File

@@ -6,7 +6,7 @@ var TransformerPass = require("./transformer-pass");
var isFunction = require("lodash/lang/isFunction");
var traverse = require("../traversal");
var isObject = require("lodash/lang/isObject");
var clone = require("../helpers/clone");
var assign = require("lodash/object/assign");
var each = require("lodash/collection/each");
/**
@@ -16,7 +16,7 @@ var each = require("lodash/collection/each");
*/
function Transformer(key, transformer, opts) {
transformer = clone(transformer);
transformer = assign({}, transformer);
var take = function (key) {
var val = transformer[key];

View File

@@ -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])));
}
});

View File

@@ -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"));
}
};

View File

@@ -5,7 +5,6 @@ require("./patch");
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");
@@ -30,14 +29,6 @@ exports.canCompile = function (filename, altExts) {
exports.canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"];
exports.normalisePathSeparator = function (filename) {
return filename.replace(/\\/g, "/");
};
exports.isInteger = function (i) {
return isNumber(i) && i % 1 === 0;
};
exports.resolve = function (loc) {
try {
return require.resolve(loc);
@@ -46,10 +37,6 @@ exports.resolve = function (loc) {
}
};
exports.trimRight = function (str) {
return str.replace(/[\n\s]+$/g, "");
};
exports.list = function (val) {
return val ? val.split(",") : [];
};
@@ -69,13 +56,6 @@ exports.arrayify = function (val) {
throw new TypeError("illegal type for arrayify");
};
exports.isAbsolute = function (loc) {
if (!loc) return false;
if (loc[0] === "/") return true; // unix
if (loc[1] === ":" && loc[2] === "\\") return true; // windows
return false;
};
var templateVisitor = {
enter: function (node, parent, scope, nodes) {
if (t.isExpressionStatement(node)) {
@@ -114,17 +94,6 @@ exports.template = function (name, nodes, keepExpression) {
}
};
exports.repeat = function (width, cha) {
cha = cha || " ";
var result = "";
for (var i = 0; i < width; i++) {
result += cha;
}
return result;
};
exports.parseTemplate = function (loc, code) {
var ast = parse({ filename: loc }, code).program;
return traverse.removeProperties(ast);

View File

@@ -1,7 +1,7 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.0.2",
"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",
@@ -50,16 +50,22 @@
"esutils": "^1.1.6",
"fs-readdir-recursive": "^0.1.0",
"globals": "^6.2.0",
"is-integer": "^1.0.4",
"js-tokenizer": "^1.3.3",
"leven": "^1.0.1",
"lodash": "^3.2.0",
"output-file-sync": "^1.1.0",
"path-is-absolute": "^1.0.0",
"private": "^0.1.6",
"regenerator-babel": "0.8.10-2",
"regexpu": "^1.1.1",
"repeating": "^1.1.2",
"shebang-regex": "^1.0.0",
"slash": "^1.0.0",
"source-map": "^0.1.43",
"source-map-support": "^0.2.9",
"source-map-to-comment": "^1.0.0"
"source-map-to-comment": "^1.0.0",
"trim-right": "^1.0.0"
},
"devDependencies": {
"browserify": "^8.1.3",

View File

@@ -1,7 +1,7 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "4.0.1",
"version": "4.1.1",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
}

View File

@@ -0,0 +1 @@
export var foo = 5;

View File

@@ -0,0 +1,4 @@
"use strict";
var foo = exports.foo = 5;
exports.__esModule = true;

View File

@@ -0,0 +1,3 @@
{
"loose": "es6.modules"
}

View File

@@ -50,16 +50,6 @@ suite("util", function () {
assert.ok(!util.canCompile("/scripts/test.css"));
});
test("isAbsolute", function () {
assert.ok(util.isAbsolute("/test.js"));
assert.ok(util.isAbsolute("C:\\test.js"));
assert.ok(!util.isAbsolute());
assert.ok(!util.isAbsolute(""));
assert.ok(!util.isAbsolute("test.js"));
assert.ok(!util.isAbsolute("test/test.js"));
});
test("list", function () {
assert.deepEqual(util.list(undefined), []);
assert.deepEqual(util.list(false), []);