Compare commits

..

731 Commits

Author SHA1 Message Date
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
Sebastian McKenzie
fdda013d07 v3.5.3 2015-02-08 22:17:05 +11:00
Sebastian McKenzie
64477d934d add 3.5.3 changelog 2015-02-08 22:10:00 +11:00
Sebastian McKenzie
45c507056a add back old tail call implementation 2015-02-08 22:09:41 +11:00
Sebastian McKenzie
730b96c195 3.5.2 2015-02-08 21:23:55 +11:00
Sebastian McKenzie
a185f91433 v3.5.2 2015-02-08 21:23:24 +11:00
Sebastian McKenzie
d053622802 add 3.5.2 changelog 2015-02-08 21:21:38 +11:00
Sebastian McKenzie
74d6b61973 disable es6 tail call tests 2015-02-08 21:21:32 +11:00
Sebastian McKenzie
97784c8cca comment out tailCall transformer 2015-02-08 21:19:01 +11:00
Sebastian McKenzie
812d93553a temporairly disable tailCall transformer 2015-02-08 21:17:21 +11:00
Sebastian McKenzie
d251b4cb56 3.5.1 2015-02-08 21:16:34 +11:00
Sebastian McKenzie
caf38e1962 v3.5.1 2015-02-08 21:04:05 +11:00
Sebastian McKenzie
4ccbee4639 fix linting errors 2015-02-08 20:59:48 +11:00
Sebastian McKenzie
84196a3a07 add 3.5.1 changelog 2015-02-08 20:57:58 +11:00
Ingvar Stepanyan
29361c055a Fix #718. 2015-02-08 11:56:39 +02:00
Sebastian McKenzie
4277265591 Merge branch 'master' of github.com:6to5/6to5 2015-02-08 20:40:47 +11:00
Sebastian McKenzie
812a2b315d bump acorn-6to5 2015-02-08 20:40:30 +11:00
Ingvar Stepanyan
0a1724fc3f Remove no more needed returnBlock helper. 2015-02-08 11:31:19 +02:00
Sebastian McKenzie
bcc9e016b1 only evaluate object destructuring pattern once 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
4ea0175ca7 simplify set template 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
799445c745 add property method assignment wrapper generator template 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
481ea12999 add cleanup internal transformer 2015-02-08 20:23:22 +11:00
Sebastian McKenzie
de6b608dda add _declarations and _scopeInfo to t.inherits 2015-02-08 20:23:21 +11:00
Sebastian McKenzie
606f813822 enable traceur test suite by default 2015-02-08 20:23:21 +11:00
Sebastian McKenzie
e06c8cd106 support generators in nameMethod helper 2015-02-08 20:23:21 +11:00
Ingvar Stepanyan
9e3c67a8a2 Clean up functionChildrenVisitor a bit. 2015-02-08 10:53:09 +02:00
Ingvar Stepanyan
91362f80b1 Clean up transformations after #714.
Since now we have runtime helper, we don't need
expression -> statement conversions anymore.
2015-02-08 10:40:03 +02:00
Sebastian McKenzie
cde988f99f update 3.5.0 changelog 2015-02-08 16:53:33 +11:00
Sebastian McKenzie
9ec0854659 3.5.0 2015-02-08 16:37:13 +11:00
Sebastian McKenzie
bb17571e56 v3.5.0 2015-02-08 16:35:45 +11:00
Sebastian McKenzie
9161af58c0 fix linting errors 2015-02-08 16:32:08 +11:00
Sebastian McKenzie
e39f4e8025 update 3.5.0 changelog 2015-02-08 16:31:24 +11:00
Sebastian McKenzie
f5e9909e71 Merge pull request #716 from daliwali/master
Make `__esModule` property not enumerable
2015-02-08 16:30:26 +11:00
Sebastian McKenzie
46913fc55f add 3.5.0 changelog 2015-02-08 16:22:12 +11:00
Dali Zheng
d358a86e98 make __esModule property not enumerable 2015-02-07 21:19:11 -08:00
Sebastian McKenzie
055545980c update traceur test runner 2015-02-08 16:19:05 +11:00
Sebastian McKenzie
6fd7f9868e upgrade acorn-6to5 2015-02-08 16:18:54 +11:00
Sebastian McKenzie
e8184a9bc5 fix browser api location in browser test 2015-02-08 14:34:43 +11:00
Sebastian McKenzie
f74de3ef55 move destructuring and parameters.rest transformer to above blockScoping 2015-02-08 14:34:34 +11:00
Sebastian McKenzie
9624f8287d add checkNode to block scoped functions transformer 2015-02-08 14:34:10 +11:00
Sebastian McKenzie
e42d5a889e make destructuring in catch clauses block scoped and add support for non-variable destructuring in for-in/of heads 2015-02-08 14:33:55 +11:00
Sebastian McKenzie
4c8e6481b6 make default parameters iife invocation less serious 2015-02-08 09:54:24 +11:00
Sebastian McKenzie
0867df2691 fix ForOf block body not properly inheriting declarations 2015-02-08 09:50:12 +11:00
Sebastian McKenzie
b06f99ab30 add iife detection to non-identifier params in default parameters 2015-02-08 09:37:06 +11:00
Sebastian McKenzie
9afa3f6b58 add opts param to t.isReferencedIdentifier 2015-02-08 09:31:41 +11:00
Sebastian McKenzie
785cb4b72f allow optional transformer to be set via the whitelist 2015-02-08 09:31:30 +11:00
Sebastian McKenzie
dabe69856a add additional checks to transformers 2015-02-08 09:31:19 +11:00
Sebastian McKenzie
24e70802b5 fix block scoped tracking in functions - fixes #710 2015-02-08 09:31:04 +11:00
Sebastian McKenzie
c1ba55a52d Merge pull request #714 from RReverser/master
Added complete TCO (tail call optimization).
2015-02-08 08:55:19 +11:00
Ingvar Stepanyan
4c318166e1 Added complete TCO (tail call optimization).
Works across functions and generates simpler and faster code than #701.
Works even across files when used in conjunction with `runtime` option.

Closes #256.
2015-02-07 22:22:38 +02:00
Sebastian McKenzie
c0af67eca1 add support for super in object literals - fixes #411 2015-02-08 02:01:17 +11:00
Sebastian McKenzie
eb14f1da00 implement optional TDZ - fixes #563 2015-02-08 01:27:22 +11:00
Sebastian McKenzie
3361b81658 expose parentPath 2015-02-08 01:27:00 +11:00
Sebastian McKenzie
a15f218e9b dump code to esvalid errors 2015-02-08 01:26:46 +11:00
Sebastian McKenzie
067cf43f52 fix File::addHelper unknown helper error message 2015-02-08 00:01:26 +11:00
Sebastian McKenzie
689ce048e6 remove tail call exec test 2015-02-07 23:52:41 +11:00
Sebastian McKenzie
8a143bf957 use a template in tail call transformer - @RReverser 2015-02-07 23:52:35 +11:00
Sebastian McKenzie
9f7bcf585d remove dead TraversalContext code 2015-02-07 23:51:05 +11:00
Sebastian McKenzie
f9efd8a272 fix error message in File::addHelper 2015-02-07 23:50:56 +11:00
Sebastian McKenzie
8cd2326ff9 Merge branch 'master' of github.com:6to5/6to5 2015-02-07 23:37:51 +11:00
Sebastian McKenzie
eb1ae70bfa Merge pull request #701 from RReverser/master
Add tail recursion optimization.
2015-02-07 23:37:43 +11:00
Ingvar Stepanyan
24ef81908c Increase test timeout for Travis. 2015-02-07 14:34:23 +02:00
Ingvar Stepanyan
b53b41cef3 Provide placeholders for proper function length. 2015-02-07 14:26:03 +02:00
Sebastian McKenzie
ad245ed46a 3.4.1 2015-02-07 19:48:59 +11:00
Sebastian McKenzie
3f6199493e v3.4.1 2015-02-07 19:48:28 +11:00
Sebastian McKenzie
e06aac4783 Revert "make export { foo as default }; trigger common interop"
This reverts commit 07c7b5b419.
2015-02-07 19:40:49 +11:00
Sebastian McKenzie
6a5adfe338 update 3.4.1 changelog 2015-02-07 19:40:29 +11:00
Sebastian McKenzie
07c7b5b419 make export { foo as default }; trigger common interop 2015-02-07 19:29:59 +11:00
Sebastian McKenzie
7f985fe08a fix incorrect strict module formatter variable - fixes #706 2015-02-07 19:29:32 +11:00
Sebastian McKenzie
38f02a6429 add 3.4.1 changelog 2015-02-07 19:19:55 +11:00
Sebastian McKenzie
f943bdcac0 Merge branch 'master' of github.com:6to5/6to5 2015-02-07 19:18:29 +11:00
Sebastian McKenzie
8dc634edfc add options to require cache key - fixes #707 2015-02-07 19:18:12 +11:00
Sebastian McKenzie
05b9cf17f0 Merge pull request #708 from tricknotes/avoid-conflict
Switch short option of `--module-ids` from `-i` to `-M`
2015-02-07 19:12:22 +11:00
Ryunosuke SATO
69bbe89616 Switch short option of --module-ids from -i to -M
`-i` conflicts with `--optional` option.

```
$ bin/6to5/index.js --help | grep "\-i,"
    -i, --optional [list]        List of optional transformers to enable
    -i, --module-ids             Insert module id in modules
```
2015-02-07 16:37:38 +09:00
Sebastian McKenzie
6b49958f7c Merge branch 'master' of github.com:6to5/6to5 2015-02-07 15:59:15 +11:00
Sebastian McKenzie
e75ce94578 move reactCompat option onto an optional transformer 2015-02-07 15:59:00 +11:00
Sebastian McKenzie
f666473724 Merge pull request #705 from cesarandreu/patch-2
Add 6to5-runtime README
2015-02-07 13:54:58 +11:00
Cesar Andreu
ae817e3c9c Add 6to5-runtime README 2015-02-06 18:53:42 -08:00
Sebastian McKenzie
2e9352de14 3.4.0 2015-02-07 10:44:06 +11:00
Sebastian McKenzie
1e9e55ddef fix browser build location in makefile 2015-02-07 10:42:28 +11:00
Sebastian McKenzie
0799ed7116 v3.4.0 2015-02-07 10:41:38 +11:00
Sebastian McKenzie
5537250d4f fix linting errors 2015-02-07 10:40:01 +11:00
Sebastian McKenzie
7ada50937b add 3.4.0 changelog 2015-02-07 10:39:24 +11:00
Sebastian McKenzie
f2ae88af93 add commonStandard module formatter - fixes #675
will be merged into strict formatters in next major
TODO: rewrite all module formatters as they've gotten out of han
2015-02-07 10:31:52 +11:00
Sebastian McKenzie
726451f86f reverts d6b39bc89b 2015-02-07 09:54:18 +11:00
Sebastian McKenzie
306cfc6328 fix 3.3.12 changelog misspelling 2015-02-07 09:53:18 +11:00
Sebastian McKenzie
a051a47048 reorder types requires 2015-02-07 08:11:42 +11:00
Ingvar Stepanyan
5b2216b348 Add tail recursion optimization.
As per ES6, VMs should perform tail call optimization and prevent growth of call stack.
This adds tail call optimization for recursion case (when function has explicit name and calls itself in `return`).
Cross-function optimization is not currently performed as it's more complicated and requires value tracking.
2015-02-06 16:34:35 +02:00
Sebastian McKenzie
ad60d49611 fix bindingEquals in constants transformer 2015-02-06 23:35:19 +11:00
Sebastian McKenzie
a6d1a5a724 add bindingEquals, typeEquals, referenceEquals helper methods to Scope 2015-02-06 23:07:10 +11:00
Sebastian McKenzie
399d835285 fix linting errors 2015-02-06 23:06:54 +11:00
Sebastian McKenzie
b66367ddde change namespace of minification.propertyLiterals and minifciation.memberExpressionLiterals to es3 2015-02-06 22:42:16 +11:00
Sebastian McKenzie
37d29b7a6f clean up function scope collection - @RReverser 2015-02-06 22:04:13 +11:00
Sebastian McKenzie
1e708fb373 fix traverse test 2015-02-06 01:59:45 +11:00
Sebastian McKenzie
76ae1682a3 remove context arg in favor of this, rename TraversalIteration to TraversalPath, and remove ast handlers 2015-02-06 01:47:43 +11:00
Sebastian McKenzie
2ef0aa95c5 clean up indentation 2015-02-06 01:17:42 +11:00
Sebastian McKenzie
9cbb49c6b2 don't return the sourcemap when inline is requested - 6to5/grunt-6to5#18 2015-02-05 22:25:33 +11:00
Sebastian McKenzie
f04a734838 fix module ids shorthand arg - fixes #696 2015-02-05 22:19:39 +11:00
Sebastian McKenzie
beb5ccab25 split up traversal so it's easier to maintain and extend later on 2015-02-05 19:42:08 +11:00
Sebastian McKenzie
b8f8f24e82 add newline to es6 destructuring member expression test 2015-02-05 19:41:53 +11:00
Sebastian McKenzie
c35a007401 simplify replace supers helper 2015-02-05 19:41:37 +11:00
Sebastian McKenzie
e639c82f2f fix internal refactoring... 2015-02-05 14:08:02 +11:00
Sebastian McKenzie
f365cc1248 more internal rearchitecturing 2015-02-05 14:05:15 +11:00
Sebastian McKenzie
2b75c67448 better scope traversal inferType todo comments 2015-02-05 11:16:13 +11:00
Sebastian McKenzie
e5e9ae7e0f v3.3.12 2015-02-05 10:32:14 +11:00
Sebastian McKenzie
009422e997 add 3.3.12 changelog 2015-02-05 10:15:15 +11:00
Sebastian McKenzie
386e221a0f don't override core supported member expressions if there's a local binding 2015-02-05 09:53:12 +11:00
Sebastian McKenzie
58db94401e 3.3.11 2015-02-05 08:53:29 +11:00
Sebastian McKenzie
f9be9bab89 v3.3.11 2015-02-05 08:37:28 +11:00
Sebastian McKenzie
dc7e963c9f style fixes 2015-02-05 08:27:59 +11:00
Sebastian McKenzie
a786f39b1b 3.3.10 2015-02-04 23:26:12 +11:00
Sebastian McKenzie
95cf793df4 v3.3.10 2015-02-04 23:25:42 +11:00
Sebastian McKenzie
ea2ad96089 update 3.3.10 changelog 2015-02-04 23:24:13 +11:00
Sebastian McKenzie
4b2cf2e2c5 fix styling errors 2015-02-04 23:24:08 +11:00
Sebastian McKenzie
23b8c72e9a remove unused traverse requires 2015-02-04 23:22:26 +11:00
Sebastian McKenzie
80876a2c0a add 3.3.10 changelog 2015-02-04 23:20:53 +11:00
Sebastian McKenzie
c923010292 fix source map tests 2015-02-04 23:20:47 +11:00
Sebastian McKenzie
c84af909f7 track end of node positions for sourcemaps - fixes douglasduteil/isparta#8 2015-02-04 23:10:54 +11:00
Sebastian McKenzie
d6b39bc89b HomeObject isn't dynamic - fixes #690 2015-02-04 18:47:58 +11:00
Sebastian McKenzie
39fe737cb6 rename es7.objectSpread transformer to es7.objectRestSpread 2015-02-04 18:35:43 +11:00
Sebastian McKenzie
37ef976515 more cleanup of the destructuring transformer 2015-02-04 18:21:10 +11:00
Sebastian McKenzie
fa5a3022d4 clean up destructuring transformer 2015-02-04 17:48:27 +11:00
Sebastian McKenzie
58bed088f5 throw an error when destructuring a null or undefined value on an empty object pattern - fixes #681 2015-02-04 17:35:24 +11:00
Sebastian McKenzie
4f023e83f8 refactor traversals that have scopes to use the scope helper method 2015-02-04 13:25:23 +11:00
Sebastian McKenzie
7d950cd60a i made the javascripts faster with a transformer prepass to check what transformers actually have to be ran 2015-02-04 12:56:34 +11:00
Sebastian McKenzie
ffc9244f88 make #683 more inline with the official jsx compiler 2015-02-04 10:38:35 +11:00
Sebastian McKenzie
6ede3986c7 Merge branch 'master' of github.com:6to5/6to5 2015-02-04 10:23:29 +11:00
Sebastian McKenzie
5a81d22167 Merge pull request #683 from caseywebdev/concat-string-literals
Concatenate adjacent string literals in JSX
2015-02-04 10:22:51 +11:00
Sebastian McKenzie
2bf2e26a64 3.3.9 2015-02-04 10:15:19 +11:00
Sebastian McKenzie
ee466e90ca v3.3.9 2015-02-04 10:13:10 +11:00
Sebastian McKenzie
911e3939b9 remove class-super-constructor-call-check helper 2015-02-04 10:08:55 +11:00
Sebastian McKenzie
ca6f8e9a96 v3.3.8 2015-02-04 10:07:50 +11:00
Sebastian McKenzie
55f2cffc22 fix linting errors 2015-02-04 10:05:20 +11:00
Sebastian McKenzie
ca482b79ad add 3.3.8 changelog 2015-02-04 10:04:03 +11:00
Sebastian McKenzie
b1f0ecf244 update class super constructor inheritance tests 2015-02-04 10:03:57 +11:00
Sebastian McKenzie
36fa174901 change instance reference to this in class super constructor call template - fixes #689 2015-02-04 10:03:15 +11:00
Sebastian McKenzie
e8dc4628ae better handle spaces in IfStatement generator 2015-02-04 08:40:23 +11:00
Sebastian McKenzie
7a0dbb0203 fix node removal 2015-02-04 08:39:54 +11:00
Sebastian McKenzie
8d81a382f7 inline back the super constructor call helper - fixes #684 2015-02-04 08:39:45 +11:00
Sebastian McKenzie
86fbba08d8 add concise format option 2015-02-04 08:39:17 +11:00
Sebastian McKenzie
23c6e7e168 fix incorrect getThisReference bind - fixes #688 2015-02-04 08:26:18 +11:00
Sebastian McKenzie
c35f041091 simplify to.isFalsyExpression method 2015-02-04 08:25:40 +11:00
Sebastian McKenzie
618c6a8e67 add isLiteral to inferType 2015-02-04 08:25:15 +11:00
Sebastian McKenzie
23429f7b7f remove blank optimization 2015-02-04 08:25:00 +11:00
Sebastian McKenzie
d6052b483a add 6to5-minify to package.json 2015-02-04 08:24:53 +11:00
Sebastian McKenzie
3b3255a964 delegate removal of nodes in traversal to exitNode 2015-02-04 08:24:38 +11:00
Sebastian McKenzie
49847e70af add some minification transformers 2015-02-04 08:23:58 +11:00
Sebastian McKenzie
c228d76e44 add 6to5-minify 2015-02-04 08:23:49 +11:00
Casey Foster
2562b0c201 Concatenate adjacent string literals in JSX 2015-02-03 10:46:54 -06:00
Sebastian McKenzie
6da6bc3eb8 remove callExpression type inferrence 2015-02-03 22:32:00 +11:00
Sebastian McKenzie
bbcfc3c9f2 3.3.7 2015-02-03 22:29:09 +11:00
Sebastian McKenzie
12b1de7c9d v3.3.7 2015-02-03 22:27:37 +11:00
Sebastian McKenzie
721636f475 add 3.3.7 changelog 2015-02-03 22:25:33 +11:00
Sebastian McKenzie
4c94941ceb force .js extension when writing files to directories with 6to5 2015-02-03 22:25:27 +11:00
Sebastian McKenzie
f06535e915 rename Scope.init to Scope.crawl 2015-02-03 22:22:36 +11:00
Sebastian McKenzie
389914c427 add use-strict to valid node flags - fixes #667 2015-02-03 22:21:55 +11:00
Sebastian McKenzie
c7f5715d8e fix boolean stripping from 6to5-node - fixes #679 2015-02-03 22:21:09 +11:00
Sebastian McKenzie
29f866525e clean up scope tracking and add some simple flow type tracking and inferrence #653 2015-02-03 21:06:21 +11:00
Sebastian McKenzie
de61455a55 3.3.5 2015-02-03 21:05:36 +11:00
Sebastian McKenzie
fd579a8772 v3.3.5 2015-02-03 20:13:43 +11:00
Sebastian McKenzie
8e708906a8 fix linting errors 2015-02-03 20:11:38 +11:00
Sebastian McKenzie
b7680059c8 add 3.3.5 changelog 2015-02-03 20:09:45 +11:00
Sebastian McKenzie
239369314c more scope refactoring - fixes #676 2015-02-03 20:06:27 +11:00
Sebastian McKenzie
f2d1fc47d1 Merge branch 'master' of github.com:6to5/6to5 2015-02-03 19:55:29 +11:00
Sebastian McKenzie
aab35736c5 Merge pull request #677 from jayphelps/merica
First pass at converting identifiers/words from en-au -> en-us
2015-02-03 19:37:33 +11:00
Sebastian McKenzie
a9405e5e80 clean up scope API 2015-02-03 19:33:32 +11:00
Jay Phelps
9880990fa7 First pass at converting identifiers/words from en-au -> en-us 2015-02-03 00:08:43 -08:00
Sebastian McKenzie
6674611b26 Merge pull request #674 from johlrich/patch-1
Change getModuleName regex to only remove extenion
2015-02-03 17:54:04 +11:00
Jonathan
e92ec6aba7 Change getModuleName regex to only remove extenion
Given a names like: "some.module.js" and "some.other.module.js" the current regex in DefaultFormatter.prototype.getModuleName will overmatch and only return "some" as the module name in both cases.

