Compare commits

..

1013 Commits

Author SHA1 Message Date
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
1141 changed files with 11631 additions and 5372 deletions

2
.gitignore vendored
View File

@@ -6,7 +6,7 @@ test/tmp
/templates.json
/tests.json
/browser.js
/polyfill.js
/browser-polyfill.js
/runtime.js
coverage
dist

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/facebook/regenerator
[submodule "vendor/test262"]
path = vendor/test262
url = https://github.com/tc39/test262

View File

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

View File

@@ -1,11 +1,11 @@
node_modules
*.log
*.cache
lib/6to5/templates
lib/6to5/transformation/templates
test
benchmark
Makefile
.*
dist
tests.json
!README.md
CHANGELOG.md

506
CHANGELOG.md Normal file
View File

@@ -0,0 +1,506 @@
# Changelog
> **Tags:**
> - [New Feature]
> - [Bug Fix]
> - [Spec Compliancy]
> - [Breaking Change]
> - [Documentation]
> - [Internal]
> - [Polish]
_Note: Gaps between patch versions are faulty/broken releases._
## 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/)

32
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,32 @@
# Contributing
Before contributing, please read the [code of conduct](https://github.com/6to5/6to5/blob/master/CODE_OF_CONDUCT.md).
* **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,170 +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");
}
});
```
### Ignore
**In**
```javascript
import foo from "foo";
export function bar() {
return foo("foobar");
}
```
**Out**
```javascript
function bar() {
return foo("foobar");
}
```
## Custom
You can alternatively specify module names instead of one of the built-in types.
$ 6to5 --modules custom-module-formatter
**node_modules/custom-module-formatter/index.js**
```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
};
```

View File

@@ -6,36 +6,7 @@ MOCHA_CMD = node_modules/mocha/bin/_mocha
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:
mkdir -p dist
node bin/cache-templates
node bin/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
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap
build:
mkdir -p dist
@@ -53,6 +24,48 @@ build:
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
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:
export SIMPLE_6TO5_TESTS=1
rm -rf coverage
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 bin/cache-templates
node bin/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
@@ -60,7 +73,7 @@ publish:
make build
cp dist/6to5.min.js browser.js
cp dist/polyfill.min.js polyfill.js
cp dist/polyfill.min.js browser-polyfill.js
cp dist/runtime.min.js runtime.js
node bin/cache-templates
@@ -72,4 +85,9 @@ publish:
git push --follow-tags
rm -rf templates.json browser.js runtime.js polyfill.js
rm -rf templates.json browser.js runtime.js browser-polyfill.js
bootstrap:
npm install
git submodule update --init
cd vendor/regenerator; npm install

8
NOTES.md Normal file
View File

@@ -0,0 +1,8 @@
# Notes
* Wildcard exports/imports wont normalise if `export default` is a non-object.
## 3.0.0 breaking changes
* Remove `allowImportExportEverywhere` option from acorn.
* Remove this shorthand from playground.

490
README.md
View File

@@ -3,8 +3,12 @@
</p>
<p align="center">
<a href="https://gratipay.com/sebmck">
<img alt="Gratipay" src="https://img.shields.io/gratipay/sebmck.svg?style=flat">
</a>
<a href="https://travis-ci.org/6to5/6to5">
<img alt="Travis Status" src="http://img.shields.io/travis/6to5/6to5.svg?branch=master&amp;style=flat&amp;label=travis">
<img alt="Travis Status" src="http://img.shields.io/travis/6to5/6to5/master.svg?style=flat&amp;label=travis">
</a>
<a href="https://codeclimate.com/github/6to5/6to5">
@@ -20,479 +24,11 @@
</a>
</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)
- [Polyfill](#polyfill)
- [Optional runtime](#optional-runtime)
- [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/6to5/6to5-browserify)
- [Brunch](https://github.com/es128/6to5-brunch)
- [Duo](https://github.com/bdo-labs/duo6to5)
- [Connect](https://github.com/6to5/6to5-connect)
- [Gulp](https://github.com/sindresorhus/gulp-6to5)
- [Grunt](https://github.com/sindresorhus/grunt-6to5)
- [Jade](https://github.com/Apoxx/jade-6to5)
- [Karma](https://github.com/shuhei/karma-6to5-preprocessor)
- [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
Compile the entire `src` directory and output it to the one concatenated file.
$ 6to5 src --out-file script-compiled.js
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",
// Optionally replace all 6to5 helper declarations with a referenece to this
// variable. If set to `true` then the default namespace is used "to5Runtime".
// Default: false
runtime: true
}
```
#### 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")({
// This will override `node_modules` ignoring - you can alternatively pass
// a regex
ignore: false
});
```
##### Options
```javascript
require("6to5/register")({
// Optional ignore regex - if any filenames **do** match this regex then they
// aren't compiled
ignore: /regex/,
// Optional only regex - if any filenames **don't** match this regex then they
// aren't compiled
only: /my_es6_folder/,
// See options above for usage
whitelist: [],
blacklist: [],
// 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
A browser version of 6to5 is available from `browser.js` inside the 6to5
directory in an npm release.
#### Scripts
While it's not recommended for serious use, when the browser version is included
all scripts with the type `text/ecmascript-6` and `text/6to5` are automatically
compiled and ran.
For example:
```html
<script src="node_modules/6to5/browser.js"></script>
<script type="text/6to5">
class Test {
test() {
return "test";
}
}
var test = new Test;
test.test();
</script>
```
#### Build
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`.
#### API
```javascript
to5.transform("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
### 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.
**NOTE:** `__proto__` is not supported on IE <= 9 so static properties
**will not** be inherited. A possible workaround is to use `super();`:
```javascript
class Foo {
static foo() {
}
}
class Bar extends Foo {
static foo() {
super();
}
}
```
### 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.
## Polyfill
6to5 includes a polyfill that includes 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.
### Node
```javascript
require("6to5/polyfill");
```
### Browser
Available from the `polyfill.js` file within the 6to5 directory of an npm
release.
## Optional runtime
6to5 has a few helper functions that'll be placed at the top of the generated
code if needed so it's not inlined multiple times throughout that file. This may
become an issue if you have multiple files, especially when you're sending them
to the browser. gzip alleviates most of this concern but it's still not ideal.
You can tell 6to5 to not place any declarations at the top of your files and
instead just point them to a reference contained within the runtime.
Simply use the following option if you're using the [Node API](#node-1):
```javascript
{
runtime: true
}
```
or the following flag if you're using the [CLI](#cli):
$ 6to5 --runtime
Then just include the runtime before your generated code.
### Getting the runtime
You can get the runtime via either:
$ 6to5-runtime
or
```javascript
require("6to5").runtime();
```
or from an npm release in `runtime.js` from the 6to5 directory.
### Customising namespace
You can also customise the runtime namespace by passing an optional namespace
argument:
```javascript
require("6to5").runtime("myCustomNamespace");
```
$ 6to5-runtime myCustomNamespace
See [Options - runtime](#options) for documentation on changing the reference in
generated code.
## 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">
<strong>6to5</strong> turns ES6+ code into vanilla ES5, so you can use next generation features <strong>today.</strong>
</p>
<p align="center">
For more information view the <a href="https://6to5.github.io">documentation</a>. For
support visit the <a href="https://gitter.im/6to5/6to5">gitter room</a>.
</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

@@ -5,7 +5,6 @@
* when found, before invoking the "real" _6to5-node(1) executable.
*/
var spawn = require("child_process").spawn;
var args = ["--harmony", __dirname + "/_6to5-node"];
process.argv.slice(2).forEach(function(arg){
@@ -14,18 +13,19 @@ process.argv.slice(2).forEach(function(arg){
switch (flag) {
case "-d":
args.unshift("--debug");
args.push("--no-timeouts");
break;
case "debug":
case "--debug":
case "--debug-brk":
args.unshift(arg);
args.push("--no-timeouts");
break;
case "-gc":
case "--expose-gc":
args.unshift("--expose-gc");
break;
case "--gc-global":
case "--harmony":
case "--harmony-proxies":
@@ -37,20 +37,32 @@ process.argv.slice(2).forEach(function(arg){
case "--trace-deprecation":
args.unshift(arg);
break;
default:
if (0 == arg.indexOf("--trace")) args.unshift(arg);
else args.push(arg);
if (arg.indexOf("--trace") === 0) {
args.unshift(arg);
} else {
args.push(arg);
}
break;
}
});
var proc = 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);
}
try {
var kexec = require("kexec");
kexec(process.argv[0], args);
} catch (err) {
if (err.code !== "MODULE_NOT_FOUND") throw err;
var child_process = require("child_process");
var proc = child_process.spawn(process.argv[0], args, { stdio: "inherit" });
proc.on("exit", function (code, signal) {
process.on("exit", function () {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code);
}
})
});
});
}

View File

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

View File

@@ -19,7 +19,9 @@ module.exports = function (commander, filenames, opts) {
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);
fs.writeFileSync(mapLoc, JSON.stringify(data.map));
}
fs.writeFileSync(dest, data.code);

View File

@@ -56,7 +56,9 @@ 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);
@@ -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" || type === "unlink" ) {
console.log(type, filename);
walk();
});
}
});
}
};

