Compare commits

...

51 Commits

Author SHA1 Message Date
Sebastian McKenzie
f93daa3ca5 v4.0.2 2015-02-17 13:10:18 +11:00
Sebastian McKenzie
7fc1d04f9b Merge branch 'master' of github.com:6to5/6to5 2015-02-17 13:07:35 +11:00
Sebastian McKenzie
d6a34f02ca upgrade regenerator-babel #803 2015-02-17 13:07:22 +11:00
Sebastian McKenzie
fc3cb099c5 Merge pull request #802 from sindresorhus/sourcemapcomment
modularize the `sourceMapToComment` method
2015-02-17 12:49:12 +11:00
Sindre Sorhus
fc663d54fa modularize the sourceMapToComment method
https://github.com/sindresorhus/source-map-to-comment
2015-02-17 08:46:23 +07:00
Sebastian McKenzie
bf2418db66 set loose property assignments to computed if it's a literal 2015-02-17 10:45:24 +11:00
Sebastian McKenzie
5bd75db0b6 update setter validation error message 2015-02-17 09:34:45 +11:00
Sebastian McKenzie
13b3335a67 Merge pull request #800 from sindresorhus/remove-unused-deps
remove unused dependencies
2015-02-17 09:26:17 +11:00
Sindre Sorhus
4987f9e668 remove unused dependencies 2015-02-17 05:23:50 +07:00
Sebastian McKenzie
e585aa6bed use ranges for devDependencies 2015-02-17 09:23:48 +11:00
Sebastian McKenzie
d6c7be760b update settersInvalidParamLength error message - closes #797 2015-02-17 09:17:06 +11:00
Sebastian McKenzie
a19321ea69 update dependency ranges 2015-02-17 09:13:23 +11:00
Sebastian McKenzie
73fc1ac64e Merge pull request #794 from sindresorhus/bump-deps
bump dependencies
2015-02-17 09:11:10 +11:00
Sindre Sorhus
1d14764471 bump dependencies
The only breaking change is 599dd668fd and it doesn't affect `babel` since it doesn't use that property.
2015-02-17 05:02:32 +07:00
Sebastian McKenzie
e336ecd9cc Merge pull request #792 from sindresorhus/remove-moot-dep
Remove `supports-color` dependency as it's available in `chalk`
2015-02-17 08:53:42 +11:00
Sebastian McKenzie
5737a96f9f Merge pull request #793 from sindresorhus/levenshtein
Use `leven` module for levenshtein distance
2015-02-17 08:53:02 +11:00
Sebastian McKenzie
d7d4ec54cd Merge pull request #796 from richgilbank/babel-rename-makefile
Fix leftover `to5`
2015-02-17 08:49:18 +11:00
Rich Gilbank
98056e26af Update Makefile 2015-02-16 11:52:20 -05:00
Sindre Sorhus
afd07c9172 Use leven module for levenshtein distance
https://github.com/sindresorhus/leven

No point in bundling code like this.

