Compare commits

...

1849 Commits

Author SHA1 Message Date
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
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
Sebastian McKenzie
078b09676f v2.13.2 2015-01-19 09:00:15 +11:00
Sebastian McKenzie
b719eaf6ab add missing semicolon 2015-01-19 08:58:11 +11:00
Sebastian McKenzie
b63accca25 remove --mangle sort from uglify since it's causing issues in safari/ios 2015-01-19 08:57:43 +11:00
Sebastian McKenzie
2d41b09c3b add 2.12.3 changelog 2015-01-19 08:57:04 +11:00
Sebastian McKenzie
0b44137d1f exclude coverage folder from npm 2015-01-19 08:56:58 +11:00
Sebastian McKenzie
8d8dd5fa37 add let scoping transformer rename note 2015-01-19 08:54:26 +11:00
Sebastian McKenzie
16b7ff972c split up tdz into an optional transformer until it has a better implementation - fixes #527 2015-01-19 08:54:04 +11:00
Sebastian McKenzie
ca41612109 use process.stdin.write instead of console.log to avoid console.log sprintf - fixes #527 2015-01-19 08:53:42 +11:00
Sebastian McKenzie
8fc7af5480 properly reference method body - fixes #530 2015-01-19 08:35:01 +11: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
1c6cb7ce40 Merge pull request #526 from tricknotes/remove-unused
Remove unused local variable
2015-01-18 22:30:24 +11:00
Ryunosuke SATO
24d6c3f488 Remove unused local variable
`hasOptional` is assigned but unused from anywhere.
2015-01-18 20:16:32 +09:00
Sebastian McKenzie
d877a04397 v2.13.1 2015-01-18 21:40:21 +11:00
Sebastian McKenzie
4844882f5e break let scoping transformer if there are no block scoped references 2015-01-18 21:37:37 +11:00
Sebastian McKenzie
a80945cfb4 ignore function declarations in TDZ detection 2015-01-18 21:33:22 +11:00
Sebastian McKenzie
6a884c58a7 add 2.13.1 changelog 2015-01-18 21:28:34 +11:00
Sebastian McKenzie
7c4701716c implement block scoping TDZ 2015-01-18 21:26:02 +11:00
Sebastian McKenzie
ecfd5fadc6 v2.13.0 2015-01-18 19:31:07 +11:00
Sebastian McKenzie
c6be5cccd7 update bin/6to5/file to new source-map api 2015-01-18 19:29:18 +11:00
Sebastian McKenzie
dd256dc3f8 add acorn-6to5 changes to 2.13.0 changelog 2015-01-18 19:26:15 +11:00
Sebastian McKenzie
622da331a6 add 2.13.0 changelog 2015-01-18 19:24:54 +11:00
Sebastian McKenzie
5a44793dcb upgrade acorn-6to5 2015-01-18 19:24:49 +11:00
Sebastian McKenzie
9c9a9b0325 make regenerator test future-proof 2015-01-18 18:51:11 +11:00
Sebastian McKenzie
2534f7f2a0 upgrade dependencies 2015-01-18 18:50:58 +11:00
Sebastian McKenzie
36a933a004 add strict mode to every file 2015-01-18 18:44:08 +11:00
Sebastian McKenzie
62c168b13c fix linting errors 2015-01-18 18:41:24 +11:00
Sebastian McKenzie
810c97d7ab actually make destructuring use the provided operator 2015-01-18 18:24:16 +11:00
Sebastian McKenzie
c2b20b18b3 make name method helper export a property method instead of a default 2015-01-18 18:24:05 +11:00
Sebastian McKenzie
309d19960f better traversal context variable names 2015-01-18 18:23:46 +11:00
Sebastian McKenzie
774cb66d9b add isBlockedScoped types helper 2015-01-18 18:23:37 +11:00
Sebastian McKenzie
d360bd5bb7 update misc tests 2015-01-18 18:23:27 +11:00
Sebastian McKenzie
74f5a73d31 update traceur 2015-01-18 18:23:14 +11:00
Sebastian McKenzie
26395a86fa add block scoped functions - fixes #514 2015-01-18 18:23:03 +11:00
Sebastian McKenzie
436c488ee3 revamp let scoping transformer - closes #510 2015-01-18 18:22:37 +11:00
Sebastian McKenzie
93d99077e5 Revert "add loose mode to spread and destructuring"
This reverts commit 95d9f59668.
2015-01-18 12:52:16 +11:00
Sebastian McKenzie
0bb52d6e3d Merge branch 'master' of github.com:6to5/6to5 2015-01-18 12:16:23 +11:00
Sebastian McKenzie
320c78b815 make let scoping collision detection much more reliable 2015-01-18 12:15:50 +11:00
Sebastian McKenzie
ddd59b94b0 upgrade acorn-6to5 2015-01-18 12:15:31 +11:00
Sebastian McKenzie
c210d64557 add loose all option 2015-01-18 12:13:08 +11:00
Sebastian McKenzie
a0f605bbab add way to automatically write expected tests 2015-01-18 12:12:58 +11:00
Sebastian McKenzie
f4b2768194 add todo note to duplicate expression 2015-01-18 12:12:32 +11:00
Sebastian McKenzie
95d9f59668 add loose mode to spread and destructuring 2015-01-18 12:12:12 +11:00
Sebastian McKenzie
c41d799b9b Merge pull request #522 from fabiomcosta/lint_fixes
Fixes lint warnings that are blocking test run
2015-01-18 10:21:12 +11:00
Fabio M. Costa
e7d4642d48 Fixes lint warnings that are blocking test run 2015-01-17 14:19:54 -08:00
Sebastian McKenzie
41949fd58b push uids to scope tracking - fixes #515 2015-01-18 02:36:37 +11:00
Sebastian McKenzie
d0dc972840 fix up formatting in traverse 2015-01-18 02:35:19 +11:00
Sebastian McKenzie
621e66e9ac add private declaration and comprehension expression support to scope tracking and id building 2015-01-18 02:35:08 +11:00
Sebastian McKenzie
529544ce0e use generateUidIdentifier instead of generateUid 2015-01-18 01:16:09 +11:00
Sebastian McKenzie
f298cd3f0f allow single idents in binary assignment operator transformer 2015-01-18 01:15:35 +11:00
Sebastian McKenzie
67029ac8e8 better helpers for assignment operators 2015-01-18 00:37:51 +11:00
Sebastian McKenzie
b54800234f clean up conditional assignment operator transformers 2015-01-17 22:56:49 +11:00
Sebastian McKenzie
ecd85f53b4 Merge pull request #516 from jridgewell/mallot
Playground Proposal: Mallet operator
2015-01-17 21:59:23 +11:00
Sebastian McKenzie
9098852897 abstract out classes super replace 2015-01-17 18:53:49 +11:00
Sebastian McKenzie
3eb4d5b466 fix up styling of #518 2015-01-17 18:53:40 +11:00
Sebastian McKenzie
ddb1c718f1 Merge pull request #518 from gaearon/perf-v8
RFC: V8-specific performance impovements
2015-01-17 18:33:35 +11:00
Sebastian McKenzie
8919873ea1 clean up react/jsx transformer 2015-01-17 18:26:14 +11:00
Sebastian McKenzie
eb9cd95d5a update for head tests 2015-01-17 17:54:04 +11:00
Sebastian McKenzie
4ec701fc44 ignore variable declarations inside loop head in newline generation - fixes #519 2015-01-17 17:44:16 +11:00
Dan Abramov
ff9511d435 Proof of concept of how traversal would look like with state parameter 2015-01-17 05:03:23 +03:00
Justin Ridgewell
ac5a6da1fa Use all falsey values 2015-01-16 19:25:28 -05:00
Justin Ridgewell
616640a128 Playground Proposal: Mallet operator
The mallet operator is similar to the current memoization operator,
except it can be used outside of just objects.

In Ruby, it’s almost the same as `a = a || b`. Note that only `nil` and
`false` are falsey in Ruby. I’ve defined it as `== null`, though that
could be changed to any JS falsey value.
2015-01-16 18:57:15 -05:00
Sebastian McKenzie
1f9ce96e43 fix rest parameter array size error in rest parameter comment 2015-01-17 10:27:01 +11:00
Sebastian McKenzie
dc6a862bec better clarification of rest parameter size construction comment 2015-01-17 10:23:53 +11:00
Dan Abramov
f9480b5280 Avoid closures when traversing 2015-01-17 00:13:39 +03:00
Dan Abramov
8dc4996547 Refactor traversal into smaller methods 2015-01-17 00:13:39 +03:00
Dan Abramov
4f01f67dd6 Avoid delete in favor of null assignment to prevent deoptimizations 2015-01-17 00:13:39 +03:00
Dan Abramov
938026abeb Use toFastProperties to speed up t.* method access 2015-01-17 00:13:38 +03:00
Sebastian McKenzie
76b8945207 v2.12.6 2015-01-16 22:52:12 +11:00
Sebastian McKenzie
e78859fae0 add 2.12.6 changelog 2015-01-16 22:49:31 +11:00
Sebastian McKenzie
d68f1e9910 add flow type generation skeleton 2015-01-16 22:47:55 +11:00
Sebastian McKenzie
20e97f2d9b add flow type visitor keys - none currently as we don't need to traverse over any of them - closes #513 2015-01-16 22:46:09 +11:00
Sebastian McKenzie
750ec7783f v2.12.5 2015-01-16 08:08:52 +11:00
Sebastian McKenzie
14ae438735 remove declarators push in let scoping 2015-01-16 08:06:38 +11:00
Sebastian McKenzie
2f8bdd7e27 add 2.12.5 changelog 2015-01-16 07:59:40 +11:00
Sebastian McKenzie
87da9fcfc5 fix let scoping for loop - closes #509 2015-01-16 07:58:14 +11:00
Sebastian McKenzie
51f6cfddca remove instanbul inclusion 2015-01-16 02:47:20 +11:00
Sebastian McKenzie
b9ad4c2773 v2.12.4 2015-01-16 02:41:23 +11:00
Sebastian McKenzie
228b3dbc34 fix linting errors 2015-01-16 02:38:45 +11:00
Sebastian McKenzie
a01802300f fix default parameters transformer for loops 2015-01-16 02:36:56 +11:00
Sebastian McKenzie
51c6a3fffc fix let scoping body not existing 2015-01-16 02:31:36 +11:00
Sebastian McKenzie
4668e1d67b fix linting errors 2015-01-16 02:29:35 +11:00
Sebastian McKenzie
75e9097e19 add 2.12.4 changelog 2015-01-16 02:29:02 +11:00
Sebastian McKenzie
0627cd94d4 turn array for ins into fors 2015-01-16 02:25:41 +11:00
Sebastian McKenzie
71879d6e8f Merge branch 'master' of github.com:6to5/6to5 2015-01-16 00:50:55 +11:00
Sebastian McKenzie
d7810cac08 add ambiguous rest parameters comment 2015-01-16 00:50:38 +11:00
Sebastian McKenzie
dc9efd21d3 Merge pull request #507 from leebyron/unused
Rm unused dependencies (pass lint)
2015-01-16 00:47:55 +11:00
Lee Byron
347e490614 Rm unused dependencies (pass lint) 2015-01-15 08:47:03 -05:00
Sebastian McKenzie
e512264be7 Merge pull request #506 from leebyron/rest
Improve performance of rest parameter.
2015-01-16 00:43:56 +11:00
Lee Byron
9624663e60 Improve performance of rest parameter.
Rather than initing an empty array and filling, create an array of the correct size up-front. Minor gain on chromium, but considerably (~5x) faster in spidermonkey/firefox.
2015-01-15 08:41:53 -05:00
Sebastian McKenzie
3cf8a6df01 rename replaceInstanceSuperReferences to replaceSuperReferences in classes transformer and add breaks on method definitions 2015-01-15 23:08:28 +11:00
Sebastian McKenzie
88eacecd72 clarify traceur ignore tests 2015-01-15 23:08:06 +11:00
Sebastian McKenzie
fcd3c9ce65 remove register blacklist tests 2015-01-15 23:07:52 +11:00
Sebastian McKenzie
1733bac3bb move chokidar to top 2015-01-15 23:07:46 +11:00
Sebastian McKenzie
21cd063274 Merge pull request #503 from shinnn/output-file-sync
Use output-file-sync instead of mkdirp
2015-01-15 20:32:48 +11:00
Shinnosuke Watanabe
db5750643a use output-file-sync instead of mkdirp
https://github.com/shinnn/output-file-sync
2015-01-15 18:29:40 +09:00
Sebastian McKenzie
60dae7a88d add build comprehension helper 2015-01-15 20:13:24 +11:00
Sebastian McKenzie
790c924b54 abstract out build comprehension helper 2015-01-15 20:13:16 +11:00
Sebastian McKenzie
50d7a46c7f abstract away remap async to generator helper 2015-01-15 20:09:50 +11:00
Sebastian McKenzie
6f7da38957 abstract out named method helper 2015-01-15 20:07:32 +11:00
Sebastian McKenzie
80764c214a add rest parameter comments 2015-01-15 19:52:53 +11:00
Sebastian McKenzie
55054e45da Revert "Improve performance of rest parameter."
This reverts commit e5463cc2a9.
2015-01-15 19:34:33 +11:00
Sebastian McKenzie
060aa5ba0b fix rest parameter check in types.isReferenced 2015-01-15 19:29:54 +11:00
Sebastian McKenzie
688d619bfe add identifier check to class id inheritance 2015-01-15 19:29:54 +11:00
Sebastian McKenzie
6db7fce543 fix computed member expressions in playground memoization 2015-01-15 19:29:54 +11:00
Sebastian McKenzie
41ff1d4ace upgrade acorn-6to5 2015-01-15 19:29:54 +11:00
Sebastian McKenzie
1c6eeba2e9 Merge pull request #499 from leebyron/rest
Improve performance of rest parameter.
2015-01-15 19:28:32 +11:00
Sebastian McKenzie
488b719fde Merge pull request #494 from gaearon/perf-2
Performance impovements
2015-01-15 19:28:04 +11:00
Sebastian McKenzie
af32080287 Merge pull request #498 from leebyron/patch-1
Update CONTRIBUTING.md
2015-01-15 19:27:07 +11:00
Sebastian McKenzie
4c1cd13536 Merge pull request #501 from shinnn/package-json
Update repository info and homepage URL
2015-01-15 14:36:39 +11:00
Dan Abramov
1002cf7796 Avoid Node allocations by making prototype call statics 2015-01-15 04:18:18 +03:00
Shinnosuke Watanabe
081dd33e73 Update repository info and homepage URL
* link to https://6to5.org
* use user/repo style
2015-01-15 10:07:54 +09:00
Sebastian McKenzie
bd9dc4f15d Merge pull request #500 from shinnn/container-based-build
Use container-based infrastructure on Travis CI
2015-01-15 12:01:33 +11:00
Shinnosuke Watanabe
c7ba566ad6 Use container-based infrastructure on Travis CI
http://docs.travis-ci.com/user/workers/container-based-infrastructure/
2015-01-15 09:55:10 +09:00
Dan Abramov
a1b326a0ab Use object lookup instead of array 2015-01-15 03:51:22 +03:00
Dan Abramov
a452f781b8 Slightly refactor and add explanations for optimized functions 2015-01-15 03:39:24 +03:00
Lee Byron
e5463cc2a9 Improve performance of rest parameter.
Rather than initing an empty array and filling, create an array of the correct size up-front. Minor gain on chromium, but considerably (~5x) faster in spidermonkey/firefox.
2015-01-14 19:08:14 -05:00
Lee Byron
7d732ef503 Update CONTRIBUTING.md 2015-01-14 19:01:53 -05:00
Lee Byron
25cb0c6344 Update CONTRIBUTING.md
Explain git init submodules step when checking out
2015-01-14 18:23:49 -05:00
Sebastian McKenzie
45a52bf478 Merge pull request #496 from swirlycheetah/master
Expand upon the contributing guidelines
2015-01-15 09:41:12 +11:00
Chris Wheatley
a14f971b8a add further commands required for workflow 2015-01-14 22:25:20 +00:00
Chris Wheatley
da65500545 expand upon the contributing guidelines 2015-01-14 22:11:46 +00:00
Dan Abramov
58a91ee9e9 Optimize node type lookup 2015-01-14 23:01:58 +03:00
Dan Abramov
19eaa181a5 Speed up common case where consumer moves only forward 2015-01-14 20:02:40 +03:00
Dan Abramov
c7c90acf3f Store ranges instead of line indexes for performance 2015-01-14 19:14:47 +03:00
Dan Abramov
c6f3a55c03 Refactor buffer for clarity and avoid regex for performance 2015-01-14 19:14:47 +03:00
Sebastian McKenzie
e01b7d288f v2.12.3 2015-01-15 02:29:44 +11:00
Sebastian McKenzie
98c0e185b8 add missing semicolon 2015-01-15 02:27:45 +11:00
Sebastian McKenzie
bf66d78210 add 2.12.3 changelog 2015-01-15 02:27:17 +11:00
Sebastian McKenzie
b60eca0a76 better typeof symbol transformer 2015-01-15 02:24:32 +11:00
Sebastian McKenzie
44f06c0b4c instance and static class method names 2015-01-15 02:24:23 +11:00
Sebastian McKenzie
6c5606b7e8 call transformer methods on traverse context 2015-01-15 02:24:05 +11:00
Sebastian McKenzie
07ddfbeb5d remove pointless prototypeProperties helper call 2015-01-15 01:20:06 +11:00
Sebastian McKenzie
87b890c172 fix parentheses deletion not support multilines - fixes #490 2015-01-15 01:14:49 +11:00
Sebastian McKenzie
245fcfe110 move mutator map checking to after loose test 2015-01-15 01:09:13 +11:00
Sebastian McKenzie
bb19f24923 remove roadrunner from 6to5-node 2015-01-15 01:08:12 +11:00
Sebastian McKenzie
4744719040 v2.12.2 2015-01-14 18:48:29 +11:00
Sebastian McKenzie
a3b814a897 fix default parameters closure scope 2015-01-14 18:46:36 +11:00
Sebastian McKenzie
f5f17f0ccb ignore function params, rest and catch clauses - webpack/webpack#688 2015-01-14 18:39:07 +11:00
Sebastian McKenzie
f6a2acdfb1 v2.12.1 2015-01-14 18:06:51 +11:00
Sebastian McKenzie
e8dba2ad1e add 2.12.1 changelog 2015-01-14 18:05:11 +11:00
Sebastian McKenzie
8ce5c5b608 add jsx to possible extensions 2015-01-14 18:04:14 +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
0dfea1a51b update notes 2015-01-14 14:54:31 +11:00
Sebastian McKenzie
a4e528e2b3 v2.12.0 2015-01-14 10:14:14 +11:00
Sebastian McKenzie
99ca9b7e9a fix linting errors 2015-01-14 10:12:11 +11:00
Sebastian McKenzie
313e932e7c fix linting errors 2015-01-14 10:11:41 +11:00
Sebastian McKenzie
6a57a4e565 fix linting errors 2015-01-14 10:11:07 +11:00
Sebastian McKenzie
fc3a5f25fb add 2.12.0 changelog 2015-01-14 10:09:47 +11:00
Sebastian McKenzie
e258b85420 clean up loose template literals 2015-01-14 08:55:24 +11:00
Sebastian McKenzie
6b836de306 add #480 test 2015-01-14 07:56:45 +11:00
Sebastian McKenzie
fe6f53d471 Merge pull request #480 from monsanto/loose-templates
Add loose transform for tagged template literals
2015-01-14 07:54:19 +11:00
Sebastian McKenzie
3b259c6b1e clean up 6to5 register-browser 2015-01-14 07:31:51 +11:00
Sebastian McKenzie
2005df3fa2 support non-string jsx literals - fixes #479 2015-01-14 07:31:28 +11:00
Christopher Monsanto
4fdcf685d3 add loose transform for tagged template literals 2015-01-13 14:48:31 -05:00
Sebastian McKenzie
afd3af834d add loose option to computed property names 2015-01-14 00:35:45 +11:00
Sebastian McKenzie
8afec8b12a rename fast mode to loose #465 2015-01-14 00:24:34 +11:00
Sebastian McKenzie
f25ed0b5de add minimum of 1 newline after line comments - fixes #442 and fixes #477 2015-01-13 23:27:52 +11:00
Sebastian McKenzie
4898770d60 ignore test262 in istanbul 2015-01-13 23:27:26 +11:00
Sebastian McKenzie
bd2fa77446 fix fast forOf and add tests 2015-01-13 23:18:46 +11:00
Sebastian McKenzie
1c2bafe0e1 use assignment instead of define for fast classes 2015-01-13 23:18:38 +11:00
Sebastian McKenzie
f8915333b0 remove double spaces in version read in makefile 2015-01-13 22:44:26 +11:00
Sebastian McKenzie
f8275adc6f upgrade acorn-6to5 2015-01-13 22:44:06 +11:00
Sebastian McKenzie
2a97a4233d remove invalid jshint options 2015-01-13 22:26:33 +11:00
Sebastian McKenzie
70eae9f6ce remove functions inside of loops 2015-01-13 22:18:58 +11:00
Sebastian McKenzie
f560062d82 remove loopfunc: false from jshint - thanks @dcousens... 2015-01-13 22:02:30 +11:00
Sebastian McKenzie
0f55a66f5b add "fast" option for transformers 2015-01-13 22:02:04 +11:00
Sebastian McKenzie
f14f72b635 add --mangle option to uglify 2015-01-13 22:01:37 +11:00
Sebastian McKenzie
9aa010d987 v2.11.4 2015-01-13 20:15:35 +11:00
Sebastian McKenzie
bd179ace86 add 2.11.4 changelog 2015-01-13 20:08:38 +11:00
Sebastian McKenzie
4df6d6043e make dependency versions static - fixes #475 2015-01-13 20:07:34 +11:00
Sebastian McKenzie
7ed7475c46 v2.11.3 2015-01-13 14:35:14 +11:00
Sebastian McKenzie
b2dc560a2d allow a string to be passed as the optional option 2015-01-13 14:33:18 +11:00
Sebastian McKenzie
010dbe1cce v2.11.2 2015-01-13 11:29:46 +11:00
Sebastian McKenzie
75cd0bab02 add 2.11.2 changelog 2015-01-13 11:26:07 +11:00
Sebastian McKenzie
3283991ed0 flip es6 geneartors include regenerator tests 2015-01-13 10:56:36 +11:00
Sebastian McKenzie
a66ce5b6ce add ignore ast check to es6 generators test because regenerator outputs an invalid ast 2015-01-13 10:44:17 +11:00
Sebastian McKenzie
9620f50f22 fix #474 test 2015-01-13 10:32:39 +11:00
Sebastian McKenzie
cc049ea851 Merge pull request #474 from amasad/master
Handle esprima-like AST catch clause in a TryStatement. Fixes #473
2015-01-13 10:26:47 +11:00
Amjad Masad
e5a04ae117 Add test 2015-01-12 17:56:16 -05:00
Amjad Masad
e07e74f010 Handle esprima-like AST catch clause in a TryStatement. Fixes #473 2015-01-12 17:32:02 -05:00
Sebastian McKenzie
7b04c501eb fix formatting of #472 2015-01-13 08:54:43 +11:00
Sebastian McKenzie
70349dd4b3 Merge pull request #472 from monsanto/no-traceback-on-syntax-err
don't print traceback on syntax error in CLI
2015-01-13 08:52:42 +11:00
Christopher Monsanto
2cedc843a8 don't print traceback on syntax error in CLI 2015-01-12 16:49:28 -05:00
Sebastian McKenzie
cf40fe3430 v2.11.1 2015-01-13 08:21:54 +11:00
Sebastian McKenzie
09ffeed139 add 2.11.1 changelog 2015-01-13 08:19:33 +11:00
Sebastian McKenzie
18f79d6253 Merge pull request #470 from monsanto/fix-dict-aliasing
remove Dict from core aliasable constructors
2015-01-13 08:17:23 +11:00
Christopher Monsanto
6f5270f38f remove Dict from core aliasable constructors 2015-01-12 14:00:43 -05:00
Brian Donovan
aac7aac373 Merge pull request #469 from clavery/master
remove console.log from react transforms
2015-01-12 10:29:29 -08:00
Charles Lavery
9361470dc7 remove console.log from react transforms 2015-01-12 13:19:32 -05:00
Sebastian McKenzie
cf579f4b6e v2.11.0 2015-01-13 01:53:03 +11:00
Sebastian McKenzie
2e497eef98 fix linting errors 2015-01-13 01:51:21 +11:00
Sebastian McKenzie
7867daaa04 add 2.11.0 changelog 2015-01-13 01:50:30 +11:00
Sebastian McKenzie
eabbcd31ad add comments to ambiguous code 2015-01-13 01:50:30 +11:00
Sebastian McKenzie
17d198f3d6 Merge pull request #468 from AluisioASG/core-aliasable
Whitelist constructors aliasable to core-js
2015-01-13 01:46:19 +11:00
Aluísio Augusto Silva Gonçalves
afd5376c8d Whitelist constructors aliasable to core-js
Expand the list of identifiers for which we substitute `_core.<Something>`
for `<Something>`.  Also an alternative fix for #421.
2015-01-12 12:29:37 -02:00
Sebastian McKenzie
02a50c9f7e fix unnecessary default parameter iife - fixes #251 2015-01-13 01:16:00 +11:00
Sebastian McKenzie
df9fa32b82 add optional to keep module id extensions - fixes #420 2015-01-13 01:12:14 +11:00
Sebastian McKenzie
831b420df3 special case single super method call with spread, fixes #227 2015-01-13 01:09:10 +11:00
Sebastian McKenzie
123186003c add support for super instead of closures - fixes #425 2015-01-13 01:00:35 +11:00
Sebastian McKenzie
fbb150cfc1 remove allowImportExportEverywhere 2015-01-13 00:10:12 +11:00
Sebastian McKenzie
ea627ed57c don't use function variable declaration for class constructor 2015-01-13 00:03:52 +11:00
Sebastian McKenzie
157bb48776 add 3.0.0 fast transformer note 2015-01-12 23:27:04 +11:00
Sebastian McKenzie
76a3771943 change ambiguous _inherits parameters 2015-01-12 20:54:37 +11:00
Sebastian McKenzie
54f8889a30 v2.10.1 2015-01-12 20:09:54 +11:00
Sebastian McKenzie
bab159bc08 fix version number in changelog 2015-01-12 20:08:14 +11:00
Sebastian McKenzie
23950963e5 add upgrade core-js note 2015-01-12 20:07:51 +11:00
Sebastian McKenzie
d1daac5550 add global shim due to core-js 0.4.4 2015-01-12 20:07:30 +11:00
Sebastian McKenzie
d93ece5ccf add 2.10.11 changelog 2015-01-12 20:05:19 +11:00
Sebastian McKenzie
c8c667bf16 add back loop ensure block 2015-01-12 20:04:19 +11:00
Sebastian McKenzie
49cdacbcb4 add includeRegenerator option 2015-01-12 20:03:02 +11:00
Sebastian McKenzie
f97bd584f7 upgrade core-js 2015-01-12 19:49:04 +11:00
Sebastian McKenzie
f1328aa82f v2.10.0 2015-01-12 11:52:32 +11:00
Sebastian McKenzie
e298a5d350 remove unused check function 2015-01-12 11:50:45 +11:00
Sebastian McKenzie
89a6ef0b26 add 2.10.0 changelog 2015-01-12 11:50:19 +11:00
Sebastian McKenzie
c7ac9b7815 rename --reactCompat arg to --react-compat 2015-01-12 11:47:04 +11:00
Sebastian McKenzie
55c99b9122 upgrade acorn-6to5 2015-01-12 11:45:21 +11:00
Sebastian McKenzie
545c8c3adb define class methods instead of assigning them - fixes #454 2015-01-12 11:44:23 +11:00
Sebastian McKenzie
d093dc8231 disallow setters without one parameter - fixes #455 2015-01-12 10:25:37 +11:00
Sebastian McKenzie
eaf9d58b8d Merge branch 'master' of github.com:6to5/6to5 2015-01-12 10:19:53 +11:00
Sebastian McKenzie
6131cea5b2 add classesFastSuper optional transformer - fixes #451 2015-01-12 10:19:22 +11:00
Sebastian McKenzie
ca4831febe Merge pull request #453 from amasad/master
Add --reactCompat option to cli
2015-01-12 09:57:21 +11:00
Amjad Masad
9cf8d05a19 Add --reactCompat option to cli 2015-01-11 12:47:17 -05:00
Sebastian McKenzie
2a4f03330b better bin name for 6to5-node 2015-01-11 22:59:36 +11:00
Sebastian McKenzie
83bc614bad add note about splitting up super transforming #411 2015-01-11 22:42:45 +11:00
Sebastian McKenzie
99ccb4111a start adding support for this mapping for supers 2015-01-11 22:15:56 +11:00
Sebastian McKenzie
f6c72e9ae9 add newline to scope 2015-01-11 22:15:56 +11:00
Sebastian McKenzie
a90730d4bf Merge pull request #449 from monsanto/fix-6to5-node-name
fix _6to5-node name in help screen
2015-01-11 18:19:04 +11:00
Christopher Monsanto
29503d2d37 fix _6to5-node name in help screen 2015-01-10 23:04:13 -05:00
Sebastian McKenzie
35451ed408 Merge pull request #447 from fkling/cli
Fix short --whitelist option
2015-01-11 11:21:41 +11:00
Felix Kling
7167aeb65a Fix short --whitelist option
`6to5 -w generators` doesn't work because `-w` is also short for
`--watch`. This changes the short option for `--whitelist` to `-l`.
2015-01-10 11:03:26 -08:00
Sebastian McKenzie
29d0489443 add autoindentation note 2015-01-11 04:55:34 +11:00
Sebastian McKenzie
82aa2686f9 fix writable being set on accessors 2015-01-11 04:55:27 +11:00
Sebastian McKenzie
24616fa08a fix linting errors 2015-01-11 03:35:37 +11:00
Sebastian McKenzie
9f3e1eabfd simplify define properties 2015-01-11 03:21:05 +11:00
Sebastian McKenzie
286d2f84bd add configurable and writable property to defined properties 2015-01-11 02:43:17 +11:00
Sebastian McKenzie
7fc484d82e add ES5 getter/setter split up note - closes #444 2015-01-11 02:30:11 +11:00
Sebastian McKenzie
ad6ab57fe3 only use raw type references in coreAliasing on Symbol - fixes #421 2015-01-11 01:00:04 +11:00
Sebastian McKenzie
348fe045d3 reformat for of transformers and add pattern support 2015-01-11 00:35:41 +11:00
Sebastian McKenzie
980b20316b Merge pull request #441 from monsanto/fast-for-of
Optional for-of transformer that puts arrays in fast path
2015-01-11 00:32:56 +11:00
Sebastian McKenzie
5b52e507ca fix non-identifier class super tests 2015-01-10 22:55:19 +11:00
Sebastian McKenzie
9853c9d78d add empty statement case to toBlock 2015-01-10 22:42:35 +11:00
Sebastian McKenzie
72ec771725 fix unnecessarily shifting super ref 2015-01-10 22:42:20 +11:00
Sebastian McKenzie
75e97d9f7e format scope default declarations better 2015-01-10 22:34:08 +11:00
Sebastian McKenzie
295faf185c remove unnecessary ensureBlock in let scoping transformer #434 2015-01-10 22:33:57 +11:00
Sebastian McKenzie
54b05f33f2 move super reference into closure 2015-01-10 22:26:51 +11:00
Sebastian McKenzie
1985146760 use Array.isArray instead of _.isArray 2015-01-10 22:26:37 +11:00
Sebastian McKenzie
13a52dd300 always use an IIFE for classes - fixes #435 2015-01-10 22:18:30 +11:00
Sebastian McKenzie
9d4bea70e6 Merge pull request #433 from gaearon/perf-traverse-refactor
Refactor traversal to avoid closures for perf
2015-01-10 22:06:08 +11:00
Dan Abramov
421906bcc1 Refactor traversal to avoid closures 2015-01-10 14:02:08 +03:00
Sebastian McKenzie
508b3531e5 Merge pull request #432 from gaearon/perf-stable
Replace _.each and for-in with for loop in hot paths
2015-01-10 21:49:37 +11:00
Sebastian McKenzie
c67c407cd0 v2.9.4 2015-01-10 16:28:02 +11:00
Sebastian McKenzie
aa552fea0d add 2.9.4 changelog 2015-01-10 16:25:39 +11:00
Sebastian McKenzie
9bbf109dc8 support UpdateExpressions as MemberExpression objects - fixes #440 2015-01-10 16:24:17 +11:00
Christopher Monsanto
393d52088a optional for-of transformer that puts arrays in fast path 2015-01-09 20:53:48 -05:00
Dan Abramov
5783973734 A few minor perf improvements 2015-01-09 22:00:07 +03:00
Dan Abramov
55e01afd0d Improve performance on hot paths by using for loops 2015-01-09 16:51:34 +03:00
Dan Abramov
1231dc6cef Replace _.each and for-in with for loop in hot paths 2015-01-09 16:00:53 +03:00
Sebastian McKenzie
b08f2061b5 fix destructuring tests 2015-01-09 21:43:24 +11:00
Sebastian McKenzie
1536d3de91 Revert "add base optional object observe transformer"
This reverts commit b619e843a9.
2015-01-09 21:18:55 +11:00
Sebastian McKenzie
fddacb1612 don't assign array expressions to a temp variable in destructuring #431 2015-01-09 21:18:51 +11:00
Sebastian McKenzie
9d1ff2b71b v2.9.3 2015-01-09 20:10:17 +11:00
Sebastian McKenzie
1c8d24f78c remove exportsWildcard helper in favor of defaults #430 2015-01-09 20:08:05 +11:00
Sebastian McKenzie
b619e843a9 add base optional object observe transformer 2015-01-09 19:57:21 +11:00
Sebastian McKenzie
e6a71c5849 move npm version up 2015-01-09 19:56:22 +11:00
Sebastian McKenzie
682668c219 v2.9.2 2015-01-09 19:51:44 +11:00
Sebastian McKenzie
dd64297838 add 2.9.2 changelog 2015-01-09 19:49:10 +11:00
Sebastian McKenzie
944a9d3908 pass exports to exportsWildcard - fixes #430 2015-01-09 19:48:11 +11:00
Sebastian McKenzie
d6922c9b75 v2.9.1 2015-01-09 19:34:28 +11:00
Sebastian McKenzie
fb0fcc7138 fix runtime generator breaking the helper inclusion loop - fixes #429 2015-01-09 19:31:43 +11:00
Sebastian McKenzie
89148e6029 Merge pull request #424 from 6to5/more-super-issues
Ensure more than one level of superclass works.
2015-01-09 08:35:40 +11:00
Brian Donovan
28d10b8eb4 Ensure more than one level of superclass works. 2015-01-08 13:33:02 -08:00
Sebastian McKenzie
3509990563 enable esnext tests by default 2015-01-09 07:23:17 +11:00
Sebastian McKenzie
c5960fb9f7 Merge pull request #408 from 6to5/fix-esnext-class-tests
[WIP] Fix super with getters and setters and with class prototypes changing.
2015-01-09 07:22:35 +11:00
Brian Donovan
07131576cf Use undefined instead of void 0. 2015-01-08 11:59:01 -08:00
Sebastian McKenzie
e75e778300 v2.9.0 2015-01-09 06:02:43 +11:00
Sebastian McKenzie
f6cb14c975 upgrade acorn-6to5 2015-01-09 06:00:19 +11:00
Brian Donovan
af1912ab7a Ensure constructors use the current super class.
This is an extension of 324a4a1b22.
2015-01-08 09:31:18 -08:00
Brian Donovan
8c478f29bc Use desc.writable instead of "writable" in desc as suggested by @stefanpenner. 2015-01-08 09:21:35 -08:00
Brian Donovan
5b4d6d7ba9 Replace superIdentifier with superProperty.
This also disallows the usage of bare `super` that is not part of a
member expression, call expression, or new expression.
2015-01-08 09:21:32 -08:00
Sebastian McKenzie
1776b072b0 v2.8.2 2015-01-09 00:08:42 +11:00
Sebastian McKenzie
726fad1b6c move publish-core into publish task 2015-01-09 00:06:21 +11:00
Sebastian McKenzie
23c16b0094 fix github url in no templates directory 2015-01-09 00:06:12 +11:00
Sebastian McKenzie
24f70ee4d0 add alternate core package - fixes #387 2015-01-08 23:31:03 +11:00
Sebastian McKenzie
fe9b0afd95 v2.8.1 2015-01-08 23:14:56 +11:00
Sebastian McKenzie
47695a8710 add 2.8.1 changelog 2015-01-08 23:12:36 +11:00
Sebastian McKenzie
e1c7584280 fix computed accessors on objects 2015-01-08 23:11:58 +11:00
Sebastian McKenzie
3e63e6cd4b v2.8.0 2015-01-08 22:49:23 +11:00
Sebastian McKenzie
ba643680e5 add 2.8.0 changelog 2015-01-08 22:46:16 +11:00
Sebastian McKenzie
611137c7d7 add umd strict and amd strict module formatter, also fix bug with wrong amd module constructor - fixes #415 2015-01-08 22:44:51 +11:00
Sebastian McKenzie
6240e5111f add modules common strict formatter - fixes #418 2015-01-08 22:29:24 +11:00
Brian Donovan
324a4a1b22 Fix super with getters and setters and with class prototypes changing. 2015-01-07 21:10:36 -08:00
Sebastian McKenzie
035f667a8f update notes with additional 3.0.0 breaking change and add a reference to the export default issue 2015-01-08 13:09:59 +11:00
Sebastian McKenzie
98985dd253 Merge pull request #416 from monsanto/indent
Add --indent option to change indent width
2015-01-08 12:43:41 +11:00
Christopher Monsanto
0a207903ce Add --indent option to change indent width 2015-01-07 18:27:58 -05:00
Sebastian McKenzie
90437d262b v2.7.4 2015-01-08 01:02:39 +11:00
Sebastian McKenzie
4aba7ec192 fix generation tests and add variable kind length 2015-01-08 01:00:32 +11:00
Sebastian McKenzie
a924c9c218 fix up declarations being split up and use a new algorithm to determine whether or not we should align them 2015-01-08 00:54:01 +11:00
Sebastian McKenzie
a2ed0ea9c5 only align variable declarations if at least one declarator has an init 2015-01-08 00:44:53 +11:00
Sebastian McKenzie
c5cd729c3d add 2.7.4 changelog 2015-01-08 00:40:43 +11:00
Sebastian McKenzie
b065d43a6d add custom level to buffer getIndent 2015-01-08 00:37:46 +11:00
Sebastian McKenzie
281003c7bd properly align multi declarator var declarations - fixes #413 2015-01-08 00:37:32 +11:00
Sebastian McKenzie
6650336c64 inherit assign from declaration in destructuring - fixes #413 2015-01-08 00:37:07 +11:00
Sebastian McKenzie
f904734695 rename prettyPrint to the more descriptive prettyCall 2015-01-08 00:36:40 +11:00
Sebastian McKenzie
0528560d81 v2.7.3 2015-01-07 22:55:09 +11:00
Sebastian McKenzie
4362ba93de fix verison number in changelog 2015-01-07 22:53:02 +11:00
Sebastian McKenzie
ca12e87370 remove unused variables 2015-01-07 22:50:24 +11:00
Sebastian McKenzie
ebaa735adc add 2.7.2 changelog 2015-01-07 22:49:21 +11:00
Sebastian McKenzie
62e406a6fe fix better jsx output 2015-01-07 22:47:37 +11:00
Sebastian McKenzie
0d45a8975c normalise module name paths 2015-01-07 22:43:05 +11:00
Sebastian McKenzie
8f64fe2332 add extends helper instead of using Object.assign 2015-01-07 22:42:26 +11:00
Sebastian McKenzie
a8a7587c1f better jsx output #369 2015-01-07 22:42:03 +11:00
Sebastian McKenzie
7736fa11f2 v2.7.2 2015-01-07 18:38:00 +11:00
Sebastian McKenzie
d203924541 disable module import reassignment tests 2015-01-07 18:35:36 +11:00
Sebastian McKenzie
cd23e500a1 add back specNoForInOfAssignment transformer 2015-01-07 18:30:48 +11:00
Sebastian McKenzie
bf24a0d6b5 temporarily disable module collission detections 2015-01-07 18:30:33 +11:00
Sebastian McKenzie
279d1affea v2.7.1 2015-01-07 14:15:16 +11:00
Sebastian McKenzie
2a1e012240 upgrade core-js 2015-01-07 14:12:21 +11:00
Sebastian McKenzie
a307a961a6 add istanbul to travis test 2015-01-07 14:10:47 +11:00
Sebastian McKenzie
fe5b1dc542 add reactCompat default to file opts 2015-01-07 14:10:37 +11:00
Sebastian McKenzie
f057347ae9 add version to browser and node build 2015-01-07 14:10:27 +11:00
Sebastian McKenzie
98f2287267 v2.7.0 2015-01-07 14:01:44 +11:00
Sebastian McKenzie
e60e0e0b0e disable timeout on test262 tests 2015-01-07 13:58:47 +11:00
Sebastian McKenzie
81fb8647b6 fixing linting errors 2015-01-07 13:58:41 +11:00
Sebastian McKenzie
e8387c7de5 add 2.7.0 changelog 2015-01-07 13:57:04 +11:00
Sebastian McKenzie
655196f3ce Merge pull request #410 from amasad/master
Add support for React pre v0.12 transform
2015-01-07 13:54:23 +11:00
Amjad Masad
eef371c3df Add support for React pre v0.12 transform
This uses an option `reactCompat` to emit code that works with React pre v0.12
2015-01-06 21:49:35 -05:00
Sebastian McKenzie
a3d21f02c6 just call mocha instead of test-simple 2015-01-07 13:44:05 +11:00
Sebastian McKenzie
ad4386c0ed make test-travis use test-simple and remove test-spec task 2015-01-07 13:33:31 +11:00
Sebastian McKenzie
3c82a61af1 better lazy error description test262 2015-01-07 13:33:19 +11:00
Sebastian McKenzie
3c154f9f6d better test262 test aliases 2015-01-07 13:19:53 +11:00
Sebastian McKenzie
22c972e85b add bootstrap to travis test 2015-01-07 13:14:45 +11:00
Sebastian McKenzie
6d7e14fb2b fix test262 loc check 2015-01-07 13:14:08 +11:00
Sebastian McKenzie
9287449372 add test-all make command 2015-01-07 13:11:25 +11:00
Sebastian McKenzie
44a35400f5 better output messages for missing vendors 2015-01-07 13:10:12 +11:00
Sebastian McKenzie
2305e2447f fix hasOwnProperty object lookup conflict 2015-01-07 13:08:20 +11:00
Sebastian McKenzie
c420d1ffc3 add test262 2015-01-07 13:08:06 +11:00
Sebastian McKenzie
fa42b076a7 remove benchmarks 2015-01-07 11:47:09 +11:00
Sebastian McKenzie
0d23c1cfdb add todo for module collisions 2015-01-07 09:56:17 +11:00
Sebastian McKenzie
0dafdd6969 better support for import collision checking - todo: check exports for collisions 2015-01-07 09:08:34 +11:00
Sebastian McKenzie
a9af8d39a2 add member expression reassign test 2015-01-07 08:00:55 +11:00
Sebastian McKenzie
1cc606d4d0 make import reassignment illegal @eventualbuddha 2015-01-07 07:58:04 +11:00
Sebastian McKenzie
2a09c0a5a5 fix import specifier and export specifier keys 2015-01-07 07:57:36 +11:00
Sebastian McKenzie
92359520cd Merge pull request #379 from webpro/amd-port-interop
Port AMD interop
2015-01-07 07:52:44 +11:00
Lars Kappert
50e5bd4680 Merge remote-tracking branch 'origin/master' into amd-port-interop
Conflicts:
	test/fixtures/transformation/es6-modules-amd/exports-default/expected.js
	test/fixtures/transformation/es6-modules-amd/overview/expected.js
	test/fixtures/transformation/es6-modules-umd/exports-default/expected.js
	test/fixtures/transformation/es6-modules-umd/overview/expected.js
