Compare commits

...

95 Commits

Author SHA1 Message Date
Sebastian McKenzie
bb19649af8 v4.3.0 2015-02-18 13:15:45 +11:00
Sebastian McKenzie
692262df1b fix linting errors 2015-02-18 13:14:06 +11:00
Sebastian McKenzie
067047da34 update commonStandard tests to commonStrict 2015-02-18 13:10:25 +11:00
Sebastian McKenzie
1c5d169b1e 4.2.1 2015-02-18 13:08:36 +11:00
Sebastian McKenzie
3f82b4ec72 remove commonStandard module formatter and make it the default behaviour of all the strict module formatters 2015-02-18 13:08:25 +11:00
Sebastian McKenzie
9c6e632021 Merge pull request #785 from babel/fn-name
Set Function.name for funcs in variables and properties as per spec.
2015-02-18 11:49:52 +11:00
Sebastian McKenzie
45553f1fb7 v4.2.1 2015-02-18 11:37:47 +11:00
Sebastian McKenzie
f228edbb84 add auxiliary comment to let scoping closure flow control - fixes #819 2015-02-18 11:35:57 +11:00
Sebastian McKenzie
64e657e53d 4.2.0 2015-02-18 11:33:58 +11:00
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
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
Ingvar Stepanyan
17e65cc772 Set Function.name for funcs in variables and properties as per spec.
Implements correct Function.name for cases like following:
 * `var x = function () { ... }`
 * `var obj = {prop: function () { ... }}`
2015-02-15 23:43:17 +02: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
355 changed files with 1698 additions and 1526 deletions

View File

4
.gitignore vendored
View File

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

2
.gitmodules vendored
View File

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

View File

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

View File

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

View File

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