Changing the . character class to \w will make sure it does not pick up additional sections and returns "some.module" and "some.other.module" for the names
2015-02-03 01:52:24 -05:00
Sebastian McKenzie
1801b725bd remove stupid jscs rules (they don't take into account reserved words ugh) and let jshint handle them 2015-02-03 15:35:44 +11:00
Sebastian McKenzie
72de8f5c9b fix class tests to reflect new call behaviour 2015-02-03 15:35:24 +11:00
Sebastian McKenzie
895d965568 fix linting errors 2015-02-03 15:17:33 +11:00
Sebastian McKenzie
3a11c7d46b as per "ES6 February 2, 2015 Draft Rev 32" "Constructors defined using class definition syntax throw when called as functions" 2015-02-03 15:16:16 +11:00
Sebastian McKenzie
92d9b3ff5f make it illegal to export a __esModule property - #673 2015-02-03 14:41:11 +11:00
Sebastian McKenzie
630f1717f0 clean up scope collision tracking and constants transformer - fixes #331 2015-02-03 13:20:52 +11:00
Sebastian McKenzie
e6e93840a6 check for scope collisions in constants transformer - fixes #331 2015-02-03 12:03:38 +11:00
Sebastian McKenzie
b2ad79cf88 rename t.getDeclarations to the WAY more reflective t.getBindingIdentifiers 2015-02-03 12:03:21 +11:00
Sebastian McKenzie
706797eb47 rename LetScoping to BlockScoping 2015-02-03 10:23:56 +11:00
Sebastian McKenzie
4163d1372a fix istanbul interop - closes #660 2015-02-03 10:23:47 +11:00
Sebastian McKenzie
4413da8d6e fix up whitespace on non empty last line JSX literals - fixes #668 2015-02-03 09:31:30 +11:00
Sebastian McKenzie
8e23d623c8 split up util.pushMutatorMap and util.buildDefineProperties 2015-02-03 09:30:52 +11:00
Sebastian McKenzie
e712c5225b use the current file basename for the displayName of export default React.createClass - 6to5/6to5-sublime#21 2015-02-02 23:48:03 +11:00
Sebastian McKenzie
8bdb723004 3.3.4 2015-02-02 21:37:11 +11:00
Sebastian McKenzie
9f912f548e v3.3.4 2015-02-02 21:36:04 +11:00
Sebastian McKenzie
41d721e372 fix source map tests 2015-02-02 21:32:45 +11:00
Sebastian McKenzie
df6ffe025c remove camelcase rule from jscs and let jshint handle it 2015-02-02 21:19:23 +11:00
Sebastian McKenzie
28b6b4af44 fix linting errors 2015-02-02 21:17:54 +11:00
Sebastian McKenzie
9e80071caa add 3.3.4 changelog 2015-02-02 21:16:53 +11:00
Sebastian McKenzie
0da4303358 remove automatic --harmony flag from 6to5-node 2015-02-02 21:14:23 +11:00
Sebastian McKenzie
83e225f30a simplify source maps, fixes weird tracking bug - fixes #658 2015-02-02 21:14:14 +11:00
Sebastian McKenzie
420505ca40 remove console.log debug 2015-02-02 21:13:40 +11:00
Sebastian McKenzie
f9a26fd903 better optimisation base 2015-02-02 20:28:34 +11:00
Sebastian McKenzie
ca0539190e add some monkeypatched istanbul interop - closes #660 2015-02-02 20:28:24 +11:00
Sebastian McKenzie
2e3226b520 fix 3.3.3 changelog sections 2015-02-02 10:55:49 +11:00
Sebastian McKenzie
7959852eeb 3.3.3 2015-02-02 10:55:43 +11:00
Sebastian McKenzie
c129eba712 v3.3.3 2015-02-02 10:52:56 +11:00
Sebastian McKenzie
0e2d7fa941 remove throw expectation on undefiend this tests 2015-02-02 10:50:29 +11:00
Sebastian McKenzie
0b33a62032 fix linting errors 2015-02-02 10:48:18 +11:00
Sebastian McKenzie
6919ed2b34 add 3.3.3 changelog 2015-02-02 10:46:44 +11:00
Sebastian McKenzie
435320e3f9 selfContainify regenerator runtime when building 6to5-runtime - fixes #659 2015-02-02 10:45:26 +11:00
Sebastian McKenzie
7b846af965 3.3.2 2015-02-02 10:45:05 +11:00
Sebastian McKenzie
18b836c16a add allowPartial option to t.buildMatchMemberExpression, fix t.isReferenced on Property nodes - fixes #656 2015-02-02 10:44:56 +11:00
Sebastian McKenzie
fb360039ce remap top level this to undefined - #562 2015-02-02 10:44:17 +11:00
Sebastian McKenzie
4763b95a0d v3.3.2 2015-02-02 01:43:47 +11:00
Sebastian McKenzie
9fe1e37ca7 fix t.buildMatchMemberExpression 2015-02-02 01:41:39 +11:00
Sebastian McKenzie
8a9aac3e68 fix linting errors 2015-02-02 01:37:27 +11:00
Sebastian McKenzie
27138abd29 simplify member expression checking, flesh out react component optimiser #653 2015-02-02 01:30:06 +11:00
Sebastian McKenzie
dcf91db475 add react component optimisation base #653 2015-02-02 00:50:25 +11:00
Sebastian McKenzie
ab63345764 3.3.1 2015-02-01 18:44:46 +11:00
Sebastian McKenzie
a35e63fb29 v3.3.1 2015-02-01 18:44:07 +11:00
Sebastian McKenzie
3fe7df9a48 fix regenerator destructuring test 2015-02-01 18:42:15 +11:00
Sebastian McKenzie
5288f3afda add 3.3.1 changelog 2015-02-01 18:33:54 +11:00
Sebastian McKenzie
25566a24f6 block hoist assignment pattern destructuring - fixes #652 2015-02-01 18:33:36 +11:00
Sebastian McKenzie
2ff6dee0ec 3.3.0 2015-02-01 16:52:23 +11:00
Sebastian McKenzie
491d1238c2 fix buildHelpers function name 2015-02-01 16:51:57 +11:00
Sebastian McKenzie
234414c2f2 v3.3.0 2015-02-01 16:49:18 +11:00
Sebastian McKenzie
3ff544bbab fix indentation detection 2015-02-01 16:47:28 +11:00
Sebastian McKenzie
416c4cbb84 fix linting errors 2015-02-01 16:44:47 +11:00
Sebastian McKenzie
db5bf1749b fix linting errors 2015-02-01 16:43:42 +11:00
Sebastian McKenzie
41349afea3 add 3.3.0 changelog 2015-02-01 16:43:05 +11:00
Sebastian McKenzie
27da6de723 add back runtime - fixes #651 2015-02-01 16:38:13 +11:00
Sebastian McKenzie
2cdb4e3343 fix linting errors 2015-02-01 16:21:13 +11:00
Sebastian McKenzie
981d3e40f8 add canRun check for playground transformers 2015-02-01 16:20:32 +11:00
Sebastian McKenzie
c7a616730c add levenshtein suggestions to undeclared variable transformer 2015-02-01 16:20:18 +11:00
Sebastian McKenzie
5aa8ece242 don't run playground transformers at all if playground isn't enabled 2015-02-01 16:19:49 +11:00
Sebastian McKenzie
8c7ba20f86 fix regenerator transformer order - fixes #617 2015-02-01 16:19:35 +11:00
Sebastian McKenzie
1cc9027fcf 3.2.1 2015-02-01 16:19:09 +11:00
Sebastian McKenzie
e63dbaa646 v3.2.1 2015-01-31 21:33:26 +11:00
Sebastian McKenzie
4a720625d9 fix linting errors 2015-01-31 21:29:44 +11:00
Sebastian McKenzie
ad428b107a add 3.2.1 changelog 2015-01-31 21:28:14 +11:00
Sebastian McKenzie
c0299320f0 avoid transforming of inner labels and propagation of maps in block scoping transformer - #644 2015-01-31 21:27:20 +11:00
Sebastian McKenzie
efaee3d5d9 remove pending tests 2015-01-31 18:11:54 +11:00
Sebastian McKenzie
12bee73070 restructure internal indexes a bit 2015-01-31 18:04:57 +11:00
Sebastian McKenzie
82c18a837d add detection skeleton #631 2015-01-31 17:59:30 +11:00
Sebastian McKenzie
fed51e8246 3.2.0 2015-01-31 17:59:08 +11:00
Sebastian McKenzie
71f17e464f update 3.2.0 changelog 2015-01-31 17:59:02 +11:00
Sebastian McKenzie
026fd7eddb v3.2.0 2015-01-31 10:15:22 +11:00
Sebastian McKenzie
456b2d3910 remove unused keys declaration in types 2015-01-31 10:12:32 +11:00
Sebastian McKenzie
4208bf3f4b add accept to valid options 6to5/gobble-6to5#2 2015-01-31 10:11:40 +11:00
Sebastian McKenzie
a81678d327 add 3.2.0 changelog 2015-01-31 10:11:19 +11:00
Sebastian McKenzie
be55f42f80 simplify Scope::has 2015-01-31 10:06:22 +11:00
Sebastian McKenzie
b1b326cf9c better self contained module tests - fixes #634 2015-01-30 22:32:21 +11:00
Sebastian McKenzie
a9ff73b4f6 use double quotes instead of single 2015-01-30 21:50:31 +11:00
Sebastian McKenzie
f5ccb9c0ba clean up types, add missing jsdoc parameters, add some descriptions 2015-01-30 21:48:32 +11:00
Sebastian McKenzie
1cbbe00b7a Merge pull request #582 from kruppel/kurt/setter-super
Support use of super inside instance setter.
2015-01-30 21:47:24 +11:00
Sebastian McKenzie
055dd5d2c3 simplify t.getDeclarations keys 2015-01-30 21:42:24 +11:00
Sebastian McKenzie
0fea437536 rename t.getIds to t.getDeclarations and remove dead code 2015-01-30 21:36:51 +11:00
Sebastian McKenzie
f325d3b065 add pattern rest parameters test 2015-01-30 21:26:45 +11:00
Sebastian McKenzie
e514660fbd we no longer have to handle labels on loops in block scoping 2015-01-30 21:26:35 +11:00
Sebastian McKenzie
a5d8144cce don't lazily check kangax compat-table exec comment 2015-01-30 21:17:35 +11:00
Sebastian McKenzie
8145840264 add istanbul config 2015-01-30 21:17:16 +11:00
Sebastian McKenzie
a02eafedfd add additional let scoping nested label tests 2015-01-30 21:07:40 +11:00
Sebastian McKenzie
3f3cd2bb3a add better support for labels in the block scoping transformer and add more let scoping tests - fixes #644 and closes #608 2015-01-30 20:51:20 +11:00
Sebastian McKenzie
503a3f2e3a ignore compat-table tests that have no code 2015-01-30 19:43:47 +11:00
Sebastian McKenzie
48a8723fdb add compat-table to make bootstrap 2015-01-30 19:39:58 +11:00
Sebastian McKenzie
92c297b1be add assertVendor test helper 2015-01-30 19:39:51 +11:00
Sebastian McKenzie
56e26378ff delay running 6to5/register in tests 2015-01-30 19:39:38 +11:00
Sebastian McKenzie
f3f69ab4fa fix scope tracking for default parameters iife 2015-01-30 19:39:20 +11:00
Sebastian McKenzie
2a488b951d remove unused variable in commonjs module formatter 2015-01-30 19:39:09 +11:00
Sebastian McKenzie
ac01caacd3 rename useStrict test to something more specific 2015-01-30 19:39:00 +11:00
Sebastian McKenzie
cbdf746474 fix block scoped functions 2015-01-30 19:38:50 +11:00
Sebastian McKenzie
ad0a1ae66d add kangax compat-table tests - fixes #606 2015-01-30 19:38:44 +11:00
Sebastian McKenzie
3b783979d8 add resolveModuleSource option - closes #471 2015-01-30 18:04:54 +11:00
Sebastian McKenzie
b2ec15accc allow test options to be plain javascript files 2015-01-30 18:04:28 +11:00
Sebastian McKenzie
3b7cfc908e use globals module instead of maintaining our own list 2015-01-30 17:17:42 +11:00
Sebastian McKenzie
010ca83d0d improved relative resolution handling for bin/6to5 - closes #643 2015-01-30 16:59:04 +11:00
Sebastian McKenzie
161c895a90 move esvalid to devDependencies 2015-01-30 16:58:38 +11:00
Sebastian McKenzie
47a45f3731 add additional react ThisExpression conversion test 2015-01-30 11:05:16 +11:00
Sebastian McKenzie
7bb3cfd932 3.1.1 2015-01-30 11:04:46 +11:00
Sebastian McKenzie
16a94a769a v3.1.1 2015-01-30 11:02:28 +11:00
Sebastian McKenzie
f7c7918efe add 3.1.1 changelog 2015-01-30 11:00:43 +11:00
Sebastian McKenzie
bf393c025f properly transform XJSIdentifier nodes referencing this into a ThisExpression - facebook/react#2927 2015-01-30 11:00:37 +11:00
Sebastian McKenzie
bbbc9c0c5e remove redundant enumerable: true property on class methods 2015-01-30 10:44:33 +11:00
Sebastian McKenzie
579db9107f fix link in 3.1.0 changelog - thanks @AluisioASG - closes #641 2015-01-30 10:42:52 +11:00
Sebastian McKenzie
d1d30e9ec9 3.1.0 2015-01-30 10:15:09 +11:00
Sebastian McKenzie
ee782f93c4 v3.1.0 2015-01-30 10:13:50 +11:00
Sebastian McKenzie
9ed6aa48a0 add esdiscuss link to class enumerability change - @thejameskyle 2015-01-30 10:11:26 +11:00
Sebastian McKenzie
ecebedd5a2 update esnext class tests 2015-01-30 10:11:11 +11:00
Sebastian McKenzie
31df576d26 make class methods nonenumerable - fixes #639 2015-01-30 10:05:17 +11:00
Sebastian McKenzie
63d6335d99 3.0.16 2015-01-30 00:18:32 +11:00
Sebastian McKenzie
9e21994c01 v3.0.16 2015-01-30 00:18:01 +11:00
Sebastian McKenzie
b8ee654ac2 update 3.0.16 changelog 2015-01-30 00:14:08 +11:00
Sebastian McKenzie
00b22b1231 don't ignore dynamic import specifiers - fixes #633 2015-01-30 00:13:37 +11:00
Sebastian McKenzie
2e589904c7 comment out detection file 2015-01-30 00:05:38 +11:00
Sebastian McKenzie
1cd475d118 add 3.0.16 changelog 2015-01-30 00:05:01 +11:00
Sebastian McKenzie
fbdea41399 comment out strictMode option until acorn-6to5 works properly 2015-01-30 00:02:25 +11:00
Sebastian McKenzie
5d720dbc43 upgrade regenerator 2015-01-30 00:01:40 +11:00
Sebastian McKenzie
3940149517 add whitespace to functions in logical expressions 2015-01-29 22:50:17 +11:00
Sebastian McKenzie
e963798067 update tests to reflect _extends helper modifications 2015-01-29 22:38:07 +11:00
Sebastian McKenzie
36acfd16ea better line break delimeter - thanks @RReverser! 2015-01-29 22:23:43 +11:00
Sebastian McKenzie
dda372f93e use either Object.assign or the extends helper 2015-01-29 21:07:51 +11:00
Sebastian McKenzie
62bc815f81 only set strictMode to true when the useStrict transformer is enabled 2015-01-29 21:07:34 +11:00
Sebastian McKenzie
4e68f94023 start adding detection base 2015-01-29 21:03:16 +11:00
Sebastian McKenzie
2687b435e0 Merge pull request #629 from stefanpenner/lodash-cleanup
cleanup: require explicit lodash modules needed
2015-01-29 16:04:47 +11:00
Stefan Penner
9ddf411f2c cleanup: require explicit lodash modules needed 2015-01-28 23:52:17 -05:00
Sebastian McKenzie
c2fc89af6c 3.0.15 2015-01-29 15:18:18 +11:00
Sebastian McKenzie
a5eda35ff4 v3.0.15 2015-01-29 15:17:08 +11:00
Sebastian McKenzie
b5e1221c54 uUse debug/node instead of debug to avoid browserify using the browser version that references window - fixes #628 2015-01-29 15:11:33 +11:00
Sebastian McKenzie
03942da57a add in support for AwaitExpression "delegation" 2015-01-29 15:11:17 +11:00
Sebastian McKenzie
e469c864bc 3.0.14 2015-01-29 12:02:05 +11:00
Sebastian McKenzie
9d50cae9fd v3.0.14 2015-01-29 12:01:11 +11:00
Sebastian McKenzie
249d749580 update asyncToGenerator tests 2015-01-29 11:58:58 +11:00
Sebastian McKenzie
ea860ac5a5 add 3.0.14 changelog 2015-01-29 11:54:42 +11:00
Sebastian McKenzie
30259f3a99 don't use a generator iterator function as this in the asyncToGenerator helper - fixes #625 2015-01-29 11:53:30 +11:00
Sebastian McKenzie
a3d7a29961 add support for using optional in 6to5-node 2015-01-29 11:52:44 +11:00
Sebastian McKenzie
8ce762846e fix 3.0.0 changelog indentation 2015-01-29 11:08:19 +11:00
Sebastian McKenzie
8092716b79 3.0.13 2015-01-29 10:44:35 +11:00
Sebastian McKenzie
b7ba54724c v3.0.13 2015-01-29 10:44:11 +11:00
Sebastian McKenzie
7f7ee41315 fix modules loose mode using modules instead of es6.modules 2015-01-29 10:42:03 +11:00
Sebastian McKenzie
b33f05bd3d 3.0.12 2015-01-29 10:41:56 +11:00
Sebastian McKenzie
1ae6eabedd v3.0.12 2015-01-29 10:15:35 +11:00
Sebastian McKenzie
973be9ad96 add noScope option to traverse.clearProperties - fixes #624 2015-01-29 10:13:29 +11:00
Sebastian McKenzie
979ce93499 add 3.0.12 changelog 2015-01-29 10:13:17 +11:00
Sebastian McKenzie
642e36c259 remove old es6.destructuring position comment - thanks @appden! 2015-01-29 09:04:01 +11:00
Sebastian McKenzie
efaf56c6de add debug messages 2015-01-29 09:03:30 +11:00
Sebastian McKenzie
a0c7950d8a 3.0.11 2015-01-29 07:43:09 +11:00
Sebastian McKenzie
f7be1b74d7 v3.0.11 2015-01-29 07:42:43 +11:00
Sebastian McKenzie
e264ac03b3 put destructuring transformer back 2015-01-29 07:40:50 +11:00
Sebastian McKenzie
425f0c5fdf add 3.0.11 changelog 2015-01-29 07:38:15 +11:00
Sebastian McKenzie
960a70287d add improved for-of loose behaviour that supports destructuring - fixes #615 2015-01-29 00:50:22 +11:00
Sebastian McKenzie
c25c33e3ee remove unnecessary ensureBlock in es6 rest parameters transformer 2015-01-29 00:06:42 +11:00
Sebastian McKenzie
d72081f82c fix codeFrame call in transformation helper 2015-01-29 00:06:24 +11:00
Sebastian McKenzie
d4debc3c85 fix regenerator tests 2015-01-29 00:06:12 +11:00
Sebastian McKenzie
7894f1a079 add regenerator parameter tests 2015-01-28 23:45:11 +11:00
Sebastian McKenzie
5ffaeb5e9f 3.0.10 2015-01-28 23:41:55 +11:00
Sebastian McKenzie
e50a7406ad move destructuring transformer to before regenerator 2015-01-28 23:41:51 +11:00
Sebastian McKenzie
962eeed252 clean up t.getIds 2015-01-28 23:41:42 +11:00
Sebastian McKenzie
2d8944fbd5 fix RestElement ast-types definition 2015-01-28 23:41:31 +11:00
Sebastian McKenzie
ddfb492ed9 v3.0.10 2015-01-28 23:14:43 +11:00
Sebastian McKenzie
3d98364adb in types.getIds make sure the declaration inside of ExportDeclaration is actually a Declaration, clean up types.isReferenced - fixes #614 2015-01-28 23:12:53 +11:00
Sebastian McKenzie
3affa543ef add yes/no comments to describe what we're actually testing for in types.isReferenced 2015-01-28 20:21:25 +11:00
Sebastian McKenzie
2a47afebde more accurate types.isReferenced comment 2015-01-28 20:09:37 +11:00
Sebastian McKenzie
f2fc6d8852 3.0.9 2015-01-28 20:09:20 +11:00
Sebastian McKenzie
28c4c18ee2 v3.0.9 2015-01-28 20:08:49 +11:00
Sebastian McKenzie
968db67d0a add in pattern support to t.isReferenced 2015-01-28 20:06:49 +11:00
Sebastian McKenzie
b22ef22e36 add missing semicolon 2015-01-28 20:03:29 +11:00
Sebastian McKenzie
044ce45d98 add 3.0.9 changelog 2015-01-28 20:02:49 +11:00
Sebastian McKenzie
69f2a0d3f1 better t.toIdentifier behaviour that doesn't camelcase on underscores - fixes #610 2015-01-28 20:01:55 +11:00
Sebastian McKenzie
4b66dcb738 more reliable t.isReferenced - fixes #610 2015-01-28 19:58:20 +11:00
Sebastian McKenzie
dfc6f1d1cf add comment explaining what the modules-split transformer does 2015-01-28 18:40:33 +11:00
Sebastian McKenzie
a64e040ac7 3.0.8 2015-01-28 18:36:45 +11:00
Sebastian McKenzie
4f9414dbb0 v3.0.8 2015-01-28 18:36:22 +11:00
Sebastian McKenzie
bc6b31efbc split up function declarations from their exports - fixes #609 2015-01-28 18:34:43 +11:00
Sebastian McKenzie
244aed1ae9 3.0.7 2015-01-28 18:20:04 +11:00
Sebastian McKenzie
4fdb2ce939 v3.0.7 2015-01-28 18:18:23 +11:00
Sebastian McKenzie
fe57eb554c add 3.0.7 changelog 2015-01-28 18:16:44 +11:00
Sebastian McKenzie
3b798943e3 upgrade core-js and use a caret, make all other dependency versions static 2015-01-28 18:15:14 +11:00
Sebastian McKenzie
4ff66a5cfc add id to a function expression scope 2015-01-28 18:14:52 +11:00
Sebastian McKenzie
5477a990bc construct null object for types.getIds 2015-01-28 18:09:38 +11:00
Sebastian McKenzie
656ca422a5 3.0.6 2015-01-28 17:52:09 +11:00
Sebastian McKenzie
7a3071a094 v3.0.6 2015-01-28 17:51:02 +11:00
Sebastian McKenzie
77361582f4 don't stop block scoped variable traversal on any scope, just skip it and fix block statement for parent delegation - fixes #605 2015-01-28 17:48:37 +11:00
Sebastian McKenzie
f585039430 3.0.5 2015-01-28 15:23:11 +11:00
Sebastian McKenzie
21dcb6037a v3.0.5 2015-01-28 15:21:38 +11:00
Sebastian McKenzie
d10d96d19a fix unused iife declaration 2015-01-28 15:19:50 +11:00
Sebastian McKenzie
64766eea44 add more reliable iife detection for default parameter independent scope 2015-01-28 15:18:50 +11:00
Sebastian McKenzie
a9e682836b 3.0.4 2015-01-28 14:52:05 +11:00
Sebastian McKenzie
f504b8d529 v3.0.4 2015-01-28 14:49:55 +11:00
Sebastian McKenzie
30b2b55c86 remove badges from readme because noone cares 2015-01-28 14:48:13 +11:00
Sebastian McKenzie
836bc3a9a4 only check for duplicates for let variables 2015-01-28 14:47:09 +11:00
Sebastian McKenzie
630bfcc6cd add 3.0.x changelogs 2015-01-28 14:44:07 +11:00
Sebastian McKenzie
117203010a don't stop block variable scope finding on first hit 2015-01-28 14:39:46 +11:00
Sebastian McKenzie
f0986fe9c7 3.0.3 2015-01-28 14:39:01 +11:00
Sebastian McKenzie
4379441277 v3.0.3 2015-01-28 14:17:26 +11:00
Sebastian McKenzie
a955af06e0 remove opts from transform output 2015-01-28 14:14:55 +11:00
Sebastian McKenzie
8f69e59f29 ignore underscored options - fixes #29 2015-01-28 14:14:33 +11:00
Sebastian McKenzie
efda5ca897 3.0.2 2015-01-28 13:59:29 +11:00
Sebastian McKenzie
8a99fd3c8d v3.0.2 2015-01-28 13:53:19 +11:00
Sebastian McKenzie
614ce4de0a add common plugin options to validOptions just to be safe 2015-01-28 13:48:45 +11:00
Sebastian McKenzie
06b2cffbfc 3.0.1 2015-01-28 13:17:54 +11:00
Sebastian McKenzie
f3dfe9571e v3.0.1 2015-01-28 13:17:34 +11:00
Sebastian McKenzie
9b9e2c4ac0 remove iojs from travis 2015-01-28 13:15:45 +11:00
Sebastian McKenzie
28e0b17a81 3.0.0 2015-01-28 13:14:05 +11:00
Sebastian McKenzie
b02f10053e fix publish-runtime task 2015-01-28 13:14:00 +11:00
Sebastian McKenzie
979dcd5330 downgrade kexec 2015-01-28 13:13:52 +11:00
Sebastian McKenzie
ff18fd37df v3.0.0 2015-01-28 13:08:55 +11:00
Sebastian McKenzie
dd56d53556 fix linting errors 2015-01-28 13:06:21 +11:00
Sebastian McKenzie
2b85045b61 split up class expressions in export default 2015-01-28 12:58:05 +11:00
Sebastian McKenzie
a1e11aba61 make explode assignable expression helper aware of declared variables so we can simplify code a lot and drop the variable declaration as evaluating it multiple times has no consequence 2015-01-28 11:50:14 +11:00
Sebastian McKenzie
946ba7a8d3 add iojs to travis 2015-01-28 11:03:00 +11:00
Sebastian McKenzie
4a94ef3aa6 add syntax highlighting to syntax error code frames 2015-01-28 11:02:54 +11:00
Sebastian McKenzie
fd45e9218c Merge branch 'master' into 3.0.0
Conflicts:
	package.json
2015-01-27 20:52:45 +11:00
Sebastian McKenzie
24d4d6d73a remove esModule flag from systemjs module formatter - fixes #599 2015-01-27 20:40:43 +11:00
Kurt Ruppel
d87b70b57e Use right side verbatim for ES6 class setter. 2015-01-26 15:55:27 -08:00
Kurt Ruppel
bbfb297d73 Support use of super inside instance setter. 2015-01-26 15:55:27 -08:00
Kurt Ruppel
9b68d08604 Add test for failing assignment to super setter. 2015-01-26 15:55:27 -08:00
Sebastian McKenzie
47b56d089f upgrade jshint and kexec 2015-01-27 07:38:14 +11:00
Sebastian McKenzie
10ede7c934 fix extends helper checking the wrong object - thanks @appden! 2015-01-27 07:38:08 +11:00
Sebastian McKenzie
344390d1b5 fix simple tests - @thejameskyle 2015-01-27 07:18:21 +11:00
Sebastian McKenzie
2869878046 use hasOwnProperty in extends helper 2015-01-27 07:16:57 +11:00
Sebastian McKenzie
2f79bee367 use either print or eval in 6to5-node - closes #591 2015-01-27 07:07:05 +11:00
Sebastian McKenzie
202d98c318 fix linting errors 2015-01-27 07:06:12 +11:00
Sebastian McKenzie
442a39359e Merge pull request #595 from 6to5/lodash
Lodash 3.0 & Regexpu 1.1
2015-01-27 06:47:55 +11:00
James Kyle
c907f8703a Fix regex transpilation test for regexpu 1.1 2015-01-26 11:44:18 -08:00
Sebastian McKenzie
6f2925ed83 remove React.__spread and use extends helper instead - fixes #594 2015-01-27 06:43:57 +11:00
Sebastian McKenzie
f256e18182 add -L arg to loose in the CLI 2015-01-27 06:40:57 +11:00
James Kyle
f9521e5599 Bump Lodash to 3.0 2015-01-26 11:39:01 -08:00
Sebastian McKenzie
41ae06f1aa Merge pull request #593 from jhorwit2/master
Upgrade core-js dependency to fix firefox issue
2015-01-27 06:34:59 +11:00
Josh Horwitz
e5613e9e0d Merge pull request #1 from jhorwit2/jhorwit2-patch-1
Updated minor version upgrade of corejs to fix firefox 20-23 issue
2015-01-26 13:38:32 -05:00
Josh Horwitz
779d14311a Updated minor version upgrade of corejs to fix firefox 20-23 issue 2015-01-26 13:38:09 -05:00
Sebastian McKenzie
971da50129 add a transformer pass class 2015-01-26 22:10:19 +11:00
Sebastian McKenzie
c49438da60 add namespaces and better structure transformation 2015-01-26 21:10:05 +11:00
Sebastian McKenzie
e4a030c916 upgrade acorn-6to5 2015-01-26 20:30:53 +11:00
Sebastian McKenzie
c72f9d894d only use GeneratorBuffer::space if it's for pretty printing so we can drop all spaces easily 2015-01-26 18:13:39 +11:00
Sebastian McKenzie
59283c1148 clean up traversal some more to make it clearer 2015-01-26 18:13:21 +11:00
Sebastian McKenzie
cfe9a4e270 add isConsequenceExpressionStatement last 2015-01-26 17:43:19 +11:00
Sebastian McKenzie
0110d18d4c clearn up traversal and fix replacement node arrays not being traversed - fixes #589 2015-01-26 17:43:11 +11:00
Sebastian McKenzie
2bd1afc5fd fix up traverse tests 2015-01-26 17:08:40 +11:00
Sebastian McKenzie
6875277375 upgrade acorn-6to5 2015-01-26 17:00:34 +11:00
Sebastian McKenzie
9b5045bb91 revert back to simpler osx-only test browser opening 2015-01-26 17:00:28 +11:00
Sebastian McKenzie
f14c0fa5d6 turn off failed test writes 2015-01-26 17:00:19 +11:00
Sebastian McKenzie
4b6203d1f4 simplify class default exports 2015-01-26 16:00:30 +11:00
Sebastian McKenzie
3db7811f00 add missing use strict declarations 2015-01-26 15:53:24 +11:00
Sebastian McKenzie
8243a34b69 change the way modules handle default exports and function declaration exports 2015-01-26 15:53:17 +11:00
Sebastian McKenzie
a821b2249b add class tests to optional async transformers 2015-01-26 15:52:39 +11:00
Sebastian McKenzie
0a851ced19 remove runtime option 2015-01-26 15:52:23 +11:00
Sebastian McKenzie
a2a1ab4c52 clean up file 2015-01-26 13:51:33 +11:00
Sebastian McKenzie
876d88c761 fix module specifier default output 2015-01-26 13:51:27 +11:00
Sebastian McKenzie
d473826a68 add window and self to valid global keys 2015-01-26 13:51:15 +11:00
Sebastian McKenzie
cfd0059fc7 fix linting errors 2015-01-26 13:51:06 +11:00
Sebastian McKenzie
b21b0e753e add back optional brackets around transformers in 6to5 --help 2015-01-26 13:50:44 +11:00
Sebastian McKenzie
5253502846 upgrade acorn-6to5 2015-01-26 12:02:58 +11:00
Sebastian McKenzie
526e743c58 fix 6to5-node blacklist 2015-01-26 12:01:03 +11:00
Sebastian McKenzie
7df0d0530f update 3.0.0 changelog 2015-01-26 11:49:05 +11:00
Sebastian McKenzie
567479787b update tests to reflect new helper compact behaviour 2015-01-26 11:48:35 +11:00
Sebastian McKenzie
59e3eb2bd1 move doDefaultExportInterop to default module formatter 2015-01-26 11:43:46 +11:00
Sebastian McKenzie
b449dbe891 make helpers compact/no newlines/comments 2015-01-26 11:43:34 +11:00
Sebastian McKenzie
c7c99efa8e add back strict module formatters 2015-01-26 10:57:06 +11:00
Sebastian McKenzie
2808bc2c90 add in custom acorn node constructor 2015-01-26 01:32:37 +11:00
Sebastian McKenzie
9b7eb2dcd8 update 3.0.0 changelog 2015-01-26 00:14:35 +11:00
Sebastian McKenzie
274b58573b change -l whitelist flag to -w in bin/6to5-node 2015-01-26 00:14:19 +11:00
Sebastian McKenzie
d7f33121c9 upgrade acorn-6to5 2015-01-26 00:14:08 +11:00
Sebastian McKenzie
75460b91d8 clean up module formatters and fix interopRequireWildcard helper 2015-01-26 00:14:04 +11:00
Sebastian McKenzie
3d355566dc avoid duplicate requires when importing modules 2015-01-25 20:39:41 +11:00
Sebastian McKenzie
a3b58edc52 only remap break/continue when inside a loop 2015-01-25 18:46:20 +11:00
Sebastian McKenzie
5c71b1a031 add base for naughty polyfill tool 2015-01-25 18:46:04 +11:00
Sebastian McKenzie
585e21a734 add whitelist and blacklist options to 6to5-node - closes #588 2015-01-25 17:26:51 +11:00
Sebastian McKenzie
a46f4f7873 upgrade acorn-6to5 2015-01-25 17:23:34 +11:00
Sebastian McKenzie
456bce1c9a rename loose modules 2015-01-25 15:46:27 +11:00
Sebastian McKenzie
d8046333c0 add test location to ast validation 2015-01-25 15:46:17 +11:00
Sebastian McKenzie
49c28d449e deprecate old transformer names 2015-01-25 15:46:04 +11:00
Sebastian McKenzie
3fdf492dcf safer common interop - closes #493 2015-01-25 14:03:25 +11:00
Sebastian McKenzie
99a4343626 use clone helper instead of lodash cloneDeep - fixes #583 2015-01-24 16:32:55 +11:00
Sebastian McKenzie
8eb3091a9d update params generator to work with new parameters 2015-01-24 16:32:37 +11:00
Sebastian McKenzie
befa221bd9 only get the basename for task names in test helper 2015-01-24 16:32:17 +11:00
Sebastian McKenzie
a954ae3a6e add breaking switch break test 2015-01-24 16:32:02 +11:00
Sebastian McKenzie
afa0a31b91 add no loopParent warning to block scoping transformer 2015-01-24 16:31:52 +11:00
Sebastian McKenzie
8a13c12738 switch rest and default parameters to new ast type 2015-01-24 16:31:43 +11:00
Sebastian McKenzie
b938e1aece rename misc transformers 2015-01-24 15:20:23 +11:00
Sebastian McKenzie
89a3206553 Merge branch 'master' into 3.0.0
Conflicts:
	CHANGELOG.md
	lib/6to5/transformation/transformers/optional-core-aliasing.js
2015-01-24 15:00:44 +11:00
Sebastian McKenzie
66e9df6b0b v2.13.7 2015-01-24 11:44:08 +11:00
Sebastian McKenzie
2fb299da22 update 2.13.7 changelog 2015-01-24 11:40:26 +11:00
Sebastian McKenzie
23d962b838 Revert "move optional async transformers down - fixes #580"
This reverts commit 9cf1c62147.
2015-01-24 11:39:50 +11:00
Sebastian McKenzie
519454c343 don't realias variables that are already declared in optional coreAliasing transformer - fixes #579 2015-01-24 11:26:51 +11:00
Sebastian McKenzie
9cf1c62147 move optional async transformers down - fixes #580 2015-01-24 11:20:56 +11:00
Sebastian McKenzie
0e6bd3ed08 v2.13.6 2015-01-24 11:13:59 +11:00
Sebastian McKenzie
95a3a02469 disable failing let scoping test 2015-01-24 11:10:18 +11:00
Sebastian McKenzie
1a0cad2ac1 add new expression as a valid conditional expression parent for parantheses insertion - fixes #578 2015-01-24 10:29:34 +11:00
Sebastian McKenzie
d78a01086d add new expression as a valid conditional expression parent for parantheses insertion - fixes #578 2015-01-24 10:29:12 +11:00
Sebastian McKenzie
3607689fbc fix tests to reflect new destructuring statement behaviour 2015-01-24 00:23:15 +11:00
Sebastian McKenzie
70ce6e0ab8 update 3.0.0 changelog 2015-01-24 00:21:21 +11:00
Sebastian McKenzie
914ef4c5f5 remove 6to5-node repl console.log 2015-01-24 00:21:15 +11:00
Sebastian McKenzie
75389b04a6 use isConsequenceExpressionStatement to correctly evaluate expressions - fixes #502 2015-01-24 00:19:48 +11:00
Sebastian McKenzie
3167d66154 add t.getLastStatements and File::isConsequenceExpressionStatement 2015-01-24 00:04:20 +11:00
Sebastian McKenzie
bd789ff032 fix bin/6to5 blacklist test 2015-01-24 00:03:32 +11:00
Sebastian McKenzie
c118c10a9d update 3.0.0 changelog 2015-01-23 23:47:16 +11:00
Sebastian McKenzie
8ed1325dfc fix RestElement argument type 2015-01-23 23:47:02 +11:00
Sebastian McKenzie
33cd9eeafd don't hoist regenerator variable declarations in system module formatter 2015-01-23 23:46:43 +11:00
Sebastian McKenzie
b280303a10 remove register opts 2015-01-23 23:46:27 +11:00
Sebastian McKenzie
0ad071af4e upgrade acorn-6to5 2015-01-23 23:46:20 +11:00
Sebastian McKenzie
a22cd72440 update to RestElement - @RReverser 2015-01-23 23:20:45 +11:00
Sebastian McKenzie
4fee58e7bc remove includeRegenerator option 2015-01-23 23:05:35 +11:00
Sebastian McKenzie
86b6904e77 fix esnext tests to reflect new super behaviour 2015-01-23 23:05:24 +11:00
Sebastian McKenzie
9f435d02f2 switch to a custom list of global keys and use object helper 2015-01-23 23:04:33 +11:00
Sebastian McKenzie
5419616063 remove optional prefixing 2015-01-23 23:03:49 +11:00
Sebastian McKenzie
5f8f9e35d7 better categorisation of transformers 2015-01-23 23:03:41 +11:00
Sebastian McKenzie
e1d2def4b1 add t.getSpecifierId that handles default specifiers 2015-01-23 23:03:04 +11:00
Sebastian McKenzie
36fef5676a add helpers 2015-01-23 23:02:48 +11:00
Sebastian McKenzie
063fec0ca6 better categorisation of transformers 2015-01-23 23:02:40 +11:00
Sebastian McKenzie
c7e4213641 update 3.0.0 changelog 2015-01-23 09:39:47 +11:00
Sebastian McKenzie
bff150f69d fix filenameRelative name and remove amdModuleIds 2015-01-23 09:39:42 +11:00
Sebastian McKenzie
dc209417e7 move internal tools from bin to tools 2015-01-23 09:39:22 +11:00
Sebastian McKenzie
fb74832594 update 3.0.0 changelog 2015-01-23 09:26:33 +11:00
Sebastian McKenzie
49cd1753e6 throw on unknown options 2015-01-23 09:26:27 +11:00
Sebastian McKenzie
36fa887be8 update XJS namespaces to JSX 2015-01-23 08:08:56 +11:00
Sebastian McKenzie
dacb187f11 upgrade acorn-6to5 2015-01-23 08:08:47 +11:00
Sebastian McKenzie
5815b17dee Merge branch 'master' into 3.0.0 2015-01-23 07:12:28 +11:00
Sebastian McKenzie
fe594dfe0c Merge pull request #572 from assaf/master
Added test case for issue #564
2015-01-23 07:12:02 +11:00
Assaf Arkin
4fe6ad43c1 Added test case for issue #564 2015-01-22 10:19:45 -08:00
Sebastian McKenzie
377212290f 6to5/polyfill can now only be required **once** 2015-01-23 00:19:30 +11:00
Sebastian McKenzie
51b6946a98 remove unlink event watching in bin/6to5 2015-01-23 00:19:19 +11:00
Sebastian McKenzie
c90904a139 put 3.0.0 changes into subsections 2015-01-22 19:24:04 +11:00
Sebastian McKenzie
8f68f62f8a add jscs 2015-01-22 19:23:56 +11:00
Sebastian McKenzie
8678917e2a add util.object that we'll use to construct objects to avoid prototype collisions 2015-01-22 18:39:31 +11:00
Sebastian McKenzie
115509653f remove strict module transformers 2015-01-22 18:39:09 +11:00
Sebastian McKenzie
f43fc08a8f remove indent option from cli 2015-01-22 18:38:21 +11:00
Sebastian McKenzie
31504a5187 add async to generator helper update note 2015-01-22 17:20:38 +11:00
Sebastian McKenzie
9bfe6e7aac add Scope::getFunctionParent method 2015-01-22 17:20:29 +11:00
Sebastian McKenzie
2e0a185db6 keep function id location in block scoped function transformer 2015-01-22 17:20:19 +11:00
Sebastian McKenzie
f63ce4ddd4 rename _letDeclars to _letDeclarators in es6 block scoping transformer 2015-01-22 17:20:05 +11:00
Sebastian McKenzie
c4fb5a5e40 more compact async to generator helper 2015-01-22 17:19:22 +11:00
Sebastian McKenzie
738203485c Merge pull request #569 from caspervonb/makefile-open
Use $BROWSER with fallbacks for opening browser tests
2015-01-22 16:05:56 +11:00
Casper Beyer
5218d07b0d Use $BROWSER with fallbacks for opening browser tests 2015-01-22 12:45:47 +08:00
Sebastian McKenzie
b9b1a44c28 support async await inside of let scoping closure wrapper - fixes #565 2015-01-22 10:53:05 +11:00
Sebastian McKenzie
c0a4e7ad55 upgrade core-js to 0.4.6 2015-01-22 10:12:24 +11:00
Sebastian McKenzie
9ed8e4a35b remove names from optional async tests 2015-01-22 10:12:11 +11:00
Sebastian McKenzie
3e2d611707 store all undeclared references on Program to better handle let scoping 2015-01-22 10:12:03 +11:00
Sebastian McKenzie
5463872926 optional async transformers should remove their ids - fixes #552 2015-01-22 08:15:35 +11:00
Sebastian McKenzie
81ff635c60 fix tests to reflect new super behaviour 2015-01-22 08:07:59 +11:00
Sebastian McKenzie
7072f64397 remove debug console.log 2015-01-22 08:07:37 +11:00
Sebastian McKenzie
418de75e77 fix bare super call being illegal in non-constructors 2015-01-22 07:54:01 +11:00
Sebastian McKenzie
bed2826e3b update 3.0.0 changelog 2015-01-22 07:52:36 +11:00
Sebastian McKenzie
f2a432531e make bare super call in non-constructors illegal 2015-01-22 07:52:31 +11:00
Sebastian McKenzie
da6c2b8d6a add illegal top level this transformer - fixes #562 2015-01-22 07:44:36 +11:00
Sebastian McKenzie
b02e28f3fd add additional 3.0.0 change notes 2015-01-22 07:38:08 +11:00
Sebastian McKenzie
da8888a350 move around transformers to work better with regenerator 2015-01-22 07:37:59 +11:00
Sebastian McKenzie
43856136d5 update tests 2015-01-22 07:37:45 +11:00
Sebastian McKenzie
589d20019f bump regenerator 2015-01-22 07:37:37 +11:00
Sebastian McKenzie
50d3599f76 upgrade regenerator-6to5 2015-01-22 07:37:26 +11:00
Sebastian McKenzie
870954c6be rewrite constants transformer 2015-01-22 07:37:18 +11:00
Sebastian McKenzie
6959e60e2c bump 6to5-runtime version 2015-01-22 01:47:19 +11:00
Sebastian McKenzie
9cdbb99eb9 fix linting errors 2015-01-22 01:47:13 +11:00
Sebastian McKenzie
48cebd5e30 rename es6.generators to regenerator 2015-01-22 01:47:07 +11:00
Sebastian McKenzie
4e829f3e1b categorise 3.0.0 changes 2015-01-22 01:46:33 +11:00
Sebastian McKenzie
7cbe914b22 update 3.0.0 changelog 2015-01-22 01:45:48 +11:00
Sebastian McKenzie
c2d61ad660 more intelligent scope tracking and insertion 2015-01-22 01:40:26 +11:00
Sebastian McKenzie
878a7ada06 better dynamic imports/data 2015-01-22 01:38:18 +11:00
Sebastian McKenzie
b7b2845160 add descriptions about why some transformers are in the position they are 2015-01-22 01:38:08 +11:00
Sebastian McKenzie
2ab4a3d362 update tests to reflect new uid behaviour 2015-01-22 01:37:50 +11:00
Sebastian McKenzie
cfd95a1398 only require imports that are necessary in selfContained 2015-01-22 01:37:28 +11:00
Sebastian McKenzie
ccdb480d44 rename traverser to visitor 2015-01-22 00:28:20 +11:00
Sebastian McKenzie
ac373a9e1c use scope for uid registry instead of a global registry 2015-01-22 00:27:45 +11:00
Sebastian McKenzie
4ce7d5a5b4 Merge branch 'guybedford-system-tests' into 3.0.0 2015-01-21 23:59:41 +11:00
Sebastian McKenzie
1e217c745b Merge branch 'system-tests' of https://github.com/guybedford/6to5 into guybedford-system-tests 2015-01-21 23:59:32 +11:00
Sebastian McKenzie
287bfc77b2 add scope file.generateUidIdentifier alias 2015-01-21 23:58:43 +11:00
Sebastian McKenzie
3205c78f01 ensure that a scope is always passed to traverse and allow scopes to have access to file 2015-01-21 23:52:12 +11:00
Sebastian McKenzie
0b6d49e421 better handling of optional transformers 2015-01-21 23:34:18 +11:00
Sebastian McKenzie
546a44d1d7 autoindentation - fixes #467 2015-01-21 23:33:57 +11:00
Sebastian McKenzie
ac891bebaa nicer unknown transformer message 2015-01-21 23:33:30 +11:00
Sebastian McKenzie
0ab4326026 Merge branch 'gaearon-traversers-3.0.0' into 3.0.0 2015-01-21 23:13:51 +11:00
Sebastian McKenzie
5fcfff23a4 Merge branch 'traversers-3.0.0' of https://github.com/gaearon/6to5 into gaearon-traversers-3.0.0 2015-01-21 23:13:43 +11:00
Sebastian McKenzie
28fe45bd1d namespace all transformer keys with their type 2015-01-21 23:12:57 +11:00
Sebastian McKenzie
f312026c23 move transformers into their corresponding type folder 2015-01-21 23:04:31 +11:00
guybedford
8023788305 add generator and variable binding tests 2015-01-21 13:58:49 +02:00
Sebastian McKenzie
0d0d89fd9c better names for property transformers 2015-01-21 22:41:55 +11:00
Sebastian McKenzie
019f2ee932 namespace default/rest parameter transformers 2015-01-21 22:40:50 +11:00
Sebastian McKenzie
8558505b65 merge comprehension transformers 2015-01-21 22:40:26 +11:00
Sebastian McKenzie
c51f8c48b6 rename let scoping transformer to block scoping 2015-01-21 22:40:17 +11:00
Dan Abramov
3d9d842a0d Extract traversers outside methods 2015-01-21 14:34:47 +03:00
Sebastian McKenzie
cfd028288f Merge branch 'master' into 3.0.0
Conflicts:
	CHANGELOG.md
	lib/6to5/transformation/transform.js
2015-01-21 17:56:34 +11:00
Sebastian McKenzie
194c080c64 v2.13.5 2015-01-21 13:37:06 +11:00
Sebastian McKenzie
4c6076e529 add 2.13.5 changelog 2015-01-21 13:35:30 +11:00
Sebastian McKenzie
df65ec08a2 support destructuring patterns in rest parameters - fixes #550 2015-01-21 13:35:24 +11:00
Sebastian McKenzie
62f11011b0 upgrade kexec - closes #551 2015-01-21 13:19:24 +11:00
Sebastian McKenzie
9385c7e4ad v2.13.4 2015-01-21 10:27:35 +11:00
Sebastian McKenzie
3c06e68cae fix default parameter node variable name 2015-01-21 10:21:27 +11:00
Sebastian McKenzie
e8810f5124 add 2.13.4 changelog 2015-01-21 10:20:13 +11:00
Sebastian McKenzie
3c258c4716 add proper ordering to function param logic - fixes #549 2015-01-21 10:17:52 +11:00
Sebastian McKenzie
193a3c167e loops should contain their child block let declarations 2015-01-20 19:33:26 +11:00
Sebastian McKenzie
4b525daf72 fix forOf scope declarations not propagating to new for loop - fixes #538 2015-01-20 19:33:05 +11:00
Sebastian McKenzie
e46f42872a add array comprehension collision test #538 2015-01-20 16:52:11 +11:00
Sebastian McKenzie
4790e4068a add for collision test #538 2015-01-20 16:52:00 +11:00
Sebastian McKenzie
26cb5d5a65 add block to for loop scope - fixes #538 2015-01-20 16:48:41 +11:00
Sebastian McKenzie
031bda61cc don't continue let scoping remapping if there are none to be remapped 2015-01-20 16:48:07 +11:00
Sebastian McKenzie
61f1fae83b remove unused template 2015-01-20 16:47:52 +11:00
Sebastian McKenzie
d911bdaf63 add AssignmentPattern support to scope tracking - fixes #537 2015-01-20 08:56:14 +11:00
Sebastian McKenzie
1859226e76 remove runtime test 2015-01-20 02:36:42 +11:00
Sebastian McKenzie
e4523de16d upgrade regenerator-6to5 2015-01-20 02:34:02 +11:00
Sebastian McKenzie
6a3829d605 remove includeRegenerator option 2015-01-20 02:31:19 +11:00
Sebastian McKenzie
437ba46889 update regenerator submodule url 2015-01-20 02:31:10 +11:00
Sebastian McKenzie
7007f7e0bb remove includeRegenerator option 2015-01-20 02:30:57 +11:00
Sebastian McKenzie
ff12a996de remove ALL check from regenerator tests 2015-01-20 02:30:49 +11:00
Sebastian McKenzie
faba02afd4 better block scoped functions 2015-01-20 02:30:41 +11:00
Sebastian McKenzie
5436e95c9a switch to regenerator-to5 2015-01-20 02:30:34 +11:00
Sebastian McKenzie
031099b58e add generator note to name method helper 2015-01-20 02:29:50 +11:00
Sebastian McKenzie
e75d1a1666 fix helper identifiers 2015-01-20 01:45:00 +11:00
Sebastian McKenzie
7f6eb3dba3 update selfContained transformer to use new File data layer 2015-01-20 01:42:43 +11:00
Sebastian McKenzie
33d2463c65 remove old runtime tests 2015-01-20 01:42:31 +11:00
Sebastian McKenzie
ab134d0919 add data abstraction layer to File 2015-01-20 01:36:00 +11:00
Sebastian McKenzie
d6412d0a1b Merge branch 'AluisioASG-scoped-es6-runtime' into 3.0.0 2015-01-20 01:34:50 +11:00
Sebastian McKenzie
9f41d6231e Merge branch 'scoped-es6-runtime' of https://github.com/AluisioASG/6to5 into AluisioASG-scoped-es6-runtime 2015-01-20 01:34:43 +11:00
Aluísio Augusto Silva Gonçalves
9d2e12dfa6 Amendments from 6to5/6to5#535 comments 2015-01-19 12:31:47 -02:00
Aluísio Augusto Silva Gonçalves
043bf13d24 Revert moving _blockHoist after regenerator
This reverts commits 81bec3e5c4 and
157f5c3304.
2015-01-19 12:24:54 -02:00
Aluísio Augusto Silva Gonçalves
3f96cf3963 Rename 6to5-runtime's helpers module to 'helpers' 2015-01-19 12:24:45 -02:00
Sebastian McKenzie
22fb346983 remove runtime option 2015-01-20 01:17:24 +11:00
Sebastian McKenzie
e7acfd7bb7 fix regenerator runtime build 2015-01-20 01:13:28 +11:00
Sebastian McKenzie
31cf740b99 fix regenerator location 2015-01-20 01:05:49 +11:00
Sebastian McKenzie
d75139a059 add 6to5-runtime build process #535 2015-01-20 00:56:09 +11:00
Sebastian McKenzie
7257e2445d Merge branch 'master' into 3.0.0
Conflicts:
	CHANGELOG.md
	lib/6to5/file.js
	lib/6to5/register.js
2015-01-20 00:36:06 +11:00
Sebastian McKenzie
f322252c36 add optional undeclared variable check transformer 2015-01-20 00:17:22 +11:00
Sebastian McKenzie
da16bf1e42 add t.isReferencedIdentifier 2015-01-20 00:17:11 +11:00
Aluísio Augusto Silva Gonçalves
157f5c3304 Remove regenerator edge case from selfContained test
Right now exporting a generator doesn't work because we hoist the
export assignment before the function expression assignment.  This
will be dealt with at another time as it is not specific to this
transformer.
2015-01-19 10:54:33 -02:00
Sebastian McKenzie
4a1addc558 better whitespace for VariableDeclarations 2015-01-19 22:09:05 +11:00
Aluísio Augusto Silva Gonçalves
e2bf61379f Add full-blown test for the selfContained transformer 2015-01-18 23:10:26 -02:00
Aluísio Augusto Silva Gonçalves
02019d4d8f Drop unnecessary dynamic import redeclaration in AMD
Instead of assigning the import a name and them declaring a new
variabled referencing that name, output the import already with
the destination name, since we know there must be no collisions
because these IDs are also generated.
2015-01-18 21:18:25 -02:00
Aluísio Augusto Silva Gonçalves
c81cc5cda0 Unify coreAliasing, externalRuntime and externalRegenerator
Merge all three transformers into the `selfContained` transformer,
as discussed in Gitter.  Name may not be final.
2015-01-18 21:15:30 -02:00
Aluísio Augusto Silva Gonçalves
8d288c01ca Import ES6 functions and helpers from 6to5-runtime
The new `6to5-runtime` packs core-js, 6to5's helpers and
the Regenerator runtime, and we're moving `coreAliasing`,
`externalRuntime` and `externalRegenerator` to use it
instead of forcing the user to depend on these packages
directly.
2015-01-18 20:39:35 -02:00
Sebastian McKenzie
857abf5024 v2.13.3 2015-01-19 09:05:37 +11:00
Sebastian McKenzie
6d67105bab add coverage and vendor to npmignore 2015-01-19 09:02:51 +11:00
Aluísio Augusto Silva Gonçalves
e2f4ca106e Merge branch 'external-regenerator-runtime' into scoped-es6-runtime 2015-01-18 20:02:48 -02:00
Aluísio Augusto Silva Gonçalves
061bbe0409 Merge branch 'external-runtime' into scoped-es6-runtime 2015-01-18 20:01:52 -02:00
Aluísio Augusto Silva Gonçalves
7e6da1d368 Add tests for the externalRegenerator transformer 2015-01-18 17:33:57 -02:00
Aluísio Augusto Silva Gonçalves
d4cc8fefd1 Add transformer to import regeneratorRuntime from a module
Thanks to facebook/regenerator#167 Regenerator's runtime can be now
required as a module (though not in an easily self-containable way).
This transformer, together with `coreAliasing` and `externalRuntime`,
allows users to ditch a runtime dependency on `6to5`/`6to5-core` to
depend directly on `core-js` and `regenerator`.
2015-01-18 17:33:56 -02:00
Aluísio Augusto Silva Gonçalves
81bec3e5c4 Move the _blockHoist transformer after regenerator
Otherwise wrapped generator functions are hoisted to the top of the
scope even if we want something else to come before them.
2015-01-18 17:33:55 -02:00
Aluísio Augusto Silva Gonçalves
e985d8b25d Don't use interopRequire for dynamic imports
They don't need it at all and this also allows use of `externalRuntime`
without fear of the runtime ending up being loaded after it's used.
2015-01-18 17:31:55 -02:00
Aluísio Augusto Silva Gonçalves
84ee0efe32 Add test for externalRuntime with AMD modules 2015-01-18 17:31:54 -02:00
Aluísio Augusto Silva Gonçalves
e9a024e58a Add simple test for externalRuntime transformer
Just import a module namespace and see what happens.
2015-01-18 17:31:53 -02:00
Aluísio Augusto Silva Gonçalves
e8237910e8 Add a transformer to import the runtime from a file
The `externalRuntime` optional transformer can be used in conjunction
with the `runtime` option to import and use the runtime from a module
instead of polluting the global environment.
2015-01-18 17:31:52 -02:00
Sebastian McKenzie
bb19f24923 remove roadrunner from 6to5-node 2015-01-15 01:08:12 +11:00
Sebastian McKenzie
0cbcbc60de allow imports and exports everywhere in loose mode 2015-01-14 15:21:45 +11:00
Sebastian McKenzie
f33cd7184f add jsx to possible extensions 2015-01-14 15:09:15 +11:00
Sebastian McKenzie
59d6400eb9 remove ignoreRegex fallback 2015-01-14 15:06:12 +11:00
Sebastian McKenzie
5c575ebf8f remove fast transformer backwards compatibility 2015-01-14 14:58:15 +11:00
Sebastian McKenzie
274205bccd Merge branch 'master' into 3.0.0
Conflicts:
	CHANGELOG.md
	package.json
2015-01-14 14:56:55 +11:00
Sebastian McKenzie
e85c9b633a enable require hook cache by default - shove it into into a temp directory - don't cache require resolutions 2015-01-14 14:55:30 +11:00
Sebastian McKenzie
fbb150cfc1 remove allowImportExportEverywhere 2015-01-13 00:10:12 +11:00
834 changed files with 9601 additions and 6597 deletions

5
.6to5rc Normal file
View File

@@ -0,0 +1,5 @@
{
"experimental": true,
"playground": true,
"loose": true
}

View File

@@ -6,6 +6,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.js]
[*.{js,json}]
indent_style = space
indent_size = 2