2015-01-06 20:21:00 +01:00
Sebastian McKenzie
64ef26a937 v2.6.3 2015-01-07 00:33:13 +11:00
Sebastian McKenzie
bfd6ffe471 add 2.6.3 changelog 2015-01-07 00:31:37 +11:00
Sebastian McKenzie
8c1760bea2 fix faulty export default source detection - fixes #406 2015-01-07 00:30:41 +11:00
Sebastian McKenzie
bdb8f87480 move docs to 6to5.github.io repo 2015-01-06 22:43:36 +11:00
Sebastian McKenzie
7f6bc54920 capitalise faq description 2015-01-06 22:40:03 +11:00
Sebastian McKenzie
b6af2f826d es6-transpiler doesn't do sourcemaps - closes 6to5/6to5.github.io#9 2015-01-06 22:34:17 +11:00
Sebastian McKenzie
7455b6d9b9 update faq copytext 2015-01-06 22:33:23 +11:00
Sebastian McKenzie
0d2e876178 doc/faq: pretty -> quite 2015-01-06 22:29:06 +11:00
Sebastian McKenzie
57ce1b201d better faq answer 2015-01-06 22:27:41 +11:00
Sebastian McKenzie
5f56da457c remove old spec tests 2015-01-06 22:19:34 +11:00
Sebastian McKenzie
ed988dc2bb is t.isValidIdentifier instead of esutils.keyword.isKeywordES6 2015-01-06 22:17:32 +11:00
Sebastian McKenzie
2c471968ea remove specBlockHoistFunctions and specNoForInOfAssignment 2015-01-06 22:17:15 +11:00
Sebastian McKenzie
fd1a91bf9c add transformer docs 2015-01-06 22:16:48 +11:00
Sebastian McKenzie
9e7de5ad2e add faq docs 2015-01-06 22:16:43 +11:00
Sebastian McKenzie
06927288ba remove this shorthand example from playground 2015-01-06 22:15:44 +11:00
Sebastian McKenzie
9342aee6bd fix up documentation links 2015-01-06 22:15:01 +11:00
Sebastian McKenzie
4f5669f53c v2.6.2 2015-01-06 20:16:33 +11:00
Sebastian McKenzie
262fd995da add 2.6.2 changelog 2015-01-06 20:15:58 +11:00
Sebastian McKenzie
1696f77980 fix rest parameter keys when on functions with params 2015-01-06 20:15:10 +11:00
Lars Kappert
dfa51954b8 Use unaryExpression for typeof 2015-01-06 10:12:08 +01:00
Lars Kappert
216b8c2fd1 Revert "Add types.TypeOfExpression"
This reverts commit 520dd7e947.
2015-01-06 10:05:44 +01:00
Sebastian McKenzie
ca2cbb02f1 v2.6.1 2015-01-06 20:04:54 +11:00
Sebastian McKenzie
b72427cdd0 fix rest parameter tests 2015-01-06 20:04:04 +11:00
Sebastian McKenzie
44e9812ad4 fix rest parameter arguments key - closes #405 2015-01-06 20:02:56 +11:00
Sebastian McKenzie
b7814e5e24 add documentation on optional protoToAssign transformer 2015-01-06 19:58:19 +11:00
Sebastian McKenzie
ec67a83326 add 3.0.0 breaking notes 2015-01-06 18:55:03 +11:00
Sebastian McKenzie
6a560cea25 Merge pull request #404 from thejameskyle/docs
Add new documentation
2015-01-06 18:44:14 +11:00
James Kyle
46f9ed7d74 Add new documentation 2015-01-05 23:27:46 -08:00
Sebastian McKenzie
92366dfc7b move incorrect tag in bug fix to internal 2015-01-06 18:08:42 +11:00
Sebastian McKenzie
f520a46175 better ordering of 2.6.0 changelog groups 2015-01-06 18:08:01 +11:00
Sebastian McKenzie
88bec1196b group 2.6.0 changelog 2015-01-06 18:07:10 +11:00
Sebastian McKenzie
ff0098f3f3 add additional 2.6.0 note 2015-01-06 17:54:34 +11:00
Sebastian McKenzie
d01d7722f4 add dynamic imports note to changelog 2015-01-06 17:49:32 +11:00
Sebastian McKenzie
2845c1a894 v2.6.0 2015-01-06 17:44:13 +11:00
Sebastian McKenzie
ed51728aba remove unused variable 2015-01-06 17:43:26 +11:00
Sebastian McKenzie
4c8f4121f0 add 2.6.0 changelog 2015-01-06 17:41:57 +11:00
Sebastian McKenzie
b9e4340700 better use strict handling inside of modules 2015-01-06 17:32:00 +11:00
Sebastian McKenzie
4c9e39afa1 replace slice with a loop in rest parameters 2015-01-06 17:05:52 +11:00
Sebastian McKenzie
7439247095 change spread call expression context from null to undefined 2015-01-06 16:45:39 +11:00
Sebastian McKenzie
254424ced5 add npm install to make bootstrap 2015-01-06 12:17:39 +11:00
Sebastian McKenzie
4fc6823ece no ast check on api tests 2015-01-06 12:17:29 +11:00
Sebastian McKenzie
d531c8aa4c add expressionStatement around system module wildcard exports 2015-01-06 12:17:20 +11:00
Sebastian McKenzie
fc59f1ff46 add closure around let scoping return tests 2015-01-06 12:16:34 +11:00
Sebastian McKenzie
7c7cd6f9b8 use thisExpression instead of identifier("this") 2015-01-06 12:08:53 +11:00
Sebastian McKenzie
e3174d5a39 add esvalid validation to transformation tests 2015-01-06 12:08:40 +11:00
Sebastian McKenzie
2558a5e12e better wildcard imports and exports - fixes #224 2015-01-06 11:48:23 +11:00
Sebastian McKenzie
7526ae5486 fix register require in transformation helper 2015-01-06 10:45:10 +11:00
Sebastian McKenzie
811fcf7e1b upgrade acorn-6to5 2015-01-06 10:44:13 +11:00
Sebastian McKenzie
62818d468e Merge branch 'traceur' 2015-01-06 10:40:42 +11:00
Sebastian McKenzie
a88bd69e30 justify disabled traceur tests 2015-01-06 10:39:56 +11:00
Sebastian McKenzie
8164bb17ce don't use interopRequire if noInteropRequire is set for default module formatter 2015-01-06 10:39:47 +11:00
Sebastian McKenzie
3ec97fc86d only check if a function is a declaration in common module hoisting 2015-01-06 10:39:18 +11:00
Sebastian McKenzie
b38a00d70e add destructuring defaults #230 2015-01-06 10:38:55 +11:00
Sebastian McKenzie
1b85607d7d add ability to assert just an error instead of an error message in tests 2015-01-06 10:38:28 +11:00
Sebastian McKenzie
fd6704ac25 update optional bluebird coroutine test to reflect new addImport 2015-01-06 10:38:11 +11:00
Sebastian McKenzie
9c527f9d9c make regenerator test use the ALL environment var 2015-01-06 10:37:40 +11:00
Sebastian McKenzie
6cf318d60f add updated interop modules to tests 2015-01-06 10:37:11 +11:00
Sebastian McKenzie
64f9f4dff5 only check declarations in let scoping reference check 2015-01-06 10:36:49 +11:00
Lars Kappert
abc90778e8 Test for exportIdentifier before building exportDeclaration 2015-01-05 21:17:12 +01:00
Lars Kappert
56f1683f06 Also test for "module" identifier if needed 2015-01-05 14:57:52 +01:00
Lars Kappert
520dd7e947 Add types.TypeOfExpression 2015-01-05 14:51:50 +01:00
Sebastian McKenzie
145413dbfd Merge pull request #396 from caspervonb/master
Add .es to register extensions
2015-01-05 20:55:36 +11:00
Casper Beyer
8c58e0f14c Add .es extension to util.canCompile 2015-01-05 16:43:00 +08:00
Casper Beyer
d62914e41c Amend require documentation to include '.es' extension 2015-01-05 16:35:01 +08:00
Casper Beyer
85db67edf4 Add .es to register extensions
.es is a known ecmascript file extension and should be handled by the loader
See RFC 4329, 8.2.
2015-01-05 16:10:41 +08:00
Sebastian McKenzie
348ad2e25c better dynamic imports - fixes #393 2015-01-05 12:40:12 +11:00
Sebastian McKenzie
5ce8ee6c2b add inheritance type check to tests 2015-01-05 12:39:46 +11:00
Sebastian McKenzie
98ad5d42e1 add optional typeof symbol test options 2015-01-05 12:39:12 +11:00
Sebastian McKenzie
b12734abd6 only run traceur and esnext on ALL_6TO5_TESTS environment variable 2015-01-05 12:39:01 +11:00
Sebastian McKenzie
f34907d518 add make bootstrap 2015-01-05 12:38:34 +11:00
Sebastian McKenzie
3bd6ec20c1 remove regenerator tests and git submodule regenerator 2015-01-05 12:38:26 +11:00
Sebastian McKenzie
b8d4479333 fix linting error 2015-01-05 10:24:23 +11:00
Sebastian McKenzie
ed833be34a force computed property on number literal property 2015-01-05 10:23:30 +11:00
Sebastian McKenzie
16024242b0 add type check to inherits template 2015-01-05 10:23:06 +11:00
Sebastian McKenzie
77add8704e alias hidden properties onto it's transformer instance 2015-01-05 10:22:27 +11:00
Sebastian McKenzie
9fd1ec0596 more reliable toValidIdentifier checking, including reserved words 2015-01-05 10:22:06 +11:00
Sebastian McKenzie
90ce4e93ed don't break let reference checking on loops in let scoping 2015-01-05 10:21:50 +11:00
Sebastian McKenzie
cf7b9234c1 make typeofSymbol transformer optional 2015-01-05 10:21:32 +11:00
Sebastian McKenzie
f85eeeb93c fix blockHoist and declarations transformers unneccesarily unshifting use strict statements 2015-01-05 10:21:24 +11:00
Sebastian McKenzie
45d0eea842 fix native type constructor spread - closes #373 2015-01-05 10:20:36 +11:00
Sebastian McKenzie
b0c9d3daa4 Merge branch 'master' into traceur 2015-01-05 10:19:41 +11:00
Sebastian McKenzie
3f152bfc3f upgrade core-js from 0.3.3 to 0.40 and regenerator from 0.8.2 to 0.8.3 2015-01-05 10:19:01 +11:00
Sebastian McKenzie
ffbfa5281b move esnext tests into their own fixtures folder 2015-01-05 10:18:42 +11:00
Sebastian McKenzie
7f87ca0d43 move traceur test suite to a git submodule 2015-01-05 10:18:30 +11:00
Sebastian McKenzie
a8fad4b958 add traceur gits ubmodule 2015-01-05 10:17:23 +11:00
Sebastian McKenzie
945ea145e7 remove esnext from differences table 2015-01-05 10:17:09 +11:00
Sebastian McKenzie
4f10bcedda Merge pull request #392 from thejameskyle/changlog-tags
Add tags to top of changelog
2015-01-05 10:15:36 +11:00
James Kyle
601b3d584f Add tags to top of changelog 2015-01-04 14:41:17 -08:00
Sebastian McKenzie
42878f85fe Merge pull request #391 from thejameskyle/extend-null-check
Make parent constructor check explicit when extending from null
2015-01-05 09:14:33 +11:00
James Kyle
3b4c9c415e Make parent constructor check explicit when extending from null - fixes #386 2015-01-04 13:45:13 -08:00
Sebastian McKenzie
7345899343 Merge pull request #389 from caspervonb/master
Make build target the default target
2015-01-05 03:01:32 +11:00
Casper Beyer
316102ab14 Make build target the default target
The top target is implicitly the default target, having this as *clean*
is rather unothodox, usually it would be the executable or library target.
2015-01-04 23:53:28 +08:00
Sebastian McKenzie
4c2b85deec better NewExpression paren insertion 2015-01-05 01:06:41 +11:00
Sebastian McKenzie
108784db20 add typeof and interop-require-wildcard helpers 2015-01-05 01:06:28 +11:00
Sebastian McKenzie
a3b30bae7a better traceur test api 2015-01-05 01:06:16 +11:00
Sebastian McKenzie
6420954c53 remove traceur tests 2015-01-05 01:06:07 +11:00
Sebastian McKenzie
a6fda01fa0 Merge branch 'master' into traceur
Conflicts:
	package.json
2015-01-05 00:53:59 +11:00
Sebastian McKenzie
655cc8fcb9 v2.5.0 2015-01-05 00:17:35 +11:00
Sebastian McKenzie
97a504bbef 2.5.0 changelog 2015-01-05 00:16:39 +11:00
Sebastian McKenzie
bf3443962b disable failing esnext tests 2015-01-05 00:15:46 +11:00
Sebastian McKenzie
a4394494ef remove noDuplicateProperties test 2015-01-05 00:15:37 +11:00
Sebastian McKenzie
2b333de81f add basic support for assignment patterns 2015-01-05 00:07:50 +11:00
Sebastian McKenzie
b81f824b7e normalise wildcard import into a default object 2015-01-05 00:07:22 +11:00
Sebastian McKenzie
9bfb8c440a add optional typeof symbol transformer 2015-01-05 00:06:57 +11:00
Sebastian McKenzie
9a6c13a6a4 Merge branch 'esnext'
Conflicts:
	package.json
2015-01-05 00:03:53 +11:00
Lars Kappert
17ce21509d Move exports identifier from UMD template to commonArgs 2015-01-04 12:59:25 +01:00
Lars Kappert
a4c8895dc3 Conditionally pass "module" arg to AMD/UMD factory 2015-01-04 12:58:52 +01:00
Lars Kappert
af4009694a Simplify AMD export declaration fn to re-use CommonJS one 2015-01-04 12:53:17 +01:00
Lars Kappert
941a8cc5ea Remove unused templates 2015-01-04 12:51:34 +01:00
Lars Kappert
359c4e8786 Use module.exports in expectations 2015-01-04 12:51:19 +01:00
Lars Kappert
7ac98c1532 Add custom export declaration fn for AMD modules 2015-01-04 11:46:28 +01:00
Lars Kappert
61c3e0a3de Modify test expectations 2015-01-04 11:45:09 +01:00
Sebastian McKenzie
ac8d77fb45 upgrade acorn-6to5 2015-01-04 21:14:59 +11:00
Sebastian McKenzie
09c88238e1 upgrade acorn-6to5 2015-01-04 20:37:14 +11:00
Sebastian McKenzie
103b619364 remove arity traceur test check 2015-01-04 20:36:35 +11:00
Sebastian McKenzie
c8a404fb72 Merge branch 'master' into traceur 2015-01-04 20:26:41 +11:00
Sebastian McKenzie
05669204dd fix generation expression comment tests 2015-01-04 20:26:07 +11:00
Sebastian McKenzie
38e6abec02 Merge branch 'master' into traceur 2015-01-04 20:23:37 +11:00
Sebastian McKenzie
1abef2c1e2 more intelligent parens wrapping of no line terminator expressions - fixes #376, reference #349 2015-01-04 20:22:24 +11:00
Sebastian McKenzie
cc6678361a comment out arity check 2015-01-04 20:20:03 +11:00
Sebastian McKenzie
2587694d44 Merge branch 'master' into traceur
Conflicts:
	package.json
2015-01-04 19:52:52 +11:00
Sebastian McKenzie
f16079c83f v2.4.10 2015-01-04 19:51:52 +11:00
Sebastian McKenzie
b7132f3529 upgrade acorn-6to5 2015-01-04 19:50:54 +11:00
Sebastian McKenzie
ed41f1652e v2.4.9 2015-01-04 19:49:54 +11:00
Sebastian McKenzie
c522bdb4b9 upgrade acorn-6to5 2015-01-04 19:48:47 +11:00
Sebastian McKenzie
005362a615 update tests to 2.4.9 fixes 2015-01-04 19:48:14 +11:00
Sebastian McKenzie
88e542634f fix linting errors 2015-01-04 19:45:18 +11:00
Sebastian McKenzie
c8304138eb add 2.4.9 changelog 2015-01-04 19:44:04 +11:00
Sebastian McKenzie
35608d497e make comprehension for-of loop a let 2015-01-04 19:42:25 +11:00
Sebastian McKenzie
b5a78355c4 add initProps to single call expression in computed property names - fixes #378 2015-01-04 19:42:16 +11:00
Sebastian McKenzie
223e28ba8f upgrade acorn-6to5 2015-01-04 19:40:51 +11:00
Sebastian McKenzie
6a35bdb42b add traceur test suite 2015-01-04 19:40:09 +11:00
Sebastian McKenzie
18813f26bb Merge branch 'master' into esnext 2015-01-04 15:32:41 +11:00
Sebastian McKenzie
ccabb91f69 add back deleted object-define-properties-closure template 2015-01-04 15:30:59 +11:00
Sebastian McKenzie
35fda899a8 remove spec-no-duplicate-properties transformer 2015-01-04 15:30:40 +11:00
Sebastian McKenzie
e2f01d41a3 fix api test 2015-01-04 13:42:16 +11:00
Sebastian McKenzie
931a80f5b3 rename "declarations" to the more sane "helpers" 2015-01-04 13:34:56 +11:00
Sebastian McKenzie
9a2fd22e91 add newline to esnext super change proto test 2015-01-04 08:35:28 +11:00
Sebastian McKenzie
cbcad22d81 update default parameters transformer to use var a = arguments[0] === undefined ? 1 : arguments[0]; instead of if (a === undefined) a = 1; 2015-01-04 08:35:14 +11:00
Sebastian McKenzie
4d5861cfdc remove invalid strict-mode es6 next class test 2015-01-04 08:34:25 +11:00
Sebastian McKenzie
c578db7ae8 upgrade acorn-6to5 2015-01-04 08:34:14 +11:00
Sebastian McKenzie
dea73b7186 change code assertion to 6to5 output 2015-01-04 08:01:29 +11:00
Sebastian McKenzie
4506e39cf5 add toString key to instance keys as methods are enumerable 2015-01-04 08:01:08 +11:00
Sebastian McKenzie
7ab6df093b use Symbol.iterator instead of @@iterator 2015-01-04 08:00:49 +11:00
Sebastian McKenzie
22eeae1a93 use assert instead of expect 2015-01-04 08:00:40 +11:00
Sebastian McKenzie
a645ae0583 contextLiteral fallback in es6-spread transformer 2015-01-04 07:59:56 +11:00
Sebastian McKenzie
7f4efecb7d support for CallExpression in Scope.prototype.generateUidBasedOnNode 2015-01-04 07:59:43 +11:00
Sebastian McKenzie
0c0f40d14a only automatically assume test is exec if it has a js extension 2015-01-04 07:58:49 +11:00
Sebastian McKenzie
cb54c11d84 add esnext tests 2015-01-04 07:39:11 +11:00
Sebastian McKenzie
55123be7d7 use t.toComputedKey in computed property name transformer 2015-01-04 07:38:49 +11:00
Sebastian McKenzie
324a0b408a add optional protoToAssign transformer 2015-01-04 07:38:36 +11:00
Sebastian McKenzie
8b2788e930 fix es6-property-method-assignment tests name 2015-01-03 21:48:22 +11:00
Sebastian McKenzie
d945379b5b remove isDynamic checks and always execute those expressions **once** 2015-01-03 21:48:06 +11:00
Sebastian McKenzie
5a622ac9c7 update traversal api in optional-bluebird-coroutines transformer 2015-01-03 20:11:21 +11:00
Sebastian McKenzie
0e9eac610b rename es5-property-methods-assignment to es6-property-method-assignment and add function ids to object methods and remap them if they contain a reference to themselves - fixes #308 2015-01-03 20:11:00 +11:00
Sebastian McKenzie
1de94a2705 fix code styling on es6 arrow functions nested test 2015-01-03 20:09:14 +11:00
Sebastian McKenzie
71132c3538 add types.toComputedPropertyKey helper 2015-01-03 20:08:39 +11:00
Sebastian McKenzie
d20ab0eb05 rename traverse stop method to skip and add a stop method that actually breaks the current traversal 2015-01-03 20:08:31 +11:00
Sebastian McKenzie
51f7e75d2e fix formatting of code of conduct paragraph in CONTRIBUTING.md 2015-01-03 11:17:55 +11:00
Sebastian McKenzie
ab4b5ce994 Merge pull request #309 from antn/add-code-of-conduct
add code of conduct
2015-01-03 11:16:05 +11:00
Sebastian McKenzie
f0d50ca9a2 add browser.js to package.json 2015-01-03 08:19:18 +11:00
Sebastian McKenzie
5168355a64 fix differences copytext grammar 2015-01-03 08:19:11 +11:00
Sebastian McKenzie
2f209a9e4e v2.4.8 2015-01-03 07:37:15 +11:00
Sebastian McKenzie
20695eaba6 add 2.4.8 changelog 2015-01-03 07:36:34 +11:00
Sebastian McKenzie
340a4dd1f2 fix code styling #370 2015-01-03 07:35:45 +11:00
Sebastian McKenzie
ef1c7a5c69 Merge pull request #370 from hughsk/browserify-register
Make require("6to5/register") work with browserify
2015-01-03 07:33:15 +11:00
Hugh Kennedy
5a01beaa1f Make require("6to5/register") work with browserify
Previously, you'd have to create a separate file for using 6to5
with both node and browserify, as the latter wasn't able to properly
handle loading 6to5's dependency tree and would crash on attempting
to do so.

