Compare commits

...

118 Commits

Author SHA1 Message Date
Sebastian McKenzie
d28583bea1 v4.7.16 2015-03-18 23:36:04 +11:00
Sebastian McKenzie
b166f35218 add typed arrays to native types list - #1043 2015-03-18 23:34:37 +11:00
Sebastian McKenzie
0914378bba add 4.7.16 changelog 2015-03-18 23:34:26 +11:00
Sebastian McKenzie
660d764390 remove loop check when aliasing breaks, continues etc - fixes #1051 2015-03-18 23:31:11 +11:00
Sebastian McKenzie
d919d7837c 4.7.15 2015-03-18 19:17:07 +11:00
Sebastian McKenzie
b49cf4e779 v4.7.15 2015-03-18 19:16:01 +11:00
Sebastian McKenzie
e30dd7042b fix constructor spreading of collections #1043 2015-03-18 19:14:23 +11:00
Sebastian McKenzie
16d8d928e8 4.7.14 2015-03-18 19:14:02 +11:00
Sebastian McKenzie
4966028397 v4.7.14 2015-03-18 19:11:21 +11:00
Sebastian McKenzie
82e04fffac add 4.7.14 changelog 2015-03-18 19:08:53 +11:00
Sebastian McKenzie
a46313903d deprecate abstract references and remaining playground features 2015-03-18 19:08:05 +11:00
Sebastian McKenzie
68340b1288 add Promise to the list of native types - fixes #1043 2015-03-18 19:06:34 +11:00
Sebastian McKenzie
7f9fe4af15 4.7.13 2015-03-17 12:12:51 +11:00
Sebastian McKenzie
977290c7e4 v4.7.13 2015-03-17 12:11:26 +11:00
Sebastian McKenzie
ebbdb95278 add 4.7.13 changelog 2015-03-17 12:09:16 +11:00
Sebastian McKenzie
9b586c7587 add support for left side patterns in assignment pattern destructuring - fixes #1037 2015-03-17 12:03:13 +11:00
Brian Donovan
4b5ba6c8c6 Add a test for the this-spread fix in 976e8c1.
Addresses #1033.
2015-03-17 11:31:09 +11:00
Sebastian McKenzie
67efb1b427 ignore this expressions in Scope#generateTempBasedOnNode - fixes #1033 2015-03-17 11:31:00 +11:00
Sebastian McKenzie
bc9c1ab61e handle comments and use strict directives better - fixes #1030 2015-03-17 11:30:30 +11:00
Sebastian McKenzie
9f037fa75e Merge pull request #1025 from thejameskyle/tjk/fix-flag
Correct --gdbjit v8 flag
2015-03-15 18:41:36 +11:00
James Kyle
8681a78618 Correct --gdbjit v8 flag 2015-03-15 00:39:48 -07:00
Sebastian McKenzie
2d72d423b3 Merge pull request #1024 from thejameskyle/tjk/1020-v8-flags
Add all v8 flags (node & iojs)
2015-03-15 18:35:19 +11:00
James Kyle
280964eafe Add all v8 flags (node & iojs). Fixes #1020 2015-03-15 00:33:39 -07:00
Sebastian McKenzie
d71c72de3c 4.7.12 2015-03-14 02:39:09 +11:00
Sebastian McKenzie
b1c21b8d4d v4.7.12 2015-03-14 02:37:30 +11:00
Sebastian McKenzie
e9b0005cf5 deprecate playground.methodBinding 2015-03-14 02:35:10 +11:00
Sebastian McKenzie
d0b6aa9882 4.7.11 2015-03-14 02:30:59 +11:00
Sebastian McKenzie
0e877acfdf v4.7.11 2015-03-14 02:29:42 +11:00
Sebastian McKenzie
b670ee18df fix unicode regex test 2015-03-14 02:28:32 +11:00
Sebastian McKenzie
24807120bf fix unicode regexes stripping their unicode flag before being passed on two regexpu - fixes #1009 2015-03-14 02:26:20 +11:00
Sebastian McKenzie
33f7c0b67e rejigger regex flag pulling 2015-03-14 02:12:13 +11:00
Sebastian McKenzie
c23b47f796 4.7.10 2015-03-14 02:02:06 +11:00
Sebastian McKenzie
2871d8a710 v4.7.10 2015-03-14 01:57:26 +11:00
Sebastian McKenzie
3172b5de5d Merge branch 'master' of github.com:babel/babel 2015-03-14 01:53:15 +11:00
Sebastian McKenzie
2c05303813 deprecate some playground transformers 2015-03-14 01:52:59 +11:00
Sebastian McKenzie
75dda10057 add 4.7.10 changelog 2015-03-14 01:52:51 +11:00
Sebastian McKenzie
581f70c803 Merge pull request #1013 from Rich-Harris/patch-1
fix inputSourceMap option
2015-03-14 01:47:55 +11:00
Rich Harris
a00d2c33d8 fix inputSourceMap option
See #827 - it looks like `opts.inputSourceMap` is the wrong way round, babel should only use an input sourcemap if the `inputSourceMap` option is *not* `false`
2015-03-13 10:46:50 -04:00
Sebastian McKenzie
27fc574e9f 4.7.9 2015-03-13 13:33:50 +11:00
Sebastian McKenzie
a3b1fcc79c v4.7.9 2015-03-13 13:30:14 +11:00
Sebastian McKenzie
491cb26c1f remove console.log 2015-03-13 13:29:13 +11:00
Sebastian McKenzie
7c3d052714 add 4.7.9 changelog 2015-03-13 13:27:40 +11:00
Sebastian McKenzie
4971d0c7f0 fix labeled nested for ofs - fixes #996 2015-03-13 13:25:37 +11:00
Sebastian McKenzie
eb4922b1ec update acorn-babel 2015-03-13 13:25:19 +11:00
Sebastian McKenzie
bb26183b44 set inputSourceMap to null by default 2015-03-13 13:14:17 +11:00
Sebastian McKenzie
4b066f7f1b add input sourcemap false option #827 2015-03-13 13:12:38 +11:00
Sebastian McKenzie
3cd110a7c9 fix block scoping break switch collision - fixes #998 2015-03-12 14:35:30 +11:00
Sebastian McKenzie
a7f9e035a4 infer computed literal function names - fixes #993 2015-03-12 14:13:24 +11:00
Sebastian McKenzie
146b9e6708 4.7.8 2015-03-11 10:17:09 +11:00
Sebastian McKenzie
0953c48620 v4.7.8 2015-03-11 07:49:54 +11:00
Sebastian McKenzie
056b90831d manually define each property in computed class helper - fixes #984 2015-03-11 07:45:29 +11:00
Sebastian McKenzie
8ba276b209 4.7.7 2015-03-11 01:25:41 +11:00
Sebastian McKenzie
8eaa9d29e3 v4.7.7 2015-03-11 01:20:34 +11:00
Sebastian McKenzie
6212791356 fix types API exposure - babel/babel-eslint#8 2015-03-11 01:14:36 +11:00
Sebastian McKenzie
d436d32d82 4.7.6 2015-03-11 00:13:03 +11:00
Sebastian McKenzie
2a29f70bba v4.7.6 2015-03-11 00:11:35 +11:00
Sebastian McKenzie
6ccb8957bd add 4.7.6 changelog 2015-03-11 00:09:52 +11:00
Sebastian McKenzie
dc45415ee0 hoist esModule to the top 2015-03-11 00:08:06 +11:00
Sebastian McKenzie
98ca541fde restructure types 2015-03-11 00:04:06 +11:00
Sebastian McKenzie
8328f638c2 add support for if and block statements to t.toSequenceExpression 2015-03-10 17:20:26 +11:00
Sebastian McKenzie
5586ce280f move build-external-helpers to tools 2015-03-10 17:20:14 +11:00
Sebastian McKenzie
0ca71f5e15 add transformation logger 2015-03-10 17:19:51 +11:00
Sebastian McKenzie
212776e220 remove detection 2015-03-10 17:19:35 +11:00
Sebastian McKenzie
4a95a9ec8f remove duplicate insert_final_newline 2015-03-10 17:19:23 +11:00
Sebastian McKenzie
45953ffc8a 4.7.5 2015-03-10 13:39:04 +11:00
Sebastian McKenzie
9c79290bb2 v4.7.5 2015-03-10 13:20:20 +11:00
Sebastian McKenzie
cfdf6b7385 add 4.7.5 changelog 2015-03-10 13:12:19 +11:00
Sebastian McKenzie
907e0e0f86 drop support for node 0.10 to save travis some unnecessary cycles <3 2015-03-10 13:11:06 +11:00
Sebastian McKenzie
f3bd9cbcb8 use a different helper if a class contains class methods to avoid non-enumerability and delegation to es6.properties.computed transformer - fixes #984, closes #986 2015-03-10 13:04:02 +11:00
Sebastian McKenzie
3bd14f9e07 add babel version to register hook cache key 2015-03-10 13:03:22 +11:00
Sebastian McKenzie
102b4b3d1e remove redundant break wrapping in for-of - fixes #985 2015-03-10 12:14:21 +11:00
Sebastian McKenzie
6564f1ff76 4.7.4 2015-03-10 06:13:37 +11:00
Sebastian McKenzie
58d7a5e069 more versatile scope pushing 2015-03-10 06:13:32 +11:00
Sebastian McKenzie
f5db53cebe remove core-js library from babel-runtime 2015-03-10 06:13:16 +11:00
Sebastian McKenzie
2da010fcae clean up #982 2015-03-10 06:11:55 +11:00
Sebastian McKenzie
52b99bdf93 Merge pull request #982 from tricknotes/error-stack
Ignore assignment to Error#stack if it is readonly property
2015-03-10 06:09:03 +11:00
Ryunosuke SATO
9d7e953451 Ignore assignment to Error#stack if it is readonly property
`Error#stack` may be an readonly property in some environments
such as PhantomJS 1.9.2 and Safari 7.0.
2015-03-10 04:05:53 +09:00
Sebastian McKenzie
b1252b865b v4.7.4 2015-03-10 03:29:47 +11:00
Sebastian McKenzie
068b1341d9 fix erroneous whitespace 2015-03-10 03:28:36 +11:00
Sebastian McKenzie
20eb143915 remove Number from the list of valid runtime constructors - fixes #981 2015-03-10 03:27:13 +11:00
Sebastian McKenzie
1302a86bf2 scope -> scopable class alias key 2015-03-10 03:22:55 +11:00
Sebastian McKenzie
b7831f1d7b prepend mocha command with node 2015-03-10 03:15:31 +11:00
Sebastian McKenzie
e46cabb21f remove code coverage from travis make task 2015-03-10 03:12:50 +11:00
Sebastian McKenzie
fff06a047e Revert "delegate node path removal to after call"
This reverts commit 5e0236d9a7.
2015-03-10 02:50:43 +11:00
Sebastian McKenzie
6b0320fc83 disable test262 tests by default 2015-03-10 02:34:35 +11:00
Sebastian McKenzie
5dde63fa0a more elaborate tests for #980 2015-03-10 02:13:00 +11:00
Sebastian McKenzie
672118149a hoist all directives - fixes #980 2015-03-10 01:53:51 +11:00
Sebastian McKenzie
5e0236d9a7 delegate node path removal to after call 2015-03-10 01:44:58 +11:00
Sebastian McKenzie
5101664e7d update 4.7.4 changelog 2015-03-10 01:44:44 +11:00
Sebastian McKenzie
2d684a06d3 update changelog version to 4.7.4 2015-03-10 01:23:24 +11:00
Sebastian McKenzie
e31bad8f42 add 4.7.3 changelog 2015-03-10 01:17:14 +11:00
Sebastian McKenzie
644b4373fc rewrite named function expressions in async function transformers - fixes #979 2015-03-10 01:16:38 +11:00
Sebastian McKenzie
62f37c1e62 fix util.booleanify 2015-03-10 01:10:58 +11:00
Sebastian McKenzie
fc0e89463b use flow types for annotations - goodbye JSDoc! 2015-03-10 00:35:52 +11:00
Sebastian McKenzie
56b6a795a4 remove path.refreshScope until i'm more confident on it's functionality so it doesn't break peopls stuff 2015-03-09 23:09:22 +11:00
Sebastian McKenzie
17b34a2959 dynamic scope tracking, toot toot - fixes #957 2015-03-09 22:07:05 +11:00
Sebastian McKenzie
c4da0253c5 move flattenable keys to types 2015-03-09 16:55:00 +11:00
Sebastian McKenzie
5f2df40f6d consistent whitespace in patch 2015-03-09 16:54:50 +11:00
Sebastian McKenzie
7d20a9b882 add traversal path todos 2015-03-09 16:54:41 +11:00
Sebastian McKenzie
ee0ac9f149 use spread in messages 2015-03-09 16:54:30 +11:00
Sebastian McKenzie
c5d3f42d8a alias core-js/library in babel-runtime - closes #965 2015-03-09 16:54:19 +11:00
Sebastian McKenzie
d162919a53 update symols transformer name 2015-03-09 03:39:30 +11:00
Sebastian McKenzie
d1f712344d add istanbul auxiliary comment task to makefile 2015-03-09 03:38:39 +11:00
Sebastian McKenzie
e985912b54 add Binary node cleanup 2015-03-09 03:38:27 +11:00
Sebastian McKenzie
97a21e4a34 update spec.typeofSymbol references to es6.symbols 2015-03-09 03:38:13 +11:00
Sebastian McKenzie
d8fb7812f7 more utility.removeConsole tests 2015-03-09 03:37:42 +11:00
Sebastian McKenzie
bfe63f5885 rename spec.typeofSymbol transformer to es6.symbols 2015-03-09 03:37:26 +11:00
Sebastian McKenzie
44ca6873a3 add super to contextVariables 2015-03-09 03:37:05 +11:00
Sebastian McKenzie
2f66ea7338 4.7.3 2015-03-08 04:33:50 +11:00
Sebastian McKenzie
70967cf53c v4.7.3 2015-03-08 04:32:46 +11:00
Sebastian McKenzie
dc117a74ae both -> inline - thanks @dkieks 2015-03-08 04:29:48 +11:00
Sebastian McKenzie
b0f32a822d pass file.addImport a name instead of an identifier 2015-03-08 04:10:53 +11:00
Sebastian McKenzie
fd99ea1749 Merge branch 'master' of github.com:babel/babel 2015-03-08 04:05:44 +11:00
Sebastian McKenzie
572129542d fallback to current parentPath if none was provided 2015-03-08 04:04:48 +11:00
Sebastian McKenzie
6f53980bfc move runtime helpers to separate modules - babel/ember-cli-babel#24 2015-03-08 04:04:40 +11:00
Sebastian McKenzie
348af1990d Merge pull request #972 from neVERberleRfellerER/node-external-helpers-tests
add tests for babel-external-helpers
2015-03-08 03:50:28 +11:00
Ondrej Kraus
bd5f350728 add tests for babel-external-helpers 2015-03-07 17:46:40 +01:00
Sebastian McKenzie
958fa282f4 4.7.2 2015-03-08 03:12:09 +11:00
207 changed files with 2307 additions and 2087 deletions