Leven is also the fastest one: https://github.com/sindresorhus/leven#benchmark
2015-02-16 22:36:20 +07:00
Sindre Sorhus
af785126bf Remove supports-color dependency as it's available in chalk 2015-02-16 22:28:51 +07:00
Sebastian McKenzie
39c5849604 Merge branch 'master' of github.com:6to5/6to5 2015-02-16 14:37:08 +11:00
Sebastian McKenzie
1b6e465317 add email to license 2015-02-16 14:36:57 +11:00
Sebastian McKenzie
15dff73cc8 Merge pull request #783 from mathiasbynens/patch-3
Update to regexpu v1.1.1
2015-02-16 03:05:59 +11:00
Mathias Bynens
186a15b3ce Update to regexpu v1.1.1 2015-02-15 17:05:35 +01:00
Sebastian McKenzie
610e52d767 4.0.1 2015-02-16 01:12:13 +11:00
Sebastian McKenzie
b0467fcb6d v4.0.1 2015-02-16 01:11:46 +11:00
Sebastian McKenzie
05be131647 rename bin tests to reflect new babel name 2015-02-16 01:08:26 +11:00
Sebastian McKenzie
f2300a5463 Revert "don't push array pattern uid if it's a local variable"
This reverts commit 86acc99fb3.
2015-02-16 01:06:14 +11:00
Sebastian McKenzie
86acc99fb3 don't push array pattern uid if it's a local variable 2015-02-16 01:01:42 +11:00
Sebastian McKenzie
21909cee76 rename runtime CLI flag to externalHelpers 2015-02-16 01:01:29 +11:00
Sebastian McKenzie
c97b53b52d fix 6to5 changelog 2015-02-16 01:01:14 +11:00
Sebastian McKenzie
c5e01146fd update rogue 6to5 occurences to babel 2015-02-15 20:39:46 +11:00
Sebastian McKenzie
010ff3ec31 reset transformer deprecation keys 2015-02-15 20:29:48 +11:00
Sebastian McKenzie
17532bfd82 update to 4.0.0 2015-02-15 19:54:14 +11:00
Sebastian McKenzie
545e9499c3 update readme to reflect babel name change 2015-02-15 19:54:08 +11:00
Sebastian McKenzie
02046c5448 rename runtime option to externalHelpers 2015-02-15 19:53:59 +11:00
Sebastian McKenzie
1d34d03ac8 rename to babel 2015-02-15 18:09:05 +11:00
Sebastian McKenzie
e05aed0394 support all loops when adding declarations - #779 2015-02-15 10:27:56 +11:00
Sebastian McKenzie
2d3b595a8b 3.6.5 2015-02-15 10:26:52 +11:00
Sebastian McKenzie
8f0b7683a1 v3.6.5 2015-02-14 23:05:13 +11:00
Sebastian McKenzie
f0d2cbb055 update 3.6.5 changelog 2015-02-14 22:57:57 +11:00
Sebastian McKenzie
602c5e0ca0 upgrade core-js 2015-02-14 22:56:49 +11:00
Sebastian McKenzie
2a2dff0eaf remap head variables when a closure is required in blockScoping transformer - fixes #763 2015-02-14 20:21:34 +11:00
Sebastian McKenzie
e1151e08c9 register default globals as bindings 2015-02-14 19:08:41 +11:00
Sebastian McKenzie
84f54ca3c7 rename defaultDeclarations to globals 2015-02-14 19:08:02 +11:00
Sebastian McKenzie
5fb793b75f add validation.react transformer 2015-02-14 19:07:54 +11:00
Sebastian McKenzie
1adc9bfc70 use t.buildMatchMemberExpression in selfContained transformer 2015-02-14 19:07:46 +11:00
Sebastian McKenzie
3649fad485 ensureBlock on if statements with expression return statements - fixes #764 2015-02-14 19:07:23 +11:00
Sebastian McKenzie
0e1743738e add auxilary comment option to prepend to helpers - #777 2015-02-14 16:53:41 +11:00
Sebastian McKenzie
6ad16302cd update 3.6.3 changelog 2015-02-14 13:29:57 +11:00
Sebastian McKenzie
4b6b7af332 3.6.4 2015-02-14 13:29:52 +11:00
334 changed files with 1459 additions and 1414 deletions

View File

4
.gitignore vendored
View File