This change instructs browserify to use "register-browser.js" in place
of "register.js". "register-browser.js" still loads the 6to5 polyfill,
but is otherwise ignored.
2015-01-02 21:30:40 +01:00
Sebastian McKenzie
5a5bf7b4ac v2.4.7 2015-01-03 06:10:52 +11:00
Sebastian McKenzie
88ee15bb4d upgrade acorn-6to5 #367 2015-01-03 06:10:10 +11:00
Sebastian McKenzie
3e51b65095 v2.4.6 2015-01-03 05:29:28 +11:00
Sebastian McKenzie
371df9ad09 add 2.4.6 changelog 2015-01-03 05:25:48 +11:00
Sebastian McKenzie
d43d5ff409 move coreAliasing and undefinedToVoid transformers down 2015-01-03 05:24:43 +11:00
Sebastian McKenzie
c2c8e52430 add modules caveat - fixes #368 2015-01-03 05:23:12 +11:00
Sebastian McKenzie
57c0ebc5f4 v2.4.5 2015-01-02 22:22:52 +11:00
Sebastian McKenzie
339bf82481 avoid printing comments if they've already been output - fixes #365 2015-01-02 22:22:01 +11:00
Sebastian McKenzie
d981c06444 v2.4.4 2015-01-02 19:24:56 +11:00
Sebastian McKenzie
8269e1488b fix incorrect scripts reference in browser 2015-01-02 19:23:50 +11:00
Sebastian McKenzie
ddda7a020f add 2.4.4 changelog 2015-01-02 19:22:03 +11:00
Sebastian McKenzie
7e9340864a lowercase object rest/spread feature name in doc/index 2015-01-02 19:20:14 +11:00
Sebastian McKenzie
5ec19f23c3 add test skeleton for types and add jsdoc comments to types 2015-01-02 19:20:05 +11:00
Sebastian McKenzie
ba48b66458 add types.appendToMemberExpression and types.prependToMemberExpression helpers 2015-01-02 16:46:58 +11:00
Sebastian McKenzie
6e8c73f65f fix incorrect member expression properties 2015-01-02 16:39:35 +11:00
Sebastian McKenzie
b34fcb0cd9 split up method binding and add description for memoization assignment operator 2015-01-02 14:33:51 +11:00
Sebastian McKenzie
ff7129f1aa remove ES5 methods from caveats and change IE classes note to IE 10 and below 2015-01-02 14:33:38 +11:00
Sebastian McKenzie
fbabd193a4 add module type to 6to5 browser 2015-01-02 14:33:18 +11:00
Sebastian McKenzie
876d69798c v2.4.3 2015-01-02 05:19:42 +11:00
Sebastian McKenzie
1a963ddc06 remove unused variable 2015-01-02 05:19:00 +11:00
Sebastian McKenzie
beb5acea6b better addImport with good hoisting etc 2015-01-02 05:18:03 +11:00
Sebastian McKenzie
6a290f233e add 2.4.3 changelog 2015-01-02 05:01:18 +11:00
Sebastian McKenzie
74563d88ed upgrade acorn-6to5 2015-01-02 05:00:23 +11:00
Sebastian McKenzie
a18177026c add support for statements in asyncToGenerator and bluebirdCoroutines transformers 2015-01-02 04:58:59 +11:00
Sebastian McKenzie
a813341433 v2.4.2 2015-01-02 04:25:44 +11:00
Sebastian McKenzie
4968de9803 fix linting errors 2015-01-02 04:24:56 +11:00
Sebastian McKenzie
0de2d33e8d add 2.4.2 changelog 2015-01-02 04:24:19 +11:00
Sebastian McKenzie
6f81ddd0d5 upgrade acorn-6to5 2015-01-02 04:24:19 +11:00
Sebastian McKenzie
6b83055b12 alias flat references in coreAliasing transformer 2015-01-02 04:24:19 +11:00
Sebastian McKenzie
080c23d5ed Merge pull request #360 from mquandalle/patch-1
Extend the license to the new year
2015-01-02 04:06:22 +11:00
Sebastian McKenzie
293bec58d7 remove appveyor badge 2015-01-02 03:53:33 +11:00
Sebastian McKenzie
93ceafc732 better uid names 2015-01-02 03:53:28 +11:00
Sebastian McKenzie
b2bac04b72 update object getter memoization docs to reflect new changes 2015-01-02 03:04:26 +11:00
Sebastian McKenzie
e549c37ca1 v2.4.1 2015-01-02 03:00:33 +11:00
Sebastian McKenzie
02512da38d fix generation tests with parenthesized expressions and trailing comments 2015-01-02 02:59:53 +11:00
Sebastian McKenzie
abe9c4fd30 add 2.4.1 changelog 2015-01-02 02:57:16 +11:00
Sebastian McKenzie
af21c52cc6 set generator on correct node #252 2015-01-02 02:55:55 +11:00
Sebastian McKenzie
706626f79a better whitespace handling of parenthesized comments due to trailing comments 2015-01-02 02:55:40 +11:00
Sebastian McKenzie
b8dd421073 v2.4.0 2015-01-02 02:26:14 +11:00
Sebastian McKenzie
5453c466d6 remove unused variable 2015-01-02 02:24:49 +11:00
Sebastian McKenzie
0cfb2e76b8 add 2.4.0 changelog 2015-01-02 02:24:01 +11:00
Sebastian McKenzie
ba67f57c1e use simple loops always in array comprehensions, support yield inside of array comprehensions - closes #325, fixes #252 2015-01-02 02:14:36 +11:00
Sebastian McKenzie
f1a178f8f9 compact body nodes in traversal 2015-01-02 01:59:49 +11:00
Sebastian McKenzie
b1d1909c64 forced closure on super classes - fixes #339 2015-01-02 01:59:42 +11:00
Sebastian McKenzie
9529f93690 move useStrict transformer to after _moduleFormatter 2015-01-02 01:58:56 +11:00
Sebastian McKenzie
925b1f7600 add optional asyncToGenerator transformer - closes #321 2015-01-02 01:31:14 +11:00
Sebastian McKenzie
40f8bc0a65 add optional bluebird coroutine transformer - @phpnode 2015-01-02 01:20:28 +11:00
Sebastian McKenzie
3a0dbabf5a v2.3.2 2015-01-02 01:04:43 +11:00
Sebastian McKenzie
383912c11b more reliable t.isExpression 2015-01-02 01:04:04 +11:00
Sebastian McKenzie
470c8fced0 add parens on expressions with trailing comments - fixes #349 2015-01-02 00:57:48 +11:00
Sebastian McKenzie
e3dc2355e8 v2.3.1 2015-01-02 00:46:14 +11:00
Sebastian McKenzie
9733cb58c9 remove unused variable 2015-01-02 00:45:26 +11:00
Sebastian McKenzie
edd5a3878a fix redefined variables 2015-01-02 00:45:01 +11:00
Sebastian McKenzie
78d2c4fa8d 2.3.1 changelog 2015-01-02 00:43:54 +11:00
Sebastian McKenzie
e268dc6138 return Object.defineProperties without a closure in property methods assignment unless it's really necessary 2015-01-02 00:42:28 +11:00
Sebastian McKenzie
5b6c0fcacd add whitespace after array and object expressions 2015-01-02 00:41:58 +11:00
Sebastian McKenzie
777f2be14e add undefinedToVoid optional transformer 2015-01-02 00:41:33 +11:00
Sebastian McKenzie
41d60a85e9 simplify define property by using a helper in playground object getter memoization 2015-01-02 00:40:47 +11:00
Sebastian McKenzie
800c350db6 use Object.defineProperty on computed properties - fixes #357 2015-01-02 00:40:37 +11:00
Sebastian McKenzie
7b5b8ab6ed add undefinedToVoid optional transformer 2015-01-02 00:25:17 +11:00
Maxime Quandalle
c7a02ca289 Extend the license to the new year 2015-01-01 13:03:38 +01:00
Sebastian McKenzie
52e23473ed allow export default non-functions mapping to module.exports in common module formatter - fixes #356 2015-01-01 22:58:46 +11:00
Sebastian McKenzie
af412cae28 v2.3.0 2015-01-01 22:40:44 +11:00
Sebastian McKenzie
4c2c96366f add 2.3.0 changelog 2015-01-01 22:40:02 +11:00
Sebastian McKenzie
de427936a6 remove invalid lval super classes in generation tests 2015-01-01 22:38:01 +11:00
Sebastian McKenzie
9d6850d576 fix linting errors 2015-01-01 22:35:08 +11:00
Sebastian McKenzie
20a0280a52 add support for optional transformers 2015-01-01 22:35:02 +11:00
Sebastian McKenzie
64b7d6fa93 more verbose unknown node error message in code generator 2015-01-01 22:34:51 +11:00
Sebastian McKenzie
d7ca7ebbb9 remove Transformer exposure 2015-01-01 22:34:29 +11:00
Sebastian McKenzie
9680730e24 remove forced closure on super classes 2015-01-01 22:34:22 +11:00
Sebastian McKenzie
07667d80ff clean up traverse 2015-01-01 22:34:05 +11:00
Sebastian McKenzie
9a633ebd9c update scope to use new traversal api 2015-01-01 22:33:40 +11:00
Sebastian McKenzie
fac4a61245 use Makefile command shortcuts 2015-01-01 22:33:30 +11:00
Sebastian McKenzie
0ebc073762 update traversal api, removing return false; in favor of this.stop(); 2015-01-01 22:33:17 +11:00
Sebastian McKenzie
860432cdfd hoist export default to very top 2015-01-01 22:31:59 +11:00
Sebastian McKenzie
c408432445 add support for circular references and hoist all variable declarations 2015-01-01 22:30:28 +11:00
Sebastian McKenzie
27e9f9d616 remove invalid lval super class test 2015-01-01 22:29:57 +11:00
Sebastian McKenzie
94a11cd602 add optional core aliasing transformer 2015-01-01 20:02:20 +11:00
Sebastian McKenzie
ab6e424cac make experimental transformers declare that they're experimental 2015-01-01 20:01:24 +11:00
Sebastian McKenzie
9ee7b07cbf add corejs aliasing transformer and support for optional transformers 2015-01-01 20:01:09 +11:00
Sebastian McKenzie
31fff092b6 upgrade acorn-6to5 - fixes #358 and #353 2014-12-31 11:56:04 +11:00
Sebastian McKenzie
e847ac11af add object-getter-memoization template 2014-12-31 11:54:51 +11:00
Sebastian McKenzie
aee1ca45b0 add isFalsyExpression check to superName and make classes a closure if they're inheriting 2014-12-31 11:54:39 +11:00
Sebastian McKenzie
46632e1a97 better object getter memoization - closes #353 2014-12-31 11:54:13 +11:00
Sebastian McKenzie
961e0b9b6b reenable system modules tests 2014-12-31 11:51:52 +11:00
Sebastian McKenzie
afdde8b3a7 v2.2.0 2014-12-29 12:48:45 +11:00
Sebastian McKenzie
918ddb4124 disable system tests temporairly 2014-12-29 11:16:47 +11:00
Sebastian McKenzie
18739ad78b remove unused variable 2014-12-29 11:15:24 +11:00
Sebastian McKenzie
74a84e2473 fix duplicate comments being output, breaking code 2014-12-29 11:13:50 +11:00
Sebastian McKenzie
52ffc65a06 make system module formatter modules anonymous by default - fixes #347 2014-12-29 01:55:30 +11:00
Sebastian McKenzie
d4fbfbbe47 Merge pull request #348 from guybedford/system
System test adjustments
2014-12-29 01:51:16 +11:00
Sebastian McKenzie
781467d423 v2.1.0 2014-12-29 01:41:05 +11:00
Sebastian McKenzie
44f5b7d013 fix case statement newline in code generator test 2014-12-29 01:39:04 +11:00
Sebastian McKenzie
dcf7f0b70b fix newline in case statement test 2014-12-29 01:37:19 +11:00
Sebastian McKenzie
03efd69998 check if node exists before inheriting comments to it 2014-12-29 01:37:12 +11:00
Sebastian McKenzie
213003a007 fix new templates path in dotfiles 2014-12-29 01:34:49 +11:00
Sebastian McKenzie
b0503f2efe add 2.1.0 changelog 2014-12-29 01:33:58 +11:00
Sebastian McKenzie
c8cf7ff286 better blacklist tests and expose register cache - closes #344 2014-12-29 01:31:26 +11:00
Sebastian McKenzie
ceb32816d7 fix destructuring in switch/case statements - closes #346 2014-12-29 01:26:51 +11:00
Sebastian McKenzie
32b94899a6 update runtime script to runtime generator 2014-12-29 01:26:21 +11:00
Sebastian McKenzie
d951082b09 move replacement node comment inheritance to traverse replacement 2014-12-29 01:26:11 +11:00
Sebastian McKenzie
b49f6e33d6 fix newline on case statement 2014-12-29 01:25:56 +11:00
Sebastian McKenzie
c5fa6425a5 explicit canRun for hidden transformers 2014-12-29 01:25:15 +11:00
Sebastian McKenzie
70d896d609 rename runtime script to runtime-generator 2014-12-29 01:24:57 +11:00
Sebastian McKenzie
e00fa8c9b1 update core-js 2014-12-29 01:24:41 +11:00
Sebastian McKenzie
13933bc9b8 move templates folder into transformation folder 2014-12-29 01:24:35 +11:00
guybedford
295bab544b re-exporting in setters 2014-12-28 14:43:56 +02:00
guybedford
cfe05ca10d exported variable declarations hoist along with functions 2014-12-28 14:41:32 +02:00
guybedford
da72182219 make modules anonymous 2014-12-28 14:38:52 +02:00
Sebastian McKenzie
005f5b2174 v2.0.4 2014-12-28 11:06:04 +11:00
Sebastian McKenzie
8551c94fa0 fix linting errors 2014-12-28 11:05:27 +11:00
Sebastian McKenzie
c509d06bc2 vaoid being greedy when destructuring array iterables 2014-12-28 11:04:00 +11:00
Sebastian McKenzie
f21743012b v2.0.3 2014-12-28 09:37:32 +11:00
Sebastian McKenzie
22dc33f93c remove unused variable 2014-12-28 09:36:29 +11:00
Sebastian McKenzie
6df6652629 better circular references in amd/umd/system module formatter 2014-12-28 09:35:47 +11:00
Sebastian McKenzie
4942ba6dd7 v2.0.2 2014-12-28 01:14:54 +11:00
Sebastian McKenzie
b63bd8cba0 remove interopRequire from system module formatter 2014-12-28 01:14:08 +11:00
Sebastian McKenzie
cd1eb11171 Merge branch 'master' of github.com:6to5/6to5 2014-12-28 01:10:00 +11:00
Sebastian McKenzie
6e1c12fd78 inherit comments in for-of transformer 2014-12-28 01:09:48 +11:00
Sebastian McKenzie
a4ea71b85d Merge pull request #337 from guybedford/master
Correct system format base support tests
2014-12-28 01:03:35 +11:00
Sebastian McKenzie
1df69bdbeb v2.0.1 2014-12-28 01:02:29 +11:00
Sebastian McKenzie
84c2766756 remove unused variable 2014-12-28 01:01:52 +11:00
Sebastian McKenzie
1f000ac83d add 2.0.1 changelog 2014-12-28 01:01:18 +11:00
Sebastian McKenzie
322aa246b8 fix automatic closure on private declarations - fixes #335 2014-12-28 01:01:13 +11:00
Sebastian McKenzie
601bbb86cd remap UpdateExpression in module exports - closes #334 2014-12-28 01:00:53 +11:00
guybedford
5c39685650 correct system format base support tests 2014-12-27 15:59:52 +02:00
Sebastian McKenzie
e6ac5eccd0 v2.0.0 2014-12-27 23:56:34 +11:00
Sebastian McKenzie
c4c9f7984f fix linting errors 2014-12-27 23:55:52 +11:00
Sebastian McKenzie
8d472a14be Merge pull request #319 from 6to5/2.0.0
2.0.0
2014-12-27 21:36:07 +11:00
Sebastian McKenzie
4fd007948c fix system modules exports from test 2014-12-27 21:34:20 +11:00
Sebastian McKenzie
f4e516e8ce fix tests as per acorn upgrade 2014-12-27 21:29:24 +11:00
Sebastian McKenzie
7fcd8ea642 upgrade acorn 2014-12-27 21:24:34 +11:00
Sebastian McKenzie
add0a7d5fe better ClassDeclarations in expression contexts 2014-12-27 21:24:29 +11:00
Sebastian McKenzie
e9445c9277 move spec transformers to bottom 2014-12-27 21:24:02 +11:00
Sebastian McKenzie
df66fa0a7f heavily simplify system module formatter and share common code between them all 2014-12-27 21:23:53 +11:00
Sebastian McKenzie
0a85211e8e fix traverse blacklist test 2014-12-27 21:22:34 +11:00
Sebastian McKenzie
ac8fc24fdb fix traverse test to reflect the new api 2014-12-27 19:16:06 +11:00
Sebastian McKenzie
71c4a29a78 update 2.0.0 changelog 2014-12-27 19:13:05 +11:00
Sebastian McKenzie
08dde22939 better ClassDeclaration contextual transformation 2014-12-27 19:12:56 +11:00
Sebastian McKenzie
d3ea0fe84f always add additional newline on the last node 2014-12-27 19:12:43 +11:00
Sebastian McKenzie
22851cd1ac clean up system module formatter 2014-12-27 19:12:31 +11:00
Sebastian McKenzie
987dc0692f Merge branch 'feat-system-module-rewrite' of https://github.com/douglasduteil/6to5 into 2.0.0
Conflicts:
	lib/6to5/transformation/modules/system.js
	test/fixtures/transformation/es6-modules-system/exports-from/expected.js
2014-12-27 17:05:21 +11:00
Sebastian McKenzie
560d60e3e7 fix formatting on react display name object declaration actual test 2014-12-27 17:02:00 +11:00
Sebastian McKenzie
e96d02c972 make traversal code simpler 2014-12-27 17:01:47 +11:00
Sebastian McKenzie
13a2d469a3 update core-js 2014-12-27 17:01:06 +11:00
Sebastian McKenzie
0b232ed228 add api opts.ast === false test 2014-12-27 17:00:58 +11:00
Sebastian McKenzie
9053e0dedf ignore bin tests under instanbul 2014-12-27 17:00:46 +11:00
Sebastian McKenzie
873e820210 add unknown module formatter test 2014-12-27 17:00:38 +11:00
Sebastian McKenzie
27bb08eadf add amd module name test 2014-12-27 17:00:27 +11:00
Sebastian McKenzie
bea903c69f add modules remap tests 2014-12-27 17:00:20 +11:00
Sebastian McKenzie
198a9c6ead nicer local exports remapping in default module formatter 2014-12-27 16:59:57 +11:00
Sebastian McKenzie
9c92679053 fix polyfill regenerator runtime path 2014-12-27 16:59:39 +11:00
Sebastian McKenzie
87d2bdadeb remove user transformers 2014-12-27 16:59:19 +11:00
Sebastian McKenzie
fa71f2a7f9 Merge branch 'core-js' into 2.0.0
Conflicts:
	lib/6to5/polyfill.js
2014-12-25 14:27:29 +11:00
Sebastian McKenzie
66e7134335 revert strict equals after #329 2014-12-23 16:11:15 +11:00
Sebastian McKenzie
99a1cf08f9 Merge pull request #329 from chicoxyzzy/fix_jshint_errors_2.0.0
fix jsHint errors in branch 2.0.0
2014-12-23 16:08:34 +11:00
chico
5de9c22452 fix jsHint errors in branch 2.0.0 2014-12-23 06:23:16 +03:00
Sebastian McKenzie
694a8dc456 rename helper functions to be more reflective of what they do 2014-12-22 23:23:59 +11:00
Sebastian McKenzie
2df1ca3971 properly freeze tagged template literal object #328 2014-12-22 22:07:45 +11:00
Sebastian McKenzie
6c7cdc9b7c update 2.0.0 changelog 2014-12-22 22:04:42 +11:00
Sebastian McKenzie
52b1d055ac fix regenerator/recast/ast-types monkey patch 2014-12-22 21:58:35 +11:00
Sebastian McKenzie
2a316bf362 move default parameters to after destructuring for param destructuring 2014-12-22 21:38:11 +11:00
Sebastian McKenzie
26ce0b8c8b switch to regenerator/runtime 2014-12-22 21:37:40 +11:00
Sebastian McKenzie
275c4cc34e add note about node/browserify polyfill usage 2014-12-22 21:37:32 +11:00
Sebastian McKenzie
bc914e6f23 freeze tagged template literal object - fixes #328 2014-12-22 21:36:59 +11:00
Sebastian McKenzie
4ea425ac7b remove ParenthesizedExpression 2014-12-22 21:36:33 +11:00
Sebastian McKenzie
bd255257f1 switch to vanilla regenerator 2014-12-22 21:34:09 +11:00
Sebastian McKenzie
41f072d112 clarify es5 and add getters/setters in IE 8<= to caveats fixes #314 2014-12-19 01:11:48 +11:00
Sebastian McKenzie
2a4c8e8423 add note about sourcemaps and 6to5/register 2014-12-18 16:30:49 +11:00
Sebastian McKenzie
122705bdaf remove custom regenerator runtime from dist 2014-12-18 16:30:33 +11:00
Sebastian McKenzie
f84e0ba640 add if statement to class super constructor call 2014-12-18 16:30:23 +11:00
Sebastian McKenzie
64216ec384 change generators/async functions to reference regenerator runtime rather than the polyfill 2014-12-18 16:30:14 +11:00
Sebastian McKenzie
a948928973 add roadrunner dependency 2014-12-18 16:29:20 +11:00
Sebastian McKenzie
5ab891b39d make first node in a class body inherit class comments 2014-12-18 16:28:13 +11:00
Sebastian McKenzie
2a742b5fac add in todo for a better t.isReferenced 2014-12-18 16:28:00 +11:00
Sebastian McKenzie
cd6b678b51 add support for exportdeclarations to constants 2014-12-18 16:27:50 +11:00
Sebastian McKenzie
c290a008b2 add --cache option to 6to5-node 2014-12-18 16:27:30 +11:00
Sebastian McKenzie
e8f0c8e8a4 Merge branch '2.0.0' of github.com:6to5/6to5 into 2.0.0 2014-12-18 01:10:28 +11:00
Sebastian McKenzie
22eb8edf41 support other operators in abstract reference assignment expression - fixes #311 2014-12-18 01:09:51 +11:00
Sebastian McKenzie
a3eb8900a9 add if super check to constructor default 2014-12-18 01:09:24 +11:00
Sebastian McKenzie
bf74f5a634 Merge pull request #310 from Dashed/patch-1
Clarify usage of 6to5 in node with harmony flag.
2014-12-18 00:25:44 +11:00
Alberto Leal
98e9a45f63 Rephrasing again.
Clarified by @sebmck on gitter.
2014-12-17 08:23:02 -05:00
Alberto Leal
1d91a758b4 Rephrasing 2014-12-17 08:19:47 -05:00
Alberto Leal
b94b4b335b Clarify usage of 6to5 in node with harmony flag. 2014-12-17 04:18:53 -05:00
antn
f4055612e5 add link to code of conduct [ci skip] 2014-12-16 22:29:37 -08:00
antn
46911bd28c add code of conduct 2014-12-16 22:17:35 -08:00
Douglas Duteil
104b1f4c9b feat(system-module): rewrite 2014-12-17 02:36:47 +01:00
Sebastian McKenzie
00c95f6a94 Merge pull request #302 from raine/patch-1
Update differences.md
2014-12-16 09:37:22 +11:00
Raine Virta
f14dc60934 Update differences.md
fix typo
2014-12-16 00:36:18 +02:00
Sebastian McKenzie
2fc8010034 move jshint to normal dependencies 2014-12-16 08:08:14 +11:00
Sebastian McKenzie
882ed48438 fix a catch param property identifier incorrectly being replaced when exploding statements in generators - fixes #301 2014-12-16 08:08:06 +11:00
Sebastian McKenzie
49578fe223 fix let variable declaration hoisting bug. All let variable declarators now have a default initializer of undefined unless they're the left of a ForIn or ForOf 2014-12-16 08:07:46 +11:00
Sebastian McKenzie
01bdb7efdc fix export and import specifier getIds and add support for computed properties to isReferenced 2014-12-16 08:07:18 +11:00
Sebastian McKenzie
fc7fc384c9 add declaration/reference support to scope 2014-12-16 08:06:56 +11:00
Sebastian McKenzie
bd78e3ed4d add end/start user transformers 2014-12-16 08:06:38 +11:00
Sebastian McKenzie
1f990f4030 fFix module formatter parsing bug where literals were being converted to identifiers 2014-12-16 08:06:25 +11:00
Sebastian McKenzie
d8e4a4a776 add module changes to 2.0.0 changelog 2014-12-15 22:36:10 +11:00
Sebastian McKenzie
473b6d6a91 more microoptimizations 2014-12-15 22:35:58 +11:00
Sebastian McKenzie
3d975da530 remove reference to regenerator runtime and say that the explicit polyfill is required 2014-12-15 22:35:41 +11:00
Sebastian McKenzie
1a4110e0a1 categorise differences and elaborate on why they're significant 2014-12-15 22:35:25 +11:00
Sebastian McKenzie
a03d491ac6 microoptimize module formatters, change method names to a new API, and add support for exporting multiple variable declarators - fixes #299 2014-12-15 22:34:49 +11:00
Sebastian McKenzie
e01e010577 add 2.0.0 changelog 2014-12-15 18:53:50 +11:00
Sebastian McKenzie
132ac00ec7 Merge pull request #298 from Dashed/patch-2
Clarify usage in node env
2014-12-15 16:35:54 +11:00
Alberto Leal
1673f78ab5 Clarify usage in node env 2014-12-15 00:35:17 -05:00
Sebastian McKenzie
76b8a06e90 Merge branch 'master' into 2.0.0 2014-12-15 16:35:15 +11:00
Sebastian McKenzie
711f84c826 Merge pull request #297 from Dashed/patch-1
Clarify polyfill usage in node env
2014-12-15 16:34:55 +11:00
Alberto Leal
4b4ff007e9 Clarify polyfill usage in node env 2014-12-15 00:34:14 -05:00
Sebastian McKenzie
e31e68cae3 use types.isSpecifierDefault in amd modules formatter 2014-12-15 14:16:34 +11:00
Sebastian McKenzie
778b4e3a27 remove commonStrict module formatter 2014-12-15 14:16:18 +11:00
Sebastian McKenzie
6011db7ae1 Merge branch 'master' into 2.0.0 2014-12-15 14:02:04 +11:00
Sebastian McKenzie
363b1631f5 switch to core-js from es6-symbol and es6-shim
Conflicts:
	lib/6to5/polyfill.js
2014-12-15 14:00:41 +11:00
Sebastian McKenzie
01286ebd5b add custom regenerator runtime to build process 2014-12-15 14:00:14 +11:00
Sebastian McKenzie
fe918a3535 add async generator functions to docs 2014-12-15 14:00:04 +11:00
Sebastian McKenzie
2fb6c7820c microoptimizations 2014-12-15 13:59:54 +11:00
Sebastian McKenzie
e7cbbefc11 Merge pull request #296 from caseywebdev/fix-295
Fix incorrect object reference in #295
2014-12-15 13:58:34 +11:00
Casey Foster
f4fdc3adc6 Fix incorrect object reference in #295 2014-12-14 20:57:32 -06:00
Sebastian McKenzie
2cd49b08ec add async generator functions to docs 2014-12-15 13:56:22 +11:00
Sebastian McKenzie
1b16ff3a0b Revert "switch to core-js from es6-symbol and es6-shim"
This reverts commit 37b2e747d5.
2014-12-15 13:54:45 +11:00
Sebastian McKenzie
b7c298a0ee Merge pull request #295 from caseywebdev/amd-umd-interop-require
Add interop require support for AMD and UMD
2014-12-15 13:48:59 +11:00
Casey Foster
5da4397392 Add interop require support for AMD and UMD 2014-12-14 20:44:38 -06:00
Sebastian McKenzie
ea5954121e disable es6-transpiler 2014-12-14 23:58:42 +11:00
Sebastian McKenzie
37b2e747d5 switch to core-js from es6-symbol and es6-shim 2014-12-14 23:58:31 +11:00
Sebastian McKenzie
3dd6eb1202 update acorn-6to5 2014-12-14 14:53:00 +11:00
Sebastian McKenzie
319ed09407 remove string includes polyfill 2014-12-14 14:49:48 +11:00
Sebastian McKenzie
77f9596682 update classes tests to work with new _extends method 2014-12-14 14:49:37 +11:00
Sebastian McKenzie
00cb90541a add support for experimental private abstract references syntax - closes #291 2014-12-14 14:49:25 +11:00
Sebastian McKenzie
d26f441a5c support falsy and null super classes - fixes #284 2014-12-14 12:19:24 +11:00
Sebastian McKenzie
11fc7cd0ce rename 6to5-browserify to 6to5ify 2014-12-14 12:18:33 +11:00
Sebastian McKenzie
c38428c536 make react transformer first 2014-12-14 12:18:14 +11:00
Sebastian McKenzie
bf40849e35 make ensureProto methods non-enumerable 2014-12-14 12:18:03 +11:00
Sebastian McKenzie
194fb77b9c add WithStatement buider keys 2014-12-14 12:17:28 +11:00
Sebastian McKenzie
ceb8e812b6 expose transformers and types 2014-12-14 12:17:16 +11:00
Sebastian McKenzie
3a261a5e05 add kexec to optionalDependencies 2014-12-13 18:02:26 +11:00
Sebastian McKenzie
4c1ad04b2c fix wrong variable name for bin/6to5-node kexec catch 2014-12-13 17:56:17 +11:00
Sebastian McKenzie
0d9e6aca67 Merge pull request #289 from monsanto/kexec
run _6to5-node using execvp() if available
2014-12-13 17:53:55 +11:00
Christopher Monsanto
aac6303696 run _6to5-node using execvp() if available 2014-12-13 01:53:36 -05:00
Sebastian McKenzie
833a4900da remove IIFE on class declarations #288 2014-12-13 17:33:35 +11:00
Sebastian McKenzie
525169460a add back parentheses generator option 2014-12-13 17:32:58 +11:00
Sebastian McKenzie
13785bddb0 escape illegal js but valid json unicode characters - fixes #247 2014-12-13 14:14:47 +11:00
Sebastian McKenzie
84332da399 document format options 2014-12-13 12:52:31 +11:00
Sebastian McKenzie
aae7d8190b fix up tests to work with the new method binding operator 2014-12-13 12:40:43 +11:00
Sebastian McKenzie
03dcc335d8 Merge branch 'master' into 2.0.0
Conflicts:
	CHANGELOG.md
2014-12-13 12:20:02 +11:00
Sebastian McKenzie
9ca05b1971 v1.15.0 2014-12-13 12:18:05 +11:00
Sebastian McKenzie
2a27b7c16c 1.15.0 2014-12-13 12:15:32 +11:00
Sebastian McKenzie
c92fd6f0bb remove useless GeneratorFunction aliasing causing issues #283 2014-12-13 12:13:03 +11:00
Sebastian McKenzie
2267344471 use # operator instead of : for playground method binding to remove ambiguous syntax 2014-12-13 04:37:00 +11:00
Sebastian McKenzie
593e4ca670 remove useless GeneratorFunction aliasing causing issues #283 2014-12-12 12:14:24 +11:00
Sebastian McKenzie
e563783a1e add gratipay to readme 2014-12-12 12:14:07 +11:00
Sebastian McKenzie
615425c808 fix linting errors 2014-12-12 12:14:02 +11:00
Sebastian McKenzie
55e2010311 comment out broken esnext 2014-12-11 23:12:15 +11:00
Sebastian McKenzie
74f40c2824 fix generator rest parameters 2014-12-11 11:02:55 +11:00
Sebastian McKenzie
c26ce1c114 abstract away astRun from transformer 2014-12-11 10:14:08 +11:00
Sebastian McKenzie
2537768772 inherit comments in modules transformer - fixes #280 2014-12-11 10:13:40 +11:00
Sebastian McKenzie
8af05634fa fix rest parameters on arrow functions 2014-12-11 10:10:07 +11:00
Sebastian McKenzie
74614e712e make rest parameters work inside of aliasFunction 2014-12-11 09:52:50 +11:00
Sebastian McKenzie
ad923cf8fa add playground support to 6to5-node 2014-12-11 09:52:29 +11:00
Sebastian McKenzie
c7d69b2f92 block scope constants 2014-12-10 23:49:13 +11:00
Sebastian McKenzie
2a0b63f3bb better symbol iterator check in regenerator runtime 2014-12-10 23:28:50 +11:00
Sebastian McKenzie
01934b6960 fix default import generation 2014-12-10 23:18:23 +11:00
Sebastian McKenzie
8ffd2e843f fix fromAst not passing ast to transform 2014-12-10 22:34:58 +11:00
Sebastian McKenzie
6d68b3da4d fix fromAst usage 2014-12-10 21:54:54 +11:00
Sebastian McKenzie
79b4207b44 upgrade acorn-6to5 2014-12-10 21:54:43 +11:00
Sebastian McKenzie
30a90d2554 fix hash bang support 2014-12-10 21:54:38 +11:00
Sebastian McKenzie
bac8758369 remove other commonInterop reference 2014-12-10 21:37:07 +11:00
Sebastian McKenzie
d00faf4a72 remove commonInterop option from register 2014-12-10 21:33:30 +11:00
Sebastian McKenzie
b986a4e482 expose ast transformer - fixes #263 2014-12-10 21:31:27 +11:00
Sebastian McKenzie
f11f364d2c add _aliasFunction to generator comprehension container - fixes #278 2014-12-10 21:28:49 +11:00
Sebastian McKenzie
c4a0f62eef add global symbol registry to polyfill 2014-12-10 21:12:01 +11:00
Sebastian McKenzie
072fff0f4c clean up system modules formatter 2014-12-10 21:11:43 +11:00
Sebastian McKenzie
59b81b389a Fix up checkLoop method comment 2014-12-10 21:11:26 +11:00
Sebastian McKenzie
4a439857d2 make mutators enumerable 2014-12-10 21:11:13 +11:00
Sebastian McKenzie
187f7ba01e Remove regenerator finished generator error 2014-12-10 21:10:59 +11:00
Sebastian McKenzie
e6da342e8b add a "spec" transformer namespace for transformers that nicen up code and make it well, more spec compliant 2014-12-10 21:09:58 +11:00
Sebastian McKenzie
1c22c608a9 make bin/6to5-node usage more inline with node 2014-12-10 21:09:09 +11:00
Sebastian McKenzie
8e96130bc0 rename common to commonStrict and commonInterop to common 2014-12-10 21:08:54 +11:00
Sebastian McKenzie
0f47814b41 separate experimental page in docs 2014-12-10 21:08:00 +11:00
Sebastian McKenzie
b32d56a168 remove 6to5-node filenames test 2014-12-09 23:32:25 +11:00
Sebastian McKenzie
5f26a0c5cc update modules tests 2014-12-09 23:28:07 +11:00
Sebastian McKenzie
2245bbc6c4 make bin/6to5-node more node bin compliant 2014-12-09 23:18:54 +11:00
Sebastian McKenzie
b8d61f1528 update github urls and regroup plugins 2014-12-09 23:18:54 +11:00
Sebastian McKenzie
e97e916b5c module export variable declaration initializer default - fixes #264 2014-12-09 23:18:54 +11:00
Sebastian McKenzie
b688154aee reformat CHANGELOG 2014-12-09 23:18:54 +11:00
Sebastian McKenzie
ccb56fe33f Merge pull request #271 from es128/patch-1
Simplify chokidar event handler
2014-12-09 09:57:12 +11:00
Elan Shanker
5e67dfbd9e Ensure only file events are acted upon 2014-12-08 17:55:54 -05:00
Elan Shanker
6f6d9bd5a8 Simplify chokidar event handler 2014-12-08 17:17:31 -05:00
Sebastian McKenzie
61b9c28ce6 update plugins to reflect 6to5 org migrations 2014-12-08 12:11:39 +11:00
Sebastian McKenzie
d11d0d3216 split up plugins into sections and change some community plugin urls to official ones 2014-12-07 22:00:31 +11:00
Sebastian McKenzie
bd876f7a4d fix starting file newlines 2014-12-07 22:00:30 +11:00
Sebastian McKenzie
f9f48620de remove unused test transformation whitespace option 2014-12-07 22:00:30 +11:00
Sebastian McKenzie
ce9a82c194 add docs for ast and code option 2014-12-07 22:00:30 +11:00
Sebastian McKenzie
24f6dfa8e2 Merge pull request #262 from josh/comment-before-newlines
Fix whitespace before comments
2014-12-07 21:11:48 +11:00
Joshua Peek
f592f95a68 Subtract one if line already ends with "{\n" 2014-12-07 02:06:54 -08:00
Joshua Peek
2e0cd0f349 Add tests for newlines before comments 2014-12-07 02:06:41 -08:00
Sebastian McKenzie
e17d5bdb13 fix comments test in property name shorthand 2014-12-07 11:46:59 +11:00
Sebastian McKenzie
c1c22ed5f7 fix duplicate comments on property key shorthands - fixes #234 2014-12-07 11:43:51 +11:00
Sebastian McKenzie
bf07f54e57 add note about inline functions to docs/differences 2014-12-07 11:31:08 +11:00
Sebastian McKenzie
eef0344cb2 fix comments-only rendering 2014-12-07 11:30:50 +11:00
Sebastian McKenzie
88a85c0ca8 fix files only containg comments not being output - fixes #259 2014-12-07 11:20:43 +11:00
Sebastian McKenzie
302e6f4caa Merge pull request #257 from thejameskyle/readme-center
Center everything in README
2014-12-07 10:55:43 +11:00
James Kyle
36c16a0227 Center everything in README 2014-12-06 15:33:17 -08:00
Sebastian McKenzie
0ee4a15d01 v1.14.17 2014-12-06 23:37:32 +11:00
Sebastian McKenzie
fbdaedc4f8 remove unused loopParent variable 2014-12-06 23:36:28 +11:00
Sebastian McKenzie
75c8d73d35 add default initializer to let variables within loop bodies and fix excessive break replacement inside of switches in let scoping - fixes #255 2014-12-06 23:35:47 +11:00
Sebastian McKenzie
21599d3a9a change memoisation to memoization 2014-12-06 20:49:33 +11:00
Sebastian McKenzie
9fbbabc7e4 v1.14.16 2014-12-06 20:48:31 +11:00
Sebastian McKenzie
8c1fe49b2e upgrade acorn-6to5 2014-12-06 20:47:40 +11:00
Sebastian McKenzie
763b4caf32 v1.14.15 2014-12-06 20:46:16 +11:00
Sebastian McKenzie
c0248cf04c add 1.14.15 changelog 2014-12-06 20:44:58 +11:00
Sebastian McKenzie
a7a6ee80f2 add object getter memoization and this shorthand to playground 2014-12-06 19:37:23 +11:00
Sebastian McKenzie
aa298b1e0a update doc/differences to reflect current status of project - fixes #253 2014-12-06 19:36:46 +11:00
Sebastian McKenzie
9c0a8e22d2 fix let scoping not working with while loops - fixes #254 2014-12-06 19:36:08 +11:00
Sebastian McKenzie
7c1a924ef6 v1.14.14 2014-12-06 00:04:00 +11:00
Sebastian McKenzie
1d975a2635 Fix tagged template literals 2014-12-06 00:03:11 +11:00
Sebastian McKenzie
67cfdbd447 better closure variable name in default parameters 2014-12-06 00:00:09 +11:00
Sebastian McKenzie
ab02231d39 fix template literals escaping 2014-12-06 00:00:00 +11:00
Sebastian McKenzie
40a2d14c7c v1.14.13 2014-12-05 23:12:01 +11:00
Sebastian McKenzie
573283f260 fix bin/6to5 error message test 2014-12-05 23:11:04 +11:00
Sebastian McKenzie
0497860462 Fix linting error 2014-12-05 23:08:35 +11:00
Sebastian McKenzie
a173775fec 1.14.13 2014-12-05 23:07:21 +11:00
Sebastian McKenzie
c5214ffe70 enumerable es6 class methods 2014-12-05 23:06:36 +11:00
Sebastian McKenzie
3d62af004d fix bin/6to5-node code formatting 2014-12-05 23:06:17 +11:00
Sebastian McKenzie
d7af8c6261 whitespace after function assignment 2014-12-05 23:06:05 +11:00
Sebastian McKenzie
680c6b166a Fix let scoping to work with while loops 2014-12-05 23:05:47 +11:00
Sebastian McKenzie
5bad458b09 Fix tests 2014-12-05 23:05:20 +11:00
Sebastian McKenzie
055f894a88 Use stylish jshint reporter 2014-12-05 23:05:05 +11:00
Sebastian McKenzie
da8edecc09 v1.14.12 2014-12-05 10:57:27 +11:00
Sebastian McKenzie
cd6dea6480 fix version in changelog 2014-12-05 10:56:33 +11:00
Sebastian McKenzie
69d7ac0e0c 1.14.11 2014-12-05 10:54:25 +11:00
Sebastian McKenzie
dae46bfbfa DRY up isDynamic checks - add isDynamic check to spread - fixes #232 2014-12-05 10:53:46 +11:00
Sebastian McKenzie
b5b175c45a v1.14.11 2014-12-05 10:10:31 +11:00
Sebastian McKenzie
569c681c4f v1.14.10 2014-12-05 09:58:16 +11:00
Sebastian McKenzie
ed1e4a7820 fix changelog version 2014-12-05 09:57:14 +11:00
Sebastian McKenzie
b55f941dae v1.14.1 2014-12-05 09:56:36 +11:00
Sebastian McKenzie
a0219ef278 fix let scoping unneccesary override - fixes #245 2014-12-05 09:55:26 +11:00
Sebastian McKenzie
b9266b0c4c v1.14.10 2014-12-04 10:35:52 +11:00
Sebastian McKenzie
a1239e5f5a add ast return transform option 2014-12-04 10:34:52 +11:00
Sebastian McKenzie
2f279de7d1 v1.14.9 2014-12-04 10:31:08 +11:00
Sebastian McKenzie
c70b3586fb Remove roadrunner 2014-12-04 10:30:16 +11:00
Sebastian McKenzie
3928384c27 v1.14.8 2014-12-04 10:25:02 +11:00
Sebastian McKenzie
e469f7f589 fix require caching 2014-12-04 10:23:55 +11:00
Sebastian McKenzie
988ab0e823 v1.14.7 2014-12-04 10:18:57 +11:00
Sebastian McKenzie
e708394408 start fixing shorthand comment issue 2014-12-04 10:17:37 +11:00
Sebastian McKenzie
7c3ab8bc3c add isparta to docs/plugins 2014-12-04 10:17:28 +11:00
Sebastian McKenzie
2b11a45117 Add support for ExpressionStatement in t.isDynamic 2014-12-04 10:17:13 +11:00
Sebastian McKenzie
d5666912d4 Add cache option to 6to5-node 2014-12-04 10:17:04 +11:00
Sebastian McKenzie
2eab56c38b Merge pull request #240 from thejameskyle/arguments-spread
Only slice arguments when necessary - fixes #239
2014-12-03 12:28:14 +11:00
James Kyle
888ab5473a Only slice arguments when necessary - fixes #239 2014-12-02 16:46:48 -08:00
Sebastian McKenzie
5fe1c07d9a v1.14.6 2014-11-30 23:40:12 +11:00
Sebastian McKenzie
758a873894 avoid ensuring a block on non-array node replacements 2014-11-30 23:39:08 +11:00
Sebastian McKenzie
e91926d094 v1.14.5 2014-11-30 11:15:54 +11:00
Sebastian McKenzie
5085b96753 update 1.14.5 changelog 2014-11-30 11:12:36 +11:00
Sebastian McKenzie
66f67b92ce upgrade acorn-6to5 2014-11-30 11:10:58 +11:00
Sebastian McKenzie
3c9fa13a1f remove JSON.stringify of unknown generator node types 2014-11-30 11:10:58 +11:00
Sebastian McKenzie
5f21fc2f17 ensureBlock on multiple node replacements - fixes #229 2014-11-30 11:10:57 +11:00
Sebastian McKenzie
4bd4e4cdbe fix sh doc code blocks 2014-11-30 11:10:57 +11:00
Sebastian McKenzie
3c7b2d7872 Merge pull request #231 from thejameskyle/module-names
Add CLI commands for module docs
2014-11-30 10:52:42 +11:00
James Kyle
5db757354a Add CLI commands for module docs 2014-11-29 11:31:34 -08:00
Sebastian McKenzie
063b379d4f remove dead playground docs 2014-11-26 22:21:18 +11:00
Sebastian McKenzie
af42fe3d30 v1.14.4 2014-11-26 17:24:55 +11:00
Sebastian McKenzie
3c808fcef2 merge pretzel maps and method binding 2014-11-26 17:23:33 +11:00
Sebastian McKenzie
a29505f75d v1.14.3 2014-11-26 16:21:40 +11:00
Sebastian McKenzie
05942d17bf add 1.14.3 changelog 2014-11-26 16:19:15 +11:00
Sebastian McKenzie
be0d4b344b add playground pretzel maps 2014-11-26 16:17:27 +11:00
Sebastian McKenzie
f1a2401681 v1.14.2 2014-11-26 10:54:45 +11:00
Sebastian McKenzie
2d61672cdb add 1.14.2 changelog 2014-11-26 10:53:52 +11:00
Sebastian McKenzie
1b00ba21a1 fix commonInterop default export handling - fixes #223 2014-11-26 10:48:30 +11:00
Sebastian McKenzie
f8ea386f3c fix computed property literals - fixes #221 2014-11-26 10:47:23 +11:00
Sebastian McKenzie
2527fffbad merge memberExpressionKeywords and memberExpressionLiterals transformer 2014-11-26 10:46:32 +11:00
Sebastian McKenzie
86498ad990 fix memoisation operator example 2014-11-26 10:46:10 +11:00
Sebastian McKenzie
27c8804214 v1.14.1 2014-11-26 00:43:24 +11:00
Sebastian McKenzie
2b6f0ee780 add changelog for 1.14.1 2014-11-26 00:42:05 +11:00
Sebastian McKenzie
c7c9660c79 classes: make VariableDeclaration inherit comments from ClassDeclaration 2014-11-26 00:41:07 +11:00
Sebastian McKenzie
ff025e63ec add ParenthesizedExpression support to t.isDynamic 2014-11-26 00:40:42 +11:00
Sebastian McKenzie
9fb6681ad3 fix dot in playground docs 2014-11-26 00:08:34 +11:00
Sebastian McKenzie
301887f88d v1.14.0 2014-11-26 00:06:13 +11:00
Sebastian McKenzie
b519bb6a68 add playground experimental note 2014-11-26 00:04:03 +11:00
Sebastian McKenzie
b6e366ad94 remove unused variables 2014-11-26 00:03:22 +11:00
Sebastian McKenzie
ba2204156c make playground option enable experimental 2014-11-26 00:02:49 +11:00
Sebastian McKenzie
2545292bce add 1.14.0 changelog 2014-11-26 00:01:29 +11:00
Sebastian McKenzie
c763cf364c clarify playground warning note 2014-11-26 00:01:17 +11:00
Sebastian McKenzie
1db7247d9a remove weird sounding however in playground warning message 2014-11-25 23:57:43 +11:00
Sebastian McKenzie
1a1e6bc3ba remove arguments-to-array helper 2014-11-25 23:56:38 +11:00
Sebastian McKenzie
d184bc93b9 add playground 2014-11-25 23:50:50 +11:00
Sebastian McKenzie
e12cca974a remove irrelevant max line length 2014-11-25 23:49:35 +11:00
Sebastian McKenzie
b17bc95b4f v1.13.13 2014-11-25 19:49:51 +11:00
Sebastian McKenzie
a71f260377 add 1.13.13 changelog 2014-11-25 19:48:42 +11:00
Sebastian McKenzie
8cbc1f7f06 Merge pull request #218 from timoxley/no-no-timeouts
Remove --no-timeouts flag.
2014-11-25 19:47:54 +11:00
Sebastian McKenzie
34335018e9 v1.13.12 2014-11-25 19:03:48 +11:00
Sebastian McKenzie
136bddab33 temporarily disable es7-modules-system tests 2014-11-25 19:02:49 +11:00
Sebastian McKenzie
b2951c5462 remove SpreadProperty definition 2014-11-25 19:01:22 +11:00
Sebastian McKenzie
07de6f5f4a clean up Scope reference addition 2014-11-25 18:59:45 +11:00
Sebastian McKenzie
99ea00ca18 simplify generator context id 2014-11-25 18:59:36 +11:00
Sebastian McKenzie
ab5c6a38eb add VirtualPropertyExpression and SpreadProperty to ast-types 2014-11-25 18:59:26 +11:00
Sebastian McKenzie
52cee84625 add 1.13.12 changelog 2014-11-25 18:57:43 +11:00
Tim Oxley
20dc8b05c9 Remove --no-timeouts flag.
Not a valid flag, causes errors when trying to use debug modes.
2014-11-25 14:54:36 +08:00
Sebastian McKenzie
ba5992621d Merge branch 'guybedford-system' 2014-11-25 14:59:57 +11:00
Sebastian McKenzie
cdae98f653 Merge branch 'system' of github.com:guybedford/6to5 into guybedford-system 2014-11-25 14:59:47 +11:00
Sebastian McKenzie
81434bb557 add types.isDynamic so we can scan a node to see if it's ~safe~ to include it twice 2014-11-25 11:44:53 +11:00
Sebastian McKenzie
3af0fc6fb7 ignore XJSEmptyExpression - fixes #214 2014-11-25 11:44:35 +11:00
guybedford
3f60062ab6 system tests updates for live bindings and function hoisting 2014-11-24 16:05:54 +02:00
Sebastian McKenzie
76499bb26e update modules docs 2014-11-24 10:33:43 +11:00
Sebastian McKenzie
44f2f701e1 v1.13.11 2014-11-24 10:23:56 +11:00
Sebastian McKenzie
032bc0af5e fix util.regexify tests 2014-11-24 10:23:00 +11:00
Sebastian McKenzie
0e822a7e54 remove unused variables 2014-11-24 10:21:01 +11:00
Sebastian McKenzie
51e521f0e0 add 1.13.11 changelog 2014-11-24 10:19:40 +11:00
Sebastian McKenzie
e5ce69d6af clean up register module formatter and rename it to system 2014-11-24 10:19:06 +11:00
Sebastian McKenzie
e3b8fa93e2 export as module.exports if there are no other ExportDeclarations in commonInterop module formatter @guybedford 2014-11-24 10:05:50 +11:00
Sebastian McKenzie
f4ce3a23ad fix explicit arguments reference for rest parameters - fixes #210 2014-11-24 10:05:49 +11:00
Sebastian McKenzie
39f4696ac7 fix util.regexify on falsy values - fixes #208 2014-11-24 10:05:49 +11:00
Sebastian McKenzie
4a9918ec6b Merge pull request #209 from douglasduteil/feat-modules-add-register-module-type
Add "register" module formatter
2014-11-24 10:05:29 +11:00
Douglas Duteil
c87e14f6a9 feat(modules): add "register" module type
Inspired by https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
2014-11-23 22:54:01 +01:00
Sebastian McKenzie
680771c81b v1.13.10 2014-11-24 01:02:18 +11:00
Sebastian McKenzie
cad3f63723 update assignment expression destructuring test 2014-11-24 01:01:13 +11:00
Sebastian McKenzie
eceda64528 add 1.13.10 changelog 2014-11-24 01:00:26 +11:00
Sebastian McKenzie
b8ec87e058 fix Scope::push block type error message 2014-11-24 00:59:56 +11:00
Sebastian McKenzie
04bd023787 add support for AssignmentExpression destructuring outside of ExpressionStatement 2014-11-24 00:56:06 +11:00
Sebastian McKenzie
f1759dc419 v1.13.9 2014-11-24 00:48:05 +11:00
Sebastian McKenzie
2985f1b40b fix VirtualPropertyExpression visitor keys - fixes #207 2014-11-24 00:47:10 +11:00
Sebastian McKenzie
14d1b6701e v1.13.8 2014-11-24 00:37:33 +11:00
Sebastian McKenzie
eb3cc9ff07 remove unused variables 2014-11-24 00:36:36 +11:00
Sebastian McKenzie
b97a2bd61d reorder object spread/rest 2014-11-24 00:35:39 +11:00
Sebastian McKenzie
49e7e3b998 fix multiple references in experimental abstract references #207 2014-11-24 00:35:18 +11:00
Sebastian McKenzie
11ac6ff084 v1.13.7 2014-11-23 22:57:30 +11:00
Sebastian McKenzie
54e7e495ac add 1.13.7 changelog 2014-11-23 22:56:13 +11:00
Sebastian McKenzie
fafdb1a18a add exponentiation operator 2014-11-23 22:55:20 +11:00
Sebastian McKenzie
b599e2c794 v1.13.6 2014-11-23 21:51:31 +11:00
Sebastian McKenzie
7f57d3d6a2 fix experimental object spread/rest helper 2014-11-23 21:50:49 +11:00
Sebastian McKenzie
a2b0ee6809 v1.13.5 2014-11-23 21:47:20 +11:00
Sebastian McKenzie
83e8c4bddd bump acorn-6to5 version 2014-11-23 21:46:07 +11:00
Sebastian McKenzie
57aca3c77f add 1.13.5 changelog 2014-11-23 21:45:18 +11:00
Sebastian McKenzie
f80527832c remove unused variables 2014-11-23 21:45:10 +11:00
Sebastian McKenzie
2ecceaac45 add VirtualPropertyExpression generator test 2014-11-23 21:43:39 +11:00
Sebastian McKenzie
32f8f9e663 change arguments to array to an additional faster helper method 2014-11-23 21:43:28 +11:00
Sebastian McKenzie
3447204d97 add experimental es7 object spread/rest - closes #200 2014-11-23 21:43:01 +11:00
Sebastian McKenzie
c500532469 v1.13.4 2014-11-23 20:17:14 +11:00
Sebastian McKenzie
3396cc84f1 fix spread not returning a new array with a single spread element 2014-11-23 20:16:10 +11:00
Sebastian McKenzie
1de4893a69 v1.13.3 2014-11-23 18:51:53 +11:00
Sebastian McKenzie
abba930f36 update sequence expression generator test 2014-11-23 18:51:07 +11:00
Sebastian McKenzie
c84097cf57 fix bin/6to5-node experimental option 2014-11-23 18:49:56 +11:00
Sebastian McKenzie
790b81938c fix Node::isUserWhitespacable 2014-11-23 18:47:38 +11:00
Sebastian McKenzie
187bbca731 add 1.13.3 changelog 2014-11-23 18:46:56 +11:00
Sebastian McKenzie
4ccc12b04d simplify Node::isUserWhitespacable method 2014-11-23 18:46:49 +11:00
Sebastian McKenzie
9a5f97d85b fix jshint errors 2014-11-23 18:46:30 +11:00
Sebastian McKenzie
4ed77e136b Merge branch 'abstract-references' 2014-11-23 18:38:24 +11:00
Sebastian McKenzie
0339d21c33 add WeakMap existence check to symbol polyfilling 2014-11-23 18:37:43 +11:00
Sebastian McKenzie
4502aee988 add support for call expression abstract references and more versatile tests 2014-11-23 18:37:30 +11:00
Sebastian McKenzie
55150853b4 remove SequenceExpression user whitespace 2014-11-23 18:36:57 +11:00
Sebastian McKenzie
b9da4f988c upgrade acorn-6to5 2014-11-23 18:36:38 +11:00
Sebastian McKenzie
bf0ca10253 add abstract reference CallExpression base 2014-11-23 16:54:51 +11:00
Sebastian McKenzie
fcc4734a1f complete abstract references support - parser support left 2014-11-23 16:47:13 +11:00
Sebastian McKenzie
d1c5c773fa make experimental warning more scary 2014-11-23 16:21:42 +11:00
Sebastian McKenzie
01ce38c5ac Merge branch 'master' into abstract-references 2014-11-23 16:17:56 +11:00
Sebastian McKenzie
cc6d440f0e update classes and destructuring test names 2014-11-23 16:17:49 +11:00
Sebastian McKenzie
2b21f4b571 Merge branch 'master' into abstract-references
Conflicts:
	lib/6to5/polyfill.js