View File

@@ -11,20 +11,34 @@ commander.option("-s, --source-maps", "Save source map alongside the compiled co
commander.option("-f, --filename [filename]", "Filename to use when reading from stdin - this will be used in source-maps, errors etc [stdin]", "stdin");
commander.option("-w, --watch", "Recompile files on changes");
commander.option("-r, --runtime", "Replace 6to5 declarations with references to a runtime");
commander.option("-e, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-p, --playground", "Enable playground support");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-w, --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("-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("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.on("--help", function(){
var outKeys = function (title, obj) {
console.log(" " + title + ":");
console.log();
var hasOptional = true;
_.each(_.keys(obj).sort(), function (key) {
if (key[0] === "_") return;
if (obj[key].optional) {
hasOptional = true;
key = "[" + key + "]";
}
console.log(" - " + key);
});
@@ -85,9 +99,14 @@ if (errors.length) {
exports.opts = {
sourceMapName: commander.outFile,
experimental: commander.experimental,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules
};

View File

@@ -1,12 +1,19 @@
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) {

View File

@@ -1,41 +1,49 @@
#!/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");
var roadrunner = require("roadrunner");
var commander = require("commander");
var Module = require("module");
var path = require("path");
var repl = require("repl");
var to5 = require("../lib/6to5");
var util = require("../lib/6to5/util");
var vm = require("vm");
var _ = require("lodash");
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);
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]");
commander.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-g, --playground", "Enable playground support");
commander.option("-c, --cache", "Cache compiled files and require paths");
var pkg = require("../package.json");
commander.version(pkg.version);
commander.usage("[options] [ -e script | script.js ] [arguments]");
commander.parse(process.argv);
if (commander.cache) roadrunner.load();
//
var registerOpts = {};
if (commander.ignore) {
registerOpts.ignoreRegex = new RegExp(commander.ignore);
}
if (commander.extensions && commander.extensions.length) {
registerOpts.extensions = commander.extensions;
}
to5.register(registerOpts);
to5.register({
experimental: commander.experimental,
extensions: commander.extensions,
playground: commander.playground,
ignore: commander.ignore,
cache: commander.cache && roadrunner.get("6to5")
});
//
var _eval = function (code, filename) {
code = to5.transform(code, { filename: filename, blacklist: ["useStrict"] }).code;
code = to5.transform(code, {
filename: filename,
blacklist: ["useStrict"],
experimental: commander.experimental,
playground: commander.playground
}).code;
return vm.runInThisContext(code, filename);
};
@@ -43,21 +51,34 @@ if (commander.eval) {
var result = _eval(commander.eval, "eval");
if (commander.print) console.log(result);
} else {
var filenames = commander.args;
if (commander.args.length) {
// slice all arguments up to the first filename since they're 6to5 args that we handle
var args = process.argv.slice(2);
if (filenames.length) {
_.each(filenames, function (filename) {
if (!util.isAbsolute(filename)) {
filename = path.join(process.cwd(), filename);
var i = 0;
_.each(args, function (arg, i2) {
if (arg[0] !== "-") {
i = i2;
return false;
}
require(require.resolve(filename));
});
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();
}
}
if (commander.cache) roadrunner.save();
function replStart() {
repl.start({
prompt: "> ",

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,13 +1,8 @@
var transform = module.exports = require("./transformation/transform");
transform.transform = transform;
transform.version = require("../../package").version;
transform.eval = function (code, opts) {
opts = opts || {};
opts.filename = opts.filename || "eval";
opts.sourceMap = "inline";
return eval(transform(code, opts).code);
};
transform.transform = transform;
transform.run = function (code, opts) {
opts = opts || {};
@@ -19,7 +14,7 @@ transform.load = function (url, callback, opts, hold) {
opts = opts || {};
opts.filename = opts.filename || url;
var xhr = window.ActiveXObject ? new window.ActiveXObject("Microsoft.XMLHTTP") : new window.XMLHttpRequest();
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");
@@ -41,7 +36,7 @@ transform.load = function (url, callback, opts, hold) {
var runScripts = function () {
var scripts = [];
var types = ["text/ecmascript-6", "text/6to5"];
var types = ["text/ecmascript-6", "text/6to5", "module"];
var index = 0;
var exec = function () {
@@ -67,8 +62,9 @@ var runScripts = function () {
}
};
var _scripts = window.document.getElementsByTagName("script");
for (var i in _scripts) {
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);
}
@@ -80,8 +76,8 @@ var runScripts = function () {
exec();
};
if (window.addEventListener) {
window.addEventListener("DOMContentLoaded", runScripts, false);
} else {
window.attachEvent("onload", runScripts);
if (global.addEventListener) {
global.addEventListener("DOMContentLoaded", runScripts, false);
} else if (global.attachEvent) {
global.attachEvent("onload", runScripts);
}

View File

@@ -10,46 +10,139 @@ var t = require("./types");
var _ = require("lodash");
function File(opts) {
this.opts = File.normaliseOptions(opts);
this.moduleFormatter = this.getModuleFormatter(opts.modules);
this.declarations = {};
this.uids = {};
this.ast = {};
this.dynamicImports = [];
this.dynamicImportIds = {};
this.opts = File.normaliseOptions(opts);
this.transformers = this.getTransformers();
this.uids = {};
this.ast = {};
}
File.declarations = ["extends", "class-props", "slice"];
File.helpers = [
"inherits",
"defaults",
"prototype-properties",
"apply-constructor",
"tagged-template-literal",
"interop-require",
"to-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice",
"bind",
"define-property",
"async-to-generator",
"interop-require-wildcard",
"typeof",
"exports-wildcard",
"extends"
];
File.excludeHelpersFromRuntime = [
"async-to-generator",
"typeof"
];
File.normaliseOptions = function (opts) {
opts = opts || {};
opts = _.cloneDeep(opts || {});
_.defaults(opts, {
whitespace: true,
blacklist: [],
whitelist: [],
sourceMap: false,
filename: "unknown",
modules: "common",
runtime: false
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
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);
_.defaults(opts, {
moduleRoot: opts.sourceRoot
});
_.defaults(opts, {
sourceFileName: opts.filename,
sourceMapName: opts.filename
sourceRoot: opts.moduleRoot
});
_.defaults(opts, {
filenameRelative: opts.filename
});
_.defaults(opts, {
sourceFileName: opts.filenameRelative,
sourceMapName: opts.filenameRelative
});
if (opts.runtime === true) {
opts.runtime = "to5Runtime";
}
if (opts.playground) {
opts.experimental = true;
}
transform._ensureTransformerNames("blacklist", opts.blacklist);
transform._ensureTransformerNames("whitelist", opts.whitelist);
transform._ensureTransformerNames("optional", opts.optional);
return opts;
};
File.prototype.getTransformers = function () {
var file = this;
var transformers = [];
var secondPassTransformers = [];
_.each(transform.transformers, function (transformer) {
if (transformer.canRun(file)) {
transformers.push(transformer);
if (transformer.secondPass) {
secondPassTransformers.push(transformer);
}
if (transformer.manipulateOptions) {
transformer.manipulateOptions(file.opts, file);
}
}
});
return transformers.concat(secondPassTransformers);
};
File.prototype.toArray = function (node, i) {
if (t.isArrayExpression(node)) {
return node;
} else if (t.isIdentifier(node) && node.name === "arguments") {
return t.callExpression(t.memberExpression(this.addHelper("slice"), t.identifier("call")), [node]);
} else {
var declarationName = "to-array";
var args = [node];
if (i) {
args.push(t.literal(i));
declarationName = "sliced-to-array";
}
return t.callExpression(this.addHelper(declarationName), args);
}
};
File.prototype.getModuleFormatter = function (type) {
var ModuleFormatter = transform.moduleFormatters[type];
var ModuleFormatter = _.isFunction(type) ? type : transform.moduleFormatters[type];
if (!ModuleFormatter) {
var loc = util.resolve(type);
@@ -57,7 +150,7 @@ File.prototype.getModuleFormatter = function (type) {
}
if (!ModuleFormatter) {
throw new ReferenceError("unknown module formatter type " + type);
throw new ReferenceError("Unknown module formatter type " + JSON.stringify(type));
}
return new ModuleFormatter(this);
@@ -75,28 +168,47 @@ File.prototype.parseShebang = function (code) {
return code;
};
File.prototype.addDeclaration = function (name) {
if (!_.contains(File.declarations, name)) {
File.prototype.addImport = function (source, name) {
name = name || source;
var id = this.dynamicImportIds[name];
if (!id) {
id = this.dynamicImportIds[name] = this.generateUidIdentifier(name);
var specifiers = [t.importSpecifier(t.identifier("default"), id)];
var declar = t.importDeclaration(specifiers, t.literal(source));
declar._blockHoist = 3;
this.dynamicImports.push(declar);
}
return id;
};
File.prototype.addHelper = function (name) {
if (!_.contains(File.helpers, name)) {
throw new ReferenceError("unknown declaration " + name);
}
var declar = this.declarations[name];
if (declar) return declar.uid;
var program = this.ast.program;
var declar = program._declarations && program._declarations[name];
if (declar) return declar.id;
var ref;
var runtimeNamespace = this.opts.runtime;
if (runtimeNamespace) {
if (runtimeNamespace && !_.contains(File.excludeHelpersFromRuntime, name)) {
name = t.identifier(t.toIdentifier(name));
return t.memberExpression(t.identifier(runtimeNamespace), name);
} else {
ref = util.template(name);
}
var uid = t.identifier(this.generateUid(name));
this.declarations[name] = {
uid: uid,
node: ref
};
var uid = this.generateUidIdentifier(name);
this.scope.push({
key: name,
id: uid,
init: ref
});
return uid;
};
@@ -109,12 +221,16 @@ File.prototype.errorWithNode = function (node, msg, Error) {
return err;
};
File.prototype.addCode = function (code) {
code = (code || "") + "";
this.code = code;
return this.parseShebang(code);
};
File.prototype.parse = function (code) {
var self = this;
this.code = code;
code = this.parseShebang(code);
code = this.addCode(code);
return util.parse(this.opts, code, function (tree) {
self.transform(tree);
@@ -123,25 +239,47 @@ File.prototype.parse = function (code) {
};
File.prototype.transform = function (ast) {
this.ast = ast;
this.scope = new Scope(null, ast.program);
var self = this;
_.each(transform.transformers, function (transformer) {
this.ast = ast;
this.scope = new Scope(ast.program);
this.moduleFormatter = this.getModuleFormatter(this.opts.modules);
var astRun = function (key) {
_.each(self.transformers, function (transformer) {
transformer.astRun(self, key);
});
};
astRun("enter");
_.each(this.transformers, function (transformer) {
transformer.transform(self);
});
astRun("exit");
};
File.prototype.generate = function () {
var opts = this.opts;
var ast = this.ast;
var result = generate(ast, opts, this.code);
var result = {
code: "",
map: null,
ast: null
};
if (opts.ast) result.ast = ast;
if (!opts.code) return result;
var _result = generate(ast, opts, this.code);
result.code = _result.code;
result.map = _result.map;
if (this.shebang) {
// add back shebang
result.code = this.shebang + result.code;
result.code = this.shebang + "\n" + result.code;
}
if (opts.sourceMap === "inline") {
@@ -152,7 +290,7 @@ File.prototype.generate = function () {
};
File.prototype.generateUid = function (name, scope) {
name = t.toIdentifier(name);
name = t.toIdentifier(name).replace(/^_+/, "");
scope = scope || this.scope;
@@ -163,6 +301,10 @@ File.prototype.generateUid = function (name, scope) {
return uid;
};
File.prototype.generateUidIdentifier = function (name, scope) {
return t.identifier(this.generateUid(name, scope));
};
File.prototype._generateUid = function (name) {
var uids = this.uids;
var i = uids[name] || 1;

View File

@@ -0,0 +1,127 @@
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.slice(0, -1);
this.position.unshift(cha);
};
Buffer.prototype.newline = function (i, removeLast) {
if (this.format.compact) return;
if (_.isBoolean(i)) {
removeLast = i;
i = null;
}
if (_.isNumber(i)) {
if (this.endsWith("{\n")) i--;
if (this.endsWith(util.repeat(i, "\n"))) return;
var self = this;
_.times(i, function () {
self.newline(null, removeLast);
});
return;
}
if (removeLast && this.isLast("\n")) this.removeLast("\n");
this.removeLast(" ");
// remove whitespace if last character was a newline
this.buf = this.buf.replace(/\n +$/, "\n");
this._push("\n");
};
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) {
return this.buf.slice(-str.length) === str;
};
Buffer.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = util.trimRight(buf);
var chars = [].concat(cha);
return _.contains(chars, _.last(buf));
};

View File

@@ -8,6 +8,7 @@ module.exports.CodeGenerator = CodeGenerator;
var Whitespace = require("./whitespace");
var SourceMap = require("./source-map");
var Position = require("./position");
var Buffer = require("./buffer");
var util = require("../util");
var n = require("./node");
var t = require("../types");
@@ -16,165 +17,69 @@ var _ = require("lodash");
function CodeGenerator(ast, opts, code) {
opts = opts || {};
this.style = {
semicolons: true,
comments: true,
compact: false,
indent: {
char: " ",
width: 2
}
};
this.comments = ast.comments || [];
this.tokens = ast.tokens || [];
this.opts = opts;
this.format = CodeGenerator.normaliseOptions(opts);
this.ast = ast;
this.buf = "";
this._indent = 0;
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 (opts) {
return _.merge({
parentheses: true,
comments: opts.comments == null || opts.comments,
compact: false,
indent: {
adjustMultilineComment: true,
style: " ",
base: 0
}
}, opts.format || {});
};
CodeGenerator.generators = {
arrayComprehensions: require("./generators/array-comprehensions"),
templateLiterals: require("./generators/template-literals"),
expressions: require("./generators/expressions"),
statements: require("./generators/statements"),
classes: require("./generators/classes"),
methods: require("./generators/methods"),
modules: require("./generators/modules"),
types: require("./generators/types"),
base: require("./generators/base"),
jsx: require("./generators/jsx")
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.newline = function (i, removeLast) {
if (!this.buf) return;
if (this.style.compact) return;
if (this.endsWith("{\n")) return;
if (_.isBoolean(i)) {
removeLast = i;
i = null;
}
if (_.isNumber(i)) {
var self = this;
_.times(i, function () {
self.newline(null, removeLast);
});
return;
}
if (removeLast && this.isLast("\n")) this.removeLast("\n");
this.removeLast(" ");
this.buf = this.buf.replace(/\n(\s+)$/, "\n");
this._push("\n");
};
CodeGenerator.prototype.removeLast = function (cha) {
if (!this.isLast(cha)) return;
this.buf = this.buf.slice(0, -1);
this.position.unshift(cha);
};
CodeGenerator.prototype.semicolon = function () {
if (this.style.semicolons) this.push(";");
};
CodeGenerator.prototype.ensureSemicolon = function () {
if (!this.isLast(";")) this.semicolon();
};
CodeGenerator.prototype.rightBrace = function () {
this.newline(true);
this.push("}");
};
CodeGenerator.prototype.keyword = function (name) {
this.push(name);
this.push(" ");
};
CodeGenerator.prototype.space = function () {
if (this.buf && !this.isLast([" ", "\n"])) {
this.push(" ");
}
};
CodeGenerator.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);
};
CodeGenerator.prototype._push = function (str) {
this.position.push(str);
this.buf += str;
};
CodeGenerator.prototype.endsWith = function (str) {
return this.buf.slice(-str.length) === str;
};
CodeGenerator.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = buf.trimRight();
var chars = [].concat(cha);
return _.contains(chars, _.last(buf));
};
CodeGenerator.prototype.getIndent = function () {
if (this.style.compact) {
return "";
} else {
return util.repeat(this.indentSize(), this.style.indent.char);
}
};
CodeGenerator.prototype.indentSize = function () {
return this._indent * this.style.indent.width;
};
CodeGenerator.prototype.indent = function () {
this._indent++;
};
CodeGenerator.prototype.dedent = function () {
this._indent--;
};
CodeGenerator.prototype.generate = function () {
var ast = this.ast;
this.print(ast);
this.buf = this.buf.trimRight();
var comments = [];
_.each(ast.comments, function (comment) {
if (!comment._displayed) comments.push(comment);
});
this._printComments(comments);
return {
map: this.map.get(),
ast: ast,
code: this.buf
code: this.buffer.get()
};
};
@@ -210,11 +115,10 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
if (!node) return "";
var self = this;
opts = opts || {};
var newline = function (leading) {
var ignoreDuplicates = false;
if (!opts.statement && !n.isUserWhitespacable(node, parent)) {
return;
}
@@ -235,12 +139,21 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
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, ignoreDuplicates);
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);
@@ -248,13 +161,12 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
if (opts.before) opts.before();
this.map.mark(node, "start");
// only compute if this node needs parens if our parent has been changed
// since acorn would've wrapped us in a ParanthesizedExpression
var needsParens = parent !== node._parent && n.needsParens(node, parent);
if (needsParens) this.push("(");
this[node.type](node, this.buildPrint(node), parent);
if (needsNoLineTermParens) {
this.newline();
this.dedent();
}
if (needsParens) this.push(")");
this.map.mark(node, "end");
@@ -264,11 +176,13 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
this.printTrailingComments(node, parent);
} else {
throw new ReferenceError("unknown node " + node.type + " " + JSON.stringify(node));
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
}
};
CodeGenerator.prototype.printJoin = function (print, nodes, opts) {
if (!nodes || !nodes.length) return;
opts = opts || {};
var self = this;
@@ -353,13 +267,28 @@ CodeGenerator.prototype._getComments = function (key, node) {
};
CodeGenerator.prototype._printComments = function (comments) {
if (this.style.compact) return;
if (!this.style.comments) return;
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));
@@ -373,14 +302,16 @@ CodeGenerator.prototype._printComments = function (comments) {
//
var offset = comment.loc.start.column;
if (offset) {
var newlineRegex = new RegExp("\\n\\s{1," + offset + "}", "g");
val = val.replace(newlineRegex, "\n");
}
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));
var indent = Math.max(self.indentSize(), column);
val = val.replace(/\n/g, "\n" + util.repeat(indent));
}
if (column === 0) {
val = self.getIndent() + val;

View File

@@ -30,3 +30,11 @@ exports.ClassBody = function (node, print) {
this.rightBrace();
}
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};

View File

@@ -8,7 +8,8 @@ exports.ComprehensionBlock = function (node, print) {
};
exports.ComprehensionExpression = function (node, print) {
this.push("[");
this.push(node.generator ? "(" : "[");
print.join(node.blocks, { separator: " " });
this.space();
@@ -21,5 +22,6 @@ exports.ComprehensionExpression = function (node, print) {
}
print(node.body);
this.push("]");
this.push(node.generator ? ")" : "]");
};

View File

@@ -1,4 +1,6 @@
var t = require("../../types");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
exports.UnaryExpression = function (node, print) {
var hasSpace = /[a-z]$/.test(node.operator);
@@ -17,12 +19,6 @@ exports.UnaryExpression = function (node, print) {
print(node.argument);
};
exports.ParenthesizedExpression = function (node, print) {
this.push("(");
print(node.expression);
this.push(")");
};
exports.UpdateExpression = function (node, print) {
if (node.prefix) {
this.push(node.operator);
@@ -44,9 +40,11 @@ exports.ConditionalExpression = function (node, print) {
exports.NewExpression = function (node, print) {
this.push("new ");
print(node.callee);
this.push("(");
print.join(node.arguments, { separator: ", " });
this.push(")");
if (node.arguments.length || this.format.parentheses) {
this.push("(");
print.join(node.arguments, { separator: ", " });
this.push(")");
}
};
exports.SequenceExpression = function (node, print) {
@@ -59,20 +57,45 @@ exports.ThisExpression = function () {
exports.CallExpression = function (node, print) {
print(node.callee);
this.push("(");
print.join(node.arguments, { separator: ", " });
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(")");
};
exports.YieldExpression = function (node, print) {
this.push("yield");
if (node.delegate) this.push("*");
if (node.argument) {
this.space();
print(node.argument);
}
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();
};
@@ -84,20 +107,38 @@ exports.ExpressionStatement = function (node, print) {
exports.BinaryExpression =
exports.LogicalExpression =
exports.AssignmentPattern =
exports.AssignmentExpression = function (node, print) {
print(node.left);
this.push(" " + node.operator + " ");
print(node.right);
};
exports.MemberExpression = function (node, print) {
print(node.object);
var SCIENTIFIC_NOTATION = /e/i;
if (node.computed) {
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,3 @@
exports.ClassProperty = function () {
throw new Error("not implemented");
};

View File

@@ -46,15 +46,11 @@ exports.XJSElement = function (node, print) {
this.indent();
_.each(node.children, function (child) {
if (t.isLiteral(child) && typeof child.value === "string") {
if (/\S/.test(child.value)) {
return self.push(child.value.replace(/^\s+|\s+$/g, ""));
} else if (/\n/.test(child.value)) {
return self.newline();
}
if (t.isLiteral(child)) {
self.push(child.value);
} else {
print(child);
}
print(child);
});
this.dedent();
@@ -78,5 +74,5 @@ exports.XJSClosingElement = function (node, print) {
};
exports.XJSEmptyExpression = function () {
this.push("null");
};

View File

@@ -41,6 +41,8 @@ exports._method = function (node, print) {
this.push(kind + " ");
}
if (value.async) this.push("async ");
if (node.computed) {
this.push("[");
print(key);
@@ -54,16 +56,9 @@ exports._method = function (node, print) {
print(value.body);
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
this.space();
@@ -74,6 +69,8 @@ exports.FunctionExpression = function (node, print) {
};
exports.ArrowFunctionExpression = function (node, print) {
if (node.async) this.push("async ");
if (node.params.length === 1 && !node.defaults.length && !node.rest && t.isIdentifier(node.params[0])) {
print(node.params[0]);
} else {

View File

@@ -1,7 +1,14 @@
var t = require("../../types");
var _ = require("lodash");
exports.ImportSpecifier =
exports.ImportSpecifier = function (node, print) {
if (node.id && node.id.name === "default") {
print(node.name);
} else {
return exports.ExportSpecifier.apply(this, arguments);
}
};
exports.ExportSpecifier = function (node, print) {
print(node.id);
if (node.name) {
@@ -25,9 +32,10 @@ exports.ExportDeclaration = function (node, print) {
if (node.declaration) {
print(node.declaration);
if (t.isStatement(node.declaration)) return;
} else {
if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) {
this.push("*");
print(specifiers[0]);
} else {
this.push("{");
if (specifiers.length) {
@@ -61,7 +69,9 @@ exports.ImportDeclaration = function (node, print) {
self.push(", ");
}
if (!spec.default && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
var isDefault = spec.id && spec.id.name === "default";
if (!isDefault && spec.type !== "ImportBatchSpecifier" && !foundImportSpecifier) {
foundImportSpecifier = true;
self.push("{ ");
}

View File

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

@@ -1,9 +1,11 @@
var t = require("../../types");
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);
};
@@ -134,15 +136,6 @@ exports.SwitchStatement = function (node, print) {
this.push(") {");
print.sequence(node.cases, { indent: true });
this.push("}");
//if (node.cases.length) {
// this.newline();
// print.sequence(node.cases, { indent: true });
// this.newline();
// this.rightBrace();
//} else {
// this.push("}");
//}
};
exports.SwitchCase = function (node, print) {
@@ -154,13 +147,8 @@ exports.SwitchCase = function (node, print) {
this.push("default:");
}
if (node.consequent.length === 1) {
this.space();
print(node.consequent[0]);
} else if (node.consequent.length > 1) {
this.newline();
print.sequence(node.consequent, { indent: true });
}
this.newline();
print.sequence(node.consequent, { indent: true });
};
exports.DebuggerStatement = function () {
@@ -170,13 +158,36 @@ exports.DebuggerStatement = function () {
exports.VariableDeclaration = function (node, print, parent) {
this.push(node.kind + " ");
print.join(node.declarations, { separator: ", " });
var inits = 0;
var noInits = 0;
for (var i in node.declarations) {
if (node.declarations[i].init) {
inits++;
} else {
noInits++;
}
}
var sep = ",";
if (inits > noInits) { // more inits than noinits
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);

View File

@@ -4,11 +4,18 @@ exports.Identifier = function (node) {
this.push(node.name);
};
exports.SpreadElement = function (node, print) {
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;
@@ -74,13 +81,20 @@ exports.Literal = function (node) {
var val = node.value;
var type = typeof val;
if (type === "boolean" || type === "number" || type === "string") {
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");
} else if (node.raw) {
this.push(node.raw);
}
};

View File

@@ -1,290 +0,0 @@
module.exports = Node;
var t = require("../types");
var _ = require("lodash");
function Node(node, parent) {
this.parent = parent;
this.node = node;
}
//
Node.whitespace = {
FunctionExpression: 1,
FunctionStatement: 1,
ClassExpression: 1,
ClassStatement: 1,
ForOfStatement: 1,
ForInStatement: 1,
ForStatement: 1,
SwitchStatement: 1,
IfStatement: { before: 1 },
//Property: { before: 1 },
Literal: { after: 1 }
};
_.each(Node.whitespace, function (amounts, type) {
if (_.isNumber(amounts)) amounts = { after: amounts, before: amounts };
Node.whitespace[type] = amounts;
});
//
Node.PRECEDENCE = {};
_.each([
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"]
], function (tier, i) {
_.each(tier, function (op) {
Node.PRECEDENCE[op] = i;
});
});
//
Node.prototype.isUserWhitespacable = function () {
//var parent = this.parent;
var node = this.node;
if (t.isUserWhitespacable(node)) {
return true;
}
//if (t.isArrayExpression(parent)) {
// return true;
//}
return false;
};
Node.prototype.needsWhitespace = function (type) {
var parent = this.parent;
var node = this.node;
if (!node) return 0;
if (t.isExpressionStatement(node)) {
node = node.expression;
}
if (type === "before") {
if (t.isProperty(node) && parent.properties[0] === node) {
return 1;
}
}
if (type === "after") {
if (t.isCallExpression(node)) {
return 1;
}
var exprs = [];
if (t.isVariableDeclaration(node)) {
exprs = _.map(node.declarations, "init");
}
if (t.isArrayExpression(node)) {
exprs = node.elements;
}
if (t.isObjectExpression(node)) {
exprs = node.properties;
}
var lines = 0;
_.each(exprs, function (expr) {
lines = Node.needsWhitespace(expr, node, type);
if (lines) return false;
});
if (lines) return lines;
}
if (t.isCallExpression(node) && t.isFunction(node.callee)) {
return 1;
}
var opts = Node.whitespace[node.type];
return (opts && opts[type]) || 0;
};
Node.prototype.needsWhitespaceBefore = function () {
return this.needsWhitespace("before");
};
Node.prototype.needsWhitespaceAfter = function () {
return this.needsWhitespace("after");
};
Node.prototype.needsParens = function () {
var parent = this.parent;
var node = this.node;
if (!parent) return false;
//
if (t.isUnaryLike(node)) {
return t.isMemberExpression(parent) && parent.object === node;
}
if (t.isBinary(node)) {
//
if (t.isCallExpression(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 = Node.PRECEDENCE[parentOp];
var nodeOp = node.operator;
var nodePos = Node.PRECEDENCE[nodeOp];
if (parentPos > nodePos) {
return true;
}
if (parentPos === nodePos && parent.right === node) {
return true;
}
}
}
if (t.isBinaryExpression(node) && node.operator === "in") {
// var i = (1 in []);
if (t.isVariableDeclarator(parent)) {
return true;
}
// for ((1 in []);;);
if (t.isFor(parent)) {
return true;
}
}
// (class {});
if (t.isClassExpression(node) && t.isExpressionStatement(parent)) {
return true;
}
if (t.isSequenceExpression(node)) {
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;
}
//
if (t.isYieldExpression(node)) {
return t.isBinary(parent) ||
t.isUnaryLike(parent) ||
t.isCallExpression(parent) ||
t.isMemberExpression(parent) ||
t.isNewExpression(parent) ||
t.isConditionalExpression(parent) ||
t.isYieldExpression(parent);
}
if (t.isNewExpression(parent) && parent.callee === node) {
return t.isCallExpression(node) || _.some(node, function (val) {
return t.isCallExpression(val);
});
}
// (1).valueOf()
if (t.isLiteral(node) && _.isNumber(node.value) && t.isMemberExpression(parent) && parent.object === node) {
return true;
}
if (t.isAssignmentExpression(node) || t.isConditionalExpression(node)) {
//
if (t.isUnaryLike(parent)) {
return true;
}
//
if (t.isBinary(parent)) {
return true;
}
//
if (t.isCallExpression(parent) && parent.callee === node) {
return true;
}
//
if (t.isConditionalExpression(parent) && parent.test === node) {
return true;
}
//
if (t.isMemberExpression(parent) && parent.object === node) {
return true;
}
}
if (t.isFunctionExpression(node)) {
// 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;
}
}
// ({ x, y }) = { x: 5, y: 6 };
if (t.isObjectPattern(node) && t.isAssignmentExpression(parent) && parent.left == node) {
return true;
}
return false;
};
_.each(Node.prototype, function (fn, key) {
Node[key] = function (node, parent) {
var n = new Node(node, parent);
var args = _.toArray(arguments).slice(2);
return n[key].apply(n, args);
};
});

View File

@@ -0,0 +1,105 @@
module.exports = Node;
var whitespace = require("./whitespace");
var parens = require("./parentheses");
var t = require("../../types");
var _ = require("lodash");
var find = function (obj, node, parent) {
var result;
_.each(obj, function (fn, type) {
if (t["is" + type](node)) {
result = fn(node, parent);
if (result != null) return false;
}
});
return result;
};
function Node(node, parent) {
this.parent = parent;
this.node = node;
}
Node.prototype.isUserWhitespacable = function () {
return t.isUserWhitespacable(this.node);
};
Node.prototype.needsWhitespace = function (type) {
var parent = this.parent;
var node = this.node;
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.prototype.needsWhitespaceBefore = function () {
return this.needsWhitespace("before");
};
Node.prototype.needsWhitespaceAfter = function () {
return this.needsWhitespace("after");
};
Node.prototype.needsParens = function () {
var parent = this.parent;
var node = this.node;
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.prototype.needsParensNoLineTerminator = function () {
var parent = this.parent;
var node = this.node;
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.prototype, function (fn, key) {
Node[key] = function (node, parent) {
var n = new Node(node, parent);
var args = _.toArray(arguments).slice(2);
return n[key].apply(n, args);
};
});

View File

@@ -0,0 +1,158 @@
var t = require("../../types");
var _ = require("lodash");
var PRECEDENCE = {};
_.each([
["||"],
["&&"],
["|"],
["^"],
["&"],
["==", "===", "!=", "!=="],
["<", ">", "<=", ">=", "in", "instanceof"],
[">>", "<<", ">>>"],
["+", "-"],
["*", "/", "%"],
["**"]
], function (tier, i) {
_.each(tier, function (op) {
PRECEDENCE[op] = i;
});
});
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) && 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,72 @@
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(amounts, function (amount, key) {
exports[key].nodes[type] = function () {
return amount;
};
});
});

View File

@@ -9,7 +9,8 @@ function SourceMap(position, opts, code) {
if (opts.sourceMap) {
this.map = new sourceMap.SourceMapGenerator({
file: opts.sourceMapName
file: opts.sourceMapName,
sourceRoot: opts.sourceRoot
});
this.map.setSourceContent(opts.sourceFileName, code);

View File

@@ -38,7 +38,11 @@ Whitespace.prototype.getNewlinesAfter = function (node) {
}
});
return this.getNewlinesBetween(startToken, endToken);
if (endToken.type.type === "eof") {
return 1;
} else {
return this.getNewlinesBetween(startToken, endToken);
}
};
Whitespace.prototype.getNewlinesBetween = function (startToken, endToken) {

View File

@@ -3,7 +3,11 @@ var util = require("./util");
var fs = require("fs");
var _ = require("lodash");
exports.runtime = require("./runtime");
exports.version = require("../../package").version;
exports.types = require("./types");
exports.runtime = require("./runtime-generator");
exports.register = function (opts) {
var register = require("./register");
@@ -17,6 +21,9 @@ exports.polyfill = function () {
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,28 +1,53 @@
var t = require("./types");
var _ = require("lodash");
// estraverse
var estraverse = require("estraverse");
_.extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
// regenerator/recast/ast-types
var types = require("ast-types");
var def = types.Type.def;
var or = types.Type.or;
// Program wrapper
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"));
// Non-standard Acorn type
def("ParenthesizedExpression")
.bases("Expression")
.build("expression")
.field("expression", def("Expression"));
// Same as ImportNamespaceSpecifier but `id` is `name`
// Acorn - Same as ImportNamespaceSpecifier but `id` is `name`
def("ImportBatchSpecifier")
.bases("Specifier")
.build("name")
.field("name", def("Identifier"));
types.finalize();
// Abstract references
def("VirtualPropertyExpression")
.bases("Expression")
.build("object", "property")
.field("object", def("Expression"))
.field("property", or(def("Identifier"), def("Expression")));
var estraverse = require("estraverse");
_.extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
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,6 +1,2 @@
if (typeof Symbol === "undefined") {
require("es6-symbol/implement");
}
require("es6-shim");
require("regenerator-6to5/runtime");
require("core-js/shim");
require("regenerator/runtime");

View File

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

View File

@@ -1,7 +1,10 @@
require("./polyfill");
var sourceMapSupport = require("source-map-support");
var roadrunner = require("roadrunner");
var util = require("./util");
var to5 = require("./index");
var fs = require("fs");
var _ = require("lodash");
sourceMapSupport.install({
@@ -36,14 +39,22 @@ var blacklistTest = function (transformer, code) {
};
blacklistTest("arrayComprehension", "var foo = [for (foo of bar) foo * foo];");
blacklistTest("generatorComprehension", "var foo = (for (foo of bar) foo * foo)");
blacklistTest("arrowFunctions", "var foo = x => x * x;");
blacklistTest("classes", "class Foo {}");
blacklistTest("computedPropertyNames", "var foo = { [foo]: bar };");
//blacklistTest("constants", "const foo = 0;");
blacklistTest("constants", function () {
try {
new Function("const foo = 'foo';\nfoo = 'wow';");
} catch (err) {
return; // constants are supported
}
throw new SyntaxError;
});
blacklistTest("defaultParamaters", "var foo = function (bar = 0) {};");
blacklistTest("destructuring", "var { x, y } = { x: 0, y: 0 };");
blacklistTest("forOf", "for (var foo of bar) {}");
blacklistTest("generators", "function* foo() {}");
blacklistTest("generators", "function* foo() {}\nasync function bar() {}"); // generators/async functions delegated to same transformer
blacklistTest("letScoping", "let foo = 0;");
blacklistTest("modules", 'import foo from "from";');
blacklistTest("propertyMethodAssignment", "{ get foo() {} }");
@@ -55,23 +66,44 @@ blacklistTest("unicodeRegex", function () { new RegExp("foo", "u"); });
//
var ignoreRegex = /node_modules/;
var transformOpts = {};
var ignoreRegex = /node_modules/;
var onlyRegex;
var whitelist = [];
var exts = {};
var maps = {};
var old = require.extensions[".js"];
var whitelist = [];
var cache;
var exts = {};
var maps = {};
var old = require.extensions[".js"];
var mtime = function (filename) {
return +fs.statSync(filename).mtime;
};
var loader = function (m, filename) {
if ((ignoreRegex && ignoreRegex.test(filename)) || (onlyRegex && !onlyRegex.test(filename))) {
return old.apply(this, arguments);
}
var result = to5.transformFileSync(filename, {
var result;
if (cache) {
var cached = cache[filename];
if (cached && cached.mtime === mtime(filename)) {
result = cached;
}
}
result = result || to5.transformFileSync(filename, _.extend({
whitelist: whitelist,
blacklist: blacklist,
sourceMap: true
});
sourceMap: true,
ast: false
}, transformOpts));
if (cache) {
result.mtime = mtime(filename);
cache[filename] = result;
}
maps[filename] = result.map;
@@ -91,7 +123,7 @@ var hookExtensions = function (_exts) {
});
};
hookExtensions([".es6", ".js"]);
hookExtensions([".es6", ".es", ".js"]);
module.exports = function (opts) {
// normalise options
@@ -99,11 +131,18 @@ module.exports = function (opts) {
if (_.isRegExp(opts)) opts = { ignore: opts };
if (opts.ignoreRegex != null) opts.ignore = opts.ignoreRegex;
if (opts.only != null) onlyRegex = opts.only;
if (opts.ignore != null) ignoreRegex = opts.ignore;
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.blacklist) blacklist = opts.blacklist;
if (opts.whitelist) whitelist = opts.whitelist;
if (opts.cache) cache = opts.cache;
if (opts.cache === false) cache = null;
if (opts.cache === true) {
roadrunner.load();
roadrunner.setup();
cache = roadrunner.get("6to5");
}
_.extend(transformOpts, opts);
};

View File

@@ -5,22 +5,24 @@ var t = require("./types");
var _ = require("lodash");
module.exports = function (namespace) {
namespace = t.identifier(namespace || "to5Runtime");
namespace = t.identifier(t.toIdentifier(namespace || "to5Runtime"));
var body = [];
var container = t.functionExpression(null, [], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, []))]);
body.push(util.template("self-global", true));
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
body.push(t.variableDeclaration("var", [
t.variableDeclarator(
namespace,
t.assignmentExpression("=", t.memberExpression(t.identifier("self"), namespace), t.objectExpression([]))
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([]))
)
]));
_.each(File.declarations, function (name) {
_.each(File.helpers, function (name) {
if (_.contains(File.excludeHelpersFromRuntime, name)) {
return false;
}
var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))

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.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 +0,0 @@
var VARIABLE_NAME = require(MODULE_NAME);

View File

@@ -1 +0,0 @@
var self = typeof global === "undefined" ? window : global;

View File

@@ -0,0 +1,267 @@
module.exports = DefaultFormatter;
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function DefaultFormatter(file) {
this.file = file;
this.localExports = this.getLocalExports();
this.localImports = this.getLocalImports();
this.remapAssignments();
//this.checkCollisions();
}
DefaultFormatter.prototype.getLocalExports = function () {
var localExports = {};
traverse(this.file.ast, {
enter: function (node) {
var declar = node && node.declaration;
if (t.isExportDeclaration(node) && declar && t.isStatement(declar)) {
_.extend(localExports, t.getIds(declar, true));
}
}
});
return localExports;
};
DefaultFormatter.prototype.getLocalImports = function () {
var localImports = {};
traverse(this.file.ast, {
enter: function (node) {
if (t.isImportDeclaration(node)) {
_.extend(localImports, t.getIds(node, true));
}
}
});
return localImports;
};
DefaultFormatter.prototype.checkCollisions = function () {
// todo: all check export collissions
var localImports = this.localImports;
var file = this.file;
var isLocalReference = function (node) {
return t.isIdentifier(node) && _.has(localImports, node.name) && localImports[node.name] !== node;
};
var check = function (node) {
if (isLocalReference(node)) {
throw file.errorWithNode(node, "Illegal assignment of module import");
}
};
traverse(file.ast, {
enter: function (node) {
if (t.isAssignmentExpression(node)) {
var left = node.left;
if (t.isMemberExpression(left)) {
while (left.object) left = left.object;
}
check(left);
} else if (t.isDeclaration(node)) {
_.each(t.getIds(node, true), check);
}
}
});
};
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.remapAssignments = function () {
var localExports = this.localExports;
var self = this;
var isLocalReference = function (node, scope) {
var name = node.name;
return t.isIdentifier(node) && localExports[name] && localExports[name] === scope.get(name, true);
};
traverse(this.file.ast, {
enter: function (node, parent, scope) {
if (t.isUpdateExpression(node) && isLocalReference(node.argument, scope)) {
this.skip();
// expand to long file assignment expression
var assign = t.assignmentExpression(node.operator[0] + "=", node.argument, t.literal(1));
// remap this assignment expression
var remapped = self.remapExportAssignment(assign);
// we don't need to change the result
if (t.isExpressionStatement(parent) || node.prefix) {
return remapped;
}
var nodes = [];
nodes.push(remapped);
var operator;
if (node.operator === "--") {
operator = "+";
} else { // "++"
operator = "-";
}
nodes.push(t.binaryExpression(operator, node.argument, t.literal(1)));
return t.sequenceExpression(nodes);
}
if (t.isAssignmentExpression(node) && isLocalReference(node.left, scope)) {
this.skip();
return self.remapExportAssignment(node);
}
}
});
};
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, "");
}
// 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._exportSpecifier = function (getRef, specifier, node, nodes) {
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
if (node.source) {
if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
nodes.push(this._exportsWildcard(getRef(), node));
} else {
var ref;
if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
// importing a default so we need to normalise it
ref = t.callExpression(this.file.addHelper("interop-require"), [getRef()]);
} else {
ref = t.memberExpression(getRef(), specifier.id);
}
// export { foo } from "test";
nodes.push(this._exportsAssign(
t.getSpecifierName(specifier),
ref,
node
));
}
} else {
// export { foo };
nodes.push(this._exportsAssign(t.getSpecifierName(specifier), specifier.id, node));
}
};
DefaultFormatter.prototype._exportsWildcard = function (objectIdentifier) {
return t.expressionStatement(t.callExpression(this.file.addHelper("exports-wildcard"), [
t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])
]));
};
DefaultFormatter.prototype._exportsAssign = 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 in declar.declarations) {
var decl = declar.declarations[i];
decl.init = this._exportsAssign(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._exportsAssign(id, ref, node);
nodes.push(assign);
this._hoistExport(declar, assign);
}
};

View File

@@ -1,16 +1,29 @@
module.exports = AMDFormatter;
var CommonJSFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
var DefaultFormatter = require("./_default");
var CommonFormatter = require("./common");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function AMDFormatter(file) {
this.file = file;
function AMDFormatter() {
DefaultFormatter.apply(this, arguments);
this.ids = {};
}
util.inherits(AMDFormatter, CommonJSFormatter);
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;
@@ -19,22 +32,40 @@ AMDFormatter.prototype.transform = function (ast) {
// build an array of module names
var names = [t.literal("exports")];
_.each(this.ids, function (id, name) {
names.push(t.literal(name));
});
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 call = t.callExpression(t.identifier("define"), [names, container]);
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._push = function (node) {
var id = node.source.value;
var ids = this.ids;
@@ -42,31 +73,26 @@ AMDFormatter.prototype._push = function (node) {
if (ids[id]) {
return ids[id];
} else {
return this.ids[id] = t.identifier(this.file.generateUid(id));
return this.ids[id] = this.file.generateUidIdentifier(id);
}
};
AMDFormatter.prototype.import = function (node) {
AMDFormatter.prototype.importDeclaration = function (node) {
this._push(node);
};
AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var key = t.getSpecifierName(specifier);
var id = specifier.id;
// import foo from "foo";
if (specifier.default) {
id = t.identifier("default");
}
var ref;
var ref = this._push(node);
if (t.isImportBatchSpecifier(specifier)) {
// import * as bar from "foo";
ref = this._push(node);
} else {
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
// import foo from "foo";
ref = t.memberExpression(this._push(node), id, false);
ref = t.callExpression(this.file.addHelper("interop-require"), [ref]);
} else {
// import {foo} from "foo";
ref = t.memberExpression(ref, specifier.id, false);
}
nodes.push(t.variableDeclaration("var", [
@@ -74,6 +100,14 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
]));
};
AMDFormatter.prototype.exportDeclaration = function (node) {
if (node.default) {
this.passModuleArg = true;
}
CommonFormatter.prototype.exportDeclaration.apply(this, arguments);
};
AMDFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var self = this;
return this._exportSpecifier(function () {

View File

@@ -1,132 +1,105 @@
module.exports = CommonJSFormatter;
var util = require("../../util");
var t = require("../../types");
var DefaultFormatter = require("./_default");
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
function CommonJSFormatter(file) {
this.file = file;
DefaultFormatter.apply(this, arguments);
var hasNonDefaultExports = false;
traverse(file.ast, {
enter: function (node) {
if (t.isExportDeclaration(node) && !node.default) hasNonDefaultExports = true;
}
});
this.hasNonDefaultExports = hasNonDefaultExports;
}
CommonJSFormatter.prototype.import = function (node, nodes) {
// import "foo";
nodes.push(util.template("require", {
//inherits: node,
MODULE_NAME: node.source.raw
}, true));
};
util.inherits(CommonJSFormatter, DefaultFormatter);
CommonJSFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
var variableName = t.getSpecifierName(specifier);
// import foo from "foo";
if (specifier.default) {
specifier.id = t.identifier("default");
if (t.isSpecifierDefault(specifier)) {
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(variableName,
t.callExpression(this.file.addHelper("interop-require"), [util.template("require", {
MODULE_NAME: node.source
})])
)
]));
} 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"), [
t.callExpression(t.identifier("require"), [node.source])
])
)
]));
} else {
// import foo from "foo";
nodes.push(util.template("require-assign-key", {
VARIABLE_NAME: variableName,
MODULE_NAME: node.source,
KEY: specifier.id
}));
}
}
var templateName = "require-assign";
// import * as bar from "foo";
if (specifier.type !== "ImportBatchSpecifier") templateName += "-key";
nodes.push(util.template(templateName, {
//inherits: node.specifiers.length === 1 && node,
VARIABLE_NAME: variableName,
MODULE_NAME: node.source.raw,
KEY: specifier.id
}));
};
CommonJSFormatter.prototype.export = function (node, nodes) {
var declar = node.declaration;
CommonJSFormatter.prototype.importDeclaration = function (node, nodes) {
// import "foo";
nodes.push(util.template("require", {
MODULE_NAME: node.source
}, true));
};
if (node.default) {
var ref = declar;
if (t.isClass(ref) || t.isFunction(ref)) {
if (ref.id) {
nodes.push(t.toStatement(ref));
ref = ref.id;
}
}
nodes.push(util.template("exports-default", {
//inherits: node,
VALUE: ref
}, true));
} else {
CommonJSFormatter.prototype.exportDeclaration = function (node, nodes) {
if (node.default && !this.exportIdentifier) {
var declar = node.declaration;
var assign;
if (t.isVariableDeclaration(declar)) {
var decl = declar.declarations[0];
// module.exports = VALUE;
var templateName = "exports-default-module";
if (decl.init) {
decl.init = util.template("exports-assign", {
//inherits: node,
// exports = module.exports = VALUE;
if (this.hasNonDefaultExports) templateName = "exports-default-module-override";
VALUE: decl.init,
KEY: decl.id
});
}
nodes.push(declar);
} else {
assign = util.template("exports-assign", {
//inherits: node,
VALUE: declar.id,
KEY: declar.id
if (t.isFunctionDeclaration(declar) || !this.hasNonDefaultExports) {
assign = util.template(templateName, {
VALUE: this._pushStatement(declar, nodes)
}, true);
nodes.push(t.toStatement(declar));
nodes.push(assign);
if (t.isFunctionDeclaration(declar)) {
assign._blockHoist = true;
}
}
}
};
CommonJSFormatter.prototype._exportSpecifier = function (getRef, specifier, node, nodes) {
var variableName = t.getSpecifierName(specifier);
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
if (node.source) {
if (t.isExportBatchSpecifier(specifier)) {
// export * from "foo";
nodes.push(util.template("exports-wildcard", {
//inherits: inherits,
OBJECT: getRef()
}, true));
// hoist to the top if this default is a function
nodes.push(this._hoistExport(declar, assign, 3));
return;
} else {
// export { foo } from "test";
nodes.push(util.template("exports-assign-key", {
//inherits: inherits,
// this export isn't a function so we can't hoist it to the top so we need to set it
// at the very end of the file with something like:
//
// module.exports = _extends(exports["default"], exports)
//
VARIABLE_NAME: variableName.name,
OBJECT: getRef(),
KEY: specifier.id
}, true));
assign = util.template("common-export-default-assign", {
EXTENDS_HELPER: this.file.addHelper("extends")
}, true);
assign._blockHoist = 0;
nodes.push(assign);
}
} else {
// export { foo };
nodes.push(util.template("exports-assign", {
//inherits: inherits,
VALUE: specifier.id,
KEY: variableName
}, true));
}
DefaultFormatter.prototype.exportDeclaration.apply(this, arguments);
};
CommonJSFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
return this._exportSpecifier(function () {
this._exportSpecifier(function () {
return t.callExpression(t.identifier("require"), [node.source]);
}, specifier, node, nodes);
};

View File

@@ -6,19 +6,13 @@ function IgnoreFormatter() {
}
IgnoreFormatter.prototype.import = function () {
};
IgnoreFormatter.prototype.importSpecifier = function () {
};
IgnoreFormatter.prototype.export = function (node, nodes) {
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,179 @@
module.exports = SystemFormatter;
var AMDFormatter = require("./amd");
var useStrict = require("../transformers/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;
AMDFormatter.apply(this, arguments);
}
util.inherits(SystemFormatter, AMDFormatter);
SystemFormatter.prototype._addImportSource = function (node, exportNode) {
node._importSource = exportNode.source && exportNode.source.value;
return node;
};
SystemFormatter.prototype._exportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
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._exportsAssign = 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);
};
SystemFormatter.prototype.buildRunnerSetters = function (block, hoistDeclarators) {
return t.arrayExpression(_.map(this.ids, function (uid, source) {
var nodes = [];
traverse(block, {
enter: function (node) {
if (node._importSource === source) {
if (t.isVariableDeclaration(node)) {
_.each(node.declarations, function (declar) {
hoistDeclarators.push(t.variableDeclarator(declar.id));
nodes.push(t.expressionStatement(
t.assignmentExpression("=", declar.id, declar.init)
));
});
} else {
nodes.push(node);
}
this.remove();
}
}
});
return t.functionExpression(null, [uid], t.blockStatement(nodes));
}));
};
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, {
enter: function (node, parent, scope) {
if (t.isFunction(node)) {
// nothing inside is accessible
return this.skip();
}
if (t.isVariableDeclaration(node)) {
if (node.kind !== "var" && !t.isProgram(parent)) { // let, const
// can't be accessed
return;
}
var nodes = [];
_.each(node.declarations, function (declar) {
hoistDeclarators.push(t.variableDeclarator(declar.id));
if (declar.init) {
// no initializer so we can just hoist it as-is
var assign = t.expressionStatement(t.assignmentExpression("=", declar.id, declar.init));
nodes.push(assign);
}
});
// for (var i in test)
// for (var i = 0;;)
if (t.isFor(parent)) {
if (parent.left === node) {
return node.declarations[0].id;
}
if (parent.init === node) {
return t.toSequenceExpression(nodes, scope);
}
}
return nodes;
}
}
});
if (hoistDeclarators.length) {
var hoistDeclar = t.variableDeclaration("var", hoistDeclarators);
hoistDeclar._blockHoist = true;
handlerBody.unshift(hoistDeclar);
}
// hoist up function declarations for circular references
traverse(block, {
enter: function (node) {
if (t.isFunction(node)) this.skip();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
this.remove();
}
}
});
handlerBody.push(returnStatement);
if (useStrict._has(block)) {
handlerBody.unshift(block.body.shift());
}
program.body = [runner];
};

View File

@@ -5,9 +5,8 @@ var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function UMDFormatter(file) {
this.file = file;
this.ids = {};
function UMDFormatter() {
AMDFormatter.apply(this, arguments);
}
util.inherits(UMDFormatter, AMDFormatter);
@@ -19,25 +18,44 @@ UMDFormatter.prototype.transform = function (ast) {
// build an array of module names
var names = [];
_.each(this.ids, function (id, name) {
for (var name in this.ids) {
names.push(t.literal(name));
});
}
// factory
var ids = _.values(this.ids);
var args = [t.identifier("exports")].concat(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));
// runner
var runner = util.template("umd-runner-body", {
AMD_ARGUMENTS: t.arrayExpression([t.literal("exports")].concat(names)),
var defineArgs = [t.literal("exports")];
if (this.passModuleArg) defineArgs.push(t.literal("module"));
defineArgs = defineArgs.concat(names);
defineArgs = [t.arrayExpression(defineArgs)];
COMMON_ARGUMENTS: names.map(function (name) {
return t.callExpression(t.identifier("require"), [name]);
})
// typeof exports !== "undefined" && typeof module !== "undefined"
var testExports = t.binaryExpression("!==", t.unaryExpression("typeof", t.identifier("exports"), true), t.literal("undefined")),
testModule = t.binaryExpression("!==", t.unaryExpression("typeof", t.identifier("module"), true), t.literal("undefined")),
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]);
}));
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
});
//

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
PROPERTY[Symbol.referenceSet](OBJECT, VALUE)

View File

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

View File

@@ -0,0 +1 @@
Array.from(VALUE);

View File

@@ -0,0 +1,37 @@
(function (fn) {
return function () {
var gen = fn.apply(this, arguments);
return new Promise(function (resolve, reject) {
function step(getNext) {
var next;
try {
next = getNext();
} catch(e) {
reject(e);
return;
}
if (next.done) {
resolve(next.value);
return;
}
Promise.resolve(next.value).then(function (v) {
step(function () {
return gen.next(v);
});
}, function (e) {
step(function () {
return gen["throw"](e);
});
});
}
step(function () {
return gen.next();
});
});
}
})

View File

@@ -0,0 +1 @@
Function.prototype.bind

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,8 @@
(function (obj, key, value) {
return Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
});

View File

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

View File

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

View File

@@ -0,0 +1,7 @@
(function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
}
}
})

View File

@@ -0,0 +1,9 @@
(function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
target[key] = source[key];
}
}
return target;
})

View File

@@ -0,0 +1 @@
Object.prototype.hasOwnProperty;

View File

@@ -0,0 +1,14 @@
(function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
})

View File

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

View File

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

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