@@ -11,5 +11,5 @@ test/tmp
coverage
dist
.package.json
packages/6to5-runtime/*.js
packages/6to5-runtime/regenerator/*.js
packages/babel-runtime/*.js
packages/babel-runtime/regenerator/*.js

2
.gitmodules vendored
View File

@@ -3,7 +3,7 @@
url = https://github.com/google/traceur-compiler
[submodule "vendor/regenerator"]
path = vendor/regenerator
url = https://github.com/6to5/regenerator-6to5
url = https://github.com/babel/regenerator-babel
[submodule "vendor/test262"]
path = vendor/test262
url = https://github.com/tc39/test262

View File

@@ -1,5 +1,5 @@
{
"excludeFiles": ["lib/6to5/transformation/templates"],
"excludeFiles": ["lib/babel/transformation/templates"],
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},

View File

@@ -1 +1 @@
lib/6to5/transformation/templates
lib/babel/transformation/templates

View File

@@ -1,7 +1,7 @@
node_modules
*.log
*.cache
lib/6to5/transformation/templates
lib/babel/transformation/templates
test
benchmark
Makefile

1093
CHANGELOG-6to5.md Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,7 @@
Contributions are always welcome, no matter how large or small. Before
contributing, please read the
[code of conduct](https://github.com/6to5/6to5/blob/master/CODE_OF_CONDUCT.md).
[code of conduct](https://github.com/babel/babel/blob/master/CODE_OF_CONDUCT.md).
**NOTE:** Please do not send pull requests that fix linting issues. It's highly
likely that they've already been fixed by the time it's submitted and it just
@@ -13,7 +13,7 @@ pollutes the git tree.
#### Workflow
* Fork the repository
* Clone your fork and change directory to it (`git clone git@github.com:yourUserName/6to5.git && cd 6to5`)
* Clone your fork and change directory to it (`git clone git@github.com:yourUserName/babel.git && cd babel`)
* Install the project dependencies (`make bootstrap`)
* Link your forked clone (`npm link`)
* Develop your changes ensuring you're fetching updates from upstream often

View File

@@ -1,4 +1,4 @@
Copyright (c) 2014-2015 Sebastian McKenzie
Copyright (c) 2014-2015 Sebastian McKenzie <sebmck@gmail.com>
MIT License

View File

@@ -5,31 +5,31 @@ UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs
JSHINT_CMD = node_modules/jshint/bin/jshint
MOCHA_CMD = node_modules/mocha/bin/_mocha
JSCS_CMD = node_modules/jscs/bin/jscs
6TO5_CMD = node_modules/6to5/bin/6to5
BABEL_CMD = node_modules/babel/bin/babel
export NODE_ENV = test
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap publish-core publish-runtime build-core watch-core
build-core:
#node $(6TO5_CMD) src --out-dir lib
#node $(BABEL_CMD) src --out-dir lib
watch-core:
#node $(6TO5_CMD) src --out-dir lib --watch
#node $(BABEL_CMD) src --out-dir lib --watch
build:
mkdir -p dist
node tools/cache-templates
node $(BROWSERIFY_CMD) -e lib/6to5/polyfill.js >dist/polyfill.js
node $(BROWSERIFY_CMD) -e lib/babel/polyfill.js >dist/polyfill.js
node $(UGLIFY_CMD) dist/polyfill.js >dist/polyfill.min.js
node $(BROWSERIFY_CMD) lib/6to5/api/browser.js -s to5 >dist/6to5.js
node $(UGLIFY_CMD) dist/6to5.js >dist/6to5.min.js
node $(BROWSERIFY_CMD) lib/babel/api/browser.js -s babel >dist/babel.js
node $(UGLIFY_CMD) dist/babel.js >dist/babel.min.js
node bin/6to5-runtime >dist/runtime.js
node $(UGLIFY_CMD) dist/runtime.js >dist/runtime.min.js
node bin/babel-external-helpers >dist/external-helpers.js
node $(UGLIFY_CMD) dist/external-helpers.js >dist/external-helpers.min.js
rm -rf templates.json
@@ -49,17 +49,16 @@ test: lint
test-simple:
# excludes test262
export SIMPLE_6TO5_TESTS=1; \
export SIMPLE_BABEL_TESTS=1; \
make test
test-all:
# includes traceur, esnext, regenerator
export ALL_6TO5_TESTS=1; \
export ALL_BABEL_TESTS=1; \
make test
test-cov:
rm -rf coverage
export SIMPLE_6TO5_TESTS=1; \
export SIMPLE_BABEL_TESTS=1; \
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
test-travis: build-core bootstrap
@@ -71,7 +70,7 @@ test-browser:
node tools/cache-templates
node tools/cache-tests
node $(BROWSERIFY_CMD) -e test/_browser.js >dist/6to5-test.js
node $(BROWSERIFY_CMD) -e test/_browser.js >dist/babel-test.js
rm -rf templates.json tests.json
test -n "`which open`" && open test/browser.html
@@ -85,9 +84,9 @@ publish:
npm version $$version --message "v%s"
make build
cp dist/6to5.min.js browser.js
cp dist/babel.min.js browser.js
cp dist/polyfill.min.js browser-polyfill.js
cp dist/runtime.min.js runtime.js
cp dist/external-helpers.min.js external-helpers.js
node tools/cache-templates
test -f templates.json
@@ -99,12 +98,12 @@ publish:
make publish-core
make publish-runtime
rm -rf templates.json browser.js browser-polyfill.js runtime.js
rm -rf templates.json browser.js browser-polyfill.js external-helpers.js
publish-runtime:
cd packages; \
node build-runtime.js; \
cd 6to5-runtime; \
cd babel-runtime; \
npm publish
publish-core:

View File

@@ -1,3 +0,0 @@
# Notes
* Wildcard exports/imports wont normalize if `export default` is a non-object. See [#224](https://github.com/6to5/6to5/issues/224).

View File

@@ -1,12 +1,12 @@
<p align="center">
<img alt="6to5" src="https://raw.githubusercontent.com/6to5/logo/master/logo.png" width="546">
<img alt="babel" src="https://raw.githubusercontent.com/babel/logo/master/logo.png" width="546">
</p>
<p align="center">
<strong>6to5</strong> turns ES6+ code into vanilla ES5, so you can use next generation features <strong>today.</strong>
<strong>Babel</strong> is a transpiler for writing next generation JavaScript.
</p>
<p align="center">
For more information view the <a href="https://6to5.github.io">documentation</a>. For
support visit the <a href="https://gitter.im/6to5/6to5">gitter room</a>.
For more information view the <a href="https://babeljs.io/">documentation</a>. For
support visit the <a href="https://gitter.im/babel/babel">gitter room</a>.
</p>

View File

@@ -1,4 +0,0 @@
#!/usr/bin/env node
var runtime = require("../lib/6to5/build-runtime");
console.log(runtime());

View File

@@ -2,14 +2,14 @@
var commander = require("commander");
var Module = require("module");
var babel = require("../lib/babel/api/node");
var path = require("path");
var repl = require("repl");
var to5 = require("../lib/6to5/api/node");
var util = require("../lib/6to5/util");
var util = require("../lib/babel/util");
var vm = require("vm");
var _ = require("lodash");
var program = new commander.Command("6to5-node");
var program = new commander.Command("babel-node");
program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print [code]", "Evaluate script and print result");
@@ -28,7 +28,7 @@ program.parse(process.argv);
//
to5.register({
babel.register({
experimental: program.experimental,
extensions: program.extensions,
playground: program.playground,
@@ -41,7 +41,7 @@ to5.register({
//
var _eval = function (code, filename) {
code = to5.transform(code, {
code = babel.transform(code, {
filename: filename,
blacklist: ["useStrict"].concat(program.blacklist || []),
whitelist: program.whitelist,
@@ -60,7 +60,7 @@ if (program.eval || program.print) {
if (program.print) console.log(result);
} else {
if (program.args.length) {
// slice all arguments up to the first filename since they're 6to5 args that we handle
// slice all arguments up to the first filename since they're babel args that we handle
var args = process.argv.slice(2);
var i = 0;

4
bin/babel-external-helpers Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env node
var runtime = require("../lib/babel/build-external-helpers");
console.log(runtime());

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env node
var opts = require("./6to5").opts;
var opts = require("./babel").opts;
opts.optional = (opts.optional || []).concat("minification");
opts.format = {
compact: true

View File

@@ -2,10 +2,10 @@
/**
* This tiny wrapper file checks for known node flags and appends them
* when found, before invoking the "real" _6to5-node(1) executable.
* when found, before invoking the "real" _babel-node(1) executable.
*/
var args = [__dirname + "/_6to5-node"];
var args = [__dirname + "/_babel-node"];
process.argv.slice(2).forEach(function(arg){
var flag = arg.split("=")[0];

View File

@@ -1,10 +1,10 @@
var sourceMap = require("source-map");
var chokidar = require("chokidar");
var util2 = require("../../lib/6to5/util");
var path = require("path");
var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
var sourceMapToComment = require("source-map-to-comment");
var sourceMap = require("source-map");
var chokidar = require("chokidar");
var path = require("path");
var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
module.exports = function (commander, filenames) {
var results = [];
@@ -42,7 +42,7 @@ module.exports = function (commander, filenames) {
});
if (commander.sourceMapsInline || (!commander.outFile && commander.sourceMaps)) {
code += "\n" + util2.sourceMapToComment(map);
code += "\n" + sourceMapToComment(map);
}
return {

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env node
var commander = require("commander");
var transform = require("../../lib/6to5/transformation");
var util = require("../../lib/6to5/util");
var transform = require("../../lib/babel/transformation");
var util = require("../../lib/babel/util");
var fs = require("fs");
var each = require("lodash/collection/each");
var keys = require("lodash/object/keys");
@@ -11,7 +11,7 @@ commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to
commander.option("-s, --source-maps", "Save source map alongside the compiled code");
commander.option("-f, --filename [filename]", "Filename to use when reading from stdin - this will be used in source-maps, errors etc [stdin]", "stdin");
commander.option("-w, --watch", "Recompile files on changes");
commander.option("-r, --runtime", "Replace 6to5 declarations with references to a runtime");
commander.option("-r, --external-helpers", "Replace helpers with references to a `babelHelpers` global");
commander.option("-e, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-p, --playground", "Enable playground support");
@@ -26,6 +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.on("--help", function () {
var outKeys = function (title, obj) {
@@ -99,6 +100,8 @@ if (errors.length) {
exports.opts = {
keepModuleIdExtensions: commander.keepModuleIdExtensions,
auxilaryComment: commander.auxilaryComment,
externalHelpers: commander.externalHelpers,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
@@ -109,13 +112,12 @@ exports.opts = {
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules,
loose: commander.loose
};
setTimeout(function () {
// this is just a hack to give `6to5-minify` and other files including this
// this is just a hack to give `babel-minify` and other files including this
// time to modify `exports.opts`
var fn;

View File

@@ -1,8 +1,8 @@
var readdir = require("fs-readdir-recursive");
var index = require("./index");
var util = require("../../lib/6to5/util");
var babel = require("../../lib/babel/api/node");
var util = require("../../lib/babel/util");
var path = require("path");
var to5 = require("../../lib/6to5/api/node");
var fs = require("fs");
var _ = require("lodash");
@@ -26,7 +26,7 @@ exports.transform = function (filename, code, opts) {
var result;
try {
result = to5.transform(code, opts);
result = babel.transform(code, opts);
} catch (e) {
if (e instanceof SyntaxError) {
console.error("SyntaxError:", e.message);

3
bin/deprecated/6to5 Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
console.error("`6to5` has been renamed to `babel`");
require("../babel");

3
bin/deprecated/6to5-minify Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
console.error("`6to5-minify` has been renamed to `babel-minify`");
require("../babel-minify");

3
bin/deprecated/6to5-node Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
console.error("`6to5-node` has been renamed to `babel-node`");
require("../_babel-node");

3
bin/deprecated/6to5-runtime Executable file
View File

@@ -0,0 +1,3 @@
#!/usr/bin/env node
console.error("`6to5-runtime` has been renamed to `babel-external-helpers`");
require("../babel-external-helpers");

View File

@@ -1 +1 @@
See [6to5.github.io/docs](https://github.com/6to5/6to5.github.io/tree/master/docs).
See [babel.github.io/docs](https://github.com/babel/babel.github.io/tree/master/docs).

View File

@@ -1,38 +0,0 @@
// taken from stackoverflow, it's crap i know.
module.exports = function (a, b) {
if (a.length === 0) return b.length;
if (b.length === 0) return a.length;
var matrix = [];
// increment along the first column of each row
var i;
for (i = 0; i <= b.length; i++) {
matrix[i] = [i];
}
// increment each column in the first row
var j;
for (j = 0; j <= a.length; j++) {
matrix[0][j] = j;
}
// Fill in the rest of the matrix
for (i = 1; i <= b.length; i++) {
for (j = 1; j <= a.length; j++) {
if (b.charAt(i - 1) == a.charAt(j - 1)) {
matrix[i][j] = matrix[i - 1][j - 1];
} else {
matrix[i][j] = Math.min(
matrix[i - 1][j - 1] + 1, // substitution
Math.min(
matrix[i][j - 1] + 1, // insertion
matrix[i - 1][j] + 1) // deletion
);
}
}
}
return matrix[b.length][a.length];
};

View File

@@ -1,9 +0,0 @@
"use strict";
if (global._6to5Polyfill) {
throw new Error("only one instance of 6to5/polyfill is allowed");
}
global._6to5Polyfill = true;
require("core-js/shim");
require("regenerator-6to5/runtime");

View File

@@ -1,41 +0,0 @@
{
"specNoForInOfAssignment": "validation.noForInOfAssignment",
"specSetters": "validation.setters",
"specBlockScopedFunctions": "spec.blockScopedFunctions",
"malletOperator": "playground.malletOperator",
"methodBinding": "playground.methodBinding",
"memoizationOperator": "playground.memoizationOperator",
"objectGetterMemoization": "playground.objectGetterMemoization",
"modules": "es6.modules",
"propertyNameShorthand": "es6.properties.shorthand",
"arrayComprehension": "es7.comprehensions",
"generatorComprehension": "es7.comprehensions",
"arrowFunctions": "es6.arrowFunctions",
"classes": "es6.classes",
"objectSpread": "es7.objectRestSpread",
"es7.objectSpread": "es7.objectRestSpread",
"exponentiationOperator": "es7.exponentiationOperator",
"spread": "es6.spread",
"templateLiterals": "es6.templateLiterals",
"propertyMethodAssignment": "es6.properties.shorthand",
"computedPropertyNames": "es6.properties.computed",
"defaultParameters": "es6.parameters.default",
"restParameters": "es6.parameters.rest",
"destructuring": "es6.destructuring",
"forOf": "es6.forOf",
"unicodeRegex": "es6.unicodeRegex",
"abstractReferences": "es7.abstractReferences",
"constants": "es6.constants",
"letScoping": "es6.letScoping",
"blockScopingTDZ": "es6.blockScopingTDZ",
"generators": "regenerator",
"protoToAssign": "spec.protoToAssign",
"typeofSymbol": "spec.typeofSymbol",
"coreAliasing": "selfContained",
"undefinedToVoid": "spec.undefinedToVoid",
"undeclaredVariableCheck": "validation.undeclaredVariableCheck",
"specPropertyLiterals": "es3.propertyLiterals",
"specMemberExpressionLiterals": "es3.memberExpressionLiterals",
"minification.propertyLiterals": "es3.propertyLiterals",
"minification.memberExpressionLiterals": "es3.memberExpressionLiterals"
}

View File

@@ -38,7 +38,7 @@ transform.load = function (url, callback, opts, hold) {
var runScripts = function () {
var scripts = [];
var types = ["text/ecmascript-6", "text/6to5", "module"];
var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
var index = 0;
var exec = function () {

View File

@@ -7,7 +7,7 @@ var fs = require("fs");
exports.version = require("../../../package").version;
exports.runtime = require("../build-runtime");
exports.buildExternalHelpers = require("../build-external-helpers");
exports.types = require("../types");
@@ -23,7 +23,7 @@ exports.polyfill = function () {
exports.canCompile = util.canCompile;
// do not use this - this is for use by official maintained 6to5 plugins
// do not use this - this is for use by official maintained babel plugins
exports._util = util;
exports.transform = transform;

View File

@@ -1,6 +1,6 @@
"use strict";
// required to safely use 6to5/register within a browserify codebase
// required to safely use babel/register within a browserify codebase
module.exports = function () {};

View File

@@ -4,7 +4,7 @@ var path = require("path");
var os = require("os");
var fs = require("fs");
var FILENAME = path.join(os.tmpdir(), "6to5.json");
var FILENAME = path.join(os.tmpdir(), "babel.json");
var data = {};
exports.save = function () {

View File

@@ -5,9 +5,9 @@ require("../../polyfill");
var sourceMapSupport = require("source-map-support");
var registerCache = require("./cache");
var extend = require("lodash/object/extend");
var babel = require("../node");
var each = require("lodash/collection/each");
var util = require("../../util");
var to5 = require("../node");
var fs = require("fs");
sourceMapSupport.install({
@@ -54,7 +54,7 @@ var compile = function (filename) {
}
if (!result) {
result = to5.transformFileSync(filename, extend({
result = babel.transformFileSync(filename, extend({
sourceMap: true,
ast: false
}, transformOpts));

View File

@@ -6,7 +6,7 @@ var util = require("./util");
var t = require("./types");
module.exports = function () {
var namespace = t.identifier("to5Runtime");
var namespace = t.identifier("babelHelpers");
var body = [];
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));

View File

@@ -82,7 +82,7 @@ Whitespace.prototype.getNewlinesAfter = function (node) {
}
}
if (endToken.type.type === "eof") {
if (endToken && endToken.type.type === "eof") {
return 1;
} else {
var lines = this.getNewlinesBetween(startToken, endToken);
@@ -96,6 +96,8 @@ Whitespace.prototype.getNewlinesAfter = function (node) {
};
Whitespace.prototype.getNewlinesBetween = function (startToken, endToken) {
if (!endToken || !endToken.loc) return 0;
var start = startToken ? startToken.loc.end.line : 1;
var end = endToken.loc.start.line;
var lines = 0;

View File

@@ -1,6 +1,5 @@
// syntax highlighting based on https://github.com/dominictarr/ansi-highlight by the fantastic Dominic Tarr
var supportsColor = require("supports-color");
var tokenize = require("js-tokenizer");
var chalk = require("chalk");
var util = require("../util");
@@ -43,7 +42,7 @@ var highlight = function (text) {
module.exports = function (lines, lineNumber, colNumber) {
colNumber = Math.max(colNumber, 0);
if (supportsColor) {
if (chalk.supportsColor) {
lines = highlight(lines);
}

View File

@@ -1,7 +1,7 @@
var normalizeAst = require("./normalize-ast");
var estraverse = require("estraverse");
var codeFrame = require("./code-frame");
var acorn = require("acorn-6to5");
var acorn = require("acorn-babel");
module.exports = function (opts, code, callback) {
try {
@@ -30,8 +30,8 @@ module.exports = function (opts, code, callback) {
return ast;
}
} catch (err) {
if (!err._6to5) {
err._6to5 = true;
if (!err._babel) {
err._babel = true;
var message = opts.filename + ": " + err.message;
var loc = err.loc;

View File

@@ -9,13 +9,14 @@ exports.messages = {
scopeDuplicateDeclaration: "Duplicate declaration $1",
undeclaredVariable: "Reference to undeclared variable $1",
undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
settersInvalidParamLength: "Setters must have only one parameter",
settersInvalidParamLength: "Setters must have exactly one parameter",
noAssignmentsInForHead: "No assignments allowed in for-in/of head",
expectedMemberExpressionOrIdentifier: "Expected type MemeberExpression or Identifier",
invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
readOnly: "$1 is read-only",
modulesIllegalExportName: "Illegal export $1",
unknownForHead: "Unknown node type $1 in ForStatement"
unknownForHead: "Unknown node type $1 in ForStatement",
didYouMean: "Did you mean $1?"
};
exports.get = function (key) {

View File

@@ -8,7 +8,7 @@ var t = require("./types");
var estraverse = require("estraverse");
extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
// regenerator-6to5/ast-types
// regenerator-babel/ast-types
var types = require("ast-types");
var def = types.Type.def;

9
lib/babel/polyfill.js Normal file
View File

@@ -0,0 +1,9 @@
"use strict";
if (global._babelPolyfill) {
throw new Error("only one instance of babel/polyfill is allowed");
}
global._babelPolyfill = true;
require("core-js/shim");
require("regenerator-babel/runtime");

View File

@@ -4,18 +4,19 @@ module.exports = File;
var 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 parse = require("../helpers/parse");
var Scope = require("../traversal/scope");
var util = require("../util");
var path = require("path");
var each = require("lodash/collection/each");
var t = require("../types");
var sourceMapToComment = require("source-map-to-comment");
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 parse = require("../helpers/parse");
var Scope = require("../traversal/scope");
var util = require("../util");
var path = require("path");
var each = require("lodash/collection/each");
var t = require("../types");
function File(opts) {
this.dynamicImportedNoDefault = [];
@@ -85,7 +86,8 @@ File.validOptions = [
"playground",
"experimental",
"resolveModuleSource",
"runtime",
"externalHelpers",
"auxilaryComment",
// these are used by plugins
"ignore",
@@ -106,6 +108,8 @@ File.prototype.normalizeOptions = function (opts) {
defaults(opts, {
keepModuleIdExtensions: false,
resolveModuleSource: null,
externalHelpers: false,
auxilaryComment: "",
experimental: false,
reactCompat: false,
playground: false,
@@ -118,7 +122,6 @@ File.prototype.normalizeOptions = function (opts) {
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
loose: [],
code: true,
ast: true
@@ -162,8 +165,8 @@ File.prototype.normalizeOptions = function (opts) {
opts.experimental = true;
}
if (opts.runtime) {
this.set("runtimeIdentifier", t.identifier("to5Runtime"));
if (opts.externalHelpers) {
this.set("runtimeIdentifier", t.identifier("babelHelpers"));
}
opts.blacklist = transform._ensureTransformerNames("blacklist", opts.blacklist);
@@ -298,6 +301,18 @@ File.prototype.isConsequenceExpressionStatement = function (node) {
return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0;
};
File.prototype.attachAuxilaryComment = function (node) {
var comment = this.opts.auxilaryComment;
if (comment) {
node.leadingComments = node.leadingComments || [];
node.leadingComments.push({
type: "Line",
value: " " + comment
});
}
return node;
};
File.prototype.addHelper = function (name) {
if (!includes(File.helpers, name)) {
throw new ReferenceError("Unknown helper " + name);
@@ -440,7 +455,7 @@ File.prototype.generate = function () {
}
if (opts.sourceMap === "inline") {
result.code += "\n" + util.sourceMapToComment(result.map);
result.code += "\n" + sourceMapToComment(result.map);
result.map = null;
}

View File

@@ -31,10 +31,7 @@ transform._ensureTransformerNames = function (type, rawKeys) {
var deprecatedKey = transform.deprecatedTransformerMap[key];
if (deprecatedKey) {
// deprecated key, remap it to the new one
console.error(
"The transformer " + key + " has been renamed to " + deprecatedKey +
" in v3.0.0 - backwards compatibilty will be removed 4.0.0"
);
console.error("The transformer " + key + " has been renamed to " + deprecatedKey);
rawKeys.push(deprecatedKey);
} else if (transform.transformers[key]) {
// valid key
@@ -48,7 +45,7 @@ transform._ensureTransformerNames = function (type, rawKeys) {
"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/6to5/6to5/blob/master/CHANGELOG.md#300"
"https://github.com/babel/babel/blob/master/CHANGELOG.md#300"
);
}
}

Some files were not shown because too many files have changed in this diff Show More