2014-11-23 16:17:10 +11:00
Sebastian McKenzie
24d9833170 better categorisation of transformers 2014-11-23 16:15:39 +11:00
Sebastian McKenzie
20f21987de fix travis badge branch 2014-11-23 16:09:13 +11:00
Sebastian McKenzie
fad0be8a45 add spec references 2014-11-23 16:08:54 +11:00
Sebastian McKenzie
02c42b94f5 Add abstract references base #205 2014-11-23 16:04:25 +11:00
Sebastian McKenzie
4808689795 add support link to readme 2014-11-23 15:30:37 +11:00
Sebastian McKenzie
6231dceb1c clarify polyfill usage 2014-11-23 15:29:21 +11:00
Sebastian McKenzie
1753afa782 rename no runtime to optional runtime in differences table 2014-11-23 15:18:00 +11:00
Sebastian McKenzie
4097da09bd clarify polyfill usage 2014-11-23 15:17:49 +11:00
Sebastian McKenzie
c7965df42d update esutils and es6-shim 2014-11-23 15:16:42 +11:00
Sebastian McKenzie
1027f8a5a4 use slice helper on arguments instead of toArray 2014-11-23 13:09:31 +11:00
Sebastian McKenzie
cbd6be30bf v1.13.2 2014-11-23 12:02:26 +11:00
Sebastian McKenzie
7e299470fd remove unused variables 2014-11-23 12:01:19 +11:00
Sebastian McKenzie
c794c2aede upgrade acorn-6to5 2014-11-23 11:59:57 +11:00
Sebastian McKenzie
1a58087460 use toArray inline helper instead of Array.from #203 #199 2014-11-23 11:59:18 +11:00
Sebastian McKenzie
44f6fc67f8 v1.13.1 2014-11-23 01:17:14 +11:00
Sebastian McKenzie
e4a3d222d6 fix constructor spread optimisation - thanks @zloirock 2014-11-23 01:16:09 +11:00
Sebastian McKenzie
5a96c2e015 v1.13.0 2014-11-22 23:46:00 +11:00
Sebastian McKenzie
43390c0d1f add experimental usage note about proposal changes 2014-11-22 23:45:05 +11:00
Sebastian McKenzie
d166656149 add constructor spread caveat and add additional Array.from cases 2014-11-22 23:44:47 +11:00
Sebastian McKenzie
acc4d289e4 link straight to caveats in no runtime on doc index 2014-11-22 23:44:28 +11:00
Sebastian McKenzie
717e6df407 use Array.from on single block array comprehensions - closes #199 2014-11-22 23:44:12 +11:00
Sebastian McKenzie
286404c6f2 update changelog for 1.13.0 2014-11-22 23:33:06 +11:00
Sebastian McKenzie
f191fd7883 update #203 test 2014-11-22 23:32:03 +11:00
Sebastian McKenzie
74f36cfaa0 Merge pull request #202 from RReverser/webworker-runtime
Fix runtime injection in Web Worker.
2014-11-22 23:29:07 +11:00
Sebastian McKenzie
71aed8b269 Merge branch 'ctor-spread-speedup' of https://github.com/RReverser/6to5 2014-11-22 23:28:06 +11:00
Sebastian McKenzie
9e6b0b45b3 Revert "Merge pull request #203 from RReverser/ctor-spread-speedup"
This reverts commit 714ca9fbc8, reversing
changes made to d50d4972a7.
2014-11-22 23:27:39 +11:00
Sebastian McKenzie
7bbb3725d4 bump next release version 2014-11-22 23:26:39 +11:00
Sebastian McKenzie
1210c92405 remove hound.yml 2014-11-22 23:26:39 +11:00
Sebastian McKenzie
714ca9fbc8 Merge pull request #203 from RReverser/ctor-spread-speedup
Speed up constructor spreads.
2014-11-22 23:22:53 +11:00
Ingvar Stepanyan
60713f0e5f Speed up constructor spreads.
Replace slow .bind with manual .create+.apply.
Gives up to 19x speed up depending on browser.

http://jsperf.com/apply-constructor
2014-11-22 14:22:50 +02:00
Ingvar Stepanyan
f1f5f8bb27 Speed up constructor spreads.
Replace slow .bind with manual .create+.apply.
Gives up to 19x speed up depending on browser.

http://jsperf.com/apply-constructor
2014-11-22 14:20:55 +02:00
Ingvar Stepanyan
a69f095720 Fix runtime injection in Web Worker.
Web Workers don't have `window` object but they have `self`
(which is available in regular windows as well).
2014-11-22 14:14:42 +02:00
Sebastian McKenzie
d50d4972a7 use experimental option in generation tests 2014-11-21 19:40:05 +11:00
Sebastian McKenzie
bd91bbee71 put experimental ES7 features behind a flag --experimental and experimental option 2014-11-21 19:36:35 +11:00
Sebastian McKenzie
8b46cce466 v1.12.26 2014-11-21 17:10:54 +11:00
Sebastian McKenzie
defa9108bd support computed property destructuring 2014-11-21 17:09:31 +11:00
Sebastian McKenzie
6b1d9b49b7 use generateUidIdentifier over the long form 2014-11-21 17:09:15 +11:00
Sebastian McKenzie
4e333cf357 add arrayify and regexify tests, add destructuring assignment expression statement only test 2014-11-21 17:08:56 +11:00
Sebastian McKenzie
ddcd7ab28d v1.12.25 2014-11-20 21:30:08 +11:00
Sebastian McKenzie
4b8a4492ba remove unused Scope variable 2014-11-20 21:29:00 +11:00
Sebastian McKenzie
4256a9960c update acorn-6to5 - fixes #195 2014-11-20 21:28:07 +11:00
Sebastian McKenzie
ecb695c30c add 1.12.25 changelog 2014-11-20 21:18:31 +11:00
Sebastian McKenzie
db97f665ed remove scope from generator visitor 2014-11-20 21:18:21 +11:00
Sebastian McKenzie
931b68dc5d use generateUidIdentifier instead of generateUid 2014-11-20 21:18:11 +11:00
Sebastian McKenzie
b5feaf7c2f remove dead code 2014-11-20 21:17:57 +11:00
Sebastian McKenzie
d82683f598 remova via regenerator from features 2014-11-20 21:10:35 +11:00
Sebastian McKenzie
6772f5a74f update ast-types, es6-shim, chokidar, estraverse and private 2014-11-20 21:10:23 +11:00
Sebastian McKenzie
a90f133918 update Scope arguments 2014-11-20 21:09:38 +11:00
Sebastian McKenzie
71ad511322 add File::generateUidIdentifier method 2014-11-20 21:08:33 +11:00
Sebastian McKenzie
ff6677a4b7 v1.12.24 2014-11-20 16:56:29 +11:00
Sebastian McKenzie
ac5e0ad392 add changelog for 1.12.24 2014-11-20 16:54:46 +11:00
Sebastian McKenzie
0a25618c34 collect references that haven't been declared in scope - fixes #173 and fixes #175 2014-11-20 16:53:22 +11:00
Sebastian McKenzie
984c048591 v1.12.23 2014-11-20 16:03:53 +11:00
Sebastian McKenzie
5867e24886 remove unused variables 2014-11-20 16:02:56 +11:00
Sebastian McKenzie
02d7cdc701 changelog for 1.12.23 2014-11-20 16:02:15 +11:00
Sebastian McKenzie
d3b3febfeb finish missing code examples in features 2014-11-20 16:02:10 +11:00
Sebastian McKenzie
7fccf98c10 small performance improvements 2014-11-20 15:09:20 +11:00
Sebastian McKenzie
4a1c393bdb inherit generator comments and add block hoisting - fixes #196 2014-11-20 15:09:07 +11:00
Sebastian McKenzie
afaf3fb0c0 v1.12.22 2014-11-20 00:51:26 +11:00
Sebastian McKenzie
2152ae9b17 remove unused kind variable 2014-11-20 00:50:18 +11:00
Sebastian McKenzie
b8f5693b5e add 1.12.22 changelog 2014-11-20 00:49:27 +11:00
Sebastian McKenzie
638143700b add whitespace around defineArgs 2014-11-20 00:49:12 +11:00
Sebastian McKenzie
aa7eb9c1c9 remove unused opts arg 2014-11-20 00:49:01 +11:00
Sebastian McKenzie
27ca532896 add 1.12.22 changelog 2014-11-20 00:44:12 +11:00
Sebastian McKenzie
913fbdbd87 Merge pull request #190 from webpro/amd-module-id
Make AMD module id's optional
2014-11-20 00:42:53 +11:00
Sebastian McKenzie
fb39df71eb support array destructuring on iterables - fixes #194 2014-11-19 21:10:40 +11:00
Sebastian McKenzie
102a566b1d ensure newlines at end of transformation tests 2014-11-19 21:09:50 +11:00
Lars Kappert
b924e3deb5 Rename to "--amd-module-ids" 2014-11-19 08:55:16 +01:00
Lars Kappert
ef21724a9c Update docs 2014-11-19 08:52:33 +01:00
Lars Kappert
fdad51b53b Revert "update umd and amd tests with new moduleName option"
This reverts commit 5409691a3a.
2014-11-19 08:45:58 +01:00
Lars Kappert
df0e4f6431 Reuse Formatter::getModuleName(), fix opts 2014-11-19 08:43:28 +01:00
Lars Kappert
a37f2093bc Merge branch 'master' of github.com:6to5/6to5 into amd-module-id
Conflicts:
	lib/6to5/file.js
	lib/6to5/transformation/modules/umd.js
2014-11-19 08:39:02 +01:00
Sebastian McKenzie
32b32329b2 make umd module formatter inherit amd constructor 2014-11-19 17:50:42 +11:00
Sebastian McKenzie
d4379d52a7 split up generator transformer emit and explode 2014-11-19 17:48:59 +11:00
Sebastian McKenzie
5c5d811647 bump chokidar and fs-readdir-recursive versions 2014-11-19 17:18:16 +11:00
Sebastian McKenzie
8feb17dd23 normalise whitespace after function keyword 2014-11-19 17:18:05 +11:00
Sebastian McKenzie
55b3f84a2f add sourceRoot and moduleRoot defaults to docs 2014-11-19 13:51:01 +11:00
Sebastian McKenzie
50dee1a754 v1.12.21 2014-11-19 13:49:35 +11:00
Sebastian McKenzie
f80f860bbc changelog for 1.12.21 2014-11-19 13:48:09 +11:00
Sebastian McKenzie
7fc2fe41af fix bug in let scoping resulting in unneccesary replacement - closes #193, closes #185 2014-11-19 13:46:00 +11:00
Sebastian McKenzie
a884a26402 revert acorn-6to5 2014-11-19 13:28:01 +11:00
Sebastian McKenzie
81ec1e1f42 remove unused variable in generators/meta 2014-11-19 12:54:54 +11:00
Sebastian McKenzie
1a27970376 publish acorn-6to5 as an npm package - fixes #187 2014-11-19 12:51:14 +11:00
Sebastian McKenzie
6822c854d4 add interop-require declaration 2014-11-19 12:40:44 +11:00
Sebastian McKenzie
8f4c4be821 generator: add existence check to printJoin 2014-11-19 12:40:35 +11:00
Sebastian McKenzie
5fca095149 use commonInterop module formatter in 6to5/register 2014-11-19 12:40:23 +11:00
Sebastian McKenzie
34599a21cb clean up common-interop module formatter 2014-11-19 12:40:10 +11:00
Sebastian McKenzie
d9d84c60b5 check for existence of node before checking it in let scoping 2014-11-19 12:13:00 +11:00
Sebastian McKenzie
221d78d2e2 arrayify whitelist and blacklist, inherit moduleRoot from sourceRoot and vice versa 2014-11-19 12:13:00 +11:00
Sebastian McKenzie
fa46f60655 expose util as _util 2014-11-19 12:13:00 +11:00
Sebastian McKenzie
03ce52fb7c use regexify and arrayify in register options 2014-11-19 12:13:00 +11:00
Sebastian McKenzie
0df0c696a9 add util.arrayify and util.regexify 2014-11-19 12:12:59 +11:00
Sebastian McKenzie
21b7f4120e add assertion checks into types 2014-11-19 12:12:59 +11:00
Sebastian McKenzie
f43a3dec4b more regenerator spring cleaning 2014-11-19 12:12:59 +11:00
Sebastian McKenzie
cacee5c625 Merge pull request #191 from Naddiseo/commonjs-interop
Added an interop commonjs loader.
2014-11-19 12:09:00 +11:00
Sebastian McKenzie
553c90ae75 Merge pull request #192 from Naddiseo/function-modules
Allow module transformers to be directly passed into opts.
2014-11-19 12:06:02 +11:00
Richard Eames
bc3502d695 Allow module transformers to be directly passed into opts. 2014-11-18 15:29:59 -07:00
Richard Eames
6ae03a5dce Added an interop commonjs loader. 2014-11-18 15:25:12 -07:00
Lars Kappert
9895711bf4 Improve performance 2014-11-18 22:15:02 +01:00
Lars Kappert
d2724554cc Make module id's for AMD body in UMD optional as well 2014-11-18 22:12:03 +01:00
Lars Kappert
8db466c698 Make AMD module id's optional 2014-11-18 22:04:41 +01:00
Sebastian McKenzie
68ef2d545e Merge pull request #188 from brentburg/webpack-return
Webpack doesn't like return outside of a function in a module
2014-11-19 01:14:07 +11:00
Brent Burgoyne
861b9e68d3 Deleted uneeded _runtime.js 2014-11-18 07:13:12 -07:00
Brent Burgoyne
a0eb108cd4 Remove global existence check 2014-11-18 07:10:47 -07:00
Brent Burgoyne
756aef6adc Instead of returning early, conditionally require actual runtime (./_runtime.js)
Fix this error with webpack:

ERROR in ./~/6to5/lib/6to5/transformation/transformers/generators/runtime.js
Module parse failed: /[...]/node_modules/6to5/lib/6to5/transformation/transformers/generators/runtime.js Line 12: Illegal return statement
You may need an appropriate loader to handle this file type.
|
| if (typeof global.regeneratorRuntime === "object") {
  |   return;
  |
}
|
 @ ./~/6to5/lib/6to5/polyfill.js 6:0-59