View File

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

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 Contributions are always welcome, no matter how large or small. Before
contributing, please read the 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 **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 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 #### Workflow
* Fork the repository * 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`) * Install the project dependencies (`make bootstrap`)
* Link your forked clone (`npm link`) * Link your forked clone (`npm link`)
* Develop your changes ensuring you're fetching updates from upstream often * 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 MIT License

View File

@@ -5,31 +5,31 @@ UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs
JSHINT_CMD = node_modules/jshint/bin/jshint JSHINT_CMD = node_modules/jshint/bin/jshint
MOCHA_CMD = node_modules/mocha/bin/_mocha MOCHA_CMD = node_modules/mocha/bin/_mocha
JSCS_CMD = node_modules/jscs/bin/jscs 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 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 .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: build-core:
#node $(6TO5_CMD) src --out-dir lib #node $(BABEL_CMD) src --out-dir lib
watch-core: watch-core:
#node $(6TO5_CMD) src --out-dir lib --watch #node $(BABEL_CMD) src --out-dir lib --watch
build: build:
mkdir -p dist mkdir -p dist
node tools/cache-templates 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 $(UGLIFY_CMD) dist/polyfill.js >dist/polyfill.min.js
node $(BROWSERIFY_CMD) lib/6to5/api/browser.js -s to5 >dist/6to5.js node $(BROWSERIFY_CMD) lib/babel/api/browser.js -s babel >dist/babel.js
node $(UGLIFY_CMD) dist/6to5.js >dist/6to5.min.js node $(UGLIFY_CMD) dist/babel.js >dist/babel.min.js
node bin/6to5-runtime >dist/runtime.js node bin/babel-external-helpers >dist/external-helpers.js
node $(UGLIFY_CMD) dist/runtime.js >dist/runtime.min.js node $(UGLIFY_CMD) dist/external-helpers.js >dist/external-helpers.min.js
rm -rf templates.json rm -rf templates.json
@@ -49,17 +49,16 @@ test: lint
test-simple: test-simple:
# excludes test262 # excludes test262
export SIMPLE_6TO5_TESTS=1; \ export SIMPLE_BABEL_TESTS=1; \
make test make test
test-all: test-all:
# includes traceur, esnext, regenerator export ALL_BABEL_TESTS=1; \
export ALL_6TO5_TESTS=1; \
make test make test
test-cov: test-cov:
rm -rf coverage rm -rf coverage
export SIMPLE_6TO5_TESTS=1; \ export SIMPLE_BABEL_TESTS=1; \
node $(ISTANBUL_CMD) $(MOCHA_CMD) -- node $(ISTANBUL_CMD) $(MOCHA_CMD) --
test-travis: build-core bootstrap test-travis: build-core bootstrap
@@ -71,7 +70,7 @@ test-browser:
node tools/cache-templates node tools/cache-templates
node tools/cache-tests 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 rm -rf templates.json tests.json
test -n "`which open`" && open test/browser.html test -n "`which open`" && open test/browser.html
@@ -85,9 +84,9 @@ publish:
npm version $$version --message "v%s" npm version $$version --message "v%s"
make build 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/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 node tools/cache-templates
test -f templates.json test -f templates.json
@@ -99,12 +98,12 @@ publish:
make publish-core make publish-core
make publish-runtime 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: publish-runtime:
cd packages; \ cd packages; \
node build-runtime.js; \ node build-runtime.js; \
cd 6to5-runtime; \ cd babel-runtime; \
npm publish npm publish
publish-core: 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"> <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>
<p align="center"> <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>
<p align="center"> <p align="center">
For more information view the <a href="https://6to5.github.io">documentation</a>. For For more information view the <a href="https://babeljs.io/">documentation</a>. For
support visit the <a href="https://gitter.im/6to5/6to5">gitter room</a>. support visit the <a href="https://gitter.im/babel/babel">gitter room</a>.
</p> </p>

View File

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

View File

@@ -1,15 +1,16 @@
#!/usr/bin/env node #!/usr/bin/env node
var commander = require("commander"); var pathIsAbsolute = require("path-is-absolute");
var Module = require("module"); var commander = require("commander");
var path = require("path"); var Module = require("module");
var repl = require("repl"); var babel = require("../lib/babel/api/node");
var to5 = require("../lib/6to5/api/node"); var path = require("path");
var util = require("../lib/6to5/util"); var repl = require("repl");
var vm = require("vm"); var util = require("../lib/babel/util");
var _ = require("lodash"); 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("-e, --eval [script]", "Evaluate script");
program.option("-p, --print [code]", "Evaluate script and print result"); program.option("-p, --print [code]", "Evaluate script and print result");
@@ -28,7 +29,7 @@ program.parse(process.argv);
// //
to5.register({ babel.register({
experimental: program.experimental, experimental: program.experimental,
extensions: program.extensions, extensions: program.extensions,
playground: program.playground, playground: program.playground,
@@ -41,7 +42,7 @@ to5.register({
// //
var _eval = function (code, filename) { var _eval = function (code, filename) {
code = to5.transform(code, { code = babel.transform(code, {
filename: filename, filename: filename,
blacklist: ["useStrict"].concat(program.blacklist || []), blacklist: ["useStrict"].concat(program.blacklist || []),
whitelist: program.whitelist, whitelist: program.whitelist,
@@ -60,7 +61,7 @@ if (program.eval || program.print) {
if (program.print) console.log(result); if (program.print) console.log(result);
} else { } else {
if (program.args.length) { 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 args = process.argv.slice(2);
var i = 0; var i = 0;
@@ -85,7 +86,7 @@ if (program.eval || program.print) {
// make the filename absolute // make the filename absolute
var filename = args[0] 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 // add back on node and concat the sliced args
process.argv = ["node"].concat(args); process.argv = ["node"].concat(args);

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 #!/usr/bin/env node
var opts = require("./6to5").opts; var opts = require("./babel").opts;
opts.optional = (opts.optional || []).concat("minification"); opts.optional = (opts.optional || []).concat("minification");
opts.format = { opts.format = {
compact: true compact: true

View File

@@ -2,10 +2,10 @@
/** /**
* This tiny wrapper file checks for known node flags and appends them * 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){ process.argv.slice(2).forEach(function(arg){
var flag = arg.split("=")[0]; var flag = arg.split("=")[0];

View File

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

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env node #!/usr/bin/env node
var commander = require("commander"); var commander = require("commander");
var transform = require("../../lib/6to5/transformation"); var transform = require("../../lib/babel/transformation");
var util = require("../../lib/6to5/util"); var util = require("../../lib/babel/util");
var fs = require("fs"); var fs = require("fs");
var each = require("lodash/collection/each"); var each = require("lodash/collection/each");
var keys = require("lodash/object/keys"); 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("-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("-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("-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("-e, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-p, --playground", "Enable playground support"); 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("-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("-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("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.option("-a, --auxiliary-comment [comment]", "Comment text to prepend to all auxiliary code");
commander.on("--help", function () { commander.on("--help", function () {
var outKeys = function (title, obj) { var outKeys = function (title, obj) {
@@ -99,6 +100,8 @@ if (errors.length) {
exports.opts = { exports.opts = {
keepModuleIdExtensions: commander.keepModuleIdExtensions, keepModuleIdExtensions: commander.keepModuleIdExtensions,
auxiliaryComment: commander.auxiliaryComment,
externalHelpers: commander.externalHelpers,
sourceMapName: commander.outFile, sourceMapName: commander.outFile,
experimental: commander.experimental, experimental: commander.experimental,
reactCompat: commander.reactCompat, reactCompat: commander.reactCompat,
@@ -109,13 +112,12 @@ exports.opts = {
sourceMap: commander.sourceMaps || commander.sourceMapsInline, sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional, optional: commander.optional,
comments: !commander.removeComments, comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules, modules: commander.modules,
loose: commander.loose loose: commander.loose
}; };
setTimeout(function () { 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` // time to modify `exports.opts`
var fn; var fn;

