Compare commits

...

1772 Commits

Author SHA1 Message Date
Sebastian McKenzie
2053610429 v5.5.3 2015-06-05 12:20:22 +01:00
Sebastian McKenzie
cd4f83b299 fix linting errors 2015-06-05 12:19:32 +01:00
Sebastian McKenzie
ec29ba19a9 add 5.5.3 changelog 2015-06-05 12:18:43 +01:00
Sebastian McKenzie
9dc03e0978 traverse over ClassProperty path rather than node 2015-06-05 12:17:55 +01:00
Sebastian McKenzie
bc4258eca9 add type inferrence for template literals 2015-06-05 12:17:45 +01:00
Sebastian McKenzie
b0e58f9770 add completion statement test and enable experimental option on deadCodeElimination tests 2015-06-05 12:17:36 +01:00
Sebastian McKenzie
a1e2641c91 5.5.2 2015-06-05 12:17:18 +01:00
Sebastian McKenzie
9108422f99 v5.5.2 2015-06-05 12:03:38 +01:00
Sebastian McKenzie
9e8f4b25ca add missing semicolon 2015-06-05 12:02:30 +01:00
Sebastian McKenzie
1cecd24823 make experimental warning more scary 2015-06-05 12:01:52 +01:00
Sebastian McKenzie
97f6e1469b add 5.5.2 changelog 2015-06-05 12:01:44 +01:00
Sebastian McKenzie
ec46eaf224 add scary experimental warning for people who use obscure transformers that are still WIP 2015-06-05 11:55:09 +01:00
Sebastian McKenzie
a102692103 when using babel/register always use the cwd - fixes #1689 2015-06-05 11:54:52 +01:00
Sebastian McKenzie
0376ec8ff0 t.isPure -> this.isPure - fixes #1688 2015-06-05 11:33:25 +01:00
Sebastian McKenzie
5932a07610 5.5.1 2015-06-05 09:57:21 +01:00
Sebastian McKenzie
6110b0c0b3 v5.5.1 2015-06-05 09:56:27 +01:00
Sebastian McKenzie
365e221d95 fix deoptValue binding boolean - fixes #1687 2015-06-05 09:55:47 +01:00
Sebastian McKenzie
acbc4859c0 only remove ClassProperty in flow transformer when it has no value 2015-06-05 09:53:59 +01:00
Sebastian McKenzie
55750e05e7 Revert "enable es6.spec.symbols by default"
This reverts commit f3acedbf08.
2015-06-05 09:44:22 +01:00
Sebastian McKenzie
ba9c4db673 finish 5.5.1 changelog - ref #1686 2015-06-05 09:43:34 +01:00
Sebastian McKenzie
ba8a63a69e remove trailing json comma 2015-06-05 09:42:53 +01:00
Sebastian McKenzie
25581981b5 always remove ClassProperty nodes in flow transformer - fixes #1686 2015-06-05 09:42:46 +01:00
Sebastian McKenzie
02a6feed73 update template literal parsing to properly handle newlines 2015-06-05 09:36:37 +01:00
Sebastian McKenzie
f3acedbf08 enable es6.spec.symbols by default 2015-06-05 08:43:41 +01:00
Sebastian McKenzie
35ab4ffaab 5.5.0 2015-06-05 08:12:17 +01:00
Sebastian McKenzie
ddfb7f2c11 v5.5.0 2015-06-05 08:11:10 +01:00
Sebastian McKenzie
e2ca03f92d fix linting errors 2015-06-05 08:10:22 +01:00
Sebastian McKenzie
c75a3c68e5 add 5.5.0 changelog 2015-06-05 08:08:20 +01:00
Sebastian McKenzie
5d617ea99b upgrade regenerator - fixes #1685 2015-06-05 07:56:33 +01:00
Sebastian McKenzie
58059a2c48 add deoptValue method to Binding that ignores all subsequent setValue calls 2015-06-05 07:52:57 +01:00
Sebastian McKenzie
4c2936773a update type inferrence to support unary operators 2015-06-05 07:47:22 +01:00
Sebastian McKenzie
c7c16ad9c1 add control flow support and deopt bindings on assignments that we can't understand 2015-06-05 07:46:32 +01:00
Sebastian McKenzie
7b676d608b allow NodePaths to be returned in node removal/replacement methods and coerce them to nodes 2015-06-05 07:46:10 +01:00
Sebastian McKenzie
48ecec1e2e move more transformers to builtin-pre group 2015-06-05 07:45:32 +01:00
Sebastian McKenzie
9dc72e71d4 add skipKey method to skip traversal of subsequent keys 2015-06-05 07:45:19 +01:00
Sebastian McKenzie
4a7a02b9af rename builtin-setup transformer group to builtin-pre 2015-06-05 07:44:45 +01:00
Sebastian McKenzie
7cb460d2f3 add eval optional transformer 2015-06-05 07:44:29 +01:00
Sebastian McKenzie
0a7dac8744 move flow to builtin-trailing group 2015-06-05 07:44:15 +01:00
Sebastian McKenzie
667d595a73 use type inferrence to work out whether to wrap template literals with the String constructor 2015-06-05 07:43:58 +01:00
Sebastian McKenzie
2d2d957be5 add back ComprehensionBlock binding identifier keys and remove body form ComprehensionBlock visitor keys 2015-06-04 22:50:17 +01:00
Sebastian McKenzie
5aef7afade fix remaining AssignmentExpression LHS ReferencedIdentifier bugs 2015-06-04 22:43:50 +01:00
Sebastian McKenzie
d5e7b5616c Merge branch 'master' of github.com:babel/babel 2015-06-04 22:23:42 +01:00
Sebastian McKenzie
9aa17a6cc2 don't consider JSXIdentifier HTML tags to be references - fixes #1683 2015-06-04 22:23:24 +01:00
Sebastian McKenzie
0f13097f59 add basic naive constant folding of assignment expressions 2015-06-04 22:08:38 +01:00
Sebastian McKenzie
355ffbdaf8 don't consider the LHS of an AssignmentExpression to be a reference 2015-06-04 22:07:44 +01:00
Sebastian McKenzie
45b0d63d72 copy parent class binding to class in the collection visitor 2015-06-04 22:07:19 +01:00
Sebastian McKenzie
c515271fbd Merge pull request #1677 from jmm/node_modules-robust3
Complete "Fix flawed require hook node_modules check" properly
2015-06-03 19:23:41 +01:00
Jesse McCarthy
6f3501876a Add test for require-hook node_modules check. 2015-06-03 09:04:59 -04:00
Jesse McCarthy
f8afc5fa17 Revert "Add test for require-hook node_modules check."
This reverts commit 1488d88c81.

Wrong branch was accidentally merged. There is a better test.
2015-06-03 09:04:59 -04:00
Sebastian McKenzie
4ecda93147 move deprecated minification.inlineExpressions to aliases 2015-06-03 10:05:56 +01:00
Sebastian McKenzie
41847162b1 check if es7.exportExtensions ie enabled in parser 2015-06-03 10:05:39 +01:00
Sebastian McKenzie
0f7e010e3e remove isSpecifierDefault check for ExportDefaultSpecifier - fixes #1673 2015-06-03 10:05:19 +01:00
Sebastian McKenzie
8201ea0aa2 Merge branch 'master' of github.com:babel/babel
# Conflicts:
#	src/babel/api/register/node.js
2015-06-03 07:26:46 +01:00
Sebastian McKenzie
a7848c1822 Merge branch 'jmm-node_modules-robust' 2015-06-03 07:26:19 +01:00
Sebastian McKenzie
d4abaeeecf Merge branch 'node_modules-robust' of https://github.com/jmm/babel into jmm-node_modules-robust 2015-06-03 07:26:12 +01:00
Sebastian McKenzie
871a82df0a Merge pull request #1665 from Jabher/master
Making babel able to run in node_modules directory
2015-06-03 07:25:22 +01:00
Sebastian McKenzie
ffbf5b0b47 convert property key to computed before checking if it's a displayName property in the react transformer builder - closes #1671 2015-06-02 23:08:46 +01:00
Sebastian McKenzie
9dcceaeb40 move minification.deadCodeElimination back to the builtin-setup transformer group 2015-06-02 17:08:49 +01:00
Sebastian McKenzie
556e58a4ab register function declarations anyway as we may not have hit them 2015-06-02 17:08:31 +01:00
Sebastian McKenzie
b6c35743e6 add import types 2015-06-02 16:24:32 +01:00
Sebastian McKenzie
0abd34f7e6 Merge branch 'master' of github.com:babel/babel 2015-06-02 16:18:13 +01:00
Sebastian McKenzie
cafd7f8e39 add Infinity/NaN, string/number member expressions/calls and Math calls static evaluation 2015-06-02 16:18:08 +01:00
Sebastian McKenzie
43c0a0e65f remove all non-function statements after completion statements in blocks 2015-06-02 16:16:36 +01:00
Sebastian McKenzie
7b359f46fd rename minification.inlineExpressions to minification.constantFolding 2015-06-02 16:16:10 +01:00
Sebastian McKenzie
880827f6ce Merge pull request #1669 from wincent/mixed-type
Add "mixed" Flow type
2015-06-02 16:15:23 +01:00
Greg Hurrell
0c300058a3 Add "mixed" Flow type
"mixed" is one of the base types listed here:

http://flowtype.org/docs/base-types.html

So this commit adds support for it.
2015-06-02 07:15:06 -07:00
Sebastian McKenzie
d35be22f7d add support for resolving array expression elements 2015-06-02 00:32:18 +01:00
Sebastian McKenzie
ff8d90061f add "istanbul ignore next" auxiliary comment when using istanbul compat mode for babel/register 2015-06-02 00:32:07 +01:00
Vsevolod Rodionov
e66109f9d0 Making babel able to run in node_modules directory (while still ignoring node_modules packages)
In case if app is installed by npm install <git tarball url> which is very comfortable thing (postinstall hooks, automatic package installation and so on) babel is unable to run over packages, e.g.
```
 ~/node_modules/some_app$ node-babel app.js
  ```
 is crashing as babel do not want in node_modules directory.

 relative path gives ability to check whether lib is in node_modules _relative_ to current app, so that if app is ran in node_modules by itself it will not be captured.
2015-06-01 14:55:51 -07:00
Sebastian McKenzie
1934c16f0f don't use initializer property for decorators on concise methods in object literals 2015-06-01 22:32:04 +01:00
Sebastian McKenzie
012ac7d9ec remove accidental console.log introduced in 80a7f13460 2015-06-01 22:01:27 +01:00
Jesse McCarthy
efb3b04225 Make node_modules path check robust. 2015-06-01 16:54:56 -04:00
Jesse McCarthy
1488d88c81 Add test for require-hook node_modules check.
(Failing.)
2015-06-01 16:54:52 -04:00
Sebastian McKenzie
80a7f13460 register named method id as a reference to avoid collisions - fixes #1664 2015-06-01 21:53:34 +01:00
Sebastian McKenzie
8919fc22b1 only infer single identifier new expression callees 2015-06-01 21:52:54 +01:00
Sebastian McKenzie
b1273cb774 Merge pull request #1663 from pangratz/fix_for_referencesImport
Minor fix for `referencesImport`
2015-06-01 18:13:49 +01:00
pangratz
0843b8355e Minor fix for referencesImport 2015-06-01 19:09:33 +02:00
Sebastian McKenzie
6457677fb4 add support for NewExpression and reference plain node 2015-06-01 17:29:02 +01:00
Sebastian McKenzie
f8a860bf21 remove unused import 2015-06-01 14:32:58 +01:00
Sebastian McKenzie
f2bed33db8 add type inference for ConditionalExpression, SequenceExpression, AssignmentExpression and add support for base type aliases in isTypeAnnotationGeneric method 2015-06-01 14:25:06 +01:00
Sebastian McKenzie
7d2c6525d8 flesh out type inferrence some more, rename some of the NodePath methods to be less ambiguous, remove dead Binding type methods 2015-06-01 14:01:14 +01:00
Sebastian McKenzie
de652dc747 change getBindingIdentifier keys to be just a string instead of an array 2015-06-01 12:06:36 +01:00
Sebastian McKenzie
9f1053212b add EmptyStatement to t.toSequenceExpression 2015-06-01 12:06:16 +01:00
Sebastian McKenzie
76690a3deb renamed Path#isPreviousType to isType 2015-06-01 12:05:42 +01:00
Sebastian McKenzie
50f2f2fc98 remove DoExpression statement parsing and clear labels and set inFunction to false when parsing DoExpression body - fixes #1658 2015-06-01 03:36:14 +01:00
Sebastian McKenzie
5c27234d19 change TCO BlockStatement visitor back to enter 2015-06-01 00:17:44 +01:00
Sebastian McKenzie
6f5d16f397 remove TCOable check 2015-06-01 00:14:12 +01:00
Sebastian McKenzie
e42a43e3d1 remove unnecessary strict helper 2015-05-31 23:40:59 +01:00
Sebastian McKenzie
bfd307cd57 move some visitors out of deoptimising enter method 2015-05-31 23:40:42 +01:00
Sebastian McKenzie
beb5ee1333 remove useless generator test helpers 2015-05-31 21:26:22 +01:00
Sebastian McKenzie
cde871555d don't pass comments in tokens to estraverse 2015-05-31 21:26:12 +01:00
Sebastian McKenzie
51b0ffa7bf prepend Comment to comment node types 2015-05-31 20:25:26 +01:00
Sebastian McKenzie
255c819727 optimise ES6 tail call transformer to only try TOC on functions that include a call to themselves 2015-05-31 15:40:41 +01:00
Sebastian McKenzie
152ccb2ce8 check if ObjectExpression has any gets/sets before filtering 2015-05-31 15:40:07 +01:00
Sebastian McKenzie
bdb3adfeea revert parts of 07a992e 2015-05-31 09:47:27 +01:00
Sebastian McKenzie
236086bee5 ignore trailing commas when inferring newlines - fixes #1304 2015-05-31 09:46:05 +01:00
Sebastian McKenzie
1436753e6d fix linting errors 2015-05-31 09:24:12 +01:00
Sebastian McKenzie
eadf8ef799 fix syntax error in helpers/parse 2015-05-31 09:20:16 +01:00
Sebastian McKenzie
f1e20cf6ff remove useless comment 2015-05-31 09:16:34 +01:00
Sebastian McKenzie
82a0851526 push comments to token stream to avoid having to re-sort - #1486 2015-05-31 09:16:27 +01:00
Sebastian McKenzie
07a992e6d3 add support for tail calls when in completion record position - fixes #1572 2015-05-31 09:07:44 +01:00
Sebastian McKenzie
f642c2baa8 relax key aliases for plain methods - fixes #1649 2015-05-30 23:53:39 -04:00
Sebastian McKenzie
2f7743cafb optimise module metadata retrieval - #1486 2015-05-30 23:42:24 -04:00
Sebastian McKenzie
44112f2d87 remove unused variable 2015-05-30 23:18:50 -04:00
Sebastian McKenzie
99c4810770 add regeneratot transform to builtin-advanced group 2015-05-30 23:18:45 -04:00
Sebastian McKenzie
9f2ac15695 move jscript transformer to the builtin-trailing group and perform transform on exit - closes #1652, fixes #1651 2015-05-30 23:09:25 -04:00
Sebastian McKenzie
19c1ee157f simplify scope parent alias keys 2015-05-30 23:08:42 -04:00
Sebastian McKenzie
973270772b use ForX alias instead of manually listing all types 2015-05-30 23:08:28 -04:00
Sebastian McKenzie
7334326042 remove extra semicolon 2015-05-30 22:37:18 -04:00
Sebastian McKenzie
4043e8e8b9 fix destructuring transformer AssignmentExpression to properly handle completion records 2015-05-30 22:33:09 -04:00
Sebastian McKenzie
7fd403998c remove dead code 2015-05-30 22:32:48 -04:00
Sebastian McKenzie
1f7fcc2985 Merge branch 'master' of github.com:babel/babel 2015-05-30 22:13:59 -04:00
Sebastian McKenzie
ba19bd36a4 optimise scope tracking into a single pass - #1486 2015-05-30 22:07:03 -04:00
Sebastian McKenzie
e119681b1f return paths accordingly in insertBefore and insertAfter methods 2015-05-30 22:03:25 -04:00
Sebastian McKenzie
fbe22e53a9 add check for dynamic node and output error message accordingly 2015-05-30 22:02:56 -04:00
Sebastian McKenzie
79e826fcc8 attempt to optimise node printing by shifting it into a class 2015-05-30 22:02:29 -04:00
Sebastian McKenzie
cf940268b9 add noScope to template visitor 2015-05-30 22:02:15 -04:00
Sebastian McKenzie
96bb572307 use flow type shorthand for eaching over specifiers 2015-05-30 19:09:23 -04:00
Sebastian McKenzie
5dafe0b66a collapse t.getBindingIdentifiers comment 2015-05-30 19:08:14 -04:00
Sebastian McKenzie
29e24a4cbe don't evaluate non-referenced identifiers 2015-05-30 19:07:58 -04:00
Sebastian McKenzie
f979d55b71 remove special ExpressionStatement handling in destructuring transformer 2015-05-30 19:07:31 -04:00
Sebastian McKenzie
164b2116a3 switch expontentation evaluation to just use the operator 2015-05-30 19:05:31 -04:00
Dan Abramov
55e623a099 Merge pull request #1650 from jmm/contrib-build-version
Make note about buildable versions more prominent.
2015-05-30 11:29:59 +03:00
Jesse McCarthy
a60b4b1302 Make note about buildable versions more prominent. 2015-05-29 14:14:15 -04:00
Dan Abramov
bf23e59bbf Add a note about building older versions. Fixes #1643 2015-05-29 16:50:34 +03:00
Sebastian McKenzie
eb4cee89c5 add referencesImport path method - fixes #1423 2015-05-28 11:39:51 -04:00
Sebastian McKenzie
fb94a87a4d add support for cluster forking - fixes #1611 2015-05-28 10:36:29 -04:00
Sebastian McKenzie
9613c7fdb6 fix linting error 2015-05-28 10:30:09 -04:00
Sebastian McKenzie
d8c97fba15 check plugin.default and then just plugin to support ES6 modules - closes #1627 2015-05-28 10:25:50 -04:00
Sebastian McKenzie
0f663560d4 add --nolazy to babel-node - fixes #1639 2015-05-28 10:24:31 -04:00
Sebastian McKenzie
4901075960 deopt rest parameter member expression optimisation on child arrow functions - fixes #1631 2015-05-28 10:22:12 -04:00
Sebastian McKenzie
4aec242979 add some comments to some path methods and remove some dead code 2015-05-28 10:04:46 -04:00
Sebastian McKenzie
d1d95e0e49 check LHS of ForIn/ForOfStatement for constants - closes #1630 2015-05-28 10:04:32 -04:00
Sebastian McKenzie
d3c643b004 clean up path resolution and add in path resolution recursion detection - cc @RReverser 2015-05-25 19:08:08 +01:00
Sebastian McKenzie
98eb30c482 rename Path#remove to Path#dangerouslyRemove 2015-05-25 16:17:28 +01:00
Sebastian McKenzie
2d43ffb5b4 remove removal scope hooks 2015-05-25 15:57:22 +01:00
Sebastian McKenzie
a195701de2 remove dead code 2015-05-25 15:28:23 +01:00
Sebastian McKenzie
f639f4bea7 upgrade babel-eslint 2015-05-25 15:28:16 +01:00
Sebastian McKenzie
334cbb06c6 flesh out removal hooks more 2015-05-25 15:28:11 +01:00
Sebastian McKenzie
f4a3b2f01a add link to readme in contributing guide so people can't whinge and note in the README that issues without reproducible examples will be closed 2015-05-25 14:55:37 +01:00
Sebastian McKenzie
dbe6f1b9a9 merge remove parent context checks 2015-05-25 04:30:17 +01:00
Sebastian McKenzie
73ada57a17 don't inline classes and functions when they're in different scopes in the utility.deadCodeElimination transformer 2015-05-25 03:33:12 +01:00
Sebastian McKenzie
8e2b743f7e add support for resyncing container on changes 2015-05-25 03:32:25 +01:00
Sebastian McKenzie
a533042503 fix bad .gitignore paths resulting in some tests and path/lib files not being included... 2015-05-25 01:42:54 +01:00
Sebastian McKenzie
49953e3464 enable no-unused-vars in eslint 2015-05-25 01:32:06 +01:00
Sebastian McKenzie
0bf95d6aea even more split up of path methods 2015-05-25 01:01:21 +01:00
Sebastian McKenzie
7d88a1ca0b rename TraversalPath to NodePath and further split up methods into separate files 2015-05-25 00:43:46 +01:00
Sebastian McKenzie
ec74eb41cf reneable eslint and fix assorted linting errors 2015-05-25 00:42:59 +01:00
Sebastian McKenzie
3139482358 clean and fix up visitor merging 2015-05-24 18:15:46 +01:00
Sebastian McKenzie
32f19aff99 clean up file processing API 2015-05-24 18:15:34 +01:00
Sebastian McKenzie
23bead9226 Merge branch 'master' of github.com:babel/babel 2015-05-24 01:45:00 +01:00
Sebastian McKenzie
bd3812c255 handle SwitchStatements as a different type of path when pushing a declaration - fixes #1614 2015-05-24 01:43:04 +01:00
Sebastian McKenzie
e498185a76 Merge pull request #1610 from dekelcohen/master
Fixed Remove Debugger transformer to use DebuggerStatement
2015-05-22 23:36:47 +01:00
Dekel Cohen
167eda4750 Fixed Remove Debugger transformer to use DebuggerStatement 2015-05-23 01:13:23 +03:00
Sebastian McKenzie
3b52ddce6d 5.4.7 2015-05-21 19:00:16 +01:00
Sebastian McKenzie
0e771c5d38 v5.4.7 2015-05-21 18:59:30 +01:00
Sebastian McKenzie
2ec1544f2d add 5.4.7 changelog 2015-05-21 18:58:49 +01:00
Sebastian McKenzie
049ef430b2 5.4.6 2015-05-21 18:58:12 +01:00
Sebastian McKenzie
34eb2babdb don't consider JSXAttribute keys to be referenced identifiers - fixes #1596 2015-05-21 18:58:07 +01:00
Sebastian McKenzie
8706754550 v5.4.6 2015-05-21 18:46:22 +01:00
Sebastian McKenzie
c7b507e119 add 5.4.6 changelog 2015-05-21 18:45:31 +01:00
Sebastian McKenzie
221c632c05 deprecate custom module formatters 2015-05-21 18:44:02 +01:00
Sebastian McKenzie
7dbde208ef spec.functionName transformer: hasBinding(name) returns true for built-in globals, so we attempt to rename the binding but it doesn't exist so exits early, add a check that doesn't perform the renaming and instead uses the wrapper - fixes #1598 2015-05-21 18:43:55 +01:00
Sebastian McKenzie
52a2e3e17c return original input if glob returned nothing in babel-cli - fixes #1591 2015-05-21 10:57:37 +01:00
Sebastian McKenzie
fa22d7dca0 5.4.5 2015-05-21 01:52:03 +01:00
Sebastian McKenzie
9fcdebde08 v5.4.5 2015-05-21 01:44:29 +01:00
Sebastian McKenzie
92157161f0 fix prettyCall generation option 2015-05-21 01:43:02 +01:00
Sebastian McKenzie
82b5479436 add 5.4.5 changelog 2015-05-21 01:41:30 +01:00
Sebastian McKenzie
91a037af55 Merge pull request #1590 from Khan/fix_retainLines_with_jsx
tests for retainLines formatting
2015-05-21 01:39:33 +01:00
Kevin Barabash
067fccc2c9 tests for retainLines formatting 2015-05-20 18:36:47 -06:00
Sebastian McKenzie
348c0d2542 handle TCO for calls that exceed the functions parameter count - fixes #1589 2015-05-21 01:21:49 +01:00
Sebastian McKenzie
f2f6bbb02c clean up explosion of module declarations, remove and inherit comments when taking off the declaration - fixes #1583 2015-05-21 01:03:23 +01:00
Sebastian McKenzie
16f7b967b5 ignore CallExpression _prettyCall when retainLines is enabled - fixes #1585 2015-05-21 00:21:18 +01:00
Sebastian McKenzie
270a8be68d add JSXIdentifier as a valid ReferencedIdentifier - fixes #1584 2015-05-21 00:20:53 +01:00
Sebastian McKenzie
82254d9d9b force push space for await/async - fixes #1581 2015-05-20 12:45:04 +01:00
Sebastian McKenzie
759a265fb0 5.4.4 2015-05-20 10:52:28 +01:00
Sebastian McKenzie
ee46f45c90 v5.4.4 2015-05-20 10:50:35 +01:00
Sebastian McKenzie
c45ce61550 print assignment pattern shorthand with matching key nicely 2015-05-20 10:44:36 +01:00
Sebastian McKenzie
b36cf11ac8 add 5.4.4 changelog 2015-05-20 10:44:17 +01:00
Sebastian McKenzie
dca0f72e4d clarify default option descriptions - fixes #1577 2015-05-20 10:36:58 +01:00
Sebastian McKenzie
68a99ed1e9 fix es6.modules-system for head hoisting 2015-05-20 10:35:01 +01:00
Sebastian McKenzie
af4feb4d88 fix renaming of assignment expressions to fix pattern renaming in the es6.blockScoping transformer - fixes #1576 2015-05-20 10:34:50 +01:00
Sebastian McKenzie
de1e965fec fix placement of for loop in es6.modules-system hoisting test 2015-05-20 10:15:42 +01:00
Sebastian McKenzie
430c5df0e7 rename sourceMapName option to sourceMapTarget - closes #1568 2015-05-20 10:14:28 +01:00
Sebastian McKenzie
9b12f799f7 clean up system module formatter hoisting visitor and allow contextual replacement of variable declarations with expressions in for head positions - fixes #1570 2015-05-20 10:07:29 +01:00
Sebastian McKenzie
f3a9c6ee5d Merge pull request #1562 from clintwood/sourcemap-file
correct cli source map file: value, honor sourceRoot when using -o opion
2015-05-20 09:57:34 +01:00
Sebastian McKenzie
e0aceeafef Merge pull request #1570 from guybedford/system-hoist-bug
System format hoisting bug
2015-05-20 09:57:14 +01:00
Sebastian McKenzie
7643d86047 Merge branch 'master' of github.com:babel/babel 2015-05-20 09:57:03 +01:00
Sebastian McKenzie
98af01a73c update old 6to5 package.json description 2015-05-20 09:56:54 +01:00
Sebastian McKenzie
e280a810c3 add support for all completion record types when exploding an expression to statements 2015-05-20 09:56:45 +01:00
Sebastian McKenzie
7a59575d1e force space before class id when generating classes - fixes #1579 2015-05-20 09:56:19 +01:00
Sebastian McKenzie
b01d8448a0 Merge pull request #1558 from jquense/patch-2
Resolve "babel-plugin-" name before trying the plain name.
2015-05-19 01:28:02 +01:00
jquense
9b3c8569f7 Resolve 'babel-plugin-' name before the plain name
Otherwise you get situations like the following: `plugins: [
'object-assign']` resolves the module `object-assign` (an Object.assign
polyfill) instead of the intended babel plugin:
babel-plugin-object-assign.
2015-05-18 20:26:51 -04:00
Sebastian McKenzie
12104f822f add assignment pattern shorthand support to explode transformer - fixes #1566 2015-05-18 22:44:40 +01:00
Sebastian McKenzie
b4cd2df745 ignore this and arguments when performing TCO on shadowed functions - fixes #1564 2015-05-18 22:41:27 +01:00
guybedford
887ffed84c system hoist bug test case 2015-05-18 23:35:09 +02:00
Sebastian McKenzie
9be3d9c8e1 Merge branch 'master' of github.com:babel/babel 2015-05-18 10:33:12 +01:00
clintwood (Office)
9d3dff3b7a correct cli source map file: value, honor sourceRoot when using -o option 2015-05-18 10:11:20 +02:00
Sebastian McKenzie
55114ec631 update AMD module formatter to add import default remapping - #1150 2015-05-18 02:01:34 +01:00
Sebastian McKenzie
9c3d00d3c3 Merge pull request #1559 from sindresorhus/hometmp
use `home-or-tmp` module instead of `user-home`
2015-05-17 23:50:26 +01:00
Sindre Sorhus
90b8826e73 use home-or-tmp module instead of user-home
The main point about using this instead of just falling back in code is that it depends on an `os.tmpdir()` polyfill [0], which means the tmpdir handling is the same no matter node/iojs version. This is useful as the core `os.tmpdir()` function has changed a lot between node versions.

[0]: https://github.com/sindresorhus/os-tmpdir

---

`os.tmpdir()` diff between Node 0.10.38 and iojs 2.0.2

```diff
+const trailingSlashRe = isWindows ? /[^:]\\$/
+                                  : /.\/$/;
+
 exports.tmpdir = function() {
-  return process.env.TMPDIR ||
-         process.env.TMP ||
-         process.env.TEMP ||
-         (process.platform === 'win32' ? 'c:\\windows\\temp' : '/tmp');
+  var path;
+  if (isWindows) {
+    path = process.env.TEMP ||
+           process.env.TMP ||
+           (process.env.SystemRoot || process.env.windir) + '\\temp';
+  } else {
+    path = process.env.TMPDIR ||
+           process.env.TMP ||
+           process.env.TEMP ||
+           '/tmp';
+  }
+  if (trailingSlashRe.test(path))
+    path = path.slice(0, -1);
+  return path;
 };
```
2015-05-18 00:39:49 +02:00
Sebastian McKenzie
65f39bbf6f switch order of jsx/flow plugins to avoid precedence issues - fixes babel/babel-eslint#103 2015-05-17 22:00:38 +01:00
Sebastian McKenzie
e9eced846f 5.4.3 2015-05-16 02:00:20 +01:00
Sebastian McKenzie
a0befe349d v5.4.3 2015-05-16 01:58:52 +01:00
Sebastian McKenzie
04992effb3 improve lost node path tracking message 2015-05-16 01:54:35 +01:00
Sebastian McKenzie
9ae54d2a50 add 5.4.3 changelog 2015-05-16 01:54:25 +01:00
Sebastian McKenzie
fe72a40159 Revert "add back descriptor.initializer existence check"
This reverts commit 02dfd18023.
2015-05-16 01:50:31 +01:00
Sebastian McKenzie
ea510d09d0 fix module shadowing when using CommonJS-like module formatters - fixes #1544 2015-05-16 01:47:48 +01:00
Sebastian McKenzie
375689a1ff handle path contexts MUCH better, they're now only held during the traversal iteration and the previous context is released upon completion, also verify path keys and try and obtain a new one if invalid - fixes #1545 2015-05-16 01:37:55 +01:00
Sebastian McKenzie
9908e331b7 Merge pull request #1549 from Naddiseo/master
Added DCE tests for all the bugs I've reported so far.
2015-05-15 23:08:32 +01:00
Richard Eames
cd8655708d Added DCE tests for all the bugs I've reported so far. 2015-05-15 15:55:58 -06:00
Sebastian McKenzie
62b94f297a don't create a new binding for local class ids, just copy the parents - fixes #1547 2015-05-15 19:11:24 +01:00
Sebastian McKenzie
01d399ee3c check for existence of variable when checking if node is pure 2015-05-15 18:48:17 +01:00
Sebastian McKenzie
30e3908484 don't perform DCE on single references nested inside the binding initializer - fixes #1546 2015-05-15 18:48:05 +01:00
Sebastian McKenzie
ff12046009 move traverse replace test up 2015-05-15 18:35:15 +01:00
Sebastian McKenzie
1a058b4a6e Merge branch 'master' of github.com:babel/babel 2015-05-15 17:42:40 +01:00
Sebastian McKenzie
02dfd18023 add back descriptor.initializer existence check 2015-05-15 17:42:28 +01:00
Sebastian McKenzie
9ab7df5f47 remove wildcards from start of patterns 2015-05-15 17:42:10 +01:00
Sebastian McKenzie
7a5b140f92 minor generation style nits 2015-05-15 17:41:56 +01:00
Sebastian McKenzie
6f83111c55 Merge pull request #1542 from amasad/already-printed
Fix bug with paren printing in compact + line retained mode
2015-05-15 17:38:40 +01:00
Sebastian McKenzie
f3f60368da remove TraversalPath node getter/setter 2015-05-15 17:34:31 +01:00
Sebastian McKenzie
7a09640b20 add environment to register cache key 2015-05-15 17:34:06 +01:00
Amjad Masad
2916d1262b Don't print leftParen if already printed before the catchup 2015-05-14 23:57:35 -07:00
Amjad Masad
741abb73d2 Add failing test for printing with compact & retainLines 2015-05-14 23:57:05 -07:00
Sebastian McKenzie
2e46755260 5.4.2 2015-05-15 02:36:22 +01:00
Sebastian McKenzie
2cff9519e1 v5.4.2 2015-05-15 02:35:07 +01:00
Sebastian McKenzie
f9c2c6e988 Merge branch 'master' of github.com:babel/babel
# Conflicts:
#	CHANGELOG.md
2015-05-15 02:34:11 +01:00
Sebastian McKenzie
5ae3dc01f1 make path patterns used by only and ignore **very** liberal, this will ease a lot of pain in dealing with them 2015-05-15 02:33:40 +01:00
Sebastian McKenzie
af4fd69dd0 make path patterns used by only and ignore **very** liberal, this will ease a lot of pain in dealing with them 2015-05-15 02:33:22 +01:00
Sebastian McKenzie
4d4493f325 elaborate on shouldIgnore changes in 5.4.1 2015-05-15 02:03:02 +01:00
Sebastian McKenzie
e70d474b39 5.4.1 2015-05-15 02:01:42 +01:00
Sebastian McKenzie
1b45f64858 v5.4.1 2015-05-15 02:00:18 +01:00
Sebastian McKenzie
b89cf6768f fix shouldIgnore only matches switch 2015-05-15 01:57:10 +01:00
Sebastian McKenzie
36ad1108b4 fix loose mode loop being weirdly inserted 2015-05-15 01:56:34 +01:00
Sebastian McKenzie
4c04371ea4 remove loop label due to babel bug 2015-05-15 01:48:47 +01:00
Sebastian McKenzie
d3e385c554 one last try fixing the shouldIgnore only filter... 2015-05-15 01:46:36 +01:00
Sebastian McKenzie
6afcef9805 actually fix shouldIgnore algorithm this time, ugh 2015-05-15 01:44:57 +01:00
Sebastian McKenzie
ed861e230b fix shouldIgnore method for only 2015-05-15 01:41:49 +01:00
Sebastian McKenzie
e15ced2922 add 5.4.1 changelog 2015-05-15 01:37:48 +01:00
Sebastian McKenzie
93052e532f Merge branch 'master' of github.com:babel/babel 2015-05-15 01:35:43 +01:00
Sebastian McKenzie
198d51ddaa heavily improve shouldIgnore algorithm - fixes #1539 2015-05-15 01:34:58 +01:00
Sebastian McKenzie
8730b24def Merge pull request #1540 from browncolyn/master
Added slash as needed dependency
2015-05-15 01:30:50 +01:00
Colyn Brown
f09c0d5998 Added slash as needed dependency 2015-05-14 17:28:20 -07:00
Sebastian McKenzie
21e4481ab7 5.4.0 2015-05-15 00:32:36 +01:00
Sebastian McKenzie
2f61754a24 v5.4.0 2015-05-15 00:29:42 +01:00
Sebastian McKenzie
3910d18bc9 add 5.4.0 changelog 2015-05-15 00:28:47 +01:00
Sebastian McKenzie
583111ebfb expose file metadata object to transformers 2015-05-15 00:24:14 +01:00
Sebastian McKenzie
1b15481460 ignore "ignored files" when babel.transform has determined that it should be ignored, this is likely the result of an rc file resolution - fixes #1362 2015-05-15 00:24:03 +01:00
Sebastian McKenzie
fd9c98ff86 move strict transformer to builtin-setup group - fixes #1538 2015-05-15 00:18:42 +01:00
Sebastian McKenzie
41b5607ef3 fix env option tests 2015-05-15 00:11:28 +01:00
Sebastian McKenzie
ae77ea807f normalise source map file paths when using the CLI - fixes #1496 2015-05-15 00:05:11 +01:00
Sebastian McKenzie
ad44190c6b properly register for head variable declaration paths when performing scope tracking - fixes #1524 2015-05-14 23:53:04 +01:00
Sebastian McKenzie
024e4454a1 add env option - closes #1531 2015-05-14 23:47:56 +01:00
Sebastian McKenzie
14dddcda36 make PathHoister much more flexible, now ignores global references and will not deopt on reassignments and will instead hoist as high as it can, this also fixes #1529 since the order of operations has changed 2015-05-14 23:29:02 +01:00
Sebastian McKenzie
d4fb924b6a add tion comment to all function visitors 2015-05-14 22:37:15 +01:00
Sebastian McKenzie
b02c97af60 Merge pull request #1536 from benjamn/master
Invoke Regenerator on async/generator Function nodes, not whole AST.
2015-05-14 22:27:42 +01:00
Ben Newman
cc611cb71c Invoke Regenerator on async/generator Function nodes, not whole AST.
This should help (dramatically?) with
https://github.com/babel/babel/issues/1486#issuecomment-101491605,
although I'm not sure how to run the benchmarks myself.
2015-05-14 15:42:58 -05:00
Sebastian McKenzie
b8a01a9919 move traversal scope logic and binding into it's own folder, rename Scope#generateTemp to generateDeclaredUidIdentifier, rename Scope#generateUidBasedOnNode to Scope#generateUidIdentifierBasedOnNode 2015-05-14 19:12:26 +01:00
Sebastian McKenzie
55c99661be NFO 2015-05-14 18:07:36 +01:00
Sebastian McKenzie
1563b216df Merge branch 'master' of github.com:babel/babel 2015-05-14 17:56:33 +01:00
Sebastian McKenzie
a9d4b485d9 simplify getStaticContext in es7.functionBind transformer - thanks @RReverser! 2015-05-14 17:48:51 +01:00
Sebastian McKenzie
360daa6267 Merge pull request #1532 from dchambers/prefix-private-methods-with-underscore
Prefix private methods names with underscore.
2015-05-14 16:52:16 +01:00
Sebastian McKenzie
724bf52929 handle "static" contexts in es7.functionBind - #1518 2015-05-14 16:37:44 +01:00
Sebastian McKenzie
7407b37bd9 Merge pull request #1518 from babel/es7.functionBind
Add experimental support for ES7 function bind.
2015-05-14 16:22:21 +01:00
Ingvar Stepanyan
da765cc4c1 Flip the negation in if-else. 2015-05-14 18:05:55 +03:00
dchambers
4f862eee6e Prefix private methods names with underscore. 2015-05-14 13:19:41 +01:00
Ingvar Stepanyan
e05d7cf49a Fix some parsing edge cases for :: operator. 2015-05-14 12:47:51 +03:00
Ingvar Stepanyan
fd8e94a90f Preserve original execution order in :: operator. 2015-05-14 12:39:05 +03:00
Sebastian McKenzie
a6cf28c5b5 Merge pull request #1525 from nkt/exponentiation-operator-inline
Added missing exponential operator inlining
2015-05-13 23:09:57 +01:00
Nikita Gusakov
6b07b13a8e Added missing exponential operator inlining 2015-05-14 01:08:02 +03:00
Sebastian McKenzie
561c4dcc25 5.3.3 2015-05-13 22:09:37 +01:00
Sebastian McKenzie
b516ea596a v5.3.3 2015-05-13 22:08:32 +01:00
Sebastian McKenzie
248758eee3 fix version number 2015-05-13 22:07:33 +01:00
Sebastian McKenzie
a808602ae0 v3.5.3 2015-05-13 22:07:00 +01:00
Sebastian McKenzie
40e3436e95 add 3.5.3 changelog 2015-05-13 22:05:07 +01:00
Sebastian McKenzie
f704770b26 uncomment out return traversal path skipping - fixes #1523 2015-05-13 22:03:50 +01:00
Sebastian McKenzie
330665f150 ignore modules alongside param bindings in minification.deadCodeElimination transformer - fixes #1523 2015-05-13 21:49:28 +01:00
Sebastian McKenzie
af41899d74 5.3.2 2015-05-13 19:58:21 +01:00
Sebastian McKenzie
d12f4d0bc8 v5.3.2 2015-05-13 19:57:20 +01:00
Sebastian McKenzie
97680e9dfd properly hoist all var patterns when wrapping bodies in the es6.blockScoping transformer - fixes #1521 2015-05-13 19:55:40 +01:00
Sebastian McKenzie
51341ca6c3 fix and add missing module specifier reference detection - fixes #1520 2015-05-13 19:23:47 +01:00
Sebastian McKenzie
ab54bfa50e Merge pull request #1519 from zpao/package-licenses
Add license fields to packages
2015-05-13 18:36:25 +01:00
Paul O’Shannessy
60aa933fb6 Add license fields to packages 2015-05-13 10:21:42 -07:00
Ingvar Stepanyan
1a299b2bcc Small fixes to es7.functionBind and generation tests added. 2015-05-13 18:20:33 +03:00
Ingvar Stepanyan
37f662d790 Add experimental support for ES7 function bind. (issue #1287) 2015-05-13 17:58:21 +03:00
Sebastian McKenzie
b0317f9bab don't consider "globals" to cause incompatible scope hoist 2015-05-13 12:33:08 +01:00
Sebastian McKenzie
be2dfaf081 register variable declarator in scope when pushing 2015-05-13 09:11:09 +01:00
Sebastian McKenzie
2c8437ae92 ignore initializerless variable declaration when trying to inline single use variables - fixes #1516 2015-05-13 08:46:41 +01:00
Sebastian McKenzie
2a0bcfd086 add support for evaluating unary ~ 2015-05-13 08:45:16 +01:00
Sebastian McKenzie
2cf41afac3 move expression inlining to exit rather than enter in minification.inlineExpressions transformer 2015-05-13 08:45:06 +01:00
Sebastian McKenzie
e318f5f3be use ReferencedIdentifier virtual type in minification.deadCodeElimination transformer 2015-05-13 08:44:33 +01:00
Sebastian McKenzie
939decb86c stop entire unnecessary traversal for regenerator 2015-05-13 08:44:18 +01:00
Sebastian McKenzie
1baa0df948 clean up array inferrence for #1515 2015-05-13 08:44:03 +01:00
Sebastian McKenzie
e8956a8c44 upgrade dev dependency babel to 5.3.1 2015-05-13 08:43:25 +01:00
Sebastian McKenzie
2f0fdbbc26 5.3.1 2015-05-13 03:21:54 +01:00
Sebastian McKenzie
5f931525bc v5.3.1 2015-05-13 03:20:33 +01:00
Sebastian McKenzie
b86545a320 update 5.3.1 changelog 2015-05-13 03:19:39 +01:00
Sebastian McKenzie
06e75c42bf update module call remap tests 2015-05-13 03:18:55 +01:00
Sebastian McKenzie
05dd65244d add 5.3.1 changelog 2015-05-13 03:16:43 +01:00
Sebastian McKenzie
c4ebfeb0fa fix explosion of modules and colliding identifiers 2015-05-13 03:16:03 +01:00
Sebastian McKenzie
1aa0bbfac9 add TraversalPath#equals 2015-05-13 03:13:27 +01:00
Sebastian McKenzie
58f1e6cbc6 remove incorrect es6.tailCall visitor comment 2015-05-13 03:13:20 +01:00
Sebastian McKenzie
83e0be3038 make import calls sequence expressions - fixes #1514 2015-05-13 03:13:10 +01:00
Sebastian McKenzie
5fc242e4ec upgrade bable dev dependency to 5.3.0 2015-05-13 03:12:32 +01:00
Sebastian McKenzie
dc101adad3 more es6.tailCall transformer cleanup 2015-05-13 01:13:08 +01:00
Sebastian McKenzie
faade72787 optimise and clean up es6.tailCall transformer 2015-05-13 01:11:26 +01:00
Sebastian McKenzie
2a78ae9889 5.3.0 2015-05-13 01:07:11 +01:00
Sebastian McKenzie
9840639843 v5.3.0 2015-05-13 00:13:14 +01:00
Sebastian McKenzie
82c21a901e clean up es6.tailCall thirdPass visitor 2015-05-13 00:11:19 +01:00
Sebastian McKenzie
e1c83144c1 add 5.3.0 changelog 2015-05-13 00:11:08 +01:00
Sebastian McKenzie
ef2ac73215 fix export scope tracking reference counter - fixes #1513 2015-05-12 23:21:30 +01:00
Sebastian McKenzie
735d8955bf sync with upstream acorn 2015-05-12 23:21:30 +01:00
Sebastian McKenzie
3abee0a4fa fix switch case breaks not being correctly transformed when non top-level - fixes #1200 2015-05-12 23:21:30 +01:00
Sebastian McKenzie
b6f18b4f2b Merge pull request #1200 from lukasmlady/regenerator-let-fn-if-bug
Add failing tests that document ES 6 generators bug
2015-05-12 23:21:17 +01:00
Sebastian McKenzie
85cd0465fa Merge pull request #1511 from amasad/trailing-methods
Trailing commas in methods
2015-05-12 21:46:18 +01:00
Amjad Masad
0452e0fdd2 Allow trailing commas in methods 2015-05-12 13:20:36 -07:00
Amjad Masad
462ff572b3 Add failing test for trailing commas in methods 2015-05-12 13:19:21 -07:00
Sebastian McKenzie
d11099bb2b Merge branch 'master' of github.com:babel/babel 2015-05-12 19:13:53 +01:00
Sebastian McKenzie
f5c4684d3e force default parameter IIFE on reference to eval 2015-05-12 19:13:32 +01:00
Sebastian McKenzie
876a22578b Merge pull request #1506 from sverrejoh/patch-1
Added missing license field to package.json
2015-05-12 09:06:55 +01:00
Sverre Johansen
9f5e8b296b Added missing license field to package.json
Project says MIT, but license field missing in package.json
2015-05-12 08:54:56 +02:00
Sebastian McKenzie
d9deb02edc register as inside a type when parsing type aliases to avoid ambiguous jsx parsing - fixes #1378 2015-05-11 23:44:22 +01:00
Sebastian McKenzie
a402d0cdeb ensure that uids don't collide with **any** bindings contained in the program - fixes #1328 2015-05-11 23:37:31 +01:00
Sebastian McKenzie
683fb62505 fix acorn hacky lookahead with token contexts - fixes #1349 2015-05-11 23:20:51 +01:00
Sebastian McKenzie
941474983d clean up es6.objectSuper transformer - fixes #1502 2015-05-11 22:34:08 +01:00
Sebastian McKenzie
2b42773e01 explode duplicate identifiers in export/import specifiers and property shorthand - fixes #1458 2015-05-11 22:08:38 +01:00
Sebastian McKenzie
8277a532f4 skip loose mode for class methods when using decorators, addresses #1501 2015-05-11 17:40:36 +01:00
Sebastian McKenzie
539784b640 add Scope#moveBindingTo method and change more for array loops to for...of 2015-05-11 17:25:09 +01:00
Sebastian McKenzie
f373f8f003 refactor _shadowFunctions transformer to not do an entire traverse per function 2015-05-11 11:38:22 +01:00
Sebastian McKenzie
8605e835eb add exit visitor existence to unvisitable node shortcircuiting 2015-05-11 01:52:19 +01:00
Sebastian McKenzie
b4ace2043a fix shortcircuting of unvisitable nodes 2015-05-11 01:43:18 +01:00
Sebastian McKenzie
444a64e934 remove incorrect no eval in strict mode 2015-05-10 20:01:13 +01:00
Sebastian McKenzie
8ea2ae924d add existence check for ast.comments 2015-05-10 20:00:38 +01:00
Sebastian McKenzie
4ceb1d6f5e short circuit unnecessary visits 2015-05-10 20:00:26 +01:00
Sebastian McKenzie
3c81899ca7 add --harmony_generators to list of node flags - closes #1474, closes #1473 2015-05-10 20:00:12 +01:00
Sebastian McKenzie
ab59fd08e5 fix array type inferrence for file#toArray from being so wonky - fixes #1355 2015-05-10 19:35:41 +01:00
Sebastian McKenzie
19b05b5e61 change some manual array for loops to for..of 2015-05-10 19:35:05 +01:00
Sebastian McKenzie
65a44a1e13 remove use of exports 2015-05-10 16:09:43 +01:00
Sebastian McKenzie
d38f18af40 create null object when clearing internalRemap instead of using an object inherited plain object - fixes #1489 2015-05-09 18:39:59 +01:00
Sebastian McKenzie
2744b9f31f only print misisng ast.comments when available 2015-05-09 17:32:47 +01:00
Sebastian McKenzie
4deed35212 fix syntax errors introduced with previous lodash each removal 2015-05-09 17:27:33 +01:00
Sebastian McKenzie
bc9ae5ea8b remove many instances of lodash each in favor of for of loops 2015-05-09 17:22:01 +01:00
Sebastian McKenzie
87d879e236 Merge branch 'master' of github.com:babel/babel 2015-05-09 16:53:05 +01:00
Sebastian McKenzie
f657598c72 remove noop traversal visitors methods 2015-05-09 16:52:57 +01:00
Sebastian McKenzie
2a5cb9d21b move some utility transformers to minification 2015-05-09 16:52:31 +01:00
Sebastian McKenzie
cf7d6b655e Merge pull request #1487 from amasad/trailing-commas
[es7.trailingFunctionCommas] Allow in new expressions
2015-05-09 03:16:18 +01:00
Amjad Masad
6d2723eec5 New expressions is allowed to have trailing commas in es7 proposal 2015-05-08 19:12:53 -07:00
Amjad Masad
6834cc5b46 Add failing tests for trailing commas in new expressions 2015-05-08 19:12:10 -07:00
Sebastian McKenzie
9b949e574f use block scoped variables in es6.blockScoping transformer 2015-05-09 01:25:36 +01:00
Sebastian McKenzie
a75af0a5d2 optimise es6.constants transformer to use the same traversal path instead of spawning another one 2015-05-09 01:25:21 +01:00
Sebastian McKenzie
080b26769c remove compat-table 2015-05-09 00:09:19 +01:00
Sebastian McKenzie
e037ae7bc9 automatically explode visitors 2015-05-09 00:07:08 +01:00
Sebastian McKenzie
c60ad89937 add verbose mode to logging 2015-05-09 00:06:55 +01:00
Sebastian McKenzie
4194857086 fix system modules test to reflect strict hoisting behaviour 2015-05-08 23:58:25 +01:00
Sebastian McKenzie
1179c44c5b share comments with siblings when nodes are removed - fixes #1484 2015-05-08 23:57:12 +01:00
Sebastian McKenzie
f6d9b270c9 update to tracuer master 2015-05-08 23:48:30 +01:00
Sebastian McKenzie
1be0159b01 Merge pull request #1484 from amasad/type-comment-print
[Flow] Add failing tests for printing comments w/ type alias
2015-05-08 23:46:18 +01:00
Sebastian McKenzie
61ba8ad997 Merge pull request #1472 from babel/single-pass
Merge internal transformers into single traversal pass
2015-05-08 23:36:29 +01:00
Sebastian McKenzie
89e31085d2 ensure dynamic imports are hoisted 2015-05-08 23:33:30 +01:00
Sebastian McKenzie
920c84a1f2 move shadow function visitors to entrance instead of exit 2015-05-08 23:33:20 +01:00
Amjad Masad
ed56fecd04 [Flow] Add failing tests for printing comments w/ type alias 2015-05-08 15:33:00 -07:00
Sebastian McKenzie
f0bfdfb699 skip traversing back into ReturnStatement replacement when rewriting loops in the es6.blockScoping transformer 2015-05-08 23:13:27 +01:00
Sebastian McKenzie
b02a1112bc change ClassExpression visitor to enter instead of exist in the es6.classes transformer 2015-05-08 23:10:02 +01:00
Sebastian McKenzie
590a165776 move hoistDirectives transformer to builtin-setup 2015-05-08 23:09:45 +01:00
Sebastian McKenzie
2fd1b2a484 rename category metadata option to group 2015-05-08 22:54:15 +01:00
Sebastian McKenzie
8f9d02d689 further work splitting up transformers into their own "category" in order of what they need and what they actually do 2015-05-08 22:53:31 +01:00
Sebastian McKenzie
b376b6b33b store uncollapsed transformer pass stack so we have access to it when calling pre and post methods 2015-05-08 22:53:03 +01:00
Sebastian McKenzie
8292d6d8ad fix replacement requeue exiting too early 2015-05-08 22:52:38 +01:00
Sebastian McKenzie
d6a5c39079 update classes to reflect new transformer precedence 2015-05-08 22:52:19 +01:00
Sebastian McKenzie
2a9a59f784 remove incomplete ludicrous transformer 2015-05-08 22:52:02 +01:00
Sebastian McKenzie
abf4a5495a don't pretty print variable declarators in concise mode 2015-05-08 22:51:47 +01:00
Sebastian McKenzie
f8b8723bef Merge pull request #1483 from jquense/patch-1
Fix plugin api typo when an object is passed in
2015-05-08 22:26:45 +01:00
Jason Quense
6b9686f2dd Fix plugin api typo when an object is passed in 2015-05-08 17:25:14 -04:00
Sebastian McKenzie
4a439d8c8e update flow strip type annotations test 2015-05-08 15:52:08 +01:00
Sebastian McKenzie
c526a3eb04 move shadow-functions internal transformer to builtin-cleanup category 2015-05-08 15:51:56 +01:00
Sebastian McKenzie
ba516901af restructure transformers into multiple categories 2015-05-08 15:26:00 +01:00
Sebastian McKenzie
8f52229a86 add get function name to source map classes test 2015-05-08 15:25:50 +01:00
Sebastian McKenzie
5b793f8882 fix TraversalPath#_getPattern incorrectly iterating over the parts 2015-05-08 15:25:34 +01:00
Sebastian McKenzie
b31c14c52a Merge branch 'master' into single-pass 2015-05-08 00:24:33 +01:00
Sebastian McKenzie
78b72512cb better verify the type of the new node before requeueing it and also stop current node traversal on skip 2015-05-08 00:24:04 +01:00
Sebastian McKenzie
2fbb3cad9f add isUser and isGenerated path methods 2015-05-08 00:23:28 +01:00
Sebastian McKenzie
2621081a13 merge in astVisitor in runtime transformer - unsure why this was separate in the first place 2015-05-08 00:23:00 +01:00
Sebastian McKenzie
8daf95bf59 name additional methods that are now covered since the naming is done in tandem 2015-05-08 00:22:43 +01:00
Sebastian McKenzie
6e8ab16b25 run es6.spec.blockScoping transformer on exit rather than enter 2015-05-08 00:22:23 +01:00
Sebastian McKenzie
a5cda5caa7 hoist param declaration when performing tco - fixes #1478 2015-05-07 23:14:03 +01:00
Sebastian McKenzie
13a6c69668 add node existence check to each visitor call 2015-05-07 23:02:40 +01:00
Sebastian McKenzie
380293d030 add transformer dependencies - fixes #1477 2015-05-07 21:35:12 +01:00
Sebastian McKenzie
0b15a97013 Merge branch 'master' into single-pass 2015-05-07 20:15:34 +01:00
Sebastian McKenzie
11af066956 5.2.17 2015-05-07 20:15:17 +01:00
Sebastian McKenzie
d7b4d342c3 v5.2.17 2015-05-07 20:12:47 +01:00
Sebastian McKenzie
77aeebe2a8 add Super node type to ast-types patch 2015-05-07 20:11:37 +01:00
Sebastian McKenzie
c3a08d413f attach auxiliary comment to function declaration helpers - fixes #1476 2015-05-07 20:11:31 +01:00
Sebastian McKenzie
23ac2319af add Super node type to ast-types patch 2015-05-07 20:11:14 +01:00
Sebastian McKenzie
a1bc0704ab attach auxiliary comment to function declaration helpers - fixes #1476 2015-05-07 20:11:02 +01:00
Sebastian McKenzie
0bbfd427af do module formatter on program exit rather than entrance 2015-05-07 16:23:47 +01:00
Sebastian McKenzie
f17b268a71 do member expression and property literal conversion to computed on exit rather than on entrance 2015-05-07 16:23:33 +01:00
Sebastian McKenzie
9ffc265bea don't requeue node unless the type has changed 2015-05-07 16:01:00 +01:00
Sebastian McKenzie
6f664ca64e merge internal transformers into single traversal pass 2015-05-07 15:53:22 +01:00
Sebastian McKenzie
8a4a76000d correctly arrayify commander extensions - closes #1470, fixes #1460 2015-05-07 13:55:12 +01:00
Sebastian McKenzie
e83daf87d4 add this.stop() to secondary strict transformer #1465 2015-05-07 08:38:46 +01:00
Sebastian McKenzie
8ed90d3af2 ignore parameter bindings in minification.deadCodeElimination transformer - fixes #1464 2015-05-07 01:58:54 +01:00
Sebastian McKenzie
0bb311f8ce 5.2.16 2015-05-06 16:45:32 +01:00
Sebastian McKenzie
53f0f0302b v5.2.16 2015-05-06 16:44:28 +01:00
Sebastian McKenzie
c25a5d2480 add 5.2.16 changelog 2015-05-06 16:43:21 +01:00
Sebastian McKenzie
fc8540d88a inherit destructuring param replacement ref from original param - fixes #1461 2015-05-06 16:29:54 +01:00
Sebastian McKenzie
31a4195c81 fix incorrect extensions variable reference - fixes #1460 2015-05-06 16:23:15 +01:00
Sebastian McKenzie
bf0e4ede00 pass correct function scope to nameMethod.property when naming class methods - fixes #1456 2015-05-06 16:03:15 +01:00
Sebastian McKenzie
3757bc6b9a reverse method decorators - fixes #1457 2015-05-06 15:57:21 +01:00
Sebastian McKenzie
2e01f220da Merge branch 'master' of github.com:babel/babel 2015-05-06 15:44:05 +01:00
Sebastian McKenzie
8ae4e1fdf2 add --harmony_rest_parameters flag to babel-node - fixes #1446 2015-05-06 15:43:51 +01:00
Sebastian McKenzie
f6219ec15a Merge pull request #1455 from monsanto/fix-async-constructor
Disallow async constructors
2015-05-06 15:12:12 +01:00
Christopher Monsanto
6a82eb5a5c disallow async constructors -- fixes #1454 2015-05-06 02:50:11 -04:00
Sebastian McKenzie
a241300ff1 force plugins to be ran at all times - fixes #1450 2015-05-06 01:14:17 +01:00
Sebastian McKenzie
d5548a6ff9 5.2.15 2015-05-05 15:41:57 +01:00
Sebastian McKenzie
ba6cb112c3 v5.2.15 2015-05-05 15:41:00 +01:00
Sebastian McKenzie
8f1bb84930 add 5.2.15 changelog 2015-05-05 15:39:05 +01:00
Sebastian McKenzie
235726eee6 remove unnecessary descriptor.initializer check 2015-05-05 15:38:17 +01:00
Sebastian McKenzie
08183ef490 don't add descriptor if we can't find it 2015-05-05 15:37:24 +01:00
Sebastian McKenzie
dc6fc3b30a fix browser-polyfill.js post-make publish purging 2015-05-05 15:37:11 +01:00
Sebastian McKenzie
76f2eb5684 5.2.14 2015-05-05 15:14:59 +01:00
Sebastian McKenzie
4f33687957 v5.2.14 2015-05-05 15:12:19 +01:00
Sebastian McKenzie
74f37fe0a3 expose unminified and minified builds of dist scripts - fixes #1444 2015-05-05 15:11:00 +01:00
Sebastian McKenzie
cc5e4bce52 fix object/property decorator interop 2015-05-05 14:42:41 +01:00
Sebastian McKenzie
f441a7cae8 don't do pretty variable declaration formatting if retainLines is enabled 2015-05-05 14:04:51 +01:00
Sebastian McKenzie
fc2be81c43 expose retainLines option to CLI 2015-05-05 14:04:36 +01:00
Sebastian McKenzie
1277a8f67f 5.2.13 2015-05-05 08:58:35 +01:00
Sebastian McKenzie
86c6d4e769 v5.2.13 2015-05-05 08:57:41 +01:00
Sebastian McKenzie
bf2d527cfe upgrade esquery 2015-05-05 08:56:58 +01:00
Sebastian McKenzie
6b59ea8eac add 5.2.13 changelog 2015-05-05 08:56:28 +01:00
Sebastian McKenzie
72e3cb9243 trigger a reference for export declarations 2015-05-05 08:54:51 +01:00
Sebastian McKenzie
5e5ede6058 move down _modules transformer 2015-05-05 08:54:38 +01:00
Sebastian McKenzie
d25944ea1f move utility transformers to top - fixes #1440 2015-05-05 08:39:46 +01:00
Sebastian McKenzie
fce2aa8fa3 add support for esquery 2015-05-05 03:21:31 +01:00
Sebastian McKenzie
0112c63779 consolidate the concept of "virtual types" 2015-05-05 02:33:49 +01:00
Sebastian McKenzie
6a4e93bf0f make visitor validation more anal, add node type wrappers, add mixin support to visitor explosion, allow visitor entrance/exit to provide an array of callbacks to use rather than limiting it to a single callback 2015-05-05 01:44:01 +01:00
Sebastian McKenzie
4328e920d2 5.2.12 2015-05-05 00:15:48 +01:00
Sebastian McKenzie
bbbf0a895d v5.2.12 2015-05-05 00:13:57 +01:00
Sebastian McKenzie
3289b33806 remove no self node replacement error 2015-05-05 00:13:07 +01:00
Sebastian McKenzie
f4b9faa6b3 clean up module declaration based UID generation - fixes #1437 2015-05-04 22:36:18 +01:00
Sebastian McKenzie
239b77816f 5.2.11 2015-05-04 22:33:26 +01:00
Sebastian McKenzie
8565e2b4e5 v5.2.11 2015-05-04 22:32:28 +01:00
Sebastian McKenzie
4317a46a3e add 5.2.11 changelog 2015-05-04 22:31:44 +01:00
Sebastian McKenzie
81ca29adc3 5.2.10 2015-05-04 22:31:38 +01:00
Sebastian McKenzie
c1a6ff7f44 rename getModuleName option to getModuleId 2015-05-04 22:31:34 +01:00
Sebastian McKenzie
7e6e5d4746 v5.2.10 2015-05-04 22:23:39 +01:00
Sebastian McKenzie
12d650e195 checkSelf() for destructuring catch clauses 2015-05-04 22:22:39 +01:00
Sebastian McKenzie
8fb58492df fix default specifiers not taking into consideration sourced imports 2015-05-04 22:20:52 +01:00
Sebastian McKenzie
2c0c2f12df avoid trying to replace a node with itself, antipattern! 2015-05-04 22:20:52 +01:00
Sebastian McKenzie
01e5354fd9 disallow replacing a node with itself 2015-05-04 22:20:52 +01:00
Sebastian McKenzie
0b100c4273 Merge pull request #1386 from jayphelps/module-id-overload
Added getModuleName() option as a function
2015-05-04 22:20:31 +01:00
Jay Phelps
340e75eb59 Added getModuleName() option as a function, allowing you to manipulate the name as needed 2015-05-04 13:30:57 -07:00
Sebastian McKenzie
53808a6d45 fix test/core/path imports 2015-05-04 15:25:35 +01:00
Sebastian McKenzie
e6326332b6 properly coerce input code to string - fixes #1432 2015-05-04 15:08:18 +01:00
Sebastian McKenzie
9e0cf84505 adds test for #1431 2015-05-04 15:06:27 +01:00
Sebastian McKenzie
b7eea7b08c Merge pull request #1431 from pangratz/fix_replaceWithSourceString
Fix bugs in `replaceWithSourceString`
2015-05-04 15:00:27 +01:00
pangratz
92dd67856e Fix bugs in replaceWithSourceString
This fixes 2 bugs within `replaceWithSourceString`:

- `code` is undefined as it should be `replacement`
- the expression of the parsed replacement hasn't been accessed correctly
2015-05-04 09:33:32 +02:00
Sebastian McKenzie
a2bb587e24 remove embedded jsx plugin and use acorn-jsx 2015-05-04 04:33:46 +01:00
Sebastian McKenzie
0c570cb599 5.2.9 2015-05-04 04:03:41 +01:00
Sebastian McKenzie
db6fab2c8f v5.2.9 2015-05-04 04:02:30 +01:00
Sebastian McKenzie
d92deb52b6 v5.2.8 2015-05-04 04:00:13 +01:00
Sebastian McKenzie
b8b70f2f4a rejigger around parse mechanics 2015-05-04 03:57:28 +01:00
Sebastian McKenzie
a8a3f6d34d Merge branch 'master' of github.com:babel/babel 2015-05-04 03:55:25 +01:00
Sebastian McKenzie
9847d226e1 add transform import - closes babel/babel-eslint#83 2015-05-04 03:54:58 +01:00
Sebastian McKenzie
3d48a16305 Merge pull request #1417 from loganfsmyth/fix-phantom-issue-1405
Explicitly sort instead of relying on key ordering.
2015-05-04 03:29:30 +01:00
Sebastian McKenzie
3d24cc9ae5 Merge pull request #1224 from jcoglan/fix-source-map-pathnames
Correct relative pathnames in source maps.
2015-05-04 00:03:27 +01:00
Sebastian McKenzie
5acc58dd68 5.2.7 2015-05-03 23:48:48 +01:00
Sebastian McKenzie
34f02f06a6 v5.2.7 2015-05-03 23:47:50 +01:00
Sebastian McKenzie
6d3fe5b85c add 5.2.7 changelog 2015-05-03 23:45:33 +01:00
Sebastian McKenzie
3878bd812c remove native super inheritance from classes - fixes #1424 2015-05-03 23:45:26 +01:00
Sebastian McKenzie
0717eaddce normalise Program replacement nodes 2015-05-03 23:35:39 +01:00
Sebastian McKenzie
102cbbe493 fix up crazy parse argument order 2015-05-03 23:31:37 +01:00
Sebastian McKenzie
d981b30194 clean up file transform pipeline 2015-05-03 23:26:37 +01:00
Sebastian McKenzie
0fc02f2cf0 add support for replacing nodes with expression source strings 2015-05-03 23:02:19 +01:00
Sebastian McKenzie
f24b5164d4 add extensions option to babel cli 2015-05-03 22:43:20 +01:00
Sebastian McKenzie
4be27ee72c update bin tests to reflect new helper format 2015-05-03 17:47:31 +01:00
Sebastian McKenzie
f0070e4828 ignore _generated FunctionDeclarations too in es6.spec.symbols transformer 2015-05-03 17:40:30 +01:00
Sebastian McKenzie
ce8beec22c update tests to reflect new helper format 2015-05-03 17:28:32 +01:00
Sebastian McKenzie
b30bdf2294 turn inserted helper declarations into function declarations if possible 2015-05-03 17:22:51 +01:00
Sebastian McKenzie
63b44a3e6e fix transformer and module formatter list in $ babel --help - fixes #1421 2015-05-02 23:16:37 +01:00
Logan Smyth
74aaf848ed Explicitly sort instead of relying on implementation-defined numeric key ordering - fixes #1405. 2015-05-01 20:00:22 -07:00
Sebastian McKenzie
95de5400e6 remove dead if statement explosion code - fixes #1413 2015-05-01 23:30:26 +01:00
Sebastian McKenzie
fe7079802b move deadCodeElimination transformer up - fixes #1409, fixes #1408 2015-05-01 23:24:16 +01:00
Sebastian McKenzie
61ddb14e25 Merge branch 'master' of github.com:babel/babel 2015-05-01 23:14:58 +01:00
Sebastian McKenzie
ca7a93cd64 move utility.deadCodeElimination transformer to minification 2015-05-01 23:13:48 +01:00
Sebastian McKenzie
90a1c81d30 split up es3.xLiterals transformers - fixes #1415 2015-05-01 23:13:30 +01:00
Sebastian McKenzie
5e9089d104 Merge pull request #1411 from hzoo/jshint-cleanup
remove old references to jshint
2015-05-01 22:45:15 +01:00
Henry Zhu
1a716943bc remove old references to jshint 2015-05-01 14:08:47 -04:00
Sebastian McKenzie
c28415c38a handle shorthand objects properly when renaming bindings, create new ones and refresh the stored binding identifier if necessary - fixes #1406 2015-05-01 15:23:46 +01:00
Sebastian McKenzie
e1491de6b8 5.2.6 2015-05-01 13:09:33 +01:00
Sebastian McKenzie
253ea8cd18 v5.2.6 2015-05-01 13:08:28 +01:00
Sebastian McKenzie
d37bad3149 add 5.2.6 changelog 2015-05-01 13:07:38 +01:00
Sebastian McKenzie
a2b912bc77 add BABEL mention to deprecation message 2015-05-01 13:07:31 +01:00
Sebastian McKenzie
f1bfbe44e2 expose Pipeline as TransformerPipeline 2015-05-01 13:00:34 +01:00
Sebastian McKenzie
dbdd07d0b8 fix addAliases call 2015-05-01 13:00:26 +01:00
Sebastian McKenzie
166909998e 5.2.5 2015-05-01 13:00:15 +01:00
Sebastian McKenzie
a8ec4c965c v5.2.5 2015-05-01 11:41:15 +01:00
Sebastian McKenzie
d2aff67c6c 5.2.4 2015-05-01 11:39:43 +01:00
Sebastian McKenzie
3353de225d fix parse API not adding all the correct pipeline transformers 2015-05-01 11:39:38 +01:00
Sebastian McKenzie
203ebeef20 v5.2.4 2015-05-01 11:29:06 +01:00
Sebastian McKenzie
032cf990c3 add 5.2.4 changelog 2015-05-01 11:28:24 +01:00
Sebastian McKenzie
16cdb43c67 expose transform pipeline and require node api inside of the browser one to avoid race conditions 2015-05-01 11:27:23 +01:00
Sebastian McKenzie
6f622033c5 5.2.3 2015-05-01 11:27:02 +01:00
Sebastian McKenzie
531d4f1937 v5.2.3 2015-05-01 09:42:23 +01:00
Sebastian McKenzie
f155bc249c fix Program global reference catching for real this time 2015-05-01 09:41:35 +01:00
Sebastian McKenzie
452d0ef30e fix Program global reference catching 2015-05-01 09:40:03 +01:00
Sebastian McKenzie
005754ba98 Revert "Revert "make dead code elimination smarter and eliminate non-referenced "pure" nodes""
This reverts commit c3c4cf17e3.
2015-05-01 09:39:33 +01:00
Sebastian McKenzie
c3c4cf17e3 Revert "make dead code elimination smarter and eliminate non-referenced "pure" nodes"
This reverts commit 4e87809ff9.
2015-05-01 09:39:07 +01:00
Sebastian McKenzie
0866e5a403 add 5.2.3 changelog 2015-05-01 09:36:48 +01:00
Sebastian McKenzie
15f5e658fc Merge branch 'master' of github.com:babel/babel 2015-05-01 09:32:28 +01:00
Sebastian McKenzie
574e6da132 add Statement and Declaration aliases to flow types - fixes #1401 2015-05-01 09:32:11 +01:00
Sebastian McKenzie
da6d27ed16 Merge pull request #1404 from timbur/master
hopefully fixes #1402
2015-05-01 09:31:46 +01:00
Sebastian McKenzie
4e87809ff9 make dead code elimination smarter and eliminate non-referenced "pure" nodes 2015-05-01 09:31:28 +01:00
Sebastian McKenzie
f4267aaab0 Merge pull request #1403 from wyand/master
fix spelling
2015-05-01 09:28:46 +01:00
Sebastian McKenzie
4f255d103a Merge pull request #1400 from monsanto/flow-object-commas
Support commas as object property separators in flow
2015-05-01 09:24:08 +01:00
Tim Burgess
502cc13aed hopefully fixes #1402 2015-05-01 04:05:22 -04:00
Dan Wyand
0a1154e6fd fix spelling 2015-05-01 01:01:10 -04:00
Christopher Monsanto
f5b3d72730 support commas as obj property separators in flow 2015-05-01 00:09:26 -04:00
Sebastian McKenzie
e9bcccffbd futz the bundler idea 2015-05-01 03:26:12 +01:00
Sebastian McKenzie
aaf4cbf06f start on babel module bundling and type inferrence 2015-05-01 02:59:59 +01:00
Sebastian McKenzie
5080534974 5.2.2 2015-05-01 00:44:48 +01:00
Sebastian McKenzie
02cb397873 v5.2.2 2015-05-01 00:43:39 +01:00
Sebastian McKenzie
d9169a87ad allow util.arrayify to take arbitrary types and coerce it into an array - #1398 2015-05-01 00:41:47 +01:00
Sebastian McKenzie
f3b6f2fc61 5.2.1 2015-05-01 00:41:24 +01:00
Sebastian McKenzie
04cc24ee82 v5.2.1 2015-05-01 00:30:42 +01:00
Sebastian McKenzie
f32079ef42 fix regression in node/register that caused node_modules to not be ignored - fixes #1398 2015-05-01 00:29:57 +01:00
Sebastian McKenzie
d1b69656ae update 5.2.0 changelog 2015-04-30 23:28:39 +01:00
Sebastian McKenzie
09453a490b 5.2.0 2015-04-30 23:27:37 +01:00
Sebastian McKenzie
e2e7627f0f v5.2.0 2015-04-30 23:15:06 +01:00
Sebastian McKenzie
4fe24a9a3b Merge pull request #1392 from jden/jden-patch-1
process glob matching in babel-cli (windows compat)
2015-04-30 23:10:24 +01:00
Sebastian McKenzie
d26e7ad577 fix no RHS in class properties causing undefined to be used instead of a noop - fixes #1396 2015-04-30 23:09:17 +01:00
Sebastian McKenzie
571cb4928f add register-without-polyfill option 2015-04-30 22:27:52 +01:00
Sebastian McKenzie
c12e8122f8 fix browser tests 2015-04-30 20:11:32 +01:00
Sebastian McKenzie
92e7a01d14 remove regenerator and test262 git submodule and tests - closes #1393 2015-04-30 20:03:34 +01:00
jden
b9ca9d42dc fix formatting per feedback from @sebmck
https://github.com/babel/babel/pull/1392#discussion-diff-29454022
2015-04-30 11:06:51 -07:00
jden
479c3e477a process glob matching in babel-cli (windows compat) 2015-04-30 10:57:48 -07:00
Sebastian McKenzie
2c3d3d8105 DRY up plugin manager position definition 2015-04-30 18:13:33 +01:00
Sebastian McKenzie
ea03f67505 use a strict regex when splitting string plugins - fixes #1361 2015-04-30 18:13:17 +01:00
Sebastian McKenzie
ee0c88a070 clean up plugin manager constructor and add some basic plugin manager tests 2015-04-30 18:06:15 +01:00
Sebastian McKenzie
98206df864 fix retainLines for comments and block statements - fixes #1388 2015-04-30 17:43:31 +01:00
Sebastian McKenzie
1066a42fb2 fix weird path context state by clearing the context before we visit it 2015-04-30 17:19:27 +01:00
Sebastian McKenzie
062175586c add parens around LHS object patterns 2015-04-30 17:18:36 +01:00
Sebastian McKenzie
0dc6b582a6 Merge pull request #1385 from monsanto/fix-var-checker
fix reference check for shorthand properties
2015-04-30 16:43:36 +01:00
Sebastian McKenzie
d8d70ba137 Merge pull request #1388 from amasad/master
Add failing test for printing block line comments with retainLines option
2015-04-30 16:42:55 +01:00
Sebastian McKenzie
f23c916520 make function name inferrence smarter - fixes #1367 2015-04-30 16:41:25 +01:00
Sebastian McKenzie
8ae4601177 rename insertOntoContainerStart to unshiftContainer 2015-04-30 14:33:54 +01:00
Sebastian McKenzie
9a466d3ef9 add optimisation.flow.forOf internal usage 2015-04-30 14:31:52 +01:00
Sebastian McKenzie
713845d14c add Terminatorless alias key for node expression wrappers that don't accept new lines 2015-04-30 13:56:42 +01:00
Sebastian McKenzie
471d60e5cd Merge branch 'master' of github.com:babel/babel 2015-04-30 13:53:58 +01:00
Sebastian McKenzie
43864e0686 Merge pull request #1390 from amasad/retainLines-return
Parenthesize statement argument when on a different line
2015-04-30 13:53:52 +01:00
Amjad Masad
4c2ae5dd19 Parenthesize statement argument when on a different line 2015-04-30 05:43:08 -07:00
Amjad Masad
a540cbe801 Failing test with return not on the same line as it's expression
Note that this is not a parenthesis issue but this was the easiest way
to reproduce it. I ran into it when testing generators with `retainLines`
and the generated `return` statement (replacing yeild) was printed on
the line preceding the expression being yielded.
2015-04-30 05:06:56 -07:00
Amjad Masad
34cc577fa2 Add failing test for printing block line comments with retainLines option 2015-04-30 04:37:45 -07:00
Sebastian McKenzie
c855b55133 add additional comment test to comment statement with retainlines option generation test 2015-04-29 23:58:36 +01:00
Sebastian McKenzie
16c86c25b7 properly catch up to comments position - fixes #1384 2015-04-29 23:57:43 +01:00
Sebastian McKenzie
4345f7945b Merge pull request #1377 from Mark-Simulacrum/issue-1376
Allow passing an array of globs to "only" option.
2015-04-29 23:39:17 +01:00
Christopher Monsanto
f44c93add2 fix reference check for shorthand properties 2015-04-29 17:56:36 -04:00
Sebastian McKenzie
09e45c51a4 Merge pull request #1384 from amasad/master
Add failing test for printing comments with retainLines option
2015-04-29 22:44:03 +01:00
Amjad Masad
1a42b72b15 Add failing test for printing comments with retainLines option 2015-04-29 14:40:23 -07:00
Sebastian McKenzie
d30415d74a update es6.spec.symbols instanceof test to reflect Function.prototype[@@hasInstance] being nonwritable #1364 2015-04-29 21:20:35 +01:00
Sebastian McKenzie
616ef8d840 make jscript transformer more trigger happy - #1382 2015-04-29 12:03:15 +01:00
Sebastian McKenzie
56437f94bc Merge pull request #1382 from kondi/jscript
add optional jscript transformer for basic IE8 compatibility (fixes #1369)
2015-04-29 11:59:32 +01:00
Pusztai Tibor
881fa6430b add optional jscript transformer for basic IE8 compatibility (fixes #1369) 2015-04-29 12:36:12 +02:00
Sebastian McKenzie
b7971690f3 add additional comments to path class, really need to go and fill in all the dummy jsdoc descriptions... 2015-04-29 01:19:56 +01:00
Sebastian McKenzie
c01d0abbd3 add insertOntoContainerStart and insertOntoContainerEnd methods 2015-04-29 01:13:35 +01:00
Sebastian McKenzie
7043119346 fix PluginManager 2015-04-29 01:13:23 +01:00
Mark-Simulacrum
b5325df57f Allow passing an array of globs to "only" option. 2015-04-28 17:59:20 -06:00
Sebastian McKenzie
0fc958e0fc remove useless force parameter in Buffer#_newline 2015-04-29 00:22:10 +01:00
Sebastian McKenzie
9cb16711dd abstract plugin initialisation to a plugin manager 2015-04-29 00:20:49 +01:00
Sebastian McKenzie
04766b13f5 add retainLines code generator option 2015-04-29 00:20:35 +01:00
Sebastian McKenzie
433d704739 add null check to interop-require-wildcard helper 2015-04-28 16:56:57 +01:00
Sebastian McKenzie
30204d2ee6 disable sudo travis config option, it breaks the build since it's using a cached node_modules which has old major versions of dependencies, ugh 2015-04-28 16:31:00 +01:00
Sebastian McKenzie
374b7cca2c update interop-require-wildcard helper 2015-04-28 15:58:37 +01:00
Sebastian McKenzie
152ae388f0 remove excessive newline 2015-04-28 15:32:16 +01:00
Sebastian McKenzie
04344026bb remove typeof object check for interop-require-wildcard helper 2015-04-28 15:32:09 +01:00
Sebastian McKenzie
cfffaf6cdb upgrade to babel 5 2015-04-28 14:55:28 +01:00
Sebastian McKenzie
2952d94e60 wrap instanceof to support @@hasInstance - fixes #1364 2015-04-28 14:27:30 +01:00
Sebastian McKenzie
0276c3ae81 visit decorators key for ClassProperty nodes 2015-04-28 00:05:10 +01:00
Sebastian McKenzie
c00f8dce3f add make build to makefile and elaborate on build steps in CONTRIBUTING - #1357. 2015-04-27 03:16:39 +01:00
Sebastian McKenzie
4e24ae39cf Merge branch 'master' of github.com:babel/babel 2015-04-27 03:06:23 +01:00
Sebastian McKenzie
12bd6494b7 use class ref instead of class name when adding class super native constructor call - fixes #1358 2015-04-27 03:06:13 +01:00
Sebastian McKenzie
e35c7550fe Merge pull request #1356 from monsanto/clean-build
remove lib/ before building
2015-04-27 02:32:53 +01:00
Christopher Monsanto
e7046abe72 remove lib/ before building 2015-04-26 21:12:50 -04:00
Sebastian McKenzie
affa7f0c6f Merge pull request #1352 from monsanto/descriptor-initalizer
call descriptor.initializer with `target` as `this`
2015-04-26 21:17:50 +01:00
Sebastian McKenzie
be650ffc61 call decorator initializers with the proper context - #1350 - thanks @monsanto 2015-04-26 21:17:15 +01:00
Sebastian McKenzie
3078d48178 don't rely on sequence expressions for <= 1 sequence expressions in blockScoping transformer 2015-04-26 21:15:30 +01:00
Sebastian McKenzie
0be93563dd fix spec.blockScopedFunctions shouldVisit method 2015-04-26 21:15:08 +01:00
Christopher Monsanto
3e55980145 call descriptor.initializer with target as this 2015-04-26 16:11:11 -04:00
Sebastian McKenzie
470ebf3a46 various random optimisations 2015-04-26 21:04:06 +01:00
Sebastian McKenzie
b695369126 add babel brand to code gen deopt message 2015-04-26 21:03:54 +01:00
Sebastian McKenzie
f4611469b4 remove declarations transformer and instead do it whenever we push a generated declaration, better for perf and removes shitty bugs - fixes #1268 2015-04-26 15:46:06 +01:00
Sebastian McKenzie
68bfafe745 add missing ast-types definitions 2015-04-26 05:26:29 +01:00
Sebastian McKenzie
f72782b71c remove transformer prepass and various other optimisations 2015-04-26 05:26:21 +01:00
Sebastian McKenzie
0f1f5e3565 implement path-specific transformer skipping via the starting prepass 2015-04-26 02:42:15 +01:00
Sebastian McKenzie
dfe126f3d4 verify traversal visitors 2015-04-25 22:49:54 +01:00
Sebastian McKenzie
4c9cb957a9 5.1.13 2015-04-25 22:46:01 +01:00
Sebastian McKenzie
8f997f8825 v5.1.13 2015-04-25 18:32:53 +01:00
Sebastian McKenzie
d789a6e7aa remove symbol check from defineProperty helper #1348 2015-04-25 18:31:29 +01:00
Sebastian McKenzie
4007148d9f 5.1.12 2015-04-25 18:23:16 +01:00
Sebastian McKenzie
998f1d544e v5.1.12 2015-04-25 18:21:37 +01:00
Sebastian McKenzie
deed48a3db fix decorator interop - fixes #1277 2015-04-25 18:18:30 +01:00
Sebastian McKenzie
00c0a958db fix runtime tests to reflect core-js 0.9.0 2015-04-25 18:08:00 +01:00
Sebastian McKenzie
1511dcbd73 resolveModuleSource on ExportAllDeclarations - fixes #1342 2015-04-25 17:47:44 +01:00
Sebastian McKenzie
12fef25803 update to core-js 0.9.0 - closes #1348 2015-04-25 17:40:59 +01:00
Sebastian McKenzie
fd30eb1839 Merge branch 'master' of github.com:babel/babel 2015-04-24 19:28:58 +01:00
Sebastian McKenzie
63344eb0a4 only skip traversal of immutable JSX elements in the optimisation.react.constantElements transformer when we've actually hoisted them - closes #1344 2015-04-24 19:28:51 +01:00
Sebastian McKenzie
6e4e11a365 fix JSX literal children not being output correctly 2015-04-24 19:28:17 +01:00
Sebastian McKenzie
e330efe058 Merge pull request #1343 from isojs/fix-ignore-only-windows
Fix ignore/only on Windows
2015-04-24 15:21:33 +01:00
Sebastian McKenzie
ce86eca8b0 Merge pull request #1335 from lukescott/fix-resolve-rc
Fix resolve rc loading options twice
2015-04-24 15:21:18 +01:00
Luke Scott
03dbaa3e0e fix resolve-rc loading options twice - fixes #1329 2015-04-24 07:13:26 -07:00
George Stagas
2bd35fac6e normalize filename slashes for shouldIgnore 2015-04-24 16:58:52 +03:00
Sebastian McKenzie
cdca4e50d9 Merge pull request #1333 from isojs/fix-rimraf-tmp
Fix test temporary dir cleanup
2015-04-24 11:31:09 +01:00
Sebastian McKenzie
bb041c1bd6 Merge pull request #1330 from joemcbride/master
Bump convert-source-map version.
2015-04-24 11:30:47 +01:00
Sebastian McKenzie
a36c1b4a92 rewrite this in shadowed functions inside native derived class constructors - fixes #1340 2015-04-24 11:20:29 +01:00
George Stagas
b760daca21 fix test tmp dir cleanup 2015-04-23 21:27:14 +03:00
Joe McBride
ff63d8f60c Bump convert-source-map version.
Relates to #1014
2015-04-23 09:29:19 -07:00
Sebastian McKenzie
74f04ed6a1 clean up interop require 2015-04-22 00:14:55 +01:00
Sebastian McKenzie
74d880bf18 Merge pull request #1317 from jeffmo/copy_static_props_on_foreign_export_objs
Copy statics from foreign exports objects when doing an ES6 import
2015-04-21 22:44:52 +01:00
jeffmo
5ce38cacaa Copy statics off of foreign exports objects when doing an ES6 import 2015-04-21 12:17:43 -04:00
Sebastian McKenzie
829f642ad8 fix spread properties in assignment position - fixes #1315 2015-04-21 16:24:34 +01:00
Sebastian McKenzie
80a4b95da4 fix incorrect externalHelpers option definition - fixes #1307 2015-04-21 16:16:07 +01:00
Sebastian McKenzie
dc2a20dbcd Merge branch 'master' of github.com:babel/babel 2015-04-21 16:14:49 +01:00
Sebastian McKenzie
f6278e43ce properly handle shorthand JSX attributes in optimisation.react.inlineElements transformer - fixes #1309 2015-04-21 16:14:36 +01:00
Sebastian McKenzie
30bc80000b Merge pull request #1311 from jquense/fix-plugin-position
Fixes bug where position was never set
2015-04-20 17:37:45 +01:00
jquense
ef56042c93 Fixes bug where position was never set
The mallet operator was compiling to `if (!position) position =
name.position`. Since position is set earlier the conditional was always
true and position was never updated from the plugin object.
2015-04-20 12:34:39 -04:00
Sebastian McKenzie
b6498103db 5.1.11 2015-04-20 06:26:23 +01:00
Sebastian McKenzie
7af4302d07 v5.1.11 2015-04-20 06:25:37 +01:00
Sebastian McKenzie
543770960c update 5.1.11 changelog 2015-04-20 06:24:30 +01:00
Sebastian McKenzie
a2975a72cc add 5.1.11 changelog 2015-04-20 06:23:53 +01:00
Sebastian McKenzie
beb3fd51d8 clean up CONTRIBUTING TOC 2015-04-20 06:16:33 +01:00
Sebastian McKenzie
9360860601 memoise and bind member expression decorators - fixes #1296 2015-04-20 06:16:20 +01:00
Sebastian McKenzie
7d4ecea8fb move react children coercion to opening element visitor - fixes #1276 2015-04-20 05:49:59 +01:00
Sebastian McKenzie
a44831b3fa Merge pull request #1285 from bucaran/contributing-doc-deps
Improve formatting and add rundown of deps with links
2015-04-20 00:24:30 +01:00
Sebastian McKenzie
8357f3900f Merge pull request #1282 from bcamper/vanilla-generator-runtime
Use vanilla regenerator when building runtime
2015-04-20 00:23:14 +01:00
Sebastian McKenzie
6b1c5bc358 remove interop require on bluebird - fixes #1289 2015-04-20 00:22:41 +01:00
Sebastian McKenzie
3564309a77 allow plugins to be specified as an object with transformer and position - fixes #1300 2015-04-20 00:05:06 +01:00
Sebastian McKenzie
c9518bb60d consider switches to be a valid scope - fixes #1297 2015-04-19 21:45:43 +01:00
Sebastian McKenzie
0f1215e33e add title to logging - fixes #1292 2015-04-19 16:06:58 +01:00
Sebastian McKenzie
d7b0b5bec0 add space to do-while code gen - fixes #1290 2015-04-17 17:35:36 -07:00
Jorge
3e5af404ab improve formatting and add rundown of deps with links 2015-04-17 15:15:03 +09:00
Sebastian McKenzie
1818094577 validate this before super on exit, not enter - fixes #1284 2015-04-16 22:04:18 -07:00
Brett Camper
6d712b3d14 use vanilla regenerator when building runtime
see #1015
2015-04-16 15:17:58 -04:00
Sebastian McKenzie
11389fe165 add 5.1.10 changelog 2015-04-15 16:12:56 -07:00
Sebastian McKenzie
0ee9531db3 5.1.10 2015-04-15 15:24:49 -07:00
Sebastian McKenzie
1622d2498d v5.1.10 2015-04-15 15:24:00 -07:00
Sebastian McKenzie
b76e6f8e5b disable ludicrous tests 2015-04-15 15:23:14 -07:00
Sebastian McKenzie
beac006832 remove regenerator from bootstrap 2015-04-15 15:22:09 -07:00
Sebastian McKenzie
20d7603c0b remove redundant replaceExpressionWithStatements for statement or block nodes - fixes #1265 2015-04-15 15:16:34 -07:00
Sebastian McKenzie
24b13c5e49 remove unnecessary csp makePredicate - fixes #1267 2015-04-15 15:13:12 -07:00
Sebastian McKenzie
9e21074e88 remove regenerator tests 2015-04-15 15:05:30 -07:00
Sebastian McKenzie
9a825bced7 remove runtime compatibility check - closes #1266 2015-04-15 15:03:45 -07:00
Sebastian McKenzie
fcb78436c6 move es6.proxies to ludicrous 2015-04-15 14:59:37 -07:00
Sebastian McKenzie
bb30a64f8d add extra transform option 2015-04-15 14:59:26 -07:00
Sebastian McKenzie
b483c16fe2 Merge branch 'proxies'
# Conflicts:
#	src/babel/transformation/file/index.js
2015-04-15 13:32:28 -07:00
Sebastian McKenzie
569f046045 5.1.9 2015-04-14 08:32:47 -07:00
Sebastian McKenzie
4e969d3d92 v5.1.9 2015-04-14 08:30:54 -07:00
Sebastian McKenzie
0bca1de285 add 5.1.9 changelog 2015-04-14 08:29:31 -07:00
Sebastian McKenzie
3a5bd06a7e fix proeprty method assignment wrapper generator template 2015-04-14 08:28:02 -07:00
Sebastian McKenzie
66a908aaa7 Mark function token as able to start an expression 2015-04-14 08:18:06 -07:00
Sebastian McKenzie
cd0ed08237 Revert "delegate to babel-cli/babel-core if it's available #1244"
This reverts commit dd84b554e6.
2015-04-14 08:02:02 -07:00
Sebastian McKenzie
dd84b554e6 delegate to babel-cli/babel-core if it's available #1244 2015-04-14 07:53:29 -07:00
Sebastian McKenzie
b51411f090 Merge branch 'master' of github.com:babel/babel 2015-04-14 07:39:52 -07:00
Sebastian McKenzie
4cc843ded3 set hoisted to true for react constant elements optimisation 2015-04-14 07:39:44 -07:00
Sebastian McKenzie
47d253c732 set passModuleArg when handling default export specifiers in amd module formatter - fixes #1260 2015-04-14 07:39:34 -07:00
Sebastian McKenzie
09901274ab Merge pull request #1257 from zloirock/master
Update NATIVE_TYPE_NAMES
2015-04-14 07:28:00 -07:00
rock
35196e20c7 Update NATIVE_TYPE_NAMES 2015-04-14 18:24:13 +06:00
Sebastian McKenzie
35af771a29 Merge branch 'master' of github.com:babel/babel 2015-04-13 21:57:04 -07:00
Sebastian McKenzie
dee80caa09 move export reassignment to exit handler - fixes #1255 2015-04-13 21:56:55 -07:00
Sebastian McKenzie
46b7cc0a72 assorted minor cleanup of variables 2015-04-13 21:56:37 -07:00
Sebastian McKenzie
3b189e22b7 Merge pull request #1256 from jayphelps/fix-writable
class properties with an undefined value are now correctly writable
2015-04-13 21:52:46 -07:00
Jay Phelps
6ca565d7fb class properties with an undefined value are now correctly writable 2015-04-13 20:53:05 -07:00
Sebastian McKenzie
64f5480f96 fix pattern LHS error messages 2015-04-13 16:45:30 -07:00
Sebastian McKenzie
828fdc8769 make illegal LHS pattern error messages more user friendly 2015-04-13 16:40:13 -07:00
Sebastian McKenzie
6763c4415e make parenthesized array patterns illegal - cc @michaelficarra 2015-04-13 16:16:57 -07:00
Sebastian McKenzie
fb30e79e03 5.1.8 2015-04-13 15:46:45 -07:00
Sebastian McKenzie
85fb4304b0 v5.1.8 2015-04-13 15:45:46 -07:00
Sebastian McKenzie
c2da77d7ec only make parenthesized object patterns illegal - fixes #1254, ref jshint/jshint#2269 2015-04-13 15:44:54 -07:00
Sebastian McKenzie
c54c3d3c15 5.1.7 2015-04-13 15:44:02 -07:00
Sebastian McKenzie
2a7c954155 v5.1.7 2015-04-13 14:59:56 -07:00
Sebastian McKenzie
3fb7f7c7cc add 5.1.6-5.1.7 changelog 2015-04-13 14:56:33 -07:00
Sebastian McKenzie
c4b2818336 remove useless kind on import declarations 2015-04-13 14:55:46 -07:00
Sebastian McKenzie
061561bfd8 add proper ecmaVersion and sourceType to parse api 2015-04-13 14:55:37 -07:00
Sebastian McKenzie
d4944d606b 5.1.6 2015-04-13 14:29:21 -07:00
Sebastian McKenzie
736b689c3b v5.1.6 2015-04-13 14:27:09 -07:00
Sebastian McKenzie
e12b377014 don't fall back to runtime catch all on locally declared variables 2015-04-13 14:26:06 -07:00
Sebastian McKenzie
5fd5b815ab fix whitespace in resolveRc 2015-04-13 14:25:47 -07:00
Sebastian McKenzie
92db8312f6 add parse api 2015-04-13 14:25:37 -07:00
James Coglan
1f2f4ce4f3 Correct relative pathnames in source maps.
Say you have a file called `src/thing.js` and you run

    $ babel src/thing.js --out-file lib/thing.js --source-maps true

This generates a source map at `lib/thing.js.map` that contains
"src/thing.js" in its `sources` array. This is incorrect; since browsers
resolve all relative URLs relative to the directory containing the file
that refers to the URL, this resolves to `lib/src/thing.js`.

To make the source map refer to the source files correctly, the
`sources` array should contain "../src/thing.js".
2015-04-13 21:17:11 +01:00
Sebastian McKenzie
e080fe547d 5.1.5 2015-04-13 11:59:47 -07:00
Sebastian McKenzie
b967ecf063 v5.1.5 2015-04-13 11:58:58 -07:00
Sebastian McKenzie
365b7285d2 bump core-js version 2015-04-13 11:58:09 -07:00
Sebastian McKenzie
a40d532b0e 5.1.4 2015-04-13 09:38:21 -07:00
Sebastian McKenzie
0487bf911d v5.1.4 2015-04-13 09:36:21 -07:00
Sebastian McKenzie
57c72d1cd0 fix syntax error in runtime definitions 2015-04-13 09:35:35 -07:00
Sebastian McKenzie
335bdffec2 add missing Reflect methods to runtime transformer #1248 2015-04-13 09:34:45 -07:00
Sebastian McKenzie
e1d76a1dfe 5.1.3 2015-04-13 09:25:37 -07:00
Sebastian McKenzie
a4845323a2 v5.1.3 2015-04-13 09:24:00 -07:00
Sebastian McKenzie
792951b489 add 5.1.3 changelog 2015-04-13 09:23:12 -07:00
Sebastian McKenzie
5adda836af don't do TCO on generators and async functions - fixes #1251 2015-04-13 09:21:59 -07:00
Sebastian McKenzie
4c2c3098c3 Merge branch 'master' of github.com:babel/babel 2015-04-13 09:20:36 -07:00
Sebastian McKenzie
087c714098 simplify runtime transformer traversal and add a catch-all - fixes #1248 2015-04-13 09:20:28 -07:00
Sebastian McKenzie
5a33e4fe05 Merge pull request #1245 from deepsweet/travis-cache
let Travis cache node_modules
2015-04-13 08:29:59 -07:00
Sebastian McKenzie
5f8667eaa7 make parsing of decorators stateless - fixes shuhei/babel-angular2-app#4 2015-04-13 08:26:51 -07:00
Sebastian McKenzie
31b4468514 switch to vanilla regenerator - closes #1247, closes #1123 2015-04-13 08:08:00 -07:00
Kir Belevich
2be9678bbe let Travis cache node_modules 2015-04-13 17:54:50 +07:00
Sebastian McKenzie
b5210877cf 5.1.2 2015-04-13 00:54:00 -07:00
Sebastian McKenzie
658dde768e v5.1.2 2015-04-13 00:52:43 -07:00
Sebastian McKenzie
8df1d81ca4 fix iterable runtime name 2015-04-13 00:51:50 -07:00
Sebastian McKenzie
a505e4a121 aAdd getIterator and isIterable to babel-runtime build script - fixes #1243 2015-04-13 00:48:19 -07:00
Sebastian McKenzie
71eafdcac7 5.1.1 2015-04-13 00:14:47 -07:00
Sebastian McKenzie
65060b0c97 v5.1.1 2015-04-13 00:13:52 -07:00
Sebastian McKenzie
09883962f1 add item to 5.1.0 changelog 2015-04-13 00:13:05 -07:00
Sebastian McKenzie
1583262807 add missing runtime symbol definitions - fixes #1242 2015-04-13 00:12:59 -07:00
Sebastian McKenzie
04c7cd5c0c add note to 5.1.0 changelog 2015-04-12 21:29:29 -07:00
Sebastian McKenzie
3f6969f4f8 5.1.0 2015-04-12 21:23:21 -07:00
Sebastian McKenzie
23db842cb8 v5.1.0 2015-04-12 21:22:25 -07:00
Sebastian McKenzie
41c82e00f9 add 5.1.0 changelog 2015-04-12 21:21:35 -07:00
Sebastian McKenzie
766099e783 5.0.13 2015-04-12 21:21:31 -07:00
Sebastian McKenzie
53bc54b3b2 v5.0.13 2015-04-12 21:14:12 -07:00
Sebastian McKenzie
bb70f37123 Merge branch 'master' of github.com:babel/babel 2015-04-12 20:59:26 -07:00
Sebastian McKenzie
8a0317132e deopt array unpack optimisation on member expressions - fixes #1241 2015-04-12 20:59:17 -07:00
Sebastian McKenzie
f598c70841 Merge pull request #1215 from AluisioASG/es7-trailing-function-commas
ES7 trailing function commas
2015-04-12 19:17:02 -07:00
Sebastian McKenzie
61b57ea055 rejigger decorator alias 2015-04-12 19:10:22 -07:00
Sebastian McKenzie
a971ad7fd2 Merge branch 'master' of github.com:babel/babel 2015-04-12 19:07:19 -07:00
Sebastian McKenzie
27b6f804ce clean up class decorators #1185 2015-04-12 19:06:59 -07:00
Sebastian McKenzie
8ab79f3a72 Merge pull request #1240 from JaRail/master
Fix broken dead-code-removal case.
2015-04-12 18:58:45 -07:00
James Railton
0c2bf2f5a2 Fix broken dead-code-removal case.
The "test" local variable was removed with path work. The last dead-code-removal check used this var. By reintroducing the local var, the unknown variable reference is fixed.
2015-04-12 18:52:37 -07:00
Sebastian McKenzie
7e1a4be085 add use strict header to decorators test 2015-04-12 09:09:26 -07:00
Sebastian McKenzie
bbc951dfe1 fix decorators order - thanks to some random japanese tweet i translated... 2015-04-12 09:05:46 -07:00
Sebastian McKenzie
b3e4aefe12 update runtime transformer to not use $for module - cc @zloirock 2015-04-12 09:00:32 -07:00
Sebastian McKenzie
26b5174dfa add descriptor for all class properties - fixes #1235 2015-04-12 08:53:01 -07:00
Sebastian McKenzie
652d3c7320 move eval and arguments identifier handling to nameMethod helper 2015-04-11 20:51:01 -07:00
Sebastian McKenzie
edc2cd320c don't consider eval and arguments valid identifiers - fixes #1232 2015-04-11 20:45:44 -07:00
Sebastian McKenzie
274a6e01dc add support for inheriting from statically inlined native constructors - closes #1172 2015-04-11 19:47:11 -07:00
Sebastian McKenzie
3561efdb86 update runtime transformer to modular core-js - fixes #1206 2015-04-11 19:07:39 -07:00
Sebastian McKenzie
1a30f1aafc fix regression with completion records for assignment expressions - fixes #1204 2015-04-11 18:13:47 -07:00
Sebastian McKenzie
e362512af3 switch to my branch of regenerator - #1123, fixes #1015 2015-04-11 17:59:14 -07:00
Sebastian McKenzie
cf5d2429b4 add support for replacement of for inits with statements - fixes #1217 2015-04-11 17:40:12 -07:00
Sebastian McKenzie
72098036b2 remove useless this from lodash map 2015-04-11 17:39:50 -07:00
Sebastian McKenzie
7905f48280 clean up dynamic imports, disable hoisting in system module formatter when **any** dynamic imports are included - fixes #1219 2015-04-11 17:22:48 -07:00
Sebastian McKenzie
aba2d1c23c fix loop constants test error message 2015-04-11 16:50:08 -07:00
Sebastian McKenzie
5326e0543d fix scope tracking for constants in loop heads - fixes #1229 2015-04-11 16:39:18 -07:00
Sebastian McKenzie
1360c93e4b fix enumerable property position in test 2015-04-11 16:35:19 -07:00
Sebastian McKenzie
235cbc18cf Merge branch 'master' of github.com:babel/babel 2015-04-11 16:31:11 -07:00
Sebastian McKenzie
98c5255b91 add support for object literal decorators - fixes #1154 2015-04-11 16:30:55 -07:00
Sebastian McKenzie
2a9777cc20 add solo helpers
# Conflicts:
#	src/babel/transformation/file/index.js
2015-04-11 14:33:56 -07:00
Sebastian McKenzie
a8702be756 add solo helpers 2015-04-11 14:33:04 -07:00
Sebastian McKenzie
0995cc3f4e add proxies 2015-04-11 14:32:52 -07:00
Sebastian McKenzie
1cfca745a4 Merge pull request #1228 from Hermanya/patch-1
Update README.md
2015-04-11 08:52:30 -07:00
Herman Starikov
a3459deecf Update README.md 2015-04-11 11:52:01 -04:00
Sebastian McKenzie
070152f6c1 parse await expression as a unary instead of an assignment - fixes #1225 2015-04-10 15:23:11 -07:00
Sebastian McKenzie
719fdf5ca1 set canBeArrow to true when parsing async functions 2015-04-10 13:51:30 -07:00
Sebastian McKenzie
f2460c6173 update to latest acorn 2015-04-10 13:44:50 -07:00
Sebastian McKenzie
155c640409 remove null regex check - fixes #1222 2015-04-10 13:44:41 -07:00
Sebastian McKenzie
7de4718b27 Merge branch 'master' of github.com:babel/babel 2015-04-09 14:58:41 -07:00
Sebastian McKenzie
4e6aed0408 don't shadow default parameter scope iife and instead just apply the this and arguments - fixes #1128 2015-04-09 14:58:33 -07:00
Brian Donovan
3be8ccf68d Prevent this command from failing during CI. 2015-04-09 14:49:45 -07:00
Sebastian McKenzie
704b31f44f use path basename as non-default import fallback - fixes #1207 2015-04-09 14:36:00 -07:00
Sebastian McKenzie
1a9f193841 Merge pull request #1216 from leebyron/update-deps
Update package dependencies
2015-04-09 13:50:23 -07:00
Lee Byron
7ff67589a7 Update package dependencies
Babel currently relies on some older versions of some dependencies. When using babel alongside other projects which use similar dependencies, this can cause npm to install multiple versions of these or to result in Babel loading a version of a dependency it doesn't claim to support.

This was mostly clean, though esutils did have a minor API change.
2015-04-09 13:38:20 -07:00
Brian Donovan
80f109efeb Ensure arrow function bodies are wrapped in parens if needed.
Closes #1214.
2015-04-09 11:50:52 -07:00
Brian Donovan
77c72bb5a6 Unlink global babel before bootstrapping to make it idempotent. 2015-04-09 09:55:48 -07:00
Aluísio Augusto Silva Gonçalves
6c5e0e6590 Add Acorn tests for trailing function commas 2015-04-09 13:35:48 -03:00
Sebastian McKenzie
83324b977d Merge branch 'master' of github.com:babel/babel
# Conflicts:
#	packages/babel-cli/package.json
2015-04-09 06:46:26 -07:00
Sebastian McKenzie
5feab11d3f Merge pull request #1212 from paulmillr/patch-2
Update to stable chokidar.
2015-04-09 06:45:58 -07:00
Sebastian McKenzie
7b4172ce7b remove chokidar from root package.json 2015-04-09 06:45:48 -07:00
Paul Miller
84439384c0 Update to stable chokidar. 2015-04-09 16:45:30 +03:00
Sebastian McKenzie
c9e7c306cc don't emit tokens when doing a lookahead 2015-04-09 06:44:16 -07:00
Sebastian McKenzie
1e398e45ff 5.0.12 2015-04-09 06:44:06 -07:00
Sebastian McKenzie
475324c4b5 Update to stable chokidar. 2015-04-09 06:43:58 -07:00
Sebastian McKenzie
407daf4bac Merge pull request #1205 from suryagaddipati/patch-1
Fix typo
2015-04-08 16:00:32 -07:00
Surya Gaddipati
4155590cd8 Fix typo 2015-04-08 18:00:03 -05:00
Sebastian McKenzie
0be6fd7abe Merge pull request #1203 from sindresorhus/modularize-userhome
modularize `user-home`
2015-04-08 09:49:03 -07:00
Sindre Sorhus
cf51bf1395 modularize user-home
No reason Babel should have to care about the intricacies of this.

This module is already used by `bower`, `eslint`, `yo`, etc.
2015-04-08 22:59:16 +07:00
Sebastian McKenzie
06a31c419a v5.0.12 2015-04-08 08:55:02 -07:00
Sebastian McKenzie
da566110c0 add 5.0.12 changelog 2015-04-08 08:53:40 -07:00
Sebastian McKenzie
c12c4a5c39 don't touch function name containers when remapping modules - fixes #1160 2015-04-08 08:52:53 -07:00
Sebastian McKenzie
d114349890 5.0.11 2015-04-08 08:15:15 -07:00
Sebastian McKenzie
8d6ae0e1eb v5.0.11 2015-04-08 08:14:28 -07:00
Sebastian McKenzie
cb8b47ee2f add missing curly brace to regression test 2015-04-08 08:13:33 -07:00
Sebastian McKenzie
daf24c5c59 add 5.0.10 changelog 2015-04-08 08:12:33 -07:00
Sebastian McKenzie
cdb2784e75 add #1199 regression test 2015-04-08 08:11:01 -07:00
Sebastian McKenzie
93feabb82e fix forOf loop inheritance - fixes #1169 2015-04-08 08:10:53 -07:00
Sebastian McKenzie
982c142bf6 Merge branch 'master' of github.com:babel/babel 2015-04-08 07:47:52 -07:00
Sebastian McKenzie
de5520a94f disable scope caching 2015-04-08 07:42:04 -07:00
Sebastian McKenzie
c239d06f10 fix MetaProperty generation 2015-04-08 07:41:56 -07:00
Lukáš Mladý
6491018c21 Add failing tests that document ES 6 generators bug 2015-04-08 14:14:45 +02:00
Sebastian McKenzie
a5fed376d8 Merge pull request #1191 from zertosh/babelrc-comments
Strip out comments before parsing babelrc
2015-04-07 18:09:07 -07:00
Sebastian McKenzie
e99fd77d89 downgrade and fix mocha version - fixes #1196 2015-04-07 18:07:23 -07:00
Sebastian McKenzie
1374863b9c 5.0.10 2015-04-07 18:06:52 -07:00
Andres Suarez
e88c28f88b Strip out comments before parsing babelrc 2015-04-07 18:50:01 -04:00
Sebastian McKenzie
7a0fd26f56 v5.0.10 2015-04-07 13:04:25 -07:00
Sebastian McKenzie
17583e4807 fix decrators modules test 2015-04-07 13:03:41 -07:00
Sebastian McKenzie
37dd5137ff don't modules reassign _ignoreModulesRemap assignments 2015-04-07 13:02:28 -07:00
Sebastian McKenzie
24fced406e Merge branch 'master' of github.com:babel/babel 2015-04-07 09:55:11 -07:00
Sebastian McKenzie
0ab1362893 don't reassign decorated classes - fixes #1167 2015-04-07 09:54:14 -07:00
Sebastian McKenzie
96506f4249 5.0.9 2015-04-07 09:20:40 -07:00
Sebastian McKenzie
ed747f88bd Merge pull request #1185 from Dignifiedquire/class-decorators-scope
Take 2: Fix class decorator scoping.
2015-04-07 08:49:56 -07:00
dignifiedquire
3987545b4f Ensure correct scope for decorated classes. 2015-04-07 14:57:15 +02:00
dignifiedquire
148aa3f96d Use a functionExpression with class decorators. Fixes #1161. 2015-04-07 14:16:48 +02:00
Sebastian McKenzie
0cb5a7c91e Revert "Use a functionExpression with class decorators. Fixes #1161."
This reverts commit f8d56d9612.
2015-04-07 04:40:39 -07:00
Sebastian McKenzie
fc34d5a9b0 Merge pull request #1184 from Dignifiedquire/class-decorators
Use a functionExpression with class decorators. Fixes #1161.
2015-04-07 03:39:59 -07:00
dignifiedquire
f8d56d9612 Use a functionExpression with class decorators. Fixes #1161. 2015-04-07 12:11:49 +02:00
Brian Donovan
737be0e95e Merge pull request #1173 from alawatthe/patch-1
Fixed path for mocha tests in CONTRIBUTING.md
2015-04-06 09:56:31 -07:00
Alexander Zeilmann
26e2b392e8 Fixed path for mocha tests 2015-04-06 18:38:33 +02:00
Sebastian McKenzie
708cdfb993 v5.0.9 2015-04-06 06:28:58 -07:00
Sebastian McKenzie
8cb3aabefa add 5.0.9 changelog 2015-04-06 06:26:11 -07:00
Sebastian McKenzie
4a87b35d20 fix function name self referencing test 2015-04-06 06:23:46 -07:00
Sebastian McKenzie
543554b258 flow tests style nit 2015-04-06 06:20:09 -07:00
Sebastian McKenzie
afd95cf663 add #1168 regression test 2015-04-06 06:20:05 -07:00
Sebastian McKenzie
87ce4b9cd8 fix order of parameter type annotation parsing - fixes #1168 2015-04-06 06:19:13 -07:00
Sebastian McKenzie
6b76f26ed8 use module id if available for umd global name - fixes #1166 2015-04-06 06:14:09 -07:00
Sebastian McKenzie
c2776e63ae rename umd module variable name - fixes #1166 2015-04-06 06:13:43 -07:00
Sebastian McKenzie
3f2fe363d1 Merge pull request #1163 from chocolateboy/babel_node_print_fix
babel-node --print: don't mangle percent characters (%)
2015-04-06 06:06:21 -07:00
Sebastian McKenzie
8de28098f4 Merge pull request #1170 from alawatthe/master
Replaced FUNCTION_ID by FUNCTION_KEY - fixes #1164
2015-04-06 06:02:49 -07:00
Aluísio Augusto Silva Gonçalves
584532cc2c [ES7] Trailing comma in function parameter list
Currenly a stage 1 proposal.
See https://github.com/jeffmo/es-trailing-function-commas.
2015-04-06 09:10:44 -03:00
alawatthe
9a28f3fdb1 Replaced FUNCTION_ID by FUNCTION_KEY - fixes #1164 2015-04-06 10:53:41 +02:00
chocolateboy
88941b3270 babel-node --print: don't mangle percent characters (%)
This applies the babel fix in #528 to babel-node.

before:

    $ babel-node --print --eval '"%%"'
    '%'

after:

    $ babel-node --print --eval '"%%"'
    '%%'
2015-04-05 06:26:29 +01:00
Sebastian McKenzie
3a768db2bf fix missing this in acorn parseExprAtom 2015-04-05 03:26:41 +10:00
Sebastian McKenzie
320a39f4c4 fix computed properties in es7 object rest/spread - thanks @AluisioASG! 2015-04-05 02:52:14 +10:00
Sebastian McKenzie
dc98ac7c93 5.0.8 2015-04-04 17:09:35 +11:00
Sebastian McKenzie
6e456f0ec1 v5.0.8 2015-04-04 17:05:47 +11:00
Sebastian McKenzie
793090628d fix #1157 regression test 2015-04-04 17:03:54 +11:00
Sebastian McKenzie
9ed251cb08 add 5.0.8 changelog 2015-04-04 17:02:50 +11:00
Sebastian McKenzie
480fa7f4e0 add regression test for #1157 2015-04-04 16:59:29 +11:00
Sebastian McKenzie
3e642dfa1b Merge pull request #1157 from jayphelps/patch-1
[BUGFIX] Check whether `value` key is in descriptor instead of checking truthy value
2015-04-04 16:57:57 +11:00
Jay Phelps
d9cbce1862 [BUGFIX] checking whether value key is in descriptor instead of checking if value is truthy since !!0 === false
class Foo {
  static bar = 0;
}

Foo.bar++;
// Cannot assign to read only property 'bar' of function
2015-04-03 22:49:34 -07:00
Sebastian McKenzie
4bd19da3c2 fix tests, better block scoped collisions 2015-04-04 14:17:26 +11:00
Sebastian McKenzie
7c710a0378 move var scope collector to before block - fixes #1153 2015-04-04 14:09:34 +11:00
Sebastian McKenzie
56335409d3 stop constructor verification traversal on FunctionDeclaration/FunctionExpression - fixes #1155 2015-04-04 14:01:26 +11:00
Sebastian McKenzie
91d78afc67 update 5.0.7 changelog 2015-04-04 05:32:32 +11:00
Sebastian McKenzie
54c6339f20 5.0.7 2015-04-04 04:51:24 +11:00
Sebastian McKenzie
fdcf64265e v5.0.7 2015-04-04 04:49:31 +11:00
Sebastian McKenzie
ffdfb491eb disable identifier resolution - fixes #1149 2015-04-04 04:46:49 +11:00
Sebastian McKenzie
eedd431f2b remove HOMEPATH from register cache home resolution 2015-04-04 04:40:10 +11:00
Sebastian McKenzie
db9ed0235f finally fix cli tests 2015-04-04 04:39:28 +11:00
Sebastian McKenzie
6c98d39937 grr, debugging travis builds is hard 2015-04-04 04:01:35 +11:00
Sebastian McKenzie
20651df3ce try and fix babel cli bootstrap 2015-04-04 03:47:47 +11:00
Sebastian McKenzie
f3155919fe shift USERPROFILE over in home resolution in babel/register - fixes #1148 2015-04-04 03:46:07 +11:00
Sebastian McKenzie
0ac8330899 remove bable-core in babel-cli bootstrap 2015-04-04 03:40:01 +11:00
Sebastian McKenzie
67201e9698 add ignore/only option to cli 2015-04-04 03:31:19 +11:00
Sebastian McKenzie
c715d96e46 wrap non-arrays/strings/falsys in an array in util.list - fixes babel/babelify#69 2015-04-04 02:40:09 +11:00
Sebastian McKenzie
b7a08100a6 add default live bindings to common module formatter 2015-04-04 01:56:58 +11:00
Sebastian McKenzie
5f91ee8a1a 5.0.6 2015-04-03 23:15:34 +11:00
Sebastian McKenzie
bc1abb5103 v5.0.6 2015-04-03 23:13:43 +11:00
Sebastian McKenzie
4b9207e5df add 5.0.6 changelog 2015-04-03 23:12:10 +11:00
Sebastian McKenzie
e847f3685f should only throw an error for colliding param bindings for let and const 2015-04-03 23:11:04 +11:00
Sebastian McKenzie
d64c2c0c45 turn internalRemap into a null inherited object, fixes a nasty bug where module import live bindings would return a function if they referenced a method on Object.prototype (eg. toString) 2015-04-03 23:10:09 +11:00
Sebastian McKenzie
76d0fb4ba6 5.0.5 2015-04-03 22:44:16 +11:00
Sebastian McKenzie
0f33b7bfbc v5.0.5 2015-04-03 22:42:50 +11:00
Sebastian McKenzie
630224e504 add 5.0.5 changelog 2015-04-03 22:41:06 +11:00
Sebastian McKenzie
62980ab6b4 Merge branch 'master' of github.com:babel/babel
t push
2015-04-03 22:38:28 +11:00
Sebastian McKenzie
d34480b42b add support for arrays to util.list - fixes #["foo", "bar"] 2015-04-03 22:38:08 +11:00
Sebastian McKenzie
306de2edbf Merge pull request #1144 from tricknotes/fix-for-browserify
Update core-js to ^0.8.1
2015-04-03 22:23:48 +11:00
Ryunosuke SATO
c33e84730d Update core-js to ^0.8.1
This version fixes the error for some environments that
has no `setTimeout`/`setInterval`.
2015-04-03 18:38:33 +09:00
Sebastian McKenzie
20f28aba64 5.0.4 2015-04-03 15:34:20 +11:00
Sebastian McKenzie
9c312607d1 Merge branch 'master' of github.com:babel/babel 2015-04-03 15:33:27 +11:00
Sebastian McKenzie
33659711c3 Merge pull request #1142 from cesarandreu/add-babel-readme
Add README.md to babel-cli
2015-04-03 15:33:00 +11:00
Sebastian McKenzie
b154af48a7 Merge branch 'master' of github.com:babel/babel 2015-04-03 15:32:52 +11:00
Cesar Andreu
bad877946f Add README.md to babel-cli 2015-04-02 21:31:47 -07:00
Sebastian McKenzie
dff3751e7f v5.0.4 2015-04-03 15:31:08 +11:00
Sebastian McKenzie
23038dcfff Merge pull request #1141 from fkling/patch-1
Update SO link in README.md
2015-04-03 15:30:47 +11:00
Felix Kling
7c7a7ee17f Update README.md
The SO link currently points to https://github.com/babel/babel/blob/master/stackoverflow.com, which is incorrect. After this change it points to the list of babeljs questions.
2015-04-02 21:29:56 -07:00
Sebastian McKenzie
9f467ef7c0 5.0.3 2015-04-03 15:29:16 +11:00
Sebastian McKenzie
a52f9ab346 add 5.0.4 changelog 2015-04-03 15:29:11 +11:00
Sebastian McKenzie
5ccbed585b Merge pull request #1140 from cesarandreu/patch-2
Avoid searching .babelrc if breakConfig is set
2015-04-03 15:27:24 +11:00
Sebastian McKenzie
f7c7da7526 v5.0.3 2015-04-03 15:24:47 +11:00
Cesar Andreu
ed58c80c64 Avoid searching .babelrc if breakConfig is set 2015-04-02 21:24:06 -07:00
Sebastian McKenzie
d7fb9f67df t push
make publish
Merge branch 'master' of github.com:babel/babel
2015-04-03 15:23:03 +11:00
Sebastian McKenzie
eef6002324 add 5.0.3 changelog 2015-04-03 15:22:36 +11:00
Sebastian McKenzie
32bcf4c3a5 Merge pull request #1139 from cesarandreu/patch-3
Add breakConfig to options.json
2015-04-03 15:19:41 +11:00
Sebastian McKenzie
86060cb0ce switch back to global uid registry - fixes #1136 2015-04-03 15:18:04 +11:00
Cesar Andreu
66a836d435 breakConfig should be hiddebn 2015-04-02 21:14:26 -07:00
Cesar Andreu
ecc14c2a31 Add breakConfig to options.json 2015-04-02 21:09:56 -07:00
Sebastian McKenzie
7e9b60fba5 turn into absolute location if not for rc resolution - fixes #1137 2015-04-03 15:03:00 +11:00
Sebastian McKenzie
313f1e755a 5.0.2 2015-04-03 06:55:53 +11:00
Sebastian McKenzie
8c7ef0a2c9 v5.0.2 2015-04-03 06:53:46 +11:00
Sebastian McKenzie
8f79010b16 add regression test for #1130 2015-04-03 06:52:23 +11:00
Sebastian McKenzie
022e6f26aa fix not being able to call non-writable methods - fixes #1133 2015-04-03 06:52:17 +11:00
Sebastian McKenzie
138fa6c9f8 add 5.0.1 changelog 2015-04-03 06:52:02 +11:00
Sebastian McKenzie
c07704cc80 remove parentPath existence check 2015-04-03 06:48:46 +11:00
Sebastian McKenzie
bf811ea34a 5.0.1 2015-04-03 06:47:47 +11:00
Sebastian McKenzie
8af3ea1c43 fix duplicate declaration regression - fixes #1130 2015-04-03 06:47:41 +11:00
Sebastian McKenzie
5fbe147a5e v5.0.1 2015-04-03 05:49:16 +11:00
Sebastian McKenzie
a9e214b1db fix build cli script 2015-04-03 05:48:02 +11:00
Sebastian McKenzie
6812fca7a9 v5.0.0 2015-04-03 05:36:47 +11:00
Sebastian McKenzie
ebc42f5ce0 add setInterval and setTimeout noop to browserify test pending a new core-js patch release 2015-04-03 04:53:13 +11:00
Sebastian McKenzie
b12a97ddd6 rename returnUsedHelpers to metadataUsedHelpers 2015-04-03 04:50:19 +11:00
Sebastian McKenzie
e8daad38a7 remove beta tag from npm publish 2015-04-03 04:39:45 +11:00
Sebastian McKenzie
c6c0bc07e2 fix empty whitelist in build-external-helpers - fixes #1129 2015-04-03 04:39:39 +11:00
Sebastian McKenzie
c60f3f0e34 fix runtime transformer and update tests 2015-04-03 02:56:32 +11:00
Sebastian McKenzie
07078138f3 update to core-js 0.8.0 2015-04-03 02:37:02 +11:00
Sebastian McKenzie
cb0026edfe fix plugin api 2015-04-03 01:53:25 +11:00
Sebastian McKenzie
ab55ec4ea2 fix afterPlugins variable 2015-04-03 00:33:54 +11:00
Sebastian McKenzie
e164123ce9 remove packages README 2015-04-03 00:33:48 +11:00
Sebastian McKenzie
f42bacf4f6 fix syntax error in File 2015-04-03 00:02:13 +11:00
Sebastian McKenzie
46adb07d41 add plugin api - closes #987 2015-04-02 23:49:24 +11:00
Sebastian McKenzie
e10bdf7c5b add try-catch to util.resolveRelative 2015-04-02 23:44:29 +11:00
Sebastian McKenzie
83eea2acc7 add babel-cli init to bootstrap 2015-04-02 23:34:28 +11:00
Sebastian McKenzie
8bdd4cc559 fix babel-external-helpers path in Makefile 2015-04-02 23:16:01 +11:00
Sebastian McKenzie
15d31b5608 move babel cli into separate folder #1097 2015-04-02 23:12:05 +11:00
Sebastian McKenzie
9ed6a7b650 simplify dynamic imports 2015-04-02 22:03:57 +11:00
Sebastian McKenzie
01a2aa7dd1 support multiple export specifier remapping 2015-04-02 20:25:05 +11:00
Sebastian McKenzie
33fde5f143 update 5.0.0 changelog 2015-04-02 20:09:29 +11:00
Sebastian McKenzie
682c775a97 fix babel-node require test to reflect import hoisting 2015-04-02 19:34:21 +11:00
Sebastian McKenzie
4846b89931 export options in browser api 2015-04-02 19:28:18 +11:00
Sebastian McKenzie
25312396a5 add live binding support to modules - fixes #1117, fixes #1057, closes #1118 2015-04-02 19:28:11 +11:00
Sebastian McKenzie
cfff7aa6fb simplfy function name inference wrapper - closes #1002 2015-04-02 02:37:00 +11:00
Sebastian McKenzie
f88a4147a6 traceur upstream sync 2015-04-02 02:21:12 +11:00
Sebastian McKenzie
3c343adf33 add support for super update and assignment expressions - fixes #426 2015-04-02 02:21:04 +11:00
Sebastian McKenzie
269587cde5 hoist block iife to avoid creating a new one for each loop iteration 2015-04-02 00:58:01 +11:00
Sebastian McKenzie
121ba8c381 fix loop block scoping, check for exact reference when doing closure detection - fixes #973 2015-04-02 00:04:10 +11:00
Sebastian McKenzie
563a427b69 add ludicrous transformer 2015-04-01 23:23:09 +11:00
Sebastian McKenzie
658164a0d2 fix booleanString compact option 2015-04-01 23:21:32 +11:00
Sebastian McKenzie
135ba84abb fix es7 export extensions compound list 2015-04-01 23:21:16 +11:00
Sebastian McKenzie
76573093bd add umd globals export - fixes #375 2015-04-01 23:02:03 +11:00
Sebastian McKenzie
22b88487ee remove use strict directive from react test 2015-04-01 14:12:11 +11:00
Sebastian McKenzie
3686951dc1 5.0.0-beta4 2015-04-01 14:07:41 +11:00
Sebastian McKenzie
f43ca32ff5 move es6 tail call test 2015-04-01 14:07:32 +11:00
Sebastian McKenzie
424a59a856 dont coerce jsx expression containers - fixes #1126 2015-04-01 14:07:26 +11:00
Sebastian McKenzie
5f159853d5 fix paramless async calls 2015-04-01 13:57:59 +11:00
Sebastian McKenzie
f9c56c6dd7 properly export acorn 2015-04-01 13:51:15 +11:00
Sebastian McKenzie
613e77cd50 v5.0.0-beta4 2015-04-01 00:46:35 +11:00
Sebastian McKenzie
27c97aab34 reneable seting of type annotations 2015-04-01 00:44:54 +11:00
Sebastian McKenzie
ad857dddd1 add verification check to deprecation 2015-04-01 00:39:20 +11:00
Sebastian McKenzie
d9762e9049 expose options 2015-04-01 00:39:12 +11:00
Sebastian McKenzie
088846a347 Merge branch 'master' of github.com:babel/babel 2015-03-31 23:47:55 +11:00
Sebastian McKenzie
7fc28cb63f move deprecation check down 2015-03-31 23:47:40 +11:00
Sebastian McKenzie
3323e0f3a5 add descriptions to remaining options 2015-03-31 23:39:02 +11:00
Sebastian McKenzie
8c09a2198a fix es7.exportExtensions stage 2015-03-31 23:38:51 +11:00
Sebastian McKenzie
eeb5b8d0c3 add es1.ludicrous transformer skeleton 2015-03-31 23:38:40 +11:00
Sebastian McKenzie
19e8274e79 make it abundantly clear in the readme that the issue tracker is not for support and questions. i'm spread thin enough and don't need to be doing support for everyone, i wish i could but sadly i can't :( 2015-03-31 23:38:16 +11:00
Sebastian McKenzie
6353abfd1b move remapAssignments to init method in the module formatter - fixes #1124 2015-03-31 19:28:42 +11:00
Sebastian McKenzie
ee14770a5c fix variable declaration semicolons in for loops 2015-03-31 10:44:31 +11:00
Sebastian McKenzie
d3b9b7251e remove 6to5 binaries 2015-03-31 10:44:10 +11:00
Sebastian McKenzie
3f7f89a6b9 make babel.json filename hidden - #1093 2015-03-31 05:27:22 +11:00
Sebastian McKenzie
7476b8c6a3 don't coerce compiled sibling children to a single literal - @spicyj 2015-03-31 03:49:41 +11:00
Sebastian McKenzie
1ef41b6f32 optimisation.react.inlineElements: move children into props and leave children out if the element has none - @spicyj 2015-03-31 03:31:27 +11:00
Sebastian McKenzie
6bc2bfce7d rename runtimeES3 transformer to es3.runtime 2015-03-31 02:34:32 +11:00
Sebastian McKenzie
153e81261c inherit string quotes - fixes #991 2015-03-31 02:09:56 +11:00
Sebastian McKenzie
b8f2a27e90 take export default specifiers into consideration in t.isSpecifierDefault 2015-03-31 01:41:04 +11:00
Sebastian McKenzie
2f25c3bd17 use users home directory to store babel/register cache - fixes #1093 2015-03-31 01:40:53 +11:00
Sebastian McKenzie
59e07b65dd downgrade core-js 2015-03-31 01:34:38 +11:00
Sebastian McKenzie
769f7fb81d update runtime tests 2015-03-31 01:30:51 +11:00
Sebastian McKenzie
7895857624 remove dead tests 2015-03-31 01:27:48 +11:00
Sebastian McKenzie
80fed5f395 take into consideration default export specifiers in common module formatter - fixes #1071 2015-03-31 01:27:43 +11:00
Sebastian McKenzie
1c7fabdd6d add runtimeES3 transformer 2015-03-31 01:20:14 +11:00
Sebastian McKenzie
12f8fa229d remove redundant spec.functionName tests 2015-03-30 21:49:58 +11:00
Sebastian McKenzie
c6546264d2 split up spec.functionName tests 2015-03-30 21:46:08 +11:00
Sebastian McKenzie
86cc5875cf re-enable shit safari test #1121 2015-03-30 21:46:01 +11:00
Sebastian McKenzie
9ea999b261 clean up class property initializers, handle scope collisions in constructors 2015-03-30 20:32:14 +11:00
Sebastian McKenzie
f81e841283 don't block hoist in system module formatter when runtime transformer is enabled - #1105 2015-03-30 18:24:44 +11:00
Sebastian McKenzie
c14ffb8319 Merge branch 'guybedford-system-unhoist-generators' into experimental 2015-03-30 18:16:44 +11:00
Sebastian McKenzie
b9f4fe86f1 merge 2015-03-30 18:16:28 +11:00
Sebastian McKenzie
56ada634b4 Merge pull request #1112 from ben-ng/patch-1
Incorrect package path
2015-03-30 18:13:37 +11:00
Sebastian McKenzie
c4d68897b3 rename own binding inside constructor if it collides with our class reference - fixes #1077 2015-03-30 18:06:59 +11:00
Sebastian McKenzie
1641caedc4 retain binding values on iteration if reassigned - fixes #1078 2015-03-30 18:02:21 +11:00
Sebastian McKenzie
3d6e722fc7 fix es6.spec.blockScoping transformer reference 2015-03-30 16:58:51 +11:00
Sebastian McKenzie
253493a43f fix es6.blockScopingTDZ transformer filename 2015-03-30 16:55:20 +11:00
Sebastian McKenzie
66471f044a add deprecation alais for es6.blockScopingTDZ 2015-03-30 16:53:46 +11:00
Sebastian McKenzie
5fa227eb73 fix module names for amd/umd tests 2015-03-30 16:53:06 +11:00
Sebastian McKenzie
f3b50f0bb9 rename es6.blockScopingTDZ to es6.spec.blockScoping 2015-03-30 16:52:58 +11:00
Sebastian McKenzie
92bba76bd5 fix test fixture transformer folder names 2015-03-30 16:44:55 +11:00
Sebastian McKenzie
46462e3e69 add optional scope parameter to TraversalPath#hoist 2015-03-30 16:41:29 +11:00
Sebastian McKenzie
bc155f956c add es6.spec.templateLiterals transformer and rename es6.symbols to es6.spec.symbols 2015-03-30 16:41:13 +11:00
Sebastian McKenzie
dc1ba58705 fix experimental arg in babel-node 2015-03-30 07:34:51 +11:00
Sebastian McKenzie
99e274921f remove experimental option in favor of a stage option 2015-03-30 07:30:37 +11:00
Sebastian McKenzie
862bd6d92a use kebab case instead of camelcase for no cli options 2015-03-30 06:43:23 +11:00
Sebastian McKenzie
46d991e3e9 add nonStandard option - @stefanpenner 2015-03-30 06:41:55 +11:00
Sebastian McKenzie
8e1b6df970 properly handle export default shorthand, also consider export default foo; and export { foo as default } to be equivalent 2015-03-30 06:31:41 +11:00
Sebastian McKenzie
f9c8d7d1fd fix incorrect interpreation of export default shorthand, update to new ast definitions - #1091 2015-03-30 06:08:37 +11:00
Sebastian McKenzie
eb2f61e43f add class property initializer and decorator parser tests 2015-03-30 03:52:39 +11:00
Sebastian McKenzie
afe8792ba4 fix names for export declaration generation tests 2015-03-30 03:38:24 +11:00
Sebastian McKenzie
42a2430d2c add support for export extensions https://github.com/leebyron/ecmascript-more-export-from - closes #1091 2015-03-30 03:38:14 +11:00
Sebastian McKenzie
c4d260231b fix optimisation.react.constantElements test fixture names 2015-03-30 01:22:59 +11:00
Sebastian McKenzie
ca5daca5dd add optimisation.react.constantElements transformer - facebook/react#3228 2015-03-30 01:22:45 +11:00
Sebastian McKenzie
3952eefd01 remove some dead code 2015-03-30 00:18:37 +11:00
Sebastian McKenzie
52c6fe2bc1 add a path hoisting mechanism that will hoist a node to it's highest compatible scope, a compatible scope is considered to be one where all references inside can be resolved to, also adds an optimisation.react.constantElements transformer that uses this to much success facebook/react#3226 2015-03-30 00:16:19 +11:00
Sebastian McKenzie
6a698f7ae4 move class property code gen to classes file 2015-03-29 19:31:02 +11:00
Sebastian McKenzie
2b0c07c2e7 only push the initializer function if required 2015-03-29 19:30:53 +11:00
Sebastian McKenzie
e27e7facac add decorator tests 2015-03-29 19:30:41 +11:00
Sebastian McKenzie
0dd32e7d9c fix class decorator methods 2015-03-29 19:30:34 +11:00
Sebastian McKenzie
286ae68da2 make constants and module imports synonymous - closes #954 2015-03-29 17:36:23 +11:00
Sebastian McKenzie
e26f994075 add existence check when merging source map - fixes #1111 2015-03-29 17:17:43 +11:00
Sebastian McKenzie
94f005e324 clean up flow object type property semicolons 2015-03-29 17:14:46 +11:00
Sebastian McKenzie
93e37aaaf1 inherit comments from class method 2015-03-29 17:09:03 +11:00
Sebastian McKenzie
e4db93f6a5 fix flow test range end of object property nodes 2015-03-29 17:05:14 +11:00
Sebastian McKenzie
c9243e8e97 fixes #1114
- The visitor keys for `ObjectTypeAnnotation`s were incorrect so those nodes weren't being traversed so comments weren't attached for them.
 - The type parser wasn't eating the semicolons for the nodes so the `end` location of each of the type properties wasn't accurate which threw off the code generation newline algorithm.
 - Type properties hadn't been given the `UserWhitespacable` alias.
2015-03-29 16:44:36 +11:00
Sebastian McKenzie
bbba374783 5.0.0-beta3 2015-03-29 16:10:17 +11:00
Sebastian McKenzie
7d95fddbed add do expression definition to ast-types - fixes #1113 2015-03-29 16:10:07 +11:00
Ben
617ed09227 Incorrect package path
I'm pretty sure that this is a mistake, since the path doesn't exist relative to this file. Is it supposed to point to the babel-core package.json like this?
2015-03-28 15:32:07 -04:00
Sebastian McKenzie
6d7887cfe2 v5.0.0-beta3 2015-03-29 01:52:30 +11:00
Sebastian McKenzie
b8e9171aaa start on changelog 2015-03-29 01:50:54 +11:00
Sebastian McKenzie
22118c0be0 add Immutable alias keys 2015-03-29 01:50:45 +11:00
Sebastian McKenzie
3754f7615f make insertBefore functionality the same as insertBefore in traversal path and add getStatementParent method 2015-03-29 01:50:36 +11:00
Sebastian McKenzie
b54901018b Merge pull request #1108 from ArrestedDevelopment/jsxpragma-option
JSX Transformer: Add 'jsxPragma' option
2015-03-28 22:17:18 +11:00
ArrestedDevelopment
121b9ca063 Add tests for JSX Pragma option 2015-03-28 02:20:01 -06:00
ArrestedDevelopment
4988a27b6c JSX Transformer: Add 'jsxPragma' option 2015-03-28 01:41:16 -06:00
Sebastian McKenzie
e0297e08b8 Merge pull request #1103 from joliss/makefile
Disable parallelism in Makefile
2015-03-28 08:39:08 +11:00
Sebastian McKenzie
79005d2f03 Merge pull request #1102 from joliss/npmignore
Prefix all npmignored files with "/"
2015-03-28 08:38:56 +11:00
Sebastian McKenzie
5cce8c32a4 Merge pull request #1101 from joliss/make-clean
Delete lib directory on `make clean`
2015-03-28 08:38:37 +11:00
Sebastian McKenzie
95b1accddc Merge pull request #1104 from joliss/travis
Re-enable experimental branch on Travis
2015-03-28 08:38:26 +11:00
Jo Liss
6149e6325f Re-enable experimental branch on Travis 2015-03-27 21:34:38 +00:00
Jo Liss
4c9d4d0378 Disable parallelism in Makefile
When MAKEFLAGS=-j2 is set in the environment, `make test-travis` can fail
surprisingly, because targets are executed in parallel.
2015-03-27 21:28:07 +00:00
Jo Liss
2e599bef4f Prefix all npmignored files with "/"
This in particular stops lib/acorn/src from being incorrectly matched by "src".
2015-03-27 21:02:28 +00:00
Jo Liss
885da177f9 Delete lib directory on make clean 2015-03-27 20:52:00 +00:00
Sebastian McKenzie
463112517f 5.0.0-beta2 2015-03-28 05:48:27 +11:00
Sebastian McKenzie
8f10dc5c39 v5.0.0-beta2 2015-03-28 05:46:57 +11:00
Sebastian McKenzie
0f99bbe293 fix test tmp directory gitignore 2015-03-28 05:45:46 +11:00
Sebastian McKenzie
0a5d2c098f add tag beta to publish scripts 2015-03-28 05:45:37 +11:00
Sebastian McKenzie
dcf4381e26 5.0.0-beta1 2015-03-28 05:45:22 +11:00
Sebastian McKenzie
543582ef47 fix helper filename in build-runtime script 2015-03-28 05:42:55 +11:00
Sebastian McKenzie
a4db58ccaa v5.0.0-beta1 2015-03-28 05:40:16 +11:00
Sebastian McKenzie
d3971e0874 move es6.arrowFunctions transformer up 2015-03-28 05:38:31 +11:00
Sebastian McKenzie
ad98186afc remove redundant semicolons from export declarations 2015-03-28 05:38:22 +11:00
Sebastian McKenzie
df251fbfff fix test paths to reflect new test directory structure 2015-03-28 05:38:12 +11:00
Sebastian McKenzie
dfbcf95b0e disable sourcemap stdin tests 2015-03-28 05:37:55 +11:00
Sebastian McKenzie
07646475d9 fix spread binding with the wrong context 2015-03-28 05:37:38 +11:00
Sebastian McKenzie
9bc67c28e3 fix path api usage in es6.forOf 2015-03-28 05:37:15 +11:00
Sebastian McKenzie
c2990d3548 add array cache to es6.destructuring to avoid running toArray multiple times 2015-03-28 05:37:06 +11:00
Sebastian McKenzie
803f8a3bbc fix paths in api test 2015-03-28 04:38:26 +11:00
Sebastian McKenzie
ee6efee4f8 disable es6 do expressions and decorators tests 2015-03-28 04:37:30 +11:00
Sebastian McKenzie
3f144e6e74 ensure that nodes are only traversed once per context 2015-03-28 04:34:05 +11:00
Sebastian McKenzie
afedfe15ae fix external helper build script to reflect filename schema changes 2015-03-28 04:08:02 +11:00
Sebastian McKenzie
b522294d3c fix helper slice filename 2015-03-28 04:07:44 +11:00
Sebastian McKenzie
954af72476 update various tests to reflect the new architecture 2015-03-28 04:00:20 +11:00
Sebastian McKenzie
de42a6f796 add existence check for child and parent when inheriting comments 2015-03-28 04:00:02 +11:00
Sebastian McKenzie
06a58f228c add TraversalPath#replaceInline, fix traversal path not updating sibling keys correctly 2015-03-28 03:59:51 +11:00
Sebastian McKenzie
7a44576c26 cache rc json 2015-03-28 03:59:14 +11:00
Sebastian McKenzie
eaa3865427 remove es7.classProperties check from parser 2015-03-28 03:59:01 +11:00
Sebastian McKenzie
b83907cc67 restructure testing infrastructure to be more modular 2015-03-28 01:21:48 +11:00
Sebastian McKenzie
a3620a58f8 add externalHelpers to source maps tests 2015-03-28 00:26:11 +11:00
Sebastian McKenzie
67a12f03fa use replaceWithNodes rather than replace in es6.forOf transformer 2015-03-28 00:26:04 +11:00
Sebastian McKenzie
c49871d33c stylistic changes to tests 2015-03-28 00:25:45 +11:00
Sebastian McKenzie
c828688d21 add existence check to t.inherits 2015-03-28 00:23:07 +11:00
Sebastian McKenzie
bd052aea50 inherit first replacement node from the current node 2015-03-28 00:22:59 +11:00
Sebastian McKenzie
ed74ccaa7d add support for decorators before class exports 2015-03-28 00:22:38 +11:00
Sebastian McKenzie
f3c9551b75 add MetaProperty visitor keys 2015-03-28 00:22:18 +11:00
Sebastian McKenzie
710a7f882d add loose mode for es6.spread and es6.destructuring that assumes all values are arrays - emberjs/ember.js#10730 2015-03-28 00:21:37 +11:00
Sebastian McKenzie
902ebd3fe7 switch back helpers to Array.isArray 2015-03-28 00:21:15 +11:00
Sebastian McKenzie
23c20cc47c inherit from the user constructor properly 2015-03-26 01:02:47 +11:00
Sebastian McKenzie
9b627ace5d impose a strict API for traversal paths and ensure AST doesn't have holes mid-transform 2015-03-26 01:02:30 +11:00
Sebastian McKenzie
4fa17341f5 add support for object expressions and patterns to scope.generateUidBasedOnNode 2015-03-26 01:00:32 +11:00
Sebastian McKenzie
1e019c0f16 realign alias keys data 2015-03-26 01:00:12 +11:00
Sebastian McKenzie
ce25ebacbf only coerce the right side in template literal implosion 2015-03-26 00:59:58 +11:00
Sebastian McKenzie
daecec2a86 better parsing of decorators - support class expressions 2015-03-26 00:58:38 +11:00
Sebastian McKenzie
238f9c2e7e call resolveModuleSource on dynamic imports - fixes #1085 2015-03-26 00:50:58 +11:00
Sebastian McKenzie
bc5f2b9be6 add param to list of duplicate declaration kinds - fixes #1084 2015-03-26 00:48:17 +11:00
Sebastian McKenzie
5390715705 update tests to latest experimental changes 2015-03-25 20:20:51 +11:00
Sebastian McKenzie
aa1333123c Merge branch 'master' into experimental
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
2015-03-25 14:17:46 +11:00
Sebastian McKenzie
048f9acc55 Merge pull request #1081 from babel/fix-tco-binding-clearing
Clear bindings immediately inside the TCO loop.
2015-03-25 14:16:46 +11:00
Brian Donovan
ed6421876a Clear bindings immediately inside the TCO loop.
We have to ensure that this happens before any potentially-hoisted
declarations from default parameters.

Closes #1080.
2015-03-24 20:15:54 -07:00
Sebastian McKenzie
e60c9fba6a better node injection mechanics that handle statement lists 2015-03-24 04:37:56 +11:00
Sebastian McKenzie
902db03e96 add loose mode to template literals 2015-03-24 03:34:42 +11:00
Sebastian McKenzie
de88b28988 add class property initializers, add more TraversalPath flexibility with additional node injection method 2015-03-24 03:34:34 +11:00
Sebastian McKenzie
0ee230d13c coerce template literal expressions to strings - fixes #1065 2015-03-23 22:04:40 +11:00
Sebastian McKenzie
c12cfe3ed0 make method definitions with expression bodies illegal - fixes #1066 2015-03-23 20:24:32 +11:00
Sebastian McKenzie
1376f2f18f move helper templates to a separate namespace 2015-03-23 17:26:54 +11:00
Sebastian McKenzie
972c621f59 remove template literals from bin 2015-03-23 17:26:31 +11:00
Sebastian McKenzie
5c41a33e41 save register cache on tick instead of sigint - fixes #1062 2015-03-23 17:26:08 +11:00
Sebastian McKenzie
bc6d01d6fc enable strict mode on babel-node eval flag - fixes #1060 2015-03-23 16:53:03 +11:00
Sebastian McKenzie
01463faf36 remove apply-constructor helper from es6.spread transformer - fixes #1052 2015-03-23 16:51:14 +11:00
Sebastian McKenzie
b234603e24 add callDelegate transformation helper - fixes #1064 2015-03-23 16:47:17 +11:00
Sebastian McKenzie
ca79fff0c4 remove acorn compiled source 2015-03-22 04:09:18 +11:00
Sebastian McKenzie
3c8f3cb521 update couple tests to reflect new statement explosion 2015-03-22 04:08:55 +11:00
Sebastian McKenzie
c9974a42ea remove legacy react metadata 2015-03-22 04:08:45 +11:00
Sebastian McKenzie
a87f6f6fdd clean up statement to expression explosion 2015-03-22 04:08:35 +11:00
Sebastian McKenzie
3d28ce7903 git ignore entire lib folder 2015-03-22 04:07:53 +11:00
Sebastian McKenzie
e04ecc79c7 add support for class decorators 2015-03-22 04:07:38 +11:00
Sebastian McKenzie
3e26511fb2 remove ShadowFunctionExpression 2015-03-22 04:07:00 +11:00
Sebastian McKenzie
9c3493e02f add do expressions 2015-03-22 04:06:15 +11:00
Sebastian McKenzie
a14e979897 use module syntax for strict module formatters 2015-03-21 15:27:32 +11:00
Sebastian McKenzie
a4ce653bed update tests to reflect fixed destructuring behaviour and statement to expression explosion 2015-03-21 15:27:13 +11:00
Sebastian McKenzie
70d068226a add ability to explode a list of statements when trying to replace an expression - damn this is powerful and allows some SUPER cool scenarios 2015-03-21 15:26:55 +11:00
Sebastian McKenzie
30b1c0154d update to modular acorn 2015-03-21 15:25:32 +11:00
Sebastian McKenzie
a602873281 update to latest acorn, better array shortcuts, don't add code frame to error message 2015-03-20 20:05:29 +11:00
Sebastian McKenzie
c8b88182f6 fix bin tests 2015-03-20 20:03:49 +11:00
Sebastian McKenzie
64f1c114c1 fix modules generation logic and remove dead node types 2015-03-19 03:17:28 +11:00
Sebastian McKenzie
4ac1a856ae fix remaining issues in estree port 2015-03-19 02:59:44 +11:00
Sebastian McKenzie
0e68b6ca11 add highlightErrors option to parser options 2015-03-19 02:59:30 +11:00
Sebastian McKenzie
2dccc8c919 more estree updates - finish flow parsing 2015-03-19 01:48:44 +11:00
Sebastian McKenzie
fdea18a289 properly support iterators in sliced-to-array helper... 2015-03-19 01:47:19 +11:00
Sebastian McKenzie
c3bdecbd25 move arrow functions transformer to before function names 2015-03-19 01:46:53 +11:00
Sebastian McKenzie
ee63fb52b7 check whitelist for existence rather than length - #1044 2015-03-19 01:46:10 +11:00
Sebastian McKenzie
8575392606 4.7.16 2015-03-18 23:37:24 +11:00
Sebastian McKenzie
d28583bea1 v4.7.16 2015-03-18 23:36:04 +11:00
Sebastian McKenzie
b166f35218 add typed arrays to native types list - #1043 2015-03-18 23:34:37 +11:00
Sebastian McKenzie
0914378bba add 4.7.16 changelog 2015-03-18 23:34:26 +11:00
Sebastian McKenzie
660d764390 remove loop check when aliasing breaks, continues etc - fixes #1051 2015-03-18 23:31:11 +11:00
Sebastian McKenzie
27206d6b7c add complete list of native constructors 2015-03-18 23:27:14 +11:00
Sebastian McKenzie
34dc56b435 Merge branch 'master' into experimental
# Conflicts:
#	src/babel/transformation/transformers/es7/abstract-references.js
#	src/babel/transformation/transformers/playground/mallet-operator.js
#	src/babel/transformation/transformers/playground/memoization-operator.js
#	src/babel/types/index.js
2015-03-18 19:18:25 +11:00
Sebastian McKenzie
d919d7837c 4.7.15 2015-03-18 19:17:07 +11:00
Sebastian McKenzie
b49cf4e779 v4.7.15 2015-03-18 19:16:01 +11:00
Sebastian McKenzie
e30dd7042b fix constructor spreading of collections #1043 2015-03-18 19:14:23 +11:00
Sebastian McKenzie
16d8d928e8 4.7.14 2015-03-18 19:14:02 +11:00
Sebastian McKenzie
4966028397 v4.7.14 2015-03-18 19:11:21 +11:00
Sebastian McKenzie
82e04fffac add 4.7.14 changelog 2015-03-18 19:08:53 +11:00
Sebastian McKenzie
a46313903d deprecate abstract references and remaining playground features 2015-03-18 19:08:05 +11:00
Sebastian McKenzie
68340b1288 add Promise to the list of native types - fixes #1043 2015-03-18 19:06:34 +11:00
Sebastian McKenzie
6a1b33b443 more updates to estree and new acorn 2015-03-18 19:02:15 +11:00
Sebastian McKenzie
df7524d909 update babel dev dependency and use for-of in sliced-to-array helper - fixes #1047 2015-03-18 19:01:58 +11:00
Sebastian McKenzie
2c39d406d1 move acorn into vendor 2015-03-18 19:01:30 +11:00
Sebastian McKenzie
2ff1a5d98b Merge branch 'master' into experimental
# Conflicts:
#	src/babel/transformation/transformers/internal/strict.js
2015-03-17 12:14:32 +11:00
Sebastian McKenzie
7f9fe4af15 4.7.13 2015-03-17 12:12:51 +11:00
Sebastian McKenzie
977290c7e4 v4.7.13 2015-03-17 12:11:26 +11:00
Sebastian McKenzie
ebbdb95278 add 4.7.13 changelog 2015-03-17 12:09:16 +11:00
Sebastian McKenzie
9b586c7587 add support for left side patterns in assignment pattern destructuring - fixes #1037 2015-03-17 12:03:13 +11:00
Brian Donovan
4b5ba6c8c6 Add a test for the this-spread fix in 976e8c1.
Addresses #1033.
2015-03-17 11:31:09 +11:00
Sebastian McKenzie
67efb1b427 ignore this expressions in Scope#generateTempBasedOnNode - fixes #1033 2015-03-17 11:31:00 +11:00
Sebastian McKenzie
bc9c1ab61e handle comments and use strict directives better - fixes #1030 2015-03-17 11:30:30 +11:00
Sebastian McKenzie
65ffe07551 remove react test option 2015-03-17 11:26:28 +11:00
Sebastian McKenzie
b606cc79ca remove class playground property initializer tests 2015-03-17 11:26:18 +11:00
Sebastian McKenzie
0e7fd0741d inject transformer parser plugins 2015-03-17 11:26:06 +11:00
Sebastian McKenzie
276cafaae1 Merge branch 'master' of github.com:babel/babel 2015-03-17 02:45:36 +11:00
Sebastian McKenzie
4f00de50d6 remove playground code gen, remove react metadata, start update of modules to estree 2015-03-17 02:45:16 +11:00
Brian Donovan
b07341a1f7 Add a note about using the --grep option to focus test runs. 2015-03-16 08:45:05 -07:00
Sebastian McKenzie
ec526f9224 embed acorn 2015-03-17 02:44:05 +11:00
Brian Donovan
76301a7713 Fix grammar. 2015-03-16 08:43:45 -07:00
Brian Donovan
67ac91815b Add a test for the this-spread fix in 976e8c1.
Addresses #1033.
2015-03-16 08:40:32 -07:00
Sebastian McKenzie
976e8c1cfd ignore this expressions in Scope#generateTempBasedOnNode - fixes #1033 2015-03-17 02:20:54 +11:00
Sebastian McKenzie
4d965b0f46 consolidate transformer metadata, remove abstract references, make react transformer optional 2015-03-16 19:26:50 +11:00
Sebastian McKenzie
b495370740 only compile babel folder in src 2015-03-16 19:25:58 +11:00
Sebastian McKenzie
b1c5915ed3 remove playground 2015-03-16 16:56:24 +11:00
Sebastian McKenzie
d94bb2e048 handle comments and use strict directives better - fixes #1030 2015-03-16 13:07:28 +11:00
Sebastian McKenzie
25fa10e592 fix syntax errors 2015-03-16 02:00:19 +11:00
Sebastian McKenzie
8d3a7acbd1 add symbol check to defineProperty helper - fixes #1010 2015-03-16 02:00:10 +11:00
Sebastian McKenzie
29d33dd31a Merge branch 'master' of github.com:babel/babel 2015-03-16 01:52:14 +11:00
Sebastian McKenzie
4afd0f553e Merge branch 'experimental'
# Conflicts:
#	src/babel/transformation/transformers/playground/method-binding.js
2015-03-16 01:51:52 +11:00
Sebastian McKenzie
1fb877e9f5 add highlightErrors option - fixes #837 2015-03-16 01:50:37 +11:00
Sebastian McKenzie
866d3a8eab move file into a separate folder 2015-03-16 01:45:08 +11:00
Sebastian McKenzie
76e1f0dd9f add babelrc to vendor 2015-03-16 01:44:17 +11:00
Sebastian McKenzie
1bbe52a022 split up module class declarations - fixes #1021 2015-03-16 01:44:10 +11:00
Sebastian McKenzie
cc0f43813c small style fixes 2015-03-16 01:26:26 +11:00
Sebastian McKenzie
b13b4bbfba add buildPass File check in preperation for plugin api 2015-03-16 01:25:59 +11:00
Sebastian McKenzie
1c6ac0a07a designate all playground and es7 transformers as optional 2015-03-16 01:25:25 +11:00
Sebastian McKenzie
5a319fd553 automate option generation 2015-03-16 01:23:57 +11:00
Sebastian McKenzie
a8cedf813b Revert "remove es7.abstractReferences, playground.methodBinding and playground.objectGetterMemoisation"
This reverts commit f4ce216d1c.
2015-03-16 01:02:35 +11:00
Sebastian McKenzie
9f037fa75e Merge pull request #1025 from thejameskyle/tjk/fix-flag
Correct --gdbjit v8 flag
2015-03-15 18:41:36 +11:00
James Kyle
8681a78618 Correct --gdbjit v8 flag 2015-03-15 00:39:48 -07:00
Sebastian McKenzie
2d72d423b3 Merge pull request #1024 from thejameskyle/tjk/1020-v8-flags
Add all v8 flags (node & iojs)
2015-03-15 18:35:19 +11:00
James Kyle
280964eafe Add all v8 flags (node & iojs). Fixes #1020 2015-03-15 00:33:39 -07:00
Sebastian McKenzie
5ee9b3c37e remove irrelevant test 2015-03-14 04:50:46 +11:00
Sebastian McKenzie
9676056f08 add note about member expression resolution 2015-03-14 04:50:23 +11:00
Sebastian McKenzie
080a844457 rename "reassigned" to "constant" to reflect purpose of the property better 2015-03-14 04:44:51 +11:00
Sebastian McKenzie
1f9f57a2a6 use paths in replace supers helper 2015-03-14 03:58:18 +11:00
Sebastian McKenzie
056b7fc634 hoist uids to their parent function 2015-03-14 03:58:02 +11:00
Sebastian McKenzie
547ecc2f73 update tests to reflect new for-of behaviour 2015-03-14 03:57:53 +11:00
Sebastian McKenzie
a1ab8fa0c1 remove playground.memoisationOperator deprecation message 2015-03-14 03:57:39 +11:00
Sebastian McKenzie
9e61a307d4 fix scope traversal 2015-03-14 03:34:02 +11:00
Sebastian McKenzie
d4d18f4230 Merge branch 'experimental' of github.com:babel/babel into experimental
# Conflicts:
#	src/babel/transformation/transformers/playground/object-getter-memoization.js
#	src/babel/traversal/path/index.js
#	src/babel/traversal/scope.js
2015-03-14 03:10:17 +11:00
Sebastian McKenzie
f4ce216d1c remove es7.abstractReferences, playground.methodBinding and playground.objectGetterMemoisation 2015-03-14 03:00:41 +11:00
Sebastian McKenzie
d71c72de3c 4.7.12 2015-03-14 02:39:09 +11:00
Sebastian McKenzie
b1c21b8d4d v4.7.12 2015-03-14 02:37:30 +11:00
Sebastian McKenzie
e9b0005cf5 deprecate playground.methodBinding 2015-03-14 02:35:10 +11:00
Sebastian McKenzie
63bac550cd Merge branch 'master' into experimental
# Conflicts:
#	src/babel/transformation/transformers/es6/for-of.js
#	src/babel/transformation/transformers/playground/object-getter-memoization.js
2015-03-14 02:34:03 +11:00
Sebastian McKenzie
d0b6aa9882 4.7.11 2015-03-14 02:30:59 +11:00
Sebastian McKenzie
0e877acfdf v4.7.11 2015-03-14 02:29:42 +11:00
Sebastian McKenzie
b670ee18df fix unicode regex test 2015-03-14 02:28:32 +11:00
Sebastian McKenzie
24807120bf fix unicode regexes stripping their unicode flag before being passed on two regexpu - fixes #1009 2015-03-14 02:26:20 +11:00
Sebastian McKenzie
33f7c0b67e rejigger regex flag pulling 2015-03-14 02:12:13 +11:00
Sebastian McKenzie
c23b47f796 4.7.10 2015-03-14 02:02:06 +11:00
Sebastian McKenzie
2871d8a710 v4.7.10 2015-03-14 01:57:26 +11:00
Sebastian McKenzie
3172b5de5d Merge branch 'master' of github.com:babel/babel 2015-03-14 01:53:15 +11:00
Sebastian McKenzie
2c05303813 deprecate some playground transformers 2015-03-14 01:52:59 +11:00
Sebastian McKenzie
75dda10057 add 4.7.10 changelog 2015-03-14 01:52:51 +11:00
Sebastian McKenzie
12664c6cd6 start migration of core from nodes to paths 2015-03-14 01:48:46 +11:00
Sebastian McKenzie
581f70c803 Merge pull request #1013 from Rich-Harris/patch-1
fix inputSourceMap option
2015-03-14 01:47:55 +11:00
Rich Harris
a00d2c33d8 fix inputSourceMap option
See #827 - it looks like `opts.inputSourceMap` is the wrong way round, babel should only use an input sourcemap if the `inputSourceMap` option is *not* `false`
2015-03-13 10:46:50 -04:00
Sebastian McKenzie
c906bd3edc start migration of core from nodes to paths 2015-03-14 01:00:02 +11:00
Sebastian McKenzie
27fc574e9f 4.7.9 2015-03-13 13:33:50 +11:00
Sebastian McKenzie
a3b1fcc79c v4.7.9 2015-03-13 13:30:14 +11:00
Sebastian McKenzie
491cb26c1f remove console.log 2015-03-13 13:29:13 +11:00
Sebastian McKenzie
7c3d052714 add 4.7.9 changelog 2015-03-13 13:27:40 +11:00
Sebastian McKenzie
4971d0c7f0 fix labeled nested for ofs - fixes #996 2015-03-13 13:25:37 +11:00
Sebastian McKenzie
eb4922b1ec update acorn-babel 2015-03-13 13:25:19 +11:00
Sebastian McKenzie
bb26183b44 set inputSourceMap to null by default 2015-03-13 13:14:17 +11:00
Sebastian McKenzie
4b066f7f1b add input sourcemap false option #827 2015-03-13 13:12:38 +11:00
Sebastian McKenzie
41a8257005 various cleanup, remove redundant whitespace, realign object keys etc 2015-03-13 01:09:04 +11:00
Sebastian McKenzie
b44ba25d11 separate binding logic from scope to a binding class, move binding type resolution to the path so it can be used on any expression - #653 2015-03-13 01:08:46 +11:00
Sebastian McKenzie
40a111abbf always resolve rc for absolute filenames 2015-03-13 01:07:33 +11:00
Sebastian McKenzie
9cff51915d switch scope tracking to a path based system 2015-03-12 14:35:55 +11:00
Sebastian McKenzie
3cd110a7c9 fix block scoping break switch collision - fixes #998 2015-03-12 14:35:30 +11:00
Sebastian McKenzie
a7f9e035a4 infer computed literal function names - fixes #993 2015-03-12 14:13:24 +11:00
Sebastian McKenzie
146b9e6708 4.7.8 2015-03-11 10:17:09 +11:00
Sebastian McKenzie
0953c48620 v4.7.8 2015-03-11 07:49:54 +11:00
Sebastian McKenzie
056b90831d manually define each property in computed class helper - fixes #984 2015-03-11 07:45:29 +11:00
Sebastian McKenzie
8ba276b209 4.7.7 2015-03-11 01:25:41 +11:00
Sebastian McKenzie
8eaa9d29e3 v4.7.7 2015-03-11 01:20:34 +11:00
Sebastian McKenzie
6212791356 fix types API exposure - babel/babel-eslint#8 2015-03-11 01:14:36 +11:00
Sebastian McKenzie
d436d32d82 4.7.6 2015-03-11 00:13:03 +11:00
Sebastian McKenzie
2a29f70bba v4.7.6 2015-03-11 00:11:35 +11:00
Sebastian McKenzie
6ccb8957bd add 4.7.6 changelog 2015-03-11 00:09:52 +11:00
Sebastian McKenzie
dc45415ee0 hoist esModule to the top 2015-03-11 00:08:06 +11:00
Sebastian McKenzie
98ca541fde restructure types 2015-03-11 00:04:06 +11:00
Sebastian McKenzie
8328f638c2 add support for if and block statements to t.toSequenceExpression 2015-03-10 17:20:26 +11:00
Sebastian McKenzie
5586ce280f move build-external-helpers to tools 2015-03-10 17:20:14 +11:00
Sebastian McKenzie
0ca71f5e15 add transformation logger 2015-03-10 17:19:51 +11:00
Sebastian McKenzie
212776e220 remove detection 2015-03-10 17:19:35 +11:00
Sebastian McKenzie
4a95a9ec8f remove duplicate insert_final_newline 2015-03-10 17:19:23 +11:00
Sebastian McKenzie
45953ffc8a 4.7.5 2015-03-10 13:39:04 +11:00
Sebastian McKenzie
9c79290bb2 v4.7.5 2015-03-10 13:20:20 +11:00
Sebastian McKenzie
cfdf6b7385 add 4.7.5 changelog 2015-03-10 13:12:19 +11:00
Sebastian McKenzie
907e0e0f86 drop support for node 0.10 to save travis some unnecessary cycles <3 2015-03-10 13:11:06 +11:00
Sebastian McKenzie
f3bd9cbcb8 use a different helper if a class contains class methods to avoid non-enumerability and delegation to es6.properties.computed transformer - fixes #984, closes #986 2015-03-10 13:04:02 +11:00
Sebastian McKenzie
3bd14f9e07 add babel version to register hook cache key 2015-03-10 13:03:22 +11:00
Sebastian McKenzie
102b4b3d1e remove redundant break wrapping in for-of - fixes #985 2015-03-10 12:14:21 +11:00
Sebastian McKenzie
6564f1ff76 4.7.4 2015-03-10 06:13:37 +11:00
Sebastian McKenzie
58d7a5e069 more versatile scope pushing 2015-03-10 06:13:32 +11:00
Sebastian McKenzie
f5db53cebe remove core-js library from babel-runtime 2015-03-10 06:13:16 +11:00
Sebastian McKenzie
2da010fcae clean up #982 2015-03-10 06:11:55 +11:00
Sebastian McKenzie
52b99bdf93 Merge pull request #982 from tricknotes/error-stack
Ignore assignment to Error#stack if it is readonly property
2015-03-10 06:09:03 +11:00
Ryunosuke SATO
9d7e953451 Ignore assignment to Error#stack if it is readonly property
`Error#stack` may be an readonly property in some environments
such as PhantomJS 1.9.2 and Safari 7.0.
2015-03-10 04:05:53 +09:00
Sebastian McKenzie
b1252b865b v4.7.4 2015-03-10 03:29:47 +11:00
Sebastian McKenzie
068b1341d9 fix erroneous whitespace 2015-03-10 03:28:36 +11:00
Sebastian McKenzie
20eb143915 remove Number from the list of valid runtime constructors - fixes #981 2015-03-10 03:27:13 +11:00
Sebastian McKenzie
1302a86bf2 scope -> scopable class alias key 2015-03-10 03:22:55 +11:00
Sebastian McKenzie
b7831f1d7b prepend mocha command with node 2015-03-10 03:15:31 +11:00
Sebastian McKenzie
e46cabb21f remove code coverage from travis make task 2015-03-10 03:12:50 +11:00
Sebastian McKenzie
fff06a047e Revert "delegate node path removal to after call"
This reverts commit 5e0236d9a7.
2015-03-10 02:50:43 +11:00
Sebastian McKenzie
6b0320fc83 disable test262 tests by default 2015-03-10 02:34:35 +11:00
Sebastian McKenzie
5dde63fa0a more elaborate tests for #980 2015-03-10 02:13:00 +11:00
Sebastian McKenzie
672118149a hoist all directives - fixes #980 2015-03-10 01:53:51 +11:00
Sebastian McKenzie
5e0236d9a7 delegate node path removal to after call 2015-03-10 01:44:58 +11:00
Sebastian McKenzie
5101664e7d update 4.7.4 changelog 2015-03-10 01:44:44 +11:00
Sebastian McKenzie
2d684a06d3 update changelog version to 4.7.4 2015-03-10 01:23:24 +11:00
Sebastian McKenzie
e31bad8f42 add 4.7.3 changelog 2015-03-10 01:17:14 +11:00
Sebastian McKenzie
644b4373fc rewrite named function expressions in async function transformers - fixes #979 2015-03-10 01:16:38 +11:00
Sebastian McKenzie
62f37c1e62 fix util.booleanify 2015-03-10 01:10:58 +11:00
Sebastian McKenzie
fc0e89463b use flow types for annotations - goodbye JSDoc! 2015-03-10 00:35:52 +11:00
Sebastian McKenzie
56b6a795a4 remove path.refreshScope until i'm more confident on it's functionality so it doesn't break peopls stuff 2015-03-09 23:09:22 +11:00
Sebastian McKenzie
17b34a2959 dynamic scope tracking, toot toot - fixes #957 2015-03-09 22:07:05 +11:00
Sebastian McKenzie
c4da0253c5 move flattenable keys to types 2015-03-09 16:55:00 +11:00
Sebastian McKenzie
5f2df40f6d consistent whitespace in patch 2015-03-09 16:54:50 +11:00
Sebastian McKenzie
7d20a9b882 add traversal path todos 2015-03-09 16:54:41 +11:00
Sebastian McKenzie
ee0ac9f149 use spread in messages 2015-03-09 16:54:30 +11:00
Sebastian McKenzie
c5d3f42d8a alias core-js/library in babel-runtime - closes #965 2015-03-09 16:54:19 +11:00
Sebastian McKenzie
d162919a53 update symols transformer name 2015-03-09 03:39:30 +11:00
Sebastian McKenzie
d1f712344d add istanbul auxiliary comment task to makefile 2015-03-09 03:38:39 +11:00
Sebastian McKenzie
e985912b54 add Binary node cleanup 2015-03-09 03:38:27 +11:00
Sebastian McKenzie
97a21e4a34 update spec.typeofSymbol references to es6.symbols 2015-03-09 03:38:13 +11:00
Sebastian McKenzie
d8fb7812f7 more utility.removeConsole tests 2015-03-09 03:37:42 +11:00
Sebastian McKenzie
bfe63f5885 rename spec.typeofSymbol transformer to es6.symbols 2015-03-09 03:37:26 +11:00
Sebastian McKenzie
44ca6873a3 add super to contextVariables 2015-03-09 03:37:05 +11:00
Sebastian McKenzie
2f66ea7338 4.7.3 2015-03-08 04:33:50 +11:00
Sebastian McKenzie
70967cf53c v4.7.3 2015-03-08 04:32:46 +11:00
Sebastian McKenzie
dc117a74ae both -> inline - thanks @dkieks 2015-03-08 04:29:48 +11:00
Sebastian McKenzie
b0f32a822d pass file.addImport a name instead of an identifier 2015-03-08 04:10:53 +11:00
Sebastian McKenzie
fd99ea1749 Merge branch 'master' of github.com:babel/babel 2015-03-08 04:05:44 +11:00
Sebastian McKenzie
572129542d fallback to current parentPath if none was provided 2015-03-08 04:04:48 +11:00
Sebastian McKenzie
6f53980bfc move runtime helpers to separate modules - babel/ember-cli-babel#24 2015-03-08 04:04:40 +11:00
Sebastian McKenzie
348af1990d Merge pull request #972 from neVERberleRfellerER/node-external-helpers-tests
add tests for babel-external-helpers
2015-03-08 03:50:28 +11:00
Ondrej Kraus
bd5f350728 add tests for babel-external-helpers 2015-03-07 17:46:40 +01:00
Sebastian McKenzie
958fa282f4 4.7.2 2015-03-08 03:12:09 +11:00
Sebastian McKenzie
31e6b18346 v4.7.2 2015-03-08 03:09:43 +11:00
Sebastian McKenzie
d17ac92a3f fix changelog version 2015-03-08 03:06:46 +11:00
Sebastian McKenzie
188bcb70f7 add 4.7.1 changelog 2015-03-08 03:03:17 +11:00
Sebastian McKenzie
b8bd11a0e7 fix incorrect builder reference 2015-03-08 03:02:19 +11:00
Sebastian McKenzie
45bc74efe7 use a lookup table instead of an if - #945 2015-03-08 02:57:37 +11:00
Sebastian McKenzie
7eb169a894 Merge pull request #945 from neVERberleRfellerER/helper-globals-fix
Add choice of output format to babel-external-helpers
2015-03-08 02:56:30 +11:00
Sebastian McKenzie
eed4f312d8 add sourceMap both option - closes #966 2015-03-08 02:54:23 +11:00
Sebastian McKenzie
44e4dc970f more es6 2015-03-08 02:52:23 +11:00
Sebastian McKenzie
5d32432e67 split up export variable declarations - fixes #939, fixes #964 2015-03-08 02:52:10 +11:00
Sebastian McKenzie
9c9af6dbbd add utility.removeClass tests and move parentPath setting to setContext - fixes #967 2015-03-08 02:49:58 +11:00
Sebastian McKenzie
70cd650e10 remove dead t.isFalsyExpression and ignore private properties in t.cloneDeep - fixes #962 2015-03-08 02:45:14 +11:00
Sebastian McKenzie
c7bb00d58d ignore case breaks - fixes #963 2015-03-07 17:41:56 +11:00
Ondrej Kraus
623be068c4 add unsupportedOutputType to messages.js 2015-03-07 01:53:34 +01:00
Ondrej Kraus
71f5c9791d replace switch with if-else chain 2015-03-07 01:50:50 +01:00
Ondrej Kraus
3e6e86d073 order template keys by length 2015-03-07 01:50:49 +01:00
Ondrej Kraus
a0fb398ca2 add possibility to select format of external helpers 2015-03-07 01:50:49 +01:00
Ondrej Kraus
71b9f19e6a change to normal UMD (fixes bug with leaking variable in AMD mode) 2015-03-07 01:50:48 +01:00
Ondrej Kraus
c45ce58f0c stop assigning to global in generated helpers code 2015-03-07 01:50:48 +01:00
Sebastian McKenzie
d32f587e3c expose dynamicImports when es6.modules is blacklisted babel/ember-cli-babel#24 2015-03-07 03:31:24 +11:00
Sebastian McKenzie
9e1874ba89 4.7.1 2015-03-07 03:31:05 +11:00
Sebastian McKenzie
35fdc5c5d8 v4.7.1 2015-03-07 02:52:17 +11:00
Sebastian McKenzie
a4035fc257 use convert-source-map package - closes #960 2015-03-07 02:46:15 +11:00
Sebastian McKenzie
42e3dc7a70 inherit all options from input source map 2015-03-07 02:28:33 +11:00
Sebastian McKenzie
cdccf24515 4.7.0 2015-03-07 02:04:58 +11:00
Sebastian McKenzie
c8cd5c108b v4.7.0 2015-03-07 01:59:02 +11:00
Sebastian McKenzie
2b95b876e1 return only constructor if class was a named class with only a constructor/no constructor 2015-03-07 01:50:34 +11:00
Sebastian McKenzie
f801772fc2 add inputSourceMap option - fixes #827, related babel/babel-loader#35 2015-03-07 01:50:07 +11:00
Sebastian McKenzie
8ad678e5bc make it illegal to have a rest on a setter 2015-03-07 01:32:03 +11:00
Sebastian McKenzie
35c49dbef7 merge validation transformers 2015-03-07 01:25:44 +11:00
Sebastian McKenzie
119314df74 update traceur 2015-03-07 01:25:37 +11:00
Sebastian McKenzie
51e336b037 class declarations also have a lexical self binding 2015-03-07 01:25:18 +11:00
Sebastian McKenzie
7d446807a9 remove rogue console.log 2015-03-06 23:40:30 +11:00
Sebastian McKenzie
8afdeaf557 replicate module environment in babel-node -e - closes #695, fixes #592 2015-03-06 23:39:49 +11:00
Sebastian McKenzie
4df50954a2 use instance indexOf instead of lodash - #951 2015-03-06 23:31:11 +11:00
Sebastian McKenzie
70b6317865 Merge pull request #951 from neVERberleRfellerER/babel-node-args-fix
add possiblity of passing colliding user arguments by separating them with --
2015-03-06 23:30:31 +11:00
Sebastian McKenzie
5ebdc44297 remove babel-runtime version check to node api 2015-03-06 23:20:48 +11:00
Sebastian McKenzie
a4659fd239 add reference checks for module specifiers - fixes #956 2015-03-06 23:19:26 +11:00
Sebastian McKenzie
19bfa4a35b add debug message for travis... 2015-03-06 23:15:20 +11:00
Sebastian McKenzie
f7fff7d35e add alternate to list of STATEMENT_OR_BLOCK_KEYS - fixes #955 2015-03-06 23:13:03 +11:00
Sebastian McKenzie
130e0ebe6b better classes, more spec compliant and nicer output - fixes #952 2015-03-06 23:08:10 +11:00
Sebastian McKenzie
69c836fc8d Merge branch 'master' of github.com:babel/babel 2015-03-06 02:27:15 +11:00
Sebastian McKenzie
f62a3ef394 further develop ast paths that represent a single location in the ast as an abstraction around a node-parent relationship 2015-03-06 02:26:04 +11:00
Sebastian McKenzie
7a6e568940 clean up classes output 2015-03-06 02:25:24 +11:00
Sebastian McKenzie
65998c3437 add error message for incompatible babel-runtime versions 2015-03-06 02:23:30 +11:00
Ondrej Kraus
160de340b0 add possiblity of passing user arguments by separating them with --
Now, when user arguments have names colliding with node arguments,
they can be separated by -- and will be parsed correctly.
2015-03-05 14:35:53 +01:00
Sebastian McKenzie
76ca40f698 Merge pull request #944 from sindresorhus/modularize-tofastproperties
modularize `util.toFastProperties()`
2015-03-05 01:10:26 +11:00
Sindre Sorhus
01ed824b5c modularize util.toFastProperties()
https://github.com/sindresorhus/to-fast-properties
2015-03-04 21:02:36 +08:00
Sebastian McKenzie
6b0dbc4486 bump regenerator-babel 2015-03-04 23:29:37 +11:00
Sebastian McKenzie
2648268f30 add contextVariables to scope 2015-03-04 22:54:00 +11:00
Sebastian McKenzie
8cf5bf7037 add filename arg to resolveModuleSource option 2015-03-04 22:53:50 +11:00
Sebastian McKenzie
60961bc3ff bump ast-types - fixes #930 2015-03-04 22:53:38 +11:00
Sebastian McKenzie
df16bc17e7 clean up formatting of system module formatter 2015-03-04 22:52:44 +11:00
Sebastian McKenzie
5337ab5a08 statically bind super references in object expressions - fixes #943 2015-03-04 22:52:07 +11:00
Sebastian McKenzie
2eaeebcce4 inherit from class constructor block statement - fixes #937 2015-03-03 23:38:11 +11:00
Sebastian McKenzie
ad71010144 4.6.6 2015-03-03 22:44:44 +11:00
Sebastian McKenzie
864169c1eb v4.6.6 2015-03-03 22:43:06 +11:00
Sebastian McKenzie
930d7f9aa6 add 4.6.6 changelog 2015-03-03 22:38:20 +11:00
Sebastian McKenzie
ed40ec03d1 more es6, template literals and modules 2015-03-03 22:31:49 +11:00
Sebastian McKenzie
73062ae240 take into consideration non-identifier nodes in es6.blockScopingTDZ transformer, also turn default and parameters into lets instead of vars - fixes #929 2015-03-03 22:30:52 +11:00
Sebastian McKenzie
bafa3e0d4c add missing is - fixes #931 - thanks @neVERberleRfellerER 2015-03-03 10:38:18 +11:00
Sebastian McKenzie
f3d2b2bb81 Merge branch 'master' of github.com:babel/babel 2015-03-03 09:49:35 +11:00
Sebastian McKenzie
a74b67d4eb Merge pull request #932 from hzoo/more-es6
More es6
2015-03-03 09:49:29 +11:00
Sebastian McKenzie
625416862f remove no es6 syntax line from contributing.md 2015-03-03 09:49:20 +11:00
Sebastian McKenzie
8dda8838ba check for body existence before length in dead code elimination transformer - fixes #931 2015-03-03 09:37:52 +11:00
Henry Zhu
96d3a25213 use more es6 concise methods 2015-03-02 10:34:30 -05:00
Sebastian McKenzie
727208f376 4.6.5 2015-03-02 22:55:36 +11:00
Sebastian McKenzie
1b046a6ecb v4.6.5 2015-03-02 22:54:35 +11:00
Sebastian McKenzie
3b8ed0d401 add 4.6.5 changelog 2015-03-02 22:51:21 +11:00
Sebastian McKenzie
d4c98d7738 add transformer aliases 2015-03-02 22:47:00 +11:00
Sebastian McKenzie
4e44af819f fix rogue strict reference 2015-03-02 22:45:21 +11:00
Sebastian McKenzie
a65acd73ca fix rogue useStrict transformer references 2015-03-02 22:41:55 +11:00
Sebastian McKenzie
b7cb2bcb7b rename useStrict transformer to strict 2015-03-02 22:37:51 +11:00
Sebastian McKenzie
5ac4dc0541 don't evaluate ArrayExpressions 2015-03-02 17:16:10 +11:00
Sebastian McKenzie
99ddd02b0a change Function export to avoid messing with istanbul 2015-03-02 15:38:43 +11:00
Sebastian McKenzie
19cfee14fd 4.6.4 2015-03-02 15:38:31 +11:00
Sebastian McKenzie
fea487bf91 v4.6.4 2015-03-02 15:34:10 +11:00
Sebastian McKenzie
ff2cbd5a2e Merge branch 'master' of github.com:babel/babel 2015-03-02 15:30:30 +11:00
Sebastian McKenzie
12e01f9e71 remove optional property on function params - fixes #927 2015-03-02 15:30:05 +11:00
Sebastian McKenzie
f62436909d Merge pull request #923 from mathiasbynens/patch-4
Explicitly update the regexpu dependency to v1.1.2
2015-03-02 11:32:27 +11:00
Mathias Bynens
e42c1adeb6 Explicitly update the regexpu dependency to v1.1.2 2015-03-01 18:50:17 +01:00
Sebastian McKenzie
e30dbbab94 properly replace labels in spec for of transformer - fixes #913, closes #914 2015-03-02 01:41:13 +11:00
Sebastian McKenzie
e3daa28e60 rename minification tests to utility 2015-03-02 01:28:34 +11:00
Sebastian McKenzie
9e5d94126c add base type tests 2015-03-02 01:28:17 +11:00
Sebastian McKenzie
95798bee0b add t.valueToNode 2015-03-02 01:28:10 +11:00
Sebastian McKenzie
63f25ab038 check parent for variable collisions when remapping closurified block scopes - fixes #915, closes #922 2015-03-02 01:27:58 +11:00
Sebastian McKenzie
27a8f2d2ea rename broke property to confident in t.evaluate 2015-03-01 18:16:27 +11:00
Sebastian McKenzie
78434bb404 add t.evaluate method 2015-03-01 17:01:46 +11:00
Sebastian McKenzie
82833a8901 update 4.6.3 changelog 2015-03-01 13:45:09 +11:00
Sebastian McKenzie
93d5288d71 4.6.3 2015-03-01 11:05:33 +11:00
Sebastian McKenzie
5d3074b460 v4.6.3 2015-03-01 11:03:55 +11:00
Sebastian McKenzie
a57475abc9 better rest param member expression deopt 2015-03-01 11:01:06 +11:00
Sebastian McKenzie
09e68d8d46 v4.6.2 2015-03-01 10:12:43 +11:00
Sebastian McKenzie
ee850c3aeb merge fix for #917 with #918 2015-03-01 10:09:03 +11:00
Sebastian McKenzie
ff5a149cec Merge branch 'master' of github.com:babel/babel
# Conflicts:
#	src/babel/transformation/transformers/es6/parameters.rest.js
2015-03-01 10:04:52 +11:00
Sebastian McKenzie
957118fb41 delay rest optimisation, deopt on unoptimisable references - fixes #918 2015-03-01 10:04:16 +11:00
Sebastian McKenzie
e7ad0a9741 Merge pull request #919 from neVERberleRfellerER/rest-args-optimization-fix
fix rest optimization in arrow functions
2015-03-01 09:38:00 +11:00
Ondrej Kraus
24f4b041c7 fix rest optimization in arrow functions and add advanced test 2015-02-28 23:28:21 +01:00
Sebastian McKenzie
4c77d04b56 more es6 modules 2015-03-01 01:01:51 +11:00
Sebastian McKenzie
e945f0d10f add support for outputting flow types - fixes #665 2015-03-01 00:32:36 +11:00
Sebastian McKenzie
fb04b2561f copy over files in watch mode 2015-02-28 21:39:40 +11:00
Sebastian McKenzie
a4f8b41507 4.6.1 2015-02-28 11:56:46 +11:00
Sebastian McKenzie
1fb6018e9c v4.6.1 2015-02-28 11:55:47 +11:00
Sebastian McKenzie
bca233d22c add 4.6.1 changelog 2015-02-28 11:52:21 +11:00
Sebastian McKenzie
c78703e194 blacklist regenerator from templates directory - fixes #912 2015-02-28 11:47:18 +11:00
Sebastian McKenzie
43fdbe3d6c fix whitespace 2015-02-28 11:31:43 +11:00
Sebastian McKenzie
8650ca7d55 properly expose util - fixes #52 2015-02-28 11:24:51 +11:00
Sebastian McKenzie
3a0c226a34 upgrade babel 2015-02-28 00:31:35 +11:00
Sebastian McKenzie
73e8bdd048 update 4.6.0 changelog 2015-02-28 00:31:28 +11:00
Sebastian McKenzie
e7c52a734e 4.6.0 2015-02-27 21:14:20 +11:00
Sebastian McKenzie
5a81b02569 v4.6.0 2015-02-27 21:09:17 +11:00
Sebastian McKenzie
999baf2888 fix regex tests 2015-02-27 21:01:13 +11:00
Sebastian McKenzie
70b25e8942 add sticky regex desugaring #904 2015-02-27 20:51:48 +11:00
Sebastian McKenzie
2ddbd4eecc fix es for of break test expected 2015-02-27 20:33:42 +11:00
Sebastian McKenzie
7520807df3 move eslint out of the core into a separate plugin 2015-02-27 16:30:53 +11:00
Sebastian McKenzie
974b71bcc3 flesh out eslint support 2015-02-27 16:11:47 +11:00
Sebastian McKenzie
0aee3c06ec add noCheckAst option to enforce newline test 2015-02-27 15:45:09 +11:00
Sebastian McKenzie
a4382580fc ignore user whitespace when splitting up module declaration - fixes #906 2015-02-27 15:25:13 +11:00
Sebastian McKenzie
166b2eda87 remove rogue export in node api 2015-02-27 15:08:01 +11:00
Sebastian McKenzie
83c23d266f add eslint with an acorn-babel compatibility layer, yay! coming soon to a production release near you 2015-02-27 13:17:22 +11:00
Sebastian McKenzie
a9db70b60d close iterators on abrupt completion - google/traceur-compiler#1773 #838 2015-02-27 11:44:13 +11:00
Sebastian McKenzie
5d90c442cb fix es6 rest parameters transformer comment 2015-02-26 23:25:48 +11:00
Sebastian McKenzie
32606ddb93 remove linting mention from contributing guide 2015-02-26 22:34:54 +11:00
Sebastian McKenzie
330f6910c6 remove unnecessary exception catch and process.exit - fixes #901 2015-02-26 22:33:36 +11:00
Sebastian McKenzie
4ca8a0e6e2 bump browserify 2015-02-26 21:41:15 +11:00
Sebastian McKenzie
f097ddeac3 bump source-map dependency 2015-02-26 21:39:54 +11:00
Sebastian McKenzie
1eb53dd13a add try-catch to bin watching compilation - fixes #901 2015-02-26 21:28:54 +11:00
Sebastian McKenzie
75b5f32e7a make js-tokens version fixed - explanation in #900 2015-02-26 21:15:54 +11:00
Sebastian McKenzie
f753cf4845 Merge pull request #900 from lydell/js-tokens-1.0
Upgrade to js-tokens@1.0.0
2015-02-26 21:13:55 +11:00
Simon Lydell
9a569f64da Upgrade to js-tokens@1.0.0
This commit also adds syntax highlighting for `null`, `false` and `true`.
2015-02-26 11:11:23 +01:00
Sebastian McKenzie
8efeae80af remove export function Function 2015-02-26 20:39:30 +11:00
Sebastian McKenzie
4df9cf6c05 add missing transform import and change babel import to a wildcard 2015-02-26 20:26:08 +11:00
Sebastian McKenzie
7729cb4b68 start using es6 modules 2015-02-26 20:13:00 +11:00
Sebastian McKenzie
307ffcd107 correctly get old extension handler in registerExtension 2015-02-26 16:00:06 +11:00
Sebastian McKenzie
751557aef1 make #889 more efficient and flexible 2015-02-26 15:24:12 +11:00
Sebastian McKenzie
3f146b54ff Merge branch 'master' of github.com:6to5/6to5 2015-02-26 15:04:21 +11:00
Sebastian McKenzie
19a173c622 Merge pull request #899 from xjamundx/patch-1
feat(6to5/register) don't override uncaughtException handler
2015-02-26 15:04:02 +11:00
Sebastian McKenzie
89bcb307a2 Merge pull request #889 from neVERberleRfellerER/rest-args-optimization-v2
Add rest parameters optimization
2015-02-26 15:03:51 +11:00
Sebastian McKenzie
ded1e02da7 move buildHelpers require down a slot 2015-02-26 13:06:15 +11:00
Sebastian McKenzie
564ba67190 4.5.5 2015-02-26 13:06:08 +11:00
Sebastian McKenzie
00c964ed19 v4.5.5 2015-02-26 13:03:02 +11:00
Sebastian McKenzie
3ab88e02c7 delete from require.extensions when old extension handler is undefined 2015-02-26 12:58:01 +11:00
Sebastian McKenzie
bb2fc830eb use some spreads 2015-02-26 12:57:43 +11:00
Sebastian McKenzie
c6a542fd1d finish remaining class conversion 2015-02-26 12:34:05 +11:00
Sebastian McKenzie
553eb2d45e more classes! 2015-02-26 12:19:28 +11:00
Ondrej Kraus
b5f3c3f4cc stop traversal when it is clear that optimization is impossible 2015-02-26 02:05:26 +01:00
Ondrej Kraus
5d83638583 set literal MemberExpression as computed in rest array destructuring 2015-02-26 01:22:00 +01:00
Sebastian McKenzie
f7186980e5 add external helpers test #898 2015-02-26 09:24:28 +11:00
Sebastian McKenzie
0eaaaa503e 4.5.4 2015-02-26 09:24:10 +11:00
Sebastian McKenzie
51dff364db v4.5.4 2015-02-26 09:21:55 +11:00
Sebastian McKenzie
dc6129eb6a fix helper whitelist in build script 2015-02-26 09:19:49 +11:00
Sebastian McKenzie
5b84b9c867 4.5.3 2015-02-26 09:11:15 +11:00
Sebastian McKenzie
04c3027f4d v4.5.3 2015-02-26 09:10:31 +11:00
Sebastian McKenzie
95e2345b19 move whitelist detection up to before the key is camelcased 2015-02-26 09:08:39 +11:00
Sebastian McKenzie
eafb02be31 4.5.2 2015-02-26 09:08:17 +11:00
Sebastian McKenzie
b91997354c v4.5.2 2015-02-26 09:04:05 +11:00
Sebastian McKenzie
4b8039a00c add 4.5.2 changelog 2015-02-26 09:00:37 +11:00
Sebastian McKenzie
0a0931dc2e add access to helpers used by the current file and allow a helper whitelist to be passed to buildHelpers - closes #898 2015-02-26 08:59:07 +11:00
Jamund Ferguson
24ace3c8c2 feat(6to5/register) don't override uncaughtException handler
Maybe we could do this by default or even make it configurable?
2015-02-25 13:51:26 -08:00
Sebastian McKenzie
372c06eb80 bump acorn-babel 2015-02-26 08:32:27 +11:00
Sebastian McKenzie
b8121ed4d0 Merge branch 'master' of github.com:6to5/6to5 2015-02-26 08:21:49 +11:00
Sebastian McKenzie
1f79445ee5 shim in function arity when proxying named functions - fixes #896 2015-02-26 08:21:37 +11:00
Sebastian McKenzie
cb46ca60af Merge pull request #894 from josh/travis-test-full-build
Test full `make build` on Travis
2015-02-26 08:05:24 +11:00
Joshua Peek
24c0c7679f Test full make build on travis 2015-02-25 10:23:42 -06:00
Ondrej Kraus
687b0f3180 remove unused function argument 2015-02-25 15:38:32 +01:00
Ondrej Kraus
e6855b974b update tests 2015-02-25 15:30:22 +01:00
Ondrej Kraus
a808742c19 remove strict-mode specific optimizations due to unsolvable ambiguities 2015-02-25 15:24:45 +01:00
Sebastian McKenzie
d7ec337567 move spec.functionName transformer to below validation transformers 2015-02-26 01:00:35 +11:00
Sebastian McKenzie
845f1ce65e remove linting since we're too bleeding edge :'( 2015-02-26 01:00:24 +11:00
Ondrej Kraus
c3f4091b6d replace for-of with with for for performance reasons 2015-02-25 14:41:20 +01:00
Ondrej Kraus
edb880f87c add tests 2015-02-25 14:26:28 +01:00
Ondrej Kraus
e8741daee3 use some ES6 to simplify code 2015-02-25 14:13:15 +01:00
Sebastian McKenzie
88563a0c26 add additional newline to alias functions transformer 2015-02-26 00:05:33 +11:00
Sebastian McKenzie
ccd7a6560c simplify README 2015-02-26 00:05:21 +11:00
Sebastian McKenzie
c340597fdb remove docs directory 2015-02-26 00:04:59 +11:00
Sebastian McKenzie
e498358125 classes... i just... no words 2015-02-25 23:47:01 +11:00
Ondrej Kraus
c5913564f8 replace quotes to conform to coding style 2015-02-25 13:34:18 +01:00
Ondrej Kraus
662bddbaca simplify optimization code 2015-02-25 13:34:17 +01:00
Ondrej Kraus
8f540dfff3 call non-strict mode optimizer before strict mode one to simplify literals 2015-02-25 13:34:17 +01:00
Ondrej Kraus
1265bc5a92 add better optimization when strictMode transformer is enabled 2015-02-25 13:34:15 +01:00
Ondrej Kraus
e677c72d58 add patterns support 2015-02-25 13:34:15 +01:00
Ondrej Kraus
8ca854156a simplify and optimize local binding handling 2015-02-25 13:34:14 +01:00
Ondrej Kraus
81ae656358 remove unused function 2015-02-25 13:34:13 +01:00
Ondrej Kraus
f2981b7e95 replace direct node type checking with helper functions 2015-02-25 13:34:12 +01:00
Ondrej Kraus
99b2e00d33 add rest parameters optimization 2015-02-25 13:34:11 +01:00
Sebastian McKenzie
25232d3141 use the mallet operator this is actually amazing i think i'm going to cry 2015-02-25 23:34:04 +11:00
Sebastian McKenzie
5b9878451a use strict BE GONE 2015-02-25 23:07:49 +11:00
Sebastian McKenzie
23d6fb6bb1 concise methods oh my god this is so good 2015-02-25 23:06:57 +11:00
Sebastian McKenzie
8d1b5c8ccb BOLD TEXT ALL UP IN THIS 2015-02-25 23:06:48 +11:00
Sebastian McKenzie
10bd7d1b91 4.5.1 2015-02-25 22:57:59 +11:00
Sebastian McKenzie
f5d9636353 v4.5.1 2015-02-25 22:55:50 +11:00
Sebastian McKenzie
a7f713ef5a remove jscs since it doesn't like arrow functions :( 2015-02-25 22:53:54 +11:00
Sebastian McKenzie
ba11069b1c utilise arrow functions omfg i love ES6 holy shit 2015-02-25 22:52:22 +11:00
Sebastian McKenzie
c13f8a3f50 update contributing guide 2015-02-25 22:43:40 +11:00
Sebastian McKenzie
339bd2b6d9 self-host #443 2015-02-25 22:36:23 +11:00
Sebastian McKenzie
a2843a5cb8 4.5.0 2015-02-25 22:03:38 +11:00
Sebastian McKenzie
c31832439a v4.5.0 2015-02-25 22:02:23 +11:00
Sebastian McKenzie
b7f19221a9 fix rc json error message 2015-02-25 22:00:32 +11:00
Sebastian McKenzie
46a37f4672 fix linting errors 2015-02-25 21:59:59 +11:00
Sebastian McKenzie
cfe2c19a02 fix linting errors 2015-02-25 21:57:49 +11:00
Sebastian McKenzie
649d91ef25 add 4.5.0 changelog 2015-02-25 21:56:23 +11:00
Sebastian McKenzie
4d72bffa30 add --copy-files bin/babel flag 2015-02-25 21:56:19 +11:00
Sebastian McKenzie
5889233adc rejigger path traversal class for es6ification 2015-02-25 21:50:40 +11:00
Sebastian McKenzie
7bb98352df add .babelrc - fixes #351 2015-02-25 21:49:48 +11:00
Sebastian McKenzie
12ebeed7c6 add missing extension to umd-strict formatter... - fixes #890 2015-02-25 19:10:20 +11:00
Sebastian McKenzie
7d87e52377 rejigger strict directives transformer logic so they're included in the body before module formatters are ran - @jayphelps 2015-02-25 17:20:23 +11:00
Sebastian McKenzie
2bab285970 temporarily disable own binding identification in nameMethod helper - fixes #871 2015-02-25 11:07:51 +11:00
Sebastian McKenzie
00651e671e don't copy over non-compilable files - fixes #888 2015-02-25 10:59:26 +11:00
Sebastian McKenzie
37588a6ceb 4.4.6 2015-02-24 22:17:46 +11:00
Sebastian McKenzie
a45d6960da v4.4.6 2015-02-24 22:17:12 +11:00
Sebastian McKenzie
b13aa41a75 fixing linting error 2015-02-24 22:15:27 +11:00
Sebastian McKenzie
20a4ed6140 add 4.4.6 changelog 2015-02-24 22:14:34 +11:00
Sebastian McKenzie
c256e060b3 Merge branch 'master' of github.com:6to5/6to5 2015-02-24 22:11:33 +11:00
Sebastian McKenzie
bef315efd6 fix up JSXElement alias keys 2015-02-24 22:11:25 +11:00
Sebastian McKenzie
2ec5390b63 bump core-js 2015-02-24 22:11:18 +11:00
Sebastian McKenzie
f4c9dd8768 Merge pull request #881 from sindresorhus/bump-chalk
bump `chalk`
2015-02-24 22:06:05 +11:00
Sindre Sorhus
510c7a3e60 bump chalk
https://github.com/sindresorhus/chalk/releases/tag/v1.0.0
2015-02-24 16:03:00 +07:00
Sebastian McKenzie
3ce9508a1c bump core-js @zloirock 2015-02-24 14:16:29 +11:00
Sebastian McKenzie
717ef280f7 clean up #870 2015-02-24 11:20:04 +11:00
Sebastian McKenzie
8c5e7cf272 Merge pull request #870 from neVERberleRfellerER/fix-extends-anon-class
fix extends with empty anonymous base class
2015-02-24 11:18:18 +11:00
Ondrej Kraus
811a843be9 add tests for extends of anonymous classes 2015-02-24 01:01:05 +01:00
Ondrej Kraus
b7c297bb89 remove anonymous class constructor name in specific case
Name of anonymous class constructor is not needed when it contains
exactly one method that is not construtor, because constructor
will be assigned to variable in closure.
2015-02-24 01:01:02 +01:00
Sebastian McKenzie
b7342ef4ea move es6.arrowFunctions transformer - fixes #874 2015-02-24 10:31:11 +11:00
Sebastian McKenzie
1a899f5e77 move attribute whitespace handling to JSXAttribute enter - fixes #872 2015-02-24 09:48:10 +11:00
Sebastian McKenzie
f2eb1643c0 throw deprecation error for @jsx React.DOM usage and crawl all comments for pragmas - fixes #876 2015-02-24 09:38:16 +11:00
neVERberleRfellerER
9621d1bbeb remove unnecessary derived class constructor name 2015-02-23 17:39:42 +01:00
Ondrej Kraus
3cf7b2b761 add name to constructor of extended anonymous class 2015-02-23 17:19:41 +01:00
Sebastian McKenzie
ae8b1e242b remove illegal left for of test 2015-02-23 21:36:42 +11:00
Sebastian McKenzie
eea48f866d allow MemberExpressions in for-of head 2015-02-23 21:31:57 +11:00
Sebastian McKenzie
84d2d7b7d4 add 4.4.5 changelog 2015-02-23 11:11:24 +11:00
Sebastian McKenzie
ea30a619dd bump regenerator-babel 2015-02-23 11:11:19 +11:00
Sebastian McKenzie
87a201db22 4.4.5 2015-02-22 23:27:02 +11:00
Sebastian McKenzie
bcc86c47bc v4.4.5 2015-02-22 23:26:01 +11:00
Sebastian McKenzie
b6df9b583b 4.4.4 2015-02-22 23:23:38 +11:00
Sebastian McKenzie
52ea7b5f59 always use closure wrap - fixes #864 2015-02-22 23:23:34 +11:00
Sebastian McKenzie
7bff8239a1 v4.4.4 2015-02-22 22:50:02 +11:00
Sebastian McKenzie
04d79c1740 fix array unpacking test 2015-02-22 22:46:27 +11:00
Sebastian McKenzie
e387da7c2b upgrade acorn-babel 2015-02-22 22:42:17 +11:00
Sebastian McKenzie
53cf453480 add 4.4.4 changelog 2015-02-22 22:40:18 +11:00
Sebastian McKenzie
341528ee4a fix linting errors 2015-02-22 22:37:51 +11:00
Sebastian McKenzie
5f6808ba92 don't transform flow module nodes 2015-02-22 22:35:47 +11:00
Sebastian McKenzie
0b2f1fedcb don't unpack array when the pattern contains more elements than the corresponding array expression 2015-02-22 22:35:38 +11:00
Sebastian McKenzie
c3c94f0a4a fix options argument to vm.runInThisContext 2015-02-22 22:35:04 +11:00
Sebastian McKenzie
f2d60aab9e optimise named functions depending on whether they contain an assignment/reference - #861 2015-02-22 21:35:08 +11:00
Sebastian McKenzie
ab6bb35a4f make line-numbers and js-tokens versions fixed 2015-02-22 20:55:09 +11:00
Sebastian McKenzie
e11b943514 revert to old named function wrapper - fixes #861 2015-02-22 20:54:47 +11:00
Sebastian McKenzie
b44a6eb297 remove is-keyword-js in favor of esutils #856 2015-02-22 10:51:27 +11:00
Sebastian McKenzie
f3288ddb1f Merge branch 'lydell-error-syntax-highlighting' 2015-02-22 10:49:30 +11:00
Simon Lydell
476aa44a90 improve syntax highlighting in error messages
- Support hexadecimal, octal and binary number literals, template strings, and
  tokenize everything more robustly in general.
- Tokens spanning over several lines (such as multiline strings and comments) no
  longer leak their color into the line number gutter.
- The color scheme is preserved.
- The line numbers are now right-aligned instead of left-aligned, since that's
  how practically every editor does it.
- Superfluos space in the line number gutter has been removed.
2015-02-21 21:20:52 +01:00
Sebastian McKenzie
c5589e9336 Merge pull request #853 from meandmycode/master
build: ensure bootstrap works on windows
2015-02-21 21:43:49 +11:00
Stephen Taylor
404eb2f972 build: ensure bootstrap works on windows 2015-02-21 10:17:28 +00:00
Sebastian McKenzie
366257915e advise users to visit the gitter room before creating an issue in the readme 2015-02-21 19:17:48 +11:00
Sebastian McKenzie
e0cd9bdbe3 4.4.3 2015-02-21 19:14:26 +11:00
Sebastian McKenzie
39854dc088 v4.4.3 2015-02-21 18:13:10 +11:00
Sebastian McKenzie
81132aa942 add 4.4.3 changelog 2015-02-21 18:08:32 +11:00
Sebastian McKenzie
5ba2e6254b check if iterator has a return method before calling it when breaking in a for...of - #838 2015-02-21 18:00:43 +11:00
Sebastian McKenzie
61ea720637 don't traverse into replacement breaks in for-of transformer - thanks @zloirock 2015-02-21 17:55:38 +11:00
Sebastian McKenzie
55357a331d rename selfContained transformer to runtime 2015-02-21 17:20:59 +11:00
Sebastian McKenzie
5deaeba3a0 4.4.2 2015-02-21 14:31:52 +11:00
Sebastian McKenzie
a38ae381e2 v4.4.2 2015-02-21 14:31:07 +11:00
Sebastian McKenzie
9a2e56f003 add moduleId option for specifying a custom module id 2015-02-21 14:29:26 +11:00
Sebastian McKenzie
5bc78b0237 4.4.1 2015-02-21 14:23:36 +11:00
Sebastian McKenzie
c5af8b8694 v4.4.1 2015-02-21 14:23:04 +11:00
Sebastian McKenzie
c637575cab remove tail-call template 2015-02-21 14:21:31 +11:00
Sebastian McKenzie
bc8d49c95c v4.4.0 2015-02-21 14:20:37 +11:00
Sebastian McKenzie
59ff0fd9a9 remove redundant esnext test 2015-02-21 14:18:53 +11:00
Sebastian McKenzie
b1f794eb84 fix linting errors 2015-02-21 14:16:02 +11:00
Sebastian McKenzie
79ab92b5d4 add 4.4.0 changelog 2015-02-21 14:14:50 +11:00
Sebastian McKenzie
f6512b45d5 coerce inferred function name to a valid identifier 2015-02-21 14:11:18 +11:00
Sebastian McKenzie
8065c981dc add iterator.return to for-of breaks - fixes #838 2015-02-21 13:31:14 +11:00
Sebastian McKenzie
7927aa2e18 make use strict directive stateless - fixes #828 2015-02-21 13:06:02 +11:00
Sebastian McKenzie
35bd510930 make react JSX transformer more generic and allow JSX comments - closes #841 2015-02-21 12:53:09 +11:00
Sebastian McKenzie
74186241f9 fix linting errors 2015-02-21 12:41:11 +11:00
Sebastian McKenzie
1effa72a33 remove format options but move compact option to main options 2015-02-21 12:41:03 +11:00
Sebastian McKenzie
b03a806d7c don't append a newline to the last switchcase 2015-02-21 12:27:38 +11:00
Sebastian McKenzie
6220fd9fc3 better control flow for tco continuation - fixes #850 and fixes #822 2015-02-21 12:27:24 +11:00
Sebastian McKenzie
8d92a75190 remove whitespace from the end of the last newline and improve newlines for switches 2015-02-21 03:22:44 +11:00
Sebastian McKenzie
60a7e40140 add website/docs issues reference to the readme 2015-02-21 02:24:28 +11:00
Sebastian McKenzie
299e462a29 unpack array rest elements when given a right hand array expression 2015-02-21 02:09:07 +11:00
Sebastian McKenzie
62556f6102 finish code generator revamp, output is now much nicer and liberal with it's use of newlines 2015-02-20 23:24:11 +11:00
Sebastian McKenzie
f2c5accab3 add getModuleName option - fixes #844 2015-02-20 23:23:50 +11:00
Sebastian McKenzie
15f1978cae Merge branch 'master' of github.com:6to5/6to5 2015-02-20 11:35:46 +11:00
Sebastian McKenzie
710ff548cb improve whitespace handling of code generator, reduce the use of lookaheads, add max newlines of 2 and better newline insertion for generated nodes 2015-02-20 11:35:27 +11:00
Sebastian McKenzie
fbb19fc656 clean up type alias keys 2015-02-20 11:34:43 +11:00
Sebastian McKenzie
e87ef80bc5 add back named methods for classes and add param binding check to spec.functionName transformer 2015-02-20 11:34:00 +11:00
Sebastian McKenzie
aca750e881 Merge pull request #839 from raganwald/patch-1
Links the babel logo in the readme to the home page
2015-02-20 08:00:26 +11:00
Reg Braithwaite
672e55082c link the babel logo in the readme to the home page 2015-02-19 15:46:35 -05:00
Sebastian McKenzie
a49f746700 add end_of_line = lf to editorconfig 2015-02-19 22:00:24 +11:00
Sebastian McKenzie
83cd3bef92 clean up destructuring transformer and optimise array destructuring - closes #749 2015-02-19 19:16:27 +11:00
Sebastian McKenzie
5e4a008a06 make code generator deopt on input >100KB 2015-02-19 10:48:08 +11:00
Sebastian McKenzie
1594efbc20 remove unused whitespace option 2015-02-19 10:47:51 +11:00
Sebastian McKenzie
002be9a05c enable spec.functionName by default 2015-02-19 10:47:44 +11:00
Sebastian McKenzie
8e06db8f7d remove minify binary 2015-02-19 10:47:08 +11:00
Sebastian McKenzie
b1238a1746 Merge branch 'master' of github.com:6to5/6to5 2015-02-19 10:46:47 +11:00
Ingvar Stepanyan
0874f390ff Add explicit return at the end of tail-recursive function.
Issue #822.
2015-02-18 14:44:47 +02:00
Sebastian McKenzie
eeff4ac9d1 add support for a string literal constructor name 2015-02-18 15:06:18 +11:00
Sebastian McKenzie
8f0ffc7302 4.3.0 2015-02-18 15:05:56 +11:00
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
Sebastian McKenzie
55dfb423ee v3.6.4 2015-02-14 13:26:59 +11:00
Sebastian McKenzie
9d1bc4817d fix flow module type stripping 2015-02-14 13:24:39 +11:00
Sebastian McKenzie
fc8666e7a4 3.6.3 2015-02-14 13:22:18 +11:00
Sebastian McKenzie
07b6881d67 add support for flow type casts and module types 2015-02-14 13:22:13 +11:00
Sebastian McKenzie
1f208a06db v3.6.3 2015-02-14 13:01:17 +11:00
Sebastian McKenzie
b5c9c84542 update bin/6to5 tests to reflect new source location 2015-02-14 12:59:31 +11:00
Sebastian McKenzie
492555bb4e fix linting errors 2015-02-14 12:54:44 +11:00
Sebastian McKenzie
53d88c0f63 upgrade acorn-6to5 2015-02-14 12:53:54 +11:00
Sebastian McKenzie
8a5da57162 use default property on 6to5-runtime modules - fixes #774 2015-02-14 00:59:34 +11:00
Sebastian McKenzie
1627e2f47e use sourceFileName instead of sourceMapName - fixes #775 2015-02-14 00:44:32 +11:00
Sebastian McKenzie
e195d6ca55 use relative location when generating the sourceMapName in bin/6to5 for directories - fixes #775 2015-02-13 23:08:47 +11:00
Sebastian McKenzie
71d5d4fb2c remove MemberExpression from binding identifier collection 2015-02-13 21:10:23 +11:00
Sebastian McKenzie
dfe13cda0d 3.6.2 2015-02-13 21:08:14 +11:00
Sebastian McKenzie
a4c6660d21 v3.6.2 2015-02-13 21:07:45 +11:00
Sebastian McKenzie
9676666e7c 3.6.1 2015-02-13 21:05:56 +11:00
Sebastian McKenzie
388133642d add support for UnaryExpression to getBindingIdentifiers and add it as a reassignment in the scope tracking 2015-02-13 21:05:52 +11:00
Sebastian McKenzie
23b5eeb72f use Symbol.iterator in for symbol detection and add the conversion of it to the selfContained transformer - @zloirock 2015-02-13 21:05:21 +11:00
Sebastian McKenzie
db36c3a7c2 v3.6.1 2015-02-13 20:50:37 +11:00
Sebastian McKenzie
e841b88cbc fix 6to5-node test collisions 2015-02-13 20:48:52 +11:00
Sebastian McKenzie
3d874f2479 update sliceToArray helper, again... 2015-02-13 20:45:43 +11:00
Sebastian McKenzie
228719102a update sliceToArray tests 2015-02-13 20:39:37 +11:00
Sebastian McKenzie
c6ce1a248c better slicedToArray helper 2015-02-13 20:38:28 +11:00
Sebastian McKenzie
ba9b85f64b only use functions returnType if it hasn't been reassigned 2015-02-13 20:36:43 +11:00
Sebastian McKenzie
56c868efee fix incorrect generateUid references in File 2015-02-13 18:27:53 +11:00
Sebastian McKenzie
1f3c3832ba fix linting errors 2015-02-13 18:25:34 +11:00
Sebastian McKenzie
3b04a8c648 fix linting errors 2015-02-13 18:24:24 +11:00
Sebastian McKenzie
2270057b54 add 3.6.1 changelog 2015-02-13 18:23:46 +11:00
Sebastian McKenzie
c3206aa9a4 move File::generateUid to Scope and add return type inferrence 2015-02-13 18:21:28 +11:00
Sebastian McKenzie
1912d1b26a remove ExportSpecifier from t.getBindingIdentifiers as it has none 2015-02-13 18:19:27 +11:00
Sebastian McKenzie
9208e7e594 update common standard import test 2015-02-13 17:47:46 +11:00
Sebastian McKenzie
ce332b3384 fix module binding resolution - fixes #762 2015-02-13 17:37:35 +11:00
Sebastian McKenzie
a567531f77 ignore member expressions in constants transformer - fixes #770 2015-02-13 17:18:42 +11:00
Sebastian McKenzie
9cce72def0 update tests that use the toSlicedArray helper 2015-02-13 17:04:18 +11:00
Sebastian McKenzie
2d8581c6dc Merge branch 'master' of github.com:6to5/6to5
Conflicts:
	lib/6to5/transformation/transformers/minification/dead-code-elimination.js
2015-02-13 16:54:09 +11:00
Sebastian McKenzie
14a000396a add error message to the sliced-to-array helper on a non-iterable param - fixes #766 2015-02-13 16:50:03 +11:00
Sebastian McKenzie
4c41f5a22f bump acorn-6to5 and 6to5 devDependency 2015-02-13 15:09:28 +11:00
Sebastian McKenzie
6be2a6e02a add extra note to minification dead code elimination transformer 2015-02-13 15:09:17 +11:00
Sebastian McKenzie
0a4fc16ca0 add type inferrence that expires when a binding is reassigned 2015-02-13 15:08:58 +11:00
Sebastian McKenzie
25d8377411 normalise JSX attribute strings 2015-02-13 15:08:39 +11:00
Brian Donovan
14267a788d Fix a typo. 2015-02-12 19:12:09 -08:00
Sebastian McKenzie
ba5c5760b1 Merge pull request #769 from 6to5/if-truthy-minification-returns-consequent
Return the consequent if the test is truthy.
2015-02-13 14:08:32 +11:00
Brian Donovan
49904b3ab3 Fix a small grammar issue. 2015-02-12 19:07:54 -08:00
Brian Donovan
a212f035e4 Return the consequent if the test is truthy. 2015-02-12 19:06:06 -08:00
Brian Donovan
ea471a6a17 Fix a few typos. 2015-02-12 18:47:08 -08:00
Brian Donovan
f5bae0b696 Remove redundant variable. 2015-02-12 18:46:53 -08:00
Brian Donovan
9ec9e13aeb Update the jsdoc to indicate that key is optional. 2015-02-12 18:36:36 -08:00
Brian Donovan
0b042b2681 Use the posessive form of "its", not a contraction of "it is". 2015-02-12 18:36:02 -08:00
Brian Donovan
83b4d12884 Correct a jsdoc comment parameter name. 2015-02-12 18:35:35 -08:00
Brian Donovan
98d555498d Remove unused variable. 2015-02-12 18:29:14 -08:00
Sebastian McKenzie
fdc05cb977 Merge pull request #767 from 6to5/templates-should-not-recurse
Ensure that templates do not recurse.
2015-02-13 11:13:30 +11:00
Brian Donovan
928ebda5bc Ensure that templates do not recurse.
Closes #765.
2015-02-12 16:10:13 -08:00
Sebastian McKenzie
0a2003af66 3.6.0 2015-02-12 21:59:37 +11:00
Sebastian McKenzie
02392635ef v3.6.0 2015-02-12 21:57:18 +11:00
Sebastian McKenzie
298cfac7f4 fix linting errors 2015-02-12 21:55:31 +11:00
Sebastian McKenzie
476b683f0f upgrade core-js 2015-02-12 21:53:51 +11:00
Sebastian McKenzie
5c5b66df54 add 3.6.0 changelog 2015-02-12 21:53:45 +11:00
Sebastian McKenzie
e7f6572a3b track arrays to avoid turning something into an array multiple times - closes #757 2015-02-12 21:30:48 +11:00
Sebastian McKenzie
e9cfd2df3e fix toConsumableArray helper 2015-02-12 16:53:00 +11:00
Sebastian McKenzie
a425136680 allow loose = true as an alias for loose = "all" 2015-02-12 16:36:17 +11:00
Sebastian McKenzie
8d06a4301c pdate tests to reflect toConsumableArray updates 2015-02-12 16:35:55 +11:00
Sebastian McKenzie
1909a16dc7 copy over files that we can't compile when specifying a directory in bin/6to5 2015-02-12 16:35:41 +11:00
Sebastian McKenzie
3bfa1f610c add bootstrapping base 2015-02-12 16:35:04 +11:00
Sebastian McKenzie
4faf2b7730 fix namespace name 2015-02-12 16:00:54 +11:00
Sebastian McKenzie
4e5d6ee976 rice up toConsumableArray helper 2015-02-12 16:00:43 +11:00
Sebastian McKenzie
afb1ee79a1 fix autoenabling of playground/experimental when used in whitelist/optional 2015-02-12 16:00:26 +11:00
Sebastian McKenzie
efe3f30741 make minification.renameLocalVariables work 2015-02-12 07:46:34 +11:00
Sebastian McKenzie
5ff0285ba7 use space helper instead of pushing a space in IfStatement generation 2015-02-12 07:46:21 +11:00
Sebastian McKenzie
d7bea2f325 remove legacy jshint comment 2015-02-12 07:46:03 +11:00
Sebastian McKenzie
32316ad942 clean up t.is 2015-02-12 07:45:55 +11:00
Sebastian McKenzie
7953eb560e force experimental and playground flag when whitelisting/optionalising transformers 2015-02-12 07:45:50 +11:00
Sebastian McKenzie
faa10df84c add toConsumableArray helper for spread - fixes #757 2015-02-12 07:37:40 +11:00
Sebastian McKenzie
ae344aa23e recurse over and duplicate array in toArray in order to handle sparse arrays - fixes #754 2015-02-12 00:33:04 +11:00
Sebastian McKenzie
e0bfc72700 fix tail call deopt check 2015-02-11 20:16:50 +11:00
Sebastian McKenzie
bf8f80faf7 add general support for declarations to Scope::rename - closes #751 2015-02-11 20:14:41 +11:00
Sebastian McKenzie
77fa8bf01c fix isReferenced on AssignmentPattern 2015-02-11 20:14:21 +11:00
Sebastian McKenzie
34ca1ac04f delay binding reassignment to after reference replacements - #751 2015-02-11 19:48:54 +11:00
Sebastian McKenzie
85d33536e0 add deopt logging to tail call transformer 2015-02-11 15:59:15 +11:00
Sebastian McKenzie
a4932e0e0f add messages to make it easier to make error messages 2015-02-11 15:57:30 +11:00
Sebastian McKenzie
4ebd0a1e8a upgrade regenerator-6to5 2015-02-11 12:12:43 +11:00
Sebastian McKenzie
14e92e9e3f remove kexec from optionalDependencies 2015-02-11 12:00:38 +11:00
Sebastian McKenzie
13687d98ed bump regenerator-6to5 2015-02-11 11:52:16 +11:00
Sebastian McKenzie
db93c52182 opt out of tail recursion optimisation if the owner id has been reassigned - fixes #744 2015-02-11 11:27:50 +11:00
Sebastian McKenzie
56a953df64 add basic support for class property initializers - #619 2015-02-11 10:59:44 +11:00
Sebastian McKenzie
c38edbbb42 Merge branch 'master' of github.com:6to5/6to5 2015-02-11 08:29:08 +11:00
Sebastian McKenzie
017bb6427a Merge pull request #743 from chicoxyzzy/master
optimise lodash usage
2015-02-11 08:28:58 +11:00
Sebastian McKenzie
714ad40cb0 update contributing guide 2015-02-11 08:28:47 +11:00
Ingvar Stepanyan
904a72fb3a Fix rename not establishing binding. 2015-02-10 17:18:46 +02:00
chico
146835e0f1 fix broken code, lint and codestyle fixes 2015-02-10 18:16:54 +03:00
chico
79ba97872c optimise lodash usage; change contains function to includes for convenience 2015-02-10 17:40:53 +03:00
Sebastian McKenzie
897566ccb3 more reliable scope construction 2015-02-11 00:38:59 +11:00
Sebastian McKenzie
4df1b6700b remove acorn node patching 2015-02-11 00:37:59 +11:00
Sebastian McKenzie
50f903caf7 proper optional builder keys 2015-02-11 00:13:27 +11:00
Sebastian McKenzie
7b8118d8bd default newName in scope.rename to a new uid 2015-02-11 00:13:21 +11:00
Sebastian McKenzie
0c1e1e757c default optional builder keys to false 2015-02-11 00:02:51 +11:00
Sebastian McKenzie
62fa583fc1 fix linting errors 2015-02-10 23:55:11 +11:00
Sebastian McKenzie
8598000a69 restructure Scope API and internal data structure 2015-02-10 23:52:23 +11:00
Sebastian McKenzie
edc8bee38e test for falsy nodes in tail call transformer subtransform 2015-02-10 22:39:46 +11:00
Sebastian McKenzie
45b70d7fba fix bad ctrl+f Class -> ClassTransformer replacement 2015-02-10 22:39:21 +11:00
Sebastian McKenzie
49a53b26bb add scope renaming helper method - fixes #645 - @RReverser 2015-02-10 22:39:07 +11:00
Sebastian McKenzie
329b4e9d21 append Transformer to the end of transformer classes 2015-02-10 22:12:36 +11:00
Sebastian McKenzie
f1bca0013e refactor tail call transformer into a class - @RReverser 2015-02-10 22:11:22 +11:00
Sebastian McKenzie
87af83f1cb Merge pull request #742 from douglasduteil/patch-1
chore(travis): run tests on nodejs 0.12 too
2015-02-10 20:30:30 +11:00
Douglas Duteil
5156574bf2 chore(travis): run tests on nodejs 0.12 too 2015-02-10 10:29:05 +01:00
Sebastian McKenzie
ac098255be fix allowPartial in t.buildMatchMemberExpression 2015-02-10 18:34:16 +11:00
Sebastian McKenzie
47b803ef24 remove old tail call transformer 2015-02-10 18:33:51 +11:00
Sebastian McKenzie
7f61c8b65e add descriptor falsy check to defaults helper - #739 2015-02-10 18:33:29 +11:00
Sebastian McKenzie
4fa9aa63a3 Merge branch 'better-tail-recursion' 2015-02-10 18:04:05 +11:00
Sebastian McKenzie
d582c7c93a Merge pull request #739 from lukescott/defaults-fix
fix defaults helper in strict mode - #738
2015-02-10 18:00:26 +11:00
Sebastian McKenzie
6266f5b924 finish minification.removeConsoleCall transformer #740 2015-02-10 17:56:31 +11:00
Luke Scott
c6920a0e60 fix defaults helper in strict mode - #738 2015-02-09 20:38:57 -08:00
Sebastian McKenzie
825d84ba52 fix defaults helper iteration - #738 2015-02-10 13:20:19 +11:00
Sebastian McKenzie
94a0eb5b06 copy over descriptors and handle non-enumerable properties in defaults helper - fixes #738 2015-02-10 13:06:26 +11:00
Sebastian McKenzie
b6d708caf2 add SpreadProperty to t.getBindingIdentifiers - fixes #734 2015-02-10 09:04:27 +11:00
Ingvar Stepanyan
0d542b61d3 Performance improvements for TCO.
http://jsperf.com/tco/17
2015-02-09 19:00:31 +02:00
Ingvar Stepanyan
5a842ab623 Fix statement substitution in templates. 2015-02-09 17:34:59 +02:00
Sebastian McKenzie
26d4b5f2cf normalise opts.sourceRoot path - 6to5/karma-6to5-preprocessor#5 2015-02-09 23:38:54 +11:00
Sebastian McKenzie
ba0dfac53d add uid scope kind 2015-02-09 21:28:51 +11:00
Sebastian McKenzie
8a4296a948 remove binding kind from pushing bindings to the function scope, better block scoped collision logic, and track label ids as references 2015-02-09 21:21:25 +11:00
Sebastian McKenzie
478f9e028f put function params into the param kind 2015-02-09 20:16:38 +11:00
Sebastian McKenzie
c4e56894d9 ignore hoisted kind when checking for block scoped collisions 2015-02-09 20:03:59 +11:00
Sebastian McKenzie
c6f13844ed move FunctionDeclarations into a hoisted kind 2015-02-09 19:53:46 +11:00
Sebastian McKenzie
5e81653680 change function params binding kind to let 2015-02-09 19:45:03 +11:00
Sebastian McKenzie
8e2df3f1f9 add kinds to binding registration and rename declaration scope methods to bindings 2015-02-09 19:42:52 +11:00
Sebastian McKenzie
a2cc384172 move rest parameters transformer above default parameters 2015-02-09 10:59:31 +11:00
Sebastian McKenzie
d37bf292a1 rename declarationKinds to bindingKinds in scope tracker 2015-02-09 10:59:20 +11:00
Sebastian McKenzie
70eb641530 fix element name in default parameters 2015-02-09 08:46:06 +11:00
Sebastian McKenzie
f845a9b2c4 ignore binding elements when finding the last non-default param - fixes #723 2015-02-09 08:25:58 +11:00
Sebastian McKenzie
ee5cb8d9ed clean up tail call transformer 2015-02-08 22:47:50 +11:00
Sebastian McKenzie
9020a21ba2 3.5.3 2015-02-08 22:17:36 +11:00
2323 changed files with 94334 additions and 15437 deletions

6
.babelrc Normal file
View File

@@ -0,0 +1,6 @@
{
"stage": 0,
"loose": ["all"],
"blacklist": ["es6.tailCall"],
"optional": ["optimisation.flow.forOf"]
}

View File

@@ -4,7 +4,7 @@ root = true
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
[*.{js,json}]
indent_style = space

1
.eslintignore Normal file
View File

@@ -0,0 +1 @@
src/babel/transformation/templates

25
.eslintrc Normal file
View File

@@ -0,0 +1,25 @@
{
"parser": "babel-eslint",
"rules": {
"strict": 0,
"no-underscore-dangle": 0,
"curly": 0,
"no-multi-spaces": 0,
"key-spacing": 0,
"no-return-assign": 0,
"consistent-return": 0,
"no-shadow": 0,
"comma-dangle": 0,
"no-use-before-define": 0,
"no-empty": 0,
"new-parens": 0,
"no-cond-assign": 0,
"no-fallthrough": 0,
"new-cap": 0,
"no-loop-func": 0,
"no-unreachable": 0
},
"env": {
"node": true
}
}

14
.gitignore vendored
View File

@@ -1,6 +1,6 @@
.DS_Store
node_modules
test/tmp
test/core/tmp
*.log
*.cache
/templates.json
@@ -8,8 +8,10 @@ test/tmp
/browser.js
/browser-polyfill.js
/runtime.js
coverage
dist
.package.json
packages/6to5-runtime/*.js
packages/6to5-runtime/regenerator/*.js
/coverage
/dist
/.package.json
/packages/babel-runtime/core-js
/packages/babel-runtime/helpers/*.js
/packages/babel-runtime/regenerator/*.js
/lib

9
.gitmodules vendored
View File

@@ -1,12 +1,3 @@
[submodule "vendor/traceur"]
path = vendor/traceur
url = https://github.com/google/traceur-compiler
[submodule "vendor/regenerator"]
path = vendor/regenerator
url = https://github.com/6to5/regenerator-6to5
[submodule "vendor/test262"]
path = vendor/test262
url = https://github.com/tc39/test262
[submodule "vendor/compat-table"]
path = vendor/compat-table
url = https://github.com/kangax/compat-table

58
.jscsrc
View File

@@ -1,58 +0,0 @@
{
"excludeFiles": ["lib/6to5/transformation/templates"],
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowYodaConditions": true,
"disallowKeywords": [ "with" ],
"disallowMultipleLineBreaks": true,
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireBlocksOnNewline": 1,
"requireCommaBeforeLineBreak": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireSpacesInForStatement": true,
"requireCurlyBraces": [
"do"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"typeof",
"function"
],
"validateLineBreaks": "LF",
"validateQuoteMarks": "\"",
"validateIndentation": 2
}

View File

@@ -1 +0,0 @@
lib/6to5/transformation/templates

View File

@@ -1,27 +0,0 @@
{
"esnext": true,
"indent": 2,
"freeze": true,
"validthis": true,
"camelcase": true,
"unused": true,
"eqnull": true,
"newcap": true,
"supernew": true,
"noyield": true,
"evil": true,
"node": true,
"boss": true,
"expr": true,
"undef": true,
"maxparams": 5,
"maxdepth": 4,
"globals": {
"window": true,
"suite": true,
"set": true,
"before": true,
"bench": true
}
}

View File

@@ -1,15 +1,15 @@
node_modules
*.log
*.cache
lib/6to5/transformation/templates
test
benchmark
Makefile
.*
dist
tests.json
CHANGELOG.md
.package.json
coverage
vendor
packages
/lib/babel/transformation/templates
/test
/benchmark
/Makefile
/dist
/tests.json
/CHANGELOG.md
/.package.json
/coverage
/vendor
/packages
/src

View File

@@ -1,12 +1,11 @@
sudo: false
#sudo: false
language: node_js
cache:
directories:
- node_modules
node_js:
- "0.10"
- "0.11"
branches:
except:
- experimental
- "0.12"
- "iojs"
before_script: "npm install -g codeclimate-test-reporter"
script: "make test-travis"

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

@@ -1,46 +1,175 @@
# NOTE: BEFORE OPENING AN ISSUE PLEASE SEE THE [README](https://github.com/babel/babel#readme).
----
<p align="center">
<strong><a href="#setup">Setup</a></strong>
|
<strong><a href="#running-tests">Running tests</a></strong>
|
<strong><a href="#workflow">Workflow</a></strong>
|
<strong><a href="#dependencies">Dependencies</a></strong>
|
<strong><a href="#code-standards">Code Standards</a></strong>
</p>
----
# Contributing
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).
Contributions are always welcome, no matter how large or small. Before
contributing, please read the
[code of conduct](https://github.com/babel/babel/blob/master/CODE_OF_CONDUCT.md).
## Developing
>Note: Babel moves fast. Only the latest release is guaranteed to build correctly.
>Older releases are not officially supported. If you attempt to build them, do that at your own risk.
#### Setup
```sh
$ git clone https://github.com/babel/babel
$ cd babel
$ make bootstrap
```
Then you can either run:
```sh
$ make build-core
```
to build Babel **once** or:
```sh
$ make watch-core
```
to have Babel build itself then incrementally build files on change.
#### Running tests
You can run tests via:
```sh
$ make test
```
This is mostly overkill and you can limit the tests to a select few by directly
running them with `mocha`:
```sh
$ mocha test/core/transformation.js
```
Use mocha's `--grep` option to run a subset of tests by name:
```sh
$ mocha test/core/transformation.js --grep es7
```
If you don't have `mocha` installed globally, you can still use it from Babel's
dependencies in `node_modules`, but make sure `node_modules/.bin` is added to
your [`$PATH`](http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path) environment variable.
#### 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
* Ensure the test are passing (`make test`)
* Create new pull request explaining your proposed change or reference an issue in your commit message
#### Dependencies
+ [ast-types](http://ghub.io/ast-types) This is required to monkeypatch regenerators AST definitions. Could be improved in the future.
+ [chalk](http://ghub.io/chalk) This is used for terminal color highlighting for syntax errors.
+ [convert-source-map](http://ghub.io/convert-source-map) Turns a source map object into a comment etc.
+ [core-js](http://ghub.io/core-js) Used for the polyfill.
+ [debug](http://ghub.io/debug) Used to output debugging information when NODE_DEBUG is set to babel.
+ [detect-indent](http://ghub.io/detect-indent) This is used in the code generator so it can infer indentation.
+ [estraverse](http://ghub.io/estraverse) The only method on this is attachComments. I'd like to implement our own comment attachment algorithm eventually though.
+ [esutils](http://ghub.io/esutils) Various ES related utilities. Check whether something is a keyword etc.
+ [fs-readdir-recursive](http://ghub.io/fs-readdir-recursive) Recursively search a directory for.
+ [globals](http://ghub.io/globals) A list of JavaScript global variables. This is used by the scope tracking to check for colliding variables.
+ [is-integer](http://ghub.io/is-integer) Checks if something is an integer.
+ [js-tokens](http://ghub.io/js-tokens) This is used to get tokens for syntax error highlighting.
+ [leven](http://ghub.io/leven) A levenstein algorithm to determine how close a word is to another. This is used to offer suggestions when using the utility.undeclaredVariableCheck transformer.
+ [line-numbers](http://ghub.io/line-numbers) Used to produce the code frames in syntax errors.
+ [lodash](http://ghub.io/lodash) Used for various utilities.
+ [minimatch](http://ghub.io/minimatch) This is used to match glob-style ignore/only filters.
+ [output-file-sync](http://ghub.io/output-file-sync) Synchronously writes a file and create its ancestor directories if needed.
+ [path-is-absolute](http://ghub.io/path-is-absolute) Checks if a path is absolute. C:\foo and \foo are considered absolute.
+ [regenerator](http://ghub.io/regenerator) This is used to transform generators/async functions.
+ [regexpu](http://ghub.io/regexpu) Used to transform unicode regex patterns.
+ [repeating](http://ghub.io/repeating) Repeats a string.
+ [shebang-regex](http://ghub.io/shebang-regex) Literally just a regex that matches shebangs.
+ [slash](http://ghub.io/slash) Normalises path separators.
+ [source-map](http://ghub.io/source-map) Generates sourcemaps.
+ [source-map-support](http://ghub.io/source-map-support) Adds source map support to babel-node/babel/register.
+ [strip-json-comments](http://ghub.io/strip-json-comments) Remove comments from a JSON string. This is used for .babelrc files.
+ [to-fast-properties](http://ghub.io/to-fast-properties) A V8 trick to put an object into fast properties mode.
+ [trim-right](http://ghub.io/trim-right) Trims the rightside whitespace.
+ [user-home](http://ghub.io/user-home) Gets the users home directory. This is used to resolve the babel-node/babel/register cache.
#### Code Standards
* **General**
* No ES6 syntax features or methods, exclusively ES5.
* Max of five arguments for functions
* Max depth of four nested blocks
* 2-spaced soft tabs
* **Naming**
* CamelCase all class names
* camelBack all variable names
* **Spacing**
* Spaces after all keywords
* Spaces before all left curly braces
* **Comments**
* Use JSDoc-style comments for methods
* Single-line comments for ambiguous code
* **Quotes**
* Always use double quotes
* Only use single quotes when the string contains a double quote
* **Declaration**
* No unused variables
* No pollution of global variables and prototypes
## Testing
$ make test
## Linting
$ make lint

View File

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

103
Makefile
View File

@@ -1,75 +1,82 @@
MAKEFLAGS = -j1
BROWSERIFY_CMD = node_modules/browserify/bin/cmd.js
ISTANBUL_CMD = node_modules/istanbul/lib/cli.js cover
UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs
#UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs --mangle sort
JSHINT_CMD = node_modules/jshint/bin/jshint
MOCHA_CMD = node_modules/mocha/bin/_mocha
JSCS_CMD = node_modules/jscs/bin/jscs
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
.PHONY: clean test test-cov test-clean test-travis test-simple test-all test-browser test-parser publish build bootstrap publish-core publish-runtime build-core watch-core build-core-test clean-core
build-core: clean-core
node $(BABEL_CMD) src --out-dir lib --copy-files
build-core-test: clean-core
node $(BABEL_CMD) src --out-dir lib --copy-files --auxiliary-comment "istanbul ignore next"
watch-core: clean-core
node $(BABEL_CMD) src --out-dir lib --watch --copy-files
clean-core:
rm -rf lib
lint:
eslint src/babel
build:
mkdir -p dist
make build-core
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 packages/babel-cli/bin/babel-external-helpers >dist/external-helpers.js
node $(UGLIFY_CMD) dist/external-helpers.js >dist/external-helpers.min.js
rm -rf templates.json
clean:
rm -rf coverage templates.json test/tmp dist
lint:
$(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin
$(JSCS_CMD) lib bin
rm -rf coverage templates.json test/tmp dist lib
test-clean:
rm -rf test/tmp
test: lint
$(MOCHA_CMD)
test: test-parser
node $(MOCHA_CMD) test/core
make test-clean
test-simple:
# excludes test262
export SIMPLE_6TO5_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; \
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
make build-core-test
node $(ISTANBUL_CMD) $(MOCHA_CMD) -- test/core
test-travis: bootstrap
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
test-parser:
node test/acorn/run.js
test-travis: bootstrap lint build test
test-browser:
mkdir -p dist
node tools/cache-templates
node tools/cache-tests
node $(BROWSERIFY_CMD) -e test/_browser.js >dist/6to5-test.js
node tools/build-tests
node $(BROWSERIFY_CMD) -e test/core/_browser.js >dist/babel-test.js
rm -rf templates.json tests.json
test -n "`which open`" && open test/browser.html
publish:
publish: lint
git pull --rebase
make test
@@ -78,9 +85,15 @@ publish:
npm version $$version --message "v%s"
make build
cp dist/6to5.min.js browser.js
cp dist/polyfill.min.js browser-polyfill.js
cp dist/runtime.min.js runtime.js
cp dist/babel.js browser.js
cp dist/babel.min.js browser.min.js
cp dist/polyfill.js browser-polyfill.js
cp dist/polyfill.min.js browser-polyfill.min.js
cp dist/external-helpers.js external-helpers.js
cp dist/external-helpers.min.js external-helpers.min.js
node tools/cache-templates
test -f templates.json
@@ -89,29 +102,27 @@ publish:
git push --follow-tags
make publish-core
make publish-cli
make publish-runtime
rm -rf templates.json browser.js browser-polyfill.js runtime.js
rm -rf templates.json browser.js browser.min.js browser-polyfill.js browser-polyfill.min.js external-helpers.js external-helpers.min.js
publish-runtime:
cd packages; \
node build-runtime.js; \
cd 6to5-runtime; \
cd babel-runtime; \
npm publish
publish-core:
tools/generate-core-package-json >package2.json
mv package.json .package.json
mv package2.json package.json
publish-cli:
cd packages; \
node build-cli.js; \
cd babel-cli; \
npm publish
rm -rf package.json
mv .package.json package.json
bootstrap:
npm list --global --depth 1 babel >/dev/null 2>&1 && npm uninstall -g babel || true
npm install
npm link
cd packages/babel-cli && npm install && npm link && npm link babel-core
git submodule update --init
cd vendor/regenerator; npm install
cd vendor/compat-table; npm install object-assign
make build

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,21 @@
<p align="center">
<img alt="6to5" src="https://raw.githubusercontent.com/6to5/logo/master/logo.png" width="546">
<a href="https://babeljs.io/">
<img alt="babel" src="https://raw.githubusercontent.com/babel/logo/master/logo.png" width="546">
</a>
</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 compiler 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 questions and support please visit the <a href="https://gitter.im/babel/babel">gitter room</a> or <a href="http://stackoverflow.com/questions/tagged/babeljs">StackOverflow</a>. The Babel issue tracker is <strong>exclusively</strong> for bug reports and feature requests.
</p>
<p align="center">
Issues without instructions to reproduce <strong>will be immediately closed<strong>.
</p>
<p align="center">
For documentation and website issues please visit the <a href="https://github.com/babel/babel.github.io">babel.github.io</a> repo.
</p>

View File

@@ -1,17 +0,0 @@
environment:
matrix:
- nodejs_version: "0.10"
- nodejs_version: "0.11"
install:
- "npm install"
- "cinst make"
test_script:
- "node --version"
- "npm --version"
- "make test-spec"
build: "off"
version: "{build}"

View File

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

View File

@@ -1,69 +0,0 @@
#!/usr/bin/env node
/**
* This tiny wrapper file checks for known node flags and appends them
* when found, before invoking the "real" _6to5-node(1) executable.
*/
var args = [__dirname + "/_6to5-node"];
process.argv.slice(2).forEach(function(arg){
var flag = arg.split("=")[0];
switch (flag) {
case "-d":
args.unshift("--debug");
break;
case "debug":
case "--debug":
case "--debug-brk":
args.unshift(arg);
break;
case "-gc":
case "--expose-gc":
args.unshift("--expose-gc");
break;
case "--gc-global":
case "--harmony":
case "--harmony-proxies":
case "--harmony-collections":
case "--harmony-generators":
case "--no-deprecation":
case "--prof":
case "--throw-deprecation":
case "--trace-deprecation":
case "--use-strict":
args.unshift(arg);
break;
default:
if (arg.indexOf("--trace") === 0) {
args.unshift(arg);
} else {
args.push(arg);
}
break;
}
});
try {
var kexec = require("kexec");
kexec(process.argv[0], args);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
var child_process = require("child_process");
var proc = child_process.spawn(process.argv[0], args, { stdio: "inherit" });
proc.on("exit", function (code, signal) {
process.on("exit", function () {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
})
});
}

View File

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

View File

@@ -1,130 +0,0 @@
#!/usr/bin/env node
var commander = require("commander");
var transform = require("../../lib/6to5/transformation");
var util = require("../../lib/6to5/util");
var fs = require("fs");
var each = require("lodash/collection/each");
var keys = require("lodash/object/keys");
commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to bottom of 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("-w, --watch", "Recompile files on changes");
commander.option("-r, --runtime", "Replace 6to5 declarations with references to a runtime");
commander.option("-e, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-p, --playground", "Enable playground support");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-l, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list);
commander.option("-L, --loose [list]", "List of transformers to enable loose mode ON", util.list);
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-c, --remove-comments", "Remove comments from the compiled code", 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("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.on("--help", function () {
var outKeys = function (title, obj) {
console.log(" " + title + ":");
console.log();
each(keys(obj).sort(), function (key) {
if (key[0] === "_") return;
if (obj[key].optional) {
key = "[" + key + "]";
}
console.log(" - " + key);
});
console.log();
};
outKeys("Transformers", transform.transformers);
outKeys("Module formatters", transform.moduleFormatters);
});
var pkg = require("../../package.json");
commander.version(pkg.version);
commander.usage("[options] <files ...>");
commander.parse(process.argv);
//
var errors = [];
var filenames = commander.args;
each(filenames, function (filename) {
if (!fs.existsSync(filename)) {
errors.push(filename + " doesn't exist");
}
});
if (commander.outDir && !filenames.length) {
errors.push("filenames required for --out-dir");
}
if (commander.outFile && commander.outDir) {
errors.push("cannot have --out-file and --out-dir");
}
if (commander.watch) {
if (!commander.outFile && !commander.outDir) {
errors.push("--watch requires --out-file or --out-dir");
}
if (!filenames.length) {
errors.push("--watch requires filenames");
}
}
if (commander.sourceMaps) {
if (!commander.outFile && !commander.outDir) {
errors.push("--source-maps requires --out-file or --out-dir");
}
}
if (errors.length) {
console.error(errors.join(". "));
process.exit(2);
}
//
exports.opts = {
keepModuleIdExtensions: commander.keepModuleIdExtensions,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
playground: commander.playground,
moduleIds: commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
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
// time to modify `exports.opts`
var fn;
if (commander.outDir) {
fn = require("./dir");
} else {
fn = require("./file");
}
fn(commander, filenames, exports.opts);
}, 0);

View File

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

View File

@@ -1,58 +0,0 @@
"use strict";
var isFunction = require("lodash/lang/isFunction");
var transform = require("../transformation");
var util = require("../util");
var fs = require("fs");
exports.version = require("../../../package").version;
exports.runtime = require("../build-runtime");
exports.types = require("../types");
exports.register = function (opts) {
var register = require("./register/node");
if (opts != null) register(opts);
return register;
};
exports.polyfill = function () {
require("../polyfill");
};
exports.canCompile = util.canCompile;
// do not use this - this is for use by official maintained 6to5 plugins
exports._util = util;
exports.transform = transform;
exports.transformFile = function (filename, opts, callback) {
if (isFunction(opts)) {
callback = opts;
opts = {};
}
opts.filename = filename;
fs.readFile(filename, function (err, code) {
if (err) return callback(err);
var result;
try {
result = transform(code, opts);
} catch (err) {
return callback(err);
}
callback(null, result);
});
};
exports.transformFileSync = function (filename, opts) {
opts = opts || {};
opts.filename = filename;
return transform(fs.readFileSync(filename), opts);
};

View File

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

View File

@@ -1,36 +0,0 @@
"use strict";
var path = require("path");
var os = require("os");
var fs = require("fs");
var FILENAME = path.join(os.tmpdir(), "6to5.json");
var data = {};
exports.save = function () {
fs.writeFileSync(FILENAME, JSON.stringify(data, null, " "));
};
exports.load = function () {
process.on("exit", exports.save);
var sigint = function () {
process.removeListener("SIGINT", sigint);
exports.save();
process.kill(process.pid, "SIGINT");
};
process.on("SIGINT", sigint);
if (!fs.existsSync(FILENAME)) return;
try {
data = JSON.parse(fs.readFileSync(FILENAME));
} catch (err) {
return;
}
};
exports.get = function () {
return data;
};

View File

@@ -1,13 +0,0 @@
var File = require("./transformation/file");
var util = require("./util");
var each = require("lodash/collection/each");
var t = require("./types");
module.exports = function (body, namespace) {
each(File.helpers, function (name) {
var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
));
});
};

View File

@@ -1,25 +0,0 @@
"use strict";
var buildHelpers = require("./build-helpers");
var generator = require("./generation");
var util = require("./util");
var t = require("./types");
module.exports = function () {
var namespace = t.identifier("to5Runtime");
var body = [];
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(
namespace,
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([]))
)
]));
buildHelpers(body, namespace);
return generator(tree).code;
};

View File

@@ -1,29 +0,0 @@
module.exports = detect;
var SYNTAX_KEYS = require("./syntax-keys");
var traverse = require("../traversal");
var visitors = traverse.explode(require("./visitors"));
function detect(ast) {
var stats = {
syntax: {},
builtins: {}
};
var detectedSyntax = function (name) {
stats.syntax[name] = true;
};
traverse(ast, {
enter: function (node, parent) {
if (SYNTAX_KEYS[node.type]) {
detectedSyntax(SYNTAX_KEYS[node.type]);
}
var visitor = visitors[node.type];
if (visitor) visitor(node, parent, detectedSyntax);
}
});
return stats;
}

View File

@@ -1,84 +0,0 @@
{
"ArrowFunctionExpression": "es6.arrowFunctions",
"AwaitExpression": "es7.asyncFunctions",
"ClassBody": "es6.classes",
"ClassDeclaration": "es6.classes",
"ClassExpression": "es6.classes",
"MethodDefinition": "es6.classes",
"ComprehensionBlock": "es7.comprehensions",
"ComprehensionExpression": "es7.comprehensions",
"ForOfStatement": "es6.forOf",
"ExportBatchSpecifier": "es6.modules",
"ExportDeclaration": "es6.modules",
"ExportSpecifier": "es6.modules",
"ImportBatchSpecifier": "es6.modules",
"ImportDeclaration": "es6.modules",
"ImportSpecifier": "es6.modules",
"ArrayPattern": "es6.destructuring",
"AssignmentPattern": "es6.destructuring",
"ObjectPattern": "es6.destructuring",
"RestElement": "es6.parameters.rest",
"SpreadElement": "es6.spread",
"SpreadProperty": "es7.objectSpread",
"TaggedTemplateExpression": "es6.templateLiterals",
"TemplateElement": "es6.templateLiterals",
"TemplateLiteral": "es6.templateLiterals",
"VirtualPropertyExpression": "es7.abstractReferences",
"PrivateDeclaration": "es7.abstractReferences",
"YieldExpression": "es6.generators",
"AnyTypeAnnotation": "flow",
"ArrayTypeAnnotation": "flow",
"BooleanTypeAnnotation": "flow",
"ClassProperty": "flow",
"DeclareClass": "flow",
"DeclareFunction": "flow",
"DeclareModule": "flow",
"DeclareVariable": "flow",
"FunctionTypeAnnotation": "flow",
"FunctionTypeParam": "flow",
"GenericTypeAnnotation": "flow",
"InterfaceExtends": "flow",
"InterfaceDeclaration": "flow",
"IntersectionTypeAnnotation": "flow",
"NullableTypeAnnotation": "flow",
"NumberTypeAnnotation": "flow",
"StringLiteralTypeAnnotation": "flow",
"StringTypeAnnotation": "flow",
"TupleTypeAnnotation": "flow",
"TypeofTypeAnnotation": "flow",
"TypeAlias": "flow",
"TypeAnnotation": "flow",
"TypeParameterDeclaration": "flow",
"TypeParameterInstantiation": "flow",
"ObjectTypeAnnotation": "flow",
"ObjectTypeCallProperty": "flow",
"ObjectTypeIndexer": "flow",
"ObjectTypeProperty": "flow",
"QualifiedTypeIdentifier": "flow",
"UnionTypeAnnotation": "flow",
"VoidTypeAnnotation": "flow",
"JSXAttribute": "jsx",
"JSXClosingElement": "jsx",
"JSXElement": "jsx",
"JSXEmptyExpression": "jsx",
"JSXExpressionContainer": "jsx",
"JSXIdentifier": "jsx",
"JSXMemberExpression": "jsx",
"JSXNamespacedName": "jsx",
"JSXOpeningElement": "jsx",
"JSXSpreadAttribute": "jsx"
}

View File

@@ -1,54 +0,0 @@
var t = require("../types");
var _ = require("lodash");
exports.AssignmentExpression = function (node, parent, detected) {
if (node.operator === "**=") {
detected("es6.exponentation");
}
};
exports.BinaryExpression = function (node, parent, detected) {
if (node.operator === "**") {
detected("es6.exponentation");
}
};
exports.VariableDeclaration = function (node, parent, detected) {
if (node.kind === "let" || node.kind === "const") {
detected("es6.blockScoping");
}
if (node.kind === "const") {
detected("es6.constants");
}
};
exports.Property = function (node, parent, detected) {
if (node.shorthand || node.method) {
detected("es6.properties.shorthand");
}
if (node.kind === "set" || node.kind === "get") {
detected("es5.properties.mutators");
}
if (node.computed) {
detected("es6.properties.computed");
}
};
exports.AssignmentPattern = function (node, parent, detected) {
if (t.isFunction(parent) && _.contains(parent.params, node)) {
detected("es6.parameters.default");
}
};
exports.Function = function (node, parent, detected) {
if (node.generator) {
detected("es6.generators");
}
if (node.async) {
detected("es7.asyncFunctions");
}
};

View File

@@ -1,166 +0,0 @@
"use strict";
module.exports = Buffer;
var isBoolean = require("lodash/lang/isBoolean");
var contains = require("lodash/collection/contains");
var isNumber = require("lodash/lang/isNumber");
var util = require("../util");
function Buffer(position, format) {
this.position = position;
this._indent = format.indent.base;
this.format = format;
this.buf = "";
}
Buffer.prototype.get = function () {
return util.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);
}
};
Buffer.prototype.indentSize = function () {
return this.getIndent().length;
};
Buffer.prototype.indent = function () {
this._indent++;
};
Buffer.prototype.dedent = function () {
this._indent--;
};
Buffer.prototype.semicolon = function () {
this.push(";");
};
Buffer.prototype.ensureSemicolon = function () {
if (!this.isLast(";")) this.semicolon();
};
Buffer.prototype.rightBrace = function () {
this.newline(true);
this.push("}");
};
Buffer.prototype.keyword = function (name) {
this.push(name);
this.space();
};
Buffer.prototype.space = function () {
if (this.format.compact) return;
if (this.buf && !this.isLast([" ", "\n"])) {
this.push(" ");
}
};
Buffer.prototype.removeLast = function (cha) {
if (!this.isLast(cha)) return;
this.buf = this.buf.substr(0, this.buf.length - 1);
this.position.unshift(cha);
};
Buffer.prototype.newline = function (i, removeLast) {
if (this.format.compact || this.format.concise) {
this.space();
return;
}
removeLast = removeLast || false;
if (isNumber(i)) {
if (this.endsWith("{\n")) i--;
if (this.endsWith(util.repeat(i, "\n"))) return;
while (i--) {
this._newline(removeLast);
}
return;
}
if (isBoolean(i)) {
removeLast = i;
}
this._newline(removeLast);
};
Buffer.prototype._newline = function (removeLast) {
if (removeLast && this.isLast("\n")) this.removeLast("\n");
this.removeLast(" ");
// remove whitespace if last character was a newline
this._removeSpacesAfterLastNewline();
this._push("\n");
};
/**
* If buffer ends with a newline and some spaces after it, trim those spaces.
*/
Buffer.prototype._removeSpacesAfterLastNewline = function () {
var lastNewlineIndex = this.buf.lastIndexOf("\n");
if (lastNewlineIndex === -1)
return;
var index = this.buf.length - 1;
while (index > lastNewlineIndex) {
if (this.buf[index] !== " ") {
break;
}
index--;
}
if (index === lastNewlineIndex) {
this.buf = this.buf.substring(0, index + 1);
}
};
Buffer.prototype.push = function (str, noIndent) {
if (this._indent && !noIndent && str !== "\n") {
// we have an indent level and we aren't pushing a newline
var indent = this.getIndent();
// replace all newlines with newlines with the indentation
str = str.replace(/\n/g, "\n" + indent);
// we've got a newline before us so prepend on the indentation
if (this.isLast("\n")) str = indent + str;
}
this._push(str);
};
Buffer.prototype._push = function (str) {
this.position.push(str);
this.buf += str;
};
Buffer.prototype.endsWith = function (str) {
var d = this.buf.length - str.length;
return d >= 0 && this.buf.lastIndexOf(str) === d;
};
Buffer.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = util.trimRight(buf);
var last = buf[buf.length - 1];
if (Array.isArray(cha)) {
return contains(cha, last);
} else {
return cha === last;
}
};

View File

@@ -1,21 +0,0 @@
"use strict";
exports.File = function (node, print) {
print(node.program);
};
exports.Program = function (node, print) {
print.sequence(node.body);
};
exports.BlockStatement = function (node, print) {
if (node.body.length === 0) {
this.push("{}");
} else {
this.push("{");
this.newline();
print.sequence(node.body, { indent: true });
this.removeLast("\n");
this.rightBrace();
}
};

View File

@@ -1,42 +0,0 @@
"use strict";
exports.ClassExpression =
exports.ClassDeclaration = function (node, print) {
this.push("class");
if (node.id) {
this.space();
print(node.id);
}
if (node.superClass) {
this.push(" extends ");
print(node.superClass);
}
this.space();
print(node.body);
};
exports.ClassBody = function (node, print) {
if (node.body.length === 0) {
this.push("{}");
} else {
this.push("{");
this.newline();
this.indent();
print.sequence(node.body);
this.dedent();
this.rightBrace();
}
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};

View File

@@ -1,156 +0,0 @@
"use strict";
var util = require("../../util");
var t = require("../../types");
var isNumber = require("lodash/lang/isNumber");
exports.UnaryExpression = function (node, print) {
var hasSpace = /[a-z]$/.test(node.operator);
var arg = node.argument;
if (t.isUpdateExpression(arg) || t.isUnaryExpression(arg)) {
hasSpace = true;
}
if (t.isUnaryExpression(arg) && arg.operator === "!") {
hasSpace = false;
}
this.push(node.operator);
if (hasSpace) this.push(" ");
print(node.argument);
};
exports.UpdateExpression = function (node, print) {
if (node.prefix) {
this.push(node.operator);
print(node.argument);
} else {
print(node.argument);
this.push(node.operator);
}
};
exports.ConditionalExpression = function (node, print) {
print(node.test);
this.space();
this.push("?");
this.space();
print(node.consequent);
this.space();
this.push(":");
this.space();
print(node.alternate);
};
exports.NewExpression = function (node, print) {
this.push("new ");
print(node.callee);
if (node.arguments.length || this.format.parentheses) {
this.push("(");
print.list(node.arguments);
this.push(")");
}
};
exports.SequenceExpression = function (node, print) {
print.list(node.expressions);
};
exports.ThisExpression = function () {
this.push("this");
};
exports.CallExpression = function (node, print) {
print(node.callee);
this.push("(");
var separator = ",";
if (node._prettyCall) {
separator += "\n";
this.newline();
this.indent();
} else {
separator += " ";
}
print.list(node.arguments, { separator: separator });
if (node._prettyCall) {
this.newline();
this.dedent();
}
this.push(")");
};
var buildYieldAwait = function (keyword) {
return function (node, print) {
this.push(keyword);
if (node.delegate || node.all) {
this.push("*");
}
if (node.argument) {
this.space();
print(node.argument);
}
};
};
exports.YieldExpression = buildYieldAwait("yield");
exports.AwaitExpression = buildYieldAwait("await");
exports.EmptyStatement = function () {
this.semicolon();
};
exports.ExpressionStatement = function (node, print) {
print(node.expression);
this.semicolon();
};
exports.BinaryExpression =
exports.LogicalExpression =
exports.AssignmentPattern =
exports.AssignmentExpression = function (node, print) {
// todo: add cases where the spaces can be dropped when in compact mode
print(node.left);
this.push(" ");
this.push(node.operator);
this.push(" ");
print(node.right);
};
var SCIENTIFIC_NOTATION = /e/i;
exports.MemberExpression = function (node, print) {
var obj = node.object;
print(obj);
if (!node.computed && t.isMemberExpression(node.property)) {
throw new TypeError("Got a MemberExpression for MemberExpression property");
}
var computed = node.computed;
if (t.isLiteral(node.property) && isNumber(node.property.value)) {
computed = true;
}
if (computed) {
this.push("[");
print(node.property);
this.push("]");
} else {
// 5..toFixed(2);
if (t.isLiteral(obj) && util.isInteger(obj.value) && !SCIENTIFIC_NOTATION.test(obj.value.toString())) {
this.push(".");
}
this.push(".");
print(node.property);
}
};

View File

@@ -1,35 +0,0 @@
"use strict";
exports.AnyTypeAnnotation =
exports.ArrayTypeAnnotation =
exports.BooleanTypeAnnotation =
exports.ClassProperty =
exports.DeclareClass =
exports.DeclareFunction =
exports.DeclareModule =
exports.DeclareVariable =
exports.FunctionTypeAnnotation =
exports.FunctionTypeParam =
exports.GenericTypeAnnotation =
exports.InterfaceExtends =
exports.InterfaceDeclaration =
exports.IntersectionTypeAnnotation =
exports.NullableTypeAnnotation =
exports.NumberTypeAnnotation =
exports.StringLiteralTypeAnnotation =
exports.StringTypeAnnotation =
exports.TupleTypeAnnotation =
exports.TypeofTypeAnnotation =
exports.TypeAlias =
exports.TypeAnnotation =
exports.TypeParameterDeclaration =
exports.TypeParameterInstantiation =
exports.ObjectTypeAnnotation =
exports.ObjectTypeCallProperty =
exports.ObjectTypeIndexer =
exports.ObjectTypeProperty =
exports.QualifiedTypeIdentifier =
exports.UnionTypeAnnotation =
exports.VoidTypeAnnotation = function () {
// todo: implement these once we have a `--keep-types` option
};

View File

@@ -1,78 +0,0 @@
"use strict";
var t = require("../../types");
var each = require("lodash/collection/each");
exports.JSXAttribute = function (node, print) {
print(node.name);
if (node.value) {
this.push("=");
print(node.value);
}
};
exports.JSXIdentifier = function (node) {
this.push(node.name);
};
exports.JSXNamespacedName = function (node, print) {
print(node.namespace);
this.push(":");
print(node.name);
};
exports.JSXMemberExpression = function (node, print) {
print(node.object);
this.push(".");
print(node.property);
};
exports.JSXSpreadAttribute = function (node, print) {
this.push("{...");
print(node.argument);
this.push("}");
};
exports.JSXExpressionContainer = function (node, print) {
this.push("{");
print(node.expression);
this.push("}");
};
exports.JSXElement = function (node, print) {
var self = this;
var open = node.openingElement;
print(open);
if (open.selfClosing) return;
this.indent();
each(node.children, function (child) {
if (t.isLiteral(child)) {
self.push(child.value);
} else {
print(child);
}
});
this.dedent();
print(node.closingElement);
};
exports.JSXOpeningElement = function (node, print) {
this.push("<");
print(node.name);
if (node.attributes.length > 0) {
this.push(" ");
print.join(node.attributes, { separator: " " });
}
this.push(node.selfClosing ? " />" : ">");
};
exports.JSXClosingElement = function (node, print) {
this.push("</");
print(node.name);
this.push(">");
};
exports.JSXEmptyExpression = function () {};

View File

@@ -1,68 +0,0 @@
"use strict";
var t = require("../../types");
exports._params = function (node, print) {
this.push("(");
print.list(node.params);
this.push(")");
};
exports._method = function (node, print) {
var value = node.value;
var kind = node.kind;
var key = node.key;
if (!kind || kind === "init") {
if (value.generator) {
this.push("*");
}
} else {
this.push(kind + " ");
}
if (value.async) this.push("async ");
if (node.computed) {
this.push("[");
print(key);
this.push("]");
} else {
print(key);
}
this._params(value, print);
this.push(" ");
print(value.body);
};
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
if (node.id) {
this.push(" ");
print(node.id);
} else {
this.space();
}
this._params(node, print);
this.space();
print(node.body);
};
exports.ArrowFunctionExpression = function (node, print) {
if (node.async) this.push("async ");
if (node.params.length === 1 && t.isIdentifier(node.params[0])) {
print(node.params[0]);
} else {
this._params(node, print);
}
this.push(" => ");
print(node.body);
};

View File

@@ -1,98 +0,0 @@
"use strict";
var t = require("../../types");
var each = require("lodash/collection/each");
exports.ImportSpecifier = function (node, print) {
if (t.isSpecifierDefault(node)) {
print(t.getSpecifierName(node));
} else {
return exports.ExportSpecifier.apply(this, arguments);
}
};
exports.ExportSpecifier = function (node, print) {
print(node.id);
if (node.name) {
this.push(" as ");
print(node.name);
}
};
exports.ExportBatchSpecifier = function () {
this.push("*");
};
exports.ExportDeclaration = function (node, print) {
this.push("export ");
var specifiers = node.specifiers;
if (node.default) {
this.push("default ");
}
if (node.declaration) {
print(node.declaration);
if (t.isStatement(node.declaration)) return;
} else {
if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) {
print(specifiers[0]);
} else {
this.push("{");
if (specifiers.length) {
this.space();
print.join(specifiers, { separator: ", " });
this.space();
}
this.push("}");
}
if (node.source) {
this.push(" from ");
print(node.source);
}
}
this.ensureSemicolon();
};
exports.ImportDeclaration = function (node, print) {
var self = this;
this.push("import ");
var specfiers = node.specifiers;
if (specfiers && specfiers.length) {
var foundImportSpecifier = false;
each(node.specifiers, function (spec, i) {
if (+i > 0) {
self.push(", ");
}
var isDefault = t.isSpecifierDefault(spec);
if (!isDefault && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
foundImportSpecifier = true;
self.push("{ ");
}
print(spec);
});
if (foundImportSpecifier) {
this.push(" }");
}
this.push(" from ");
}
print(node.source);
this.semicolon();
};
exports.ImportBatchSpecifier = function (node, print) {
this.push("* as ");
print(node.name);
};

View File

@@ -1,9 +0,0 @@
"use strict";
var each = require("lodash/collection/each");
each(["BindMemberExpression", "BindFunctionExpression"], function (type) {
exports[type] = function () {
throw new ReferenceError("Trying to render non-standard playground node " + JSON.stringify(type));
};
});

View File

@@ -1,221 +0,0 @@
"use strict";
var util = require("../../util");
var t = require("../../types");
exports.WithStatement = function (node, print) {
this.keyword("with");
this.push("(");
print(node.object);
this.push(")");
print.block(node.body);
};
exports.IfStatement = function (node, print) {
this.keyword("if");
this.push("(");
print(node.test);
this.push(")");
this.space();
print.indentOnComments(node.consequent);
if (node.alternate) {
if (this.isLast("}")) this.push(" ");
this.keyword("else");
if (this.format.format && !t.isBlockStatement(node.alternate)) {
this.push(" ");
}
print.indentOnComments(node.alternate);
}
};
exports.ForStatement = function (node, print) {
this.keyword("for");
this.push("(");
print(node.init);
this.push(";");
if (node.test) {
this.push(" ");
print(node.test);
}
this.push(";");
if (node.update) {
this.push(" ");
print(node.update);
}
this.push(")");
print.block(node.body);
};
exports.WhileStatement = function (node, print) {
this.keyword("while");
this.push("(");
print(node.test);
this.push(")");
print.block(node.body);
};
var buildForXStatement = function (op) {
return function (node, print) {
this.keyword("for");
this.push("(");
print(node.left);
this.push(" " + op + " ");
print(node.right);
this.push(")");
print.block(node.body);
};
};
exports.ForInStatement = buildForXStatement("in");
exports.ForOfStatement = buildForXStatement("of");
exports.DoWhileStatement = function (node, print) {
this.keyword("do");
print(node.body);
this.space();
this.keyword("while");
this.push("(");
print(node.test);
this.push(");");
};
var buildLabelStatement = function (prefix, key) {
return function (node, print) {
this.push(prefix);
var label = node[key || "label"];
if (label) {
this.push(" ");
print(label);
}
this.semicolon();
};
};
exports.ContinueStatement = buildLabelStatement("continue");
exports.ReturnStatement = buildLabelStatement("return", "argument");
exports.BreakStatement = buildLabelStatement("break");
exports.LabeledStatement = function (node, print) {
print(node.label);
this.push(": ");
print(node.body);
};
exports.TryStatement = function (node, print) {
this.keyword("try");
print(node.block);
this.space();
// Esprima bug puts the catch clause in a `handlers` array.
// see https://code.google.com/p/esprima/issues/detail?id=433
// We run into this from regenerator generated ast.
if (node.handlers) {
print(node.handlers[0]);
} else {
print(node.handler);
}
if (node.finalizer) {
this.space();
this.push("finally ");
print(node.finalizer);
}
};
exports.CatchClause = function (node, print) {
this.keyword("catch");
this.push("(");
print(node.param);
this.push(") ");
print(node.body);
};
exports.ThrowStatement = function (node, print) {
this.push("throw ");
print(node.argument);
this.semicolon();
};
exports.SwitchStatement = function (node, print) {
this.keyword("switch");
this.push("(");
print(node.discriminant);
this.push(")");
this.space();
this.push("{");
print.sequence(node.cases, { indent: true });
this.push("}");
};
exports.SwitchCase = function (node, print) {
if (node.test) {
this.push("case ");
print(node.test);
this.push(":");
} else {
this.push("default:");
}
this.newline();
print.sequence(node.consequent, { indent: true });
};
exports.DebuggerStatement = function () {
this.push("debugger;");
};
exports.VariableDeclaration = function (node, print, parent) {
this.push(node.kind + " ");
var hasInits = false;
// don't add whitespace to loop heads
if (!t.isFor(parent)) {
for (var i = 0; i < node.declarations.length; i++) {
if (node.declarations[i].init) {
// has an init so let's split it up over multiple lines
hasInits = true;
}
}
}
var sep = ",";
if (hasInits) {
sep += "\n" + util.repeat(node.kind.length + 1);
} else {
sep += " ";
}
print.list(node.declarations, { separator: sep });
if (!t.isFor(parent)) {
this.semicolon();
}
};
exports.PrivateDeclaration = function (node, print) {
this.push("private ");
print.join(node.declarations, { separator: ", " });
this.semicolon();
};
exports.VariableDeclarator = function (node, print) {
if (node.init) {
print(node.id);
this.space();
this.push("=");
this.space();
print(node.init);
} else {
print(node.id);
}
};

View File

@@ -1,32 +0,0 @@
"use strict";
var each = require("lodash/collection/each");
exports.TaggedTemplateExpression = function (node, print) {
print(node.tag);
print(node.quasi);
};
exports.TemplateElement = function (node) {
this._push(node.value.raw);
};
exports.TemplateLiteral = function (node, print) {
this.push("`");
var quasis = node.quasis;
var self = this;
var len = quasis.length;
each(quasis, function (quasi, i) {
print(quasi);
if (i + 1 < len) {
self.push("${ ");
print(node.expressions[i]);
self.push(" }");
}
});
this._push("`");
};

View File

@@ -1,106 +0,0 @@
"use strict";
var each = require("lodash/collection/each");
exports.Identifier = function (node) {
this.push(node.name);
};
exports.RestElement =
exports.SpreadElement =
exports.SpreadProperty = function (node, print) {
this.push("...");
print(node.argument);
};
exports.VirtualPropertyExpression = function (node, print) {
print(node.object);
this.push("::");
print(node.property);
};
exports.ObjectExpression =
exports.ObjectPattern = function (node, print) {
var props = node.properties;
if (props.length) {
this.push("{");
this.space();
print.list(props, { indent: true });
this.space();
this.push("}");
} else {
this.push("{}");
}
};
exports.Property = function (node, print) {
if (node.method || node.kind === "get" || node.kind === "set") {
this._method(node, print);
} else {
if (node.computed) {
this.push("[");
print(node.key);
this.push("]");
} else {
print(node.key);
if (node.shorthand) return;
}
this.push(":");
this.space();
print(node.value);
}
};
exports.ArrayExpression =
exports.ArrayPattern = function (node, print) {
var elems = node.elements;
var self = this;
var len = elems.length;
this.push("[");
each(elems, function (elem, i) {
if (!elem) {
// If the array expression ends with a hole, that hole
// will be ignored by the interpreter, but if it ends with
// two (or more) holes, we need to write out two (or more)
// commas so that the resulting code is interpreted with
// both (all) of the holes.
self.push(",");
} else {
if (i > 0 && !self.format.compact) self.push(" ");
print(elem);
if (i < len - 1) self.push(",");
}
});
this.push("]");
};
exports.Literal = function (node) {
var val = node.value;
var type = typeof val;
if (type === "string") {
val = JSON.stringify(val);
// escape illegal js but valid json unicode characters
val = val.replace(/[\u000A\u000D\u2028\u2029]/g, function (c) {
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
});
this.push(val);
} else if (type === "number") {
this.push(val + "");
} else if (type === "boolean") {
this.push(val ? "true" : "false");
} else if (node.regex) {
this.push("/" + node.regex.pattern + "/" + node.regex.flags);
} else if (val === null) {
this.push("null");
}
};

View File

@@ -1,361 +0,0 @@
"use strict";
module.exports = function (ast, opts, code) {
var gen = new CodeGenerator(ast, opts, code);
return gen.generate();
};
module.exports.CodeGenerator = CodeGenerator;
var detectIndent = require("detect-indent");
var Whitespace = require("./whitespace");
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");
function CodeGenerator(ast, opts, code) {
opts = opts || {};
this.comments = ast.comments || [];
this.tokens = ast.tokens || [];
this.format = CodeGenerator.normalizeOptions(code, opts);
this.opts = opts;
this.ast = ast;
this.whitespace = new Whitespace(this.tokens, this.comments);
this.position = new Position;
this.map = new SourceMap(this.position, opts, code);
this.buffer = new Buffer(this.position, this.format);
}
each(Buffer.prototype, function (fn, key) {
CodeGenerator.prototype[key] = function () {
return fn.apply(this.buffer, arguments);
};
});
CodeGenerator.normalizeOptions = function (code, opts) {
var style = " ";
if (code) {
var indent = detectIndent(code).indent;
if (indent && indent !== " ") style = indent;
}
return merge({
parentheses: true,
comments: opts.comments == null || opts.comments,
compact: false,
concise: false,
indent: {
adjustMultilineComment: true,
style: style,
base: 0
}
}, opts.format || {});
};
CodeGenerator.generators = {
templateLiterals: require("./generators/template-literals"),
comprehensions: require("./generators/comprehensions"),
expressions: require("./generators/expressions"),
statements: require("./generators/statements"),
playground: require("./generators/playground"),
classes: require("./generators/classes"),
methods: require("./generators/methods"),
modules: require("./generators/modules"),
types: require("./generators/types"),
flow: require("./generators/flow"),
base: require("./generators/base"),
jsx: require("./generators/jsx")
};
each(CodeGenerator.generators, function (generator) {
extend(CodeGenerator.prototype, generator);
});
CodeGenerator.prototype.generate = function () {
var ast = this.ast;
this.print(ast);
var comments = [];
each(ast.comments, function (comment) {
if (!comment._displayed) comments.push(comment);
});
this._printComments(comments);
return {
map: this.map.get(),
code: this.buffer.get()
};
};
CodeGenerator.prototype.buildPrint = function (parent) {
var self = this;
var print = function (node, opts) {
return self.print(node, parent, opts);
};
print.sequence = function (nodes, opts) {
opts = opts || {};
opts.statement = true;
return self.printJoin(print, nodes, opts);
};
print.join = function (nodes, opts) {
return self.printJoin(print, nodes, opts);
};
print.list = function (items, opts) {
opts = opts || {};
var sep = opts.separator || ", ";
if (self.format.compact) sep = ",";
opts.separator = sep;
print.join(items, opts);
};
print.block = function (node) {
return self.printBlock(print, node);
};
print.indentOnComments = function (node) {
return self.printAndIndentOnComments(print, node);
};
return print;
};
CodeGenerator.prototype.print = function (node, parent, opts) {
if (!node) return "";
if (parent && parent._compact) {
node._compact = true;
}
var oldConcise = this.format.concise;
if (node._compact) {
this.format.concise = true;
}
var self = this;
opts = opts || {};
var newline = function (leading) {
if (!opts.statement && !n.isUserWhitespacable(node, parent)) {
return;
}
var lines = 0;
if (node.start != null && !node._ignoreUserWhitespace) {
// user node
if (leading) {
lines = self.whitespace.getNewlinesBefore(node);
} else {
lines = self.whitespace.getNewlinesAfter(node);
}
} else {
// generated node
if (!leading) lines++; // always include at least a single line after
var needs = n.needsWhitespaceAfter;
if (leading) needs = n.needsWhitespaceBefore;
lines += needs(node, parent);
// generated nodes can't add starting file whitespace
if (!self.buffer.get()) lines = 0;
}
self.newline(lines);
};
if (this[node.type]) {
var needsNoLineTermParens = n.needsParensNoLineTerminator(node, parent);
var needsParens = needsNoLineTermParens || n.needsParens(node, parent);
if (needsParens) this.push("(");
if (needsNoLineTermParens) this.indent();
this.printLeadingComments(node, parent);
newline(true);
if (opts.before) opts.before();
this.map.mark(node, "start");
this[node.type](node, this.buildPrint(node), parent);
if (needsNoLineTermParens) {
this.newline();
this.dedent();
}
if (needsParens) this.push(")");
this.map.mark(node, "end");
if (opts.after) opts.after();
newline(false);
this.printTrailingComments(node, parent);
} else {
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}
this.format.concise = oldConcise;
};
CodeGenerator.prototype.printJoin = function (print, nodes, opts) {
if (!nodes || !nodes.length) return;
opts = opts || {};
var self = this;
var len = nodes.length;
if (opts.indent) self.indent();
each(nodes, function (node, i) {
print(node, {
statement: opts.statement,
after: function () {
if (opts.iterator) {
opts.iterator(node, i);
}
if (opts.separator && i < len - 1) {
self.push(opts.separator);
}
}
});
});
if (opts.indent) self.dedent();
};
CodeGenerator.prototype.printAndIndentOnComments = function (print, node) {
var indent = !!node.leadingComments;
if (indent) this.indent();
print(node);
if (indent) this.dedent();
};
CodeGenerator.prototype.printBlock = function (print, node) {
if (t.isEmptyStatement(node)) {
this.semicolon();
} else {
this.push(" ");
print(node);
}
};
CodeGenerator.prototype.generateComment = function (comment) {
var val = comment.value;
if (comment.type === "Line") {
val = "//" + val;
} else {
val = "/*" + val + "*/";
}
return val;
};
CodeGenerator.prototype.printTrailingComments = function (node, parent) {
this._printComments(this.getComments("trailingComments", node, parent));
};
CodeGenerator.prototype.printLeadingComments = function (node, parent) {
this._printComments(this.getComments("leadingComments", node, parent));
};
CodeGenerator.prototype.getComments = function (key, node, parent) {
if (t.isExpressionStatement(parent)) {
return [];
}
var comments = [];
var nodes = [node];
var self = this;
if (t.isExpressionStatement(node)) {
nodes.push(node.argument);
}
each(nodes, function (node) {
comments = comments.concat(self._getComments(key, node));
});
return comments;
};
CodeGenerator.prototype._getComments = function (key, node) {
return (node && node[key]) || [];
};
CodeGenerator.prototype._printComments = function (comments) {
if (this.format.compact) return;
if (!this.format.comments) return;
if (!comments || !comments.length) return;
var self = this;
each(comments, function (comment) {
var skip = false;
// find the original comment in the ast and set it as displayed
each(self.ast.comments, function (origComment) {
if (origComment.start === comment.start) {
// comment has already been output
if (origComment._displayed) skip = true;
origComment._displayed = true;
return false;
}
});
if (skip) return;
// whitespace before
self.newline(self.whitespace.getNewlinesBefore(comment));
var column = self.position.column;
var val = self.generateComment(comment);
if (column && !self.isLast(["\n", " ", "[", "{"])) {
self._push(" ");
column++;
}
//
if (comment.type === "Block" && self.format.indent.adjustMultilineComment) {
var offset = comment.loc.start.column;
if (offset) {
var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
val = val.replace(newlineRegex, "\n");
}
var indent = Math.max(self.indentSize(), column);
val = val.replace(/\n/g, "\n" + util.repeat(indent));
}
if (column === 0) {
val = self.getIndent() + val;
}
//
self._push(val);
// whitespace after
self.newline(self.whitespace.getNewlinesAfter(comment));
});
};

View File

@@ -1,112 +0,0 @@
"use strict";
module.exports = Node;
var whitespace = require("./whitespace");
var parens = require("./parentheses");
var t = require("../../types");
var each = require("lodash/collection/each");
var some = require("lodash/collection/some");
var find = function (obj, node, parent) {
if (!obj) return;
var result;
var types = Object.keys(obj);
for (var i = 0; i < types.length; i++) {
var type = types[i];
if (t.is(type, node)) {
var fn = obj[type];
result = fn(node, parent);
if (result != null) break;
}
}
return result;
};
function Node(node, parent) {
this.parent = parent;
this.node = node;
}
Node.isUserWhitespacable = function (node) {
return t.isUserWhitespacable(node);
};
Node.needsWhitespace = function (node, parent, type) {
if (!node) return 0;
if (t.isExpressionStatement(node)) {
node = node.expression;
}
var lines = find(whitespace[type].nodes, node, parent);
if (lines) return lines;
each(find(whitespace[type].list, node, parent), function (expr) {
lines = Node.needsWhitespace(expr, node, type);
if (lines) return false;
});
return lines || 0;
};
Node.needsWhitespaceBefore = function (node, parent) {
return Node.needsWhitespace(node, parent, "before");
};
Node.needsWhitespaceAfter = function (node, parent) {
return Node.needsWhitespace(node, parent, "after");
};
Node.needsParens = function (node, parent) {
if (!parent) return false;
if (t.isNewExpression(parent) && parent.callee === node) {
if (t.isCallExpression(node)) return true;
var hasCall = some(node, function (val) {
return t.isCallExpression(val);
});
if (hasCall) return true;
}
return find(parens, node, parent);
};
Node.needsParensNoLineTerminator = function (node, parent) {
if (!parent) return false;
// no comments
if (!node.leadingComments || !node.leadingComments.length) {
return false;
}
if (t.isYieldExpression(parent) || t.isAwaitExpression(parent)) {
return true;
}
if (t.isContinueStatement(parent) || t.isBreakStatement(parent) ||
t.isReturnStatement(parent) || t.isThrowStatement(parent)) {
return true;
}
return false;
};
each(Node, function (fn, key) {
Node.prototype[key] = function () {
// Avoid leaking arguments to prevent deoptimization
var args = new Array(arguments.length + 2);
args[0] = this.node;
args[1] = this.parent;
for (var i = 0; i < args.length; i++) {
args[i + 2] = arguments[i];
}
return Node[key].apply(null, args);
};
});

View File

@@ -1,84 +0,0 @@
"use strict";
var t = require("../../types");
var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
var isNumber = require("lodash/lang/isNumber");
exports.before = {
nodes: {
Property: function (node, parent) {
if (parent.properties[0] === node) {
return 1;
}
},
SpreadProperty: function (node, parent) {
return exports.before.nodes.Property(node, parent);
},
SwitchCase: function (node, parent) {
if (parent.cases[0] === node) {
return 1;
}
},
CallExpression: function (node) {
if (t.isFunction(node.callee)) {
return 1;
}
}
}
};
exports.after = {
nodes: {
LogicalExpression: function (node) {
return t.isFunction(node.left) || t.isFunction(node.right);
},
AssignmentExpression: function (node) {
if (t.isFunction(node.right)) {
return 1;
}
}
},
list: {
VariableDeclaration: function (node) {
return map(node.declarations, "init");
},
ArrayExpression: function (node) {
return node.elements;
},
ObjectExpression: function (node) {
return node.properties;
}
}
};
each({
Function: 1,
Class: 1,
For: 1,
ArrayExpression: { after: 1 },
ObjectExpression: { after: 1 },
SwitchStatement: 1,
IfStatement: { before: 1 },
CallExpression: { after: 1 },
Literal: { after: 1 }
}, function (amounts, type) {
if (isNumber(amounts)) {
amounts = { after: amounts, before: amounts };
}
each([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
each(amounts, function (amount, key) {
exports[key].nodes[type] = function () {
return amount;
};
});
});
});

View File

@@ -1,29 +0,0 @@
"use strict";
module.exports = Position;
function Position() {
this.line = 1;
this.column = 0;
}
Position.prototype.push = function (str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line++;
this.column = 0;
} else {
this.column++;
}
}
};
Position.prototype.unshift = function (str) {
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
this.column--;
}
}
};

View File

@@ -1,56 +0,0 @@
"use strict";
module.exports = SourceMap;
var sourceMap = require("source-map");
var t = require("../types");
function SourceMap(position, opts, code) {
this.position = position;
this.opts = opts;
if (opts.sourceMap) {
this.map = new sourceMap.SourceMapGenerator({
file: opts.sourceMapName,
sourceRoot: opts.sourceRoot
});
this.map.setSourceContent(opts.sourceFileName, code);
} else {
this.map = null;
}
}
SourceMap.prototype.get = function () {
var map = this.map;
if (map) {
return map.toJSON();
} else {
return map;
}
};
SourceMap.prototype.mark = function (node, type) {
var loc = node.loc;
if (!loc) return; // no location info
var map = this.map;
if (!map) return; // no source map
if (t.isProgram(node) || t.isFile(node)) return; // illegal mapping nodes
var position = this.position;
var generated = {
line: position.line,
column: position.column
};
var original = loc[type];
map.addMapping({
source: this.opts.sourceFileName,
generated: generated,
original: original
});
};

View File

@@ -1,111 +0,0 @@
"use strict";
module.exports = Whitespace;
var sortBy = require("lodash/collection/sortBy");
/**
* Returns `i`th number from `base`, continuing from 0 when `max` is reached.
* Useful for shifting `for` loop by a fixed number but going over all items.
*
* @param {Number} i Current index in the loop
* @param {Number} base Start index for which to return 0
* @param {Number} max Array length
* @returns {Number} shiftedIndex
*/
function getLookupIndex(i, base, max) {
i += base;
if (i >= max)
i -= max;
return i;
}
function Whitespace(tokens, comments) {
this.tokens = sortBy(tokens.concat(comments), "start");
this.used = {};
// Profiling this code shows that while generator passes over it, indexes
// returned by `getNewlinesBefore` and `getNewlinesAfter` are always increasing.
// We use this implementation detail for an optimization: instead of always
// starting to look from `this.tokens[0]`, we will start `for` loops from the
// previous successful match. We will enumerate all tokens—but the common
// case will be much faster.
this._lastFoundIndex = 0;
}
Whitespace.prototype.getNewlinesBefore = function (node) {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var j = 0; j < tokens.length; j++) {
// optimize for forward traversal by shifting for loop index
var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
token = tokens[i];
// this is the token this node starts with
if (node.start === token.start) {
startToken = tokens[i - 1];
endToken = token;
this._lastFoundIndex = i;
break;
}
}
return this.getNewlinesBetween(startToken, endToken);
};
Whitespace.prototype.getNewlinesAfter = function (node) {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var j = 0; j < tokens.length; j++) {
// optimize for forward traversal by shifting for loop index
var i = getLookupIndex(j, this._lastFoundIndex, this.tokens.length);
token = tokens[i];
// this is the token this node ends with
if (node.end === token.end) {
startToken = token;
endToken = tokens[i + 1];
this._lastFoundIndex = i;
break;
}
}
if (endToken.type.type === "eof") {
return 1;
} else {
var lines = this.getNewlinesBetween(startToken, endToken);
if (node.type === "Line" && !lines) {
// line comment
return 1;
} else {
return lines;
}
}
};
Whitespace.prototype.getNewlinesBetween = function (startToken, endToken) {
var start = startToken ? startToken.loc.end.line : 1;
var end = endToken.loc.start.line;
var lines = 0;
for (var line = start; line < end; line++) {
if (typeof this.used[line] === "undefined") {
this.used[line] = true;
lines++;
}
}
return lines;
};

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,79 +0,0 @@
// 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");
var defs = {
string1: "red",
string2: "red",
punct: ["white", "bold"],
curly: "green",
parens: ["blue", "bold"],
square: ["yellow"],
name: "white",
keyword: ["cyan"],
number: "magenta",
regexp: "magenta",
comment1: "grey",
comment2: "grey"
};
var highlight = function (text) {
var colorize = function (str, col) {
if (!col) return str;
if (Array.isArray(col)) {
col.forEach(function (col) {
str = chalk[col](str);
});
} else {
str = chalk[col](str);
}
return str;
};
return tokenize(text, true).map(function (str) {
var type = tokenize.type(str);
return colorize(str, defs[type]);
}).join("");
};
module.exports = function (lines, lineNumber, colNumber) {
colNumber = Math.max(colNumber, 0);
if (supportsColor) {
lines = highlight(lines);
}
lines = lines.split(/\r\n|[\n\r\u2028\u2029]/);
var start = Math.max(lineNumber - 3, 0);
var end = Math.min(lines.length, lineNumber + 3);
var width = (end + "").length;
if (!lineNumber && !colNumber) {
start = 0;
end = lines.length;
}
return "\n" + lines.slice(start, end).map(function (line, i) {
var curr = i + start + 1;
var gutter = curr === lineNumber ? "> " : " ";
var sep = curr + util.repeat(width + 1);
gutter += sep + "| ";
var str = gutter + line;
if (colNumber && curr === lineNumber) {
str += "\n";
str += util.repeat(gutter.length - 2);
str += "|" + util.repeat(colNumber) + "^";
}
return str;
}).join("\n");
};

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,5 +0,0 @@
"use strict";
module.exports = function () {
return Object.create(null);
};

View File

@@ -1,49 +0,0 @@
var normalizeAst = require("./normalize-ast");
var estraverse = require("estraverse");
var codeFrame = require("./code-frame");
var acorn = require("acorn-6to5");
module.exports = function (opts, code, callback) {
try {
var comments = [];
var tokens = [];
var ast = acorn.parse(code, {
allowImportExportEverywhere: opts.allowImportExportEverywhere,
allowReturnOutsideFunction: !opts._anal,
ecmaVersion: opts.experimental ? 7 : 6,
playground: opts.playground,
strictMode: opts.strictMode,
onComment: comments,
locations: true,
onToken: tokens,
ranges: true
});
estraverse.attachComments(ast, comments, tokens);
ast = normalizeAst(ast, comments, tokens);
if (callback) {
return callback(ast);
} else {
return ast;
}
} catch (err) {
if (!err._6to5) {
err._6to5 = true;
var message = opts.filename + ": " + err.message;
var loc = err.loc;
if (loc) {
var frame = codeFrame(code, loc.line, loc.column + 1);
message += frame;
}
if (err.stack) err.stack = err.stack.replace(err.message, message);
err.message = message;
}
throw err;
}
};

View File

@@ -1,17 +0,0 @@
"use strict";
/**
* A trick from Bluebird to force V8 to use fast properties for an object.
* Read more: http://stackoverflow.com/questions/24987896/
*
* Use %HasFastProperties(obj) and --allow-natives-syntax to check whether
* a particular object already has fast properties.
*/
module.exports = function toFastProperties(obj) {
/*jshint -W027*/
function f() {}
f.prototype = obj;
return f;
eval(obj);
};

View File

@@ -1,67 +0,0 @@
"use strict";
var extend = require("lodash/object/extend");
var t = require("./types");
require("./types/node");
// estraverse
var estraverse = require("estraverse");
extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
// regenerator-6to5/ast-types
var types = require("ast-types");
var def = types.Type.def;
var or = types.Type.or;
def("File")
.bases("Node")
.build("program")
.field("program", def("Program"));
def("AssignmentPattern")
.bases("Pattern")
.build("left", "right")
.field("left", def("Pattern"))
.field("right", def("Expression"));
// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
def("ImportBatchSpecifier")
.bases("Specifier")
.build("name")
.field("name", def("Identifier"));
def("RestElement")
.bases("Pattern")
.build("argument")
.field("argument", def("expression"));
// Abstract references
def("VirtualPropertyExpression")
.bases("Expression")
.build("object", "property")
.field("object", def("Expression"))
.field("property", or(def("Identifier"), def("Expression")));
def("PrivateDeclaration")
.bases("Declaration")
.build("declarations")
.field("declarations", [def("Identifier")]);
// Playground
def("BindMemberExpression")
.bases("Expression")
.build("object", "property", "arguments")
.field("object", def("Expression"))
.field("property", or(def("Identifier"), def("Expression")))
.field("arguments", [def("Expression")]);
def("BindFunctionExpression")
.bases("Expression")
.build("callee", "arguments")
.field("callee", def("Expression"))
.field("arguments", [def("Expression")]);
types.finalize();

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,471 +0,0 @@
"use strict";
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 contains = require("lodash/collection/contains");
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.dynamicImportIds = {};
this.dynamicImported = [];
this.dynamicImports = [];
this.dynamicData = {};
this.data = {};
this.lastStatements = [];
this.opts = this.normalizeOptions(opts);
this.ast = {};
this.buildTransformers();
}
File.helpers = [
"inherits",
"defaults",
"prototype-properties",
"apply-constructor",
"tagged-template-literal",
"tagged-template-literal-loose",
"interop-require",
"to-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice",
"bind",
"define-property",
"async-to-generator",
"interop-require-wildcard",
"typeof",
"extends",
"get",
"set",
"class-call-check",
"object-destructuring-empty",
"temporal-undefined",
"temporal-assert-defined",
"tail-call"
];
File.validOptions = [
"filename",
"filenameRelative",
"blacklist",
"whitelist",
"loose",
"optional",
"modules",
"sourceMap",
"sourceMapName",
"sourceFileName",
"sourceRoot",
"moduleRoot",
"moduleIds",
"comments",
"reactCompat",
"keepModuleIdExtensions",
"code",
"ast",
"format",
"playground",
"experimental",
"resolveModuleSource",
"runtime",
// these are used by plugins
"ignore",
"only",
"extensions",
"accept"
];
File.prototype.normalizeOptions = function (opts) {
opts = clone(opts);
for (var key in opts) {
if (key[0] !== "_" && File.validOptions.indexOf(key) < 0) {
throw new ReferenceError("Unknown option: " + key);
}
}
defaults(opts, {
keepModuleIdExtensions: false,
resolveModuleSource: null,
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
loose: [],
code: true,
ast: true
});
// normalize windows path separators to unix
opts.filename = opts.filename.replace(/\\/g, "/");
opts.basename = path.basename(opts.filename, path.extname(opts.filename));
opts.blacklist = util.arrayify(opts.blacklist);
opts.whitelist = util.arrayify(opts.whitelist);
opts.optional = util.arrayify(opts.optional);
opts.loose = util.arrayify(opts.loose);
if (contains(opts.loose, "all")) {
opts.loose = Object.keys(transform.transformers);
}
defaults(opts, {
moduleRoot: opts.sourceRoot
});
defaults(opts, {
sourceRoot: opts.moduleRoot
});
defaults(opts, {
filenameRelative: opts.filename
});
defaults(opts, {
sourceFileName: opts.filenameRelative,
sourceMapName: opts.filenameRelative
});
if (opts.playground) {
opts.experimental = true;
}
if (opts.runtime) {
this.set("runtimeIdentifier", t.identifier("to5Runtime"));
}
opts.blacklist = transform._ensureTransformerNames("blacklist", opts.blacklist);
opts.whitelist = transform._ensureTransformerNames("whitelist", opts.whitelist);
opts.optional = transform._ensureTransformerNames("optional", opts.optional);
opts.loose = transform._ensureTransformerNames("loose", opts.loose);
if (opts.reactCompat) {
opts.optional.push("reactCompat");
console.error("The reactCompat option has been moved into the optional transformer " +
"`reactCompat` - backwards compatibility will be removed in v4.0.0");
}
return opts;
};
File.prototype.isLoose = function (key) {
return contains(this.opts.loose, key);
};
File.prototype.buildTransformers = function () {
var file = this;
var transformers = {};
var secondaryStack = [];
var stack = [];
each(transform.transformers, function (transformer, key) {
var pass = transformers[key] = transformer.buildPass(file);
if (pass.canRun(file)) {
stack.push(pass);
if (transformer.secondPass) {
secondaryStack.push(pass);
}
if (transformer.manipulateOptions) {
transformer.manipulateOptions(file.opts, file);
}
}
});
this.transformerStack = stack.concat(secondaryStack);
this.transformers = transformers;
};
File.prototype.debug = function (msg) {
var parts = this.opts.filename;
if (msg) parts += ": " + msg;
util.debug(parts);
};
File.prototype.toArray = function (node, i) {
if (t.isArrayExpression(node)) {
return node;
} else if (t.isIdentifier(node) && node.name === "arguments") {
return t.callExpression(t.memberExpression(this.addHelper("slice"), t.identifier("call")), [node]);
} else {
var declarationName = "to-array";
var args = [node];
if (i) {
args.push(t.literal(i));
declarationName = "sliced-to-array";
}
return t.callExpression(this.addHelper(declarationName), args);
}
};
File.prototype.getModuleFormatter = function (type) {
var ModuleFormatter = isFunction(type) ? type : transform.moduleFormatters[type];
if (!ModuleFormatter) {
var loc = util.resolve(type);
if (loc) ModuleFormatter = require(loc);
}
if (!ModuleFormatter) {
throw new ReferenceError("Unknown module formatter type " + JSON.stringify(type));
}
return new ModuleFormatter(this);
};
File.prototype.parseShebang = function (code) {
var shebangMatch = code.match(SHEBANG_REGEX);
if (shebangMatch) {
this.shebang = shebangMatch[0];
// remove shebang
code = code.replace(SHEBANG_REGEX, "");
}
return code;
};
File.prototype.set = function (key, val) {
return this.data[key] = val;
};
File.prototype.setDynamic = function (key, fn) {
this.dynamicData[key] = fn;
};
File.prototype.get = function (key) {
var data = this.data[key];
if (data) {
return data;
} else {
var dynamic = this.dynamicData[key];
if (dynamic) {
return this.set(key, dynamic());
}
}
};
File.prototype.addImport = function (source, name) {
name = name || source;
var id = this.dynamicImportIds[name];
if (!id) {
id = this.dynamicImportIds[name] = this.generateUidIdentifier(name);
var specifiers = [t.importSpecifier(t.identifier("default"), id)];
var declar = t.importDeclaration(specifiers, t.literal(source));
declar._blockHoist = 3;
this.dynamicImported.push(declar);
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
}
return id;
};
File.prototype.isConsequenceExpressionStatement = function (node) {
return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0;
};
File.prototype.addHelper = function (name) {
if (!contains(File.helpers, name)) {
throw new ReferenceError("Unknown helper " + name);
}
var program = this.ast.program;
var declar = program._declarations && program._declarations[name];
if (declar) return declar.id;
var runtime = this.get("runtimeIdentifier");
if (runtime) {
name = t.identifier(t.toIdentifier(name));
return t.memberExpression(runtime, name);
} else {
var ref = util.template(name);
ref._compact = true;
var uid = this.generateUidIdentifier(name);
this.scope.push({
key: name,
id: uid,
init: ref
});
return uid;
}
};
File.prototype.errorWithNode = function (node, msg, Error) {
Error = Error || SyntaxError;
var loc = node.loc.start;
var err = new Error("Line " + loc.line + ": " + msg);
err.loc = loc;
return err;
};
File.prototype.addCode = function (code) {
code = (code || "") + "";
this.code = code;
return this.parseShebang(code);
};
File.prototype.parse = function (code) {
var self = this;
code = this.addCode(code);
var opts = this.opts;
opts.allowImportExportEverywhere = this.isLoose("es6.modules");
//opts.strictMode = this.transformers.useStrict.canRun();
return parse(opts, code, function (tree) {
self.transform(tree);
return self.generate();
});
};
File.prototype.transform = function (ast) {
this.debug();
this.ast = ast;
this.lastStatements = t.getLastStatements(ast.program);
this.scope = new Scope(ast.program, ast, null, this);
var modFormatter = this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
if (modFormatter.init && this.transformers["es6.modules"].canRun()) {
modFormatter.init();
}
this.checkNode(ast);
this.call("pre");
each(this.transformerStack, function (pass) {
pass.transform();
});
this.call("post");
};
File.prototype.call = function (key) {
var stack = this.transformerStack;
for (var i = 0; i < stack.length; i++) {
var transformer = stack[i].transformer;
if (transformer[key]) {
transformer[key](this);
}
}
};
var checkTransformerVisitor = {
enter: function (node, parent, scope, state) {
checkNode(state.stack, node, scope);
}
};
var checkNode = function (stack, node, scope) {
each(stack, function (pass) {
if (pass.shouldRun) return;
pass.checkNode(node, scope);
});
};
File.prototype.checkNode = function (node, scope) {
var stack = this.transformerStack;
scope = scope || this.scope;
checkNode(stack, node, scope);
scope.traverse(node, checkTransformerVisitor, {
stack: stack
});
};
File.prototype.generate = function () {
var opts = this.opts;
var ast = this.ast;
var result = {
code: "",
map: null,
ast: null
};
if (opts.ast) result.ast = ast;
if (!opts.code) return result;
var _result = generate(ast, opts, this.code);
result.code = _result.code;
result.map = _result.map;
if (this.shebang) {
// add back shebang
result.code = this.shebang + "\n" + result.code;
}
if (opts.sourceMap === "inline") {
result.code += "\n" + util.sourceMapToComment(result.map);
result.map = null;
}
return result;
};
File.prototype.generateUid = function (name, scope) {
name = t.toIdentifier(name).replace(/^_+/, "");
scope = scope || this.scope;
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (scope.hasReference(uid));
return uid;
};
File.prototype.generateUidIdentifier = function (name, scope) {
scope = scope || this.scope;
var id = t.identifier(this.generateUid(name, scope));
scope.addDeclarationToFunctionScope("var", id);
return id;
};
File.prototype._generateUid = function (name, i) {
var id = name;
if (i > 1) id += i;
return "_" + id;
};

View File

@@ -1,73 +0,0 @@
var cloneDeep = require("lodash/lang/cloneDeep");
var traverse = require("../../traversal");
var clone = require("lodash/lang/clone");
var each = require("lodash/collection/each");
var has = require("lodash/object/has");
var t = require("../../types");
exports.push = function (mutatorMap, key, kind, computed, value) {
var alias;
if (t.isIdentifier(key)) {
alias = key.name;
if (computed) alias = "computed:" + alias;
} else if (t.isLiteral(key)) {
alias = String(key.value);
} else {
alias = JSON.stringify(traverse.removeProperties(cloneDeep(key)));
}
var map;
if (has(mutatorMap, alias)) {
map = mutatorMap[alias];
} else {
map = {};
}
mutatorMap[alias] = map;
map._key = key;
if (computed) {
map._computed = true;
}
map[kind] = value;
};
exports.build = function (mutatorMap) {
var objExpr = t.objectExpression([]);
each(mutatorMap, function (map) {
var mapNode = t.objectExpression([]);
var propNode = t.property("init", map._key, mapNode, map._computed);
if (!map.get && !map.set) {
map.writable = t.literal(true);
}
if (map.enumerable === false) {
delete map.enumerable;
} else {
map.enumerable = t.literal(true);
}
map.configurable = t.literal(true);
each(map, function (node, key) {
if (key[0] === "_") return;
node = clone(node);
var inheritNode = node;
if (t.isMethodDefinition(node)) node = node.value;
var prop = t.property("init", t.identifier(key), node);
t.inheritsComments(prop, inheritNode);
t.removeComments(inheritNode);
mapNode.properties.push(prop);
});
objExpr.properties.push(propNode);
});
return objExpr;
};

View File

@@ -1,53 +0,0 @@
"use strict";
var util = require("../../util");
var t = require("../../types");
var visitor = {
enter: function (node, parent, scope, state) {
// check if this node is an identifier that matches the same as our function id
if (!t.isIdentifier(node, { name: state.id })) return;
// check if this node is the one referenced
if (!t.isReferenced(node, parent)) return;
// check that we don't have a local variable declared as that removes the need
// for the wrapper
var localDeclar = scope.getBinding(state.id);
if (localDeclar !== state.outerDeclar) return;
state.selfReference = true;
this.stop();
}
};
exports.property = function (node, file, scope) {
var key = t.toComputedKey(node, node.key);
if (!t.isLiteral(key)) return node; // we can't set a function id with this
var id = t.toIdentifier(key.value);
key = t.identifier(id);
var state = {
id: id,
selfReference: false,
outerDeclar: scope.getBinding(id),
};
scope.traverse(node, visitor, state);
var method = node.value;
if (state.selfReference) {
var templateName = "property-method-assignment-wrapper";
if (method.generator) templateName += "-generator";
node.value = util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: key,
FUNCTION_KEY: scope.generateUidIdentifier(id),
WRAPPER_KEY: scope.generateUidIdentifier(id + "Wrapper")
});
} else {
method.id = key;
}
};

View File

@@ -1,26 +0,0 @@
var t = require("../../types");
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");
exports.isCreateClass = function (node) {
if (!node || !t.isCallExpression(node)) return false;
// not React.createClass call member object
if (!isCreateClassCallExpression(node.callee)) return false;
// no call arguments
var args = node.arguments;
if (args.length !== 1) return false;
// first node arg is not an object
var first = args[0];
if (!t.isObjectExpression(first)) return false;
return true;
};
exports.isReactComponent = t.buildMatchMemberExpression("React.Component");
exports.isCompatTag = function (tagName) {
return tagName && /^[a-z]|\-/.test(tagName);
};

View File

@@ -1,40 +0,0 @@
"use strict";
var t = require("../../types");
var visitor = {
enter: function (node) {
if (t.isFunction(node)) this.skip();
if (t.isAwaitExpression(node)) {
node.type = "YieldExpression";
if (node.all) {
// await* foo; -> yield Promise.all(foo);
node.all = false;
node.argument = t.callExpression(t.memberExpression(t.identifier("Promise"), t.identifier("all")), [node.argument]);
}
}
}
};
module.exports = function (node, callId, scope) {
node.async = false;
node.generator = true;
scope.traverse(node, visitor);
var call = t.callExpression(callId, [node]);
var id = node.id;
delete node.id;
if (t.isFunctionDeclaration(node)) {
var declar = t.variableDeclaration("let", [
t.variableDeclarator(id, call)
]);
declar._blockHoist = true;
return declar;
} else {
return call;
}
};

View File

@@ -1,302 +0,0 @@
"use strict";
module.exports = ReplaceSupers;
var t = require("../../types");
/**
* Description
*
* @param {Object} opts
* @param {Boolean} [inClass]
*/
function ReplaceSupers(opts, inClass) {
this.topLevelThisReference = opts.topLevelThisReference;
this.methodNode = opts.methodNode;
this.className = opts.className;
this.superName = opts.superName;
this.isStatic = opts.isStatic;
this.hasSuper = false;
this.inClass = inClass;
this.isLoose = opts.isLoose;
this.scope = opts.scope;
this.file = opts.file;
}
/**
* Sets a super class value of the named property.
*
* @example
*
* _set(Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", this)
*
* @param {Node} property
* @param {Node} value
* @param {Boolean} isComputed
* @param {Node} thisExpression
*
* @returns {Node}
*/
ReplaceSupers.prototype.setSuperProperty = function (property, value, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("set"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
value,
thisExpression
]
);
};
/**
* Gets a node representing the super class value of the named property.
*
* @example
*
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
* @param {Node} property
* @param {Boolean} isComputed
* @param {Node} thisExpression
*
* @returns {Node}
*/
ReplaceSupers.prototype.getSuperProperty = function (property, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("get"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
thisExpression
]
);
};
/**
* Description
*/
ReplaceSupers.prototype.replace = function () {
this.traverseLevel(this.methodNode.value, true);
};
var visitor = {
enter: function (node, parent, scope, state) {
var topLevel = state.topLevel;
var self = state.self;
if (t.isFunction(node) && !t.isArrowFunctionExpression(node)) {
// we need to call traverseLevel again so we're context aware
self.traverseLevel(node, false);
return this.skip();
}
if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
// break on object methods
return this.skip();
}
var getThisReference = topLevel ?
// top level so `this` is the instance
t.thisExpression :
// not in the top level so we need to create a reference
self.getThisReference.bind(self);
var callback = self.specHandle;
if (self.isLoose) callback = self.looseHandle;
return callback.call(self, getThisReference, node, parent);
}
};
/**
* Description
*
* @param {Object} node
* @param {Boolean} topLevel
*/
ReplaceSupers.prototype.traverseLevel = function (node, topLevel) {
var state = { self: this, topLevel: topLevel };
this.scope.traverse(node, visitor, state);
};
/**
* Description
*/
ReplaceSupers.prototype.getThisReference = function () {
if (this.topLevelThisReference) {
return this.topLevelThisReference;
} else {
var ref = this.topLevelThisReference = this.file.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(this.topLevelThisReference, t.thisExpression())
]));
return ref;
}
};
/**
* Description
*
* @param {Object} node
* @param {Object} id
* @param {Object} parent
* @returns {Object}
*/
ReplaceSupers.prototype.getLooseSuperProperty = function (id, parent) {
var methodNode = this.methodNode;
var methodName = methodNode.key;
var superName = this.superName || t.identifier("Function");
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> ClassName.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superName, t.identifier("call"));
} else {
id = superName;
// foo() { super(); }
if (!methodNode.static) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
// super.test -> ClassName.prototype.test
return t.memberExpression(superName, t.identifier("prototype"));
} else {
return superName;
}
};
/**
* Description
*
* @param {Function} getThisReference
* @param {Object} node
* @param {Object} parent
*/
ReplaceSupers.prototype.looseHandle = function (getThisReference, node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
this.hasSuper = true;
return this.getLooseSuperProperty(node, parent);
} else if (t.isCallExpression(node)) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// super.test(); -> ClassName.prototype.MethodName.call(this);
this.hasSuper = true;
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(getThisReference());
}
};
/**
* Description
*
* @param {Function} getThisReference
* @param {Object} node
* @param {Object} parent
*/
ReplaceSupers.prototype.specHandle = function (getThisReference, node, parent) {
var methodNode = this.methodNode;
var property;
var computed;
var args;
var thisReference;
if (isIllegalBareSuper(node, parent)) {
throw this.file.errorWithNode(node, "Illegal use of bare super");
}
if (t.isCallExpression(node)) {
var callee = node.callee;
if (isSuper(callee, node)) {
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);
property = methodNode.key;
computed = methodNode.computed;
args = node.arguments;
// bare `super` call is illegal inside non-constructors
// - https://esdiscuss.org/topic/super-call-in-methods
// - https://twitter.com/wycats/status/544553184396836864
if (methodNode.key.name !== "constructor" || !this.inClass) {
var methodName = methodNode.key.name || "METHOD_NAME";
throw this.file.errorWithNode(node, "Direct super call is illegal in non-constructor, use super." + methodName + "() instead");
}
} else if (t.isMemberExpression(callee) && isSuper(callee.object, callee)) {
// super.test(); -> _get(Object.getPrototypeOf(ClassName.prototype), "test", this).call(this);
property = callee.property;
computed = callee.computed;
args = node.arguments;
}
} else if (t.isMemberExpression(node) && isSuper(node.object, node)) {
// super.name; -> _get(Object.getPrototypeOf(ClassName.prototype), "name", this);
property = node.property;
computed = node.computed;
} else if (t.isAssignmentExpression(node) && isSuper(node.left.object, node.left) && methodNode.kind === "set") {
// super.name = "val"; -> _set(Object.getPrototypeOf(ClassName.prototype), "name", this);
this.hasSuper = true;
return this.setSuperProperty(node.left.property, node.right, node.left.computed, getThisReference());
}
if (!property) return;
this.hasSuper = true;
thisReference = getThisReference();
var superProperty = this.getSuperProperty(property, computed, thisReference);
if (args) {
if (args.length === 1 && t.isSpreadElement(args[0])) {
// super(...arguments);
return t.callExpression(
t.memberExpression(superProperty, t.identifier("apply")),
[thisReference, args[0].argument]
);
} else {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call")),
[thisReference].concat(args)
);
}
} else {
return superProperty;
}
};
var isIllegalBareSuper = function (node, parent) {
if (!isSuper(node, parent)) return false;
if (t.isMemberExpression(parent, { computed: false })) return false;
if (t.isCallExpression(parent, { callee: node })) return false;
return true;
};
var isSuper = function (node, parent) {
return t.isIdentifier(node, { name: "super" }) && t.isReferenced(node, parent);
};

View File

@@ -1,21 +0,0 @@
"use strict";
var t = require("../../types");
exports.has = function (node) {
var first = node.body[0];
return t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" });
};
exports.wrap = function (node, callback) {
var useStrictNode;
if (exports.has(node)) {
useStrictNode = node.body.shift();
}
callback();
if (useStrictNode) {
node.body.unshift(useStrictNode);
}
};

View File

@@ -1,73 +0,0 @@
"use strict";
module.exports = transform;
var normalizeAst = require("../helpers/normalize-ast");
var Transformer = require("./transformer");
var object = require("../helpers/object");
var File = require("./file");
var each = require("lodash/collection/each");
function transform(code, opts) {
var file = new File(opts);
return file.parse(code);
}
transform.fromAst = function (ast, code, opts) {
ast = normalizeAst(ast);
var file = new File(opts);
file.addCode(code);
file.transform(ast);
return file.generate();
};
transform._ensureTransformerNames = function (type, rawKeys) {
var keys = [];
for (var i = 0; i < rawKeys.length; i++) {
var key = rawKeys[i];
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"
);
rawKeys.push(deprecatedKey);
} else if (transform.transformers[key]) {
// valid key
keys.push(key);
} else if (transform.namespaces[key]) {
// namespace, append all transformers within this namespace
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/6to5/6to5/blob/master/CHANGELOG.md#300"
);
}
}
return keys;
};
transform.transformers = object();
transform.namespaces = object();
transform.deprecatedTransformerMap = require("./transformers/deprecated");
transform.moduleFormatters = require("./modules");
var rawTransformers = require("./transformers");
each(rawTransformers, function (transformer, key) {
var namespace = key.split(".")[0];
transform.namespaces[namespace] = transform.namespaces[namespace] || [];
transform.namespaces[namespace].push(key);
transform.transformers[key] = new Transformer(key, transformer);
});

View File

@@ -1,301 +0,0 @@
"use strict";
module.exports = DefaultFormatter;
var object = require("../../helpers/object");
var util = require("../../util");
var t = require("../../types");
var extend = require("lodash/object/extend");
function DefaultFormatter(file) {
this.file = file;
this.ids = object();
this.hasNonDefaultExports = false;
this.hasLocalExports = false;
this.hasLocalImports = false;
this.localImportOccurences = object();
this.localExports = object();
this.localImports = object();
this.getLocalExports();
this.getLocalImports();
this.remapAssignments();
}
DefaultFormatter.prototype.doDefaultExportInterop = function (node) {
return node.default && !this.noInteropRequireExport && !this.hasNonDefaultExports;
};
DefaultFormatter.prototype.bumpImportOccurences = function (node) {
var source = node.source.value;
var occurs = this.localImportOccurences;
occurs[source] = occurs[source] || 0;
occurs[source] += node.specifiers.length;
};
var exportsVisitor = {
enter: function (node, parent, scope, formatter) {
var declar = node && node.declaration;
if (t.isExportDeclaration(node)) {
formatter.hasLocalImports = true;
if (declar && t.isStatement(declar)) {
extend(formatter.localExports, t.getBindingIdentifiers(declar));
}
if (!node.default) {
formatter.hasNonDefaultExports = true;
}
if (node.source) {
formatter.bumpImportOccurences(node);
}
}
}
};
DefaultFormatter.prototype.getLocalExports = function () {
this.file.scope.traverse(this.file.ast, exportsVisitor, this);
};
var importsVisitor = {
enter: function (node, parent, scope, formatter) {
if (t.isImportDeclaration(node)) {
formatter.hasLocalImports = true;
extend(formatter.localImports, t.getBindingIdentifiers(node));
formatter.bumpImportOccurences(node);
}
}
};
DefaultFormatter.prototype.getLocalImports = function () {
this.file.scope.traverse(this.file.ast, importsVisitor, this);
};
var remapVisitor = {
enter: function (node, parent, scope, formatter) {
if (t.isUpdateExpression(node) && formatter.isLocalReference(node.argument, scope)) {
this.skip();
// expand to long file assignment expression
var assign = t.assignmentExpression(node.operator[0] + "=", node.argument, t.literal(1));
// remap this assignment expression
var remapped = formatter.remapExportAssignment(assign);
// we don't need to change the result
if (t.isExpressionStatement(parent) || node.prefix) {
return remapped;
}
var nodes = [];
nodes.push(remapped);
var operator;
if (node.operator === "--") {
operator = "+";
} else { // "++"
operator = "-";
}
nodes.push(t.binaryExpression(operator, node.argument, t.literal(1)));
return t.sequenceExpression(nodes);
}
if (t.isAssignmentExpression(node) && formatter.isLocalReference(node.left, scope)) {
this.skip();
return formatter.remapExportAssignment(node);
}
}
};
DefaultFormatter.prototype.remapAssignments = function () {
if (this.hasLocalImports) {
this.file.scope.traverse(this.file.ast, remapVisitor, this);
}
};
DefaultFormatter.prototype.isLocalReference = function (node) {
var localImports = this.localImports;
return t.isIdentifier(node) && localImports[node.name] && localImports[node.name] !== node;
};
DefaultFormatter.prototype.checkLocalReference = function (node) {
var file = this.file;
if (this.isLocalReference(node)) {
throw file.errorWithNode(node, "Illegal assignment of module import");
}
};
DefaultFormatter.prototype.remapExportAssignment = function (node) {
return t.assignmentExpression(
"=",
node.left,
t.assignmentExpression(
node.operator,
t.memberExpression(t.identifier("exports"), node.left),
node.right
)
);
};
DefaultFormatter.prototype.isLocalReference = function (node, scope) {
var localExports = this.localExports;
var name = node.name;
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.getBinding(name);
};
DefaultFormatter.prototype.getModuleName = function () {
var opts = this.file.opts;
var filenameRelative = opts.filenameRelative;
var moduleName = "";
if (opts.moduleRoot) {
moduleName = opts.moduleRoot + "/";
}
if (!opts.filenameRelative) {
return moduleName + opts.filename.replace(/^\//, "");
}
if (opts.sourceRoot) {
// remove sourceRoot from filename
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?");
filenameRelative = filenameRelative.replace(sourceRootRegEx, "");
}
if (!opts.keepModuleIdExtensions) {
// remove extension
filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");
}
moduleName += filenameRelative;
// normalize path separators
moduleName = moduleName.replace(/\\/g, "/");
return moduleName;
};
DefaultFormatter.prototype._pushStatement = function (ref, nodes) {
if (t.isClass(ref) || t.isFunction(ref)) {
if (ref.id) {
nodes.push(t.toStatement(ref));
ref = ref.id;
}
}
return ref;
};
DefaultFormatter.prototype._hoistExport = function (declar, assign, priority) {
if (t.isFunctionDeclaration(declar)) {
assign._blockHoist = priority || 2;
}
return assign;
};
DefaultFormatter.prototype.getExternalReference = function (node, nodes) {
var ids = this.ids;
var id = node.source.value;
if (ids[id]) {
return ids[id];
} else {
return this.ids[id] = this._getExternalReference(node, nodes);
}
};
DefaultFormatter.prototype.checkExportIdentifier = function (node) {
if (t.isIdentifier(node, { name: "__esModule" })) {
throw this.file.errorWithNode(node, "Illegal export __esModule - this is used internally for CommonJS interop");
}
};
DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
if (node.source) {
var ref = this.getExternalReference(node, nodes);
if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
nodes.push(this.buildExportsWildcard(ref, node));
} else {
if (t.isSpecifierDefault(specifier) && !this.noInteropRequireExport) {
// importing a default so we need to normalize it
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
ref = t.memberExpression(ref, t.getSpecifierId(specifier));
}
// export { foo } from "test";
nodes.push(this.buildExportsAssignment(
t.getSpecifierName(specifier),
ref,
node
));
}
} else {
// export { foo };
nodes.push(this.buildExportsAssignment(t.getSpecifierName(specifier), specifier.id, node));
}
};
DefaultFormatter.prototype.buildExportsWildcard = function (objectIdentifier) {
return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [
t.identifier("exports"),
t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])
]));
};
DefaultFormatter.prototype.buildExportsAssignment = function (id, init) {
this.checkExportIdentifier(id);
return util.template("exports-assign", {
VALUE: init,
KEY: id
}, true);
};
DefaultFormatter.prototype.exportDeclaration = function (node, nodes) {
var declar = node.declaration;
var id = declar.id;
if (node.default) {
id = t.identifier("default");
}
var assign;
if (t.isVariableDeclaration(declar)) {
for (var i = 0; i < declar.declarations.length; i++) {
var decl = declar.declarations[i];
decl.init = this.buildExportsAssignment(decl.id, decl.init, node).expression;
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === 0) t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
var ref = declar;
if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
ref = declar.id;
nodes.push(declar);
}
assign = this.buildExportsAssignment(id, ref, node);
nodes.push(assign);
this._hoistExport(declar, assign);
}
};

View File

@@ -1,3 +0,0 @@
"use strict";
module.exports = require("./_strict")(require("./amd"));

View File

@@ -1,108 +0,0 @@
"use strict";
module.exports = AMDFormatter;
var DefaultFormatter = require("./_default");
var CommonFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
var contains = require("lodash/collection/contains");
var values = require("lodash/object/values");
function AMDFormatter() {
CommonFormatter.apply(this, arguments);
}
util.inherits(AMDFormatter, DefaultFormatter);
AMDFormatter.prototype.init = CommonFormatter.prototype.init;
AMDFormatter.prototype.buildDependencyLiterals = function () {
var names = [];
for (var name in this.ids) {
names.push(t.literal(name));
}
return names;
};
/**
* Wrap the entire body in a `define` wrapper.
*/
AMDFormatter.prototype.transform = function (program) {
var body = program.body;
// build an array of module names
var names = [t.literal("exports")];
if (this.passModuleArg) names.push(t.literal("module"));
names = names.concat(this.buildDependencyLiterals());
names = t.arrayExpression(names);
// build up define container
var params = values(this.ids);
if (this.passModuleArg) params.unshift(t.identifier("module"));
params.unshift(t.identifier("exports"));
var container = t.functionExpression(null, params, t.blockStatement(body));
var defineArgs = [names, container];
var moduleName = this.getModuleName();
if (moduleName) defineArgs.unshift(t.literal(moduleName));
var call = t.callExpression(t.identifier("define"), defineArgs);
program.body = [t.expressionStatement(call)];
};
/**
* Get the AMD module name that we'll prepend to the wrapper
* to define this module
*/
AMDFormatter.prototype.getModuleName = function () {
if (this.file.opts.moduleIds) {
return DefaultFormatter.prototype.getModuleName.apply(this, arguments);
} else {
return null;
}
};
AMDFormatter.prototype._getExternalReference = function (node) {
return this.file.generateUidIdentifier(node.source.value);
};
AMDFormatter.prototype.importDeclaration = function (node) {
this.getExternalReference(node);
};
AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var key = t.getSpecifierName(specifier);
var ref = this.getExternalReference(node);
if (contains(this.file.dynamicImported, node)) {
// Prevent unnecessary renaming of dynamic imports.
this.ids[node.source.value] = ref;
} else if (t.isImportBatchSpecifier(specifier)) {
// import * as bar from "foo";
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequireImport) {
// import foo from "foo";
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
// import {foo} from "foo";
ref = t.memberExpression(ref, t.getSpecifierId(specifier), false);
}
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(key, ref)
]));
};
AMDFormatter.prototype.exportDeclaration = function (node) {
if (this.doDefaultExportInterop(node)) {
this.passModuleArg = true;
}
CommonFormatter.prototype.exportDeclaration.apply(this, arguments);
};

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,3 +0,0 @@
"use strict";
module.exports = require("./_strict")(require("./common"));

View File

@@ -1,99 +0,0 @@
"use strict";
module.exports = CommonJSFormatter;
var DefaultFormatter = require("./_default");
var contains = require("lodash/collection/contains");
var util = require("../../util");
var t = require("../../types");
function CommonJSFormatter() {
DefaultFormatter.apply(this, arguments);
}
util.inherits(CommonJSFormatter, DefaultFormatter);
CommonJSFormatter.prototype.init = function () {
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
this.file.ast.program.body.push(util.template("exports-module-declaration", true));
}
};
CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var variableName = t.getSpecifierName(specifier);
var ref = this.getExternalReference(node, nodes);
// import foo from "foo";
if (t.isSpecifierDefault(specifier)) {
if (!contains(this.file.dynamicImported, node)) {
if (this.noInteropRequireImport) {
ref = t.memberExpression(ref, t.identifier("default"));
} else {
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
}
}
nodes.push(t.variableDeclaration("var", [t.variableDeclarator(variableName, ref)]));
} else {
if (specifier.type === "ImportBatchSpecifier") {
if (!this.noInteropRequireImport) {
ref = t.callExpression(this.file.addHelper("interop-require-wildcard"), [ref]);
}
// import * as bar from "foo";
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(variableName, ref)
]));
} else {
// import { foo } from "foo";
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(
variableName,
t.memberExpression(ref, t.getSpecifierId(specifier))
)
]));
}
}
};
CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
// import "foo";
nodes.push(util.template("require", {
MODULE_NAME: node.source
}, true));
};
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
if (this.doDefaultExportInterop(node)) {
var declar = node.declaration;
var assign = util.template("exports-default-assign", {
VALUE: this._pushStatement(declar, nodes)
}, true);
if (t.isFunctionDeclaration(declar)) {
// we can hoist this assignment to the top of the file
assign._blockHoist = 3;
}
nodes.push(assign);
return;
}
DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
};
CommonJSFormatter.prototype._getExternalReference = function (node, nodes) {
var source = node.source.value;
var call = t.callExpression(t.identifier("require"), [node.source]);
if (this.localImportOccurences[source] > 1) {
var uid = this.file.generateUidIdentifier(source);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(uid, call)
]));
return uid;
} else {
return call;
}
};

View File

@@ -1,20 +0,0 @@
"use strict";
module.exports = IgnoreFormatter;
var t = require("../../types");
function IgnoreFormatter() {
}
IgnoreFormatter.prototype.exportDeclaration = function (node, nodes) {
var declar = t.toStatement(node.declaration, true);
if (declar) nodes.push(t.inherits(declar, node));
};
IgnoreFormatter.prototype.importDeclaration =
IgnoreFormatter.prototype.importSpecifier =
IgnoreFormatter.prototype.exportSpecifier = function () {
};

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,201 +0,0 @@
"use strict";
module.exports = SystemFormatter;
var DefaultFormatter = require("./_default");
var AMDFormatter = require("./amd");
var useStrict = require("../helpers/use-strict");
var util = require("../../util");
var t = require("../../types");
var last = require("lodash/array/last");
var each = require("lodash/collection/each");
var map = require("lodash/collection/map");
function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.noInteropRequireExport = true;
this.noInteropRequireImport = true;
DefaultFormatter.apply(this, arguments);
}
util.inherits(SystemFormatter, AMDFormatter);
SystemFormatter.prototype.init = function () {};
SystemFormatter.prototype._addImportSource = function (node, exportNode) {
node._importSource = exportNode.source && exportNode.source.value;
return node;
};
SystemFormatter.prototype.buildExportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [
t.variableDeclarator(leftIdentifier)
]);
var right = objectIdentifier;
var block = t.blockStatement([
t.expressionStatement(this.buildExportCall(leftIdentifier, valIdentifier))
]);
return this._addImportSource(t.forInStatement(left, right, block), node);
};
SystemFormatter.prototype.buildExportsAssignment = function (id, init, node) {
var call = this.buildExportCall(t.literal(id.name), init, true);
return this._addImportSource(call, node);
};
SystemFormatter.prototype.remapExportAssignment = function (node) {
return this.buildExportCall(t.literal(node.left.name), node);
};
SystemFormatter.prototype.buildExportCall = function (id, init, isStatement) {
var call = t.callExpression(this.exportIdentifier, [id, init]);
if (isStatement) {
return t.expressionStatement(call);
} else {
return call;
}
};
SystemFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
AMDFormatter.prototype.importSpecifier.apply(this, arguments);
this._addImportSource(last(nodes), node);
};
var runnerSettersVisitor = {
enter: function (node, parent, scope, state) {
if (node._importSource === state.source) {
if (t.isVariableDeclaration(node)) {
each(node.declarations, function (declar) {
state.hoistDeclarators.push(t.variableDeclarator(declar.id));
state.nodes.push(t.expressionStatement(
t.assignmentExpression("=", declar.id, declar.init)
));
});
} else {
state.nodes.push(node);
}
this.remove();
}
}
};
SystemFormatter.prototype.buildRunnerSetters = function (block, hoistDeclarators) {
var scope = this.file.scope;
return t.arrayExpression(map(this.ids, function (uid, source) {
var state = {
source: source,
nodes: [],
hoistDeclarators: hoistDeclarators
};
scope.traverse(block, runnerSettersVisitor, state);
return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
}));
};
var hoistVariablesVisitor = {
enter: function (node, parent, scope, hoistDeclarators) {
if (t.isFunction(node)) {
// nothing inside is accessible
return this.skip();
}
if (t.isVariableDeclaration(node)) {
if (node.kind !== "var" && !t.isProgram(parent)) { // let, const
// can't be accessed
return;
}
// ignore block hoisted nodes as these can be left in
if (node._blockHoist) return;
var nodes = [];
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
hoistDeclarators.push(t.variableDeclarator(declar.id));
if (declar.init) {
// no initializer so we can just hoist it as-is
var assign = t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init));
nodes.push(assign);
}
}
// for (var i in test)
// for (var i = 0;;)
if (t.isFor(parent)) {
if (parent.left === node) {
return node.declarations[0].id;
}
if (parent.init === node) {
return t.toSequenceExpression(nodes, scope);
}
}
return nodes;
}
}
};
var hoistFunctionsVisitor = {
enter: function (node, parent, scope, handlerBody) {
if (t.isFunction(node)) this.skip();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
this.remove();
}
}
};
SystemFormatter.prototype.transform = function (program) {
var hoistDeclarators = [];
var moduleName = this.getModuleName();
var moduleNameLiteral = t.literal(moduleName);
var block = t.blockStatement(program.body);
var runner = util.template("system", {
MODULE_NAME: moduleNameLiteral,
MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
EXPORT_IDENTIFIER: this.exportIdentifier,
SETTERS: this.buildRunnerSetters(block, hoistDeclarators),
EXECUTE: t.functionExpression(null, [], block)
}, true);
var handlerBody = runner.expression.arguments[2].body.body;
if (!moduleName) runner.expression.arguments.shift();
var returnStatement = handlerBody.pop();
// hoist up all variable declarations
this.file.scope.traverse(block, hoistVariablesVisitor, hoistDeclarators);
if (hoistDeclarators.length) {
var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
hoistDeclar._blockHoist = true;
handlerBody.unshift(hoistDeclar);
}
// hoist up function declarations for circular references
this.file.scope.traverse(block, hoistFunctionsVisitor, handlerBody);
handlerBody.push(returnStatement);
if (useStrict.has(block)) {
handlerBody.unshift(block.body.shift());
}
program.body = [runner];
};

View File

@@ -1,3 +0,0 @@
"use strict";
module.exports = require("./_strict")(require("./umd"));

View File

@@ -1,73 +0,0 @@
"use strict";
module.exports = UMDFormatter;
var AMDFormatter = require("./amd");
var util = require("../../util");
var t = require("../../types");
var values = require("lodash/object/values");
function UMDFormatter() {
AMDFormatter.apply(this, arguments);
}
util.inherits(UMDFormatter, AMDFormatter);
UMDFormatter.prototype.transform = function (program) {
var body = program.body;
// build an array of module names
var names = [];
for (var name in this.ids) {
names.push(t.literal(name));
}
// factory
var ids = values(this.ids);
var args = [t.identifier("exports")];
if (this.passModuleArg) args.push(t.identifier("module"));
args = args.concat(ids);
var factory = t.functionExpression(null, args, t.blockStatement(body));
// amd
var defineArgs = [t.literal("exports")];
if (this.passModuleArg) defineArgs.push(t.literal("module"));
defineArgs = defineArgs.concat(names);
defineArgs = [t.arrayExpression(defineArgs)];
// common
var testExports = util.template("test-exports");
var testModule = util.template("test-module");
var commonTests = this.passModuleArg ? t.logicalExpression("&&", testExports, testModule) : testExports;
var commonArgs = [t.identifier("exports")];
if (this.passModuleArg) commonArgs.push(t.identifier("module"));
commonArgs = commonArgs.concat(names.map(function (name) {
return t.callExpression(t.identifier("require"), [name]);
}));
// globals
//var umdArgs = [];
//
var moduleName = this.getModuleName();
if (moduleName) defineArgs.unshift(t.literal(moduleName));
var runner = util.template("umd-runner-body", {
AMD_ARGUMENTS: defineArgs,
COMMON_TEST: commonTests,
COMMON_ARGUMENTS: commonArgs
});
//
var call = t.callExpression(runner, [factory]);
program.body = [t.expressionStatement(call)];
};

View File

@@ -1,5 +0,0 @@
(function (Constructor, args) {
var instance = Object.create(Constructor.prototype);
var result = Constructor.apply(instance, args);
return result != null && (typeof result == "object" || typeof result == "function") ? result : instance;
});

View File

@@ -1 +0,0 @@
CORE_ID.$for.getIterator(VALUE);

View File

@@ -1,8 +0,0 @@
(function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
})

View File

@@ -1,3 +0,0 @@
for (var ITERATOR_KEY = OBJECT[Symbol.iterator](), STEP_KEY; !(STEP_KEY = ITERATOR_KEY.next()).done; ) {
}

View File

@@ -1,4 +0,0 @@
(function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
})

View File

@@ -1,3 +0,0 @@
for (var LEN = ARGUMENTS.length, ARRAY = Array(ARRAY_LEN), KEY = START; KEY < LEN; KEY++) {
ARRAY[ARRAY_KEY] = ARGUMENTS[KEY];
}

View File

@@ -1,13 +0,0 @@
{
var ARGUMENTS_ID = arguments,
THIS_ID = this,
SHOULD_CONTINUE_ID,
RESULT_ID;
do {
SHOULD_CONTINUE_ID = false;
RESULT_ID = FUNCTION.apply(THIS_ID, ARGUMENTS_ID);
} while(SHOULD_CONTINUE_ID);
return RESULT_ID;
}

View File

@@ -1,23 +0,0 @@
(function () {
function Tail(func, args, context) {
this.func = func;
this.args = args;
this.context = context;
}
Tail.prototype._isTailDescriptor = true;
var isRunning = false;
return function (func, args, context) {
var result = new Tail(func, args, context);
if (!isRunning) {
isRunning = true;
do {
result = result.func.apply(result.context, result.args);
} while (result instanceof Tail || (result && result._isTailDescriptor));
isRunning = false;
}
return result;
};
})()

View File

@@ -1,63 +0,0 @@
module.exports = TransformerPass;
var contains = require("lodash/collection/contains");
/**
* This class is responsible for traversing over the provided `File`s
* AST and running it's parent transformers handlers over it.
*/
function TransformerPass(file, transformer) {
this.transformer = transformer;
this.shouldRun = !transformer.check;
this.handlers = transformer.handlers;
this.file = file;
}
TransformerPass.prototype.canRun = function () {
var transformer = this.transformer;
var opts = this.file.opts;
var key = transformer.key;
// internal
if (key[0] === "_") return true;
// blacklist
var blacklist = opts.blacklist;
if (blacklist.length && contains(blacklist, key)) return false;
// whitelist
var whitelist = opts.whitelist;
if (whitelist.length) return contains(whitelist, key);
// optional
if (transformer.optional && !contains(opts.optional, key)) return false;
// experimental
if (transformer.experimental && !opts.experimental) return false;
// playground
if (transformer.playground && !opts.playground) return false;
return true;
};
TransformerPass.prototype.checkNode = function (node) {
var check = this.transformer.check;
if (check) {
return this.shouldRun = check(node);
} else {
return true;
}
};
TransformerPass.prototype.transform = function () {
if (!this.shouldRun) return;
var file = this.file;
file.debug("Running transformer " + this.transformer.key);
file.scope.traverse(file.ast, this.handlers, file);
};

View File

@@ -1,73 +0,0 @@
"use strict";
module.exports = Transformer;
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 each = require("lodash/collection/each");
/**
* This is the class responsible for normalising a transformers handlers
* as well as constructing a `TransformerPass` that is repsonsible for
* actually running the transformer over the provided `File`.
*/
function Transformer(key, transformer, opts) {
transformer = clone(transformer);
var take = function (key) {
var val = transformer[key];
delete transformer[key];
return val;
};
this.manipulateOptions = take("manipulateOptions");
this.check = take("check");
this.post = take("post");
this.pre = take("pre");
this.experimental = !!take("experimental");
this.playground = !!take("playground");
this.secondPass = !!take("secondPass");
this.optional = !!take("optional");
this.handlers = this.normalize(transformer);
this.opts = opts || {};
this.key = key;
}
Transformer.prototype.normalize = function (transformer) {
var self = this;
if (isFunction(transformer)) {
transformer = { ast: transformer };
}
traverse.explode(transformer);
each(transformer, function (fns, type) {
// hidden property
if (type[0] === "_") {
self[type] = fns;
return;
}
if (isFunction(fns)) fns = { enter: fns };
if (!isObject(fns)) return;
if (!fns.enter) fns.enter = function () { };
if (!fns.exit) fns.exit = function () { };
transformer[type] = fns;
});
return transformer;
};
Transformer.prototype.buildPass = function (file) {
return new TransformerPass(file, this);
};

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

@@ -1,16 +0,0 @@
"use strict";
var t = require("../../../types");
exports.MemberExpression = function (node) {
var prop = node.property;
if (node.computed && t.isLiteral(prop) && t.isValidIdentifier(prop.value)) {
// foo["bar"] => foo.bar
node.property = t.identifier(prop.value);
node.computed = false;
} else if (!node.computed && t.isIdentifier(prop) && !t.isValidIdentifier(prop.name)) {
// foo.default -> foo["default"]
node.property = t.literal(prop.name);
node.computed = true;
}
};

View File

@@ -1,15 +0,0 @@
"use strict";
var t = require("../../../types");
exports.Property = function (node) {
var key = node.key;
if (t.isLiteral(key) && t.isValidIdentifier(key.value)) {
// "foo": "bar" -> foo: "bar"
node.key = t.identifier(key.value);
node.computed = false;
} else if (!node.computed && t.isIdentifier(key) && !t.isValidIdentifier(key.name)) {
// default: "bar" -> "default": "bar"
node.key = t.literal(key.name);
}
};

View File

@@ -1,30 +0,0 @@
"use strict";
var defineMap = require("../../helpers/define-map");
var t = require("../../../types");
exports.check = function (node) {
return t.isProperty(node) && (node.kind === "get" || node.kind === "set");
};
exports.ObjectExpression = function (node) {
var mutatorMap = {};
var hasAny = false;
node.properties = node.properties.filter(function (prop) {
if (prop.kind === "get" || prop.kind === "set") {
hasAny = true;
defineMap.push(mutatorMap, prop.key, prop.kind, prop.computed, prop.value);
return false;
} else {
return true;
}
});
if (!hasAny) return;
return t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
[node, defineMap.build(mutatorMap)]
);
};

View File

@@ -1,116 +0,0 @@
"use strict";
var t = require("../../../types");
function transformExpression(node, scope, state) {
if (!node) return;
return (function subTransform(node) {
switch (node.type) {
case "ConditionalExpression":
// any value of ternary operator can be final one
subTransform(node.consequent);
subTransform(node.alternate);
break;
case "LogicalExpression":
// only right expression can be final and so optimized
subTransform(node.right);
break;
case "SequenceExpression":
// only last element of sequence can be optimized
var seq = node.expressions;
subTransform(seq[seq.length - 1]);
break;
case "CallExpression":
var callee = node.callee, thisBinding;
var args = [callee];
// bind `this` to object in member expressions
if (t.isMemberExpression(callee)) {
var object = state.wrapSideEffect(callee.object);
callee.object = object.expr;
thisBinding = object.ref;
}
if (node.arguments.length > 0 || thisBinding) {
args.push(t.arrayExpression(node.arguments));
}
if (thisBinding) {
args.push(thisBinding);
}
node.callee = state.getHelperRef();
node.arguments = args;
break;
}
})(node);
}
var functionChildrenVisitor = {
enter: function (node, parent, scope, state) {
if (t.isReturnStatement(node)) {
// prevent entrance by current visitor
this.skip();
// transform return argument into statement if
// it contains tail recursion
transformExpression(node.argument, scope, state);
} else if (t.isFunction(node)) {
// inner function's bodies are irrelevant
this.skip();
} else if (t.isTryStatement(parent)) {
if (node === parent.block) {
// `try`-blocks can't be optimized
this.skip();
} else if (parent.finalizer && node !== parent.finalizer) {
// `catch` clause followed by `finally` can't be optimized
this.skip();
}
}
}
};
var functionVisitor = {
enter: function (node, parent, scope, state) {
// traverse all child nodes of this function and find `arguments` and `this`
scope.traverse(node, functionChildrenVisitor, state);
return this.skip();
}
};
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, parent, scope, file) {
var tempId, helperRef;
var state = {
ownerId: node.id,
getHelperRef: function () {
return helperRef = helperRef || file.addHelper("tail-call");
},
wrapSideEffect: function (node) {
if (t.isIdentifier(node) || t.isLiteral(node)) {
return {expr: node, ref: node};
}
tempId = tempId || scope.generateUidIdentifier("temp");
return {
expr: t.assignmentExpression("=", tempId, node),
ref: tempId
};
}
};
// traverse the function and look for tail recursion
scope.traverse(node, functionVisitor, state);
if (tempId) {
t.ensureBlock(node).body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(tempId)
]));
}
};

View File

@@ -1,15 +0,0 @@
"use strict";
var t = require("../../../types");
exports.check = t.isArrowFunctionExpression;
exports.ArrowFunctionExpression = function (node) {
t.ensureBlock(node);
node._aliasFunction = "arrow";
node.expression = false;
node.type = "FunctionExpression";
return node;
};

View File

@@ -1,45 +0,0 @@
"use strict";
var t = require("../../../types");
var visitor = {
enter: function (node, parent, scope, state) {
if (!t.isReferencedIdentifier(node, parent)) return;
var declared = state.letRefs[node.name];
if (!declared) return;
// declared node is different in this scope
if (scope.getBinding(node.name) !== declared) return;
var assert = t.callExpression(
state.file.addHelper("temporal-assert-defined"),
[node, t.literal(node.name), state.file.addHelper("temporal-undefined")]
);
this.skip();
if (t.isAssignmentExpression(parent) || t.isUpdateExpression(parent)) {
if (parent._ignoreBlockScopingTDZ) return;
this.parentPath.replaceNode(t.sequenceExpression([assert, parent]));
} else {
return t.logicalExpression("&&", assert, node);
}
}
};
exports.optional = true;
exports.Loop =
exports.Program =
exports.BlockStatement = function (node, parent, scope, file) {
var letRefs = node._letReferences;
if (!letRefs) return;
var state = {
letRefs: letRefs,
file: file
};
scope.traverse(node, visitor, state);
};

View File

@@ -1,540 +0,0 @@
"use strict";
var traverse = require("../../../traversal");
var object = require("../../../helpers/object");
var util = require("../../../util");
var t = require("../../../types");
var values = require("lodash/object/values");
var extend = require("lodash/object/extend");
exports.check = function (node) {
return t.isVariableDeclaration(node) && (node.kind === "let" || node.kind === "const");
};
var isLet = function (node, parent) {
if (!t.isVariableDeclaration(node)) return false;
if (node._let) return true;
if (node.kind !== "let") return false;
// https://github.com/6to5/6to5/issues/255
if (isLetInitable(node, parent)) {
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
declar.init = declar.init || t.identifier("undefined");
}
}
node._let = true;
node.kind = "var";
return true;
};
var isLetInitable = function (node, parent) {
return !t.isFor(parent) || t.isFor(parent) && parent.left !== node;
};
var isVar = function (node, parent) {
return t.isVariableDeclaration(node, { kind: "var" }) && !isLet(node, parent);
};
var standardizeLets = function (declars) {
for (var i = 0; i < declars.length; i++) {
delete declars[i]._let;
}
};
exports.VariableDeclaration = function (node, parent, scope, file) {
if (!isLet(node, parent)) return;
if (isLetInitable(node) && file.transformers["es6.blockScopingTDZ"].canRun()) {
var nodes = [node];
for (var i = 0; i < node.declarations.length; i++) {
var decl = node.declarations[i];
if (decl.init) {
var assign = t.assignmentExpression("=", decl.id, decl.init);
assign._ignoreBlockScopingTDZ = true;
nodes.push(t.expressionStatement(assign));
}
decl.init = file.addHelper("temporal-undefined");
}
node._blockHoist = 2;
return nodes;
}
};
exports.Loop = function (node, parent, scope, file) {
var init = node.left || node.init;
if (isLet(init, node)) {
t.ensureBlock(node);
node.body._letDeclarators = [init];
}
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
blockScoping.run();
};
exports.Program =
exports.BlockStatement = function (block, parent, scope, file) {
if (!t.isLoop(parent)) {
var blockScoping = new BlockScoping(false, block, parent, scope, file);
blockScoping.run();
}
};
/**
* Description
*
* @param {Boolean|Node} loopParent
* @param {Node} block
* @param {Node} parent
* @param {Scope} scope
* @param {File} file
*/
function BlockScoping(loopParent, block, parent, scope, file) {
this.loopParent = loopParent;
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
this.outsideLetReferences = object();
this.hasLetReferences = false;
this.letReferences = block._letReferences = object();
this.body = [];
}
/**
* Start the ball rolling.
*/
BlockScoping.prototype.run = function () {
var block = this.block;
if (block._letDone) return;
block._letDone = true;
var needsClosure = this.getLetReferences();
// this is a block within a `Function/Program` so we can safely leave it be
if (t.isFunction(this.parent) || t.isProgram(this.block)) return;
// we can skip everything
if (!this.hasLetReferences) return;
if (needsClosure) {
this.needsClosure();
} else {
this.remap();
}
};
function replace(node, parent, scope, remaps) {
if (!t.isReferencedIdentifier(node, parent)) return;
var remap = remaps[node.name];
if (!remap) return;
var ownBinding = scope.getBinding(node.name);
if (ownBinding === remap.binding) {
node.name = remap.uid;
} else {
// scope already has it's own binding that doesn't
// match the one we have a stored replacement for
if (this) this.skip();
}
}
var replaceVisitor = {
enter: replace
};
function traverseReplace(node, parent, scope, remaps) {
replace(node, parent, scope, remaps);
scope.traverse(node, replaceVisitor, remaps);
}
/**
* Description
*/
BlockScoping.prototype.remap = function () {
var hasRemaps = false;
var letRefs = this.letReferences;
var scope = this.scope;
// alright, so since we aren't wrapping this block in a closure
// we have to check if any of our let variables collide with
// those in upper scopes and then if they do, generate a uid
// for them and replace all references with it
var remaps = object();
for (var key in letRefs) {
// just an Identifier node we collected in `getLetReferences`
// this is the defining identifier of a declaration
var ref = letRefs[key];
if (scope.parentHasReference(key)) {
var uid = scope.generateUidIdentifier(ref.name).name;
ref.name = uid;
hasRemaps = true;
remaps[key] = remaps[uid] = {
binding: ref,
uid: uid
};
}
}
if (!hasRemaps) return;
//
var loopParent = this.loopParent;
if (loopParent) {
traverseReplace(loopParent.right, loopParent, scope, remaps);
traverseReplace(loopParent.test, loopParent, scope, remaps);
traverseReplace(loopParent.update, loopParent, scope, remaps);
}
scope.traverse(this.block, replaceVisitor, remaps);
};
/**
* Description
*/
BlockScoping.prototype.needsClosure = function () {
var block = this.block;
// if we're inside of a for loop then we search to see if there are any
// `break`s, `continue`s, `return`s etc
this.has = this.checkLoop();
// hoist var references to retain scope
this.hoistVarDeclarations();
// turn outsideLetReferences into an array
var params = values(this.outsideLetReferences);
// build the closure that we're going to wrap the block with
var fn = t.functionExpression(null, params, t.blockStatement(block.body));
fn._aliasFunction = true;
// replace the current block body with the one we're going to build
block.body = this.body;
// build a call and a unique id that we can assign the return value to
var call = t.callExpression(fn, params);
var ret = this.scope.generateUidIdentifier("ret");
// handle generators
var hasYield = traverse.hasType(fn.body, this.scope, "YieldExpression", t.FUNCTION_TYPES);
if (hasYield) {
fn.generator = true;
call = t.yieldExpression(call, true);
}
// handlers async functions
var hasAsync = traverse.hasType(fn.body, this.scope, "AwaitExpression", t.FUNCTION_TYPES);
if (hasAsync) {
fn.async = true;
call = t.awaitExpression(call, true);
}
this.build(ret, call);
};
var letReferenceFunctionVisitor = {
enter: function (node, parent, scope, state) {
// not a direct reference
if (!t.isReferencedIdentifier(node, parent)) return;
// this scope has a variable with the same name so it couldn't belong
// to our let scope
if (scope.hasOwnBinding(node.name)) return;
// not a part of our scope
if (!state.letReferences[node.name]) return;
state.closurify = true;
}
};
var letReferenceBlockVisitor = {
enter: function (node, parent, scope, state) {
if (t.isFunction(node)) {
scope.traverse(node, letReferenceFunctionVisitor, state);
return this.skip();
}
}
};
/**
* Description
*/
BlockScoping.prototype.getLetReferences = function () {
var block = this.block;
var declarators = block._letDeclarators || [];
var declar;
//
for (var i = 0; i < declarators.length; i++) {
declar = declarators[i];
extend(this.outsideLetReferences, t.getBindingIdentifiers(declar));
}
//
if (block.body) {
for (i = 0; i < block.body.length; i++) {
declar = block.body[i];
if (isLet(declar, block)) {
declarators = declarators.concat(declar.declarations);
}
}
}
//
for (i = 0; i < declarators.length; i++) {
declar = declarators[i];
var keys = t.getBindingIdentifiers(declar);
extend(this.letReferences, keys);
this.hasLetReferences = true;
}
// no let references so we can just quit
if (!this.hasLetReferences) return;
// set let references to plain var references
standardizeLets(declarators);
var state = {
letReferences: this.letReferences,
closurify: false
};
// traverse through this block, stopping on functions and checking if they
// contain any local let references
this.scope.traverse(this.block, letReferenceBlockVisitor, state);
return state.closurify;
};
var loopNodeTo = function (node) {
if (t.isBreakStatement(node)) {
return "break";
} else if (t.isContinueStatement(node)) {
return "continue";
}
};
var loopVisitor = {
enter: function (node, parent, scope, state) {
var replace;
if (t.isLoop(node)) {
state.ignoreLabeless = true;
scope.traverse(node, loopVisitor, state);
state.ignoreLabeless = false;
}
if (t.isFunction(node) || t.isLoop(node)) {
return this.skip();
}
var loopText = loopNodeTo(node);
if (loopText) {
if (node.label) {
// we shouldn't be transforming this because it exists somewhere inside
if (state.innerLabels.indexOf(node.label.name) >= 0) {
return;
}
loopText = loopText + "|" + node.label.name;
} else {
// we shouldn't be transforming these statements because
// they don't refer to the actual loop we're scopifying
if (state.ignoreLabeless) return;
// break statements mean something different in this context
if (t.isBreakStatement(node) && t.isSwitchCase(parent)) return;
}
state.hasBreakContinue = true;
state.map[loopText] = node;
replace = t.literal(loopText);
}
if (t.isReturnStatement(node)) {
state.hasReturn = true;
replace = t.objectExpression([
t.property("init", t.identifier("v"), node.argument || t.identifier("undefined"))
]);
}
if (replace) {
replace = t.returnStatement(replace);
return t.inherits(replace, node);
}
}
};
var loopLabelVisitor = {
enter: function (node, parent, scope, state) {
if (t.isLabeledStatement(node)) {
state.innerLabels.push(node.label.name);
}
}
};
/**
* If we're inside of a loop then traverse it and check if it has one of
* the following node types `ReturnStatement`, `BreakStatement`,
* `ContinueStatement` and replace it with a return value that we can track
* later on.
*
* @returns {Object}
*/
BlockScoping.prototype.checkLoop = function () {
var state = {
hasBreakContinue: false,
ignoreLabeless: false,
innerLabels: [],
hasReturn: false,
isLoop: !!this.loopParent,
map: {}
};
this.scope.traverse(this.block, loopLabelVisitor, state);
this.scope.traverse(this.block, loopVisitor, state);
return state;
};
var hoistVarDeclarationsVisitor = {
enter: function (node, parent, scope, self) {
if (t.isForStatement(node)) {
if (isVar(node.init, node)) {
node.init = t.sequenceExpression(self.pushDeclar(node.init));
}
} else if (t.isFor(node)) {
if (isVar(node.left, node)) {
node.left = node.left.declarations[0].id;
}
} else if (isVar(node, parent)) {
return self.pushDeclar(node).map(t.expressionStatement);
} else if (t.isFunction(node)) {
return this.skip();
}
}
};
/**
* Hoist all var declarations in this block to before it so they retain scope
* once we wrap everything in a closure.
*/
BlockScoping.prototype.hoistVarDeclarations = function () {
traverse(this.block, hoistVarDeclarationsVisitor, this.scope, this);
};
/**
* Turn a `VariableDeclaration` into an array of `AssignmentExpressions` with
* their declarations hoisted to before the closure wrapper.
*
* @param {Node} node VariableDeclaration
* @returns {Array}
*/
BlockScoping.prototype.pushDeclar = function (node) {
this.body.push(t.variableDeclaration(node.kind, node.declarations.map(function (declar) {
return t.variableDeclarator(declar.id);
})));
var replace = [];
for (var i = 0; i < node.declarations.length; i++) {
var declar = node.declarations[i];
if (!declar.init) continue;
var expr = t.assignmentExpression("=", declar.id, declar.init);
replace.push(t.inherits(expr, declar));
}
return replace;
};
/**
* Push the closure to the body.
*
* @param {Node} ret Identifier
* @param {Node} call CallExpression
*/
BlockScoping.prototype.build = function (ret, call) {
var has = this.has;
if (has.hasReturn || has.hasBreakContinue) {
this.buildHas(ret, call);
} else {
this.body.push(t.expressionStatement(call));
}
};
/**
* Description
*
* @param {Node} ret Identifier
* @param {Node} call CallExpression
*/
BlockScoping.prototype.buildHas = function (ret, call) {
var body = this.body;
body.push(t.variableDeclaration("var", [
t.variableDeclarator(ret, call)
]));
var loopParent = this.loopParent;
var retCheck;
var has = this.has;
var cases = [];
if (has.hasReturn) {
// typeof ret === "object"
retCheck = util.template("let-scoping-return", {
RETURN: ret
});
}
if (has.hasBreakContinue) {
if (!loopParent) {
throw new Error("Has no loop parent but we're trying to reassign breaks " +
"and continues, something is going wrong here.");
}
for (var key in has.map) {
cases.push(t.switchCase(t.literal(key), [has.map[key]]));
}
if (has.hasReturn) {
cases.push(t.switchCase(null, [retCheck]));
}
if (cases.length === 1) {
var single = cases[0];
body.push(t.ifStatement(
t.binaryExpression("===", ret, single.test),
single.consequent[0]
));
} else {
body.push(t.switchStatement(ret, cases));
}
} else {
if (has.hasReturn) body.push(retCheck);
}
};

View File

@@ -1,270 +0,0 @@
"use strict";
var ReplaceSupers = require("../../helpers/replace-supers");
var nameMethod = require("../../helpers/name-method");
var defineMap = require("../../helpers/define-map");
var util = require("../../../util");
var t = require("../../../types");
exports.check = t.isClass;
exports.ClassDeclaration = function (node, parent, scope, file) {
return new Class(node, file, scope, true).run();
};
exports.ClassExpression = function (node, parent, scope, file) {
if (!node.id) {
if (t.isProperty(parent) && parent.value === node && !parent.computed && t.isIdentifier(parent.key)) {
// var o = { foo: class {} };
node.id = parent.key;
}
if (t.isVariableDeclarator(parent) && t.isIdentifier(parent.id)) {
// var foo = class {};
node.id = parent.id;
}
}
return new Class(node, file, scope, false).run();
};
/**
* Description
*
* @param {Node} node
* @param {File} file
* @param {Scope} scope
* @param {Boolean} closure
*/
function Class(node, file, scope, isStatement) {
this.isStatement = isStatement;
this.scope = scope;
this.node = node;
this.file = file;
this.hasInstanceMutators = false;
this.hasStaticMutators = false;
this.instanceMutatorMap = {};
this.staticMutatorMap = {};
this.hasConstructor = false;
this.className = node.id || scope.generateUidIdentifier("class");
this.superName = node.superClass || t.identifier("Function");
this.hasSuper = !!node.superClass;
this.isLoose = file.isLoose("es6.classes");
}
/**
* Description
*
* @returns {Array}
*/
Class.prototype.run = function () {
var superName = this.superName;
var className = this.className;
var file = this.file;
//
var body = this.body = [];
var constructorBody = t.blockStatement([
t.expressionStatement(t.callExpression(file.addHelper("class-call-check"), [
t.thisExpression(),
className
]))
]);
var constructor;
if (this.node.id) {
constructor = t.functionDeclaration(className, [], constructorBody);
body.push(constructor);
} else {
constructor = t.functionExpression(null, [], constructorBody);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(className, constructor)
]));
}
this.constructor = constructor;
var closureParams = [];
var closureArgs = [];
//
if (this.hasSuper) {
closureArgs.push(superName);
if (!t.isIdentifier(superName)) {
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
superName = superRef;
}
closureParams.push(superName);
this.superName = superName;
body.push(t.expressionStatement(t.callExpression(file.addHelper("inherits"), [className, superName])));
}
this.buildBody();
t.inheritsComments(body[0], this.node);
var init;
if (body.length === 1) {
// only a constructor so no need for a closure container
init = t.toExpression(constructor);
} else {
body.push(t.returnStatement(className));
init = t.callExpression(
t.functionExpression(null, closureParams, t.blockStatement(body)),
closureArgs
);
}
if (this.isStatement) {
return t.variableDeclaration("let", [
t.variableDeclarator(className, init)
]);
} else {
return init;
}
};
/**
* Description
*/
Class.prototype.buildBody = function () {
var constructor = this.constructor;
var className = this.className;
var superName = this.superName;
var classBody = this.node.body.body;
var body = this.body;
for (var i = 0; i < classBody.length; i++) {
var node = classBody[i];
if (t.isMethodDefinition(node)) {
var replaceSupers = new ReplaceSupers({
methodNode: node,
className: this.className,
superName: this.superName,
isStatic: node.static,
isLoose: this.isLoose,
scope: this.scope,
file: this.file
}, true);
replaceSupers.replace();
if (node.key.name === "constructor") {
this.pushConstructor(node);
} else {
this.pushMethod(node);
}
} else if (t.isPrivateDeclaration(node)) {
this.closure = true;
body.unshift(node);
}
}
// we have no constructor, we have a super, and the super doesn't appear to be falsy
if (!this.hasConstructor && this.hasSuper && !t.isFalsyExpression(superName)) {
var helperName = "class-super-constructor-call";
if (this.isLoose) helperName += "-loose";
constructor.body.body.push(util.template(helperName, {
CLASS_NAME: className,
SUPER_NAME: this.superName
}, true));
}
var instanceProps;
var staticProps;
if (this.hasInstanceMutators) {
instanceProps = defineMap.build(this.instanceMutatorMap);
}
if (this.hasStaticMutators) {
staticProps = defineMap.build(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
staticProps = staticProps || t.literal(null);
var args = [className, staticProps];
if (instanceProps) args.push(instanceProps);
body.push(t.expressionStatement(
t.callExpression(this.file.addHelper("prototype-properties"), args)
));
}
};
/**
* Push a method to it's respective mutatorMap.
*
* @param {Node} node MethodDefinition
*/
Class.prototype.pushMethod = function (node) {
var methodName = node.key;
var kind = node.kind;
if (kind === "") {
nameMethod.property(node, this.file, this.scope);
if (this.isLoose) {
// use assignments instead of define properties for loose classes
var className = this.className;
if (!node.static) className = t.memberExpression(className, t.identifier("prototype"));
methodName = t.memberExpression(className, methodName, node.computed);
var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
t.inheritsComments(expr, node);
this.body.push(expr);
return;
}
kind = "value";
}
var mutatorMap = this.instanceMutatorMap;
if (node.static) {
this.hasStaticMutators = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceMutators = true;
}
defineMap.push(mutatorMap, methodName, kind, node.computed, node);
defineMap.push(mutatorMap, methodName, "enumerable", node.computed, false);
};
/**
* Replace the constructor body of our class.
*
* @param {Node} method MethodDefinition
*/
Class.prototype.pushConstructor = function (method) {
if (method.kind) {
throw this.file.errorWithNode(method, "illegal kind for constructor method");
}
var construct = this.constructor;
var fn = method.value;
this.hasConstructor = true;
t.inherits(construct, fn);
t.inheritsComments(construct, method);
construct._ignoreUserWhitespace = true;
construct.params = fn.params;
construct.body.body = construct.body.body.concat(fn.body.body);
};

View File

@@ -1,47 +0,0 @@
"use strict";
var t = require("../../../types");
exports.check = function (node) {
return t.isVariableDeclaration(node, { kind: "const" });
};
var visitor = {
enter: function (node, parent, scope, state) {
if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) {
var ids = t.getBindingIdentifiers(node);
for (var key in ids) {
var id = ids[key];
var constant = state.constants[key];
// no constant exists
if (!constant) continue;
// check if the assignment id matches the constant declaration id
// if it does then it was the id used to initially declare the
// constant so we can just ignore it
if (id === constant) continue;
// check if there's been a local binding that shadows this constant
if (!scope.bindingEquals(key, constant)) continue;
throw state.file.errorWithNode(id, key + " is read-only");
}
} else if (t.isScope(node)) {
this.skip();
}
}
};
exports.Scope = function (node, parent, scope, file) {
scope.traverse(node, visitor, {
constants: scope.getAllDeclarationsOfKind("const"),
file: file
});
};
exports.VariableDeclaration = function (node) {
if (node.kind === "const") node.kind = "let";
};

View File

@@ -1,400 +0,0 @@
"use strict";
var t = require("../../../types");
exports.check = t.isPattern;
function Destructuring(opts) {
this.blockHoist = opts.blockHoist;
this.operator = opts.operator;
this.nodes = opts.nodes;
this.scope = opts.scope;
this.file = opts.file;
this.kind = opts.kind;
}
Destructuring.prototype.buildVariableAssignment = function (id, init) {
var op = this.operator;
if (t.isMemberExpression(id)) op = "=";
var node;
if (op) {
node = t.expressionStatement(t.assignmentExpression(op, id, init));
} else {
node = t.variableDeclaration(this.kind, [
t.variableDeclarator(id, init)
]);
}
node._blockHoist = this.blockHoist;
return node;
};
Destructuring.prototype.buildVariableDeclaration = function (id, init) {
var declar = t.variableDeclaration("var", [
t.variableDeclarator(id, init)
]);
declar._blockHoist = this.blockHoist;
return declar;
};
Destructuring.prototype.push = function (elem, parentId) {
if (t.isObjectPattern(elem)) {
this.pushObjectPattern(elem, parentId);
} else if (t.isArrayPattern(elem)) {
this.pushArrayPattern(elem, parentId);
} else if (t.isAssignmentPattern(elem)) {
this.pushAssignmentPattern(elem, parentId);
} else {
this.nodes.push(this.buildVariableAssignment(elem, parentId));
}
};
Destructuring.prototype.pushAssignmentPattern = function (pattern, parentId) {
var tempParentId = this.scope.generateUidBasedOnNode(parentId);
var declar = t.variableDeclaration("var", [
t.variableDeclarator(tempParentId, parentId)
]);
declar._blockHoist = this.blockHoist;
this.nodes.push(declar);
this.nodes.push(this.buildVariableAssignment(
pattern.left,
t.conditionalExpression(
t.binaryExpression("===", tempParentId, t.identifier("undefined")),
pattern.right,
tempParentId
)
));
};
Destructuring.prototype.pushObjectSpread = function (pattern, parentId, prop, i) {
// get all the keys that appear in this object before the current spread
var keys = [];
for (var i2 = 0; i2 < pattern.properties.length; i2++) {
var prop2 = pattern.properties[i2];
if (i2 >= i) break;
if (t.isSpreadProperty(prop2)) continue;
var key = prop2.key;
if (t.isIdentifier(key)) {
key = t.literal(prop2.key.name);
}
keys.push(key);
}
keys = t.arrayExpression(keys);
var value = t.callExpression(this.file.addHelper("object-without-properties"), [parentId, keys]);
this.nodes.push(this.buildVariableAssignment(prop.argument, value));
};
Destructuring.prototype.pushObjectProperty = function (prop, parentId) {
if (t.isLiteral(prop.key)) prop.computed = true;
var pattern2 = prop.value;
var patternId2 = t.memberExpression(parentId, prop.key, prop.computed);
if (t.isPattern(pattern2)) {
this.push(pattern2, patternId2);
} else {
this.nodes.push(this.buildVariableAssignment(pattern2, patternId2));
}
};
Destructuring.prototype.pushObjectPattern = function (pattern, parentId) {
if (!pattern.properties.length) {
this.nodes.push(t.expressionStatement(
t.callExpression(this.file.addHelper("object-destructuring-empty"), [parentId])
));
}
if (pattern.properties.length > 1 && t.isMemberExpression(parentId)) {
var temp = this.scope.generateUidBasedOnNode(parentId, this.file);
this.nodes.push(this.buildVariableDeclaration(temp, parentId));
parentId = temp;
}
for (var i = 0; i < pattern.properties.length; i++) {
var prop = pattern.properties[i];
if (t.isSpreadProperty(prop)) {
this.pushObjectSpread(pattern, parentId, prop, i);
} else {
this.pushObjectProperty(prop, parentId);
}
}
};
var hasRest = function (pattern) {
for (var i = 0; i < pattern.elements.length; i++) {
if (t.isRestElement(pattern.elements[i])) {
return true;
}
}
return false;
};
Destructuring.prototype.pushArrayPattern = function (pattern, parentId) {
if (!pattern.elements) return;
// if we have a rest then we need all the elements
var count = !hasRest(pattern) && pattern.elements.length;
var toArray = this.file.toArray(parentId, count);
var _parentId = this.scope.generateUidBasedOnNode(parentId, this.file);
this.nodes.push(this.buildVariableDeclaration(_parentId, toArray));
parentId = _parentId;
for (var i = 0; i < pattern.elements.length; i++) {
var elem = pattern.elements[i];
// hole
if (!elem) continue;
var newPatternId;
if (t.isRestElement(elem)) {
newPatternId = this.file.toArray(parentId);
if (i > 0) {
newPatternId = t.callExpression(t.memberExpression(newPatternId, t.identifier("slice")), [t.literal(i)]);
}
elem = elem.argument;
} else {
newPatternId = t.memberExpression(parentId, t.literal(i), true);
}
this.push(elem, newPatternId);
}
};
Destructuring.prototype.init = function (pattern, parentId) {
if (!t.isArrayExpression(parentId) && !t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
var key = this.scope.generateUidBasedOnNode(parentId);
this.nodes.push(this.buildVariableDeclaration(key, parentId));
parentId = key;
}
this.push(pattern, parentId);
};
exports.ForInStatement =
exports.ForOfStatement = function (node, parent, scope, file) {
var left = node.left;
if (t.isPattern(left)) {
// for ({ length: k } in { abc: 3 });
var temp = scope.generateUidIdentifier("ref");
node.left = t.variableDeclaration("var", [
t.variableDeclarator(temp)
]);
t.ensureBlock(node);
node.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(left, temp)
]));
return;
}
if (!t.isVariableDeclaration(left)) return;
var pattern = left.declarations[0].id;
if (!t.isPattern(pattern)) return;
var key = scope.generateUidIdentifier("ref");
node.left = t.variableDeclaration(left.kind, [
t.variableDeclarator(key, null)
]);
var nodes = [];
var destructuring = new Destructuring({
kind: left.kind,
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(pattern, key);
t.ensureBlock(node);
var block = node.body;
block.body = nodes.concat(block.body);
};
exports.Function = function (node, parent, scope, file) {
var nodes = [];
var hasDestructuring = false;
node.params = node.params.map(function (pattern, i) {
if (!t.isPattern(pattern)) return pattern;
hasDestructuring = true;
var parentId = scope.generateUidIdentifier("ref");
var destructuring = new Destructuring({
blockHoist: node.params.length - i,
nodes: nodes,
scope: scope,
file: file,
kind: "var",
});
destructuring.init(pattern, parentId);
return parentId;
});
if (!hasDestructuring) return;
t.ensureBlock(node);
var block = node.body;
block.body = nodes.concat(block.body);
};
exports.CatchClause = function (node, parent, scope, file) {
var pattern = node.param;
if (!t.isPattern(pattern)) return;
var ref = scope.generateUidIdentifier("ref");
node.param = ref;
var nodes = [];
var destructuring = new Destructuring({
kind: "let",
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(pattern, ref);
node.body.body = nodes.concat(node.body.body);
return node;
};
exports.ExpressionStatement = function (node, parent, scope, file) {
var expr = node.expression;
if (expr.type !== "AssignmentExpression") return;
if (!t.isPattern(expr.left)) return;
if (file.isConsequenceExpressionStatement(node)) return;
var nodes = [];
var ref = scope.generateUidIdentifier("ref");
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(ref, expr.right)
]));
var destructuring = new Destructuring({
operator: expr.operator,
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(expr.left, ref);
return nodes;
};
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!t.isPattern(node.left)) return;
var ref = scope.generateUidIdentifier("temp");
scope.push({
key: ref.name,
id: ref
});
var nodes = [];
nodes.push(t.assignmentExpression("=", ref, node.right));
var destructuring = new Destructuring({
operator: node.operator,
file: file,
scope: scope,
nodes: nodes
});
destructuring.init(node.left, ref);
nodes.push(ref);
return t.toSequenceExpression(nodes, scope);
};
var variableDeclarationhasPattern = function (node) {
for (var i = 0; i < node.declarations.length; i++) {
if (t.isPattern(node.declarations[i].id)) {
return true;
}
}
return false;
};
exports.VariableDeclaration = function (node, parent, scope, file) {
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;
if (!variableDeclarationhasPattern(node)) return;
var nodes = [];
var declar;
for (var i = 0; i < node.declarations.length; i++) {
declar = node.declarations[i];
var patternId = declar.init;
var pattern = declar.id;
var destructuring = new Destructuring({
nodes: nodes,
scope: scope,
kind: node.kind,
file: file
});
if (t.isPattern(pattern) && patternId) {
destructuring.init(pattern, patternId);
if (+i !== node.declarations.length - 1) {
// we aren't the last declarator so let's just make the
// last transformed node inherit from us
t.inherits(nodes[nodes.length - 1], declar);
}
} else {
nodes.push(t.inherits(destructuring.buildVariableAssignment(declar.id, declar.init), declar));
}
}
if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
// https://github.com/6to5/6to5/issues/113
// for (let [x] = [0]; false;) {}
declar = null;
for (i = 0; i < nodes.length; i++) {
node = nodes[i];
declar = declar || t.variableDeclaration(node.kind, []);
if (!t.isVariableDeclaration(node) && declar.kind !== node.kind) {
throw file.errorWithNode(node, "Cannot use this node within the current parent");
}
declar.declarations = declar.declarations.concat(node.declarations);
}
return declar;
}
return nodes;
};

View File

@@ -1,105 +0,0 @@
"use strict";
var util = require("../../../util");
var t = require("../../../types");
exports.check = t.isForOfStatement;
exports.ForOfStatement = function (node, parent, scope, file) {
var callback = spec;
if (file.isLoose("es6.forOf")) callback = loose;
var build = callback(node, parent, scope, file);
var declar = build.declar;
var loop = build.loop;
var block = loop.body;
// inherit comments from the original loop
t.inheritsComments(loop, node);
// ensure that it's a block so we can take all it's statemetns
t.ensureBlock(node);
// add the value declaration to the new loop body
if (declar) {
block.body.push(declar);
}
// push the rest of the original loop body onto our new body
block.body = block.body.concat(node.body.body);
t.inherits(loop, node);
// todo: find out why this is necessary? #538
loop._scopeInfo = node._scopeInfo;
return loop;
};
var loose = function (node, parent, scope, file) {
var left = node.left;
var declar, id;
if (t.isIdentifier(left) || t.isPattern(left)) {
// for (i of test), for ({ i } of test)
id = left;
} else if (t.isVariableDeclaration(left)) {
// for (var i of test)
id = scope.generateUidIdentifier("ref");
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(left.declarations[0].id, id)
]);
} else {
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
}
var loop = util.template("for-of-loose", {
LOOP_OBJECT: scope.generateUidIdentifier("iterator"),
IS_ARRAY: scope.generateUidIdentifier("isArray"),
OBJECT: node.right,
INDEX: scope.generateUidIdentifier("i"),
ID: id
});
if (!declar) {
// no declaration so we need to remove the variable declaration at the top of
// the for-of-loose template
loop.body.body.shift();
}
return {
declar: declar,
loop: loop
};
};
var spec = function (node, parent, scope, file) {
var left = node.left;
var declar;
var stepKey = scope.generateUidIdentifier("step");
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left) || t.isPattern(left)) {
// for (i of test), for ({ i } of test)
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {
// for (var i of test)
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(left.declarations[0].id, stepValue)
]);
} else {
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
}
var loop = util.template("for-of", {
ITERATOR_KEY: scope.generateUidIdentifier("iterator"),
STEP_KEY: stepKey,
OBJECT: node.right
});
return {
declar: declar,
loop: loop
};
};

View File

@@ -1,52 +0,0 @@
"use strict";
var t = require("../../../types");
exports.check = require("../internal/modules").check;
exports.ImportDeclaration = function (node, parent, scope, file) {
var nodes = [];
if (node.specifiers.length) {
for (var i = 0; i < node.specifiers.length; i++) {
file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
}
} else {
file.moduleFormatter.importDeclaration(node, nodes, parent);
}
if (nodes.length === 1) {
// inherit `_blockHoist` - this is for `_blockHoist` in File.prototype.addImport
nodes[0]._blockHoist = node._blockHoist;
}
return nodes;
};
exports.ExportDeclaration = function (node, parent, scope, file) {
var nodes = [];
var i;
if (node.declaration) {
// make sure variable exports have an initializer
// this is done here to avoid duplicating it in the module formatters
if (t.isVariableDeclaration(node.declaration)) {
var declar = node.declaration.declarations[0];
declar.init = declar.init || t.identifier("undefined");
}
file.moduleFormatter.exportDeclaration(node, nodes, parent);
} else if (node.specifiers) {
for (i = 0; i < node.specifiers.length; i++) {
file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
}
}
if (node._blockHoist) {
for (i = 0; i < nodes.length; i++) {
nodes[i]._blockHoist = node._blockHoist;
}
}
return nodes;
};

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