2014-11-18 06:55:39 -07:00
Sebastian McKenzie
7b74c1c8ec more generator spring cleaning 2014-11-17 17:30:41 +11:00
Sebastian McKenzie
8e115ef3ed regenerator spring cleaning 2014-11-17 17:04:04 +11:00
Sebastian McKenzie
b9a6cf35b7 Merge pull request #184 from thejameskyle/support-table
Sort comparison table by most es6 support and split into two groups
2014-11-17 16:50:24 +11:00
James Kyle
2e22de71b4 Sort comparison table by most es6 support and split into two groups 2014-11-16 21:49:19 -08:00
Sebastian McKenzie
a077c75c8c v1.12.20 2014-11-17 14:24:31 +11:00
Sebastian McKenzie
c0b03e8126 append sourceMappingURL when using bin/6to5 and output sourcemaps - fixes #183 2014-11-17 14:22:25 +11:00
Sebastian McKenzie
a3a4a7645c v1.12.19 2014-11-17 14:10:10 +11:00
Sebastian McKenzie
7bd1337ee8 clean up weird regenerator formatting, only one instance, heaps more to go! 2014-11-17 13:56:42 +11:00
Sebastian McKenzie
c54f530b10 fix up duplicate variables in regenerator 2014-11-17 12:48:35 +11:00
Sebastian McKenzie
9d3a3a57f2 fix up generator normaliseOptions 2014-11-17 12:39:01 +11:00
Sebastian McKenzie
e1474c2f5f add 1.12.19 changelog 2014-11-17 12:00:05 +11:00
Sebastian McKenzie
8a9a205122 fix up comments option 2014-11-17 11:59:52 +11:00
Sebastian McKenzie
885d65f9de Merge pull request #179 from webpro/remove-comments
Remove comments
2014-11-17 11:54:41 +11:00
Sebastian McKenzie
43d1435c97 Merge pull request #180 from SimonDegraeve/add-jsxhint-plugin
Add JSXHint in the plugins list.
2014-11-17 11:47:47 +11:00
Simon Degraeve
247c14c5ab Add JSXHint in the plugins list. 2014-11-17 08:19:49 +08:00
Lars Kappert
0e2b12c134 Separate comments and comments setting 2014-11-16 21:11:43 +01:00
Lars Kappert
59c5abe188 Exclude comments from generated code 2014-11-16 20:33:50 +01:00
Lars Kappert
e1cc1dcb4b Introduce --remove-comments (-c) option 2014-11-16 20:33:50 +01:00
Sebastian McKenzie
d091793077 add generator support let scoping - fixes #178 2014-11-17 04:09:48 +11:00
Sebastian McKenzie
e6baac1003 move regenerator into main repo so we can iterate on it faster and make a bunch of additional changes 2014-11-17 04:09:29 +11:00
Sebastian McKenzie
c41608edc3 add gobble to plugins 2014-11-17 04:04:02 +11:00
Sebastian McKenzie
3815913537 v1.12.18 2014-11-16 21:01:12 +11:00
Sebastian McKenzie
e5c18749f0 add changelog for 1.12.18 2014-11-16 21:00:00 +11:00
Sebastian McKenzie
b7458f949c Merge pull request #177 from josh/browser-global
Prefer module provided `global` rather than `window` reference
2014-11-16 20:58:12 +11:00
Sebastian McKenzie
69302b314f add sprockets-es6 to plugins 2014-11-16 20:55:56 +11:00
Joshua Peek
0c57a00fdb Check if attachEvent is defined 2014-11-16 01:41:56 -08:00
Joshua Peek
3bec8b0311 Prefer module global reference rather than window 2014-11-16 01:41:16 -08:00
Sebastian McKenzie
6a88e05362 v1.12.17 2014-11-16 19:29:25 +11:00
Sebastian McKenzie
e3bd2dff8d remove unused path variable 2014-11-16 19:27:49 +11:00
Sebastian McKenzie
ef82171254 update amd/umd modules documentation 2014-11-16 19:27:15 +11:00
Sebastian McKenzie
00d94fd810 update changelog with additional new options 2014-11-16 19:26:03 +11:00
Sebastian McKenzie
d929d3c5eb remove duplicate i variable from traverse 2014-11-16 19:24:58 +11:00
Sebastian McKenzie
5c1ee86b97 remove filenameRelative from bin/6to5* since it's unneccesary 2014-11-16 19:24:47 +11:00
Sebastian McKenzie
5409691a3a update umd and amd tests with new moduleName option 2014-11-16 19:22:37 +11:00
Sebastian McKenzie
24964ac454 add filenameRelative to bin/6to5* 2014-11-16 19:20:08 +11:00
Sebastian McKenzie
faa81ab85b add 1.12.17 changelog 2014-11-16 19:19:57 +11:00
Sebastian McKenzie
d4bc082bb9 add new filenameRelative, sourceRoot and moduleRoot option documentation 2014-11-16 19:19:46 +11:00
Sebastian McKenzie
3777af6bbd add filenameRelative default and make sourceFileName and sourceMapName inherit form it 2014-11-16 19:19:25 +11:00
Sebastian McKenzie
1f258e9e9c add sourceRoot to source map 2014-11-16 19:19:07 +11:00
Sebastian McKenzie
50333c879c add comments and change single quotes in amd formatter getModuleName 2014-11-16 19:18:56 +11:00
Sebastian McKenzie
105e6ac379 add filenameRelative to tests 2014-11-16 19:18:30 +11:00
Sebastian McKenzie
dadab64e39 Merge pull request #176 from darvelo/master
Generate moduleNames for AMD/UMD
2014-11-16 19:00:56 +11:00
Sebastian McKenzie
2b82f2bcc2 ignore unknown nodes in traversal 2014-11-16 18:52:54 +11:00
Sebastian McKenzie
f1183505b1 optimise traverse, improves traversal speed by 50% 2014-11-16 18:50:07 +11:00
Sebastian McKenzie
fa3b24e5b4 don't lazy set templates, can't even remember why i did this 2014-11-16 18:49:29 +11:00
Sebastian McKenzie
5789447068 add loc option to exec test 2014-11-16 18:48:32 +11:00
David Arvelo
f1f7321590 Generate moduleNames for AMD/UMD 2014-11-16 02:38:00 -05:00
Sebastian McKenzie
9ff4df6dae v1.12.16 2014-11-16 14:39:15 +11:00
Sebastian McKenzie
0dbb24c922 remove unused i variable in default parameters transformer 2014-11-16 14:37:26 +11:00
Sebastian McKenzie
a027d2b9cf add 1.12.16 changelog 2014-11-16 14:34:42 +11:00
Sebastian McKenzie
e290990371 scope: remove unused references instance property 2014-11-16 14:34:29 +11:00
Sebastian McKenzie
d0a2bd170e clean up constants transformer 2014-11-16 14:33:37 +11:00
Sebastian McKenzie
69db46f96b move down and clump constants and let scoping transformer positions 2014-11-16 14:33:29 +11:00
Sebastian McKenzie
27ba4b2bba scope: switch over declaration building to info so we can build multiple things 2014-11-16 14:33:16 +11:00
Sebastian McKenzie
b337c1ab06 test/transformation: use full location as filename 2014-11-16 14:32:40 +11:00
Sebastian McKenzie
a1895b4bb4 implement temporal dead zone for default parameters - fixes #169 2014-11-16 14:32:03 +11:00
Sebastian McKenzie
00483917f0 fix comments not being retained from MethodDefinition in classes 2014-11-16 11:30:05 +11:00
Sebastian McKenzie
d09bafaf8c Merge pull request #172 from thejameskyle/docs-whitespace
Add newline to keep marked from parsing incorrectly
2014-11-16 10:32:04 +11:00
James Kyle
a7ef02c781 Add newline to keep marked from parsing incorrectly 2014-11-15 15:31:16 -08:00
Sebastian McKenzie
94cd45c269 v1.12.15 2014-11-15 11:42:06 +11:00
Sebastian McKenzie
424bab97d0 update acorn-6to5 - fixes #165 2014-11-15 11:40:34 +11:00
Sebastian McKenzie
a1bdd804e2 v1.12.14 2014-11-15 11:30:37 +11:00
Sebastian McKenzie
10c051890b fix changelog version 2014-11-15 11:29:41 +11:00
Sebastian McKenzie
ac49d0a335 v1.12.4 2014-11-15 11:29:06 +11:00
Sebastian McKenzie
b56f1800e5 update regenerator-6to5 2014-11-15 11:27:29 +11:00
Sebastian McKenzie
49ef92c586 add changelog for v1.12.4 2014-11-15 11:23:42 +11:00
Sebastian McKenzie
542fe89123 fix up tests to work with new member expression keyword generator 2014-11-15 11:23:16 +11:00
Sebastian McKenzie
5b118c0c3f add _property-literals test 2014-11-15 11:13:10 +11:00
Sebastian McKenzie
8503916799 add _memberExpressionKeywords transformer that turns keyword identifiers to computed literals 2014-11-15 11:13:02 +11:00
Sebastian McKenzie
206c828a56 more react compliant whitespace - #165 2014-11-15 11:00:32 +11:00
Sebastian McKenzie
7a261a1db1 fix duplicate let scoping in functions - fixes #166 2014-11-15 09:47:48 +11:00
Sebastian McKenzie
c9d9a085f1 v1.12.13 2014-11-15 03:08:35 +11:00
Sebastian McKenzie
6d1953d9c3 fix constants transformer not accurately checking nodes 2014-11-15 03:07:33 +11:00
Sebastian McKenzie
92621d71c7 remove unused variable 2014-11-15 03:01:58 +11:00
Sebastian McKenzie
dc01731c25 add changelog for 1.12.13 2014-11-15 03:01:01 +11:00
Sebastian McKenzie
9fb8a80f60 support raw property on tagged template literals - closes #164 2014-11-15 03:00:53 +11:00
Sebastian McKenzie
85c2de57e4 fix for-head duplication testing and replacement - fixes #162 2014-11-15 02:50:05 +11:00
Sebastian McKenzie
58fac2e2be support duplicate constants within different block scopes - fixes #161 2014-11-15 02:49:49 +11:00
Sebastian McKenzie
682806f1ca instead of ignoring dot tests, add them as pending 2014-11-15 02:49:28 +11:00
Sebastian McKenzie
47c6f74251 v1.12.12 2014-11-14 23:15:14 +11:00
Sebastian McKenzie
37f360c72d make scope tracker more reliable to handle all edgecases 2014-11-14 23:13:58 +11:00
Sebastian McKenzie
e5a8c95b62 v1.12.11 2014-11-14 19:39:25 +11:00
Sebastian McKenzie
921d459f13 fix transformation let scoping hoisting test 2014-11-14 19:38:29 +11:00
Sebastian McKenzie
58898932e6 shift letScoping to before forOf transformer 2014-11-14 19:35:07 +11:00
Sebastian McKenzie
c7b45116c4 fix generation of integer Literals in MemberExpression 2014-11-14 19:34:54 +11:00
Sebastian McKenzie
32ddd638ba Revert "expose moduleName option - closes #158"
This reverts commit fdd1451d53.
2014-11-14 18:33:11 +11:00
Sebastian McKenzie
0eb3cda2d4 add 1.12.11 changelog 2014-11-14 17:20:05 +11:00
Sebastian McKenzie
2acb24d43d block scope classes 2014-11-14 17:19:46 +11:00
Sebastian McKenzie
fdd1451d53 expose moduleName option - closes #158 2014-11-14 17:19:39 +11:00
Sebastian McKenzie
43e2f121a6 remove nodes replacing in util.template 2014-11-14 09:28:23 +11:00
Sebastian McKenzie
297e55ba63 Revert "fix up types.toStatement and return an expressionStatement if all else fails"
This reverts commit 740193b1e2.
2014-11-14 09:28:04 +11:00
Sebastian McKenzie
38396dadd5 remove unused nodes.inherits in util.template 2014-11-14 09:15:29 +11:00
Sebastian McKenzie
f75f045026 turn custom runtime into a proper identifier 2014-11-14 09:15:00 +11:00
Sebastian McKenzie
740193b1e2 fix up types.toStatement and return an expressionStatement if all else fails 2014-11-14 09:14:49 +11:00
Sebastian McKenzie
b9fe1475c2 add basic api test 2014-11-14 09:13:00 +11:00
Sebastian McKenzie
6065220f9b add runtime test 2014-11-14 09:12:54 +11:00
Sebastian McKenzie
715884662e fix basic unicode-regex test 2014-11-14 09:12:49 +11:00
Sebastian McKenzie
11780c28ff add let scoping hoisting test 2014-11-14 09:12:38 +11:00
Sebastian McKenzie
215c2da7cb v1.12.10 2014-11-14 07:40:41 +11:00
Sebastian McKenzie
c7c41d6548 add changelog for 1.12.10 2014-11-14 07:39:06 +11:00
Sebastian McKenzie
695571b435 fix LetScoping::pushDeclar - fixes #156 2014-11-14 07:34:50 +11:00
Sebastian McKenzie
f845633cc1 v1.12.9 2014-11-14 02:24:08 +11:00
Sebastian McKenzie
72c9b1d6c9 remove redundant changelog message 2014-11-14 02:23:23 +11:00
Sebastian McKenzie
edd3363e48 fix unicode regex test escaping 2014-11-14 02:23:12 +11:00
Sebastian McKenzie
114b5ef9ec add changelog for 1.12.9 2014-11-14 02:20:15 +11:00
Sebastian McKenzie
2f4e0c3361 escape unicode characters - fixes #154 2014-11-14 02:17:06 +11:00
Sebastian McKenzie
3ee51dae1a fix semicolon 2014-11-14 00:59:18 +11:00
Sebastian McKenzie
20263c1151 fix newline in let-scoping/for-break-continue-return test 2014-11-14 00:55:39 +11:00
Sebastian McKenzie
eaac564f11 add toIdentifier, toBlock and toStatement tests 2014-11-14 00:55:22 +11:00
Sebastian McKenzie
63a47ef7bb optimise types.toStatement for when we're directly passed a statement 2014-11-14 00:55:14 +11:00
Sebastian McKenzie
6963cc1e40 fix WithStatement missing paranthesis 2014-11-14 00:54:58 +11:00
Sebastian McKenzie
5eb2462e29 fix up semicolons for module ExportDeclaration generator 2014-11-14 00:54:28 +11:00
Sebastian McKenzie
9e285cdc20 remove unneccesary Literal generator raw 2014-11-14 00:54:12 +11:00
Sebastian McKenzie
01ade47af9 add single spread test 2014-11-14 00:54:00 +11:00
Sebastian McKenzie
b1fe449b0d allow XJSElement and SequenceExpression to be user whitespacable 2014-11-14 00:53:45 +11:00
Sebastian McKenzie
2b458ec2d4 make it illegal to use destructuring outside of an ExpressionStatement 2014-11-14 00:53:10 +11:00
Sebastian McKenzie
d5f47f4f4d generator: correctly output XJSEmptyExpression 2014-11-14 00:52:49 +11:00
Sebastian McKenzie
d4deb18975 support async functions in generator and move MethodDefinition to class generator 2014-11-14 00:52:36 +11:00
Sebastian McKenzie
5a794db73b fix up let scoping transformer comments 2014-11-14 00:52:15 +11:00
Sebastian McKenzie
dc131f05a8 add comprehensive generation tests 2014-11-14 00:51:59 +11:00
Sebastian McKenzie
1d4f79790a add brief usage to doc/index.md - thanks @gabrielecirulli ❤️ 2014-11-13 23:31:51 +11:00
Sebastian McKenzie
6bcbaf6df1 better feature code examples 2014-11-13 19:00:08 +11:00
Sebastian McKenzie
bc199ef0c9 better api documentation 2014-11-13 18:59:59 +11:00
Sebastian McKenzie
f5fed99c81 better 6to5 tagline 2014-11-13 18:59:46 +11:00
Sebastian McKenzie
66a6d3cffe add CONTRIBUTING.md 2014-11-13 18:59:29 +11:00
Sebastian McKenzie
39227486a6 add async to caveats 2014-11-13 14:47:39 +11:00
Sebastian McKenzie
caafa31df1 chagne ES6 to ES6+ when talking about 6to5 support 2014-11-13 14:47:32 +11:00
Sebastian McKenzie
4c41c904f5 v1.12.8 2014-11-13 13:42:54 +11:00
Sebastian McKenzie
0917a6a5b1 better destructuring AssignmentExpression error message 2014-11-13 13:42:18 +11:00
Sebastian McKenzie
349eba33ce add async functions to traceur differences 2014-11-13 13:40:54 +11:00
Sebastian McKenzie
8ff21b407d temporarily forbid AssignmentExpression destructuring outside of ExpressionStatement 2014-11-13 13:40:41 +11:00
Sebastian McKenzie
751ea7a12c v1.12.7 2014-11-13 13:19:45 +11:00
Sebastian McKenzie
b30cd227cc update acorn-6to5 - fixes #153 2014-11-13 13:18:59 +11:00
Sebastian McKenzie
18dc7b8143 v1.12.6 2014-11-13 12:55:39 +11:00
Sebastian McKenzie
1c628bbec1 disable generation/comments/comment-only test 2014-11-13 12:53:38 +11:00
Sebastian McKenzie
d4c3dde02a update to latest acorn-6to5 2014-11-13 12:49:29 +11:00
Sebastian McKenzie
a587106a6b v1.12.5 2014-11-13 12:26:16 +11:00
Sebastian McKenzie
9c1b60e451 fix excessive whitespace trimming resulting in innaccurate sourcemap line - fixes #151 2014-11-13 12:25:11 +11:00
Sebastian McKenzie
0c7e0b65b9 add browser support, array comprehension, async functions and generator comprehension to differences table 2014-11-13 03:24:45 +11:00
Sebastian McKenzie
5c17091db4 replace documentation link 2014-11-13 01:17:14 +11:00
Sebastian McKenzie
7fa5ba88df v1.12.4 2014-11-13 01:16:45 +11:00
Sebastian McKenzie
2fae245cd5 add 1.12.4 changelog 2014-11-13 01:15:41 +11:00
Sebastian McKenzie
297f103ddb move docs to folder 2014-11-13 01:13:48 +11:00
Sebastian McKenzie
fd63650d6a add .hound.yml 2014-11-12 19:25:35 +11:00
Sebastian McKenzie
e13ed39567 v1.12.3 2014-11-12 18:43:39 +11:00
Sebastian McKenzie
bb00f641b7 remove unused variables in spread transformer 2014-11-12 18:42:24 +11:00
Sebastian McKenzie
25b466a627 remove unused variables 2014-11-12 18:39:50 +11:00
Sebastian McKenzie
ac231f2987 add 1.12.3 changelog 2014-11-12 18:38:39 +11:00
Sebastian McKenzie
458e3d48f6 use Array.from instead of Array.prototype.slice in spread transformer and support NewExpression spreads - fixes #148 2014-11-12 18:38:30 +11:00
Sebastian McKenzie
c235780611 move down 6to5-node util declaration 2014-11-12 18:37:32 +11:00
Sebastian McKenzie
56b858ccb1 add generator comprehension transformer 2014-11-12 18:29:41 +11:00
Sebastian McKenzie
d42351bb02 add default parameters existence change to well... the defaultParameters transformer 2014-11-12 18:29:27 +11:00
Sebastian McKenzie
ed7378cc2d add apply-constructor declaration and add support for not returning generated code in opts.code 2014-11-12 18:29:03 +11:00
Sebastian McKenzie
a47a7dc347 rename util.parseNoProperties to util.parseTemplate 2014-11-12 18:28:11 +11:00
Sebastian McKenzie
2c82b5a4b0 add generator option to FunctionExpression builder keys 2014-11-12 18:27:56 +11:00
Sebastian McKenzie
3578135b90 add spread caveat and add generator comprehension and react/jsx to features 2014-11-12 18:27:05 +11:00
Sebastian McKenzie
5f3408b2a2 upgrade regenerator-6to5 2014-11-12 18:26:29 +11:00
Sebastian McKenzie
9e3f9fda6b add support for generator comprehensions - fixes #149 2014-11-12 18:26:22 +11:00
Sebastian McKenzie
7f425d2c6e v1.12.2 2014-11-12 12:22:03 +11:00
Sebastian McKenzie
311a8e042b add missing semicolon 2014-11-12 12:19:25 +11:00
Sebastian McKenzie
27d30329fd add more react spread tests 2014-11-12 12:18:16 +11:00
Sebastian McKenzie
12c5a3e73b add 1.12.2 changelog 2014-11-12 12:17:59 +11:00
Sebastian McKenzie
2a166a6ed1 support jsx spread attributes that aren't the first - fixes #146 2014-11-12 12:17:45 +11:00
Sebastian McKenzie
896929378e add util.trimRight method - fixes #147 2014-11-12 12:17:26 +11:00
Sebastian McKenzie
ae439d27b9 update mocha and browserify 2014-11-12 12:08:33 +11:00
Sebastian McKenzie
e22798261a change useless self references to this 2014-11-12 02:03:46 +11:00
Sebastian McKenzie
d0af8b8d0a remove numeric literals transformer 2014-11-12 02:03:25 +11:00
Sebastian McKenzie
beaa2fa540 add async functions to features 2014-11-12 02:03:11 +11:00
Sebastian McKenzie
b8cac9787e produce new MemberExpression in a CallExpression super identifier instead of mutating the property 2014-11-12 01:51:57 +11:00
Sebastian McKenzie
64f6e4a0c5 clean up classes transformer and add comments 2014-11-12 01:48:55 +11:00
Sebastian McKenzie
c4a7ac5a8b turn classes transformer into a class like let scoping 2014-11-12 01:39:35 +11:00
Sebastian McKenzie
1ed682fa76 fix up jsdoc in let-scoping transformer 2014-11-12 01:39:02 +11:00
Sebastian McKenzie
9987e7fe0e add 1.12.1 changelog 2014-11-12 01:38:50 +11:00
Sebastian McKenzie
e74c7cb0b7 turn the let scoping transformer into a class because it's quite complicated and the logic needs to be WAY more organised 2014-11-12 01:20:51 +11:00
Sebastian McKenzie
2f01e5c3af v1.12.1 2014-11-12 00:47:53 +11:00
Sebastian McKenzie
6847211971 fix up aliasFunctions transformer 2014-11-12 00:46:36 +11:00
Sebastian McKenzie
965e246259 add back opts defaults 2014-11-12 00:46:20 +11:00
Sebastian McKenzie
af59eb7d6a fix linting errors 2014-11-12 00:33:39 +11:00
Sebastian McKenzie
def4319058 stop _alias-functions transformer when hitting a function that's not an arrow function - fixes #145 2014-11-12 00:32:30 +11:00
Sebastian McKenzie
d90383b1ba generator: add Buffer class that deals with the actual code output 2014-11-12 00:27:59 +11:00
Sebastian McKenzie
1ac40ee834 remove static whitespace properties in favor of pushing to the dynamic ones 2014-11-12 00:15:31 +11:00
Sebastian McKenzie
3d5d170eff move whitespace and parentheses generation logic into separate files 2014-11-12 00:11:34 +11:00
Sebastian McKenzie
b5bdba46f1 change test-appveyor to test-spec and add test-clean method to clean up after tests 2014-11-11 23:27:01 +11:00
Sebastian McKenzie
c4e162b8e5 add rails to plugins 2014-11-11 22:27:52 +11:00
Sebastian McKenzie
98bc750b05 add mocha to plugins 2014-11-11 22:25:27 +11:00
Sebastian McKenzie
84002ed1ce add jest to plugins 2014-11-11 22:12:26 +11:00
Sebastian McKenzie
aaab2db0ec add react/jsx to readme 2014-11-11 20:06:02 +11:00
Sebastian McKenzie
7f3959444c v1.12.0 2014-11-11 19:14:52 +11:00
Sebastian McKenzie
0ba9216d6f remove unused variables in react transformer 2014-11-11 19:14:00 +11:00
Sebastian McKenzie
6dfe66bce3 add v1.12.0 to changelog 2014-11-11 19:12:44 +11:00
Sebastian McKenzie
9e08a6f084 combine jsx and react transformer so we can make the jsx output correct - #143 2014-11-11 19:11:30 +11:00
Sebastian McKenzie
b9f3f1e2a9 add comment inheriting to types.inherits 2014-11-11 19:10:41 +11:00
Sebastian McKenzie
4f18ed406c v1.11.15 2014-11-11 17:17:08 +11:00
Sebastian McKenzie
4d8e5f728a 1.11.15 2014-11-11 17:16:11 +11:00
Sebastian McKenzie
54857ceac7 fix jsx literal generator - closes #143 2014-11-11 17:15:37 +11:00
Sebastian McKenzie
5b961ea3e7 v1.11.14 2014-11-11 15:35:18 +11:00
Sebastian McKenzie
35b28cf722 more reliable jsx literal whitespace 2014-11-11 15:34:29 +11:00
Sebastian McKenzie
c5bfbf37f0 add 1.11.14 changelog 2014-11-11 15:27:23 +11:00
Sebastian McKenzie
cfee68aa67 jsx: replace all newlines and excess whitespace with spaces - fixes #142 2014-11-11 15:26:25 +11:00
Sebastian McKenzie
7d0dae129c nicer let-scoping switch 2014-11-11 15:25:37 +11:00
Sebastian McKenzie
f9d14fa2ed add runtime, property-literals and shebang tests 2014-11-11 15:25:27 +11:00
Sebastian McKenzie
11d55e661e rename let-scoping tests to traceur-let-scoping and add additional let-scoping tests 2014-11-11 15:25:13 +11:00
Sebastian McKenzie
0544e98fb1 add switch case generated node whitespace 2014-11-11 15:24:40 +11:00
Sebastian McKenzie
59d918ea67 remove unused isArray traverse.hasType 2014-11-11 15:23:52 +11:00
Sebastian McKenzie
b4232699d2 add newline after shebang 2014-11-11 15:23:31 +11:00
Sebastian McKenzie
6bd67ca660 v1.11.13 2014-11-11 14:31:06 +11:00
Sebastian McKenzie
4722c0ce56 add support for escodegen-style format options 2014-11-11 14:30:06 +11:00
Sebastian McKenzie
25a5caa0fc update regenerator-6to5 2014-11-11 14:29:32 +11:00
Sebastian McKenzie
6f05466cf5 normalise windows path separators to unix 2014-11-11 13:36:59 +11:00
Sebastian McKenzie
1ad9edb57c tests/bin: normalise stdout path separators 2014-11-11 13:33:50 +11:00
Sebastian McKenzie
c6ae33c5a2 tests: change all windows line endings to unix ones 2014-11-11 13:30:19 +11:00
Sebastian McKenzie
e0d620b1d5 remove browser-polyfill.js instead of polyfill.js 2014-11-11 13:29:50 +11:00
Sebastian McKenzie
5588bf56eb add CHANGELOG 2014-11-11 13:29:37 +11:00
Sebastian McKenzie
a0e500de6c v1.11.12 2014-11-11 13:14:31 +11:00
Sebastian McKenzie
bf8d9801ce rename browserified polyfill to browser-polyfill - fixes #140 2014-11-11 13:13:10 +11:00
Sebastian McKenzie
68b99a7004 v1.11.11 2014-11-11 13:06:06 +11:00
Sebastian McKenzie
5ae4f8eec7 add AwaitExpression generator 2014-11-11 13:05:07 +11:00
Sebastian McKenzie
d9a3eadad7 move generators transformer to bottom 2014-11-11 13:03:06 +11:00
Sebastian McKenzie
b1cc5419a4 add AwaitExpression visitor keys - fixes #141 2014-11-11 13:02:55 +11:00
Sebastian McKenzie
c6a7a9c401 v1.11.10 2014-11-11 09:48:28 +11:00
Sebastian McKenzie
608df54b02 bump acorn-6to5 version to one that supports async/await - closes #134 2014-11-11 09:47:29 +11:00
Sebastian McKenzie
2ac83ec95b v1.11.9 2014-11-11 08:07:29 +11:00
Sebastian McKenzie
e4596f638d only check string literals in property-literals transformer 2014-11-11 08:06:31 +11:00
Sebastian McKenzie
1425af9b2a v1.11.8 2014-11-11 07:51:43 +11:00
Sebastian McKenzie
9351c6470f bump regenerator version 2014-11-11 07:50:07 +11:00
Sebastian McKenzie
7b8a50509a v1.11.7 2014-11-11 01:07:20 +11:00
Sebastian McKenzie
1400dee0c1 delegate code and opts assurance to File 2014-11-11 01:06:29 +11:00
Sebastian McKenzie
9e2fc6db9c clone options - sindresorhus/grunt-6to5#7 2014-11-11 01:04:39 +11:00
Sebastian McKenzie
aef5b89492 fix appveyor badge 2014-11-10 21:12:30 +11:00
Sebastian McKenzie
e0bf6f698e add appveyor badge to readme 2014-11-10 21:09:09 +11:00
Sebastian McKenzie
1ac459a05d better appveyor make test 2014-11-10 21:09:04 +11:00
Sebastian McKenzie
1b49835b27 v1.11.6 2014-11-10 16:46:40 +11:00
Sebastian McKenzie
db7b6a4972 fix canCompile in readdirFilter in bin/6to5 util 2014-11-10 16:45:30 +11:00
Sebastian McKenzie
79045e15c5 remove second canCompile declaration 2014-11-10 16:42:04 +11:00
Sebastian McKenzie
b7e6d8f998 add appveyor.yml 2014-11-10 16:31:32 +11:00
Sebastian McKenzie
88c6ce4e48 v1.11.5 2014-11-10 13:10:39 +11:00
Sebastian McKenzie
8c97f1d92e allow constant properties to be modified - fixes #131 2014-11-10 13:09:45 +11:00
Sebastian McKenzie
833e8b091b v1.11.4 2014-11-10 13:02:04 +11:00
Sebastian McKenzie
23ebb23944 add missing util declaration to let scoping transformer 2014-11-10 13:00:52 +11:00
Sebastian McKenzie
778cab33d5 move canCompile method to util 2014-11-10 12:59:24 +11:00
Sebastian McKenzie
5849c6af17 add canCompile method to node api 2014-11-10 12:58:44 +11:00
Sebastian McKenzie
bb0655d8f6 move transformer assignment to new Transformer 2014-11-10 08:21:35 +11:00
Sebastian McKenzie
9977a5f614 change gitter travis hook to always 2014-11-10 08:20:18 +11:00
Sebastian McKenzie
9318d63b5c add let-scoping-return template to let scoping transformer 2014-11-10 08:16:47 +11:00
Sebastian McKenzie
b2ab0dbedc add self-global template to runtime generation 2014-11-10 08:16:38 +11:00
Sebastian McKenzie
e0d3e18865 add allowReturnOutsideFunction to util.parse and make nodes optional in util.template 2014-11-10 08:16:22 +11:00
Sebastian McKenzie
3a3ad4775b add gitter webhook to travis 2014-11-10 08:16:00 +11:00
Sebastian McKenzie
40fdd2a828 dry up types.getIds 2014-11-10 00:51:46 +11:00
Sebastian McKenzie
12f66e852a v1.11.3 2014-11-10 00:22:09 +11:00
Sebastian McKenzie
c61c9aab56 remove invalid ObjectPattern assignment 2014-11-10 00:19:37 +11:00
Sebastian McKenzie
7adc919bb6 remove invalid ObjectPattern destructuring assignment 2014-11-10 00:18:01 +11:00
Sebastian McKenzie
9989b89b92 v1.11.2 2014-11-09 22:27:52 +11:00
Sebastian McKenzie
361ef02a88 support ParenthesizedExpression in types.getIds 2014-11-09 22:26:48 +11:00
Sebastian McKenzie
72369c90a2 update dependencies 2014-11-09 22:11:06 +11:00
Sebastian McKenzie
fa26174d3f better isParenthesizedExpression support for destructuring 2014-11-09 22:10:59 +11:00
Sebastian McKenzie
227d51a556 add AssignmentExpression ObjectPattern test 2014-11-09 22:10:43 +11:00
Sebastian McKenzie
a5f00aa3f6 v1.11.1 2014-11-09 21:39:19 +11:00
Sebastian McKenzie
a47723c66c fix destructuring to support ParanthesizedExpression 2014-11-09 21:37:59 +11:00
Sebastian McKenzie
ab2f652bdf break up let scoping transformer some more 2014-11-09 21:25:14 +11:00
Sebastian McKenzie
5aff7709f7 add back _property-literals transformer that somehow disappeared? 2014-11-09 21:25:05 +11:00
Sebastian McKenzie
06ba731452 traverse: pass opts.scope instead of opts 2014-11-09 21:24:48 +11:00
Sebastian McKenzie
f4c81531ad break up let scoping 2014-11-09 20:31:46 +11:00
Sebastian McKenzie
19b115c76b generator: dry up ForXStatements and *Statements 2014-11-09 20:31:36 +11:00
Sebastian McKenzie
96b08bf7df remove codeclimate from travis 2014-11-09 20:20:21 +11:00
Sebastian McKenzie
8f435d59da change sebmck to new 6to5 org 2014-11-09 20:08:36 +11:00
Sebastian McKenzie
6df03c00a8 Merge pull request #130 from thejameskyle/patch-1
Update logo on README
2014-11-09 20:05:11 +11:00
James Kyle
4ec134814e Update logo on README 2014-11-09 01:04:32 -08:00
Sebastian McKenzie
4fb50cfe20 v1.11.0 2014-11-09 18:45:50 +11:00
Sebastian McKenzie
bac952e036 move runtime to dist/runtime 2014-11-09 18:42:42 +11:00
Sebastian McKenzie
9844540bb0 add npm release-only files to gitignore 2014-11-09 18:38:09 +11:00
Sebastian McKenzie
1a9a60e010 fix polyfill require path 2014-11-09 18:37:57 +11:00
Sebastian McKenzie
e26812e622 remove v8-argv 2014-11-09 18:33:07 +11:00
Sebastian McKenzie
7f306388e4 remove polyfill from root 2014-11-09 18:32:19 +11:00
Sebastian McKenzie
b217453d49 clean up runtime generation declarations 2014-11-09 18:22:26 +11:00
Sebastian McKenzie
463165e0c8 remove unneccesary declaration 2014-11-09 18:22:12 +11:00
Sebastian McKenzie
85d7da9a7c fix comment space column bug 2014-11-09 18:22:04 +11:00
Sebastian McKenzie
48f6c5c649 remove i from mocha globals 2014-11-09 18:21:50 +11:00
Sebastian McKenzie
d1187dde82 fix up tests to work with the new code generator 2014-11-09 18:21:42 +11:00
Sebastian McKenzie
f21a6b36ac peg regenerator-6to5 and acorn-6to5 to a commit 2014-11-09 18:21:29 +11:00
Sebastian McKenzie
407bb9278f uglify polyfill.js and use minified versions in npm release 2014-11-09 16:41:45 +11:00
Sebastian McKenzie
70b3d88455 fix browser polyfill copytext 2014-11-09 16:40:46 +11:00
Sebastian McKenzie
98df094e60 fix cached templates exporting 2014-11-09 16:40:37 +11:00
Sebastian McKenzie
4bae820a5a remove Error.captureStackTrace monkey patch as it's no longer necessary with the latest ast-types 2014-11-09 16:37:47 +11:00
Sebastian McKenzie
4e8afa18da move Polyfill from caveats 2014-11-09 16:34:21 +11:00
Sebastian McKenzie
fbf0c25bbe include polyfill 2014-11-09 16:33:26 +11:00
Sebastian McKenzie
a90da9908c only prepend whitespace to properties if we're the first 2014-11-09 16:28:56 +11:00
Sebastian McKenzie
bd51215316 change Runtime to Optional runtime in README 2014-11-09 16:28:21 +11:00
Sebastian McKenzie
e3c6ee5c88 only use needsParens if the node has changed parent 2014-11-09 16:28:05 +11:00
Sebastian McKenzie
8c40db5658 use Program builder 2014-11-09 16:27:39 +11:00
Sebastian McKenzie
4d59976d82 remove _parent from nodes in traverse.removeProperties 2014-11-09 16:27:31 +11:00
Sebastian McKenzie
83286cccd2 use file node builder and save parents to ast tree 2014-11-09 16:26:52 +11:00
Sebastian McKenzie
de7edcaeb0 finalize ast-types 2014-11-09 16:26:32 +11:00
Sebastian McKenzie
6c8db61b23 switch to regenerator-6to5 2014-11-09 16:26:27 +11:00
Sebastian McKenzie
e3d2748970 fix up react display-name test whitespace 2014-11-09 16:26:12 +11:00
Sebastian McKenzie
fa8c570e77 add File and Program to builder keys 2014-11-09 16:25:55 +11:00
Sebastian McKenzie
677f9805c6 update ast-types and add regenerator-6to5 2014-11-09 16:25:45 +11:00
Sebastian McKenzie
eff5efaf10 fix up patching 2014-11-09 13:42:11 +11:00
Sebastian McKenzie
a909a6febd add CatchClause scope 2014-11-09 13:42:00 +11:00
Sebastian McKenzie
61ee0ef6f6 fix generation comments return-no-argument test whitespace 2014-11-09 12:14:15 +11:00
Sebastian McKenzie
07c15f02e6 update generation test to new api 2014-11-09 12:13:55 +11:00
Sebastian McKenzie
3f4068ae00 fix runtime declaration inclusion copytext 2014-11-09 12:12:23 +11:00
Sebastian McKenzie
dce41bb989 fix up tests 2014-11-09 12:09:59 +11:00
Sebastian McKenzie
896663056d add ParenthesizedExpression builder 2014-11-09 12:09:42 +11:00
Sebastian McKenzie
dfe4ce86e0 fix up templateLiterals blacklist check 2014-11-09 12:09:32 +11:00
Sebastian McKenzie
24f0120e01 add patch so we can patch estraverse and ast-types 2014-11-09 12:09:07 +11:00
Sebastian McKenzie
0108562e88 remove unused key variable 2014-11-09 12:07:57 +11:00
Sebastian McKenzie
e4e4ae5b1d fix up node inheritance 2014-11-09 12:07:46 +11:00
Sebastian McKenzie
ba04377ed8 add types.toIdentifier 2014-11-09 12:07:25 +11:00
Sebastian McKenzie
cd9e289dee traverse: clean up scope getIds building 2014-11-09 12:07:14 +11:00
Sebastian McKenzie
0b86a2fef8 use acorns preserveParens 2014-11-09 12:06:56 +11:00
Sebastian McKenzie
b84cb1828b generator: avoid redundant source map mappings 2014-11-09 12:03:47 +11:00
Sebastian McKenzie
aedc013ab8 generator: rename Whitespace methods 2014-11-09 12:03:31 +11:00
Sebastian McKenzie
ab9cd4e630 add support for an optional runtime - closes #129 2014-11-09 12:02:06 +11:00
Sebastian McKenzie
8ef5148870 fix up modules tests 2014-11-08 12:00:49 +11:00
Sebastian McKenzie
4cb90cb1e0 add precedence to generated node generation 2014-11-08 12:00:26 +11:00
Sebastian McKenzie
d0a33ab933 add inherits option to util.template 2014-11-08 12:00:12 +11:00
Sebastian McKenzie
9ea4431ba3 add alternate shallow equals option to types.is* 2014-11-08 11:59:54 +11:00
Sebastian McKenzie
08580edda8 fix up some tests 2014-11-08 09:17:21 +11:00
Sebastian McKenzie
5c6d57c51b add transformation and generation folders 2014-11-08 09:17:12 +11:00
Sebastian McKenzie
744d1af485 move down propertyLiterals transformer in case classes produces any 2014-11-07 21:10:28 +11:00
Sebastian McKenzie
591b78b159 move property literal check to a separate transformer 2014-11-07 21:01:39 +11:00
Sebastian McKenzie
49ea641314 ignore computed property literals that are valid identifiers 2014-11-07 20:51:01 +11:00
Sebastian McKenzie
37a7c92500 remove duplicate mutator map test 2014-11-07 20:47:15 +11:00
Sebastian McKenzie
35b7b140da fix pointless newlines after left braces 2014-11-07 20:47:09 +11:00
Sebastian McKenzie
159f5217e3 simplify ast transformer code 2014-11-07 20:46:54 +11:00
Sebastian McKenzie
795e38e4f4 add Statement node type 2014-11-07 20:46:43 +11:00
Sebastian McKenzie
2a9af21e93 add modules ignore tests 2014-11-07 20:46:20 +11:00
Sebastian McKenzie
e327e041ab add basic generation tests 2014-11-07 20:46:11 +11:00
Sebastian McKenzie
f8e8cd3979 support SpreadElement in destructuring - fixes #128 2014-11-07 20:46:02 +11:00
Sebastian McKenzie
b3206d94a6 Merge branch 'master' into experimental
Conflicts:
	README.md
	lib/6to5/register.js
2014-11-07 13:54:59 +11:00
Sebastian McKenzie
fcbd315bc1 v1.10.12 2014-11-07 13:53:15 +11:00
Sebastian McKenzie
71646f4ade register: fix ignoreRegex compatibility check 2014-11-07 13:52:13 +11:00
Sebastian McKenzie
56ac964e54 remove newline assurance and add optional Error constructor to File::errorWithNode 2014-11-07 13:51:31 +11:00
Sebastian McKenzie
e5f1eb64b6 clarify default ignore in 6to5/register 2014-11-07 13:41:24 +11:00
Sebastian McKenzie
6145f0a03b v1.10.11 2014-11-07 13:17:41 +11:00
Sebastian McKenzie
54f901f131 require: add missing blacklistTests, implement opts.whitelist and opts.only - closes #125
Conflicts:
	lib/6to5/register.js
2014-11-07 13:16:26 +11:00
Sebastian McKenzie
df70be4ebb clean up and fix tests 2014-11-07 12:33:35 +11:00
Sebastian McKenzie
99ba77bb0b nicer removeProperties for comments 2014-11-07 12:33:22 +11:00
Sebastian McKenzie
346f72be05 ensure files end with a newline 2014-11-07 12:32:48 +11:00
Sebastian McKenzie
c0e6cda071 add UserWhitespacable alias to Property 2014-11-07 12:32:31 +11:00
Sebastian McKenzie
c054ff7bbb better whitespace detection in generator 2014-11-07 12:32:15 +11:00
Sebastian McKenzie
771d3dc8a0 don't inherit from XJSAttribute in jsx transformer because it causes some weird whitespace issues 2014-11-07 12:31:54 +11:00
Sebastian McKenzie
e8d4806b45 combine export declaration assignments into variable declarations 2014-11-07 12:31:31 +11:00
Sebastian McKenzie
469a522300 better whitespace for code generation 2014-11-07 12:31:09 +11:00
Sebastian McKenzie
4068a8bf68 remove exposure to generator from browser build 2014-11-07 12:30:29 +11:00
Sebastian McKenzie
a04513a3c7 faster util.pushMutatorMap aliases 2014-11-07 12:28:52 +11:00
Sebastian McKenzie
6f0ca947a7 remove exposure to generate and util 2014-11-07 12:28:28 +11:00
Sebastian McKenzie
dd62244e10 use v8-argv to make sure node is ran with --harmony for 6to5-node 2014-11-07 12:28:17 +11:00
Sebastian McKenzie
12f68b05c3 better Symbol polyfill existence check because the one es6-symbol uses isn't reliable 2014-11-07 12:27:57 +11:00
Sebastian McKenzie
62fe128132 more support to t.getIds and add t.needsWhitespaceBefore method 2014-11-07 12:26:48 +11:00
Sebastian McKenzie
bf632ca20b more efficient constants collision checking 2014-11-07 12:26:19 +11:00
Sebastian McKenzie
26428cde41 require: add missing blacklistTests, implement opts.whitelist and opts.only - closes #125 2014-11-07 12:25:42 +11:00
Sebastian McKenzie
9bb8a16d93 change polyfill to monkey patch in browser comment 2014-11-05 15:22:17 +11:00
Sebastian McKenzie
44cd044586 add duo and karma plugins to readme - thanks @shuhei and @bd-labs! 2014-11-05 15:22:07 +11:00
Sebastian McKenzie
765899a521 use push instead of _push for first backtick in template literals 2014-11-04 18:37:00 +11:00
Sebastian McKenzie
1d40cac52f let ExpressionStatements handle child comments 2014-11-04 18:34:21 +11:00
Sebastian McKenzie
fb0325a4d8 add support for SpreadElement to types.getIds 2014-11-04 18:33:48 +11:00
Sebastian McKenzie
1df25a633c fix code reference on generate 2014-11-04 18:33:33 +11:00
Sebastian McKenzie
cfbaae456b use _push instead of push on template literals end 2014-11-04 18:32:51 +11:00
Sebastian McKenzie
95ace3220d fix indentation on generation comments tests 2014-11-04 18:32:30 +11:00
Sebastian McKenzie
2e0f3de72c add missing util require 2014-11-04 18:07:28 +11:00
Sebastian McKenzie
732c21d42a clean up some tests 2014-11-04 18:07:19 +11:00
Sebastian McKenzie
a535007a35 clean up let scoping transformer and add lots of comments 2014-11-04 18:06:54 +11:00
Sebastian McKenzie
5ff6f445b2 fix class computed methods 2014-11-04 15:53:36 +11:00
Sebastian McKenzie
d7ae3b506a fix linting errors 2014-11-04 15:53:11 +11:00
Sebastian McKenzie
287cbbb6a1 implement new and improved let scoping - fixes #91, fixes #102, fixes #124 2014-11-04 14:59:44 +11:00
Sebastian McKenzie
d1088583ba default generateUid scope to Program 2014-11-04 12:57:06 +11:00
Sebastian McKenzie
c967cded78 make id optional in t.getIds 2014-11-04 12:56:53 +11:00
Sebastian McKenzie
71d87f5b97 cache scope ids and limit id variable declarations to kind 2014-11-04 12:56:37 +11:00
Sebastian McKenzie
56271efada pass scope to transformers 2014-11-04 12:48:08 +11:00
Sebastian McKenzie
89fbb06658 simplify VariableDeclaration ForStatement check 2014-11-04 12:47:56 +11:00
Sebastian McKenzie
43ee3b77f3 add SequenceExpression and UnaryExpression builders 2014-11-04 12:47:39 +11:00
Sebastian McKenzie
9ef826b53e move visitor-keys from traverse to types 2014-11-04 12:47:27 +11:00
Sebastian McKenzie
6519ceaa63 move util.getIds to types.getIds 2014-11-04 12:47:03 +11:00
Sebastian McKenzie
d28496006e implement Scope so we can keep track of references to avoid collisions when generating ids 2014-11-04 12:46:47 +11:00
Sebastian McKenzie
5f9710e61f add explanation for gross Error.captureStackTrace polyfill 2014-11-04 12:45:17 +11:00
Sebastian McKenzie
c4cadd8a64 add text/6to5 to browser compilation script types 2014-11-04 09:13:50 +11:00
Sebastian McKenzie
d3c5b8ef0b automatic browser <script type="text/ecmascript-6"> compilation - closes #97 2014-11-04 08:56:48 +11:00
Sebastian McKenzie
120df2c611 make browser api backwards compatible 2014-11-04 08:22:44 +11:00
Sebastian McKenzie
719d23eb3b add Error.captureStackTrace polyfill so browser build will work in non-v8 environments - fixes #107 2014-11-04 08:19:13 +11:00
Sebastian McKenzie
364abf60ea fix generation test whitespace 2014-11-04 08:05:09 +11:00
Sebastian McKenzie
0f5a141c91 change acorn-ast-types to ast-types 2014-11-04 08:04:41 +11:00
Sebastian McKenzie
fca3a0c56f generator: add ensureSemicolon and printBlock methods 2014-11-04 08:04:32 +11:00
Sebastian McKenzie
e88505aba6 better ExportDeclaration generation 2014-11-04 08:04:22 +11:00
Sebastian McKenzie
500a0bdfb6 better whitespace for blocks and methods 2014-11-04 08:04:11 +11:00
Sebastian McKenzie
2a0efceef5 change behaviour of tests and browser testing/build 2014-11-04 08:03:52 +11:00
Sebastian McKenzie
225754ae12 Merge branch 'master' into experimental 2014-11-03 21:18:50 +11:00
Sebastian McKenzie
6f230de01c fix maybeReplace wrong node callback bug 2014-11-03 21:17:56 +11:00
Sebastian McKenzie
3c3746b21f fix transformer alias types key 2014-11-03 21:17:42 +11:00
Sebastian McKenzie
f49f057b33 generator: add trim option to isLast 2014-11-03 21:17:17 +11:00
Sebastian McKenzie
e3b9a0dd38 update alias-functions transformer to use types 2014-11-03 21:16:15 +11:00
Sebastian McKenzie
f540c3f4b7 fix test newlines 2014-11-03 21:15:58 +11:00
Sebastian McKenzie
6e5917e537 make array comprehensions use for-of unless using an array literal - fixes #98 2014-11-03 21:15:49 +11:00
Sebastian McKenzie
816c1d304b remove builders and move them to automatially generated types 2014-11-03 21:13:35 +11:00
Sebastian McKenzie
5deeae1aa2 travis: ignore experimental branch 2014-11-03 18:26:50 +11:00
Sebastian McKenzie
718e342e86 fix classes supername transformer inference 2014-11-03 18:22:57 +11:00
Sebastian McKenzie
cb98605520 add example usage for custom module formatters 2014-11-03 18:20:01 +11:00
Sebastian McKenzie
600513bcab add ignore module formatter - closes #119 2014-11-03 18:18:51 +11:00
Sebastian McKenzie
620e5791af use t.is* methods to nicen up code 2014-11-03 18:10:52 +11:00
Sebastian McKenzie
47ee2cc99f simplify err.loc references 2014-11-03 17:53:08 +11:00
Sebastian McKenzie
6cc70f7465 compare code instead of ast for transformation tests 2014-11-03 17:52:59 +11:00
Sebastian McKenzie
20484c66c5 add types.inherits method that inherits loc, range, start, end etc 2014-11-03 17:52:50 +11:00
Sebastian McKenzie
171bcad870 make transformation tests compare output instead of ast 2014-11-03 17:52:15 +11:00
Sebastian McKenzie
c963c30107 fix errorWithNode line mapping 2014-11-03 17:50:25 +11:00
Sebastian McKenzie
795183569d fix export default assignment bug 2014-11-03 14:40:47 +11:00
Sebastian McKenzie
9a3c973280 add removeLastNewline to generator and add newlines to generated nodes 2014-11-03 14:40:33 +11:00
Sebastian McKenzie
95f3ca6348 Merge branch 'master' into code-generator
Conflicts:
	lib/6to5/transformers/classes.js
	test/fixtures/transformation/source-maps/class/expected.js
	test/fixtures/transformation/source-maps/class/source-mappings.json