View File

@@ -1,8 +1,8 @@
var readdir = require("fs-readdir-recursive"); var readdir = require("fs-readdir-recursive");
var index = require("./index"); 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 path = require("path");
var to5 = require("../../lib/6to5/api/node");
var fs = require("fs"); var fs = require("fs");
var _ = require("lodash"); var _ = require("lodash");
@@ -26,7 +26,7 @@ exports.transform = function (filename, code, opts) {
var result; var result;
try { try {
result = to5.transform(code, opts); result = babel.transform(code, opts);
} catch (e) { } catch (e) {
if (e instanceof SyntaxError) { if (e instanceof SyntaxError) {
console.error("SyntaxError:", e.message); 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,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,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,13 +0,0 @@
"use strict";
module.exports = CommonStandardFormatter;
var CommonStrictFormatter = require("./common-strict");
var util = require("../../util");
function CommonStandardFormatter() {
this.noInteropRequireImport = true;
CommonStrictFormatter.apply(this, arguments);
}
util.inherits(CommonStandardFormatter, CommonStrictFormatter);

View File

@@ -1,11 +0,0 @@
module.exports = {
commonStandard: require("./common-standard"),
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
};

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 runScripts = function () {
var scripts = []; var scripts = [];
var types = ["text/ecmascript-6", "text/6to5", "module"]; var types = ["text/ecmascript-6", "text/6to5", "text/babel", "module"];
var index = 0; var index = 0;
var exec = function () { var exec = function () {

View File

@@ -7,7 +7,7 @@ var fs = require("fs");
exports.version = require("../../../package").version; exports.version = require("../../../package").version;
exports.runtime = require("../build-runtime"); exports.buildExternalHelpers = require("../build-external-helpers");
exports.types = require("../types"); exports.types = require("../types");
@@ -23,7 +23,7 @@ exports.polyfill = function () {
exports.canCompile = util.canCompile; 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._util = util;
exports.transform = transform; exports.transform = transform;

View File

@@ -1,6 +1,6 @@
"use strict"; "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 () {}; module.exports = function () {};

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,8 @@
"use strict"; "use strict";
var util = require("../../util"); var isInteger = require("is-integer");
var t = require("../../types"); var isNumber = require("lodash/lang/isNumber");
var isNumber = require("lodash/lang/isNumber"); var t = require("../../types");
exports.UnaryExpression = function (node, print) { exports.UnaryExpression = function (node, print) {
var hasSpace = /[a-z]$/.test(node.operator); var hasSpace = /[a-z]$/.test(node.operator);
@@ -146,7 +146,7 @@ exports.MemberExpression = function (node, print) {
this.push("]"); this.push("]");
} else { } else {
// 5..toFixed(2); // 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("."); this.push(".");
} }

View File

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

View File

@@ -9,13 +9,13 @@ module.exports.CodeGenerator = CodeGenerator;
var detectIndent = require("detect-indent"); var detectIndent = require("detect-indent");
var Whitespace = require("./whitespace"); var Whitespace = require("./whitespace");
var repeating = require("repeating");
var SourceMap = require("./source-map"); var SourceMap = require("./source-map");
var Position = require("./position"); var Position = require("./position");
var Buffer = require("./buffer"); var Buffer = require("./buffer");
var extend = require("lodash/object/extend"); var extend = require("lodash/object/extend");
var merge = require("lodash/object/merge"); var merge = require("lodash/object/merge");
var each = require("lodash/collection/each"); var each = require("lodash/collection/each");
var util = require("../util");
var n = require("./node"); var n = require("./node");
var t = require("../types"); var t = require("../types");
@@ -344,7 +344,7 @@ CodeGenerator.prototype._printComments = function (comments) {
} }
var indent = Math.max(self.indentSize(), column); 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) { if (column === 0) {

View File

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

View File

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

View File

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

View File

@@ -9,13 +9,15 @@ exports.messages = {
scopeDuplicateDeclaration: "Duplicate declaration $1", scopeDuplicateDeclaration: "Duplicate declaration $1",
undeclaredVariable: "Reference to undeclared variable $1", undeclaredVariable: "Reference to undeclared variable $1",
undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?", 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", noAssignmentsInForHead: "No assignments allowed in for-in/of head",
expectedMemberExpressionOrIdentifier: "Expected type MemeberExpression or Identifier", expectedMemberExpressionOrIdentifier: "Expected type MemeberExpression or Identifier",
invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue", invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
readOnly: "$1 is read-only", readOnly: "$1 is read-only",
modulesIllegalExportName: "Illegal export $1", modulesIllegalExportName: "Illegal export $1",
unknownForHead: "Unknown node type $1 in ForStatement" unknownForHead: "Unknown node type $1 in ForStatement",
didYouMean: "Did you mean $1?",
evalInStrictMode: "eval is not allowed in strict mode"
}; };
exports.get = function (key) { exports.get = function (key) {

View File

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

@@ -2,20 +2,21 @@
module.exports = File; 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 isFunction = require("lodash/lang/isFunction");
var transform = require("./index"); var transform = require("./index");
var generate = require("../generation"); var generate = require("../generation");
var defaults = require("lodash/object/defaults"); var defaults = require("lodash/object/defaults");
var includes = require("lodash/collection/includes"); var includes = require("lodash/collection/includes");
var clone = require("../helpers/clone"); var assign = require("lodash/object/assign");
var parse = require("../helpers/parse"); var parse = require("../helpers/parse");
var Scope = require("../traversal/scope"); var Scope = require("../traversal/scope");
var util = require("../util"); var slash = require("slash");
var path = require("path"); var util = require("../util");
var each = require("lodash/collection/each"); var path = require("path");
var t = require("../types"); var each = require("lodash/collection/each");
var t = require("../types");
function File(opts) { function File(opts) {
this.dynamicImportedNoDefault = []; this.dynamicImportedNoDefault = [];
@@ -59,7 +60,8 @@ File.helpers = [
"object-destructuring-empty", "object-destructuring-empty",
"temporal-undefined", "temporal-undefined",
"temporal-assert-defined", "temporal-assert-defined",
"tail-call" "tail-call",
"self-global"
]; ];
File.validOptions = [ File.validOptions = [
@@ -85,7 +87,8 @@ File.validOptions = [
"playground", "playground",
"experimental", "experimental",
"resolveModuleSource", "resolveModuleSource",
"runtime", "externalHelpers",
"auxiliaryComment",
// these are used by plugins // these are used by plugins
"ignore", "ignore",
@@ -95,7 +98,7 @@ File.validOptions = [
]; ];
File.prototype.normalizeOptions = function (opts) { File.prototype.normalizeOptions = function (opts) {
opts = clone(opts); opts = assign({}, opts);
for (var key in opts) { for (var key in opts) {
if (key[0] !== "_" && File.validOptions.indexOf(key) < 0) { if (key[0] !== "_" && File.validOptions.indexOf(key) < 0) {
@@ -106,6 +109,8 @@ File.prototype.normalizeOptions = function (opts) {
defaults(opts, { defaults(opts, {
keepModuleIdExtensions: false, keepModuleIdExtensions: false,
resolveModuleSource: null, resolveModuleSource: null,
externalHelpers: false,
auxilaryComment: "",
experimental: false, experimental: false,
reactCompat: false, reactCompat: false,
playground: false, playground: false,
@@ -118,16 +123,15 @@ File.prototype.normalizeOptions = function (opts) {
comments: true, comments: true,
filename: "unknown", filename: "unknown",
modules: "common", modules: "common",
runtime: false,
loose: [], loose: [],
code: true, code: true,
ast: true ast: true
}); });
// normalize windows path separators to unix // normalize windows path separators to unix
opts.filename = util.normalisePathSeparator(opts.filename); opts.filename = slash(opts.filename);
if (opts.sourceRoot) { if (opts.sourceRoot) {
opts.sourceRoot = util.normalisePathSeparator(opts.sourceRoot); opts.sourceRoot = slash(opts.sourceRoot);
} }
opts.basename = path.basename(opts.filename, path.extname(opts.filename)); opts.basename = path.basename(opts.filename, path.extname(opts.filename));
@@ -162,8 +166,8 @@ File.prototype.normalizeOptions = function (opts) {
opts.experimental = true; opts.experimental = true;
} }
if (opts.runtime) { if (opts.externalHelpers) {
this.set("runtimeIdentifier", t.identifier("to5Runtime")); this.set("runtimeIdentifier", t.identifier("babelHelpers"));
} }
opts.blacklist = transform._ensureTransformerNames("blacklist", opts.blacklist); opts.blacklist = transform._ensureTransformerNames("blacklist", opts.blacklist);
@@ -243,12 +247,13 @@ File.prototype.getModuleFormatter = function (type) {
}; };
File.prototype.parseShebang = function (code) { File.prototype.parseShebang = function (code) {
var shebangMatch = code.match(SHEBANG_REGEX); var shebangMatch = shebangRegex.exec(code);
if (shebangMatch) { if (shebangMatch) {
this.shebang = shebangMatch[0]; this.shebang = shebangMatch[0];
// remove shebang // remove shebang
code = code.replace(SHEBANG_REGEX, ""); code = code.replace(shebangRegex, "");
} }
return code; return code;
@@ -298,6 +303,18 @@ File.prototype.isConsequenceExpressionStatement = function (node) {
return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0; return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0;
}; };
File.prototype.attachAuxiliaryComment = function (node) {
var comment = this.opts.auxiliaryComment;
if (comment) {
node.leadingComments = node.leadingComments || [];
node.leadingComments.push({
type: "Line",
value: " " + comment
});
}
return node;
};
File.prototype.addHelper = function (name) { File.prototype.addHelper = function (name) {
if (!includes(File.helpers, name)) { if (!includes(File.helpers, name)) {
throw new ReferenceError("Unknown helper " + name); throw new ReferenceError("Unknown helper " + name);
@@ -352,7 +369,7 @@ File.prototype.parse = function (code) {
var opts = this.opts; var opts = this.opts;
opts.allowImportExportEverywhere = this.isLoose("es6.modules"); opts.allowImportExportEverywhere = this.isLoose("es6.modules");
//opts.strictMode = this.transformers.useStrict.canRun(); opts.strictMode = this.transformers.useStrict.canRun();
return parse(opts, code, function (tree) { return parse(opts, code, function (tree) {
self.transform(tree); self.transform(tree);
@@ -440,7 +457,7 @@ File.prototype.generate = function () {
} }
if (opts.sourceMap === "inline") { if (opts.sourceMap === "inline") {
result.code += "\n" + util.sourceMapToComment(result.map); result.code += "\n" + sourceMapToComment(result.map);
result.map = null; result.map = null;
} }

View File

@@ -31,10 +31,7 @@ transform._ensureTransformerNames = function (type, rawKeys) {
var deprecatedKey = transform.deprecatedTransformerMap[key]; var deprecatedKey = transform.deprecatedTransformerMap[key];
if (deprecatedKey) { if (deprecatedKey) {
// deprecated key, remap it to the new one // deprecated key, remap it to the new one
console.error( console.error("The transformer " + key + " has been renamed to " + deprecatedKey);
"The transformer " + key + " has been renamed to " + deprecatedKey +
" in v3.0.0 - backwards compatibilty will be removed 4.0.0"
);
rawKeys.push(deprecatedKey); rawKeys.push(deprecatedKey);
} else if (transform.transformers[key]) { } else if (transform.transformers[key]) {
// valid key // valid key
@@ -44,12 +41,7 @@ transform._ensureTransformerNames = function (type, rawKeys) {
keys = keys.concat(transform.namespaces[key]); keys = keys.concat(transform.namespaces[key]);
} else { } else {
// invalid key // invalid key
throw new ReferenceError( throw new ReferenceError("Unknown transformer " + key + " specified in " + type);
"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"
);
} }
} }

View File

@@ -4,6 +4,7 @@ var util = require("../../util");
module.exports = function (Parent) { module.exports = function (Parent) {
var Constructor = function () { var Constructor = function () {
this.noInteropRequireImport = true;
this.noInteropRequireExport = true; this.noInteropRequireExport = true;
Parent.apply(this, arguments); Parent.apply(this, arguments);
}; };

View File

@@ -20,7 +20,9 @@ CommonJSFormatter.prototype.init = function () {
scope.rename("module"); scope.rename("module");
if (!this.noInteropRequireImport && this.hasNonDefaultExports) { 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,10 @@
module.exports = {
commonStrict: require("./common-strict"),
amdStrict: require("./amd-strict"),
umdStrict: require("./umd-strict"),
common: require("./common"),
system: require("./system"),
ignore: require("./ignore"),
amd: require("./amd"),
umd: require("./umd")
};

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