View File

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

1
.gitignore vendored
View File

@@ -12,5 +12,6 @@ coverage
dist
.package.json
packages/babel-runtime/*.js
packages/babel-runtime/helpers/*.js
packages/babel-runtime/regenerator/*.js
lib

View File

@@ -1,7 +1,6 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.12"
- "iojs"

View File

@@ -13,6 +13,94 @@ _Note: Gaps between patch versions are faulty/broken releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 4.7.16
* **Bug Fix**
* Fix constructor spreading of typed arrays.
* Fix break/continue/return aliasing of non-loops in block scoping transformer.
## 4.7.15
* **Bug Fix**
* Fix constructor spreading of collections.
## 4.7.14
* **Bug Fix**
* Fix constructor spreading of `Promise`.
* **Internal**
* Deprecate remaining playground transformers and abstract references.
## 4.7.13
* **Bug Fix**
* Handle comments on use strict directives.
* Fix assignment patterns with a left side pattern.
* **Polish**
* Special case `this` when doing expression memoisation.
## 4.7.12
* **Bug Fix**
* Deprecate `playground.methodBinding`.
## 4.7.11
* **Bug Fix**
* Fix unicode regexes stripping their unicode flag before being passed on two `regexpu`.
## 4.7.10
* **Internal**
* Deprecate `playground.methodBinding` and `playground.objectGetterMemoization`.
* **Bug Fix**
* Fix `inputSourceMap` option. Thanks [@Rich-Harris](https://github.com/Rich-Harris)!
## 4.7.9
* **Polish**
* Allow `inputSourceMap` to be set to `false` to skip the source map inference.
* Infer computed literal property names.
* **Bug Fix**
* Fix nested labeled for-ofs.
* Fix block scoping `break` colliding with the parent switch case.
* **Internal**
* Upgrade `acorn-babel`.
## 4.7.8
* **Bug Fix**
* Fix computed classes not properly setting symbols.
## 4.7.7
* **Bug Fix**
* Fix `types` API exposure.
## 4.7.6
* **Bug Fix**
* Fix non-Identifier/Literal computed class methods.
* **Polish**
* Add a fallback if `stack` on an error is unconfigurable.
* Hoist `esModule` module declarations to the top of the file to handle circular dependencies better.
## 4.7.5
* **Bug Fix**
* Don't remap` break`s to call the iterator return.
* **Polish**
* Use a different helper for computed classes for much nicer output. Also fixes a bug in symbols being non-enumerable so they wouldn't be set on the class.
## 4.7.4
* **Bug Fix**
* Rewrite named function expressions in optional async function transformers.
* Hoist directives.
* Remove `Number` from the list of valid `runtime` constructors.
* **Internal**
* `spec.typeofSymbol` transformer has been renamed to `es6.symbols`.
## 4.7.2
* **New Feature**

View File

@@ -8,11 +8,14 @@ BABEL_CMD = node_modules/babel/bin/babel
export NODE_ENV = test
.PHONY: clean test test-cov test-clean test-travis test-simple test-all test-browser publish build bootstrap publish-core publish-runtime build-core watch-core
.PHONY: clean test test-cov test-clean test-travis test-simple test-all test-browser publish build bootstrap publish-core publish-runtime build-core watch-core build-core-test
build-core:
node $(BABEL_CMD) src --out-dir lib --copy-files
build-core-test:
node $(BABEL_CMD) src --out-dir lib --copy-files --auxiliary-comment "istanbul ignore next"
watch-core:
node $(BABEL_CMD) src --out-dir lib --watch --copy-files
@@ -40,26 +43,19 @@ test-clean:
rm -rf test/tmp
test:
$(MOCHA_CMD)
node $(MOCHA_CMD)
make test-clean
test-simple:
# excludes test262
export SIMPLE_BABEL_TESTS=1; \
make test
test-all:
export ALL_BABEL_TESTS=1; \
make test
test-cov:
rm -rf coverage
export SIMPLE_BABEL_TESTS=1; \
make build-core-test
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
test-travis: bootstrap build
node $(ISTANBUL_CMD) $(MOCHA_CMD) --
if test -n "$$CODECLIMATE_REPO_TOKEN"; then codeclimate < coverage/lcov.info; fi
test-travis: bootstrap build test
test-browser:
mkdir -p dist

View File

@@ -2,7 +2,7 @@
var commander = require("commander");
var util = require("../lib/babel/util");
var runtime = require("../lib/babel/build-external-helpers");
var runtime = require("../lib/babel/tools/build-external-helpers");
commander.option("-l, --whitelist [whitelist]", "Whitelist of helpers to ONLY include", util.list);
commander.option("-t, --output-type [type]", "Type of output (global|umd|var)", "global");

View File

@@ -36,16 +36,380 @@ babelArgs.forEach(function(arg){
args.unshift("--expose-gc");
break;
case "--gc-global":
case "--use_strict":
case "--es_staging":
case "--harmony":
case "--harmony-proxies":
case "--harmony-collections":
case "--harmony-generators":
case "--no-deprecation":
case "--harmony_shipping":
case "--harmony_modules":
case "--harmony_arrays":
case "--harmony_array_includes":
case "--harmony_regexps":
case "--harmony_arrow_functions":
case "--harmony_proxies":
case "--harmony_sloppy":
case "--harmony_unicode":
case "--harmony_tostring":
case "--harmony_numeric_literals":
case "--harmony_strings":
case "--harmony_scoping":
case "--harmony_classes":
case "--harmony_object_literals":
case "--harmony_templates":
case "--compiled_keyed_generic_loads":
case "--pretenuring_call_new":
case "--allocation_site_pretenuring":
case "--trace_pretenuring":
case "--trace_pretenuring_statistics":
case "--track_fields":
case "--track_double_fields":
case "--track_heap_object_fields":
case "--track_computed_fields":
case "--track_field_types":
case "--smi_binop":
case "--vector_ics":
case "--optimize_for_size":
case "--unbox_double_arrays":
case "--string_slices":
case "--crankshaft":
case "--hydrogen_filter":
case "--use_gvn":
case "--gvn_iterations":
case "--use_canonicalizing":
case "--use_inlining":
case "--use_escape_analysis":
case "--use_allocation_folding":
case "--use_local_allocation_folding":
case "--use_write_barrier_elimination":
case "--max_inlining_levels":
case "--max_inlined_source_size":
case "--max_inlined_nodes":
case "--max_inlined_nodes_cumulative":
case "--loop_invariant_code_motion":
case "--fast_math":
case "--collect_megamorphic_maps_from_stub_cache":
case "--hydrogen_stats":
case "--trace_check_elimination":
case "--trace_hydrogen":
case "--trace_hydrogen_filter":
case "--trace_hydrogen_stubs":
case "--trace_hydrogen_file":
case "--trace_phase":
case "--trace_inlining":
case "--trace_load_elimination":
case "--trace_store_elimination":
case "--trace_alloc":
case "--trace_all_uses":
case "--trace_range":
case "--trace_gvn":
case "--trace_representation":
case "--trace_removable_simulates":
case "--trace_escape_analysis":
case "--trace_allocation_folding":
case "--trace_track_allocation_sites":
case "--trace_migration":
case "--trace_generalization":
case "--stress_pointer_maps":
case "--stress_environments":
case "--deopt_every_n_times":
case "--deopt_every_n_garbage_collections":
case "--print_deopt_stress":
case "--trap_on_deopt":
case "--trap_on_stub_deopt":
case "--deoptimize_uncommon_cases":
case "--polymorphic_inlining":
case "--use_osr":
case "--array_bounds_checks_elimination":
case "--trace_bce":
case "--array_bounds_checks_hoisting":
case "--array_index_dehoisting":
case "--analyze_environment_liveness":
case "--load_elimination":
case "--check_elimination":
case "--store_elimination":
case "--dead_code_elimination":
case "--fold_constants":
case "--trace_dead_code_elimination":
case "--unreachable_code_elimination":
case "--trace_osr":
case "--stress_runs":
case "--lookup_sample_by_shared":
case "--cache_optimized_code":
case "--flush_optimized_code_cache":
case "--inline_construct":
case "--inline_arguments":
case "--inline_accessors":
case "--escape_analysis_iterations":
case "--optimize_for_in":
case "--concurrent_recompilation":
case "--job_based_recompilation":
case "--trace_concurrent_recompilation":
case "--concurrent_recompilation_queue_length":
case "--concurrent_recompilation_delay":
case "--block_concurrent_recompilation":
case "--concurrent_osr":
case "--omit_map_checks_for_leaf_maps":
case "--turbo_filter":
case "--trace_turbo":
case "--trace_turbo_graph":
case "--trace_turbo_cfg_file":
case "--trace_turbo_types":
case "--trace_turbo_scheduler":
case "--trace_turbo_reduction":
case "--trace_turbo_jt":
case "--turbo_asm":
case "--turbo_verify":
case "--turbo_stats":
case "--turbo_types":
case "--turbo_source_positions":
case "--context_specialization":
case "--turbo_deoptimization":
case "--turbo_inlining":
case "--turbo_inlining_intrinsics":
case "--trace_turbo_inlining":
case "--loop_assignment_analysis":
case "--turbo_profiling":
case "--turbo_reuse_spill_slots":
case "--turbo_delay_ssa_decon":
case "--turbo_move_optimization":
case "--turbo_jt":
case "--typed_array_max_size_in_heap":
case "--frame_count":
case "--interrupt_budget":
case "--type_info_threshold":
case "--generic_ic_threshold":
case "--self_opt_count":
case "--trace_opt_verbose":
case "--debug_code":
case "--code_comments":
case "--enable_sse3":
case "--enable_sse4_1":
case "--enable_sahf":
case "--enable_avx":
case "--enable_fma3":
case "--enable_vfp3":
case "--enable_armv7":
case "--enable_armv8":
case "--enable_neon":
case "--enable_sudiv":
case "--enable_mls":
case "--enable_movw_movt":
case "--enable_unaligned_accesses":
case "--enable_32dregs":
case "--enable_vldr_imm":
case "--force_long_branches":
case "--expose_natives_as":
case "--expose_debug_as":
case "--expose_free_buffer":
case "--expose_gc":
case "--expose_gc_as":
case "--expose_externalize_string":
case "--expose_trigger_failure":
case "--stack_trace_limit":
case "--builtins_in_stack_traces":
case "--disable_native_files":
case "--inline_new":
case "--trace_codegen":
case "--trace":
case "--mask_constants_with_cookie":
case "--lazy":
case "--trace_opt":
case "--trace_opt_stats":
case "--opt":
case "--always_opt":
case "--always_osr":
case "--prepare_always_opt":
case "--trace_deopt":
case "--trace_stub_failures":
case "--serialize_toplevel":
case "--serialize_inner":
case "--trace_serializer":
case "--min_preparse_length":
case "--max_opt_count":
case "--compilation_cache":
case "--cache_prototype_transitions":
case "--cpu_profiler_sampling_interval":
case "--trace_debug_json":
case "--trace_js_array_abuse":
case "--trace_external_array_abuse":
case "--trace_array_abuse":
case "--enable_liveedit":
case "--hard_abort":
case "--stack_size":
case "--max_stack_trace_source_length":
case "--always_inline_smi_code":
case "--min_semi_space_size":
case "--target_semi_space_size":
case "--max_semi_space_size":
case "--semi_space_growth_factor":
case "--experimental_new_space_growth_heuristic":
case "--max_old_space_size":
case "--initial_old_space_size":
case "--max_executable_size":
case "--gc_global":
case "--gc_interval":
case "--trace_gc":
case "--trace_gc_nvp":
case "--trace_gc_ignore_scavenger":
case "--trace_idle_notification":
case "--trace_idle_notification_verbose":
case "--print_cumulative_gc_stat":
case "--print_max_heap_committed":
case "--trace_gc_verbose":
case "--trace_fragmentation":
case "--collect_maps":
case "--weak_embedded_maps_in_optimized_code":
case "--weak_embedded_objects_in_optimized_code":
case "--flush_code":
case "--flush_code_incrementally":
case "--trace_code_flushing":
case "--age_code":
case "--incremental_marking":
case "--incremental_marking_steps":
case "--concurrent_sweeping":
case "--trace_incremental_marking":
case "--track_gc_object_stats":
case "--heap_profiler_trace_objects":
case "--use_idle_notification":
case "--use_ic":
case "--trace_ic":
case "--native_code_counters":
case "--always_compact":
case "--never_compact":
case "--compact_code_space":
case "--incremental_code_compaction":
case "--cleanup_code_caches_at_gc":
case "--use_marking_progress_bar":
case "--zap_code_space":
case "--random_seed":
case "--trace_weak_arrays":
case "--track_prototype_users":
case "--use_verbose_printer":
case "--allow_natives_syntax":
case "--trace_parse":
case "--trace_sim":
case "--debug_sim":
case "--check_icache":
case "--stop_sim_at":
case "--sim_stack_alignment":
case "--sim_stack_size":
case "--log_regs_modified":
case "--log_colour":
case "--ignore_asm_unimplemented_break":
case "--trace_sim_messages":
case "--stack_trace_on_illegal":
case "--abort_on_uncaught_exception":
case "--randomize_hashes":
case "--hash_seed":
case "--profile_deserialization":
case "--regexp_optimization":
case "--testing_bool_flag":
case "--testing_maybe_bool_flag":
case "--testing_int_flag":
case "--testing_float_flag":
case "--testing_string_flag":
case "--testing_prng_seed":
case "--testing_serialization_file":
case "--startup_blob":
case "--profile_hydrogen_code_stub_compilation":
case "--predictable":
case "--help":
case "--dump_counters":
case "--debugger":
case "--map_counters":
case "--js_arguments":
case "--gdbjit":
case "--gdbjit_full":
case "--gdbjit_dump":
case "--gdbjit_dump_filter":
case "--force_marking_deque_overflows":
case "--stress_compaction":
case "--log":
case "--log_all":
case "--log_api":
case "--log_code":
case "--log_gc":
case "--log_handles":
case "--log_snapshot_positions":
case "--log_suspect":
case "--prof":
case "--throw-deprecation":
case "--trace-deprecation":
case "--use-strict":
case "--prof_browser_mode":
case "--log_regexp":
case "--logfile":
case "--logfile_per_isolate":
case "--ll_prof":
case "--perf_basic_prof":
case "--perf_jit_prof":
case "--gc_fake_mmap":
case "--log_internal_timer_events":
case "--log_timer_events":
case "--log_instruction_stats":
case "--log_instruction_file":
case "--log_instruction_period":
case "--redirect_code_traces":
case "--redirect_code_traces_to":
case "--hydrogen_track_positions":
case "--trace_elements_transitions":
case "--trace_creation_allocation_sites":
case "--print_code_stubs":
case "--test_secondary_stub_cache":
case "--test_primary_stub_cache":
case "--print_code":
case "--print_opt_code":
case "--print_unopt_code":
case "--print_code_verbose":
case "--print_builtin_code":
case "--sodium":
case "--print_all_code":
case "--es5_readonly":
case "--es52_globals":
case "--harmony_typeof":
case "--harmony_collections":
case "--packed_arrays":
case "--smi_only_arrays":
case "--clever_optimizations":
case "--use_range":
case "--eliminate_dead_phis":
case "--optimize_closures":
case "--loop_weight":
case "--opt_safe_uint32_operations":
case "--parallel_recompilation":
case "--trace_parallel_recompilation":
case "--parallel_recompilation_queue_length":
case "--experimental_profiler":
case "--watch_ic_patching":
case "--self_optimization":
case "--direct_self_opt":
case "--retry_self_opt":
case "--count_based_interrupts":
case "--interrupt_at_exit":
case "--weighted_back_edges":
case "--debug_code (generate extra code":
case "--enable_sse2":
case "--enable_cmov":
case "--enable_rdtsc":
case "--enable_vfp2":
case "--enable_fpu":
case "--stack_trace_on_abort":
case "--always_full_compiler":
case "--debugger_auto_break":
case "--break_on_abort":
case "--max_new_space_size":
case "--trace_external_memory":
case "--lazy_sweeping":
case "--trace_exception":
case "--preallocate_message_memory":
case "--preemption":
case "--extra_code":
case "--remote_debugger":
case "--debugger_agent":
case "--debugger_port":
case "--debug_compile_events":
case "--debug_script_collected_events":
case "--gdbjit":
case "--log_runtime":
case "--prof_auto":
case "--prof_lazy":
case "--sliding_state_window":
args.unshift(arg);
break;

View File

@@ -1,7 +1,7 @@
{
"name": "babel",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "4.7.2",
"version": "4.7.16",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
"repository": "babel/babel",
@@ -36,7 +36,7 @@
"test": "make test"
},
"dependencies": {
"acorn-babel": "0.11.1-37",
"acorn-babel": "0.11.1-38",
"ast-types": "~0.7.0",
"chalk": "^1.0.0",
"chokidar": "^0.12.6",

View File

View File

@@ -1,7 +1,10 @@
{
"name": "babel-runtime",
"description": "babel selfContained runtime",
"version": "4.7.1",
"version": "4.7.15",
"repository": "babel/babel",
"author": "Sebastian McKenzie <sebmck@gmail.com>"
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"dependencies": {
"core-js": "^0.6.1"
}
}

View File

@@ -1,11 +1,12 @@
"use strict";
var transform = require("../lib/babel/transformation");
var buildHelpers = require("../lib/babel/build-helpers");
var util = require("../lib/babel/util");
var fs = require("fs");
var t = require("../lib/babel/types");
var _ = require("lodash");
var transform = require("../lib/babel/transformation");
var each = require("lodash/collection/each");
var File = require("../lib/babel/transformation/file");
var util = require("../lib/babel/util");
var fs = require("fs");
var t = require("../lib/babel/types");
var _ = require("lodash");
var relative = function (filename) {
return __dirname + "/babel-runtime/" + filename;
@@ -39,22 +40,26 @@ var updatePackage = function () {
var selfContainify = function (code) {
return transform(code, {
optional: ["selfContained"]
optional: ["runtime"]
}).code;
};
var buildHelpers2 = function () {
var body = util.template("self-contained-helpers-head");
var tree = t.program(body);
buildHelpers(body, t.identifier("helpers"));
var buildHelper = function (helperName) {
var tree = t.program(
util.template("self-contained-helpers-head", {
HELPER: util.template(helperName)
})
);
return transform.fromAst(tree, null, {
optional: ["selfContained"]
optional: ["runtime"]
}).code;
};
writeFile("helpers.js", buildHelpers2());
each(File.helpers, function (helperName) {
writeFile("helpers/" + helperName + ".js", buildHelper(helperName));
});
writeFile("core-js.js", readFile("core-js/library", true));
writeFile("regenerator/index.js", readFile("regenerator-babel/runtime-module", true));
writeFile("regenerator/runtime.js", selfContainify(readFile("regenerator-babel/runtime")));

View File

@@ -9,10 +9,12 @@ export { canCompile } from "../util";
export { default as acorn } from "acorn-babel";
export { default as transform } from "../transformation";
export { default as traverse } from "../traversal";
export { default as buildExternalHelpers } from "../build-external-helpers";
export { default as types } from "../types";
export { default as buildExternalHelpers } from "../tools/build-external-helpers";
export { version } from "../../../package";
import * as t from "../types";
export { t as types };
export function register(opts) {
var callback = require("./register/node");
if (opts != null) callback(opts);

View File

@@ -46,7 +46,7 @@ var compile = function (filename) {
var opts = extend({}, transformOpts);
resolveRc(filename, opts);
var cacheKey = `${filename}:${JSON.stringify(opts)}`;
var cacheKey = `${filename}:${JSON.stringify(opts)}:${babel.version}`;
if (cache) {
var cached = cache[cacheKey];

View File

@@ -1,15 +0,0 @@
import File from "./transformation/file";
import * as util from "./util";
import each from "lodash/collection/each";
import t from "./types";
export default function (body, namespace, whitelist = []) {
each(File.helpers, function (name) {
if (whitelist.length && whitelist.indexOf(name) === -1) return;
var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
));
});
};

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
import isInteger from "is-integer";
import isNumber from "lodash/lang/isNumber";
import t from "../../types";
import * as t from "../../types";
export function UnaryExpression(node, print) {
var hasSpace = /[a-z]$/.test(node.operator);

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
export function AnyTypeAnnotation() {
this.push("any");

View File

@@ -1,5 +1,5 @@
import each from "lodash/collection/each";
import t from "../../types";
import * as t from "../../types";
export function JSXAttribute(node, print) {
print(node.name);

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
export function _params(node, print) {
print(node.typeParameters);

View File

@@ -1,5 +1,5 @@
import each from "lodash/collection/each";
import t from "../../types";
import * as t from "../../types";
export function ImportSpecifier(node, print) {
if (t.isSpecifierDefault(node)) {

View File

@@ -1,5 +1,5 @@
import repeating from "repeating";
import t from "../../types";
import * as t from "../../types";
export function WithStatement(node, print) {
this.keyword("with");

View File

@@ -8,7 +8,7 @@ import Buffer from "./buffer";
import extend from "lodash/object/extend";
import each from "lodash/collection/each";
import n from "./node";
import t from "../types";
import * as t from "../types";
class CodeGenerator {
constructor(ast, opts, code) {

View File

@@ -2,7 +2,7 @@ import whitespace from "./whitespace";
import * as parens from "./parentheses";
import each from "lodash/collection/each";
import some from "lodash/collection/some";
import t from "../../types";
import * as t from "../../types";
var find = function (obj, node, parent) {
if (!obj) return;

View File

@@ -1,5 +1,5 @@
import each from "lodash/collection/each";
import t from "../../types";
import * as t from "../../types";
var PRECEDENCE = {};

View File

@@ -1,7 +1,7 @@
import isBoolean from "lodash/lang/isBoolean";
import each from "lodash/collection/each";
import map from "lodash/collection/map";
import t from "../../types";
import * as t from "../../types";
function crawl(node, state = {}) {
if (t.isMemberExpression(node)) {

View File

@@ -1,5 +1,5 @@
import sourceMap from "source-map";
import t from "../types";
import * as t from "../types";
export default class SourceMap {
constructor(position, opts, code) {

View File

@@ -1,4 +1,4 @@
import t from "../types";
import * as t from "../types";
export default function (ast, comments, tokens) {
if (ast && ast.type === "Program") {

View File

@@ -40,7 +40,15 @@ export default function (opts, code, callback) {
message += frame;
}
if (err.stack) err.stack = err.stack.replace(err.message, message);
if (err.stack) {
var newStack = err.stack.replace(err.message, message);
try {
err.stack = newStack;
} catch (e) {
// `err.stack` may be a readonly property in some environments
}
}
err.message = message;
}

View File

@@ -24,14 +24,10 @@ export var messages = {
unsupportedOutputType: "Unsupported output type $1"
};
export function get(key) {
export function get(key: String, ...args) {
var msg = messages[key];
if (!msg) throw new ReferenceError(`Unknown message ${JSON.stringify(key)}`);
var args = [];
for (var i = 1; i < arguments.length; i++) {
args.push(arguments[i]);
}
args = parseArgs(args);
return msg.replace(/\$(\d+)/g, function (str, i) {
@@ -39,7 +35,7 @@ export function get(key) {
});
}
export function parseArgs(args) {
export function parseArgs(args: Array<any>) {
return args.map(function (val) {
if (val != null && val.inspect) {
return val.inspect();

View File

@@ -1,7 +1,7 @@
import estraverse from "estraverse";
import extend from "lodash/object/extend";
import types from "ast-types";
import t from "./types";
import * as t from "./types";
// estraverse
@@ -9,8 +9,8 @@ extend(estraverse.VisitorKeys, t.VISITOR_KEYS);
// regenerator-babel/ast-types
var def = types.Type.def;
var or = types.Type.or;
var def = types.Type.def;
var or = types.Type.or;
def("File")
.bases("Node")

View File

@@ -1,8 +1,9 @@
import buildHelpers from "./build-helpers";
import generator from "./generation";
import * as messages from "./messages";
import * as util from "./util";
import t from "./types";
import generator from "../generation";
import * as messages from "../messages";
import * as util from "../util";
import File from "../transformation/file";
import each from "lodash/collection/each";
import * as t from "../types";
function buildGlobal(namespace, builder) {
var body = [];
@@ -49,8 +50,20 @@ function buildVar(namespace, builder) {
return t.program(body);
}
function buildHelpers(body, namespace, whitelist = []) {
each(File.helpers, function (name) {
if (whitelist.length && whitelist.indexOf(name) === -1) return;
var key = t.identifier(t.toIdentifier(name));
body.push(t.expressionStatement(
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
));
});
}
export default function (whitelist, outputType = "global") {
var namespace = t.identifier("babelHelpers");
var builder = function (body) {
return buildHelpers(body, namespace, whitelist);
};

View File

@@ -7,13 +7,14 @@ import generate from "../generation";
import defaults from "lodash/object/defaults";
import includes from "lodash/collection/includes";
import assign from "lodash/object/assign";
import Logger from "./logger";
import parse from "../helpers/parse";
import Scope from "../traversal/scope";
import slash from "slash";
import * as util from "../util";
import path from "path";
import each from "lodash/collection/each";
import t from "../types";
import * as t from "../types";
var checkTransformerVisitor = {
enter(node, parent, scope, state) {
@@ -23,7 +24,7 @@ var checkTransformerVisitor = {
function checkNode(stack, node, scope) {
each(stack, function (pass) {
if (pass.shouldRun) return;
if (pass.shouldRun || pass.ran) return;
pass.checkNode(node, scope);
});
}
@@ -41,6 +42,7 @@ export default class File {
this.lastStatements = [];
this.opts = this.normalizeOptions(opts);
this.log = new Logger(this);
this.ast = {};
this.buildTransformers();
@@ -50,6 +52,7 @@ export default class File {
"inherits",
"defaults",
"create-class",
"create-computed-class",
"apply-constructor",
"tagged-template-literal",
"tagged-template-literal-loose",
@@ -121,7 +124,7 @@ export default class File {
"accept"
];
normalizeOptions(opts) {
normalizeOptions(opts: Object) {
opts = assign({}, opts);
for (var key in opts) {
@@ -136,7 +139,7 @@ export default class File {
returnUsedHelpers: false,
externalHelpers: false,
auxilaryComment: "",
inputSourceMap: false,
inputSourceMap: null,
experimental: false,
reactCompat: false,
playground: false,
@@ -227,7 +230,7 @@ export default class File {
return opts;
};
isLoose(key) {
isLoose(key: string) {
return includes(this.opts.loose, key);
}
@@ -259,13 +262,7 @@ export default class File {
this.transformers = transformers;
}
debug(msg) {
var parts = this.opts.filename;
if (msg) parts += `: ${msg}`;
util.debug(parts);
}
getModuleFormatter(type) {
getModuleFormatter(type: string) {
var ModuleFormatter = isFunction(type) ? type : transform.moduleFormatters[type];
if (!ModuleFormatter) {
@@ -280,19 +277,21 @@ export default class File {
return new ModuleFormatter(this);
}
parseInputSourceMap(code) {
parseInputSourceMap(code: string) {
var opts = this.opts;
var inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
opts.inputSourceMap = inputMap.toObject();
code = convertSourceMap.removeComments(code);
if (opts.inputSourceMap !== false) {
var inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
opts.inputSourceMap = inputMap.toObject();
code = convertSourceMap.removeComments(code);
}
}
return code;
}
parseShebang(code) {
parseShebang(code: string) {
var shebangMatch = shebangRegex.exec(code);
if (shebangMatch) {
@@ -305,15 +304,15 @@ export default class File {
return code;
}
set(key, val) {
set(key: string, val): any {
return this.data[key] = val;
};
setDynamic(key, fn) {
setDynamic(key: string, fn: Function) {
this.dynamicData[key] = fn;
}
get(key) {
get(key: string): any {
var data = this.data[key];
if (data) {
return data;
@@ -325,7 +324,7 @@ export default class File {
}
}
addImport(source, name, noDefault) {
addImport(source: string, name?: string, noDefault?: boolean): Object {
name ||= source;
var id = this.dynamicImportIds[name];
@@ -349,11 +348,11 @@ export default class File {
return id;
}
isConsequenceExpressionStatement(node) {
isConsequenceExpressionStatement(node: Object): boolean {
return t.isExpressionStatement(node) && this.lastStatements.indexOf(node) >= 0;
}
attachAuxiliaryComment(node) {
attachAuxiliaryComment(node: Object): Object {
var comment = this.opts.auxiliaryComment;
if (comment) {
node.leadingComments ||= [];
@@ -365,7 +364,7 @@ export default class File {
return node;
}
addHelper(name) {
addHelper(name: string): Object {
if (!includes(File.helpers, name)) {
throw new ReferenceError(`Unknown helper ${name}`);
}
@@ -377,10 +376,13 @@ export default class File {
this.usedHelpers[name] = true;
var generator = this.get("helperGenerator");
var runtime = this.get("helpersNamespace");
if (runtime) {
name = t.identifier(t.toIdentifier(name));
return t.memberExpression(runtime, name);
if (generator) {
return generator(name);
} else if (runtime) {
var id = t.identifier(t.toIdentifier(name));
return t.memberExpression(runtime, id);
} else {
var ref = util.template(name);
ref._compact = true;
@@ -394,10 +396,6 @@ export default class File {
}
}
logDeopt() {
// todo, (node, msg)
}
errorWithNode(node, msg, Error = SyntaxError) {
var loc = node.loc.start;
var err = new Error(`Line ${loc.line}: ${msg}`);
@@ -405,14 +403,14 @@ export default class File {
return err;
}
addCode(code) {
addCode(code: string) {
code = (code || "") + "";
code = this.parseInputSourceMap(code);
this.code = code;
return this.parseShebang(code);
}
parse(code) {
parse(code: string) {
code = this.addCode(code);
var opts = this.opts;
@@ -427,7 +425,7 @@ export default class File {
}
transform(ast) {
this.debug();
this.log.debug();
this.ast = ast;
this.lastStatements = t.getLastStatements(ast.program);
@@ -449,7 +447,7 @@ export default class File {
this.call("post");
}
call(key) {
call(key: string) {
var stack = this.transformerStack;
for (var i = 0; i < stack.length; i++) {
var transformer = stack[i].transformer;
@@ -477,7 +475,7 @@ export default class File {
});
}
mergeSourceMap(map) {
mergeSourceMap(map: Object) {
var opts = this.opts;
var inputMap = opts.inputSourceMap;
@@ -499,7 +497,11 @@ export default class File {
return map;
}
generate() {
generate(): {
code: string;
map?: Object;
ast?: Object;
} {
var opts = this.opts;
var ast = this.ast;
@@ -531,7 +533,7 @@ export default class File {
result.code += "\n" + convertSourceMap.fromObject(result.map).toComment();
}
if (opts.sourceMap === "both") {
if (opts.sourceMap === "inline") {
result.map = null;
}

View File

@@ -1,5 +1,5 @@
import explode from "./explode-assignable-expression";
import t from "../../types";
import * as t from "../../types";
export default function (exports, opts) {
var isAssignment = function (node) {

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
export default function build(node, buildBody) {
var self = node.blocks.shift();

View File

@@ -1,5 +1,5 @@
import explode from "./explode-assignable-expression";
import t from "../../types";
import * as t from "../../types";
export default function (exports, opts) {
var buildAssignment = function (left, right) {

View File

@@ -7,7 +7,7 @@ import isString from "lodash/lang/isString";
import * as messages from "../../messages";
import esutils from "esutils";
import * as react from "./react";
import t from "../../types";
import * as t from "../../types";
export default function (exports, opts) {
exports.check = function (node) {

View File

@@ -2,36 +2,43 @@ import cloneDeep from "lodash/lang/cloneDeep";
import traverse from "../../traversal";
import each from "lodash/collection/each";
import has from "lodash/object/has";
import t from "../../types";
import * as t from "../../types";
export function push(mutatorMap, key, kind, computed, value) {
var alias;
var alias = t.toKeyAlias({ computed }, key);
if (t.isIdentifier(key)) {
alias = key.name;
if (computed) alias = `computed:${alias}`;
} else if (t.isLiteral(key)) {
alias = String(key.value);
} else {
alias = JSON.stringify(traverse.removeProperties(t.cloneDeep(key)));
}
var map;
if (has(mutatorMap, alias)) {
map = mutatorMap[alias];
} else {
map = {};
}
var map = {};
if (has(mutatorMap, alias)) map = mutatorMap[alias];
mutatorMap[alias] = map;
map._key = key;
if (computed) {
map._computed = true;
}
if (computed) map._computed = true;
map[kind] = value;
}
export function hasComputed(mutatorMap) {
for (var key in mutatorMap) {
if (mutatorMap[key]._computed) {
return true;
}
}
return false;
}
export function toComputedObjectFromClass(obj) {
var objExpr = t.arrayExpression([]);
for (var i = 0; i < obj.properties.length; i++) {
var prop = obj.properties[i];
var val = prop.value;
val.properties.unshift(t.property("init", t.identifier("key"), t.toComputedKey(prop)));
objExpr.elements.push(val);
}
return objExpr;
}
export function toClassObject(mutatorMap) {
var objExpr = t.objectExpression([]);
@@ -49,6 +56,7 @@ export function toClassObject(mutatorMap) {
var prop = t.property("init", t.identifier(key), node);
t.inheritsComments(prop, inheritNode);
t.removeComments(inheritNode);
mapNode.properties.push(prop);
});
@@ -59,35 +67,11 @@ export function toClassObject(mutatorMap) {
}
export function toDefineObject(mutatorMap) {
var objExpr = t.objectExpression([]);
each(mutatorMap, function (map) {
var mapNode = t.objectExpression([]);
var propNode = t.property("init", map._key, mapNode, map._computed);
if (map.value) {
map.writable = t.literal(true);
}
if (map.value) map.writable = t.literal(true);
map.configurable = t.literal(true);
map.enumerable = t.literal(true);
each(map, function (node, key) {
if (key[0] === "_") return;
node = t.clone(node);
var inheritNode = node;
if (t.isMethodDefinition(node)) node = node.value;
var prop = t.property("init", t.identifier(key), node);
t.inheritsComments(prop, inheritNode);
t.removeComments(inheritNode);
mapNode.properties.push(prop);
});
objExpr.properties.push(propNode);
});
return objExpr;
return toClassObject(mutatorMap);
}

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
var getObjRef = function (node, nodes, file, scope) {
var ref;

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
export default function (node) {
var lastNonDefault = 0;

View File

@@ -1,6 +1,6 @@
import getFunctionArity from "./get-function-arity";
import * as util from "../../util";
import t from "../../types";
import * as t from "../../types";
var visitor = {
enter(node, parent, scope, state) {
@@ -111,7 +111,7 @@ export function bare(node, parent, scope) {
if (node.id) return node;
var id;
if (t.isProperty(parent) && parent.kind === "init" && !parent.computed) {
if (t.isProperty(parent) && parent.kind === "init" && (!parent.computed || t.isLiteral(parent.key))) {
// { foo() {} };
id = parent.key;
} else if (t.isVariableDeclarator(parent)) {
@@ -121,9 +121,16 @@ export function bare(node, parent, scope) {
return node;
}
if (!t.isIdentifier(id)) return node;
var name;
if (t.isLiteral(id)) {
name = id.value;
} else if (t.isIdentifier(id)) {
name = id.name;
} else {
return;
}
var name = t.toIdentifier(id.name);
name = t.toIdentifier(name);
id = t.identifier(name);
var state = visit(node, name, scope);

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
var isCreateClassCallExpression = t.buildMatchMemberExpression("React.createClass");

View File

@@ -1,5 +1,5 @@
import pull from "lodash/array/pull";
import t from "../../types";
import * as t from "../../types";
export function is(node, flag) {
return t.isLiteral(node) && node.regex && node.regex.flags.indexOf(flag) >= 0;
@@ -7,7 +7,7 @@ export function is(node, flag) {
export function pullFlag(node, flag) {
var flags = node.regex.flags.split("");
if (node.regex.flags.indexOf("u") < 0) return;
pull(flags, "u");
if (node.regex.flags.indexOf(flag) < 0) return;
pull(flags, flag);
node.regex.flags = flags.join("");
}

View File

@@ -1,7 +1,7 @@
import t from "../../types";
import * as t from "../../types";
var visitor = {
enter(node) {
var awaitVisitor = {
enter(node, parent, scope, state) {
if (t.isFunction(node)) this.skip();
if (t.isAwaitExpression(node)) {
@@ -16,13 +16,23 @@ var visitor = {
}
};
var referenceVisitor = {
enter(node, parent, scope, state) {
var name = state.id.name;
if (t.isReferencedIdentifier(node, parent, { name: name }) && scope.bindingIdentifierEquals(name, state.id)) {
return state.ref ||= scope.generateUidIdentifier(name);
}
}
};
export default function (node, callId, scope) {
node.async = false;
node.generator = true;
scope.traverse(node, visitor);
scope.traverse(node, awaitVisitor, state);
var call = t.callExpression(callId, [node]);
var id = node.id;
node.id = null;
@@ -33,6 +43,16 @@ export default function (node, callId, scope) {
declar._blockHoist = true;
return declar;
} else {
if (id) {
var state = { id: id };
scope.traverse(node, referenceVisitor, state);
if (state.ref) {
scope.parent.push({ id: state.ref });
return t.assignmentExpression("=", state.ref, call);
}
}
return call;
}
};

View File

@@ -1,7 +1,7 @@
module.exports = ReplaceSupers;
import * as messages from "../../messages";
import t from "../../types";
import * as t from "../../types";
function isIllegalBareSuper(node, parent) {
@@ -47,12 +47,9 @@ export default class ReplaceSupers {
/**
* Description
*
* @param {Object} opts
* @param {Boolean} [inClass]
*/
constructor(opts, inClass) {
constructor(opts: Object, inClass?: boolean = false) {
this.topLevelThisReference = opts.topLevelThisReference;
this.methodNode = opts.methodNode;
this.superRef = opts.superRef;
@@ -76,15 +73,9 @@ export default class ReplaceSupers {
*
* _set(Object.getPrototypeOf(CLASS.prototype), "METHOD", "VALUE", this)
*
* @param {Node} property
* @param {Node} value
* @param {Boolean} isComputed
* @param {Node} thisExpression
*
* @returns {Node}
*/
setSuperProperty(property, value, isComputed, thisExpression) {
setSuperProperty(property: Object, value: Object, isComputed: boolean, thisExpression: Object): Object {
return t.callExpression(
this.file.addHelper("set"),
[
@@ -108,14 +99,9 @@ export default class ReplaceSupers {
*
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
* @param {Node} property
* @param {Boolean} isComputed
* @param {Node} thisExpression
*
* @returns {Node}
*/
getSuperProperty(property, isComputed, thisExpression) {
getSuperProperty(property: Object, isComputed: boolean, thisExpression: Object): Object {
return t.callExpression(
this.file.addHelper("get"),
[
@@ -141,12 +127,9 @@ export default class ReplaceSupers {
/**
* Description
*
* @param {Object} node
* @param {Boolean} topLevel
*/
traverseLevel(node, topLevel) {
traverseLevel(node: Object, topLevel: boolean) {
var state = { self: this, topLevel: topLevel };
this.scope.traverse(node, visitor, state);
}
@@ -169,14 +152,9 @@ export default class ReplaceSupers {
/**
* Description
*
* @param {Object} node
* @param {Object} id
* @param {Object} parent
* @returns {Object}
*/
getLooseSuperProperty(id, parent) {
getLooseSuperProperty(id: Object, parent: Object) {
var methodNode = this.methodNode;
var methodName = methodNode.key;
var superRef = this.superRef || t.identifier("Function");
@@ -211,13 +189,9 @@ export default class ReplaceSupers {
/**
* Description
*
* @param {Function} getThisReference
* @param {Object} node
* @param {Object} parent
*/
looseHandle(getThisReference, node, parent) {
looseHandle(getThisReference: Function, node: Object, parent: Object) {
if (t.isIdentifier(node, { name: "super" })) {
this.hasSuper = true;
return this.getLooseSuperProperty(node, parent);
@@ -235,13 +209,9 @@ export default class ReplaceSupers {
/**
* Description
*
* @param {Function} getThisReference
* @param {Object} node
* @param {Object} parent
*/
specHandle(getThisReference, node, parent) {
specHandle(getThisReference: Function, node: Object, parent: Object) {
var methodNode = this.methodNode;
var property;
var computed;

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
export function has(node) {
var first = node.body[0];

View File

@@ -4,7 +4,7 @@ import object from "../helpers/object";
import File from "./file";
import each from "lodash/collection/each";
export default function transform(code, opts) {
export default function transform(code: code, opts?: Object) {
var file = new File(opts);
return file.parse(code);
}
@@ -18,7 +18,7 @@ transform.fromAst = function (ast, code, opts) {
return file.generate();
};
transform._ensureTransformerNames = function (type, rawKeys) {
transform._ensureTransformerNames = function (type: string, rawKeys: Array<string>) {
var keys = [];
for (var i = 0; i < rawKeys.length; i++) {

View File

@@ -0,0 +1,22 @@
import * as util from "../util";
export default class Logger {
constructor(file: File) {
this.filename = file.opts.filename;
this.file = file;
}
_buildMessage(msg: string): string {
var parts = this.filename;
if (msg) parts += `: ${msg}`;
return parts;
}
debug(msg: string) {
util.debug(this._buildMessage(msg));
}
deopt(node: Object, msg: string) {
util.debug(this._buildMessage(msg));
}
}

View File

@@ -2,7 +2,7 @@ import * as messages from "../../messages";
import extend from "lodash/object/extend";
import object from "../../helpers/object";
import * as util from "../../util";
import t from "../../types";
import * as t from "../../types";
var remapVisitor = {
enter(node, parent, scope, formatter) {

View File

@@ -3,7 +3,7 @@ import CommonFormatter from "./common";
import includes from "lodash/collection/includes";
import values from "lodash/object/values";
import * as util from "../../util";
import t from "../../types";
import * as t from "../../types";
export default class AMDFormatter extends DefaultFormatter {
init = CommonFormatter.prototype.init;

View File

@@ -1,7 +1,7 @@
import DefaultFormatter from "./_default";
import includes from "lodash/collection/includes";
import * as util from "../../util";
import t from "../../types";
import * as t from "../../types";
export default class CommonJSFormatter extends DefaultFormatter {
init() {
@@ -13,7 +13,7 @@ export default class CommonJSFormatter extends DefaultFormatter {
if (!this.noInteropRequireImport && this.hasNonDefaultExports) {
var templateName = "exports-module-declaration";
if (this.file.isLoose("es6.modules")) templateName += "-loose";
file.ast.program.body.push(util.template(templateName, true));
file.ast.program.body.unshift(util.template(templateName, true));
}
};

View File

@@ -1,4 +1,4 @@
import t from "../../types";
import * as t from "../../types";
export default class IgnoreFormatter {
exportDeclaration(node, nodes) {

View File

@@ -4,7 +4,7 @@ import * as util from "../../util";
import last from "lodash/array/last";
import each from "lodash/collection/each";
import map from "lodash/collection/map";
import t from "../../types";
import * as t from "../../types";
var hoistVariablesVisitor = {
enter(node, parent, scope, hoistDeclarators) {

View File

@@ -1,7 +1,7 @@
import AMDFormatter from "./amd";
import values from "lodash/object/values";
import * as util from "../../util";
import t from "../../types";
import * as t from "../../types";
export default class UMDFormatter extends AMDFormatter {
transform(program) {

View File

@@ -0,0 +1,16 @@
(function() {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i ++) {
var prop = props[i];
prop.configurable = true;
if (prop.value) prop.writable = true;
Object.defineProperty(target, prop.key, prop);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
})()

View File

@@ -1,2 +1,2 @@
var helpers = exports.default = {};
exports.default = HELPER;
exports.__esModule = true;

View File

@@ -6,14 +6,15 @@ import includes from "lodash/collection/includes";
*/
export default class TransformerPass {
constructor(file, transformer) {
constructor(file: File, transformer: Transformer) {
this.transformer = transformer;
this.shouldRun = !transformer.check;
this.handlers = transformer.handlers;
this.file = file;
this.ran = false;
}
canRun() {
canRun(): boolean {
var transformer = this.transformer;
var opts = this.file.opts;
@@ -42,7 +43,7 @@ export default class TransformerPass {
return true;
}
checkNode(node) {
checkNode(node: Object): boolean {
var check = this.transformer.check;
if (check) {
return this.shouldRun = check(node);
@@ -56,8 +57,10 @@ export default class TransformerPass {
var file = this.file;
file.debug(`Running transformer ${this.transformer.key}`);
file.log.debug(`Running transformer ${this.transformer.key}`);
file.scope.traverse(file.ast, this.handlers, file);
this.ran = true;
}
}

View File

@@ -12,7 +12,7 @@ import each from "lodash/collection/each";
*/
export default class Transformer {
constructor(transformerKey, transformer, opts) {
constructor(transformerKey: key, transformer: Object, opts: Object) {
transformer = assign({}, transformer);
var take = function (key) {
@@ -36,7 +36,7 @@ export default class Transformer {
this.key = transformerKey;
}
normalize(transformer) {
normalize(transformer: Object): Object {
if (isFunction(transformer)) {
transformer = { ast: transformer };
}
@@ -65,7 +65,7 @@ export default class Transformer {
return transformer;
}
buildPass(file) {
buildPass(file: File): TransformerPass {
return new TransformerPass(file, this);
}
}

View File

@@ -1,6 +1,7 @@
{
"selfContained": "runtime",
"unicode-regex": "regex.unicode",
"spec.typeofSymbol": "es6.symbols",
"minification.deadCodeElimination": "utility.deadCodeElimination",
"minification.removeConsoleCalls": "utility.removeConsole",

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export function MemberExpression(node) {
var prop = node.property;

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export function Property(node) {
var key = node.key;

View File

@@ -1,5 +1,5 @@
import * as defineMap from "../../helpers/define-map";
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isProperty(node) && (node.kind === "get" || node.kind === "set");

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export var check = t.isArrowFunctionExpression;

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
var visitor = {
enter(node, parent, scope, state) {

View File

@@ -1,7 +1,7 @@
import traverse from "../../../traversal";
import object from "../../../helpers/object";
import * as util from "../../../util";
import t from "../../../types";
import * as t from "../../../types";
import values from "lodash/object/values";
import extend from "lodash/object/extend";
@@ -69,13 +69,14 @@ export function Loop(node, parent, scope, file) {
t.ensureBlock(node);
node.body._letDeclarators = [init];
}
var blockScoping = new BlockScoping(node, node.body, parent, scope, file);
blockScoping.run();
var blockScoping = new BlockScoping(this, node.body, parent, scope, file);
return blockScoping.run();
}
export function BlockStatement(block, parent, scope, file) {
if (!t.isLoop(parent)) {
var blockScoping = new BlockScoping(false, block, parent, scope, file);
var blockScoping = new BlockScoping(null, block, parent, scope, file);
blockScoping.run();
}
}
@@ -222,25 +223,24 @@ class BlockScoping {
/**
* Description
*
* @param {Boolean|Node} loopParent
* @param {Node} block
* @param {Node} parent
* @param {Scope} scope
* @param {File} file
*/
constructor(loopParent, block, parent, scope, file) {
this.loopParent = loopParent;
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
constructor(loopPath?: TraversalPath, block: Object, parent: Object, scope: Scope, file: File) {
this.parent = parent;
this.scope = scope;
this.block = block;
this.file = file;
this.outsideLetReferences = object();
this.hasLetReferences = false;
this.letReferences = block._letReferences = object();
this.body = [];
if (loopPath) {
this.loopParent = loopPath.parent;
this.loopLabel = t.isLabeledStatement(this.loopParent) && this.loopParent.label;
this.loop = loopPath.node;
}
}
/**
@@ -265,6 +265,10 @@ class BlockScoping {
} else {
this.remap();
}
if (this.loopLabel && !t.isLabeledStatement(this.loopParent)) {
return t.labeledStatement(this.loopLabel, this.loop);
}
}
/**
@@ -303,11 +307,11 @@ class BlockScoping {
//
var loopParent = this.loopParent;
if (loopParent) {
traverseReplace(loopParent.right, loopParent, scope, remaps);
traverseReplace(loopParent.test, loopParent, scope, remaps);
traverseReplace(loopParent.update, loopParent, scope, remaps);
var loop = this.loop;
if (loop) {
traverseReplace(loop.right, loop, scope, remaps);
traverseReplace(loop.test, loop, scope, remaps);
traverseReplace(loop.update, loop, scope, remaps);
}
scope.traverse(this.block, replaceVisitor, remaps);
@@ -323,7 +327,7 @@ class BlockScoping {
var outsideRefs = this.outsideLetReferences;
// remap loop heads with colliding variables
if (this.loopParent) {
if (this.loop) {
for (var name in outsideRefs) {
var id = outsideRefs[name];
@@ -444,7 +448,7 @@ class BlockScoping {
ignoreLabeless: false,
innerLabels: [],
hasReturn: false,
isLoop: !!this.loopParent,
isLoop: !!this.loop,
map: {}
};
@@ -466,12 +470,9 @@ class BlockScoping {
/**
* Turn a `VariableDeclaration` into an array of `AssignmentExpressions` with
* their declarations hoisted to before the closure wrapper.
*
* @param {Node} node VariableDeclaration
* @returns {Array}
*/
pushDeclar(node) {
pushDeclar(node: { type: "VariableDeclaration" }): Array<Object> {
this.body.push(t.variableDeclaration(node.kind, node.declarations.map(function (declar) {
return t.variableDeclarator(declar.id);
})));
@@ -491,12 +492,9 @@ class BlockScoping {
/**
* Push the closure to the body.
*
* @param {Node} ret Identifier
* @param {Node} call CallExpression
*/
build(ret, call) {
build(ret: { type: "Identifier" }, call: { type: "CallExpression" }) {
var has = this.has;
if (has.hasReturn || has.hasBreakContinue) {
this.buildHas(ret, call);
@@ -507,19 +505,16 @@ class BlockScoping {
/**
* Description
*
* @param {Node} ret Identifier
* @param {Node} call CallExpression
*/
buildHas(ret, call) {
buildHas(ret: { type: "Identifier" }, call: { type: "CallExpression" }) {
var body = this.body;
body.push(t.variableDeclaration("var", [
t.variableDeclarator(ret, call)
]));
var loopParent = this.loopParent;
var loop = this.loop;
var retCheck;
var has = this.has;
var cases = [];
@@ -532,11 +527,6 @@ class BlockScoping {
}
if (has.hasBreakContinue) {
if (!loopParent) {
throw new Error("Has no loop parent but we're trying to reassign breaks " +
"and continues, something is going wrong here.");
}
for (var key in has.map) {
cases.push(t.switchCase(t.literal(key), [has.map[key]]));
}
@@ -552,6 +542,14 @@ class BlockScoping {
single.consequent[0]
)));
} else {
// #998
for (var i = 0; i < cases.length; i++) {
var caseConsequent = cases[i].consequent[0];
if (t.isBreakStatement(caseConsequent) && !caseConsequent.label) {
caseConsequent.label = this.loopLabel ||= this.file.scope.generateUidIdentifier("loop");
}
}
body.push(this.file.attachAuxiliaryComment(t.switchStatement(ret, cases)));
}
} else {

View File

@@ -4,7 +4,7 @@ import * as defineMap from "../../helpers/define-map";
import * as messages from "../../../messages";
import * as util from "../../../util";
import traverse from "../../../traversal";
import t from "../../../types";
import * as t from "../../../types";
export var check = t.isClass;
@@ -56,14 +56,9 @@ class ClassTransformer {
/**
* Description
*
* @param {Node} node
* @param {Node} parent
* @param {Scope} scope
* @param {File} file
*/
constructor(node, parent, scope, file) {
constructor(node: Object, parent: Object, scope: Scope, file: File) {
this.parent = parent;
this.scope = scope;
this.node = node;
@@ -222,6 +217,7 @@ class ClassTransformer {
var instanceProps;
var staticProps;
var classHelper = "create-class";
if (this.hasInstanceMutators) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
@@ -232,24 +228,28 @@ class ClassTransformer {
}
if (instanceProps || staticProps) {
if (defineMap.hasComputed(this.instanceMutatorMap) || defineMap.hasComputed(this.staticMutatorMap)) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
classHelper = "create-computed-class";
}
instanceProps ||= t.literal(null);
var args = [this.classRef, instanceProps];
if (staticProps) args.push(staticProps);
body.push(t.expressionStatement(
t.callExpression(this.file.addHelper("create-class"), args)
t.callExpression(this.file.addHelper(classHelper), args)
));
}
}
/**
* Description
*
* @param {Node} node
*/
verifyConstructor(node) {
verifyConstructor(node: Object) {
return; // enable this for the next major
var state = {
@@ -267,11 +267,9 @@ class ClassTransformer {
/**
* Push a method to its respective mutatorMap.
*
* @param {Node} node MethodDefinition
*/
pushMethod(node) {
pushMethod(node: { type: "MethodDefinition" }) {
var methodName = node.key;
var kind = node.kind;
@@ -308,11 +306,9 @@ class ClassTransformer {
/**
* Description
*
* @param {Node} node
*/
pushProperty(node) {
pushProperty(node: Object) {
if (!node.value) return;
var key;
@@ -332,11 +328,9 @@ class ClassTransformer {
/**
* Replace the constructor body of our class.
*
* @param {Node} method MethodDefinition
*/
pushConstructor(method) {
pushConstructor(method: { type: "MethodDefinition" }) {
if (method.kind) {
throw this.file.errorWithNode(method, messages.get("classesIllegalConstructorKind"));
}

View File

@@ -1,5 +1,5 @@
import * as messages from "../../../messages";
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isVariableDeclaration(node, { kind: "const" });

View File

@@ -1,5 +1,5 @@
import * as messages from "../../../messages";
import t from "../../../types";
import * as t from "../../../types";
export var check = t.isPattern;
@@ -135,10 +135,7 @@ export function AssignmentExpression(node, parent, scope, file) {
if (!t.isPattern(node.left)) return;
var ref = scope.generateUidIdentifier("temp");
scope.push({
key: ref.name,
id: ref
});
scope.push({ id: ref });
var nodes = [];
nodes.push(t.assignmentExpression("=", ref, node.right));
@@ -293,14 +290,21 @@ class DestructuringTransformer {
//
this.nodes.push(this.buildVariableAssignment(
pattern.left,
t.conditionalExpression(
t.binaryExpression("===", tempValueRef, t.identifier("undefined")),
pattern.right,
tempValueRef
)
));
var tempConditional = t.conditionalExpression(
t.binaryExpression("===", tempValueRef, t.identifier("undefined")),
pattern.right,
tempValueRef
);
var left = pattern.left;
if (t.isPattern(left)) {
this.nodes.push(t.expressionStatement(
t.assignmentExpression("=", tempValueRef, tempConditional)
));
this.push(left, tempValueRef);
} else {
this.nodes.push(this.buildVariableAssignment(left, tempConditional));
}
}
pushObjectSpread(pattern, objRef, spreadProp, spreadPropIndex) {

View File

@@ -1,6 +1,6 @@
import * as messages from "../../../messages";
import * as util from "../../../util";
import t from "../../../types";
import * as t from "../../../types";
export var check = t.isForOfStatement;
@@ -32,40 +32,10 @@ export function ForOfStatement(node, parent, scope, file) {
// todo: find out why this is necessary? #538
loop._scopeInfo = node._scopeInfo;
if (build.replaceParent) {
this.parentPath.node = build.node;
} else {
return build.node;
}
if (build.replaceParent) this.parentPath.node = build.node;
return build.node;
}
var breakVisitor = {
enter(node, parent, scope, state) {
if (this.isLoop()) {
state.ignoreLabeless = true;
scope.traverse(node, breakVisitor, state);
state.ignoreLabeless = false;
return this.skip();
}
if (this.isBreakStatement()) {
if (!node.label && state.ignoreLabeless) return;
if (node.label && node.label.name !== state.label) return;
// break statements mean something different in this context
if (t.isSwitchCase(parent)) return;
var ret = t.expressionStatement(
t.callExpression(t.memberExpression(state.iteratorKey, t.identifier("return")), [])
);
ret = state.wrapReturn(ret);
this.skip();
return [ret, node];
}
}
};
var loose = function (node, parent, scope, file) {
var left = node.left;
var declar, id;
@@ -102,23 +72,6 @@ var loose = function (node, parent, scope, file) {
//
scope.traverse(node, breakVisitor, {
iteratorKey: iteratorKey,
label: t.isLabeledStatement(parent) && parent.label.name,
wrapReturn(node) {
return t.ifStatement(
t.logicalExpression(
"&&",
t.unaryExpression("!", isArrayKey, true),
t.memberExpression(iteratorKey, t.identifier("return")
)
), node);
}
});
//
return {
declar: declar,
node: loop,
@@ -170,17 +123,6 @@ var spec = function (node, parent, scope, file) {
//
scope.traverse(node, breakVisitor, {
iteratorKey: iteratorKey,
label: isLabeledParent && parent.label.name,
wrapReturn(node) {
return t.ifStatement(t.memberExpression(iteratorKey, t.identifier("return")), node);
}
});
//
return {
replaceParent: isLabeledParent,
declar: declar,

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export { check } from "../internal/modules";

View File

@@ -1,5 +1,5 @@
import ReplaceSupers from "../../helpers/replace-supers";
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isIdentifier(node, { name: "super" });
@@ -40,10 +40,7 @@ export function ObjectExpression(node, parent, scope, file) {
}
if (objectRef) {
scope.push({
id: objectRef
});
scope.push({ id: objectRef });
return t.assignmentExpression("=", objectRef, node);
}
}

View File

@@ -1,5 +1,5 @@
import * as util from "../../../util";
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isFunction(node) && hasDefaults(node);

View File

@@ -1,6 +1,6 @@
import isNumber from "lodash/lang/isNumber";
import * as util from "../../../util";
import t from "../../../types";
import * as t from "../../../types";
export var check = t.isRestElement;

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
function loose(node, body, objId) {
for (var i = 0; i < node.properties.length; i++) {

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isProperty(node) && (node.method || node.shorthand);

View File

@@ -1,5 +1,5 @@
import * as regex from "../../helpers/regex";
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return regex.is(node, "y");

View File

@@ -7,6 +7,6 @@ export function check(node) {
export function Literal(node) {
if (!regex.is(node, "u")) return;
regex.pullFlag(node, "y");
node.regex.pattern = rewritePattern(node.regex.pattern, node.regex.flags);
regex.pullFlag(node, "u");
}

View File

@@ -1,5 +1,5 @@
import includes from "lodash/collection/includes";
import t from "../../../types";
import * as t from "../../../types";
function getSpreadLiteral(spread, scope) {
return scope.toArray(spread.argument, true);

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export var optional = true;

View File

@@ -3,7 +3,7 @@ import * as messages from "../../../messages";
import flatten from "lodash/array/flatten";
import * as util from "../../../util";
import map from "lodash/collection/map";
import t from "../../../types";
import * as t from "../../../types";
exports.Function = function (node, parent, scope, file) {
var tailCall = new TailCallTransformer(node, scope, file);
@@ -161,7 +161,7 @@ class TailCallTransformer {
if (!this.hasTailRecursion) return;
if (this.hasDeopt()) {
this.file.logDeopt(node, messages.get("tailCallReassignmentDeopt"));
this.file.log.deopt(node, messages.get("tailCallReassignmentDeopt"));
return;
}

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
var buildBinaryExpression = function (left, right) {
return t.binaryExpression("+", left, right);

View File

@@ -1,7 +1,7 @@
// https://github.com/zenparsing/es-abstract-refs
import * as util from "../../../util";
import t from "../../../types";
import * as t from "../../../types";
export var experimental = true;
@@ -24,6 +24,7 @@ var container = function (parent, call, ret, file) {
export function AssignmentExpression(node, parent, scope, file) {
var left = node.left;
if (!t.isVirtualPropertyExpression(left)) return;
console.error("Abstract references are deprecated and will be removed in 5.0.0");
var value = node.right;
var temp;
@@ -65,6 +66,7 @@ export function UnaryExpression(node, parent, scope, file) {
var arg = node.argument;
if (!t.isVirtualPropertyExpression(arg)) return;
if (node.operator !== "delete") return;
console.error("Abstract references are deprecated and will be removed in 5.0.0");
var call = util.template("abstract-expression-delete", {
PROPERTY: arg.property,
@@ -77,6 +79,7 @@ export function UnaryExpression(node, parent, scope, file) {
export function CallExpression(node, parent, scope) {
var callee = node.callee;
if (!t.isVirtualPropertyExpression(callee)) return;
console.error("Abstract references are deprecated and will be removed in 5.0.0");
var temp = scope.generateTempBasedOnNode(callee.object);
@@ -98,6 +101,7 @@ export function CallExpression(node, parent, scope) {
}
export function VirtualPropertyExpression(node) {
console.error("Abstract references are deprecated and will be removed in 5.0.0");
return util.template("abstract-expression-get", {
PROPERTY: node.property,
OBJECT: node.object
@@ -105,6 +109,7 @@ export function VirtualPropertyExpression(node) {
}
export function PrivateDeclaration(node) {
console.error("Abstract references are deprecated and will be removed in 5.0.0");
return t.variableDeclaration("const", node.declarations.map(function (id) {
return t.variableDeclarator(id, t.newExpression(t.identifier("WeakMap"), []));
}));

View File

@@ -1,7 +1,7 @@
import buildComprehension from "../../helpers/build-comprehension";
import traverse from "../../../traversal";
import * as util from "../../../util";
import t from "../../../types";
import * as t from "../../../types";
export var experimental = true;

View File

@@ -1,7 +1,7 @@
// https://github.com/rwaldron/exponentiation-operator
import build from "../../helpers/build-binary-assignment-operator-transformer";
import t from "../../../types";
import * as t from "../../../types";
export var experimental = true;

View File

@@ -1,6 +1,6 @@
// https://github.com/sebmarkbage/ecmascript-rest-spread
import t from "../../../types";
import * as t from "../../../types";
export var experimental = true;

View File

@@ -94,7 +94,7 @@ export default {
_aliasFunctions: require("./internal/alias-functions"),
"spec.typeofSymbol": require("./spec/typeof-symbol"),
"es6.symbols": require("./es6/symbols"),
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
_strict: require("./internal/strict"),

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
var functionChildrenVisitor = {
enter(node, parent, scope, state) {

View File

@@ -13,3 +13,18 @@ export var ExpressionStatement = {
if (!node.expression) this.remove();
}
};
export var Binary = {
exit(node) {
var right = node.right;
var left = node.left;
if (!left && !right) {
this.remove();
} else if (!left) {
return right;
} else if (!right) {
return left;
}
}
};

View File

@@ -1,5 +1,5 @@
import * as strict from "../../helpers/strict";
import t from "../../../types";
import * as t from "../../../types";
export var secondPass = true;

View File

@@ -4,7 +4,7 @@
// a generator function as a default then regenerator will destroy the export
// declaration and leave a variable declaration in it's place... yeah, handy.
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isImportDeclaration(node) || t.isExportDeclaration(node);
@@ -32,9 +32,11 @@ export function ExportDeclaration(node, parent, scope) {
if (node.default) {
if (t.isClassDeclaration(declar)) {
// export default class Foo {};
this.node = [getDeclar(), node];
node.declaration = declar.id;
return [getDeclar(), node];
} else if (t.isClassExpression(declar)) {
// export default class {};
var temp = scope.generateUidIdentifier("default");
declar = t.variableDeclaration("var", [
t.variableDeclarator(temp, declar)
@@ -42,25 +44,26 @@ export function ExportDeclaration(node, parent, scope) {
node.declaration = temp;
return [getDeclar(), node];
} else if (t.isFunctionDeclaration(declar)) {
// export default function Foo() {}
node._blockHoist = 2;
node.declaration = declar.id;
return [getDeclar(), node];
}
} else {
if (t.isFunctionDeclaration(declar)) {
// export function Foo() {}
node.specifiers = [t.importSpecifier(declar.id, declar.id)];
node.declaration = null;
node._blockHoist = 2;
return [getDeclar(), node];
} else if (t.isVariableDeclaration(declar)) {
// export var foo = "bar";
var specifiers = [];
var bindings = t.getBindingIdentifiers(declar);
for (var key in bindings) {
var id = bindings[key];
specifiers.push(t.exportSpecifier(id, id));
}
return [declar, t.exportDeclaration(null, specifiers)];
}
}

View File

@@ -1,7 +1,18 @@
import t from "../../../types";
import * as t from "../../../types";
export function Program(program, parent, scope, file) {
if (file.transformers.strict.canRun()) {
program.body.unshift(t.expressionStatement(t.literal("use strict")));
var directive = file.get("existingStrictDirective");
if (!directive) {
directive = t.expressionStatement(t.literal("use strict"));
var first = program.body[0];
if (first) {
directive.leadingComments = first.leadingComments;
first.leadingComments = [];
}
}
program.body.unshift(directive);
}
}

View File

@@ -1,5 +1,5 @@
import * as messages from "../../../messages";
import t from "../../../types";
import * as t from "../../../types";
export function ForOfStatement(node, parent, scope, file) {
var left = node.left;
@@ -25,3 +25,16 @@ export function Property(node, parent, scope, file) {
}
export { Property as MethodDefinition };
export function BlockStatement(node) {
for (var i = 0; i < node.body.length; i++) {
var bodyNode = node.body[i];
if (t.isExpressionStatement(bodyNode) && t.isLiteral(bodyNode.expression)) {
bodyNode._blockHoist = Infinity;
} else {
return;
}
}
}
export { BlockStatement as Program };

View File

@@ -1,5 +1,5 @@
import remapAsyncToGenerator from "../../helpers/remap-async-to-generator";
import t from "../../../types";
import * as t from "../../../types";
export function manipulateOptions(opts) {
opts.experimental = true;

View File

@@ -1,4 +1,4 @@
import t from "../../../types";
import * as t from "../../../types";
export function Flow(node) {
this.remove();

View File

@@ -1,5 +1,5 @@
import * as react from "../../helpers/react";
import t from "../../../types";
import * as t from "../../../types";
export function manipulateOptions(opts) {
opts.blacklist.push("react");

View File

@@ -1,5 +1,5 @@
import * as react from "../../helpers/react";
import t from "../../../types";
import * as t from "../../../types";
var JSX_ANNOTATION_REGEX = /^\*\s*@jsx\s+([^\s]+)/;

View File

@@ -1,5 +1,5 @@
import regenerator from "regenerator-babel";
import t from "../../../types";
import * as t from "../../../types";
export function check(node) {
return t.isFunction(node) && (node.async || node.generator);

View File

@@ -2,7 +2,7 @@ import includes from "lodash/collection/includes";
import * as util from "../../../util";
import core from "core-js/library";
import has from "lodash/object/has";
import t from "../../../types";
import * as t from "../../../types";
var isSymboliterator = t.buildMatchMemberExpression("Symbol.iterator");
@@ -16,8 +16,7 @@ var ALIASABLE_CONSTRUCTORS = [
"Map",
"WeakMap",
"Set",
"WeakSet",
"Number"
"WeakSet"
];
var astVisitor = {
@@ -81,8 +80,8 @@ export function Program(node, parent, scope, file) {
}
export function pre(file) {
file.setDynamic("helpersNamespace", function () {
return file.addImport("babel-runtime/helpers", "babelHelpers");
file.set("helperGenerator", function (name) {
return file.addImport("babel-runtime/helpers/" + name, name);
});
file.setDynamic("coreIdentifier", function () {

View File

@@ -1,10 +1,10 @@
import * as messages from "../../../messages";
import t from "../../../types";
import * as t from "../../../types";
export function Program(program) {
export function Program(program, parent, scope, file) {
var first = program.body[0];
if (t.isExpressionStatement(first) && t.isLiteral(first.expression, { value: "use strict" })) {
program.body.shift();
file.set("existingStrictDirective", program.body.shift());
}
}

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