2014-11-03 13:38:44 +11:00
Sebastian McKenzie
c17878913b add classProps declaration to simplify/nicen up class property defining - closes #88 2014-11-03 13:36:23 +11:00
Sebastian McKenzie
c8139317ee add static property inherit warning for IE <= 9 to README - closes #116 2014-11-03 13:09:36 +11:00
Sebastian McKenzie
6d6039aeb6 Merge branch 'master' into code-generator 2014-11-03 12:36:11 +11:00
Sebastian McKenzie
74f11dfddf add chai to devDependencies 2014-11-03 12:35:59 +11:00
Sebastian McKenzie
4c63b4ea1e Merge branch 'master' into code-generator 2014-11-03 12:34:15 +11:00
Sebastian McKenzie
6332e725fe update bin tests to match updated use strict behaviour 2014-11-03 12:34:00 +11:00
Sebastian McKenzie
f3d371869d Merge branch 'master' into code-generator
Conflicts:
	lib/6to5/register.js
2014-11-03 12:22:07 +11:00
Sebastian McKenzie
89ecd46b77 move _moduleFormatter transformer before useStrict transformer and remove duplicate use strict removing - fixes #114 2014-11-03 12:20:47 +11:00
Sebastian McKenzie
9f8e8d96a8 simplify hasParans for NewExpression 2014-11-03 12:15:57 +11:00
Sebastian McKenzie
a7bbd1dd3e generator: fix comments in harmony-edgecase tests 2014-11-03 12:15:44 +11:00
Sebastian McKenzie
6d961c1857 faster traverse.hasType with array of nodes 2014-11-03 12:15:27 +11:00
Sebastian McKenzie
e13a650d05 remove IfStatement making consequent and alternate blocks 2014-11-03 11:17:36 +11:00
Sebastian McKenzie
3cd7ed69a3 remove useless blank template 2014-11-03 11:16:48 +11:00
Sebastian McKenzie
93c6d69e21 make transformation tests ignore whitespace 2014-11-03 11:15:06 +11:00
Sebastian McKenzie
57d3c836bd register: add additional blacklistTests 2014-11-03 11:14:52 +11:00
Sebastian McKenzie
115282d57b generator: add _push method to simplify buffer pushing and location tracking 2014-11-03 11:13:37 +11:00
Sebastian McKenzie
72d924d85b generator: fix NewExpression arguments 2014-11-03 11:12:30 +11:00
Sebastian McKenzie
6838062279 move util.errorWithNode to File 2014-11-03 11:11:37 +11:00
Sebastian McKenzie
bc79cec15a add NewExpression support to needsParans 2014-11-03 11:11:07 +11:00
Sebastian McKenzie
85f0f6fb14 add whitespace option and move util.errorWithNode to File 2014-11-03 11:09:58 +11:00
Sebastian McKenzie
bf61c1e85d remove recast and add ast-types 2014-11-03 11:09:24 +11:00
Sebastian McKenzie
bd2e3d784f fix source-map transformation tests 2014-11-03 11:09:14 +11:00
Sebastian McKenzie
7e8c5cd20f Merge pull request #118 from amsul/patch-1
Added ability to register 6to5 with a blacklist
2014-11-02 10:39:13 +11:00
amsul
ddbb522392 Updated blacklist option to replace reference 2014-11-01 19:36:10 -04:00
amsul
288cfd1f00 Added ability to register 6to5 with a blacklist
Currently, to achieve this, I have to use this workaround:

```js
var to5 = require('6to5')
delete to5.transform.transformers.generators
require('6to5/register')
```

After this simple change, I can make it much nicer:

```js
require('6to5/register')({
    blacklist: ['generators']
})
```

Cheers!
2014-11-01 14:15:52 -04:00
Sebastian McKenzie
435b9434ea don't mess with the indentation of TemplateElements 2014-11-01 23:26:48 +11:00
Sebastian McKenzie
2409b017db generator: remove parans around ConditionalExpression 2014-11-01 23:08:50 +11:00
Sebastian McKenzie
99f2864048 generator: remove redundant print call 2014-11-01 23:08:33 +11:00
Sebastian McKenzie
5351057557 generator: move BlockStatement to base generator 2014-11-01 23:08:16 +11:00
Sebastian McKenzie
1a5ee7d5da change acorn-jsx to acorn-6to5 2014-11-01 23:07:53 +11:00
Sebastian McKenzie
ebea86c527 split up types.ensureBlock into types.toBlock 2014-11-01 23:07:34 +11:00
Sebastian McKenzie
bf58004947 generator: add intelligent whitespace based on tokens on nodes in a sequence 2014-11-01 23:07:17 +11:00
Sebastian McKenzie
f0c78102ca move template literal generators into separate file 2014-11-01 19:37:21 +11:00
Sebastian McKenzie
da1512eeb0 rename generation test names to be more descriptive 2014-11-01 19:34:16 +11:00
Sebastian McKenzie
43ea593677 traverse.removeProperties: remove raw property 2014-11-01 19:29:17 +11:00
Sebastian McKenzie
629cea497f move keyword method and restyle variable declarations 2014-11-01 19:29:02 +11:00
Sebastian McKenzie
9475dc681f finish jsx generator 2014-11-01 19:28:42 +11:00
Sebastian McKenzie
6e41309ede add err.stack test to code frame error capture 2014-11-01 19:28:35 +11:00
Sebastian McKenzie
42322e1ce7 add examples to types.needsParans tests 2014-11-01 19:27:42 +11:00
Sebastian McKenzie
400fa8ed97 remove unused ParenthesizedExpression 2014-11-01 19:27:23 +11:00
Sebastian McKenzie
07e2842226 implement array comprehension generator 2014-11-01 19:27:09 +11:00
Sebastian McKenzie
7d46b7c465 expose generator 2014-11-01 17:56:07 +11:00
Sebastian McKenzie
fcf6c9e066 generator: add isLast helper method 2014-11-01 17:53:01 +11:00
Sebastian McKenzie
a5523664fc generator: add alternate support to IfStatement 2014-11-01 17:52:48 +11:00
Sebastian McKenzie
1841f5c8a0 v1.10.10 2014-11-01 16:08:11 +11:00
Sebastian McKenzie
33f8988313 support for numeric literals with recast - fixes #117 2014-11-01 16:06:46 +11:00
Sebastian McKenzie
1d3544eadc fix function generation spacing 2014-11-01 16:00:17 +11:00
Sebastian McKenzie
646bdfd04c types.needsParans: add parent ExpressionStatement check for FunctionExpression 2014-11-01 15:58:44 +11:00
Sebastian McKenzie
aba9bba7db generator: use new keyword method for keywords 2014-11-01 15:56:27 +11:00
Sebastian McKenzie
e77382582f generator: add keyword method, remove __ident method and implement better position tracking 2014-11-01 15:56:10 +11:00
Sebastian McKenzie
af997b9945 Merge pull request #115 from djindjic/patch-1
Just a little info added
2014-11-01 08:39:33 +11:00
Aleksandar Djindjic
a2332f08bc Just a little info added
I needed this and it maybe help to someone else
2014-10-31 14:58:46 +01:00
Sebastian McKenzie
bbffde374e Merge branch 'master' into code-generator 2014-10-31 21:39:47 +11:00
Sebastian McKenzie
115dca56b6 v1.10.9 2014-10-31 21:39:17 +11:00
Sebastian McKenzie
251e4d01c8 join together declarations in destructuring to return a single node if possible - fixes #113 2014-10-31 21:38:22 +11:00
Sebastian McKenzie
0fbf0e2a77 generator: add semicolon helper method, add optional printJoin iterator 2014-10-31 21:24:54 +11:00
Sebastian McKenzie
e8628ea1a7 add chai 2014-10-31 21:24:36 +11:00
Sebastian McKenzie
a5a8f08bb8 generator: implement missing node types 2014-10-31 21:23:45 +11:00
Sebastian McKenzie
d376bd3c0e generator: remove redundant async tests 2014-10-31 21:23:31 +11:00
Sebastian McKenzie
20818b086c generator: add support for modules 2014-10-31 21:22:56 +11:00
Sebastian McKenzie
f9ef1723a6 generator: add support for ForOfStatement 2014-10-31 21:22:43 +11:00
Sebastian McKenzie
6e7b8a14fe remove comments in traverse.removeProperties 2014-10-31 21:22:28 +11:00
Sebastian McKenzie
622bb2e962 types: add more tests for optional paranthesis 2014-10-31 21:22:03 +11:00
Sebastian McKenzie
5c5348537d generator: add support for method properties and computed keys and shorthand 2014-10-31 21:21:50 +11:00
Sebastian McKenzie
0def62b918 replace single quotes with double quotes in generaton tests 2014-10-31 21:21:26 +11:00
Sebastian McKenzie
530ad78428 fix & html entity in travis badge branch url - thanks @davidchambers 2014-10-31 11:51:49 +11:00
Sebastian McKenzie
daced12baa add base for TemplateLiteral generator 2014-10-31 11:51:00 +11:00
Sebastian McKenzie
51f18a152e fix test generation actual ast 2014-10-31 11:50:52 +11:00
Sebastian McKenzie
51f72ace57 Merge pull request #112 from thejameskyle/travis-badge
Add ?branch=master to Travis CI badge
2014-10-31 11:47:50 +11:00
James Kyle
2fa36b30d5 Add ?branch=master to Travis CI badge 2014-10-30 17:46:08 -07:00
Sebastian McKenzie
11270e0803 Merge branch 'master' into code-generator
Conflicts:
	lib/6to5/transformers/rest-parameters.js
2014-10-31 11:44:48 +11:00
Sebastian McKenzie
6f8cbf0ad1 v1.10.8 2014-10-31 11:43:36 +11:00
Sebastian McKenzie
6696d5fcf4 fix rest parameters in arrow functions containing wrong arguments reference - fixes #11 2014-10-31 11:42:09 +11:00
Sebastian McKenzie
591f123670 update tests to work with new syntax 2014-10-31 11:38:52 +11:00
Sebastian McKenzie
1f7270720f add more type methods 2014-10-31 11:38:37 +11:00
Sebastian McKenzie
ec3a3cbbc9 more descriptive test helper method names 2014-10-31 11:38:18 +11:00
Sebastian McKenzie
8a1ea82e97 remove legacy generator options 2014-10-31 11:38:04 +11:00
Sebastian McKenzie
6953b6e8b6 remove start and end props from nodes in traverse.removeProperties 2014-10-31 11:37:49 +11:00
Sebastian McKenzie
378832d31b add comments with estraverse 2014-10-31 11:37:17 +11:00
Sebastian McKenzie
85703eb5b8 run internal transformers when using a whitelist 2014-10-31 11:37:04 +11:00
Sebastian McKenzie
d0fdd3bf41 remove comments transformer 2014-10-31 11:36:44 +11:00
Sebastian McKenzie
a7385bdf1b make CodeGenerators use static method calls instead of recursive string methods 2014-10-31 11:36:28 +11:00
Sebastian McKenzie
9c7c385ee8 add generation tests from escodegen 2014-10-31 11:35:57 +11:00
Sebastian McKenzie
7c84af2ba8 remove optional computed property in b.memberExpression 2014-10-30 17:38:05 +11:00
Sebastian McKenzie
009d063790 just return constructor if only a constructor exists in classes 2014-10-30 17:37:51 +11:00
Sebastian McKenzie
5483c4ef6f split up code generators 2014-10-30 17:30:05 +11:00
Sebastian McKenzie
5558f61518 add more feature detection to 6to5/register 2014-10-30 17:16:33 +11:00
Sebastian McKenzie
96bc95d6d9 add blacklist syntax feature checking to 6to5/register 2014-10-30 17:11:54 +11:00
Sebastian McKenzie
11dd13b7e0 remove invalid node types from generator and add todo ones 2014-10-30 17:11:31 +11:00
Sebastian McKenzie
976e6782a2 expose traverse.VISITOR_KEYS 2014-10-30 17:11:13 +11:00
Sebastian McKenzie
febc3062cc update traverse visitor keys to acorn ones 2014-10-30 17:11:05 +11:00
Sebastian McKenzie
efff5e5aab add generation completeness test 2014-10-30 17:10:54 +11:00
Sebastian McKenzie
eefab7f80f remove unused variables 2014-10-30 13:31:45 +11:00
Sebastian McKenzie
1a3d306949 Merge branch 'master' into code-generator
Conflicts:
	package.json
2014-10-30 13:29:05 +11:00
Sebastian McKenzie
e5ae2f8eaf fix linting errors 2014-10-30 13:26:13 +11:00
Sebastian McKenzie
e797be518f move some util and traverse methods into types 2014-10-30 13:26:06 +11:00
Sebastian McKenzie
45cb755845 better eval contexts in bin/6to5-node 2014-10-30 13:09:37 +11:00
Sebastian McKenzie
3b9a339c79 remove useless traverse.Delete 2014-10-30 13:09:23 +11:00
Sebastian McKenzie
ea7ac4cd2d change acorn-ast-types to internal builders 2014-10-30 13:09:12 +11:00
Sebastian McKenzie
e141a8b875 run 6to5-node repl in a context 2014-10-30 12:15:37 +11:00
Sebastian McKenzie
6768fc3800 add back regex.flags in unicode regex transformer 2014-10-30 12:15:12 +11:00
Sebastian McKenzie
0af5e00b5f update jsx empty test to new dom tags behaviour 2014-10-30 12:14:41 +11:00
Sebastian McKenzie
4b3ebc62b1 fix indentation 2014-10-29 20:52:31 +11:00
Sebastian McKenzie
cc094efe1b modify regex object instead of creating a new literal 2014-10-29 20:52:25 +11:00
Sebastian McKenzie
8f4a3f77a0 remove jsx known-tags and use the latest jsx known tag definition 2014-10-29 20:52:12 +11:00
Sebastian McKenzie
b31f3666c8 yank out acorn-recast and replace it with our own code generator 2014-10-29 20:51:52 +11:00
Sebastian McKenzie
b1495832d7 remove acorn-recast 2014-10-29 20:51:03 +11:00
1384 changed files with 18072 additions and 5353 deletions

6
.gitignore vendored
View File