2
.gitignore vendored
View File

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

5
.gitmodules vendored
View File

@@ -3,7 +3,10 @@
url = https://github.com/google/traceur-compiler
[submodule "vendor/regenerator"]
path = vendor/regenerator
url = https://github.com/facebook/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

2
.istanbul.yml Normal file
View File

@@ -0,0 +1,2 @@
instrumentation:
root: lib

58
.jscsrc Normal file
View File

@@ -0,0 +1,58 @@
{
"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,3 +1 @@
node_modules
test
lib/6to5/transformation/templates

View File

@@ -2,6 +2,7 @@
"esnext": true,
"indent": 2,
"freeze": true,
"validthis": true,
"camelcase": true,
"unused": true,
"eqnull": true,

View File

@@ -11,3 +11,5 @@ tests.json
CHANGELOG.md
.package.json
coverage
vendor
packages

View File

@@ -3,6 +3,7 @@ language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"
branches:
except:

View File

@@ -11,6 +11,389 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 3.6.1
* **Bug Fix**
* Multiline JSX string literals are now supported.
* Fix scope tracking import specifiers incorrectly.
* Fix templates incorrectly recursing into their replacements.
* **Internal**
* Type inferrence now extends to function return types.
* Upgrade `acorn-6to5`.
## 3.6.0
* **New Feature**
* Add playground class property initializers.
* **Polish**
* Completely reimplemented scope tracking, can now track types and optimise certain helpers based on it.
* Extremely fast tail recursion optimisation implementation. Thanks [@RReverser](https://github.com/RReverser)!
* **Internal**
* `kexec` has been removed as an optional dependency and must be user installed.
* Upgrade `regenerator-6to5`.
* Upgrade `acorn-6to5`.
* Upgrade `core-js`.
## 3.5.3
* Enable `es6.tailCall` transformer with the first implementation that only works with self referencing calls until we can implement nested tail calls elegantly.
## 3.5.2
* Disable `es6.tailCall` temporairly after reports of it breaking.
## 3.5.1
* **Polish**
* Allow tail calls to work across files without the runtime.
* **Internal**
* Upgrade `acorn-6to5`.
## 3.5.0
* **Bug Fix**
* Destructuring patterns as the left operator in `ForInStatement`/`ForOfStatement`.
* **Polish**
* Make default parameter IIFE invocation smarter.
* Make `__esModule` flag non-enumerable. Thanks [@daliwali](https://github.com/daliwali)!
* **Internal**
* More performance improvements.
* Parsing is now ~30% faster thanks to [marijnh/acorn@7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f](https://github.com/marijnh/acorn/commit/7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f).
* **New Feature**
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edgecases.
* `super` in object literals.
* Tail call optimisation. Thanks [@RReverser](https://github.com/RReverser)!
## 3.4.1
* **Bug Fix**
* Fix conflicting `--module-ids` shorthand arg in `$ 6to5`.
* Add require hook options to cache key.
* Fix strict module formatter.
## 3.4.0
* **New Feature**
* Add `commonStandard` module formatter.
* **Bug Fix**
* Fix conflicting `--module-ids` shorthand arg in `$ 6to5`.
* **Internal**
* Lots of internal refactoring with scope tracking and traversal.
* **Polish**
* Don't return `map` in the API result if `sourceMap` was set to `"inline"`.
## 3.3.12
* **Bug Fix**
* Don't override `MemberExpression`s with `core-js` in `selfContained` if a local binding exists.
## 3.3.11
* **Bug Fix**
* Fix the require cache.
## 3.3.10
* **Internal**
* Restructure transformers so they're only ran if the AST contains nodes that they need to worry about. Improves transpilation speed significantly.
* **Bug Fix**
* Fix source maps not tracking end of node locations.
* **Spec Compliancy**
* Use static super references as the home object is actually done at definition time.
* **Polish**
* Force the `es6.destructuring` transformer to be whitelisted when the `es7.objectSpread` transformer is.
* Join sibling string literals when creating JSX.
## 3.3.9
* **Bug Fix**
* Fix super inside of functions.
* Fix super constructor inheritance.
## 3.3.7
* **Bug Fix**
* Add `--use-strict` to valid node flags in `6to5-node`.
* Fix booleans not being properly stripped from the arguments in `6to5-node`.
* Force `.js` extension when writing files to directories with `6to5`.
## 3.3.5
* **Bug Fix**
* Fix block scoping inside of while loops.
* Make module name regex more conservative. Thanks [@johlrich](https://github.com/johlrich)!
* Fix block scoping of constants.
* Fix istanbul interop.
* Make JSX transforming more inline with the official transformer with spaces after non-empty last lines.
* **Polish**
* Make it illegal to export a property called `__esModule`.
## 3.3.4
* **Polish**
* Add istanbul `require` interop.
* **Bug Fix**
* Fix incorrect source map column tracking in specific scenarios.
## 3.3.3
* **Polish**
* Remap top level `this` to `undefined` instead of throwing an error.
* **Bug Fix**
* Run `selfContained` transformer over the regenerator runtime when building `6to5-runtime`.
* Fix `t.isReferenced` not properly allowing `value` nodes.
## 3.3.1
* **Bug Fix**
* Block hoist assignment pattern destructuring.
## 3.3.0
* **Bug Fix**
* Do all transforms before the regenerator transform is ran.
* **New Feature**
* Added back the 2.x optional runtime.
## 3.2.1
* **Bug Fix**
* Fix block scoping transformer rewriting breaks and continues to inner labels.
## 3.2.0
* **Bug Fix**
* Fixed scope tracking for default parameters IIFE.
* Fixed block scoped functions.
* Improved `bin/6to5` path resolution.
* **New Feature**
* You can now trigger super setters in classes. Thanks [@kruppel](https://github.com/kruppel)!
* Add `resolveSourceMap` option.
* Better support and output for block scoping loops with labels.
## 3.1.1
* **Polish**
* Drop `enumerable: false` clause from class method definitions as `enumerable` already defaults to `false`.
* **Bug Fix**
* Properly transform `XJSIdentifier` nodes referencing `this` into a `ThisExpression`.
## 3.1.0
* **Breaking Change**
* [Make class methods unenumerable](https://esdiscuss.org/topic/classes-and-enumerability#content-61).
## 3.0.16
* **Bug Fix**
* Don't ignore dynamic import specifiers.
* **Internal**
* Upgrade `regenerator-6to5`.
* **Polish**
* Use `Object.assign` in place of extends helper if it exists.
* Require individual `lodash` methods. Thanks [@stefanpenner](https://github.com/stefanpenner)!
## 3.0.15
* **Bug Fix**
* Use `debug/node` instead of `debug` to avoid browserify using the browser version that references `window`.
## 3.0.14
* **New Feature**
* Add `--optional` argument to `6to5-node`.
* **Bug Fix**
* Fix bug in `asyncToGenerator` helper where it was incorrectly calling generator iterator functions.
## 3.0.13
* **Bug Fix**
* Fix modules loose mode using `modules` instead of `es6.modules`.
## 3.0.12
* **Internal**
* Add internal debug messages.
* **Bug Fix**
* Add `noScope` option to `traverse.clearProperties`.
## 3.0.11
* **Bug Fix**
* Fix `ast-types` `RestElement` definition.
* Make `es6.forOf` loose mode more versatile and support destructuring.
## 3.0.10
* **Bug Fix**
* In `types.getIds` make sure the `declaration` inside of `ExportDeclaration` is actually a `Declaration`.
## 3.0.9
* **Bug Fix**
* Make `t.isReferenced` more powerful, actually take into consideration all contexts were identifier nodes aren't actually references.
* Don't camelcase underscores when converting a string to a valid identifier.
## 3.0.8
* **Bug Fix**
* Split up default function declaration exports due to regenerator destroying the parent export declaration.
## 3.0.7
* **Internal**
* Upgrade `core-js` to `0.4.9`.
* **Bug Fix**
* Add id to function express scope tracking.
## 3.0.6
* **Bug Fix**
* Fix block scope variable tracking stopping whenever it hits a new scope.
* Fix block scope variable tracking breaking on all block statement scopes that have a for loop parent.
## 3.0.5
* **Internal**
* More reliable default parameter scope.
## 3.0.4
* **Bug Fix**
* Remove traversal stops from block scope tracking.
## 3.0.3
* **Internal**
* Ignore options starting with `_`.
## 3.0.2
* **Internal**
* Add common plugin options to valid options list.
## 3.0.1
* **Internal**
* Downgrade `kexec` as `1.1.0` throws compilation errors.
## 3.0.0
* **Polish**
* Generated code autoindentation.
* Moved global uid registry to a scope registry resulting in nicer uids.
* `this` is now illegal in the top level scope when using the default `useStrict` transformer.
* New `asyncToGenerator` helper that's much more compact.
* Throw errors on unknown options.
* More reliable default parameter scope.
* Helpers are now compact and have no newlines.
* **Internal**
* Rewritten a lot of the internals to much simpler.
* Removed TDZ from default parameters as it was very wonky and unreliable.
* Upgrade `core-js` to `0.4.6`.
* Upgrade `acorn-6to5`.
* JSX support is now on-par with react-tools/esprima.
* Shorthand destructuring.
* **Bug Fix**
* Generators now work flawlessly with any parameter transformers.
* Optional async function transformers should not name their functions.
* Remove `unlink` event watching in `bin/6to5`.
* Fix regenerator variable declarations being incorrectly hoisted breaking scope.
* Transformers that attempted to simplify expressions that had no consequence now take into account whether it's one of the last statements/expressions in the script.
* **New Feature**
* New `selfContained` transformer.
* New `undeclaredVariableCheck` optional transformer.
* Added `--blacklist` and `--whitelist` options to `6to5-node`.
* **Breaking Change**
* Caching is now always enabled for the require hook. It also now no longer caches require resolutions.
* Bare `super();` only works inside of constructors.
* Removed the optional runtime in favor of the `selfContained` transformer.
* This shorthand has been removed from the playground.
* `6to5/polyfill` can now only be required **once**.
* **CLI**
* `--indent` option has been removed.
* `--include-regenerator` option has been removed.
* `--amd-modules-id` option has been removed, use `--module-ids` instead.
* **Options**
* `amdModuleIds` option has been removed, use `moduleIds` instead.
* `includeRegenerator` has been removed.
* `ignoreRegex` fallback has now been dropped from the require hook. `register(/foo/);`, `register({ ignoreRegex: /foo/ })` -> `register({ ignore: /foo/ })`.
* **Modules**
* Module interop now only collapses to `module.exports` when there's a **single** export that's default.
* Imports and exports are now illegal anywhere except the root level by default. Set `modules` to [loose mode](http://6to5.org/docs/usage/loose) to allow them everywhere.
* **Transformers**
* Optional fast transformer backwards compatibility support has been removed. Use [loose mode](https://6to5.org/docs/usage/loose).
* Removed the `coreAliasing` transformer in favor of `selfContained`.
* Renamed transformers:
* `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.objectSpread`
* `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.blockScoping`
* `blockScopingTDZ` -> `es6.blockScopingTDZ`
* `generators` -> `regenerator`
* `protoToAssign` -> `spec.protoToAssign`
* `typeofSymbol` -> `spec.typeofSymbol`
* `coreAliasing` -> `selfContained`
* `undefinedToVoid` -> `spec.undefinedToVoid`
* `undeclaredVariableCheck` -> `validation.undeclaredVariableCheck`
* `specPropertyLiterals` -> `minification.propertyLiterals`
* `specMemberExpressionLiterals` -> `minification.memberExpressionLiterals`
## 2.13.7
* **Bug Fix**
* Don't realias variables that are already declared in optional `coreAliasing` transformer.
## 2.13.6
* **Bug Fix**
* Add `NewExpression` as a valid parent for parentheses insertion for `ConditionalExpression`.
## 2.13.5
* **Bug Fix**
* Allow rest parameters to be destructuring patterns.
* **Internal**
* Upgrade `kexec` to `1.1.0`.
## 2.13.4
* **Bug Fix**
* Fix ordering of destructuring and default params.
* Fix loop body scope.
* Fix `for...of` transformation not retaining it's scope.
* Add destructuring assignment support to scope tracking.
* **Polish**
* More reliable newlines for pretty printing variable declarations.
## 2.13.3
* **Internal**
* Add `coverage` and `vendor` to npmignore.
## 2.13.2
* **Bug Fix**
@@ -67,8 +450,8 @@ _Note: Gaps between patch versions are faulty/broken releases._
* **Polish**
* Rest parameters now allocate the array before populating.
* **Internal**
* `for...in` loops have been changed to optimised `for` loops - better performance and no enumeration of protoype keys.
* Parts of the code generator have now been optimised thanks to [gaearon](https://github.com/gaearon).
* `for...in` loops have been changed to optimized `for` loops - better performance and no enumeration of protoype keys.
* Parts of the code generator have now been optimized thanks to [gaearon](https://github.com/gaearon).
## 2.12.3
@@ -91,7 +474,7 @@ _Note: Gaps between patch versions are faulty/broken releases._
* **Bug Fix**
* Support non-string JSX literals.
* **New Feature**
* Loose mode for some transformers that enables non-spec behaviour.
* Loose mode for some transformers that enables non-spec behavior.
* **Internal**
* Uglify `--mangle sort` has been added to the build script, cutting minified scripts in half.
@@ -529,7 +912,7 @@ _Note: Gaps between patch versions are faulty/broken releases._
## 1.13.2
* Optimise `Array.from` usage by adding a helper method.
* Optimize `Array.from` usage by adding a helper method.
* Upgrade `acorn-6to5`.
## 1.13.1

View File

@@ -1,6 +1,12 @@
# 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/6to5/6to5/blob/master/CODE_OF_CONDUCT.md).
**NOTE:** Please do not send pull requests that fix linting issues. It's highly
likely that they've already been fixed by the time it's submitted and it just
pollutes the git tree.
## Developing
@@ -12,7 +18,8 @@ Contributions are always welcome, no matter how large or small. Before contribut
* 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
* Create new pull request explaining your proposed change or reference an issue
in your commit message
#### Code Standards

View File

@@ -4,20 +4,28 @@ 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
6TO5_CMD = node_modules/6to5/bin/6to5
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
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap publish-core publish-runtime build-core watch-core
build-core:
#node $(6TO5_CMD) src --out-dir lib
watch-core:
#node $(6TO5_CMD) src --out-dir lib --watch
build:
mkdir -p dist
node bin/cache-templates
node tools/cache-templates
node $(BROWSERIFY_CMD) -e lib/6to5/polyfill.js >dist/polyfill.js
node $(UGLIFY_CMD) dist/polyfill.js >dist/polyfill.min.js
node $(BROWSERIFY_CMD) lib/6to5/browser.js -s to5 >dist/6to5.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 bin/6to5-runtime >dist/runtime.js
@@ -30,6 +38,7 @@ clean:
lint:
$(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin
$(JSCS_CMD) lib bin
test-clean:
rm -rf test/tmp
@@ -40,28 +49,28 @@ test: lint
test-simple:
# excludes test262
export SIMPLE_6TO5_TESTS=1
export SIMPLE_6TO5_TESTS=1; \
make test
test-all:
# includes traceur, esnext, regenerator
export ALL_6TO5_TESTS=1
export ALL_6TO5_TESTS=1; \
make test
test-cov:
export SIMPLE_6TO5_TESTS=1
rm -rf coverage
export SIMPLE_6TO5_TESTS=1; \
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
test-travis: bootstrap
test-travis: build-core bootstrap
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
test-browser:
mkdir -p dist
node bin/cache-templates
node bin/cache-tests
node tools/cache-templates
node tools/cache-tests
node $(BROWSERIFY_CMD) -e test/_browser.js >dist/6to5-test.js
rm -rf templates.json tests.json
@@ -80,27 +89,36 @@ publish:
cp dist/polyfill.min.js browser-polyfill.js
cp dist/runtime.min.js runtime.js
node bin/cache-templates
node tools/cache-templates
test -f templates.json
npm publish
git push --follow-tags
# generate
bin/generate-core-package-json >package2.json
make publish-core
make publish-runtime
rm -rf templates.json browser.js browser-polyfill.js runtime.js
publish-runtime:
cd packages; \
node build-runtime.js; \
cd 6to5-runtime; \
npm publish
publish-core:
tools/generate-core-package-json >package2.json
mv package.json .package.json
mv package2.json package.json
npm publish
# restore
rm -rf package.json
mv .package.json package.json
rm -rf templates.json browser.js runtime.js browser-polyfill.js
bootstrap:
npm install
git submodule update --init
cd vendor/regenerator; npm install
cd vendor/compat-table; npm install object-assign

View File

@@ -1,14 +1,3 @@
# Notes
* Wildcard exports/imports wont normalise if `export default` is a non-object. See [#224](https://github.com/6to5/6to5/issues/224).
## 3.0.0 breaking changes
* Remove `allowImportExportEverywhere` option from acorn.
* Remove this shorthand from playground.
* Remove `super()` inside non-constructors - add descriptive error message.
* Split up ES5 getter/setter transforming and ES6 property methods into separate transformers.
* Add autoindentation.
* Move `super` transformation from classes into a separate transformer that also supports object expressions.
* Remove fast transformer backwards compatibility.
* Rename let scoping transformer to block scoping.
* Wildcard exports/imports wont normalize if `export default` is a non-object. See [#224](https://github.com/6to5/6to5/issues/224).

View File

@@ -2,28 +2,6 @@
<img alt="6to5" src="https://raw.githubusercontent.com/6to5/logo/master/logo.png" width="546">
</p>
<p align="center">
<a href="https://gratipay.com/sebmck">
<img alt="Gratipay" src="https://img.shields.io/gratipay/sebmck.svg?style=flat">
</a>
<a href="https://travis-ci.org/6to5/6to5">
<img alt="Travis Status" src="http://img.shields.io/travis/6to5/6to5/master.svg?style=flat&amp;label=travis">
</a>
<a href="https://codeclimate.com/github/6to5/6to5">
<img alt="Code Climate Score" src="http://img.shields.io/codeclimate/github/6to5/6to5.svg?style=flat">
</a>
<a href="https://codeclimate.com/github/6to5/6to5">
<img alt="Coverage" src="http://img.shields.io/codeclimate/coverage/github/6to5/6to5.svg?style=flat">
</a>
<a href="https://david-dm.org/6to5/6to5">
<img alt="Dependency Status" src="http://img.shields.io/david/6to5/6to5.svg?style=flat">
</a>
</p>
<p align="center">
<strong>6to5</strong> turns ES6+ code into vanilla ES5, so you can use next generation features <strong>today.</strong>
</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}"

7
bin/6to5-minify Executable file
View File

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

View File

@@ -5,7 +5,7 @@
* when found, before invoking the "real" _6to5-node(1) executable.
*/
var args = ["--harmony", __dirname + "/_6to5-node"];
var args = [__dirname + "/_6to5-node"];
process.argv.slice(2).forEach(function(arg){
var flag = arg.split("=")[0];
@@ -35,6 +35,7 @@ process.argv.slice(2).forEach(function(arg){
case "--prof":
case "--throw-deprecation":
case "--trace-deprecation":
case "--use-strict":
args.unshift(arg);
break;

View File

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

View File

@@ -11,6 +11,9 @@ module.exports = function (commander, filenames, opts) {
}
var write = function (src, relative) {
// remove extension and then append back on .js
relative = relative.replace(/\.(\w*?)$/, "") + ".js";
var dest = path.join(commander.outDir, relative);
var data = util.compile(src, { sourceMapName: dest });
@@ -34,8 +37,13 @@ module.exports = function (commander, filenames, opts) {
if (stat.isDirectory(filename)) {
var dirname = filename;
_.each(util.readdirFilter(dirname), function (filename) {
write(path.join(dirname, filename), filename);
_.each(util.readdir(dirname), function (filename) {
var src = path.join(dirname, filename);
if (util.canCompile(filename)) {
write(src, filename);
} else {
outputFileSync(path.join(commander.outDir, filename), fs.readFileSync(src));
}
});
} else {
write(filename, filename);
@@ -51,12 +59,9 @@ module.exports = function (commander, filenames, opts) {
ignoreInitial: true
});
_.each(["add", "change", "unlink"], function (type) {
_.each(["add", "change"], function (type) {
watcher.on(type, function (filename) {
// chop off the dirname plus the path separator
var relative = filename.slice(dirname.length + 1);
console.log(type, filename);
var relative = path.relative(dirname, filename) || filename;
write(filename, relative);
});
});

View File

@@ -77,7 +77,7 @@ module.exports = function (commander, filenames) {
if (chunk !== null) code += chunk;
});
process.stdin.on("end", function() {
process.stdin.on("end", function () {
results.push(util.transform(commander.filename, code));
output();
});
@@ -117,7 +117,7 @@ module.exports = function (commander, filenames) {
persistent: true,
ignoreInitial: true
}).on("all", function (type, filename) {
if (type === "add" || type === "change" || type === "unlink" ) {
if (type === "add" || type === "change") {
console.log(type, filename);
walk();
}

View File

@@ -1,10 +1,11 @@
#!/usr/bin/env node
var commander = require("commander");
var transform = require("../../lib/6to5/transformation/transform");
var transform = require("../../lib/6to5/transformation");
var util = require("../../lib/6to5/util");
var fs = require("fs");
var _ = require("lodash");
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");
@@ -18,23 +19,20 @@ commander.option("-m, --modules [modules]", "Module formatter type to use [commo
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("--loose [list]", "List of transformers to enable their loose mode", 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("-I, --indent [width]", "Indent width [2]", 2);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-M, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
commander.option("-E, --include-regenerator", "Include the regenerator runtime if necessary", false);
commander.option("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.on("--help", function(){
commander.on("--help", function () {
var outKeys = function (title, obj) {
console.log(" " + title + ":");
console.log();
_.each(_.keys(obj).sort(), function (key) {
each(keys(obj).sort(), function (key) {
if (key[0] === "_") return;
if (obj[key].optional) {
@@ -62,7 +60,7 @@ var errors = [];
var filenames = commander.args;
_.each(filenames, function (filename) {
each(filenames, function (filename) {
if (!fs.existsSync(filename)) {
errors.push(filename + " doesn't exist");
}
@@ -101,12 +99,11 @@ if (errors.length) {
exports.opts = {
keepModuleIdExtensions: commander.keepModuleIdExtensions,
includeRegenerator: commander.includeRegenerator,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
moduleIds: commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
@@ -114,20 +111,20 @@ exports.opts = {
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules,
loose: commander.loose,
format: {
indent: {
style: util.repeat(parseInt(commander.indent))
}
}
loose: commander.loose
};
var fn;
setTimeout(function () {
// this is just a hack to give `6to5-minify` and other files including this
// time to modify `exports.opts`
if (commander.outDir) {
fn = require("./dir");
} else {
fn = require("./file");
}
var fn;
fn(commander, filenames, exports.opts);
if (commander.outDir) {
fn = require("./dir");
} else {
fn = require("./file");
}
fn(commander, filenames, exports.opts);
}, 0);

View File

@@ -2,7 +2,7 @@ var readdir = require("fs-readdir-recursive");
var index = require("./index");
var util = require("../../lib/6to5/util");
var path = require("path");
var to5 = require("../../lib/6to5");
var to5 = require("../../lib/6to5/api/node");
var fs = require("fs");
var _ = require("lodash");
@@ -12,6 +12,10 @@ exports.readdirFilter = function (filename) {
});
};
exports.readdir = readdir;
exports.canCompile = util.canCompile;
exports.addSourceMappingUrl = function (code, loc) {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
};

View File

@@ -1,40 +1,41 @@
#!/usr/bin/env node
var roadrunner = require("roadrunner");
var commander = require("commander");
var Module = require("module");
var path = require("path");
var repl = require("repl");
var to5 = require("../lib/6to5");
var util = require("../lib/6to5/util");
var vm = require("vm");
var _ = require("lodash");
var commander = require("commander");
var Module = require("module");
var path = require("path");
var repl = require("repl");
var to5 = require("../lib/6to5/api/node");
var util = require("../lib/6to5/util");
var vm = require("vm");
var _ = require("lodash");
var program = new commander.Command("6to5-node");
program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print", "Evaluate script and print result");
program.option("-p, --print [code]", "Evaluate script and print result");
program.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js]");
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js,.es,.jsx]");
program.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
program.option("-g, --playground", "Enable playground support");
program.option("-c, --cache", "Cache compiled files and require paths");
program.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
program.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
program.option("-o, --optional [optional]", "List of optional transformers to enable", util.list);
var pkg = require("../package.json");
program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);
if (program.cache) roadrunner.load();
//
to5.register({
experimental: program.experimental,
extensions: program.extensions,
playground: program.playground,
ignore: program.ignore,
cache: program.cache && roadrunner.get("6to5")
blacklist: program.blacklist,
whitelist: program.whitelist,
optional: program.optional,
ignore: program.ignore
});
//
@@ -42,15 +43,20 @@ to5.register({
var _eval = function (code, filename) {
code = to5.transform(code, {
filename: filename,
blacklist: ["useStrict"],
blacklist: ["useStrict"].concat(program.blacklist || []),
whitelist: program.whitelist,
optional: program.optional,
experimental: program.experimental,
playground: program.playground
}).code;
return vm.runInThisContext(code, filename);
};
if (program.eval) {
var result = _eval(program.eval, "eval");
if (program.eval || program.print) {
var code = program.eval;
if (!code || code === true) code = program.print;
var result = _eval(code, "eval");
if (program.print) console.log(result);
} else {
if (program.args.length) {
@@ -58,8 +64,19 @@ if (program.eval) {
var args = process.argv.slice(2);
var i = 0;
var ignoreNext = false;
_.each(args, function (arg, i2) {
if (arg[0] !== "-") {
if (ignoreNext) {
ignoreNext = false;
return;
}
if (arg[0] === "-") {
var parsedArg = program[arg.slice(2)];
if (parsedArg && parsedArg !== true) {
ignoreNext = true;
}
} else {
i = i2;
return false;
}
@@ -79,8 +96,6 @@ if (program.eval) {
}
}
if (program.cache) roadrunner.save();
function replStart() {
repl.start({
prompt: "> ",

View File

@@ -1,8 +1,8 @@
"use strict";
var transform = module.exports = require("./transformation/transform");
var transform = module.exports = require("../transformation");
transform.version = require("../../package").version;
transform.version = require("../../../package").version;
transform.transform = transform;

View File

@@ -1,24 +1,24 @@
"use strict";
var transform = require("./transformation/transform");
var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
var isFunction = require("lodash/lang/isFunction");
var transform = require("../transformation");
var util = require("../util");
var fs = require("fs");
exports.version = require("../../package").version;
exports.version = require("../../../package").version;
exports.types = require("./types");
exports.runtime = require("../build-runtime");
exports.runtime = require("./runtime-generator");
exports.types = require("../types");
exports.register = function (opts) {
var register = require("./register");
var register = require("./register/node");
if (opts != null) register(opts);
return register;
};
exports.polyfill = function () {
require("./polyfill");
require("../polyfill");
};
exports.canCompile = util.canCompile;
@@ -29,7 +29,7 @@ exports._util = util;
exports.transform = transform;
exports.transformFile = function (filename, opts, callback) {
if (_.isFunction(opts)) {
if (isFunction(opts)) {
callback = opts;
opts = {};
}

View File

@@ -4,4 +4,4 @@
module.exports = function () {};
require("./polyfill");
require("../../polyfill");

View File

@@ -0,0 +1,36 @@
"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

@@ -0,0 +1,152 @@
"use strict";
require("../../polyfill");
var sourceMapSupport = require("source-map-support");
var registerCache = require("./cache");
var extend = require("lodash/object/extend");
var each = require("lodash/collection/each");
var util = require("../../util");
var to5 = require("../node");
var fs = require("fs");
sourceMapSupport.install({
retrieveSourceMap: function (source) {
var map = maps && maps[source];
if (map) {
return {
url: null,
map: map
};
} else {
return null;
}
}
});
//
registerCache.load();
var cache = registerCache.get();
//
var transformOpts = {};
var ignoreRegex = /node_modules/;
var onlyRegex;
var exts = {};
var maps = {};
var mtime = function (filename) {
return +fs.statSync(filename).mtime;
};
var compile = function (filename) {
var result;
var cacheKey = filename + ":" + JSON.stringify(transformOpts);
if (cache) {
var cached = cache[cacheKey];
if (cached && cached.mtime === mtime(filename)) {
result = cached;
}
}
if (!result) {
result = to5.transformFileSync(filename, extend({
sourceMap: true,
ast: false
}, transformOpts));
}
if (cache) {
result.mtime = mtime(filename);
cache[cacheKey] = result;
}
maps[filename] = result.map;
return result.code;
};
var shouldIgnore = function (filename) {
return (ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename));
};
var istanbulMonkey = {};
if (process.env.running_under_istanbul) { // jshint ignore:line
// we need to monkey patch fs.readFileSync so we can hook into
// what istanbul gets, it's extremely dirty but it's the only way
var _readFileSync = fs.readFileSync;
fs.readFileSync = function (filename) {
if (istanbulMonkey[filename]) {
delete istanbulMonkey[filename];
var code = compile(filename);
istanbulMonkey[filename] = true;
return code;
} else {
return _readFileSync.apply(this, arguments);
}
};
}
var istanbulLoader = function (m, filename, old) {
istanbulMonkey[filename] = true;
old(m, filename);
};
var normalLoader = function (m, filename) {
m._compile(compile(filename), filename);
};
var registerExtension = function (ext) {
var old = require.extensions[ext];
var loader = normalLoader;
if (process.env.running_under_istanbul) loader = istanbulLoader; // jshint ignore:line
require.extensions[ext] = function (m, filename) {
if (shouldIgnore(filename)) {
old(m, filename);
} else {
loader(m, filename, old);
}
};
};
var hookExtensions = function (_exts) {
each(exts, function (old, ext) {
require.extensions[ext] = old;
});
exts = {};
each(_exts, function (ext) {
exts[ext] = require.extensions[ext];
registerExtension(ext);
});
};
hookExtensions(util.canCompile.EXTENSIONS);
module.exports = function (opts) {
// normalize options
opts = opts || {};
if (opts.only != null) onlyRegex = util.regexify(opts.only);
if (opts.ignore != null) ignoreRegex = util.regexify(opts.ignore);
if (opts.extensions) hookExtensions(util.arrayify(opts.extensions));
if (opts.cache === false) cache = null;
delete opts.extensions;
delete opts.ignore;
delete opts.cache;
delete opts.only;
extend(transformOpts, opts);
};

13
lib/6to5/build-helpers.js Normal file
View File

@@ -0,0 +1,13 @@
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))
));
});
};

25
lib/6to5/build-runtime.js Normal file
View File

@@ -0,0 +1,25 @@
"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

@@ -0,0 +1,29 @@
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

@@ -0,0 +1,84 @@
{
"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

@@ -0,0 +1,54 @@
var t = require("../types");
var includes = require("lodash/collection/includes");
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) && includes(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,348 +0,0 @@
"use strict";
module.exports = File;
var SHEBANG_REGEX = /^\#\!.*/;
var transform = require("./transformation/transform");
var generate = require("./generation/generator");
var Scope = require("./traverse/scope");
var util = require("./util");
var t = require("./types");
var _ = require("lodash");
function File(opts) {
this.dynamicImports = [];
this.dynamicImportIds = {};
this.opts = File.normaliseOptions(opts);
this.transformers = this.getTransformers();
this.uids = {};
this.ast = {};
}
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"
];
File.excludeHelpersFromRuntime = [
"async-to-generator",
"typeof",
"tagged-template-literal-loose"
];
File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {});
_.defaults(opts, {
keepModuleIdExtensions: false,
includeRegenerator: false,
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
loose: [],
code: true,
ast: true
});
// normalise windows path separators to unix
opts.filename = opts.filename.replace(/\\/g, "/");
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);
}
// todo: remove in 3.0.0
_.each({
fastForOf: "forOf",
classesFastSuper: "classes"
}, function (newTransformer, oldTransformer) {
if (_.contains(opts.optional, oldTransformer)) {
_.pull(opts.optional, oldTransformer);
opts.loose.push(newTransformer);
}
});
_.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.runtime === true) {
opts.runtime = "to5Runtime";
}
if (opts.playground) {
opts.experimental = true;
}
transform._ensureTransformerNames("blacklist", opts.blacklist);
transform._ensureTransformerNames("whitelist", opts.whitelist);
transform._ensureTransformerNames("optional", opts.optional);
transform._ensureTransformerNames("loose", opts.loose);
return opts;
};
File.prototype.isLoose = function (key) {
return _.contains(this.opts.loose, key);
};
File.prototype.getTransformers = function () {
var file = this;
var transformers = [];
var secondPassTransformers = [];
_.each(transform.transformers, function (transformer) {
if (transformer.canRun(file)) {
transformers.push(transformer);
if (transformer.secondPass) {
secondPassTransformers.push(transformer);
}
if (transformer.manipulateOptions) {
transformer.manipulateOptions(file.opts, file);
}
}
});
return transformers.concat(secondPassTransformers);
};
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.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.dynamicImports.push(declar);
}
return id;
};
File.prototype.addHelper = function (name) {
if (!_.contains(File.helpers, name)) {
throw new ReferenceError("unknown declaration " + name);
}
var program = this.ast.program;
var declar = program._declarations && program._declarations[name];
if (declar) return declar.id;
var ref;
var runtimeNamespace = this.opts.runtime;
if (runtimeNamespace && !_.contains(File.excludeHelpersFromRuntime, name)) {
name = t.identifier(t.toIdentifier(name));
return t.memberExpression(t.identifier(runtimeNamespace), name);
} else {
ref = util.template(name);
}
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);
return util.parse(this.opts, code, function (tree) {
self.transform(tree);
return self.generate();
});
};
File.prototype.transform = function (ast) {
var self = this;
this.ast = ast;
this.scope = new Scope(ast.program);
this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
var astRun = function (key) {
_.each(self.transformers, function (transformer) {
transformer.astRun(self, key);
});
};
astRun("enter");
_.each(this.transformers, function (transformer) {
transformer.transform(self);
});
astRun("exit");
};
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);
}
return result;
};
File.prototype.generateUid = function (name, scope) {
name = t.toIdentifier(name).replace(/^_+/, "");
scope = scope || this.scope;
var uid;
do {
uid = this._generateUid(name);
} while (scope.has(uid));
return uid;
};
File.prototype.generateUidIdentifier = function (name, scope) {
scope = scope || this.scope;
var id = t.identifier(this.generateUid(name, scope));
scope.add(id);
return id;
};
File.prototype._generateUid = function (name) {
var uids = this.uids;
var i = uids[name] || 1;
var id = name;
if (i > 1) id += i;
uids[name] = i + 1;
return "_" + id;
};

View File

@@ -2,8 +2,10 @@
module.exports = Buffer;
var util = require("../util");
var _ = require("lodash");
var isBoolean = require("lodash/lang/isBoolean");
var includes = require("lodash/collection/includes");
var isNumber = require("lodash/lang/isNumber");
var util = require("../util");
function Buffer(position, format) {
this.position = position;
@@ -17,7 +19,7 @@ Buffer.prototype.get = function () {
};
Buffer.prototype.getIndent = function () {
if (this.format.compact) {
if (this.format.compact || this.format.concise) {
return "";
} else {
return util.repeat(this._indent, this.format.indent.style);
@@ -51,10 +53,12 @@ Buffer.prototype.rightBrace = function () {
Buffer.prototype.keyword = function (name) {
this.push(name);
this.push(" ");
this.space();
};
Buffer.prototype.space = function () {
if (this.format.compact) return;
if (this.buf && !this.isLast([" ", "\n"])) {
this.push(" ");
}
@@ -68,10 +72,14 @@ Buffer.prototype.removeLast = function (cha) {
};
Buffer.prototype.newline = function (i, removeLast) {
if (this.format.compact) return;
if (this.format.compact || this.format.concise) {
this.space();
return;
}
removeLast = removeLast || false;
if (_.isNumber(i)) {
if (isNumber(i)) {
if (this.endsWith("{\n")) i--;
if (this.endsWith(util.repeat(i, "\n"))) return;
@@ -81,7 +89,7 @@ Buffer.prototype.newline = function (i, removeLast) {
return;
}
if (_.isBoolean(i)) {
if (isBoolean(i)) {
removeLast = i;
}
@@ -102,13 +110,13 @@ Buffer.prototype._newline = function (removeLast) {
* If buffer ends with a newline and some spaces after it, trim those spaces.
*/
Buffer.prototype._removeSpacesAfterLastNewline = function () {
var lastNewlineIndex = this.buf.lastIndexOf('\n');
var lastNewlineIndex = this.buf.lastIndexOf("\n");
if (lastNewlineIndex === -1)
return;
var index = this.buf.length - 1;
while (index > lastNewlineIndex) {
if (this.buf[index] !== ' ') {
if (this.buf[index] !== " ") {
break;
}
@@ -151,7 +159,7 @@ Buffer.prototype.isLast = function (cha, trimRight) {
var last = buf[buf.length - 1];
if (Array.isArray(cha)) {
return _.contains(cha, last);
return includes(cha, last);
} else {
return cha === last;
}

View File

@@ -1,8 +1,8 @@
"use strict";
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
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);
@@ -17,7 +17,7 @@ exports.UnaryExpression = function (node, print) {
}
this.push(node.operator);
if (hasSpace) this.space();
if (hasSpace) this.push(" ");
print(node.argument);
};
@@ -33,9 +33,13 @@ exports.UpdateExpression = function (node, print) {
exports.ConditionalExpression = function (node, print) {
print(node.test);
this.push(" ? ");
this.space();
this.push("?");
this.space();
print(node.consequent);
this.push(" : ");
this.space();
this.push(":");
this.space();
print(node.alternate);
};
@@ -44,13 +48,13 @@ exports.NewExpression = function (node, print) {
print(node.callee);
if (node.arguments.length || this.format.parentheses) {
this.push("(");
print.join(node.arguments, { separator: ", " });
print.list(node.arguments);
this.push(")");
}
};
exports.SequenceExpression = function (node, print) {
print.join(node.expressions, { separator: ", " });
print.list(node.expressions);
};
exports.ThisExpression = function () {
@@ -72,9 +76,7 @@ exports.CallExpression = function (node, print) {
separator += " ";
}
print.join(node.arguments, {
separator: separator
});
print.list(node.arguments, { separator: separator });
if (node._prettyCall) {
this.newline();
@@ -87,7 +89,11 @@ exports.CallExpression = function (node, print) {
var buildYieldAwait = function (keyword) {
return function (node, print) {
this.push(keyword);
if (node.delegate) this.push("*");
if (node.delegate || node.all) {
this.push("*");
}
if (node.argument) {
this.space();
print(node.argument);
@@ -111,8 +117,11 @@ 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(" " + node.operator + " ");
this.push(" ");
this.push(node.operator);
this.push(" ");
print(node.right);
};
@@ -127,7 +136,7 @@ exports.MemberExpression = function (node, print) {
}
var computed = node.computed;
if (t.isLiteral(node.property) && _.isNumber(node.property.value)) {
if (t.isLiteral(node.property) && isNumber(node.property.value)) {
computed = true;
}

View File

@@ -1,9 +1,9 @@
"use strict";
var t = require("../../types");
var _ = require("lodash");
var t = require("../../types");
var each = require("lodash/collection/each");
exports.XJSAttribute = function (node, print) {
exports.JSXAttribute = function (node, print) {
print(node.name);
if (node.value) {
this.push("=");
@@ -11,35 +11,35 @@ exports.XJSAttribute = function (node, print) {
}
};
exports.XJSIdentifier = function (node) {
exports.JSXIdentifier = function (node) {
this.push(node.name);
};
exports.XJSNamespacedName = function (node, print) {
exports.JSXNamespacedName = function (node, print) {
print(node.namespace);
this.push(":");
print(node.name);
};
exports.XJSMemberExpression = function (node, print) {
exports.JSXMemberExpression = function (node, print) {
print(node.object);
this.push(".");
print(node.property);
};
exports.XJSSpreadAttribute = function (node, print) {
exports.JSXSpreadAttribute = function (node, print) {
this.push("{...");
print(node.argument);
this.push("}");
};
exports.XJSExpressionContainer = function (node, print) {
exports.JSXExpressionContainer = function (node, print) {
this.push("{");
print(node.expression);
this.push("}");
};
exports.XJSElement = function (node, print) {
exports.JSXElement = function (node, print) {
var self = this;
var open = node.openingElement;
@@ -47,7 +47,7 @@ exports.XJSElement = function (node, print) {
if (open.selfClosing) return;
this.indent();
_.each(node.children, function (child) {
each(node.children, function (child) {
if (t.isLiteral(child)) {
self.push(child.value);
} else {
@@ -59,22 +59,20 @@ exports.XJSElement = function (node, print) {
print(node.closingElement);
};
exports.XJSOpeningElement = function (node, print) {
exports.JSXOpeningElement = function (node, print) {
this.push("<");
print(node.name);
if (node.attributes.length > 0) {
this.space();
this.push(" ");
print.join(node.attributes, { separator: " " });
}
this.push(node.selfClosing ? " />" : ">");
};
exports.XJSClosingElement = function (node, print) {
exports.JSXClosingElement = function (node, print) {
this.push("</");
print(node.name);
this.push(">");
};
exports.XJSEmptyExpression = function () {
};
exports.JSXEmptyExpression = function () {};

View File

@@ -3,30 +3,8 @@
var t = require("../../types");
exports._params = function (node, print) {
var self = this;
this.push("(");
print.join(node.params, {
separator: ", ",
iterator: function (param, i) {
var def = node.defaults && node.defaults[i];
if (def) {
self.push(" = ");
print(def);
}
}
});
if (node.rest) {
if (node.params.length) {
this.push(", ");
}
this.push("...");
print(node.rest);
}
print.list(node.params);
this.push(")");
};
@@ -54,7 +32,7 @@ exports._method = function (node, print) {
}
this._params(value, print);
this.space();
this.push(" ");
print(value.body);
};
@@ -63,8 +41,14 @@ exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
this.space();
if (node.id) print(node.id);
if (node.id) {
this.push(" ");
print(node.id);
} else {
this.space();
}
this._params(node, print);
this.space();
print(node.body);
@@ -73,7 +57,7 @@ exports.FunctionExpression = function (node, print) {
exports.ArrowFunctionExpression = function (node, print) {
if (node.async) this.push("async ");
if (node.params.length === 1 && !node.defaults.length && !node.rest && t.isIdentifier(node.params[0])) {
if (node.params.length === 1 && t.isIdentifier(node.params[0])) {
print(node.params[0]);
} else {
this._params(node, print);

View File

@@ -1,11 +1,11 @@
"use strict";
var t = require("../../types");
var _ = require("lodash");
var t = require("../../types");
var each = require("lodash/collection/each");
exports.ImportSpecifier = function (node, print) {
if (node.id && node.id.name === "default") {
print(node.name);
if (t.isSpecifierDefault(node)) {
print(t.getSpecifierName(node));
} else {
return exports.ExportSpecifier.apply(this, arguments);
}
@@ -66,12 +66,12 @@ exports.ImportDeclaration = function (node, print) {
if (specfiers && specfiers.length) {
var foundImportSpecifier = false;
_.each(node.specifiers, function (spec, i) {
each(node.specifiers, function (spec, i) {
if (+i > 0) {
self.push(", ");
}
var isDefault = spec.id && spec.id.name === "default";
var isDefault = t.isSpecifierDefault(spec);
if (!isDefault && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
foundImportSpecifier = true;

View File

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

View File

@@ -15,13 +15,19 @@ exports.IfStatement = function (node, print) {
this.keyword("if");
this.push("(");
print(node.test);
this.push(") ");
this.push(")");
this.space();
print.indentOnComments(node.consequent);
if (node.alternate) {
if (this.isLast("}")) this.space();
this.keyword("else");
if (this.format.format && !t.isBlockStatement(node.alternate)) {
this.push(" ");
}
print.indentOnComments(node.alternate);
}
};
@@ -34,13 +40,13 @@ exports.ForStatement = function (node, print) {
this.push(";");
if (node.test) {
this.space();
this.push(" ");
print(node.test);
}
this.push(";");
if (node.update) {
this.space();
this.push(" ");
print(node.update);
}
@@ -87,7 +93,7 @@ var buildLabelStatement = function (prefix, key) {
var label = node[key || "label"];
if (label) {
this.space();
this.push(" ");
print(label);
}
@@ -144,7 +150,9 @@ exports.SwitchStatement = function (node, print) {
this.keyword("switch");
this.push("(");
print(node.discriminant);
this.push(") {");
this.push(")");
this.space();
this.push("{");
print.sequence(node.cases, { indent: true });
this.push("}");
};
@@ -169,26 +177,25 @@ exports.DebuggerStatement = function () {
exports.VariableDeclaration = function (node, print, parent) {
this.push(node.kind + " ");
var inits = 0;
var noInits = 0;
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) {
inits++;
} else {
noInits++;
// has an init so let's split it up over multiple lines
hasInits = true;
}
}
}
var sep = ",";
if (inits > noInits) { // more inits than no inits so let's add a newline
if (hasInits) {
sep += "\n" + util.repeat(node.kind.length + 1);
} else {
sep += " ";
}
print.join(node.declarations, { separator: sep });
print.list(node.declarations, { separator: sep });
if (!t.isFor(parent)) {
this.semicolon();
@@ -204,7 +211,9 @@ exports.PrivateDeclaration = function (node, print) {
exports.VariableDeclarator = function (node, print) {
if (node.init) {
print(node.id);
this.push(" = ");
this.space();
this.push("=");
this.space();
print(node.init);
} else {
print(node.id);

View File

@@ -1,6 +1,6 @@
"use strict";
var _ = require("lodash");
var each = require("lodash/collection/each");
exports.TaggedTemplateExpression = function (node, print) {
print(node.tag);
@@ -18,7 +18,7 @@ exports.TemplateLiteral = function (node, print) {
var self = this;
var len = quasis.length;
_.each(quasis, function (quasi, i) {
each(quasis, function (quasi, i) {
print(quasi);
if (i + 1 < len) {

View File

@@ -1,11 +1,12 @@
"use strict";
var _ = require("lodash");
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("...");
@@ -26,7 +27,7 @@ exports.ObjectPattern = function (node, print) {
this.push("{");
this.space();
print.join(props, { separator: ", ", indent: true });
print.list(props, { indent: true });
this.space();
this.push("}");
@@ -48,7 +49,8 @@ exports.Property = function (node, print) {
if (node.shorthand) return;
}
this.push(": ");
this.push(":");
this.space();
print(node.value);
}
};
@@ -61,7 +63,7 @@ exports.ArrayPattern = function (node, print) {
this.push("[");
_.each(elems, function (elem, i) {
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
@@ -70,7 +72,7 @@ exports.ArrayPattern = function (node, print) {
// both (all) of the holes.
self.push(",");
} else {
if (i > 0) self.push(" ");
if (i > 0 && !self.format.compact) self.push(" ");
print(elem);
if (i < len - 1) self.push(",");
}
@@ -92,8 +94,10 @@ exports.Literal = function (node) {
});
this.push(val);
} else if (type === "boolean" || type === "number") {
this.push(JSON.stringify(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) {

View File

@@ -7,21 +7,25 @@ module.exports = function (ast, opts, code) {
module.exports.CodeGenerator = CodeGenerator;
var Whitespace = require("./whitespace");
var SourceMap = require("./source-map");
var Position = require("./position");
var Buffer = require("./buffer");
var util = require("../util");
var n = require("./node");
var t = require("../types");
var _ = require("lodash");
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.normaliseOptions(opts);
this.format = CodeGenerator.normalizeOptions(code, opts);
this.opts = opts;
this.ast = ast;
this.whitespace = new Whitespace(this.tokens, this.comments);
@@ -30,20 +34,27 @@ function CodeGenerator(ast, opts, code) {
this.buffer = new Buffer(this.position, this.format);
}
_.each(Buffer.prototype, function (fn, key) {
each(Buffer.prototype, function (fn, key) {
CodeGenerator.prototype[key] = function () {
return fn.apply(this.buffer, arguments);
};
});
CodeGenerator.normaliseOptions = function (opts) {
return _.merge({
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: style,
base: 0
}
}, opts.format || {});
@@ -64,8 +75,8 @@ CodeGenerator.generators = {
jsx: require("./generators/jsx")
};
_.each(CodeGenerator.generators, function (generator) {
_.extend(CodeGenerator.prototype, generator);
each(CodeGenerator.generators, function (generator) {
extend(CodeGenerator.prototype, generator);
});
CodeGenerator.prototype.generate = function () {
@@ -74,7 +85,7 @@ CodeGenerator.prototype.generate = function () {
this.print(ast);
var comments = [];
_.each(ast.comments, function (comment) {
each(ast.comments, function (comment) {
if (!comment._displayed) comments.push(comment);
});
this._printComments(comments);
@@ -102,6 +113,16 @@ CodeGenerator.prototype.buildPrint = function (parent) {
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);
};
@@ -116,6 +137,15 @@ CodeGenerator.prototype.buildPrint = function (parent) {
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 || {};
@@ -180,6 +210,8 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
} 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) {
@@ -192,7 +224,7 @@ CodeGenerator.prototype.printJoin = function (print, nodes, opts) {
if (opts.indent) self.indent();
_.each(nodes, function (node, i) {
each(nodes, function (node, i) {
print(node, {
statement: opts.statement,
after: function () {
@@ -257,7 +289,7 @@ CodeGenerator.prototype.getComments = function (key, node, parent) {
nodes.push(node.argument);
}
_.each(nodes, function (node) {
each(nodes, function (node) {
comments = comments.concat(self._getComments(key, node));
});
@@ -275,11 +307,11 @@ CodeGenerator.prototype._printComments = function (comments) {
var self = this;
_.each(comments, function (comment) {
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) {
each(self.ast.comments, function (origComment) {
if (origComment.start === comment.start) {
// comment has already been output
if (origComment._displayed) skip = true;

View File

@@ -5,7 +5,8 @@ module.exports = Node;
var whitespace = require("./whitespace");
var parens = require("./parentheses");
var t = require("../../types");
var _ = require("lodash");
var each = require("lodash/collection/each");
var some = require("lodash/collection/some");
var find = function (obj, node, parent) {
if (!obj) return;
@@ -44,7 +45,7 @@ Node.needsWhitespace = function (node, parent, type) {
var lines = find(whitespace[type].nodes, node, parent);
if (lines) return lines;
_.each(find(whitespace[type].list, node, parent), function (expr) {
each(find(whitespace[type].list, node, parent), function (expr) {
lines = Node.needsWhitespace(expr, node, type);
if (lines) return false;
});
@@ -65,7 +66,7 @@ Node.needsParens = function (node, parent) {
if (t.isNewExpression(parent) && parent.callee === node) {
if (t.isCallExpression(node)) return true;
var hasCall = _.some(node, function (val) {
var hasCall = some(node, function (val) {
return t.isCallExpression(val);
});
if (hasCall) return true;
@@ -94,7 +95,7 @@ Node.needsParensNoLineTerminator = function (node, parent) {
return false;
};
_.each(Node, function (fn, key) {
each(Node, function (fn, key) {
Node.prototype[key] = function () {
// Avoid leaking arguments to prevent deoptimization
var args = new Array(arguments.length + 2);

View File

@@ -1,11 +1,11 @@
"use strict";
var t = require("../../types");
var _ = require("lodash");
var t = require("../../types");
var each = require("lodash/collection/each");
var PRECEDENCE = {};
_.each([
each([
["||"],
["&&"],
["|"],
@@ -18,7 +18,7 @@ _.each([
["*", "/", "%"],
["**"]
], function (tier, i) {
_.each(tier, function (op) {
each(tier, function (op) {
PRECEDENCE[op] = i;
});
});
@@ -151,8 +151,10 @@ exports.ConditionalExpression = function (node, parent) {
return true;
}
if (t.isCallExpression(parent) && parent.callee === node) {
return true;
if (t.isCallExpression(parent) || t.isNewExpression(parent)) {
if (parent.callee === node) {
return true;
}
}
if (t.isConditionalExpression(parent) && parent.test === node) {

View File

@@ -1,7 +1,9 @@
"use strict";
var _ = require("lodash");
var t = require("../../types");
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: {
@@ -31,6 +33,10 @@ exports.before = {
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;
@@ -40,7 +46,7 @@ exports.after = {
list: {
VariableDeclaration: function (node) {
return _.map(node.declarations, "init");
return map(node.declarations, "init");
},
ArrayExpression: function (node) {
@@ -53,7 +59,7 @@ exports.after = {
}
};
_.each({
each({
Function: 1,
Class: 1,
For: 1,
@@ -64,12 +70,12 @@ _.each({
CallExpression: { after: 1 },
Literal: { after: 1 }
}, function (amounts, type) {
if (_.isNumber(amounts)) {
if (isNumber(amounts)) {
amounts = { after: amounts, before: amounts };
}
_.each([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
_.each(amounts, function (amount, key) {
each([type].concat(t.FLIPPED_ALIAS_KEYS[type] || []), function (type) {
each(amounts, function (amount, key) {
exports[key].nodes[type] = function () {
return amount;
};

View File

@@ -48,8 +48,6 @@ SourceMap.prototype.mark = function (node, type) {
var original = loc[type];
if (generated.line === original.line && generated.column === original.column) return; // nothing to map
map.addMapping({
source: this.opts.sourceFileName,
generated: generated,

View File

@@ -2,7 +2,7 @@
module.exports = Whitespace;
var _ = require("lodash");
var sortBy = require("lodash/collection/sortBy");
/**
* Returns `i`th number from `base`, continuing from 0 when `max` is reached.
@@ -23,7 +23,7 @@ function getLookupIndex(i, base, max) {
}
function Whitespace(tokens, comments) {
this.tokens = _.sortBy(tokens.concat(comments), "start");
this.tokens = sortBy(tokens.concat(comments), "start");
this.used = {};
// Profiling this code shows that while generator passes over it, indexes
@@ -101,7 +101,7 @@ Whitespace.prototype.getNewlinesBetween = function (startToken, endToken) {
var lines = 0;
for (var line = start; line < end; line++) {
if (typeof this.used[line] === 'undefined') {
if (typeof this.used[line] === "undefined") {
this.used[line] = true;
lines++;
}

12
lib/6to5/helpers/clone.js Normal file
View File

@@ -0,0 +1,12 @@
"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

@@ -0,0 +1,79 @@
// 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

@@ -0,0 +1,38 @@
// 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

@@ -0,0 +1,9 @@
var t = require("../types");
module.exports = function (ast, comments, tokens) {
if (ast && ast.type === "Program") {
return t.file(ast, comments || [], tokens || []);
} else {
throw new Error("Not a valid ast?");
}
};

View File

@@ -0,0 +1,5 @@
"use strict";
module.exports = function () {
return Object.create(null);
};

49
lib/6to5/helpers/parse.js Normal file
View File

@@ -0,0 +1,49 @@
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;
}
};

48
lib/6to5/messages.js Normal file
View File

@@ -0,0 +1,48 @@
var util = require("util");
exports.messages = {
tailCallReassignmentDeopt: "Function reference has been reassigned so it's probably be dereferenced so we can't optimise this with confidence",
JSXNamespacedTags: "Namespace tags are not supported. ReactJSX is not XML.",
classesIllegalBareSuper: "Illegal use of bare super",
classesIllegalSuperCall: "Direct super call is illegal in non-constructor, use super.$1() instead",
classesIllegalConstructorKind: "Illegal kind for constructor method",
scopeDuplicateDeclaration: "Duplicate declaration $1",
undeclaredVariable: "Reference to undeclared variable $1",
undeclaredVariableSuggestion: "Reference to undeclared variable $1 - did you mean $2?",
settersInvalidParamLength: "Setters must have only one parameter",
noAssignmentsInForHead: "No assignments allowed in for-in/of head",
expectedMemberExpressionOrIdentifier: "Expected type MemeberExpression or Identifier",
invalidParentForThisNode: "We don't know how to handle this node within the current parent - please open an issue",
readOnly: "$1 is read-only",
modulesIllegalExportName: "Illegal export $1",
unknownForHead: "Unknown node type $1 in ForStatement"
};
exports.get = function (key) {
var msg = exports.messages[key];
if (!msg) throw new ReferenceError("Unknown message `" + key + "`");
var args = [];
for (var i = 1; i < arguments.length; i++) {
args.push(arguments[i]);
}
args = exports.parseArgs(args);
return msg.replace(/\$(\d+)/g, function (str, i) {
return args[--i];
});
};
exports.parseArgs = function (args) {
return args.map(function (val) {
if (val != null && val.inspect) {
return val.inspect();
} else {
try {
return JSON.stringify(val) || val + "";
} catch (e) {
return util.inspect(val);
}
}
});
};

View File

@@ -1,24 +1,29 @@
"use strict";
var t = require("./types");
var _ = require("lodash");
var extend = require("lodash/object/extend");
var t = require("./types");
// estraverse
var estraverse = require("estraverse");
_.extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
// regenerator/recast/ast-types
// 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"));
.bases("Pattern")
.build("left", "right")
.field("left", def("Pattern"))
.field("right", def("Expression"));
// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
def("ImportBatchSpecifier")
@@ -26,6 +31,11 @@ def("ImportBatchSpecifier")
.build("name")
.field("name", def("Identifier"));
def("RestElement")
.bases("Pattern")
.build("argument")
.field("argument", def("expression"));
// Abstract references
def("VirtualPropertyExpression")
.bases("Expression")

View File

@@ -1,4 +1,9 @@
"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/runtime");
require("regenerator-6to5/runtime");

View File

@@ -1,104 +0,0 @@
"use strict";
require("./polyfill");
var sourceMapSupport = require("source-map-support");
var roadrunner = require("roadrunner");
var util = require("./util");
var to5 = require("./index");
var fs = require("fs");
var _ = require("lodash");
sourceMapSupport.install({
retrieveSourceMap: function (source) {
var map = maps && maps[source];
if (map) {
return {
url: null,
map: map
};
} else {
return null;
}
}
});
var transformOpts = {};
var ignoreRegex = /node_modules/;
var onlyRegex;
var whitelist = [];
var cache;
var exts = {};
var maps = {};
var old = require.extensions[".js"];
var mtime = function (filename) {
return +fs.statSync(filename).mtime;
};
var loader = function (m, filename) {
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) {
return old.apply(this, arguments);
}
var result;
if (cache) {
var cached = cache[filename];
if (cached && cached.mtime === mtime(filename)) {
result = cached;
}
}
result = result || to5.transformFileSync(filename, _.extend({
whitelist: whitelist,
sourceMap: true,
ast: false
}, transformOpts));
if (cache) {
result.mtime = mtime(filename);
cache[filename] = result;
}
maps[filename] = result.map;
m._compile(result.code, filename);
};
var hookExtensions = function (_exts) {
_.each(exts, function (old, ext) {
require.extensions[ext] = old;
});
exts = {};
_.each(_exts, function (ext) {
exts[ext] = require.extensions[ext];
require.extensions[ext] = loader;
});
};
hookExtensions(util.canCompile.EXTENSIONS);
module.exports = function (opts) {
// normalise options
opts = opts || {};
if (_.isRegExp(opts)) opts = { ignore: opts };
if (opts.ignoreRegex != null) opts.ignore = opts.ignoreRegex;
if (opts.only != null) onlyRegex = util.regexify(opts.only);
if (opts.ignore != null) ignoreRegex = util.regexify(opts.ignore);
if (opts.extensions) hookExtensions(util.arrayify(opts.extensions));
if (opts.cache) cache = opts.cache;
if (opts.cache === false) cache = null;
if (opts.cache === true) {
roadrunner.load();
roadrunner.setup();
cache = roadrunner.get("6to5");
}
_.extend(transformOpts, opts);
};

View File

@@ -1,35 +0,0 @@
"use strict";
var generator = require("./generation/generator");
var util = require("./util");
var File = require("./file");
var t = require("./types");
var _ = require("lodash");
module.exports = function (namespace) {
namespace = t.identifier(t.toIdentifier(namespace || "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([]))
)
]));
_.each(File.helpers, function (name) {
if (_.contains(File.excludeHelpersFromRuntime, name)) {
return;
}
var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
));
});
return generator(tree).code;
};

View File

@@ -0,0 +1,445 @@
"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 includes = require("lodash/collection/includes");
var clone = require("../helpers/clone");
var parse = require("../helpers/parse");
var Scope = require("../traversal/scope");
var util = require("../util");
var path = require("path");
var each = require("lodash/collection/each");
var t = require("../types");
function File(opts) {
this.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",
"to-consumable-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 = util.normalisePathSeparator(opts.filename);
if (opts.sourceRoot) {
opts.sourceRoot = util.normalisePathSeparator(opts.sourceRoot);
}
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 (includes(opts.loose, "all") || includes(opts.loose, true)) {
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");
}
var ensureEnabled = function (key) {
var namespace = transform.transformerNamespaces[key];
if (namespace === "es7") opts.experimental = true;
if (namespace === "playground") opts.playground = true;
};
each(opts.whitelist, ensureEnabled);
each(opts.optional, ensureEnabled);
return opts;
};
File.prototype.isLoose = function (key) {
return includes(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.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.scope.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 (!includes(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.scope.generateUidIdentifier(name);
this.scope.push({
key: name,
id: uid,
init: ref
});
return uid;
}
};
File.prototype.logDeopt = function () {
// todo, (node, msg)
};
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;
};

View File

@@ -12,7 +12,10 @@ module.exports = function (exports, opts) {
return t.assignmentExpression("=", left, right);
};
exports.ExpressionStatement = function (node, parent, scope, context, file) {
exports.ExpressionStatement = function (node, parent, scope, file) {
// hit the `AssignmentExpression` one below
if (file.isConsequenceExpressionStatement(node)) return;
var expr = node.expression;
if (!isAssignment(expr)) return;
@@ -26,14 +29,12 @@ module.exports = function (exports, opts) {
return nodes;
};
exports.AssignmentExpression = function (node, parent, scope, context, file) {
if (t.isExpressionStatement(parent)) return;
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!isAssignment(node)) return;
var nodes = [];
var exploded = explode(node.left, nodes, file, scope);
nodes.push(opts.build(exploded.uid, node.right));
nodes.push(exploded.ref);
nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
return t.toSequenceExpression(nodes, scope);
};

View File

@@ -8,7 +8,10 @@ module.exports = function (exports, opts) {
return t.assignmentExpression("=", left, right);
};
exports.ExpressionStatement = function (node, parent, scope, context, file) {
exports.ExpressionStatement = function (node, parent, scope, file) {
// hit the `AssignmentExpression` one below
if (file.isConsequenceExpressionStatement(node)) return;
var expr = node.expression;
if (!opts.is(expr, file)) return;
@@ -24,8 +27,7 @@ module.exports = function (exports, opts) {
return nodes;
};
exports.AssignmentExpression = function (node, parent, scope, context, file) {
if (t.isExpressionStatement(parent)) return;
exports.AssignmentExpression = function (node, parent, scope, file) {
if (!opts.is(node, file)) return;
var nodes = [];

View File

@@ -0,0 +1,284 @@
"use strict";
// Based upon the excellent jsx-transpiler by Ingvar Stepanyan (RReverser)
// https://github.com/RReverser/jsx-transpiler
// jsx
var isString = require("lodash/lang/isString");
var messages = require("../../messages");
var esutils = require("esutils");
var react = require("./react");
var t = require("../../types");
module.exports = function (exports, opts) {
exports.check = function (node) {
if (t.isJSX(node)) return true;
if (react.isCreateClass(node)) return true;
return false;
};
exports.JSXIdentifier = function (node, parent) {
if (node.name === "this" && t.isReferenced(node, parent)) {
return t.thisExpression();
} else if (esutils.keyword.isIdentifierName(node.name)) {
node.type = "Identifier";
} else {
return t.literal(node.name);
}
};
exports.JSXNamespacedName = function (node, parent, scope, file) {
throw file.errorWithNode(node, messages.get("JSXNamespacedTags"));
};
exports.JSXMemberExpression = {
exit: function (node) {
node.computed = t.isLiteral(node.property);
node.type = "MemberExpression";
}
};
exports.JSXExpressionContainer = function (node) {
return node.expression;
};
exports.JSXAttribute = {
exit: function (node) {
var value = node.value || t.literal(true);
if (t.isLiteral(value) && isString(value.value)) {
value.value = value.value.replace(/\n\s+/g, " ");
}
return t.inherits(t.property("init", node.name, value), node);
}
};
exports.JSXOpeningElement = {
exit: function (node, parent, scope, file) {
var tagExpr = node.name;
var args = [];
var tagName;
if (t.isIdentifier(tagExpr)) {
tagName = tagExpr.name;
} else if (t.isLiteral(tagExpr)) {
tagName = tagExpr.value;
}
var state = {
tagExpr: tagExpr,
tagName: tagName,
args: args
};
if (opts.pre) {
opts.pre(state);
}
var attribs = node.attributes;
if (attribs.length) {
attribs = buildJSXOpeningElementAttributes(attribs, file);
} else {
attribs = t.literal(null);
}
args.push(attribs);
if (opts.post) {
opts.post(state);
}
return state.call || t.callExpression(state.callee, args);
}
};
/**
* The logic for this is quite terse. It's because we need to
* support spread elements. We loop over all attributes,
* breaking on spreads, we then push a new object containg
* all prior attributes to an array for later processing.
*/
var buildJSXOpeningElementAttributes = function (attribs, file) {
var _props = [];
var objs = [];
var pushProps = function () {
if (!_props.length) return;
objs.push(t.objectExpression(_props));
_props = [];
};
while (attribs.length) {
var prop = attribs.shift();
if (t.isJSXSpreadAttribute(prop)) {
pushProps();
objs.push(prop.argument);
} else {
_props.push(prop);
}
}
pushProps();
if (objs.length === 1) {
// only one object
attribs = objs[0];
} else {
// looks like we have multiple objects
if (!t.isObjectExpression(objs[0])) {
objs.unshift(t.objectExpression([]));
}
// spread it
attribs = t.callExpression(
file.addHelper("extends"),
objs
);
}
return attribs;
};
exports.JSXElement = {
exit: function (node) {
var callExpr = node.openingElement;
for (var i = 0; i < node.children.length; i++) {
var child = node.children[i];
if (t.isLiteral(child) && typeof child.value === "string") {
cleanJSXElementLiteralChild(child, callExpr.arguments);
continue;
} else if (t.isJSXEmptyExpression(child)) {
continue;
}
callExpr.arguments.push(child);
}
callExpr.arguments = flatten(callExpr.arguments);
if (callExpr.arguments.length >= 3) {
callExpr._prettyCall = true;
}
return t.inherits(callExpr, node);
}
};
var isStringLiteral = function (node) {
return t.isLiteral(node) && isString(node.value);
};
var flatten = function (args) {
var flattened = [];
var last;
for (var i = 0; i < args.length; i++) {
var arg = args[i];
if (isStringLiteral(arg) && isStringLiteral(last)) {
last.value += arg.value;
} else {
last = arg;
flattened.push(arg);
}
}
return flattened;
};
var cleanJSXElementLiteralChild = function (child, args) {
var lines = child.value.split(/\r\n|\n|\r/);
var lastNonEmptyLine = 0;
var i;
for (i = 0; i < lines.length; i++) {
if (lines[i].match(/[^ \t]/)) {
lastNonEmptyLine = i;
}
}
for (i = 0; i < lines.length; i++) {
var line = lines[i];
var isFirstLine = i === 0;
var isLastLine = i === lines.length - 1;
var isLastNonEmptyLine = i === lastNonEmptyLine;
// replace rendered whitespace tabs with spaces
var trimmedLine = line.replace(/\t/g, " ");
// trim whitespace touching a newline
if (!isFirstLine) {
trimmedLine = trimmedLine.replace(/^[ ]+/, "");
}
// trim whitespace touching an endline
if (!isLastLine) {
trimmedLine = trimmedLine.replace(/[ ]+$/, "");
}
if (trimmedLine) {
if (!isLastNonEmptyLine) {
trimmedLine += " ";
}
args.push(t.literal(trimmedLine));
}
}
};
// display names
var addDisplayName = function (id, call) {
var props = call.arguments[0].properties;
var safe = true;
for (var i = 0; i < props.length; i++) {
var prop = props[i];
if (t.isIdentifier(prop.key, { name: "displayName" })) {
safe = false;
break;
}
}
if (safe) {
props.unshift(t.property("init", t.identifier("displayName"), t.literal(id)));
}
};
exports.ExportDeclaration = function (node, parent, scope, file) {
if (node.default && react.isCreateClass(node.declaration)) {
addDisplayName(file.opts.basename, node.declaration);
}
};
exports.AssignmentExpression =
exports.Property =
exports.VariableDeclarator = function (node) {
var left, right;
if (t.isAssignmentExpression(node)) {
left = node.left;
right = node.right;
} else if (t.isProperty(node)) {
left = node.key;
right = node.value;
} else if (t.isVariableDeclarator(node)) {
left = node.id;
right = node.init;
}
if (t.isMemberExpression(left)) {
left = left.property;
}
if (t.isIdentifier(left) && react.isCreateClass(right)) {
addDisplayName(left.name, right);
}
};
};

View File

@@ -0,0 +1,73 @@
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

@@ -5,14 +5,30 @@ var t = require("../../types");
var getObjRef = function (node, nodes, file, scope) {
var ref;
if (t.isIdentifier(node)) {
ref = node;
if (scope.hasBinding(node.name)) {
// this variable is declared in scope so we can be 100% sure
// that evaluating it multiple times wont trigger a getter
// or something else
return node;
} else {
// could possibly trigger a getter so we need to only evaluate
// it once
ref = node;
}
} else if (t.isMemberExpression(node)) {
ref = node.object;
if (t.isIdentifier(ref) && scope.hasGlobal(ref.name)) {
// the object reference that we need to save is locally declared
// so as per the previous comment we can be 100% sure evaluating
// it multiple times will be safe
return ref;
}
} else {
throw new Error("We can't explode this node type " + node.type);
}
var temp = scope.generateUidBasedOnNode(ref, file);
var temp = scope.generateUidBasedOnNode(ref);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, ref)
]));
@@ -24,7 +40,7 @@ var getPropRef = function (node, nodes, file, scope) {
var key = t.toComputedKey(node, prop);
if (t.isLiteral(key)) return key;
var temp = scope.generateUidBasedOnNode(prop, file);
var temp = scope.generateUidBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, prop)
]));

View File

@@ -1,11 +1,10 @@
"use strict";
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
var util = require("../../util");
var t = require("../../types");
var traverser = {
enter: function (node, parent, scope, context, state) {
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;
@@ -14,11 +13,11 @@ var traverser = {
// check that we don't have a local variable declared as that removes the need
// for the wrapper
var localDeclar = scope.get(state.id, true);
var localDeclar = scope.getBindingIdentifier(state.id);
if (localDeclar !== state.outerDeclar) return;
state.selfReference = true;
context.stop();
this.stop();
}
};
@@ -32,19 +31,23 @@ exports.property = function (node, file, scope) {
var state = {
id: id,
selfReference: false,
outerDeclar: scope.get(id, true),
outerDeclar: scope.getBindingIdentifier(id),
};
traverse(node, traverser, scope, state);
scope.traverse(node, visitor, state);
var method = node.value;
if (state.selfReference) {
node.value = util.template("property-method-assignment-wrapper", {
FUNCTION: node.value,
var templateName = "property-method-assignment-wrapper";
if (method.generator) templateName += "-generator";
node.value = util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: key,
FUNCTION_KEY: file.generateUidIdentifier(id, scope),
WRAPPER_KEY: file.generateUidIdentifier(id + "Wrapper", scope)
FUNCTION_KEY: scope.generateUidIdentifier(id),
WRAPPER_KEY: scope.generateUidIdentifier(id + "Wrapper")
});
} else {
node.value.id = key;
method.id = key;
}
};

View File

@@ -0,0 +1,26 @@
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,27 +1,36 @@
"use strict";
var traverse = require("../../traverse");
var t = require("../../types");
var t = require("../../types");
module.exports = function (node, callId) {
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;
traverse(node, {
enter: function (node, parent, scope, context) {
if (t.isFunction(node)) context.skip();
if (t.isAwaitExpression(node)) {
node.type = "YieldExpression";
}
}
});
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("var", [
t.variableDeclarator(node.id, call)
var declar = t.variableDeclaration("let", [
t.variableDeclarator(id, call)
]);
declar._blockHoist = true;
return declar;

View File

@@ -2,28 +2,61 @@
module.exports = ReplaceSupers;
var traverse = require("../../traverse");
var messages = require("../../messages");
var t = require("../../types");
/**
* Description
*
* @param {Object} methodNode
* @param {Object} className
* @param {Object} superName
* @param {Boolean} isLoose
* @param {File} file
* @param {Object} opts
* @param {Boolean} [inClass]
*/
function ReplaceSupers(methodNode, className, superName, isLoose, file) {
this.topLevelThisReference = null;
this.methodNode = methodNode;
this.className = className;
this.superName = superName;
this.isLoose = isLoose;
this.file = file;
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.
*
@@ -32,20 +65,20 @@ function ReplaceSupers(methodNode, className, superName, isLoose, file) {
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
* @param {Node} property
* @param {boolean} isStatic
* @param {boolean} isComputed
* @param {Boolean} isComputed
* @param {Node} thisExpression
*
* @returns {Node}
*/
ReplaceSupers.prototype.superProperty = function (property, isStatic, isComputed, thisExpression) {
ReplaceSupers.prototype.getSuperProperty = function (property, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("get"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
this.isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
@@ -54,6 +87,70 @@ ReplaceSupers.prototype.superProperty = function (property, isStatic, isComputed
);
};
/**
* 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.scope.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(this.topLevelThisReference, t.thisExpression())
]));
return ref;
}
};
/**
* Description
*
@@ -63,7 +160,8 @@ ReplaceSupers.prototype.superProperty = function (property, isStatic, isComputed
* @returns {Object}
*/
ReplaceSupers.prototype.looseSuperProperty = function (methodNode, id, parent) {
ReplaceSupers.prototype.getLooseSuperProperty = function (id, parent) {
var methodNode = this.methodNode;
var methodName = methodNode.key;
var superName = this.superName || t.identifier("Function");
@@ -95,70 +193,6 @@ ReplaceSupers.prototype.looseSuperProperty = function (methodNode, id, parent) {
}
};
/**
* Description
*/
ReplaceSupers.prototype.replace = function () {
this.traverseLevel(this.methodNode.value, true);
};
/**
* Description
*
* @param {Object} node
* @param {Boolean} topLevel
*/
ReplaceSupers.prototype.traverseLevel = function (node, topLevel) {
var self = this;
traverse(node, {
enter: function (node, parent, scope, context) {
if (t.isFunction(node) && !t.isArrowFunctionExpression(node)) {
// we need to call traverseLevel again so we're context aware
self.traverseLevel(node, false);
return context.skip();
}
if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
// break on object methods
return context.skip();
}
var getThisReference = function () {
if (topLevel) {
// top level so `this` is the instance
return t.thisExpression();
} else {
// not in the top level so we need to create a reference
return self.getThisReference();
}
};
var callback = self.specHandle;
if (self.isLoose) callback = self.looseHandle;
return callback.call(self, getThisReference, node, parent);
}
});
};
/**
* 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
*
@@ -169,13 +203,15 @@ ReplaceSupers.prototype.getThisReference = function () {
ReplaceSupers.prototype.looseHandle = function (getThisReference, node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
return this.looseSuperProperty(this.methodNode, node, parent);
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());
}
@@ -194,39 +230,49 @@ ReplaceSupers.prototype.specHandle = function (getThisReference, node, parent) {
var property;
var computed;
var args;
var thisReference;
if (t.isIdentifier(node, { name: "super" })) {
if (!(t.isMemberExpression(parent) && !parent.computed && parent.property === node)) {
throw this.file.errorWithNode(node, "illegal use of bare super");
}
} else if (t.isCallExpression(node)) {
if (isIllegalBareSuper(node, parent)) {
throw this.file.errorWithNode(node, messages.get("classesIllegalBareSuper"));
}
if (t.isCallExpression(node)) {
var callee = node.callee;
if (t.isIdentifier(callee, { name: "super" })) {
if (isSuper(callee, node)) {
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);
property = methodNode.key;
computed = methodNode.computed;
args = node.arguments;
} else {
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// 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, messages.get("classesIllegalSuperCall", methodName));
}
} 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)) {
if (!t.isIdentifier(node.object, { name: "super" })) return;
} 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;
var thisReference = getThisReference();
var superProperty = this.superProperty(property, methodNode.static, computed, thisReference);
this.hasSuper = true;
thisReference = getThisReference();
var superProperty = this.getSuperProperty(property, computed, thisReference);
if (args) {
if (args.length === 1 && t.isSpreadElement(args[0])) {
// super(...arguments);
@@ -244,3 +290,14 @@ ReplaceSupers.prototype.specHandle = function (getThisReference, node, parent) {
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

@@ -0,0 +1,76 @@
"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.transformerNamespaces = object();
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.transformerNamespaces[key] = namespace;
transform.transformers[key] = new Transformer(key, transformer);
});

View File

@@ -2,84 +2,128 @@
module.exports = DefaultFormatter;
var traverse = require("../../traverse");
var messages = require("../../messages");
var extend = require("lodash/object/extend");
var object = require("../../helpers/object");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function DefaultFormatter(file) {
this.file = file;
this.scope = file.scope;
this.file = file;
this.ids = object();
this.localExports = this.getLocalExports();
this.localImports = this.getLocalImports();
this.hasNonDefaultExports = false;
this.hasLocalExports = false;
this.hasLocalImports = false;
this.localImportOccurences = object();
this.localExports = object();
this.localImports = object();
this.getLocalExports();
this.getLocalImports();
this.remapAssignments();
//this.checkCollisions();
}
var exportsTraverser = {
enter: function (node, parent, scope, context, localExports) {
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) && declar && t.isStatement(declar)) {
_.extend(localExports, t.getIds(declar, true));
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 () {
var localExports = {};
traverse(this.file.ast, exportsTraverser, null, localExports);
return localExports;
this.file.scope.traverse(this.file.ast, exportsVisitor, this);
};
var importsTraverser = {
enter: function (node, parent, scope, context, localImports) {
var importsVisitor = {
enter: function (node, parent, scope, formatter) {
if (t.isImportDeclaration(node)) {
_.extend(localImports, t.getIds(node, true));
formatter.hasLocalImports = true;
extend(formatter.localImports, t.getBindingIdentifiers(node));
formatter.bumpImportOccurences(node);
}
}
};
DefaultFormatter.prototype.getLocalImports = function () {
var localImports = {};
traverse(this.file.ast, importsTraverser, null, localImports);
return localImports;
this.file.scope.traverse(this.file.ast, importsVisitor, this);
};
var collissionsTraverser = {
enter: function (node, parent, scope, context, check) {
if (t.isAssignmentExpression(node)) {
var remapVisitor = {
enter: function (node, parent, scope, formatter) {
if (t.isUpdateExpression(node) && formatter.isLocalReference(node.argument, scope)) {
this.skip();
var left = node.left;
if (t.isMemberExpression(left)) {
while (left.object) left = left.object;
// 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;
}
check(left);
} else if (t.isDeclaration(node)) {
_.each(t.getIds(node, true), check);
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.checkCollisions = function () {
// todo: all check export collissions
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;
var file = this.file;
var isLocalReference = function (node) {
return t.isIdentifier(node) && _.has(localImports, node.name) && localImports[node.name] !== node;
};
var check = function (node) {
if (isLocalReference(node)) {
throw file.errorWithNode(node, "Illegal assignment of module import");
}
};
traverse(file.ast, collissionsTraverser, null, check);
return t.isIdentifier(node) && localImports[node.name] && localImports[node.name] !== node;
};
DefaultFormatter.prototype.remapExportAssignment = function (node) {
@@ -94,51 +138,10 @@ DefaultFormatter.prototype.remapExportAssignment = function (node) {
);
};
DefaultFormatter.prototype.remapAssignments = function () {
DefaultFormatter.prototype.isLocalReference = function (node, scope) {
var localExports = this.localExports;
var self = this;
var isLocalReference = function (node, scope) {
var name = node.name;
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.get(name, true);
};
traverse(this.file.ast, {
enter: function (node, parent, scope, context, isLocalReference) {
if (t.isUpdateExpression(node) && isLocalReference(node.argument, scope)) {
context.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 = self.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) && isLocalReference(node.left, scope)) {
context.skip();
return self.remapExportAssignment(node);
}
}
}, null, isLocalReference);
var name = node.name;
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.getBindingIdentifier(name);
};
DefaultFormatter.prototype.getModuleName = function () {
@@ -162,12 +165,12 @@ DefaultFormatter.prototype.getModuleName = function () {
if (!opts.keepModuleIdExtensions) {
// remove extension
filenameRelative = filenameRelative.replace(/\.(.*?)$/, "");
filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");
}
moduleName += filenameRelative;
// normalise path separators
// normalize path separators
moduleName = moduleName.replace(/\\/g, "/");
return moduleName;
@@ -192,25 +195,40 @@ DefaultFormatter.prototype._hoistExport = function (declar, assign, priority) {
return assign;
};
DefaultFormatter.prototype._exportSpecifier = function (getRef, specifier, node, nodes) {
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
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, messages.get("modulesIllegalExportName", node.name));
}
};
DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
if (node.source) {
var ref = this.getExternalReference(node, nodes);
if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
nodes.push(this._exportsWildcard(getRef(), node));
nodes.push(this.buildExportsWildcard(ref, node));
} else {
var ref;
if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
// importing a default so we need to normalise it
ref = t.callExpression(this.file.addHelper("interop-require"), [getRef()]);
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(getRef(), specifier.id);
ref = t.memberExpression(ref, t.getSpecifierId(specifier));
}
// export { foo } from "test";
nodes.push(this._exportsAssign(
nodes.push(this.buildExportsAssignment(
t.getSpecifierName(specifier),
ref,
node
@@ -218,18 +236,19 @@ DefaultFormatter.prototype._exportSpecifier = function (getRef, specifier, node,
}
} else {
// export { foo };
nodes.push(this._exportsAssign(t.getSpecifierName(specifier), specifier.id, node));
nodes.push(this.buildExportsAssignment(t.getSpecifierName(specifier), specifier.id, node));
}
};
DefaultFormatter.prototype._exportsWildcard = function (objectIdentifier) {
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._exportsAssign = function (id, init) {
DefaultFormatter.prototype.buildExportsAssignment = function (id, init) {
this.checkExportIdentifier(id);
return util.template("exports-assign", {
VALUE: init,
KEY: id
@@ -251,7 +270,7 @@ DefaultFormatter.prototype.exportDeclaration = function (node, nodes) {
for (var i = 0; i < declar.declarations.length; i++) {
var decl = declar.declarations[i];
decl.init = this._exportsAssign(decl.id, decl.init, node).expression;
decl.init = this.buildExportsAssignment(decl.id, decl.init, node).expression;
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === 0) t.inherits(newDeclar, declar);
@@ -265,7 +284,7 @@ DefaultFormatter.prototype.exportDeclaration = function (node, nodes) {
nodes.push(declar);
}
assign = this._exportsAssign(id, ref, node);
assign = this.buildExportsAssignment(id, ref, node);
nodes.push(assign);

View File

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

View File

@@ -6,15 +6,17 @@ var DefaultFormatter = require("./_default");
var CommonFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
var includes = require("lodash/collection/includes");
var values = require("lodash/object/values");
function AMDFormatter() {
CommonFormatter.apply(this, arguments);
this.ids = {};
}
util.inherits(AMDFormatter, DefaultFormatter);
AMDFormatter.prototype.init = CommonFormatter.prototype.init;
AMDFormatter.prototype.buildDependencyLiterals = function () {
var names = [];
for (var name in this.ids) {
@@ -27,9 +29,8 @@ AMDFormatter.prototype.buildDependencyLiterals = function () {
* Wrap the entire body in a `define` wrapper.
*/
AMDFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
AMDFormatter.prototype.transform = function (program) {
var body = program.body;
// build an array of module names
@@ -40,7 +41,7 @@ AMDFormatter.prototype.transform = function (ast) {
// build up define container
var params = _.values(this.ids);
var params = values(this.ids);
if (this.passModuleArg) params.unshift(t.identifier("module"));
params.unshift(t.identifier("exports"));
@@ -68,33 +69,29 @@ AMDFormatter.prototype.getModuleName = function () {
}
};
AMDFormatter.prototype._push = function (node) {
var id = node.source.value;
var ids = this.ids;
if (ids[id]) {
return ids[id];
} else {
return this.ids[id] = this.file.generateUidIdentifier(id);
}
AMDFormatter.prototype._getExternalReference = function (node) {
return this.scope.generateUidIdentifier(node.source.value);
};
AMDFormatter.prototype.importDeclaration = function (node) {
this._push(node);
this.getExternalReference(node);
};
AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var key = t.getSpecifierName(specifier);
var ref = this._push(node);
var ref = this.getExternalReference(node);
if (t.isImportBatchSpecifier(specifier)) {
if (includes(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.noInteropRequire) {
} 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, specifier.id, false);
ref = t.memberExpression(ref, t.getSpecifierId(specifier), false);
}
nodes.push(t.variableDeclaration("var", [
@@ -103,16 +100,9 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
};
AMDFormatter.prototype.exportDeclaration = function (node) {
if (node.default && !this.noInteropExport) {
if (this.doDefaultExportInterop(node)) {
this.passModuleArg = true;
}
CommonFormatter.prototype.exportDeclaration.apply(this, arguments);
};
AMDFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var self = this;
return this._exportSpecifier(function () {
return self._push(node);
}, specifier, node, nodes);
};

View File

@@ -0,0 +1,13 @@
"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

@@ -3,54 +3,61 @@
module.exports = CommonJSFormatter;
var DefaultFormatter = require("./_default");
var traverse = require("../../traverse");
var includes = require("lodash/collection/includes");
var util = require("../../util");
var t = require("../../types");
function CommonJSFormatter(file) {
function CommonJSFormatter() {
DefaultFormatter.apply(this, arguments);
var hasNonDefaultExports = false;
traverse(file.ast, {
enter: function (node) {
if (t.isExportDeclaration(node) && !node.default) hasNonDefaultExports = true;
}
});
this.hasNonDefaultExports = hasNonDefaultExports;
}
util.inherits(CommonJSFormatter, DefaultFormatter);
CommonJSFormatter.prototype.init = function () {
var file = this.file;
var scope = file.scope;
scope.rename("module");
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
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)) {
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(variableName,
t.callExpression(this.file.addHelper("interop-require"), [util.template("require", {
MODULE_NAME: node.source
})])
)
]));
if (!includes(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.callExpression(this.file.addHelper("interop-require-wildcard"), [
t.callExpression(t.identifier("require"), [node.source])
])
t.memberExpression(ref, t.getSpecifierId(specifier))
)
]));
} else {
// import foo from "foo";
nodes.push(util.template("require-assign-key", {
VARIABLE_NAME: variableName,
MODULE_NAME: node.source,
KEY: specifier.id
}));
}
}
};
@@ -63,45 +70,35 @@ CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
};
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
if (node.default && !this.noInteropRequire && !this.noInteropExport) {
if (this.doDefaultExportInterop(node)) {
var declar = node.declaration;
var assign;
var assign = util.template("exports-default-assign", {
VALUE: this._pushStatement(declar, nodes)
}, true);
// module.exports = VALUE;
var templateName = "exports-default-module";
// exports = module.exports = VALUE;
if (this.hasNonDefaultExports) templateName = "exports-default-module-override";
if (t.isFunctionDeclaration(declar) || !this.hasNonDefaultExports) {
assign = util.template(templateName, {
VALUE: this._pushStatement(declar, nodes)
}, true);
// hoist to the top if this default is a function
nodes.push(this._hoistExport(declar, assign, 3));
return;
} else {
// this export isn't a function so we can't hoist it to the top so we need to set it
// at the very end of the file with something like:
//
// module.exports = _extends(exports["default"], exports)
//
assign = util.template("common-export-default-assign", {
EXTENDS_HELPER: this.file.addHelper("extends")
}, true);
assign._blockHoist = 0;
nodes.push(assign);
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.exportSpecifier = function (specifier, node, nodes) {
this._exportSpecifier(function () {
return t.callExpression(t.identifier("require"), [node.source]);
}, specifier, node, nodes);
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.scope.generateUidIdentifier(source);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(uid, call)
]));
return uid;
} else {
return call;
}
};

View File

@@ -0,0 +1,11 @@
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

@@ -2,29 +2,34 @@
module.exports = SystemFormatter;
var AMDFormatter = require("./amd");
var useStrict = require("../helpers/use-strict");
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
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.noInteropRequire = true;
this.exportIdentifier = file.scope.generateUidIdentifier("export");
this.noInteropRequireExport = true;
this.noInteropRequireImport = true;
AMDFormatter.apply(this, arguments);
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._exportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
SystemFormatter.prototype.buildExportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.scope.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [
@@ -40,7 +45,7 @@ SystemFormatter.prototype._exportsWildcard = function (objectIdentifier, node) {
return this._addImportSource(t.forInStatement(left, right, block), node);
};
SystemFormatter.prototype._exportsAssign = function (id, init, node) {
SystemFormatter.prototype.buildExportsAssignment = function (id, init, node) {
var call = this.buildExportCall(t.literal(id.name), init, true);
return this._addImportSource(call, node);
};
@@ -60,42 +65,101 @@ SystemFormatter.prototype.buildExportCall = function (id, init, isStatement) {
SystemFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
AMDFormatter.prototype.importSpecifier.apply(this, arguments);
this._addImportSource(_.last(nodes), node);
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) {
return t.arrayExpression(_.map(this.ids, function (uid, source) {
var scope = this.file.scope;
return t.arrayExpression(map(this.ids, function (uid, source) {
var state = {
nodes: [],
source: source,
nodes: [],
hoistDeclarators: hoistDeclarators
};
traverse(block, {
enter: function (node, parent, scope, context, state) {
if (node._importSource === 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);
}
context.remove();
}
}
}, null, state);
scope.traverse(block, runnerSettersVisitor, state);
return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
}));
};
SystemFormatter.prototype.transform = function (ast) {
var program = ast.program;
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);
@@ -116,46 +180,7 @@ SystemFormatter.prototype.transform = function (ast) {
var returnStatement = handlerBody.pop();
// hoist up all variable declarations
traverse(block, {
enter: function (node, parent, scope, context, hoistDeclarators) {
if (t.isFunction(node)) {
// nothing inside is accessible
return context.skip();
}
if (t.isVariableDeclaration(node)) {
if (node.kind !== "var" && !t.isProgram(parent)) { // let, const
// can't be accessed
return;
}
var nodes = [];
_.each(node.declarations, function (declar) {
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;
}
}
}, null, hoistDeclarators);
this.file.scope.traverse(block, hoistVariablesVisitor, hoistDeclarators);
if (hoistDeclarators.length) {
var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
@@ -164,16 +189,7 @@ SystemFormatter.prototype.transform = function (ast) {
}
// hoist up function declarations for circular references
traverse(block, {
enter: function (node, parent, scope, context, handlerBody) {
if (t.isFunction(node)) context.skip();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
context.remove();
}
}
}, null, handlerBody);
this.file.scope.traverse(block, hoistFunctionsVisitor, handlerBody);
handlerBody.push(returnStatement);

View File

@@ -5,7 +5,7 @@ module.exports = UMDFormatter;
var AMDFormatter = require("./amd");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
var values = require("lodash/object/values");
function UMDFormatter() {
AMDFormatter.apply(this, arguments);
@@ -13,9 +13,8 @@ function UMDFormatter() {
util.inherits(UMDFormatter, AMDFormatter);
UMDFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
UMDFormatter.prototype.transform = function (program) {
var body = program.body;
// build an array of module names
@@ -26,7 +25,7 @@ UMDFormatter.prototype.transform = function (ast) {
// factory
var ids = _.values(this.ids);
var ids = values(this.ids);
var args = [t.identifier("exports")];
if (this.passModuleArg) args.push(t.identifier("module"));
args = args.concat(ids);

View File

@@ -0,0 +1,3 @@
{
"blacklist": ["useStrict"]
}

View File

@@ -1,3 +0,0 @@
ARRAY.forEach(function (KEY) {
});

View File

@@ -3,35 +3,26 @@
var gen = fn.apply(this, arguments);
return new Promise(function (resolve, reject) {
function step(getNext) {
var next;
var callNext = step.bind(null, "next");
var callThrow = step.bind(null, "throw");
function step(key, arg) {
try {
next = getNext();
} catch(e) {
reject(e);
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (next.done) {
resolve(next.value);
return;
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(callNext, callThrow);
}
Promise.resolve(next.value).then(function (v) {
step(function () {
return gen.next(v);
});
}, function (e) {
step(function () {
return gen["throw"](e);
});
});
}
step(function () {
return gen.next();
});
callNext();
});
}
};
})

View File

@@ -0,0 +1,5 @@
(function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
});

View File

@@ -1,3 +1,3 @@
if (Object.getPrototypeOf(CLASS_NAME) !== null) {
Object.getPrototypeOf(CLASS_NAME).apply(this, arguments);
if (SUPER_NAME != null) {
SUPER_NAME.apply(this, arguments);
}

View File

@@ -1 +0,0 @@
module.exports = EXTENDS_HELPER(exports["default"], exports);

View File

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

View File

@@ -1 +1 @@
var VARIABLE_NAME = ARGUMENTS[ARGUMENT_KEY] === undefined ? DEFAULT_VALUE : ARGUMENTS[ARGUMENT_KEY];
let VARIABLE_NAME = ARGUMENTS[ARGUMENT_KEY] === undefined ? DEFAULT_VALUE : ARGUMENTS[ARGUMENT_KEY];

View File

@@ -1,7 +1,10 @@
(function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;

View File

@@ -1 +0,0 @@
exports = module.exports = VALUE;

View File

@@ -0,0 +1,3 @@
Object.defineProperty(exports, "__esModule", {
value: true
});

View File

@@ -1,8 +1,10 @@
(function (target) {
Object.assign || (function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
target[key] = source[key];
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;

View File

@@ -2,6 +2,7 @@ for (var LOOP_OBJECT = OBJECT,
IS_ARRAY = Array.isArray(LOOP_OBJECT),
INDEX = 0,
LOOP_OBJECT = IS_ARRAY ? LOOP_OBJECT : LOOP_OBJECT[Symbol.iterator]();;) {
var ID;
if (IS_ARRAY) {
if (INDEX >= LOOP_OBJECT.length) break;
ID = LOOP_OBJECT[INDEX++];

View File

@@ -1,3 +1,3 @@
(function (obj) {
return obj && obj.constructor === Object ? obj : { default: obj };
return obj && obj.__esModule ? obj : { default: obj };
})

View File

@@ -1,3 +1,3 @@
(function (obj) {
return obj && (obj["default"] || obj);
return obj && obj.__esModule ? obj.default : obj;
})

View File

@@ -0,0 +1,3 @@
(function (obj) {
if (obj == null) throw new TypeError("Cannot destructure undefined");
});

View File

@@ -0,0 +1,11 @@
(function (FUNCTION_KEY) {
var WRAPPER_KEY = function* FUNCTION_ID() {
return yield* FUNCTION_KEY.apply(this, arguments);
};
WRAPPER_KEY.toString = function () {
return FUNCTION_KEY.toString();
};
return WRAPPER_KEY;
})(FUNCTION)

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