@@ -4,6 +4,12 @@ test/tmp
*.log
*.cache
/templates.json
/tests.json
/browser.js
/browser-polyfill.js
/runtime.js
coverage
dist
.package.json
packages/6to5-runtime/*.js
packages/6to5-runtime/regenerator/*.js

9
.gitmodules vendored Normal file
View File

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

60
.jscsrc Normal file
View File

@@ -0,0 +1,60 @@
{
"excludeFiles": ["lib/6to5/transformation/templates"],
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowQuotedKeysInObjects": 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,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"requireSpacesInForStatement": true,
"requireCurlyBraces": [
"do"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"typeof"
],
"validateLineBreaks": "LF",
"validateQuoteMarks": "\"",
"validateIndentation": 2
}

View File

@@ -1,3 +1 @@
node_modules
test
lib/6to5/templates
lib/6to5/transformation/templates

View File

@@ -5,7 +5,6 @@
"camelcase": true,
"unused": true,
"eqnull": true,
"proto": true,
"newcap": true,
"supernew": true,
"noyield": true,
@@ -14,12 +13,11 @@
"boss": true,
"expr": true,
"undef": true,
"loopfunc": true,
"white": true,
"maxparams": 5,
"maxdepth": 4,
"globals": {
"window": true,
"suite": true,
"set": true,
"before": true,

View File

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

View File

@@ -1,12 +1,20 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.11"
branches:
except:
- experimental
before_script: "npm install -g codeclimate-test-reporter"
script: "make test-travis"
addons:
code_climate:
repo_token:
secure: "PfP9sDUJzSznDb+ZEPO2cignXabSTXJxEVm5ESRPgEcFr+/4b0pt3hI8R9b+9mLtBEwtw3DLUq48MOeqEKnq29csQmpjPVcN6gT4uR2DdNa1JpVgDuwxT05NB3fBea9U2reM73iV8ylCgPHExr2uGR9/87JzR2beY/56EUL5NjY="
notifications:
webhooks:
urls:
- https://webhooks.gitter.im/e/acf1870e9d223c65e8d5
on_success: always
on_failure: always
on_start: false

841
CHANGELOG.md Normal file
View File

@@ -0,0 +1,841 @@
# Changelog
> **Tags:**
> - [New Feature]
> - [Bug Fix]
> - [Spec Compliancy]
> - [Breaking Change]
> - [Documentation]
> - [Internal]
> - [Polish]
_Note: Gaps between patch versions are faulty/broken releases._
## 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**
* Fix `super` inside of nested functions.
* **Internal**
* Move let scoping TDZ into a separate transformer until it's more solid.
* Use `process.stdin.write` instead of `console.log` in `bin` to avoid sprintfification.
## 2.13.1
* **New Feature**
* Temporal dead zone for block binding.
## 2.13.0
* **New Feature**
* Block scoped functions.
* Add `--loose all` option.
* Add playground mallet operator thanks to [@jridgewell](https://github.com/jridgewell).
* **Bug Fix**
* Rewrote large parts of the let scoping transformer. Now passes all known tests.
* **Internal**
* Even more optimisations thanks to the awesome [@gaearon](https://github.com/gaearon).
* Upgrade `acorn-6to5`.
* Fixes exponentation operator thanks to [@charliesome](https://github.com/charliesome).
* Fix flow optional parameters with types.
* Upgrade `chokidar` to `0.12.6`.
* Upgrade `commander` to `2.6.0`.
* Upgrade `core-js` to `0.4.5`.
* Upgrade `estraverse` to `1.9.1`.
* Upgrade `jshint` to `2.5.11`.
* Upgrade `regenerator` to `0.8.9`.
* Upgrade `regexpu` to `1.0.0`.
* Upgrade `source-map` to `0.1.43`.
* Upgrade `source-map-support` to `0.2.9`.
* Upgrade `browserify` to `8.1.1`.
* Upgrade `chai` to `1.10.0`.
* Upgrade `istanbul` to `0.3.5`.
* Upgrade `mocha` to `2.1.0`.
* Upgrade `uglify-js` to `2.4.16`.
## 2.12.6
* **Bug Fix**
* Add missing flow type traversal keys.
## 2.12.5
* **Internal**
* Fix incorrect `for...in` loop still causing `ember-script` issues.
## 2.12.4
* **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).
## 2.12.3
* **Spec Compliancy**
* Optional `typeof` transformer checks for `undefined` before passing it to the helper.
* Class methods are now named.
## 2.12.2
* **Internal**
* Exclude nodes in function parameters and catch clauses from `isReferenced` check.
## 2.12.1
* **Internal**
* Add `.jsx` to list of allowed extensions.
## 2.12.0
* **Bug Fix**
* Support non-string JSX literals.
* **New Feature**
* Loose mode for some transformers that enables non-spec behaviour.
* **Internal**
* Uglify `--mangle sort` has been added to the build script, cutting minified scripts in half.
## 2.11.4
* **Internal**
* Make all dependency versions fixed.
## 2.11.3
* **Bug Fix**
* Allow a string to be passed as the `optional` option.
## 2.11.2
* **Bug Fix**
* Support esprima-style catch clause handlers.
* **Polish**
* Don't print a stacktrace for syntax errors in the CLI.
## 2.11.1
* **Bug Fix**
* Remove stray `console.log` outputting debug code.
* Remove `Dict` from `coreAliasing`.
## 2.11.0
* **Bug Fix**
* Fix unnecessary IIFE in default parameters on method calls.
* Add support for supers inside of closures.
* **New Feature**
* Add `--keep-module-id-extensions`/`keepModuleIdExtensions` option to keep extensions in module ids.
* **Polish**
* Special case single argument spread properties in `super` inside classes.
* Don't use a variable declaration for class declaration IFFE.
* Rename `inherits` helper parameters.
* `coreAliasing` transformer now aliases `Promise`, `Set`, `Map` and more. Thanks [@AluisioASG](https://github.com/AluisioASG).
## 2.10.1
* **Internal**
* Upgrade `core-js` to `0.4.4`.
* **New Feature**
* Added `--include-regenerator` option to CLI and `includeRegenerator` option to API that includes the regenerator runtime if necessary.
## 2.10.0
* **New Feature**
* Add `classesFastSuper` optional transformer that doesn't support parent getters and prototype changing.
* Add `forOfFast` transformer that speeds up `for...of` on arrays but produces more code.
* Add `--react-compat` to `bin/6to5`.
* **Spec Compliancy**
* Disallow setters without a single parameter.
* Add `configurable` and `writable` to defined properties.
* Use define instead of assignment for class methods.
* **Polish**
* Fix bin name in `6to5-node --help`.
* Fix shorthand `--whitelist` name in `bin/6to5`.
* **Internal**
* Hot code optimisation of traversal etc thanks to [gaearon](https://github.com/gaearon).
## 2.9.4
* **Bug Fix**
* Support `UpdateExpression`s as `MemberExpression` objects.
## 2.9.3
* **Bug Fix**
* Remove `exportsWildcard` helper in favor of `defaults`.
## 2.9.2
* **Bug Fix**
* Pass `exports` to `exportWildcard` helper to allow for use inside the optional runtime.
## 2.9.1
* **Bug Fix**
* Fix runtime generator breaking the helper inclusion loop.
## 2.9.0
* **Internal**
* Upgrade `acorn-6to5`.
* Now supports destructuring shorthand properties.
## 2.8.1
* **Bug Fix**
* Fix computed accessors on object literals.
## 2.8.0
* **New Feature**
* Add `commonStrict`, `amdStrict` and `umdStrict` module formatters that remove `module.exports` interop assignment.
* Add `--indent` option to the 6to5 CLI.
## 2.7.4
* **Polish**
* Inherit assignments from their declaration in destructuring.
* Properly align multi-declarator variable declarations.
## 2.7.3
* **Polish**
* Indent and add newlines to `React.createElement` calls in `react` transformer.
* Remove `Object.assign` calls and replace it with an `extends` helper.
## 2.7.1
* **New Feature**
* Expose `version` on browser and node API.
* **Internal**
* Upgrade `core-js` to 0.4.1
## 2.7.0
* **Spec Compliancy**
* Disallow reassignments of imports.
* **New Feature**
* `reactCompat` option to enable pre-v0.12 react components.
## 2.6.3
* **Bug Fix**
* Fix 2.6.0 regression caused by faulty export default from a source handling.
## 2.6.2
* **Bug Fix**
* Fix rest parameter keys when on functions with params.
## 2.6.1
* **Bug Fix**
* Fix rest parameter arguments key.
## 2.6.0
* **Bug Fix**
* Better handling of number literal property keys.
* Handle `NewExpression` paren insertion edegcases better.
* **Internal**
* Fix incorrect AST node `identifier("this")`.
* Better `toIdentifier` method that handles reserved words.
* Upgrade `acorn-6to5`.
* Fix exponentiation operator precedence.
* Fix line terminators after async contextual keywords.
* Add semicolons as class elements inside of a class body.
* Upgrade to `core-js` 4.0.0.
* Upgrade to `regenerator` 0.8.3.
* Fix non-loop labeled statements.
* **New Feature**
* Basic destructuring defaults
* Add `.es` to list of supported extensions.
* Add optional `typeofSymbol` transformer.
* Use a `for` loop for rest parameters instead of `Array.prototype.slice`.
* **Polish**
* Move `"use strict";` to inside module bodies instead of at the top of the file.
* Better handling of dynamic imports.
* **Spec Compliancy**
* Class inheritance now has a `function` or `null` type check.
* Add `interopRequireWildcard` around wildcard imports and exports to handle non-object exports.
## 2.5.0
* Remove `noDuplicateProperties` transformer.
* Better generated UIDs based on nodes.
* Default parameters now use `arguments[i]`, conditionals and variable declarations instead of using long-form if statements.
## 2.4.10
* Upgrade `acorn-6to5`.
## 2.4.9
* Upgrade `acorn-6to5`.
* Add optional `protoToAssign` transformer.
* Fix missing properties from computed property keys.
* Make ES7 comprehensions `let` variables.
## 2.4.8
* Make `require("6to5/register")` work with browserify - [#370](https://github.com/6to5/6to5/pull/370). Thanks [@hughsk](https://github.com/hughsk)!
## 2.4.7
* Upgrade `acorn-6to5`.
## 2.4.6
* Move `coreAliasing` and `undefinedToVoid` transformers down to catch `moduleFormatter` transforms.
## 2.4.5
* Avoid printing comments if they've already been output.
## 2.4.4
* Add `module` type to browser build `<script>` handler.
* Fix some `MemberExpression` modifying incorrectly setting `property` to a `MemberExpression`.
## 2.4.3
* Upgrade `acorn-6to5`.
* Add support for `FunctionDeclaration`s in `bluebirdCoroutines` and `asyncToGenerators` transformers.
## 2.4.2
* Upgrade `acorn-6to5`.
* Better uids generated for various transformers based on parent node.
* Alias flat references in `coreAliasing` transformer.
## 2.4.1
* Better whitespace handling of parenthesized expressions due to trailing comments.
* Fix `yield` inside of comprehensions.
## 2.4.0
* Use a closure always for classes with a super.
* Always use native loops for array comprehensions.
* Allow `yield` inside of comprehensions.
* Add optional `bluebirdCoroutine` transformer.
* Add optional `asyncToGenerator` transformer.
* Move `useStrict` transformer to before `_moduleFormatter` causing `"use strict";` to always be placed the very top.
## 2.3.2
* Add parens on expressions with trailing comments.
## 2.3.1
* Add `undefinedToVoid` optional transformer.
* Use `Object.defineProperty` for computed properties.
## 2.3.0
* Upgrade `acorn-6to5`.
* Support circular references and hoist variable declarations in `system` module formatter.
* Add optional transformers, including a new `coreAliasing` transformer that aliases native ES6 static properties to their `core-js` equivalent.
## 2.2.0
* Make `system` module formatter modules anonymous by default.
* Fix duplicate comments being output, breaking code.
## 2.1.0
* Add `cache` option to register hook.
* Update `core-js`.
* Fix starting newline not being added on case statements.
* Fix destructuring `VariableDeclaration`s not inside `BlockStatement`s and `Program`.
## 2.0.4
* Avoid being greedy when destructuring array iterables.
## 2.0.3
* Hoist function declarations in system module formatter for circular references.
* Hoist default function declarations in umd and amd module formatters for circular references.
## 2.0.2
* Inherit comments in `for-of` transformer.
* Remove `interopRequire` from `system` module formatter.
## 2.0.1
* Remap `UpdateExpression` module export binding.
* Fix automatic closure on `PrivateDeclaration` in classes.
## 2.0.0
* Make string literal generation only escapes unicode that it has to.
* Internal code generation format options have been exposed.
* Change playground method binding operator from `:` to `#` removing ambiguous syntax with terns.
* Fix rest parameters in async and generator functions.
* Export/import declarations replace by the modules transformer now inherit comments.
* Added playground flag to `6to5-node`.
* `6to5-node` now behaves the same as `node`.
* `6to5-node` now uses `kexec` to become the forked process to correctly propagate signals on unix.
* Constants are now block scoped.
* Exposed ast transformer.
* Merged `commonInterop` and `common` module formatters.
* Fix generator comprehensions not inheriting `arguments`, `this` etc.
* Object and class mutator shorthand are now enumerable.
* Remove regenerator `Generator has already finished` error which isn't spec-compliant.
* Expose internal `spec` transformers that nicen up code output.
* Add export variable declaration default initializers.
* Propagate export declaration reassignments.
* Add initializer default to block scoped variable declarations within a loop.
* Flow type support.
* Make async/await contextual keywords.
* Allow `yield`ing of non-objects.
* Class declarations now lack an IIFE.
* Support falsy and `null` super classes.
* Add support for experimental abstract references `private` declarations.
* Leave out IIFE for class declarations.
* Switched to [core-js](https://github.com/zloirock/core-js) from [es6-symbol](https://github.com/medikoo/es6-symbol) and [es6-shim](https://github.com/paulmillr/es6-shim/) for built-in polyfill.
* `amd` and `umd` module formatters now behave the same as `common` with `interopRequire`.
* Micro-optimizations to boost performance by 200%.
* Rename module formatter methods `import` to `importDeclaration` and `export` to `exportDeclaration`.
* Support multiple declarators in export variable declarations.
* Freeze tagged template literal object.
* Remove inlined `regenerator` fork.
* Remove `ParenthesizedExpression`.
* Rename `object-spread` helper to `object-without-properties`.
* Rename `class-props` helper to `prototype-properties`.
* Rename `extends` helper to `inherits`.
* Completely rewritten `system` module formatter.
## 1.15.0
* Don't alias `GeneratorFunction` and check the name which causes minifiers to remove the name and throw an error later on when we check if it's set.
## 1.14.18
* Fix files only containg comments not being output.
* Fix duplicate comments on property key shorthands.
## 1.14.17
* Add default initializer to let variables within loop bodies.
* Fix excessive `break` replacement inside of switches in let scoping.
## 1.14.16
* Add object getter memos and this shorthand to playground.
* Fix while loops in let scoping.
* Upgrade `acorn-6to5`.
## 1.14.14
* Fix template literals escaping.
## 1.14.13
* Fix let scoping of `while` loops.
* Make class methods enumerable.
## 1.14.12
* Fix duplicate dynamic expressions in call spread.
## 1.14.10
* Fix let scoping unneccesary override.
## 1.14.6
* Avoid ensuring a block on non-array node replacements.
## 1.14.5
* Upgrade `acorn-6to5`.
* Fix JSON recursion error for unknown code generator node types.
* Ensure that a statement is a block on block/statement types when replacing them with multiple nodes.
## 1.14.4
* Merge pretzel maps and method binding.
## 1.14.3
* Add playground pretzel maps.
## 1.14.2
* Fix `commonInterop` default export handling.
* Fix keyworded property key identifiers being turned into computed property key literals.
## 1.14.1
* Inherit comments from `ClassDeclaration`.
## 1.14.0
* Add [playground](https://6to5.github.io/playground.html).
## 1.13.13
* Fix `--debug` in `bin/6to5-node`. Thanks [@timoxley](https://github.com/timoxley).
## 1.13.12
* Ignore `XJSEmptyExpression`s in `react` transformer output.
## 1.13.11
* Fix `util.regexify` on falsy values.
* Fix `_aliasFunction` with rest parameters.
* Export as `module.exports` instead of `exports.default` if there are no other `ExportDeclaration`s in `commonInterop` module formatter.
* Add `system` module formatter. Thanks [@douglasduteil](https://github.com/douglasduteil).
## 1.13.10
* Add support for `AssignmentExpression` destructuring outside of `ExpressionStatement`.
## 1.13.9
* Fix `VirtualPropertyExpression` visitor keys.
## 1.13.8
* Only use a single reference in abstract references.
## 1.13.7
* Upgrade `acorn-6to5`.
* Add experimental exponentiation operator support.
## 1.13.6
* Fix experimental object spread/rest helper.
## 1.13.5
* Upgrade `acorn-6to5`.
* Add experimental support for object spread/rest.
* Change `arguments` to array to an additional helper method.
## 1.13.4
* Fix single spread element returning itself.
## 1.13.3
* Upgrade `acorn-6to5`.
* Add experimental support for abstract references.
## 1.13.2
* Optimise `Array.from` usage by adding a helper method.
* Upgrade `acorn-6to5`.
## 1.13.1
* Fix constructor spread optimisation. Thanks [@zloirock](https://github.com/zloirock).
## 1.13.0
* Put experimental ES7 features behind a flag `--experimental` and `experimental` option.
* Constructor spread performance increase. Thanks [@RReverser](https://github.com/RReverser).
* Use `self` instead of `window` in the optional 6to5 runtime. Thanks [@RReverser](https://github.com/RReverser).
## 1.12.26
* Support computed property destructuring.
## 1.12.25
* Update `acorn-6to5`, `ast-types`, `es6-shim`, `chokidar`, `estraverse` and `private`.
## 1.12.24
* Collect references that haven't been declared in scope.
## 1.12.23
* Fix generator function export hoisting.
## 1.12.22
* Update `fs-readdir-recursive` and `chokidar`.
* Support array destructuring on iterables.
* Make amd module id optional. Thanks [@webpro](https://github.com/webpro).
## 1.12.21
* Fix unneccesary let scoping replacement.
* Add `commonInterop` module formatter. Thanks [@Naddiseo](https://github.com/Naddiseo).
* Fix `return` outside of function body bug. Thanks [@brentburg](https://github.com/brentburg).
* Add more flexible option types.
## 1.12.20
* Append `sourceMappingURL` when using `bin/6to5` and output sourcemaps.
## 1.12.19
* Add `comments` option and `--remove-comments` flag. Thanks [@webpro](htps://github.com/webpro).
* Embed `regenerator`.
## 1.12.18
* Use `global` reference instead of `window`.
## 1.12.17
* Add `moduleName`, `sourceRoot` and `filenameRelative` options. Thanks [@darvelo](https://github.com/darvelo).
* Traversal optimisations.
## 1.12.16
* Fix comments not being retained from `MethodDefinition` in classes.
* Add temporal dead zone in default parameters.
## 1.12.15
* Update `acorn-6to5`.
## 1.12.14
* Fix duplicate let scoping in functions.
* Make JSX whitespace more React-compliant.
* Add `_memberExpressionKeywords` transformer that turns keyword identifiers to computed literals.
* Upgrade `regenerator-6to5`.
## 1.12.13
* Support duplicate constants within different block scopes.
* Fix for-head duplication testing and replacement.
* Support `raw` property on tagged template literals.
## 1.12.12
* Make scope tracker more reliable to handle all edgecases.
## 1.12.11
* Block scope classes.
* Fix generation of integer `Literal`s in `MemberExpression`.
## 1.12.10
* Fix let scoping var hoisting.
## 1.12.9
* Escape unicode characters when generating string `Literal`s.
* Fix semicolons being output for statements in `ExportDeclaration`.
* Fix `WithStatement` missing parenthesis.
## 1.12.8
* Temporarily forbid `AssignmentExpression` destructuring outside of `ExpressionStatement`.
## 1.12.7
* Update to latest `acorn-6to5`.
## 1.12.6
* Update to latest `acorn-6to5`.
## 1.12.5
* Fix excessive whitespace trimming resulting in innaccurate sourcemap line.
## 1.12.4
* Add `doc` folder for documentation.
## 1.12.3
* Support generator comprehensions.
* Use `Array.from` instead of `Array.prototype.slice` in spread transformer.
* Support spread in `NewExpression`s.
## 1.12.2
* Upgrade `matcha` to `0.6.0` and `browserify` to `6.3.2`.
* Add own `trimRight` helper instead of relying on the string instance method.
* Support JSX spreads that aren't the first.
## 1.12.1
* Fix `this` and `arguments` mapping in the `_aliasFunctions` transformer.
## 1.12.0
* Combine `jsx` and `react` transformers to `react`.
* Update `react` syntax output to React v0.12.
## 1.11.15
* Fix JSX literal whitespace generation.
## 1.11.14
* Avoid using a switch for let-scoping continue and break statements and use an if statement instead.
* Remove excess whitespace and newlines from JSX literals.
## 1.11.13
* Update regenerator-6to5
* Add support for most escodegen formatting options

13
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,13 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)

46
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,46 @@
# 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).
## Developing
#### Workflow
* Fork the repository
* Clone your fork and change directory to it (`git clone git@github.com:yourUserName/6to5.git && cd 6to5`)
* Install the project dependencies (`make bootstrap`)
* Link your forked clone (`npm link`)
* Develop your changes ensuring you're fetching updates from upstream often
* Ensure the test are passing (`make test`)
* Create new pull request explaining your proposed change or reference an issue in your commit message
#### Code Standards
* **General**
* No ES6 syntax features or methods, exclusively ES5.
* Max of five arguments for functions
* Max depth of four nested blocks
* 2-spaced soft tabs
* **Naming**
* CamelCase all class names
* camelBack all variable names
* **Spacing**
* Spaces after all keywords
* Spaces before all left curly braces
* **Comments**
* Use JSDoc-style comments for methods
* Single-line comments for ambiguous code
* **Quotes**
* Always use double quotes
* Only use single quotes when the string contains a double quote
* **Declaration**
* No unused variables
* No pollution of global variables and prototypes
## Testing
$ make test
## Linting
$ make lint

View File

@@ -1,162 +0,0 @@
# Features
## Array comprehension
```javascript
[for (i of [1, 2, 3]) i * i]; // [1, 4, 9]
```
## Arrow functions
```javascript
arr.map(x => x * x);
```
## Let scoping
```javascript
for (let i in arr) {
let v = arr[i];
}
```
## Classes
```javascript
class Foo extends Bar {
constructor() { }
foo() { }
get bar() { }
set bar() { }
}
```
## Computed property names
```javascript
var foo = "foo";
var bar = "bar";
var obj = {
["foo" + bar]: "heh",
["bar" + foo]: "noo",
foo: "foo",
bar: "bar"
};
```
## Constants
```javascript
const MULTIPLIER = 5;
console.log(2 * MULTIPLIER);
MULTIPLIER = 6; // error
var MULTIPLIER; // error
```
## Default parameters
```javascript
function foo(bar = "foo") {
return bar + "bar";
}
```
## Destructuring
```javascript
var [a, [b], c, d] = ["hello", [", ", "junk"], ["world"]];
console.log(a + b + c); // hello, world
```
## For-of
```javascript
for (var i of [1, 2, 3]) {
console.log(i * i);
}
```
## Generators
```javascript
```
## Modules
```javascript
```
## Numeric literals
```javascript
0b111110111 === 503; // true
0o767 === 503; // true
```
## Property method assignment
```javascript
var obj = {
foo() {
return "foobar";
},
get bar() {
return this._bar;
},
set bar(val) {
this._bar = val;
}
};
```
## Property name shorthand
```javascript
function f(x, y) {
return { x, y };
}
```
## Rest parameters
```javascript
function printList(name, ...items) {
console.log("list %s has the following items", name);
items.forEach(function (item) {
console.log(item);
});
}
```
## Spread
```javascript
function add(x, y) {
return x + y;
}
var numbers = [5, 10];
add(...numbers); // 15
```
## Template literals
```javascript
var x = 5;
var y = 10;
console.log(`${x} + ${y} = ${x + y}`); // "5 + 10 = 15"
```
## Unicode regex
```javascript
var string = 'foo💩bar';
var match = string.match(/foo(.)bar/u);
console.log(match[1]);
```

View File

@@ -1,4 +1,4 @@
Copyright (c) 2014 Sebastian McKenzie
Copyright (c) 2014-2015 Sebastian McKenzie
MIT License

View File

@@ -1,145 +0,0 @@
# Modules
## Usage
### CLI
$ 6to5 --modules common script.js
### Node
```javascript
var to5 = require("6to5");
to5.transform('import "foo";', { modules: "common" });
```
## Formats
### Common (Default)
**In**
```javascript
import "foo";
import foo from "foo";
import * as foo from "foo";
import {bar} from "foo";
import {foo as bar} from "foo";
export {test};
export var test = 5;
export default test;
```
**Out**
```javascript
require("foo");
var foo = require("foo").default;
var foo = require("foo");
var bar = require("foo").bar;
var bar = require("foo").foo;
exports.test = test;
var test = 5; exports.test = test;
exports.default = test;
```
### AMD
**In**
```javascript
import foo from "foo";
export function bar() {
return foo("foobar");
}
```
**Out**
```javascript
define(["exports", "foo"], function (exports, _foo) {
exports.bar = bar;
var foo = _foo.default;
function bar() {
return foo("foobar");
}
});
```
### UMD
**In**
```javascript
import foo from "foo";
export function bar() {
return foo("foobar");
}
```
**Out**
```javascript
(function (factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "foo"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("foo"));
}
})(function (exports) {
exports.bar = bar;
var foo = _foo.default;
function bar() {
return foo("foobar");
}
});
```
## Custom
You can alternatively specify module names instead of one of the built-in types.
```javascript
module.exports = ModuleFormatter;
function ModuleFormatter() {
}
ModuleFormatter.prototype.transform = function (ast) {
// this is ran after all transformers have had their turn at modifying the ast
// feel free to modify this however
};
ModuleFormatter.prototype.import = function (node, nodes) {
// node is an ImportDeclaration
};
ModuleFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
// specifier is an ImportSpecifier
// node is an ImportDeclaration
};
ModuleFormatter.prototype.export = function (node, nodes) {
// node is an ExportDeclaration
};
ModuleFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
// specifier is an ExportSpecifier
// node is an ExportDeclaration
};
```

120
Makefile
View File

@@ -1,60 +1,112 @@
BROWSERIFY_CMD = node_modules/browserify/bin/cmd.js
ISTANBUL_CMD = node_modules/istanbul/lib/cli.js cover
UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs
#UGLIFY_CMD = node_modules/uglify-js/bin/uglifyjs --mangle sort
JSHINT_CMD = node_modules/jshint/bin/jshint
MOCHA_CMD = node_modules/mocha/bin/_mocha
JSCS_CMD = node_modules/jscs/bin/jscs
export NODE_ENV = test
.PHONY: clean test test-cov test-travis test-browser publish bench build
clean:
rm -rf coverage templates.json test/tmp dist
bench:
npm install es6-transpiler traceur esnext es6now jstransform
node node_modules/matcha/bin/_matcha
test:
$(JSHINT_CMD) lib bin benchmark/index.js
$(MOCHA_CMD)
test-cov:
rm -rf coverage
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
test-travis:
node $(ISTANBUL_CMD) $(MOCHA_CMD) -- --reporter spec
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
test-browser:
make build
node bin/generate-browser-test >dist/6to5-test.js
test -n "`which open`" && open test/browser.html
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap publish-core publish-runtime
build:
mkdir -p dist
node bin/cache-templates
node tools/cache-templates
browserify lib/6to5/browser.js -s to5 >dist/6to5.js
uglifyjs dist/6to5.js >dist/6to5.min.js
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 $(UGLIFY_CMD) dist/6to5.js >dist/6to5.min.js
rm -rf templates.json
clean:
rm -rf coverage templates.json test/tmp dist
lint:
$(JSHINT_CMD) --reporter node_modules/jshint-stylish/stylish.js lib bin
$(JSCS_CMD) lib bin
test-clean:
rm -rf test/tmp
test: lint
$(MOCHA_CMD)
make test-clean
test-simple:
# excludes test262
export SIMPLE_6TO5_TESTS=1; \
make test
test-all:
# includes traceur, esnext, regenerator
export ALL_6TO5_TESTS=1; \
make test
test-cov:
rm -rf coverage
export SIMPLE_6TO5_TESTS=1; \
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
test-travis: bootstrap
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
test-browser:
mkdir -p dist
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
test -n "`which open`" && open test/browser.html
publish:
git pull --rebase
make test
make build
cp dist/6to5.js browser.js
read -p "Version: " version; \
npm version $$version --message "v%s"
node bin/cache-templates
make build
cp dist/6to5.min.js browser.js
cp dist/polyfill.min.js browser-polyfill.js
node tools/cache-templates
test -f templates.json
read -p "Version: " version; \
npm version $$version --message "v%s"
npm publish
git push --follow-tags
rm -rf templates.json browser.js
make publish-core
make publish-runtime
rm -rf templates.json browser.js browser-polyfill.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
rm -rf package.json
mv .package.json package.json
bootstrap:
npm install
git submodule update --init
cd vendor/regenerator; npm install

3
NOTES.md Normal file
View File

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

385
README.md
View File

@@ -1,385 +1,12 @@
<p align="center">
<img alt="6to5" src="http://i.imgur.com/hVl9KRw.png">
<img alt="6to5" src="https://raw.githubusercontent.com/6to5/logo/master/logo.png" width="546">
</p>
<p align="center">
<a href="https://travis-ci.org/sebmck/6to5">
<img alt="Travis Status" src="http://img.shields.io/travis/sebmck/6to5.svg?style=flat&amp;label=travis">
</a>
<a href="https://codeclimate.com/github/sebmck/6to5">
<img alt="Code Climate Score" src="http://img.shields.io/codeclimate/github/sebmck/6to5.svg?style=flat">
</a>
<a href="https://codeclimate.com/github/sebmck/6to5">
<img alt="Coverage" src="http://img.shields.io/codeclimate/coverage/github/sebmck/6to5.svg?style=flat">
</a>
<a href="https://david-dm.org/sebmck/6to5">
<img alt="Dependency Status" src="http://img.shields.io/david/sebmck/6to5.svg?style=flat">
</a>
<strong>6to5</strong> turns ES6+ code into vanilla ES5, so you can use next generation features <strong>today.</strong>
</p>
**6to5** turns ES6 code into vanilla ES5, so you can use ES6 features **today.**
- **Readable** - formatting is retained if possible so your generated code is as similar as possible.
- **Extensible** - with a large range of [plugins](#plugins) and **browser support**.
- **Lossless** - **source map support** so you can debug your compiled code with ease.
- **Compact** - maps directly to the equivalent ES5 with **no runtime**[\*](#generators).
## Installation
It's as easy as:
$ npm install -g 6to5
## Table of Contents
- [Features](#features)
- [Usage](#usage)
- [Plugins](#plugins)
- [CLI](#cli)
- [Node](#node-1)
- [Browser](#browser)
- [Modules](#modules)
- [Caveats](#caveats)
- [Differences](#differences)
## [Features](FEATURES.md)
- [Array comprehension](FEATURES.md#array-comprehension)
- [Arrow functions](FEATURES.md#arrow-functions)
- [Classes](FEATURES.md#classes)
- [Computed property names](FEATURES.md#computed-property-names)
- [Constants](FEATURES.md#constants)
- [Default parameters](FEATURES.md#default-parameters)
- [Destructuring](FEATURES.md#destructuring)
- [For-of](FEATURES.md#for-of)
- [Generators](FEATURES.md#generators) via [regenerator](https://github.com/facebook/regenerator)
- [Let scoping](FEATURES.md#let-scoping)
- [Modules](FEATURES.md#modules)
- [Numeric literals](FEATURES.md#numeric-literals)
- [Property method assignment](FEATURES.md#property-method-assignment)
- [Property name shorthand](FEATURES.md#property-name-shorthand)
- [Rest parameters](FEATURES.md#rest-parameters)
- [Spread](FEATURES.md#spread)
- [Template literals](FEATURES.md#template-literals)
- [Unicode regex](FEATURES.md#unicode-regex)
## Usage
### Plugins
- [Broccoli](https://github.com/very-geek/broccoli-6to5-transpiler)
- [Browserify](https://github.com/sebmck/6to5-browserify)
- [Brunch](https://github.com/es128/6to5-brunch)
- [Connect](https://github.com/sebmck/6to5-connect)
- [Gulp](https://github.com/sindresorhus/gulp-6to5)
- [Grunt](https://github.com/sindresorhus/grunt-6to5)
- [Jade](https://github.com/Apoxx/jade-6to5)
- [webpack](https://github.com/Couto/6to5-loader)
### CLI
Compile the file `script.js` and output it to stdout.
$ 6to5 script.js
Compile the file `script.js` and output it to `script-compiled.js`.
$ 6to5 script.js --out-file script-compiled.js
Compile the file `script.js` and output it to `script-compiled.js` and save a
source map to `script-compiled.js.map`.
$ 6to5 script.js --source-maps --out-file script-compiled.js
Compile the file `script.js` and output it to `script-compiled.js` with a source
map embedded in a comment at the bottom.
$ 6to5 script.js --source-maps-inline --out-file script-compiled.js
Compile the entire `src` directory and output it to the `lib` directory.
$ 6to5 src --out-dir lib
Pipe a file in via stdin and output it to `script-compiled.js`
$ 6to5 --out-file script-compiled.js < script.js
#### Node
Launch a repl.
$ 6to5-node
Evaluate code.
$ 6to5-node -e "class Test { }"
Compile and run `test.js`.
$ 6to5-node test
### Node
```javascript
var to5 = require("6to5");
var result = to5.transform("code();", options);
result.code;
result.map;
result.ast;
to5.transformFileSync("filename.js", options).code;
to5.transformFile("filename.js", options, function (err, result) {
});
```
##### Options
```javascript
{
// Filename for use in errors etc.
// Default: "unknown"
filename: "filename",
// List of transformers to EXCLUDE.
// Run `6to5 --help` to see a full list of transformers.
blacklist: [],
// List of transformers to ONLY use.
// Run `6to5 --help` to see a full list of transformers.
whitelist: [],
// Module formatter to use
// Run `6to5 --help` to see a full list of module formatters.
// Default: "common"
modules: "common",
// If truthy, adds a `map` property to returned output.
// If set to "inline", a comment with a sourceMappingURL directive is added to
// the bottom of the returned code.
// Default: false
sourceMap: true,
// Set `file` on returned source map.
// Default: `filename` option.
sourceMapName: "filename",
// Set `sources[0]` on returned source map.
// Default: `filename` option.
sourceFileName: "filename"
}
```
#### Require hook
All subsequent files required by node with the extensions `.es6` and `.js` will
be transformed by 6to5. The polyfill specified in [Polyfill](#polyfill) is also
required.
```javascript
require("6to5/register");
```
**NOTE:** By default all requires to `node_modules` will be ignored. You can
override this by passing an ignore regex via:
```javascript
require("6to5/register")(/regex/);
```
You can also customise the file extensions that the require hook will use via:
```javascript
require("6to5/register")({
// optional ignore regex
ignoreRegex: /regex/,
// this will remove the currently hooked extensions of .es6 and .js so you'll
// have to add them back if you want them to be used again
extensions: [".js", ".es6"]
});
```
### Browser
You can build a browser version of the compiler by running the following in the
6to5 directory:
$ make build
This will output the files `dist/6to5.js` and `dist/6to5.min.js`.
Just include one of those in the browser and access the transform method via the
global `to5`.
```javascript
to5("class Test {}").code;
```
#### Test
To test 6to5 in your browser run:
$ make test-browser
And open `test/browser.html` in your browser if it doesn't open automatically.
## [Modules](MODULES.md)
See [Modules - Common](MODULES.md#common-default) for documentation on the
default module formatting.
Alternatively see [Modules](MODULES.md) for all other supported module formatting types.
## Caveats
### Polyfill
6to5 does not include a runtime nor polyfill and it's up to the developer to
include one in compiled browser code.
#### Node
A polyfill is included with the 6to5 module that can be included in node like
so:
```javascript
require("6to5/polyfill");
```
This is simply a wrapper around the
[regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js) and the
[es6-shim](https://github.com/paulmillr/es6-shim) and
[es6-symbol](https://github.com/medikoo/es6-symbol) polyfills.
#### Browser
If you're planning on using 6to5 output in the browser then it's up to you
to include polyfills. [es6-symbol](https://github.com/medikoo/es6-symbol#browser)
and [es6-shim](https://raw.githubusercontent.com/paulmillr/es6-shim/master/es6-shim.js)
fill the vast majority of polyfill concerns.
### For-of
A polyfill is required for for-of functionality that implements `Symbol` and
adds `prototype[Symbol.iterator]` behaviour to built-ins. Using the polyfills
specified in [polyfill](#polyfill) suffices.
### Classes
Built-in classes such as `Date`, `Array` and `DOM` cannot be subclassed due to
limitations in ES5 implementations.
If you're inheriting from a class then static properties are inherited from it
via [\_\_proto\_\_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto),
this is widely supported but you may run into problems with much older browsers.
### Generators
The [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
and an [ES6 polyfill](#polyfill) are required in order for generators to work.
## Differences
### Philosophy
The fundamental concept behind 6to5 is that the generated code must be close as
possible to the original, retaining all the same formatting and readability.
Many other transpilers are just concerned with making the code work while 6to5
is concerned with making sure it works **and** is readable at the same time.
For example, given the following array comprehension:
```javascript
var seattlers = [for (c of customers) if (c.city == "Seattle") { name: c.name, age: c.age }];
```
is generated to the following with 6to5:
```javascript
var seattlers = customers.filter(function (c) {
return c.city == "Seattle";
}).map(function (c) {
return {
name: c.name,
age: c.age
};
});
```
The following is what Traceur generates:
```javascript
var seattlers = (function() {
var c;
var $__20 = 0,
$__21 = [];
for (var $__22 = customers[$traceurRuntime.toProperty(Symbol.iterator)](),
$__23; !($__23 = $__22.next()).done; ) {
c = $__23.value;
if (c.city == "Seattle")
$traceurRuntime.setProperty($__21, $__20++, {
name: c.name,
age: c.age
});
}
return $__21;
}());
```
As you can tell, it's not very pretty, unreadable even. Instead of mapping
directly to a runtime, like other transpilers, 6to5 maps directly to the
equivalent ES5.
I'm not saying 6to5 is for everyone or even suited for everything. Traceur is
better suited if you'd like a full ES6 environment with polyfills and all.
### Comparison to other transpilers
| | 6to5 | Traceur | esnext | es6now | es6-transpiler | jstransform |
| ---------------------------- | ---- | ------- | ------ | ------ | -------------- | ----------- |
| No runtime | ✓ | | | | ✓ | ✓ |
| Source maps | ✓ | ✓ | ✓ | | ✓ | ✓ |
| No compiler global pollution | ✓ | | ✓ | | ✓ | ✓ |
| Arrow functions | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Classes | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Computed property names | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Constants | ✓ | ✓ | | | ✓ | |
| Default parameters | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Destructuring | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| For-of | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Generators | ✓ | ✓ | ✓ | | | |
| Let scoping | ✓ | ✓ | | | ✓ | |
| Modules | ✓ | ✓ | | ✓ | | |
| Property method assignment | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Property name shorthand | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Rest parameters | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Spread | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Template literals | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Unicode regex | ✓ | ✓ | | | ✓ | |
#### [Traceur](https://github.com/google/traceur-compiler)
Traceur requires quite a bulky runtime (~75KB) and produces quite verbose code.
While this can be trimmed down by selectively building the runtime, it's an
unneccesary step when a runtime can be eliminated entirely.
#### [es6now](https://github.com/zenparsing/es6now)
es6now doesn't output sourcemaps. This is cited as a positive as line-to-line
mapping is the goal. This however obviously doesn't retain column mapping
resulting in the output code not being very pleasant.
#### [es6-transpiler](https://github.com/termi/es6-transpiler)
The es6-transpiler compiler requires shims to operate which pollutes the global
scope resulting in possible collisions.
es6-transpiler maps line-by-line, just like es6now, this results in the same
issues such as lack of column information and unpleasant code output.
<p align="center">
For more information view the <a href="https://6to5.github.io">documentation</a>. For
support visit the <a href="https://gitter.im/6to5/6to5">gitter room</a>.
</p>

17
appveyor.yml Normal file
View File

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

View File

@@ -1,99 +0,0 @@
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var obj = {};
var foo = "foo";
var bar = "bar";
// constants
const MULTIPLIER = 5;
// classes
class Foo {
constructor() {
this.foo = "bar";
}
}
class Bar extends Foo {
constructor() {
super();
}
// default parameters
go(foo = "bar", bar = "foo") {
}
// not supported by jstransform
//get foo() {
// return this._foo;
//}
//set foo(val) {
// this._foo = val + " foo!";
//}
}
// arrow functions
arr.map(x => x * x);
// block binding
for (let key in arr) {
let val = arr[key];
console.log(key, val);
}
// computed property names
obj = {
["foo" + bar]: "foobar"
};
// destructuring
var [a, [b], c, d] = ["hello", [", ", "junk"], ["world"]];
console.log(a + b + c);
// array comprehension
// [for (i of [1, 2, 3]) i * i]; // not supported by es6now
// for-of
for (var i of [1, 2, 3]) {
console.log(i * i);
}
// property method assignment
obj = {
foo() {
return "foobar";
},
get bar() {
return this._bar;
},
set bar(val) {
this._bar = val;
}
};
// property name shorthand
function f(x, y) {
return { x, y };
}
// rest parameters
function printList(name, ...items) {
console.log("list %s has the following items", name);
items.forEach(function (item) {
console.log(item);
});
}
// spread
function add(x, y) {
return x + y;
}
var numbers = [5, 10];
add(...numbers);
// template literals
var x = 5;
var y = 10;
console.log(`${x} + ${y} = ${x + y}`);

View File

@@ -1,168 +0,0 @@
Error.stackTraceLimit = Infinity;
var jsTrans = require("jstransform");
var traceur = require("traceur");
var es6tr = require("es6-transpiler");
var es6now = require("es6now");
var esnext = require("esnext");
var to5 = require("../lib/6to5");
//var uglify = require("uglify-js");
var matcha = require("matcha");
var path = require("path");
var fs = require("fs");
var _ = require("lodash");
var readResolve = function (filename) {
try {
filename = require.resolve(filename);
} catch (err) {
return null;
}
return fs.readFileSync(filename, "utf8");
};
var getVersion = function (name) {
return require(name + "/package.json").version;
};
var jsTransVisitors = [];
_.each([
"arrow-function-visitors", "class-visitors", "destructuring-visitors",
"object-concise-method-visitors", "object-short-notation-visitors",
"rest-param-visitors", "template-visitors"
], function (name) {
var mod = require("jstransform/visitors/es6-" + name);
jsTransVisitors = jsTransVisitors.concat(mod.visitorList);
});
var compilers = {
"6to5": {
version: getVersion(".."),
compile: function (code, filename) {
return to5.transform(code, { filename: filename }).code;
}
},
traceur: {
runtime: readResolve("traceur/bin/traceur-runtime.js"),
compile: function (code) {
return traceur.compile(code, {
modules: "commonjs",
experimental: true
});
}
},
esnext: {
runtime: readResolve("esnext/node_modules/regenerator/runtime.js") || readResolve("regenerator/runtime.js"),
compile: function (code) {
return esnext.compile(code).code;
}
},
es6now: {
runtime: readResolve("es6now/runtime/ES6.js"),
compile: function (code) {
return es6now.translate(code);
}
},
"es6-transpiler": {
compile: function (code) {
var result = es6tr.run({ src: code });
if (result.errors.length) throw new Error(result.join("; "));
return result.src;
}
},
jstransform: {
compile: function (code) {
return jsTrans.transform(jsTransVisitors, code).code;
}
}
};
// versions
//var uglifyTitle = "uglify v" + getVersion("uglify-js");
_.each(compilers, function (compiler, name) {
compiler.title = name + " v" + (compiler.version || getVersion(name));
});
//
var sizeBenchmark = function (code, loc, name, compiler) {
var log = function (output, title) {
title = [compiler.title].concat(title || []).join(" + ");
var text;
var color;
if (output.stack) {
text = "error";
color = "red";
} else {
var kilo = (output.length / 1024).toFixed(2);
text = kilo + "KB";
color = "cyan";
}
text = matcha.utils.color(matcha.utils.padBefore(text, 22), color);
console.log(text, matcha.utils.color("» " + title, "gray"));
if (output.stack) {
console.error(output.stack);
}
};
var go = function (getOutput, title) {
var code;
try {
code = getOutput();
} catch (err) {
log(err, title);
return;
}
log(code, title);
};
var output;
go(function () {
return output = compiler.compile(code, loc);
});
if (!output) return;
//go(function () {
// return uglify.minify(output, { fromString: true }).code;
//}, uglifyTitle);
};
//
_.each(fs.readdirSync(__dirname + "/fixtures"), function (name) {
var alias = path.basename(name, path.extname(name));
suite(alias, function () {
set("delay", 0);
var loc = __dirname + "/fixtures/" + name;
var code = fs.readFileSync(loc, "utf8");
before(function () {
_.each(compilers, function (compiler, name) {
sizeBenchmark(code, loc, name, compiler);
});
});
_.each(compilers, function (compiler) {
bench(compiler.title, function () {
compiler.compile(code, loc);
});
});
});
});

View File

@@ -1,83 +1,68 @@
#!/usr/bin/env node
var commander = require("commander");
var util = require("../lib/6to5/util");
var path = require("path");
var repl = require("repl");
var to5 = require("../lib/6to5");
var vm = require("vm");
var _ = require("lodash");
/**
* This tiny wrapper file checks for known node flags and appends them
* when found, before invoking the "real" _6to5-node(1) executable.
*/
commander.option("-e, --eval [script]", "evaluate script");
commander.option("-p, --print", "evaluate script and print result");
commander.option("-i, --ignore [regex]", "ignore all files that match this regex when using the require hook");
commander.option("-x, --extensions [extensions]", "list of extensions to hook into [.es6,.js]", util.list);
var args = ["--harmony", __dirname + "/_6to5-node"];
var pkg = require("../package.json");
commander.version(pkg.version);
commander.usage("[options] [ -e script | script.js ] [arguments]");
commander.parse(process.argv);
process.argv.slice(2).forEach(function(arg){
var flag = arg.split("=")[0];
//
switch (flag) {
case "-d":
args.unshift("--debug");
break;
var registerOpts = {};
case "debug":
case "--debug":
case "--debug-brk":
args.unshift(arg);
break;
if (commander.ignore) {
registerOpts.ignoreRegex = new RegExp(commander.ignore);
}
case "-gc":
case "--expose-gc":
args.unshift("--expose-gc");
break;
if (commander.extensions && commander.extensions.length) {
registerOpts.extensions = commander.extensions
}
case "--gc-global":
case "--harmony":
case "--harmony-proxies":
case "--harmony-collections":
case "--harmony-generators":
case "--no-deprecation":
case "--prof":
case "--throw-deprecation":
case "--trace-deprecation":
args.unshift(arg);
break;
to5.register(registerOpts);
//
var _eval = function (code, filename) {
code = to5.transform(code, { filename: filename }).code;
return vm.runInThisContext(code, filename);
};
if (commander.eval) {
var result = _eval(commander.eval, "eval");
if (commander.print) console.log(result);
} else {
var filenames = commander.args;
if (filenames.length) {
_.each(filenames, function (filename) {
if (!util.isAbsolute(filename)) {
filename = path.join(process.cwd(), filename);
default:
if (arg.indexOf("--trace") === 0) {
args.unshift(arg);
} else {
args.push(arg);
}
require(require.resolve(filename));
});
} else {
replStart();
break;
}
}
});
function replStart() {
repl.start({
prompt: "> ",
input: process.stdin,
output: process.stdout,
eval: replEval,
useGlobal: true
try {
var kexec = require("kexec");
kexec(process.argv[0], args);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
var child_process = require("child_process");
var proc = child_process.spawn(process.argv[0], args, { stdio: "inherit" });
proc.on("exit", function (code, signal) {
process.on("exit", function () {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
})
});
}
function replEval(code, context, filename, callback) {
var err;
var result;
try {
code = code.slice(1, -2); // remove "(" and "\n)"
result = _eval(code, filename);
} catch (e) {
err = e;
}
callback(err, result);
}

View File

@@ -1,9 +1,9 @@
var chokidar = require("chokidar");
var mkdirp = require("mkdirp");
var path = require("path");
var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
var outputFileSync = require("output-file-sync");
var chokidar = require("chokidar");
var path = require("path");
var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
module.exports = function (commander, filenames, opts) {
if (commander.sourceMapsInline) {
@@ -15,14 +15,13 @@ module.exports = function (commander, filenames, opts) {
var data = util.compile(src, { sourceMapName: dest });
var up = path.normalize(dest + "/..");
mkdirp.sync(up);
if (commander.sourceMaps) {
fs.writeFileSync(dest + ".map", JSON.stringify(data.map));
var mapLoc = dest + ".map";
data.code = util.addSourceMappingUrl(data.code, mapLoc);
outputFileSync(mapLoc, JSON.stringify(data.map));
}
fs.writeFileSync(dest, data.code);
outputFileSync(dest, data.code);
console.log(src + " -> " + dest);
};
@@ -52,7 +51,7 @@ 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);

View File

@@ -28,7 +28,7 @@ module.exports = function (commander, filenames) {
map.setSourceContent(filename, result.actual);
consumer.eachMapping(function (mapping) {
map._mappings.push({
map._mappings.add({
generatedLine: mapping.generatedLine + offset,
generatedColumn: mapping.generatedColumn,
originalLine: mapping.originalLine,
@@ -56,12 +56,14 @@ module.exports = function (commander, filenames) {
if (commander.outFile) {
if (commander.sourceMaps) {
fs.writeFileSync(commander.outFile + ".map", JSON.stringify(result.map));
var mapLoc = commander.outFile + ".map";
result.code = util.addSourceMappingUrl(result.code, mapLoc);
fs.writeFileSync(mapLoc, JSON.stringify(result.map));
}
fs.writeFileSync(commander.outFile, result.code);
} else {
console.log(result.code);
process.stdout.write(result.code + "\n");
}
};
@@ -75,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();
});
@@ -100,8 +102,8 @@ module.exports = function (commander, filenames) {
}
});
_.each(_filenames, function (filename, i) {
results.push(util.compile(filename, { _noStrict: +i !== 0 }));
_.each(_filenames, function (filename) {
results.push(util.compile(filename));
});
output();
@@ -111,16 +113,14 @@ module.exports = function (commander, filenames) {
walk();
if (commander.watch) {
var watcher = chokidar.watch(filenames, {
chokidar.watch(filenames, {
persistent: true,
ignoreInitial: true
});
_.each(["add", "change", "unlink"], function (type) {
watcher.on(type, function (filename) {
}).on("all", function (type, filename) {
if (type === "add" || type === "change") {
console.log(type, filename);
walk();
});
}
});
}
};

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env node
var commander = require("commander");
var transform = require("../../lib/6to5/transform");
var transform = require("../../lib/6to5/transformation/transform");
var util = require("../../lib/6to5/util");
var fs = require("fs");
var _ = require("lodash");
@@ -10,20 +10,33 @@ commander.option("-t, --source-maps-inline", "Append sourceMappingURL comment to
commander.option("-s, --source-maps", "Save source map alongside the compiled code");
commander.option("-f, --filename [filename]", "Filename to use when reading from stdin - this will be used in source-maps, errors etc [stdin]", "stdin");
commander.option("-w, --watch", "Recompile files on changes");
commander.option("-e, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-p, --playground", "Enable playground support");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-l, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list);
commander.option("-L, --loose [list]", "List of transformers to enable loose mode ON", util.list);
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
commander.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory");
commander.option("-c, --remove-comments", "Remove comments from the compiled code", false);
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
commander.option("--keep-module-id-extensions", "Keep extensions when generating module ids", false);
commander.on("--help", function(){
commander.on("--help", function () {
var outKeys = function (title, obj) {
console.log(" " + title + ":");
console.log();
_.each(_.keys(obj).sort(), function (key) {
if (key[0] === "_") return;
if (obj[key].optional) {
key = "[" + key + "]";
}
console.log(" - " + key);
});
@@ -83,11 +96,19 @@ if (errors.length) {
//
exports.opts = {
sourceMapName: commander.outFile,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
modules: commander.modules
keepModuleIdExtensions: commander.keepModuleIdExtensions,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
playground: commander.playground,
moduleIds: commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
modules: commander.modules,
loose: commander.loose
};
var fn;

View File

@@ -1,19 +1,36 @@
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 fs = require("fs");
var _ = require("lodash");
exports.readdirFilter = function (filename) {
return readdir(filename).filter(util.canCompile);
return readdir(filename).filter(function (filename) {
return util.canCompile(filename);
});
};
exports.addSourceMappingUrl = function (code, loc) {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
};
exports.transform = function (filename, code, opts) {
opts = _.extend(opts || {}, index.opts);
opts.filename = filename;
var result = to5.transform(code, opts);
var result;
try {
result = to5.transform(code, opts);
} catch (e) {
if (e instanceof SyntaxError) {
console.error("SyntaxError:", e.message);
process.exit(1);
} else {
throw e;
}
}
result.filename = filename;
result.actual = code;
return result;

110
bin/_6to5-node Normal file
View File

@@ -0,0 +1,110 @@
#!/usr/bin/env node
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 program = new commander.Command("6to5-node");
program.option("-e, --eval [script]", "Evaluate script");
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,.es,.jsx]");
program.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
program.option("-g, --playground", "Enable playground support");
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);
var pkg = require("../package.json");
program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);
//
to5.register({
experimental: program.experimental,
extensions: program.extensions,
playground: program.playground,
blacklist: program.blacklist,
whitelist: program.whitelist,
ignore: program.ignore
});
//
var _eval = function (code, filename) {
code = to5.transform(code, {
filename: filename,
blacklist: ["useStrict"].concat(program.blacklist || []),
whitelist: program.whitelist,
experimental: program.experimental,
playground: program.playground
}).code;
return vm.runInThisContext(code, filename);
};
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) {
// slice all arguments up to the first filename since they're 6to5 args that we handle
var args = process.argv.slice(2);
var i = 0;
_.each(args, function (arg, i2) {
if (arg[0] !== "-") {
i = i2;
return false;
}
});
args = args.slice(i);
// make the filename absolute
var filename = args[0]
if (!util.isAbsolute(filename)) args[0] = path.join(process.cwd(), filename);
// add back on node and concat the sliced args
process.argv = ["node"].concat(args);
Module.runMain();
} else {
replStart();
}
}
function replStart() {
repl.start({
prompt: "> ",
input: process.stdin,
output: process.stdout,
eval: replEval,
useGlobal: true
});
}
function replEval(code, context, filename, callback) {
var err;
var result;
try {
if (code[0] === "(" && code[code.length - 1] === ")") {
code = code.slice(1, -1); // remove "(" and ")"
}
result = _eval(code, filename);
} catch (e) {
err = e;
}
callback(err, result);
}

View File

@@ -1,6 +0,0 @@
#!/usr/bin/env node
var helper = require("../test/_helper");
var util = require("../lib/6to5/util");
console.log("(" + helper.run + ")(" + JSON.stringify(helper.getTests()) + ", to5, proclaim)");

1
doc/index.md Normal file
View File

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

View File

@@ -1,3 +1,85 @@
var transform = require("./transform");
"use strict";
module.exports = transform;
var transform = module.exports = require("./transformation/transform");
transform.version = require("../../package").version;
transform.transform = transform;
transform.run = function (code, opts) {
opts = opts || {};
opts.sourceMap = "inline";
return new Function(transform(code, opts).code)();
};
transform.load = function (url, callback, opts, hold) {
opts = opts || {};
opts.filename = opts.filename || url;
var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
xhr.open("GET", url, true);
if ("overrideMimeType" in xhr) xhr.overrideMimeType("text/plain");
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) return;
var status = xhr.status;
if (status === 0 || status === 200) {
var param = [xhr.responseText, opts];
if (!hold) transform.run.apply(transform, param);
if (callback) callback(param);
} else {
throw new Error("Could not load " + url);
}
};
xhr.send(null);
};
var runScripts = function () {
var scripts = [];
var types = ["text/ecmascript-6", "text/6to5", "module"];
var index = 0;
var exec = function () {
var param = scripts[index];
if (param instanceof Array) {
transform.run.apply(transform, param);
index++;
exec();
}
};
var run = function (script, i) {
var opts = {};
if (script.src) {
transform.load(script.src, function (param) {
scripts[i] = param;
exec();
}, opts, true);
} else {
opts.filename = "embedded";
scripts[i] = [script.innerHTML, opts];
}
};
var _scripts = global.document .getElementsByTagName("script");
for (var i = 0; i < _scripts.length; ++i) {
var _script = _scripts[i];
if (types.indexOf(_script.type) >= 0) scripts.push(_script);
}
for (i in scripts) {
run(scripts[i], i);
}
exec();
};
if (global.addEventListener) {
global.addEventListener("DOMContentLoaded", runScripts, false);
} else if (global.attachEvent) {
global.attachEvent("onload", runScripts);
}

View File

@@ -1,57 +1,212 @@
"use strict";
module.exports = File;
var SHEBANG_REGEX = /^\#\!.*/;
var transform = require("./transform");
var recast = require("acorn-recast");
var transform = require("./transformation/transform");
var generate = require("./generation/generator");
var clone = require("./helpers/clone");
var Scope = require("./traverse/scope");
var util = require("./util");
var b = require("acorn-ast-types").builders;
var t = require("./types");
var _ = require("lodash");
function File(opts) {
this.opts = File.normaliseOptions(opts);
this.moduleFormatter = this.getModuleFormatter(opts.modules);
this.dynamicImportIds = {};
this.dynamicImported = [];
this.dynamicImports = [];
this.declarations = {};
this.uids = {};
this.ast = {};
this.dynamicData = {};
this.data = {};
this.lastStatements = [];
this.opts = File.normaliseOptions(opts);
this.ast = {};
this.buildTransformers();
}
File.helpers = [
"inherits",
"defaults",
"prototype-properties",
"apply-constructor",
"tagged-template-literal",
"tagged-template-literal-loose",
"interop-require",
"to-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice",
"bind",
"define-property",
"async-to-generator",
"interop-require-wildcard",
"typeof",
"extends",
"get"
];
File.validOptions = [
"filename",
"filenameRelative",
"blacklist",
"whitelist",
"loose",
"optional",
"modules",
"sourceMap",
"sourceMapName",
"sourceFileName",
"sourceRoot",
"moduleRoot",
"moduleIds",
"comments",
"reactCompat",
"keepModuleIdExtensions",
"code",
"ast",
"format",
"playground",
"experimental",
// these are used by plugins
"ignore",
"only",
"extensions"
];
File.normaliseOptions = function (opts) {
opts = 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, {
blacklist: [],
whitelist: [],
sourceMap: false,
filename: "unknown",
modules: "common"
keepModuleIdExtensions: false,
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
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);
}
_.defaults(opts, {
moduleRoot: opts.sourceRoot
});
_.defaults(opts, {
sourceFileName: opts.filename,
sourceMapName: opts.filename
sourceRoot: opts.moduleRoot
});
transform._ensureTransformerNames("blacklist", opts.blacklist);
transform._ensureTransformerNames("whitelist", opts.whitelist);
_.defaults(opts, {
filenameRelative: opts.filename
});
_.defaults(opts, {
sourceFileName: opts.filenameRelative,
sourceMapName: opts.filenameRelative
});
if (opts.playground) {
opts.experimental = true;
}
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);
return opts;
};
File.prototype.isLoose = function (key) {
return _.contains(this.opts.loose, key);
};
File.prototype.buildTransformers = function () {
var file = this;
var transformers = {};
var secondaryStack = [];
var stack = [];
_.each(transform.transformers, function (transformer, key) {
var pass = transformers[key] = transformer.buildPass(file);
if (pass.canRun(file)) {
stack.push(pass);
if (transformer.secondPass) {
secondaryStack.push(pass);
}
if (transformer.manipulateOptions) {
transformer.manipulateOptions(file.opts, file);
}
}
});
this.transformerStack = stack.concat(secondaryStack);
this.transformers = transformers;
};
File.prototype.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 ModuleLoader = transform.moduleFormatters[type];
var ModuleFormatter = _.isFunction(type) ? type : transform.moduleFormatters[type];
if (!ModuleLoader) {
if (!ModuleFormatter) {
var loc = util.resolve(type);
if (loc) ModuleLoader = require(loc);
if (loc) ModuleFormatter = require(loc);
}
if (!ModuleLoader) {
throw new ReferenceError("unknown module formatter type " + type);
if (!ModuleFormatter) {
throw new ReferenceError("Unknown module formatter type " + JSON.stringify(type));
}
return new ModuleLoader(this);
return new ModuleFormatter(this);
};
File.prototype.parseShebang = function (code) {
@@ -66,85 +221,180 @@ File.prototype.parseShebang = function (code) {
return code;
};
File.prototype.addDeclaration = function (name) {
var declar = this.declarations[name];
if (declar) return declar.uid;
File.prototype.set = function (key, val) {
return this.data[key] = val;
};
var uid = b.identifier(this.generateUid(name));
this.declarations[name] = {
uid: uid,
node: util.template(name)
};
return uid;
File.prototype.setDynamic = function (key, fn) {
this.dynamicData[key] = fn;
};
File.prototype.get = function (key) {
var data = this.data[key];
if (data) {
return data;
} else {
var dynamic = this.dynamicData[key];
if (dynamic) {
return this.set(key, dynamic());
}
}
};
File.prototype.addImport = function (source, name) {
name = name || source;
var id = this.dynamicImportIds[name];
if (!id) {
id = this.dynamicImportIds[name] = this.generateUidIdentifier(name);
var specifiers = [t.importSpecifier(t.identifier("default"), id)];
var declar = t.importDeclaration(specifiers, t.literal(source));
declar._blockHoist = 3;
this.dynamicImported.push(declar);
this.moduleFormatter.importSpecifier(specifiers[0], declar, this.dynamicImports);
}
return id;
};
File.prototype.isConsequenceExpressionStatement = function (node) {
return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0;
};
File.prototype.addHelper = function (name) {
if (!_.contains(File.helpers, name)) {
throw new ReferenceError("unknown declaration " + name);
}
var program = this.ast.program;
var declar = program._declarations && program._declarations[name];
if (declar) return declar.id;
var runtime = this.get("runtimeIdentifier");
if (runtime) {
name = t.identifier(t.toIdentifier(name));
return t.memberExpression(runtime, name);
} else {
var ref = util.template(name);
ref._compact = true;
var uid = this.generateUidIdentifier(name);
this.scope.push({
key: name,
id: uid,
init: ref
});
return uid;
}
};
File.prototype.errorWithNode = function (node, msg, Error) {
Error = Error || SyntaxError;
var loc = node.loc.start;
var err = new Error("Line " + loc.line + ": " + msg);
err.loc = loc;
return err;
};
File.prototype.addCode = function (code) {
code = (code || "") + "";
this.code = code;
return this.parseShebang(code);
};
File.prototype.parse = function (code) {
var self = this;
code = this.parseShebang(code);
code = this.addCode(code);
return util.parse(this.opts, code, function (tree) {
var opts = this.opts;
opts.allowImportExportEverywhere = this.isLoose("modules");
return util.parse(opts, code, function (tree) {
self.transform(tree);
return self.generate();
});
};
File.prototype.transform = function (ast) {
this.ast = ast;
var self = this;
_.each(transform.transformers, function (transformer) {
transformer.transform(self);
this.ast = ast;
this.lastStatements = t.getLastStatements(ast.program);
this.scope = new Scope(ast.program, ast, null, this);
this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
var astRun = function (key) {
_.each(self.transformerStack, function (pass) {
pass.astRun(key);
});
};
astRun("enter");
_.each(this.transformerStack, function (pass) {
pass.transform();
});
astRun("exit");
};
File.prototype.generate = function () {
var opts = this.opts;
var ast = this.ast;
var printOpts = { tabWidth: 2 };
var result = {
code: "",
map: null,
ast: null
};
if (opts.sourceMap) {
printOpts.sourceMapName = opts.sourceMapName;
}
if (opts.ast) result.ast = ast;
if (!opts.code) return result;
var result = recast.print(ast, printOpts);
var code = result.code;
var _result = generate(ast, opts, this.code);
result.code = _result.code;
result.map = _result.map;
if (this.shebang) {
// add back shebang
code = this.shebang + code;
result.code = this.shebang + "\n" + result.code;
}
if (opts.sourceMap === "inline") {
code += "\n" + util.sourceMapToComment(result.map);
result.code += "\n" + util.sourceMapToComment(result.map);
}
return {
code: code,
map: result.map || null,
ast: ast
};
return result;
};
File.prototype.generateUid = function (name) {
// replace all non-valid identifiers with dashes
name = name.replace(/[^a-zA-Z0-9]/g, "-");
File.prototype.generateUid = function (name, scope) {
name = t.toIdentifier(name).replace(/^_+/, "");
// remove all dashes and numbers from start of name
name = name.replace(/^[-0-9]+/, "");
scope = scope || this.scope;
// camel case
name = name.replace(/[-_\s]+(.)?/g, function (match, c) {
return c ? c.toUpperCase() : "";
});
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (scope.has(uid));
return uid;
};
var uids = this.uids;
var i = uids[name] || 1;
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, i) {
var id = name;
if (i > 1) id += i;
uids[name] = i + 1;
return "_" + id;
};

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,29 @@
"use strict";
exports.ComprehensionBlock = function (node, print) {
this.keyword("for");
this.push("(");
print(node.left);
this.push(" of ");
print(node.right);
this.push(")");
};
exports.ComprehensionExpression = function (node, print) {
this.push(node.generator ? "(" : "[");
print.join(node.blocks, { separator: " " });
this.space();
if (node.filter) {
this.keyword("if");
this.push("(");
print(node.filter);
this.push(")");
this.space();
}
print(node.body);
this.push(node.generator ? ")" : "]");
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,169 @@
"use strict";
var t = require("../../types");
var _ = require("lodash");
var PRECEDENCE = {};
_.each([
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"],
["**"]
], function (tier, i) {
_.each(tier, function (op) {
PRECEDENCE[op] = i;
});
});
exports.UpdateExpression = function (node, parent) {
if (t.isMemberExpression(parent) && parent.object === node) {
// (foo++).test()
return true;
}
};
exports.ObjectExpression = function (node, parent) {
if (t.isExpressionStatement(parent)) {
// ({ foo: "bar" });
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
// ({ foo: "bar" }).foo
return true;
}
return false;
};
exports.Binary = function (node, parent) {
if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) {
return true;
}
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
if (t.isBinary(parent)) {
var parentOp = parent.operator;
var parentPos = PRECEDENCE[parentOp];
var nodeOp = node.operator;
var nodePos = PRECEDENCE[nodeOp];
if (parentPos > nodePos) {
return true;
}
if (parentPos === nodePos && parent.right === node) {
return true;
}
}
};
exports.BinaryExpression = function (node, parent) {
if (node.operator === "in") {
// var i = (1 in []);
if (t.isVariableDeclarator(parent)) {
return true;
}
// for ((1 in []);;);
if (t.isFor(parent)) {
return true;
}
}
};
exports.SequenceExpression = function (node, parent) {
if (t.isForStatement(parent)) {
// Although parentheses wouldn't hurt around sequence
// expressions in the head of for loops, traditional style
// dictates that e.g. i++, j++ should not be wrapped with
// parentheses.
return false;
}
if (t.isExpressionStatement(parent) && parent.expression === node) {
return false;
}
// Otherwise err on the side of overparenthesization, adding
// explicit exceptions above if this proves overzealous.
return true;
};
exports.YieldExpression = function (node, parent) {
return t.isBinary(parent) ||
t.isUnaryLike(parent) ||
t.isCallExpression(parent) ||
t.isMemberExpression(parent) ||
t.isNewExpression(parent) ||
t.isConditionalExpression(parent) ||
t.isYieldExpression(parent);
};
exports.ClassExpression = function (node, parent) {
return t.isExpressionStatement(parent);
};
exports.UnaryLike = function (node, parent) {
return t.isMemberExpression(parent) && parent.object === node;
};
exports.FunctionExpression = function (node, parent) {
// function () {};
if (t.isExpressionStatement(parent)) {
return true;
}
// (function test() {}).name;
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
// (function () {})();
if (t.isCallExpression(parent) && parent.callee === node) {
return true;
}
};
exports.AssignmentExpression =
exports.ConditionalExpression = function (node, parent) {
if (t.isUnaryLike(parent)) {
return true;
}
if (t.isBinary(parent)) {
return true;
}
if (t.isCallExpression(parent) || t.isNewExpression(parent)) {
if (parent.callee === node) {
return true;
}
}
if (t.isConditionalExpression(parent) && parent.test === node) {
return true;
}
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
return false;
};

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

@@ -1,8 +1,13 @@
var transform = require("./transform");
"use strict";
var transform = require("./transformation/transform");
var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
exports.util = require("./util");
exports.version = require("../../package").version;
exports.types = require("./types");
exports.register = function (opts) {
var register = require("./register");
@@ -14,6 +19,11 @@ exports.polyfill = function () {
require("./polyfill");
};
exports.canCompile = util.canCompile;
// do not use this - this is for use by official maintained 6to5 plugins
exports._util = util;
exports.transform = transform;
exports.transformFile = function (filename, opts, callback) {

View File

@@ -1,82 +0,0 @@
module.exports = AMDFormatter;
var CommonJSFormatter = require("./common");
var util = require("../util");
var b = require("acorn-ast-types").builders;
var _ = require("lodash");
function AMDFormatter(file) {
this.file = file;
this.ids = {};
}
util.inherits(AMDFormatter, CommonJSFormatter);
AMDFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
// build an array of module names
var names = [b.literal("exports")];
_.each(this.ids, function (id, name) {
names.push(b.literal(name));
});
names = b.arrayExpression(names);
// build up define container
var params = _.values(this.ids);
params.unshift(b.identifier("exports"));
var container = b.functionExpression(null, params, b.blockStatement(body));
var call = b.callExpression(b.identifier("define"), [names, container]);
program.body = [b.expressionStatement(call)];
};
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] = b.identifier(this.file.generateUid(id));
}
};
AMDFormatter.prototype.import = function (node) {
this._push(node);
};
AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var key = util.getSpecifierName(specifier);
var id = specifier.id;
// import foo from "foo";
if (specifier.default) {
id = b.identifier("default");
}
var ref;
if (specifier.type === "ImportBatchSpecifier") {
// import * as bar from "foo";
ref = this._push(node);
} else {
// import foo from "foo";
ref = b.memberExpression(this._push(node), id, false);
}
nodes.push(b.variableDeclaration("var", [
b.variableDeclarator(key, ref)
]));
};
AMDFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var self = this;
return this._exportSpecifier(function () {
return self._push(node);
}, specifier, node, nodes);
};

View File

@@ -1,97 +0,0 @@
module.exports = CommonJSFormatter;
var util = require("../util");
var b = require("acorn-ast-types").builders;
function CommonJSFormatter(file) {
this.file = file;
}
CommonJSFormatter.prototype.import = function (node, nodes) {
// import "foo";
nodes.push(util.template("require", {
MODULE_NAME: node.source.raw
}, true));
};
CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var variableName = util.getSpecifierName(specifier);
// import foo from "foo";
if (specifier.default) {
specifier.id = b.identifier("default");
}
var templateName = "require-assign";
// import * as bar from "foo";
if (specifier.type !== "ImportBatchSpecifier") templateName += "-key";
nodes.push(util.template(templateName, {
VARIABLE_NAME: variableName,
MODULE_NAME: node.source.raw,
KEY: specifier.id
}));
};
CommonJSFormatter.prototype.export = function (node, nodes) {
var declar = node.declaration;
if (node.default) {
util.ensureExpressionType(declar);
nodes.push(util.template("exports-default", {
VALUE: declar
}, true));
} else {
var id = declar.id;
if (declar.type === "VariableDeclaration") {
id = declar.declarations[0].id;
}
var assign = util.template("exports-assign", {
VALUE: id,
KEY: id
}, true);
nodes.push(declar);
if (declar.type === "FunctionDeclaration") {
assign._blockHoist = true;
}
nodes.push(assign);
}
};
CommonJSFormatter.prototype._exportSpecifier = function (getRef, specifier, node, nodes) {
var variableName = util.getSpecifierName(specifier);
if (node.source) {
if (specifier.type === "ExportBatchSpecifier") {
// export * from "foo";
nodes.push(util.template("exports-wildcard", {
OBJECT: getRef()
}, true));
} else {
// export { foo } from "test";
nodes.push(util.template("exports-assign-key", {
VARIABLE_NAME: variableName.name,
OBJECT: getRef(),
KEY: specifier.id
}, true));
}
} else {
// export { foo };
nodes.push(util.template("exports-assign", {
VALUE: specifier.id,
KEY: variableName
}, true));
}
};
CommonJSFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
return this._exportSpecifier(function () {
return b.callExpression(b.identifier("require"), [node.source]);
}, specifier, node, nodes);
};

View File

@@ -1,47 +0,0 @@
module.exports = UMDFormatter;
var AMDFormatter = require("./amd");
var util = require("../util");
var b = require("acorn-ast-types").builders;
var _ = require("lodash");
function UMDFormatter(file) {
this.file = file;
this.ids = {};
}
util.inherits(UMDFormatter, AMDFormatter);
UMDFormatter.prototype.transform = function (ast) {
var program = ast.program;
var body = program.body;
// build an array of module names
var names = [];
_.each(this.ids, function (id, name) {
names.push(b.literal(name));
});
// factory
var ids = _.values(this.ids);
var args = [b.identifier("exports")].concat(ids);
var factory = b.functionExpression(null, args, b.blockStatement(body));
// runner
var runner = util.template("umd-runner-body", {
AMD_ARGUMENTS: b.arrayExpression([b.literal("exports")].concat(names)),
COMMON_ARGUMENTS: names.map(function (name) {
return b.callExpression(b.identifier("require"), [name]);
})
});
//
var call = b.callExpression(runner, [factory]);
program.body = [b.expressionStatement(call)];
};

67
lib/6to5/patch.js Normal file
View File

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

View File

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

View File

@@ -0,0 +1,7 @@
"use strict";
// required to safely use 6to5/register within a browserify codebase
module.exports = function () {};
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 () {
if (!fs.existsSync(FILENAME)) return;
try {
data = JSON.parse(fs.readFileSync(FILENAME));
} catch (err) {
return;
}
process.on("exit", exports.save);
var sigint = function () {
process.removeListener("SIGINT", sigint);
exports.save();
process.kill(process.pid, "SIGINT");
};
process.on("SIGINT", sigint);
};
exports.get = function () {
return data;
};

View File

@@ -1,12 +1,17 @@
"use strict";
require("./polyfill");
var sourceMapSupport = require("source-map-support");
var registerCache = require("./register-cache");
var util = require("./util");
var to5 = require("./index");
var fs = require("fs");
var _ = require("lodash");
sourceMapSupport.install({
retrieveSourceMap: function (source) {
var map = maps[source];
var map = maps && maps[source];
if (map) {
return {
url: null,
@@ -20,19 +25,47 @@ sourceMapSupport.install({
//
var ignoreRegex = /node_modules/;
var exts = {};
var maps = {};
var old = require.extensions[".js"];
registerCache.load();
var cache = registerCache.get();
//
var transformOpts = {};
var ignoreRegex = /node_modules/;
var onlyRegex;
var whitelist = [];
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)) {
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) {
return old.apply(this, arguments);
}
var result = to5.transformFileSync(filename, {
sourceMap: true
});
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;
@@ -52,15 +85,23 @@ var hookExtensions = function (_exts) {
});
};
hookExtensions([".es6", ".js"]);
hookExtensions(util.canCompile.EXTENSIONS);
module.exports = function (opts) {
// normalise options
opts = opts || {};
if (_.isRegExp(opts)) opts = { ignoreRegex: opts };
if (opts.ignoreRegex != null) {
ignoreRegex = opts.ignoreRegex;
}
if (opts.only != null) onlyRegex = util.regexify(opts.only);
if (opts.ignore != null) ignoreRegex = util.regexify(opts.ignore);
if (opts.extensions) hookExtensions(opts.extensions);
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);
};

View File

@@ -1 +0,0 @@
var VARIABLE_NAME = SLICE_KEY.call(arguments, SLICE_ARG);

View File

@@ -1 +0,0 @@
var VARIABLE_NAME = SLICE_KEY.call(arguments);

View File

@@ -1 +0,0 @@
SLICE_KEY.call(arguments);

View File

@@ -1,5 +0,0 @@
ARRAY.filter(function (KEY) {
return FILTER;
}).map(function (KEY) {
return STATEMENT;
});

View File

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

View File

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

View File

@@ -1,2 +0,0 @@
SUPER_NAME.apply(this, arguments);

View File

@@ -1,7 +0,0 @@
(function () {
var CLASS_NAME = function () {
};
return CLASS_NAME;
})()

View File

@@ -1 +0,0 @@
exports.VARIABLE_NAME = OBJECT.KEY;

View File

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

View File

@@ -1,5 +0,0 @@
(function (obj) {
for (var i in obj) {
exports[i] = obj[i];
}
})(OBJECT);

View File

@@ -1,11 +0,0 @@
(function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
})

View File

@@ -1,3 +0,0 @@
(function (KEY) {
return KEY;
})(OBJECT)

View File

@@ -1 +0,0 @@
if (VARIABLE === undefined) VARIABLE = DEFAULT;

View File

@@ -1,4 +0,0 @@
(function (KEY) {
CONTENT;
return KEY;
})(OBJECT);

View File

@@ -1 +0,0 @@
Object.defineProperties(OBJECT, PROPS);

View File

@@ -1 +0,0 @@
var VARIABLE_NAME = require(MODULE_NAME);

View File

@@ -1,118 +0,0 @@
module.exports = transform;
var Transformer = require("./transformer");
var sourceMap = require("source-map");
var recast = require("acorn-recast");
var File = require("./file");
var util = require("./util");
var _ = require("lodash");
function transform(code, opts) {
opts = opts || {};
code = (code || "") + "";
var file = new File(opts);
return file.parse(code);
}
transform.test = function (task, assert) {
var actual = task.actual;
var expect = task.expect;
var opts = task.options;
var exec = task.exec;
var getOpts = function (filename) {
return _.merge({ filename: filename }, opts);
};
var execCode = exec.code.trim();
var result;
if (execCode) {
result = transform(execCode, getOpts(exec.filename));
execCode = result.code;
require("./polyfill");
var fn = new Function("assert", execCode);
fn(assert);
} else {
var actualCode = actual.code.trim();
var expectCode = expect.code.trim();
var printOpts = { tabWidth: 2 };
result = transform(actualCode, getOpts(actual.filename));
actualCode = recast.prettyPrint(result.ast, printOpts).code;
var expectAst = util.parse(expect, expectCode);
var expectResult = recast.prettyPrint(expectAst, printOpts);
expectCode = expectResult.code;
assert.equal(actualCode, expectCode);
}
if (task.sourceMap) {
assert.deepEqual(task.sourceMap, result.map);
}
if (task.sourceMappings) {
var consumer = new sourceMap.SourceMapConsumer(result.map);
_.each(task.sourceMappings, function (mapping, i) {
var generated = mapping.generated;
var original = mapping.original;
var pos = consumer.originalPositionFor(generated);
var msg = "source mapping " + i + " - generated: " + generated.line + ":" + generated.column;
assert.equal(pos.line + ":" + pos.column, original.line + ":" + original.column, msg);
});
}
};
transform._ensureTransformerNames = function (type, keys) {
_.each(keys, function (key) {
if (!_.has(transform.transformers, key)) {
throw new ReferenceError("unknown transformer " + key + " specified in " + type);
}
});
};
transform.transformers = {
modules: require("./transformers/modules"),
computedPropertyNames: require("./transformers/computed-property-names"),
propertyNameShorthand: require("./transformers/property-name-shorthand"),
constants: require("./transformers/constants"),
arrayComprehension: require("./transformers/array-comprehension"),
arrowFunctions: require("./transformers/arrow-functions"),
classes: require("./transformers/classes"),
spread: require("./transformers/spread"),
templateLiterals: require("./transformers/template-literals"),
propertyMethodAssignment: require("./transformers/property-method-assignment"),
defaultParameters: require("./transformers/default-parameters"),
letScoping: require("./transformers/let-scoping"),
restParameters: require("./transformers/rest-parameters"),
destructuring: require("./transformers/destructuring"),
forOf: require("./transformers/for-of"),
unicodeRegex: require("./transformers/unicode-regex"),
generators: require("./transformers/generators"),
react: require("./transformers/react"),
jsx: require("./transformers/jsx"),
_aliasFunctions: require("./transformers/_alias-functions"),
_blockHoist: require("./transformers/_block-hoist"),
_declarations: require("./transformers/_declarations"),
_moduleFormatter: require("./transformers/_module-formatter"),
useStrict: require("./transformers/use-strict")
};
transform.moduleFormatters = {
common: require("./modules/common"),
amd: require("./modules/amd"),
umd: require("./modules/umd")
};
_.each(transform.transformers, function (transformer, key) {
transform.transformers[key] = new Transformer(key, transformer);
});

View File

@@ -0,0 +1,46 @@
"use strict";
var explode = require("./explode-assignable-expression");
var t = require("../../types");
module.exports = function (exports, opts) {
var isAssignment = function (node) {
return node.operator === opts.operator + "=";
};
var buildAssignment = function (left, right) {
return t.assignmentExpression("=", left, right);
};
exports.ExpressionStatement = function (node, parent, scope, context, file) {
// hit the `AssignmentExpression` one below
if (file.isConsequenceExpressionStatement(node)) return;
var expr = node.expression;
if (!isAssignment(expr)) return;
var nodes = [];
var exploded = explode(expr.left, nodes, file, scope, true);
nodes.push(t.expressionStatement(
buildAssignment(exploded.ref, opts.build(exploded.uid, expr.right))
));
return nodes;
};
exports.AssignmentExpression = function (node, parent, scope, context, file) {
if (!isAssignment(node)) return;
var nodes = [];
var exploded = explode(node.left, nodes, file, scope);
nodes.push(buildAssignment(exploded.ref, opts.build(exploded.uid, node.right)));
return t.toSequenceExpression(nodes, scope);
};
exports.BinaryExpression = function (node) {
if (node.operator !== opts.operator) return;
return opts.build(node.left, node.right);
};
};

View File

@@ -0,0 +1,25 @@
"use strict";
var t = require("../../types");
module.exports = function build(node, buildBody) {
var self = node.blocks.shift();
if (!self) return;
var child = build(node, buildBody);
if (!child) {
// last item
child = buildBody();
// add a filter as this is our final stop
if (node.filter) {
child = t.ifStatement(node.filter, t.blockStatement([child]));
}
}
return t.forOfStatement(
t.variableDeclaration("let", [t.variableDeclarator(self.left)]),
self.right,
t.blockStatement([child])
);
};

View File

@@ -0,0 +1,47 @@
"use strict";
var explode = require("./explode-assignable-expression");
var t = require("../../types");
module.exports = function (exports, opts) {
var buildAssignment = function (left, right) {
return t.assignmentExpression("=", left, right);
};
exports.ExpressionStatement = function (node, parent, scope, context, file) {
// hit the `AssignmentExpression` one below
if (file.isConsequenceExpressionStatement(node)) return;
var expr = node.expression;
if (!opts.is(expr, file)) return;
var nodes = [];
var exploded = explode(expr.left, nodes, file, scope);
nodes.push(t.ifStatement(
opts.build(exploded.uid, file),
t.expressionStatement(buildAssignment(exploded.ref, expr.right))
));
return nodes;
};
exports.AssignmentExpression = function (node, parent, scope, context, file) {
if (!opts.is(node, file)) return;
var nodes = [];
var exploded = explode(node.left, nodes, file, scope);
nodes.push(t.logicalExpression(
"&&",
opts.build(exploded.uid, file),
buildAssignment(exploded.ref, node.right)
));
// todo: duplicate expression node
nodes.push(exploded.ref);
return t.toSequenceExpression(nodes, scope);
};
};

View File

@@ -0,0 +1,73 @@
"use strict";
var t = require("../../types");
var getObjRef = function (node, nodes, file, scope) {
var ref;
if (t.isIdentifier(node)) {
if (scope.has(node.name, true)) {
// 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.has(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);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, ref)
]));
return temp;
};
var getPropRef = function (node, nodes, file, scope) {
var prop = node.property;
var key = t.toComputedKey(node, prop);
if (t.isLiteral(key)) return key;
var temp = scope.generateUidBasedOnNode(prop);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(temp, prop)
]));
return temp;
};
module.exports = function (node, nodes, file, scope, allowedSingleIdent) {
var obj;
if (t.isIdentifier(node) && allowedSingleIdent) {
obj = node;
} else {
obj = getObjRef(node, nodes, file, scope);
}
var ref, uid;
if (t.isIdentifier(node)) {
ref = node;
uid = obj;
} else {
var prop = getPropRef(node, nodes, file, scope);
var computed = node.computed || t.isLiteral(prop);
uid = ref = t.memberExpression(obj, prop, computed);
}
return {
uid: uid,
ref: ref
};
};

View File

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

View File

@@ -0,0 +1,35 @@
"use strict";
var traverse = require("../../traverse");
var t = require("../../types");
var visitor = {
enter: function (node, parent, scope, context) {
if (t.isFunction(node)) context.skip();
if (t.isAwaitExpression(node)) {
node.type = "YieldExpression";
}
}
};
module.exports = function (node, callId, scope) {
node.async = false;
node.generator = true;
traverse(node, visitor, scope);
var call = t.callExpression(callId, [node]);
var id = node.id;
delete node.id;
if (t.isFunctionDeclaration(node)) {
var declar = t.variableDeclaration("let", [
t.variableDeclarator(id, call)
]);
declar._blockHoist = true;
return declar;
} else {
return call;
}
};

View File

@@ -0,0 +1,251 @@
"use strict";
module.exports = ReplaceSupers;
var traverse = require("../../traverse");
var t = require("../../types");
/**
* Description
*
* @param {Object} opts
*/
function ReplaceSupers(opts) {
this.topLevelThisReference = null;
this.methodNode = opts.methodNode;
this.className = opts.className;
this.superName = opts.superName;
this.isLoose = opts.isLoose;
this.scope = opts.scope;
this.file = opts.file;
}
/**
* Gets a node representing the super class value of the named property.
*
* @example
*
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
* @param {Node} property
* @param {boolean} isStatic
* @param {boolean} isComputed
*
* @returns {Node}
*/
ReplaceSupers.prototype.superProperty = function (property, isStatic, 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"))
]
),
isComputed ? property : t.literal(property.name),
thisExpression
]
);
};
/**
* Description
*
* @param {Object} node
* @param {Object} id
* @param {Object} parent
* @returns {Object}
*/
ReplaceSupers.prototype.looseSuperProperty = function (methodNode, id, parent) {
var methodName = methodNode.key;
var superName = this.superName || t.identifier("Function");
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> ClassName.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superName, t.identifier("call"));
} else {
id = superName;
// foo() { super(); }
if (!methodNode.static) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
// super.test -> ClassName.prototype.test
return t.memberExpression(superName, t.identifier("prototype"));
} else {
return superName;
}
};
/**
* Description
*/
ReplaceSupers.prototype.replace = function () {
this.traverseLevel(this.methodNode.value, true);
};
var visitor = {
enter: function (node, parent, scope, context, 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 context.skip();
}
if (t.isProperty(node, { method: true }) || t.isMethodDefinition(node)) {
// break on object methods
return context.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;
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 };
traverse(node, visitor, this.scope, state);
};
/**
* Description
*/
ReplaceSupers.prototype.getThisReference = function () {
if (this.topLevelThisReference) {
return this.topLevelThisReference;
} else {
var ref = this.topLevelThisReference = this.file.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(this.topLevelThisReference, t.thisExpression())
]));
return ref;
}
};
/**
* Description
*
* @param {Function} getThisReference
* @param {Object} node
* @param {Object} parent
*/
ReplaceSupers.prototype.looseHandle = function (getThisReference, node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
return this.looseSuperProperty(this.methodNode, 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);
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(getThisReference());
}
};
/**
* Description
*
* @param {Function} getThisReference
* @param {Object} node
* @param {Object} parent
*/
ReplaceSupers.prototype.specHandle = function (getThisReference, node, parent) {
var methodNode = this.methodNode;
var property;
var computed;
var args;
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)) {
var callee = node.callee;
if (t.isIdentifier(callee, { name: "super" })) {
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);
property = methodNode.key;
computed = methodNode.computed;
args = node.arguments;
// bare `super` call is illegal inside non-constructors
// - https://esdiscuss.org/topic/super-call-in-methods
// - https://twitter.com/wycats/status/544553184396836864
if (methodNode.key.name !== "constructor") {
var methodName = methodNode.key.name || "METHOD_NAME";
throw this.file.errorWithNode(node, "Direct super call is illegal in non-constructor, use super." + methodName + "() instead");
}
} else {
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// 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;
// super.name; -> _get(Object.getPrototypeOf(ClassName.prototype), "name", this);
property = node.property;
computed = node.computed;
}
if (!property) return;
var thisReference = getThisReference();
var superProperty = this.superProperty(property, methodNode.static, computed, thisReference);
if (args) {
if (args.length === 1 && t.isSpreadElement(args[0])) {
// super(...arguments);
return t.callExpression(
t.memberExpression(superProperty, t.identifier("apply")),
[thisReference, args[0].argument]
);
} else {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call")),
[thisReference].concat(args)
);
}
} else {
return superProperty;
}
};

View File

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

View File

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

View File

@@ -0,0 +1,14 @@
"use strict";
var util = require("../../util");
module.exports = function (Parent) {
var Constructor = function () {
this.noInteropRequire = true;
Parent.apply(this, arguments);
};
util.inherits(Constructor, Parent);
return Constructor;
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,199 @@
"use strict";
module.exports = SystemFormatter;
var DefaultFormatter = require("./_default");
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");
function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.noInteropRequire = true;
DefaultFormatter.apply(this, arguments);
}
util.inherits(SystemFormatter, AMDFormatter);
SystemFormatter.prototype._addImportSource = function (node, exportNode) {
node._importSource = exportNode.source && exportNode.source.value;
return node;
};
SystemFormatter.prototype.buildExportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);
var left = t.variableDeclaration("var", [
t.variableDeclarator(leftIdentifier)
]);
var right = objectIdentifier;
var block = t.blockStatement([
t.expressionStatement(this.buildExportCall(leftIdentifier, valIdentifier))
]);
return this._addImportSource(t.forInStatement(left, right, block), node);
};
SystemFormatter.prototype.buildExportsAssignment = function (id, init, node) {
var call = this.buildExportCall(t.literal(id.name), init, true);
return this._addImportSource(call, node);
};
SystemFormatter.prototype.remapExportAssignment = function (node) {
return this.buildExportCall(t.literal(node.left.name), node);
};
SystemFormatter.prototype.buildExportCall = function (id, init, isStatement) {
var call = t.callExpression(this.exportIdentifier, [id, init]);
if (isStatement) {
return t.expressionStatement(call);
} else {
return call;
}
};
SystemFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
AMDFormatter.prototype.importSpecifier.apply(this, arguments);
this._addImportSource(_.last(nodes), node);
};
var runnerSettersVisitor = {
enter: function (node, parent, scope, context, 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);
}
context.remove();
}
}
};
SystemFormatter.prototype.buildRunnerSetters = function (block, hoistDeclarators) {
var scope = this.file.scope;
return t.arrayExpression(_.map(this.ids, function (uid, source) {
var state = {
source: source,
nodes: [],
hoistDeclarators: hoistDeclarators
};
traverse(block, runnerSettersVisitor, scope, state);
return t.functionExpression(null, [uid], t.blockStatement(state.nodes));
}));
};
var hoistVariablesVisitor = {
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;
}
// 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, context, handlerBody) {
if (t.isFunction(node)) context.skip();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
context.remove();
}
}
};
SystemFormatter.prototype.transform = function (ast) {
var program = ast.program;
var hoistDeclarators = [];
var moduleName = this.getModuleName();
var moduleNameLiteral = t.literal(moduleName);
var block = t.blockStatement(program.body);
var runner = util.template("system", {
MODULE_NAME: moduleNameLiteral,
MODULE_DEPENDENCIES: t.arrayExpression(this.buildDependencyLiterals()),
EXPORT_IDENTIFIER: this.exportIdentifier,
SETTERS: this.buildRunnerSetters(block, hoistDeclarators),
EXECUTE: t.functionExpression(null, [], block)
}, true);
var handlerBody = runner.expression.arguments[2].body.body;
if (!moduleName) runner.expression.arguments.shift();
var returnStatement = handlerBody.pop();
// hoist up all variable declarations
traverse(block, hoistVariablesVisitor, this.file.scope, hoistDeclarators);
if (hoistDeclarators.length) {
var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
hoistDeclar._blockHoist = true;
handlerBody.unshift(hoistDeclar);
}
// hoist up function declarations for circular references
traverse(block, hoistFunctionsVisitor, this.file.scope, handlerBody);
handlerBody.push(returnStatement);
if (useStrict.has(block)) {
handlerBody.unshift(block.body.shift());
}
program.body = [runner];
};

View File

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

View File

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

View File

@@ -0,0 +1 @@
PROPERTY[Symbol.referenceGet](OBJECT).call(OBJECT)

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