Compare commits

..

210 Commits

Author SHA1 Message Date
Henry Zhu
1c13250807 v7.0.0-beta.0 2017-09-11 23:01:41 -04:00
Laurin Quast
8742012b5e Add --keep-file-extension option to babel-cli (#6221)
* Add --keep-module-extension option to babel-cli

* Rename keep-module-extension option to keep-file-extension; Change option to preserve all file extensions
2017-09-11 18:06:44 -04:00
Justin Ridgewell
4daf11528c Return inserted/replaced paths (#5710)
* Return inserted/replaced paths

This gives `Path`’s replacement and insertion methods a consistent
return value: the inserted/replaced paths.

Before, they could return `undefined`, a `node`, or a the current path
inside an array. It was kinda pointless.  But now they always return an
array of paths, which is useful for solving
https://github.com/babel/babel/pull/4935#discussion_r96151368.

* Return inserted nodes and not BlockStatement

Addded test for bug #4363

* Cleanups

- `#replaceWith` will now return the current path if it's the same node
- `#insertAfter` and `#insertBefore` use public Path APIs now
- Makes container insertion faster (single splice call)
- Use public APIs in container insertion
- Replacing a statement with an expression returns the expression's path
- Replacing an expression with multiple statements returns the inserted
  closure's body's paths.
2017-09-11 16:07:04 -04:00
Mateusz Burzyński
c47258d68c Annotating transformed classes with #__PURE__ comment (#6209) 2017-09-11 11:18:37 -04:00
Ben Newman
c4f6a7a06f Add failing test case for object rest after array rest, and fix it. (#6213)
* Add failing test case for object rest after array rest.

Discovered while upgrading https://github.com/meteor/babel to Babel 7.

The error is:

  1) babel-plugin-transform-object-rest-spread/object rest with array rest:
     TypeError: /Users/ben/dev/babel/packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/with-array-rest/actual.js: Property id of VariableDeclarator expected node to be of a type ["LVal"] but instead got null
      at Object.validate (packages/babel-types/lib/definitions/index.js:73:13)
      at validate (packages/babel-types/lib/index.js:460:9)
      at Object.builder (packages/babel-types/lib/index.js:428:7)
      at Object.RestElement (packages/babel-plugin-transform-object-rest-spread/lib/index.js:157:41)
      at NodePath._call (packages/babel-traverse/lib/path/context.js:53:20)
      at NodePath.call (packages/babel-traverse/lib/path/context.js:40:17)
      at NodePath.visit (packages/babel-traverse/lib/path/context.js:84:12)
      ...

* Fix object rest following array rest. (#6213)

* Avoid treating array ...rest elements as object ...rest properties.

* Also avoid treating ...rest parameters as object ...rest properties.

Returning early if the parent was an ArrayPattern was not quite enough,
since a RestElement can appear as a parameter in a Function as well.

* Move RestElement parent check earlier in visitor method.
2017-09-11 11:16:14 -04:00
Sven SAULEAU
1341e4163b fix(preset-es2015): pass loose option (#6224) 2017-09-11 10:37:18 -04:00
Lukas Geiger
b6467a68ca Add option to define output directory relative to the input (#5421)
* Fix output directory if filename is given

* Add test for relative output path

* Add option to define output dir relative to input

* Add tests for --copy-files

* Test error handling for wrong arguments
2017-09-09 20:38:06 -04:00
Daniel Tschinder
5565e1b406 Correctly requeue CallExpression in AMD transform (#5497)
* Correctly requeue the define()-CallExpression

* Use pushContainer
2017-09-09 20:33:35 -04:00
Ruben Verborgh
6560a29c36 Redeclaring a variable counts as a modification (#6219)
* Redeclaring a variable counts as a modification.

Fixes #6217.

* Remove "existing" logic from Binding.

Was added in #5745, but no longer triggered since 6536e605a.
2017-09-08 23:02:26 -04:00
Justin Ridgewell
4e612058c0 Do not fix linting errors in precommit hooks (#6218)
It's just damn annoying. Supersedes #5908.
2017-09-08 19:52:49 -04:00
Nicolò Ribaudo
4e7961dcf8 Use /bin/bash instead of /bin/sh in scripts
`/bin/sh` isn't always an alias of `/bin/bash`, so bash-specific syntax broke the scripts.
(like 777a9ae6e4/scripts/_get-test-directories.sh (L7))
2017-09-07 17:19:40 -07:00
Noah Lemen
777a9ae6e4 warn about class properties support in decorators readme and error messaging (#6196) 2017-09-05 14:24:21 -04:00
Astha Sharma
3a2b7fe3cd JSX pragma revert (#6195)
* Removed the deprecated jsx pragma detection code and the concerned tests that included jsx-pragma

* Removed extra tests

* Restored packages/babel-plugin-transform-react-jsx/test/fixtures/react/honor-custom-jsx-pragma-option/

* Added JSX_ANNOTATION_REGEX

* Reverted the tests for jsx-pragma-options and removed those which throw deprecated message
2017-09-04 00:25:56 -04:00
Logan Smyth
d6ba4d0a24 Only compile files inside the cwd in babel-register. (#5590) 2017-09-02 01:07:26 -04:00
Justin Ridgewell
5df70e6a94 Fix bad Scope#parent caching (#6155)
* Fix bad Scope#parent caching

Now, we traverse the path until we find a parent scope.

Fixes #6057.

* Fix bad merge

* Remove cached data

* I need to stop using Github editor

* Fix infinite loops due to scopable paths being moved up
2017-09-02 01:03:10 -04:00
Daniel Tschinder
ca117e08cb fix(requeue): Always requeue implicitely created BlockStatements (#6193)
This reverts the former fix done in #5743 and always requeues
BlockStatements when they get created.

This also fixes a bug in babel-generator which would indent code
even though no comments are present.
2017-09-02 01:02:21 -04:00
Zev Isert
2dd03e3ee9 Allow NodeJS v8.4 experimental HTTP2 (#6175)
* Allow NodeJS v8.4 experimental HTTP2

Native NodeJS HTTP/2 support experimental though, so might not be worth merging this

* Linter picked up on a line with only spaces

Removed the spaces
2017-09-02 00:42:45 +02:00
Logan Smyth
4f441ff27e Ignore the standalone output bundle so it will require() faster. 2017-09-01 15:31:29 -07:00
Justin Ridgewell
f7109658f9 Added --delete-dir-on-start option for babel (#6187)
* added --delete-dir-on-start option 

added --delete-dir-on-start-option to delete dir on start of compilation to remove deleted files from the orignial files from the --out-dir

* added option --delete-dir-on-start

added --delete-dir-on-start that option will delete the --out-dir before the compilation of code to remove the deleted files from the source from the out directory

* added --delete-dir-on-start option

added --delete-dir-on-start-option to delete dir on start of compilation to remove deleted files from the orignial files from the --out-dir

* bug removed deleting the correct dir

in the previous code, the source dir was deleted each time rather than deleting the out dir

* Remove shorthand

* Prevent babel-cli option from reaching babel-core

* Lint
2017-09-01 17:45:13 -04:00
Justin Ridgewell
f39811d271 Derived constructors don't always need a super (#6189) 2017-09-01 17:14:25 -04:00
Logan Smyth
fad9345c85 Revert Yarn workspace changes from #6056 for now.
Yarn currently fails to add the correct symlinks in some cases. See https://github.com/yarnpkg/yarn/issues/4289
2017-09-01 13:17:25 -07:00
Justin Ridgewell
1797ac5015 Update babylon and remove bad label tests (#6188) 2017-09-01 12:29:48 -04:00
Mateusz Burzyński
76161e0a73 Added new outputType - module - for build-external-helpers tool. Should help with tree-shaking story. It's strongly influenced by how the helpers are transformed by rollup-plugin-babel. (#5916) 2017-08-31 23:44:24 -04:00
Daniel Tschinder
ab30fa54cb Update debug to 3.0 (#6184) 2017-08-31 23:30:04 -04:00
Daniel Tschinder
44f6ff5e85 Update prettier, eslint + plugins, flow, husky and lint-staged (#6183) 2017-08-31 22:56:29 +02:00
Henry Zhu
6108bee4f9 update changelog labels [skip ci] 2017-08-31 15:59:05 -04:00
Daniel Tschinder
0189b38702 Merge branch '6.x' into 7.0
# Conflicts:
#	CONTRIBUTING.md
#	Makefile
#	README.md
#	lerna.json
#	lib/types.js
#	package.json
#	packages/babel-cli/package.json
#	packages/babel-code-frame/package.json
#	packages/babel-core/package.json
#	packages/babel-core/test/fixtures/transformation/misc/regression-2892/expected.js
#	packages/babel-generator/package.json
#	packages/babel-generator/src/generators/flow.js
#	packages/babel-generator/src/index.js
#	packages/babel-generator/test/fixtures/flow/declare-statements/expected.js
#	packages/babel-generator/test/fixtures/flow/object-literal-types/expected.js
#	packages/babel-generator/test/fixtures/flow/opaque-type-alias/expected.js
#	packages/babel-helper-bindify-decorators/package.json
#	packages/babel-helper-builder-binary-assignment-operator-visitor/package.json
#	packages/babel-helper-builder-conditional-assignment-operator-visitor/package.json
#	packages/babel-helper-builder-react-jsx/package.json
#	packages/babel-helper-call-delegate/package.json
#	packages/babel-helper-define-map/package.json
#	packages/babel-helper-explode-assignable-expression/package.json
#	packages/babel-helper-explode-class/package.json
#	packages/babel-helper-fixtures/package.json
#	packages/babel-helper-function-name/package.json
#	packages/babel-helper-get-function-arity/package.json
#	packages/babel-helper-hoist-variables/package.json
#	packages/babel-helper-optimise-call-expression/package.json
#	packages/babel-helper-plugin-test-runner/package.json
#	packages/babel-helper-regex/package.json
#	packages/babel-helper-remap-async-to-generator/package.json
#	packages/babel-helper-replace-supers/package.json
#	packages/babel-helper-transform-fixture-test-runner/package.json
#	packages/babel-helpers/package.json
#	packages/babel-plugin-transform-async-generator-functions/package.json
#	packages/babel-plugin-transform-async-to-generator/package.json
#	packages/babel-plugin-transform-async-to-module-method/package.json
#	packages/babel-plugin-transform-class-constructor-call/package.json
#	packages/babel-plugin-transform-class-properties/package.json
#	packages/babel-plugin-transform-decorators/package.json
#	packages/babel-plugin-transform-es2015-block-scoping/package.json
#	packages/babel-plugin-transform-es2015-classes/package.json
#	packages/babel-plugin-transform-es2015-classes/test/fixtures/regression/T6755/expected.js
#	packages/babel-plugin-transform-es2015-computed-properties/package.json
#	packages/babel-plugin-transform-es2015-duplicate-keys/package.json
#	packages/babel-plugin-transform-es2015-function-name/package.json
#	packages/babel-plugin-transform-es2015-modules-amd/package.json
#	packages/babel-plugin-transform-es2015-modules-commonjs/package.json
#	packages/babel-plugin-transform-es2015-modules-commonjs/src/index.js
#	packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/interop/export-destructured/expected.js
#	packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object-default-params/expected.js
#	packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object-rest/expected.js
#	packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/export-const-destructuring-object/expected.js
#	packages/babel-plugin-transform-es2015-modules-commonjs/test/fixtures/strict/options.json
#	packages/babel-plugin-transform-es2015-modules-systemjs/package.json
#	packages/babel-plugin-transform-es2015-modules-umd/package.json
#	packages/babel-plugin-transform-es2015-object-super/package.json
#	packages/babel-plugin-transform-es2015-parameters/package.json
#	packages/babel-plugin-transform-es2015-shorthand-properties/package.json
#	packages/babel-plugin-transform-es2015-sticky-regex/package.json
#	packages/babel-plugin-transform-es2015-unicode-regex/package.json
#	packages/babel-plugin-transform-es5-property-mutators/package.json
#	packages/babel-plugin-transform-exponentiation-operator/package.json
#	packages/babel-plugin-transform-flow-comments/test/fixtures/flow-comments/opaque-type-alias/expected.js
#	packages/babel-plugin-transform-object-rest-spread/package.json
#	packages/babel-plugin-transform-object-rest-spread/src/index.js
#	packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/nested-2/expected.js
#	packages/babel-plugin-transform-object-rest-spread/test/fixtures/object-rest/nested/expected.js
#	packages/babel-plugin-transform-proto-to-assign/package.json
#	packages/babel-plugin-transform-react-constant-elements/test/fixtures/constant-elements/regression-node-type-export-default/expected.js
#	packages/babel-plugin-transform-react-constant-elements/test/fixtures/constant-elements/regression-node-type-export/expected.js
#	packages/babel-plugin-transform-react-display-name/package.json
#	packages/babel-plugin-transform-react-display-name/src/index.js
#	packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/assignment-expression/expected.js
#	packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/nested/expected.js
#	packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/object-property/expected.js
#	packages/babel-plugin-transform-react-display-name/test/fixtures/display-name/variable-declarator/expected.js
#	packages/babel-plugin-transform-react-jsx-compat/package.json
#	packages/babel-plugin-transform-react-jsx/package.json
#	packages/babel-plugin-transform-regenerator/package.json
#	packages/babel-plugin-transform-regenerator/test/fixtures/regression/6733/expected.js
#	packages/babel-plugin-transform-regenerator/test/fixtures/regression/T7041/expected.js
#	packages/babel-plugin-transform-regenerator/test/fixtures/variable-renaming/retain-lines/expected.js
#	packages/babel-plugin-transform-runtime/README.md
#	packages/babel-plugin-transform-runtime/test/fixtures/runtime/custom-runtime/expected.js
#	packages/babel-plugin-transform-runtime/test/fixtures/runtime/full/expected.js
#	packages/babel-plugin-transform-runtime/test/fixtures/runtime/regenerator-runtime/expected.js
#	packages/babel-plugin-transform-strict-mode/package.json
#	packages/babel-polyfill/package.json
#	packages/babel-preset-es2015/package.json
#	packages/babel-preset-es2016/package.json
#	packages/babel-preset-es2017/package.json
#	packages/babel-preset-latest/package.json
#	packages/babel-preset-react/package.json
#	packages/babel-preset-stage-0/package.json
#	packages/babel-preset-stage-1/package.json
#	packages/babel-preset-stage-2/package.json
#	packages/babel-preset-stage-3/package.json
#	packages/babel-register/README.md
#	packages/babel-register/package.json
#	packages/babel-runtime/package.json
#	packages/babel-template/package.json
#	packages/babel-traverse/package.json
#	packages/babel-traverse/src/scope/lib/renamer.js
#	packages/babel-traverse/test/evaluation.js
#	packages/babel-traverse/test/replacement.js
#	packages/babel-types/README.md
#	packages/babel-types/package.json
#	packages/babel-types/src/converters.js
#	packages/babel-types/src/definitions/core.js
#	packages/babel-types/src/definitions/es2015.js
#	packages/babel-types/src/definitions/flow.js
#	packages/babel-types/test/converters.js
#	packages/babel-types/test/validators.js
#	scripts/generate-interfaces.js
#	yarn.lock
2017-08-31 17:44:17 +02:00
Henry Zhu
b82b65a31e v7.0.0-alpha.20 2017-08-30 15:02:49 -04:00
Justin Ridgewell
5e7fce3fe0 Update babylon (#6172) 2017-08-30 00:19:36 -04:00
Brandon Max
84580cc2d1 Refactor es2015-loose and es2015-no-commonjs presets to use preset op… (#6168) 2017-08-30 00:02:54 -04:00
Noah Lemen
d70603ffa9 re-add template literals tests, add ones that were missing (#6169) 2017-08-29 21:06:05 -04:00
Logan Smyth
d79a7920a1 Merge pull request #5586 from loganfsmyth/config-dependency-cycles
Handle cycles of plugins compiling themselves and .babelrc.js files loading themselves
2017-08-29 15:11:51 -07:00
Logan Smyth
2846e06db1 Add dependency cycle handing for plugins and config files. 2017-08-29 14:57:34 -07:00
Logan Smyth
beff7809ea Add debug() calls for config loading. 2017-08-29 14:57:33 -07:00
Henry Zhu
0a4f1b0a6e update babylon beta.22 (#6167) 2017-08-29 17:53:29 -04:00
Buu Nguyen
75861fac87 Fix bug replacement nodes not requeued (#5743) 2017-08-28 15:10:00 -06:00
Artem Yavorsky
b2b3d7944a Spec compatibility for iteratorClose condition. (#6094)
* for-of: IteratorClose spec compatibility.

See #3:
https://tc39.github.io/ecma262/#sec-iteratorclose

* Update spec fixtures for for-of.

* Fix IteratorClose case for remap-async-to-generator.

* Fix IteratorClose case for async-generator-function test output.

* Modify few tests according to iteratorClose fix.

* Fix iteratorClose for helpers.slicedToArray also.

* Update iteratorClose fixture for commonjs.
2017-08-28 13:39:02 -06:00
Henry Zhu
827d84536a Merge pull request #6156 from jridgewell/pr/5502
Fix overshadowing local binding
2017-08-28 13:38:21 -06:00
Justin Ridgewell
3e487f89ab Don't merge test options. (#6157)
* Don't merge test options.

Particularly, I don't want `lodash/merge` to merge my specific plugins
with the general test plugins. It led to odd behavior where I could
enable a loose transform in my specific test, just to have it overridden
by the test fixture's general options.

* Need options
2017-08-28 13:36:03 -06:00
Noah Lemen
40805894c5 default to spec mode for template literal transform (#6098)
* spec/loose/default switch for template literal transform, update/re-org tests

* update readme

* flip if statements

* consolidate else/if

* readme wording modification, updates to examples
2017-08-28 12:57:09 -06:00
Henry Zhu
95dd16aeeb Merge pull request #6159 from jridgewell/pr/3701
Allow native Symbols as computed property names
2017-08-28 12:50:10 -06:00
Justin Ridgewell
ac6eda2709 Class instance properties define their own context (#6158) 2017-08-28 12:47:17 -06:00
Oliver Don
960151c876 Fix #4840: Alias class prototype for methods in loose mode (#5560)
* Fix #4840: Alias class prototype for methods in loose mode

* Cleanup
2017-08-26 21:15:45 -04:00
Justin Ridgewell
7795750862 Tests 2017-08-25 22:52:17 -04:00
Adam Miller
2d8fdf3045 Allow native Symbols as computed property names (#6705)
The for-in loop in helpers.defineEnumerableProperties doesn't iterate over Symbols.
If Object.getOwnPropertySymbols exists, include the discovered values when defining properties.
2017-08-25 22:33:51 -04:00
Justin Ridgewell
a70cda812c Remove old test 2017-08-25 19:52:15 -04:00
Justin Ridgewell
4b297907d1 Move fix into #checkBlockScopedCollisions 2017-08-25 19:23:11 -04:00
Moti Zilberman
48c114169f Move up check for binding kind "local"
This puts the check before the call to `checkBlockScopedCollisions`.
Fixes #4946.
2017-08-25 19:21:38 -04:00
Moti Zilberman
68786c4f0f Add test for issue #4946 2017-08-25 19:21:38 -04:00
Moti Zilberman
1ef5871300 Add tests for #5491 and related cases
The two function expression tests would fail before 6705de7. The
function declaration test was not a failing case but is added here for
completeness.
2017-08-25 19:21:38 -04:00
Moti Zilberman
c3e8715010 Mask existing "local" bindings when registering new binding
Fixes #5491.
2017-08-25 19:21:38 -04:00
Mauro Bringolf
d8b4073536 Consistent const violations (#6100)
* Changed updateExpression to report itself as violation instead of its argument

* Update getBindingIdentifiers to work with forXStatement and return proper node as violation

* Updated unaryExpression violation to be consistent with changes.
2017-08-24 21:19:02 -04:00
Mateusz Burzyński
3c4f19a28d Adjusted Object Rest/Spread tests to use only allowed syntax from the latest spec (#6102) 2017-08-24 15:50:43 -04:00
Noah Lemen
2db0c3ad1d linting: disallow t.identifier("undefined") in plugins (#6096)
* add new custom eslint rule, replace remaining t.identifier("undefined") with buildUndefinedNode(), update tests

* change no-undefined-identifier reporting descriptor
2017-08-24 15:43:01 -04:00
Nicolò Ribaudo
4577bd1b7c TypeParameterInstantiation params can be "Flow" nodes, not "FlowType" (#6140) 2017-08-22 23:11:02 -04:00
Daniel Lo Nigro
93cf26abca Fix babel-standalone for realz (#6137)
* Fix babel-standalone

* Fix infinite loop in Makefile (oops)

* Override Node.js module resolution to handle babel-core
2017-08-22 13:46:30 -07:00
Astha Sharma
62c22c7b5d Removed the deprecated jsx pragma detection code (#6145)
* Removed the deprecated jsx pragma detection code and the concerned tests that included jsx-pragma

* Removed extra tests

* Restored packages/babel-plugin-transform-react-jsx/test/fixtures/react/honor-custom-jsx-pragma-option/
2017-08-22 15:29:06 -04:00
Bryan Wain
63baaa7148 add --config-file option to CLI to pass in .babelrc location (#6133) 2017-08-22 13:58:24 -04:00
Justin Ridgewell
7e726a81e6 Complete export transform split (#6139)
They were each transforming the other's syntax (including namespace
transform would transform default, too, and vice-versa).
2017-08-21 14:15:40 -04:00
Ramiro Silveyra d'Avila
9e4e64dac9 Remove Flow support in React preset (#6118) 2017-08-21 10:48:18 -04:00
Daniel Lo Nigro
3569cb9922 Allow nightly Yarn builds to be used (#6138)
* Allow nightly Yarn builds to be used

Fixes:
```
C:\src\babel (fix-it-fix-it-fix-it-fix-it) (babel)
λ yarn
yarn install v1.0.0-20170811.1240
[1/5] Validating package.json...
error babel@: The engine "yarn" is incompatible with this module. Expected version ">=0.27.5".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
```

* Use Yarn 0.28.4 to fix build
2017-08-20 16:19:17 -07:00
Sangboak Lee
c6a094a9d2 Split export extensions into 2 different plugins, update stage presets (#6080) 2017-08-19 09:35:40 -04:00
Henry Zhu
cee4cde53e v6.26.0 2017-08-16 11:54:08 -04:00
Henry Zhu
aa330999d0 update changelog 2017-08-16 11:39:05 -04:00
Henry Zhu
5749276d7e update deps 2017-08-16 10:21:19 -04:00
Henry Zhu
7b30f77954 Merge pull request #6111 from modosc/update-regenerator
Update regenerator
2017-08-16 10:17:59 -04:00
Anup
6ab3b4c0e3 Add 'configurable' property to class fields (#6123) 2017-08-16 10:12:38 -04:00
Henry Zhu
70ab2e0620 Merge pull request #6113 from Andarist/fix/regenerator-fixtures
Fix/regenerator fixtures
2017-08-16 10:11:24 -04:00
Sven SAULEAU
0d16499fc0 Merge pull request #6124 from uxter/patch-1
Update README.md
2017-08-16 15:30:51 +02:00
Sven SAULEAU
77bbe20352 fix: [skip ci] split babel config 2017-08-16 15:30:16 +02:00
Vasiliy Shilov
bd569433c4 Update README.md: A semicolon is required after a class property. 2017-08-16 16:18:39 +03:00
Mateusz Burzyński
fffa604023 Fixed regenerator related fixtures 2017-08-16 10:02:33 +02:00
Ben Newman
e08ff8e650 Update regenerator-runtime to version 0.11.0. 2017-08-16 10:02:33 +02:00
Ben Newman
b660f61b92 Update regenerator-transform to version 0.10.0. 2017-08-16 10:02:33 +02:00
Sven SAULEAU
5fb282f73f Merge pull request #6121 from maurobringolf/babel-website-link
Update babel/website link
2017-08-16 08:56:09 +02:00
Mauro Bringolf
7cc5580c71 Update babel/website link 2017-08-16 08:41:48 +02:00
Brian Ng
2eaff3d01c Fix rest-member-expression-optimisation fixture (#6116) 2017-08-15 21:34:09 -04:00
Piotr Kowalski
b684699f79 Typo in name of most famous language [skip ci] 2017-08-15 19:35:41 -05:00
jbrown215
f4716dc816 Backport #6031 (#6112)
* Backport #6031

* Backport #6031

* Rebase on master, rerun scripts

* Update flowconfig
2017-08-15 17:42:01 -04:00
Henry Zhu
d375d80001 6.26.0 changelog [skip ci] 2017-08-15 17:06:16 -04:00
Henry Zhu
98824e7cb7 backport the fix #6052 [skip ci] 2017-08-15 17:01:25 -04:00
jbrown215
c28465e03e Flow opaque type 6.x backport (#6081)
* Flow opaque type backport

* Add tests for strip types, comments, and babel-generator

* Fix failing tests, run scripts

* Bump babylon to 6.18.0
2017-08-15 16:44:15 -04:00
Justin Ridgewell
4ca686b7be Fix relative execution location introspection (#5741)
So, I was reading the new Flow type strictness and noticed
https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/
Specifically, I wondered whether the `sum_all` example would copy the
arguments into an array, then loop over. Sadly, it does.

```js
function sum_all(...rest) {
  let ret = 0;
  for (let i = 0; i < rest.length; i++) { ret += rest[i]; }
  return ret;
}

// output
function sum_all() {
  var ret = 0;
  for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) {
    rest[_key] = arguments[_key];
  }
  for (var i = 0; i < rest.length; i++) { ret += rest[i]; }
  return ret;
}
```

But then I noticed if I changed `let i = 0` to `let i: number = 0`, it
worked directly on `arguments`. That lead me down a rabbit hole to
`Path#_guessExecutionStatusRelativeTo`. When tracing through, the last
comparison made no sense to me. It was trying to find the index of
`"init"` in a list of `["declarations"]` and `"body"` in `["directives",
"body"]`. Red flags and such.

But it makes sense when you're trying to compare the visitor order of
the common ancestor path. Then we're trying to find `"init"` in a list
of `["init", "test", "update", "body"]`. Oh, and there's `"body"` in
there too! And now we know the `ForStatement`'s `init` is executed
before the `body`.
2017-08-14 22:22:18 -04:00
Nicolò Ribaudo
b84f8e9234 Don't use _possibleConstructorReturn inside arrow functions (#6103)
Arrow functions can't be entrly skipped while traversing because this
references inside of them needs to be transformed, so I added a check
which prevents return statements inside arrow functions from being
saved for the transformation.

Fixes #5817 (regression)
2017-08-14 11:11:05 -04:00
Brian Ng
9e51038ad9 Fix class prop test fixture (#6090) 2017-08-14 09:20:36 -05:00
Henry Zhu
777a8e2bb4 add more links [skip ci] 2017-08-12 22:04:55 -04:00
Henry Zhu
ad1f87cf07 add new yarn version requirement [skip ci] 2017-08-12 22:00:25 -04:00
Daniel Lo Nigro
a04c18af71 Move babel-standalone into main Babel repo (#6029)
* Move babel-standalone into main Babel repo

* Don't try to gather coverage data for babel-standalone test

* Fix JSX test

* Always use npm v4 on Travis

* Include pull request number as part of version number

* Cherry-picking 5721b2e43e

Remove deprecated packages to prevent Babel v6 files from being pulled in

* Use RootMostResolvePlugin to dedupe packages

* Avoid destructuring so the build works on archaic Node.js versions

* - Fix version number
- Remove Babili packages (they should be in separate babili-standalone)
- Remove deprecated  syntax-class-constructor-call

* - Remove more Babili packages
- Remove `babel-plugin-inline-replace-variables` for now as it pulls in Babel 6 stuff

* Actually remove reference to babel-plugin-undeclared-variables-check

* Add Babylon to root package.json so we hoist the right version. This fixes the tests.
2017-08-11 23:36:19 -07:00
Diogo Franco
0538c3cd8c Add another test for runtime order of template literals (#6092)
More proof that it really is unsafe to merge the .concat calls if the
value is an expression that has any chance of executing impure code 😢
2017-08-12 14:11:27 +09:00
Diogo Franco (Kovensky)
cd66657f34 Update outdated test fixture 2017-08-12 14:10:19 +09:00
Andy
9243c78ea2 babel-plugin-transform-class-properties: Ignore type annotations when looking for name collisions (#6082) 2017-08-11 10:27:48 -05:00
Sangboak Lee
218f191a59 remove left transform-class-properties from stage (#6088) 2017-08-10 22:30:45 -04:00
Henry Zhu
3154c2c114 pr template [skip ci] (#6086) 2017-08-10 16:35:32 -04:00
Noah Lemen
4fdd75695b Update Class Fields to Stage 3 and change default behavior (#6076)
* add transform-class-properties to stage 3, set spec mode to default

* update readme with examples; use `buildUndefinedNode()`; change behavior to always define both static and nonstatic class properties regardless of spec/loose mode; update tests
2017-08-10 11:19:49 -04:00
Rick Waldron
9c91e35ce4 Add numeric separator to stage 2 preset (#6071) 2017-08-10 11:05:35 -04:00
Karl Cheng
3a55e1326c Allow substrings for TEST_ONLY in make (#6079)
This allows TEST_ONLY to match substrings of the package directory name
instead of having to use the full package directory name.
2017-08-10 10:55:46 -04:00
Brian Ng
370559c62f Replace decache with direct removal in babel-register tests (#6085) 2017-08-10 10:52:27 -04:00
Andy
a74b307752 babel-types: Add missing field, fix incorrect definitions (#6083)
* babel-types: Add missing field, fix incorrect definitions

* Regenerate babel-types readme
2017-08-09 16:56:19 -04:00
Mateusz Burzyński
b41fe4efb1 [docs] Added clarification note about transform-react-inline-elements usage … (#6078)
* Added clarification note about transform-react-inline-elements usage with transform-runtime [skip ci]

* small tweaks [skip ci]
2017-08-09 08:45:02 -05:00
Andy
68d2f8d161 Add "classProperties" plugin to babel-generator typescript tests (#6074) 2017-08-08 17:38:39 -04:00
Andy
1c1ce5a9e4 Move parser plugin from babel-preset-typescript to babel-plugin-syntax-typescript (#6070) 2017-08-08 16:01:14 -05:00
Boopathi Rajaa
ab76cb6b53 Fix scope of catch block (#5980)
* Fix scope of catch block

* Throw error on Duplicate variable declaration

* Update test
2017-08-08 16:26:29 -04:00
Henry Zhu
009d7f0b76 Yarn engines (#6064) 2017-08-07 21:54:33 -05:00
Henry Zhu
f667f07d82 update to alpha.18 (#6062) 2017-08-07 21:15:20 -04:00
Henry Zhu
94f54da30b lockfile [skip ci] 2017-08-07 20:01:33 -04:00
Henry Zhu
d85c642617 revert lerna-changelog change [skip ci] 2017-08-07 19:42:12 -04:00
Henry Zhu
79f4956948 v7.0.0-alpha.19 2017-08-07 18:21:08 -04:00
Henry Zhu
7f92e1d9dd Update gulp, fix build (#6061)
* gulp-babel 7.0
2017-08-07 17:09:22 -04:00
Andy
e37a5eb5eb Add babel-plugin-syntax-typescript, babel-plugin-transform-typescript, and babel-preset-typescript (#5899)
* Add babel-plugin-syntax-typescript and babel-plugin-transform-typescript

* Add babel-preset-typescript

* Remove unnecessary handler for JSXOpeningElement

* Use `t.isFoo(node)` instead of `node.type === "Foo"`

* Clean up parameter property assignment generation

* Don't use function for `isSuperCall`

* slice -> shift

* Calculate sourceFileHasJsx only if necessary

* Remove `export =` support

* remove some syntax readme newlines [skip ci]
2017-08-07 11:45:52 -04:00
Henry Zhu
66ec5263a4 Use Yarn Workspaces (#6056)
* update lerna and lerna-changelog

* Lerna: enable yarn, yarn workspaces [skip ci]

* use older version of Babel since it matches on semver (cannot be the same version)

* install yarn version

* revert node engine change

* update flow

* circle ci on 8

* update lock
2017-08-05 14:48:15 -04:00
Teddy Katz
13d931c417 Don't insert the same node into the AST multiple times (fixes babel/babili#556) (#6054) 2017-08-04 19:00:29 -04:00
Henry Zhu
47a9ba3440 Merge pull request #6051 from babel/5709-2
Rewrite parameter transform and drop _blockHoist reliance
2017-08-04 18:55:23 -04:00
Henry Zhu
a1debae8f0 babylon beta.19 (#6053) 2017-08-04 14:46:12 -04:00
Henry Zhu
30c4d6b456 Merge pull request #6052 from babel/array-destructuring-hole
Array destructuring hole
2017-08-04 12:20:50 -04:00
Henry Zhu
0e58007264 add test for spread with hole 2017-08-04 12:06:26 -04:00
Henry Zhu
577173cc02 fix export when array destructuring exported value with hole 2017-08-04 11:53:49 -04:00
Henry Zhu
8c457e9283 Merge pull request #5468 from babel/react-preset
Add requireDirective to strip-flow-types for use in React preset
2017-08-04 11:31:12 -04:00
Brian Ng
2a83867436 Fixes from review 2017-08-04 10:16:45 -05:00
Brian Ng
9dd65c809f fixes 2017-08-03 22:27:30 -05:00
Brian Ng
af5f34ace5 Throw if annotation found without directive 2017-08-03 21:54:36 -05:00
Brian Ng
57da9bdbed Add requireDirective to strip-flow-types for use in React preset 2017-08-03 21:13:45 -05:00
Logan Smyth
d86ae2fb84 Remove _blockHoist usage from param processing. 2017-08-03 20:56:50 -05:00
Logan Smyth
18084db7cf Fix an ordering bug in object-rest-spread. 2017-08-03 20:56:24 -05:00
Logan Smyth
8e19a5b057 Update param scope values when expanding parameters. 2017-08-03 20:56:24 -05:00
Logan Smyth
95882d4e5a Rewrite param processing to be more clearly defined. 2017-08-03 20:56:08 -05:00
Henry Zhu
99ab2b206c update to alpha.18 (#6050) 2017-08-03 20:40:53 -04:00
Henry Zhu
77cfa94682 yarn: fix ci? 2017-08-03 20:02:31 -04:00
Henry Zhu
79c6814d65 v7.0.0-alpha.18 2017-08-03 18:20:36 -04:00
Henry Zhu
d479673074 prepublish [skip ci] 2017-08-03 18:18:36 -04:00
Henry Zhu
6630ae9794 Merge pull request #6046 from jridgewell/pr/6038
Fix invalid block-scoped loop
2017-08-03 08:51:25 -04:00
Justin Ridgewell
6bb1486405 Fix 2017-08-02 19:47:14 -04:00
Sarup Banskota
75808a2d14 Prevent getFunctionParent from returning Program (#5923) 2017-08-02 16:30:33 -05:00
jbrown215
4e9a25e34a Flow opaque type aliases (#5990) 2017-08-02 16:30:19 -05:00
Henry Zhu
0f823beeb1 Newlines in fixtures (#6044)
* write newlines for fixtures

* rerun fixtures
2017-08-02 15:35:29 -04:00
Sergey Rubanov
829c75a866 Development Only: drop Node 4-5 and npm 2 (#6037) [skip ci]
Node versions 4 and 5 are obsolete. Version of npm bundled in Node 6 is 3 so npm 2 could be dropped as well.
2017-08-02 14:30:13 -04:00
Henry Zhu
9d7c82d869 Adding failing test for 6025 2017-08-01 16:16:47 -04:00
Brian Ng
21eeed8a8c Fix generate interfaces script (#6031)
* Fix typo in TSPropertySignature type definition

* Sort fields in generate-interfaces script
2017-08-01 14:38:46 -04:00
Brian Ng
889f4e7791 Fix refs in transform-optional-chaining docs [skip ci] (#6035) 2017-08-01 14:30:16 -04:00
Brian Ng
c5e81516dd Add optional catch binding to stage 3 preset (#6032) 2017-07-31 16:00:43 -04:00
Brian Ng
6d965c0926 Make babel-node a standalone package (#6023)
* Make babel-node a standalone package

* New package `babel-node` previously `babel-cli/bin/babel-node`

* updates
2017-07-29 22:26:28 -04:00
Jimmy Jia
2dba910b9e Merge branch '6.x' 2017-07-29 12:20:18 -04:00
Andy
e32042f353 babel-generator: Comment TypeScript-specific code (#6026) 2017-07-28 18:03:38 -04:00
Andy
c1d07fd6db babel-generator: Add TypeScript support (#5896)
* babel-generator: Add TypeScript support

* Remove type declarations; not published from babylon

* Remove TODOs

* Consistently use `this.word` for tokens that are words
2017-07-28 16:07:05 -04:00
Henry Zhu
f83c83d49c add proposals repo [skip ci] (#6024) 2017-07-28 15:31:47 -04:00
chocolateboy
605adc922d allow PluginPass.file.addImport to create empty import statements (#6022)
* allow PluginPass.file.addImport to create empty import statements; fixes #6021

omitting addImport's second argument creates an import statement with an
empty `specifiers` array i.e. an empty import statement:

plugin:

    Program (path, { file }) {
        file.addImport('foo-bar/register')
    }

output:

    import "foo-bar/register";
2017-07-28 12:37:00 -04:00
Henry Zhu
593cbc1d53 Function sent (#6020)
* change back to function-sent

* update stage 2
2017-07-26 18:01:40 -04:00
Noah Lemen
5c45753cd6 add TEST_GREP example clarification [skip ci] (#6013) 2017-07-26 17:53:46 -04:00
Andy
1563221171 babel-types: Have NewExpression inherit from CallExpression (#6019) 2017-07-26 17:53:23 -04:00
Andy
b242e0d946 babel-generator: Make plugins list explicit for test cases (#6018) 2017-07-26 15:46:47 -04:00
Henry Zhu
9322fd0458 v7.0.0-alpha.17 2017-07-26 08:38:44 -04:00
Henry Zhu
f01438e9b1 update devdeps to latest, update babylon (#6012)
* temporary flow strip measure
2017-07-26 07:57:49 -04:00
Henry Zhu
ce5d1d0f59 why 2017-07-25 17:47:59 -04:00
Shuaibird Hwang
4d51052037 FIX access to the prototype of an instance (#6005)
The right way access to the prototype of an instance is using the `__proto__` rather than the `prototype`.
2017-07-24 21:46:38 -04:00
Marcus Cavanaugh
fe13ba8fc2 Remove unused functions from renamer.js. (#5965) 2017-07-20 11:19:10 -04:00
Brian Ng
81e87b0838 Remove codecov node package and use bash uploader (#5938)
* Remove codecov node package and use bash uploader

* test
2017-07-11 21:32:48 -04:00
Jeffrey Wear
72183ff2e9 Clarify use of bind operator in "prefix position" (#5917)
The REPL [shows](https://babeljs.io/repl/#?babili=false&evaluate=false&lineWrap=true&presets=es2015%2Creact%2Cstage-0&targets=&browsers=&builtIns=false&debug=false&code_lz=PYIwVgXBBmCuB2BjA3AKAPToAQEsDOWApgI6w4BuAhgDaHwAuW9wEqcSAdCDvACYAUoMAEo0qKEI7sUGbPiKkKNOo2atJ0rjwFDRqVEKjT-Vansy4CJMqZVMWbBIg6Ia1QeAA0WU3vEQNJxMaczkrRVsGe1ZNV2p3IW9fZCA)
that when the bind operator prefixes `obj.func` (as opposed to being used
between `obj` and `func`), rather than binding a free function `func` to `obj`,
it binds `obj.func` to `obj`.

[skip ci]
2017-07-04 16:21:39 -07:00
Jim Nielsen
9ad660bbe1 Swap github/twitter links (#5895) [skip ci] 2017-06-28 14:51:23 -04:00
Henry Zhu
48c770e4bb Force color output in test runs to ensure consistent behavior in Travis 2017-06-27 17:48:56 -04:00
Josh Johnston
3cf4cee40a Fix 5768 (#5811)
* Fix destructured exports

- adds a failing test based on description in #5768
- handles ObjectPattern and ArrayPattern

* use export assignment template
2017-06-27 17:31:47 -04:00
Justin Ridgewell
64eafad472 Merge pull request #5469 from yavorsky/fix-commonjs-destructuring
Fix commonjs exports with destructuring.
2017-06-21 16:41:55 -04:00
Danny Andrews
3b28bd2cb1 [skip ci] Fix typos in README.md (#5857) 2017-06-14 09:49:41 -05:00
Konstantin Pschera
fea3a72838 Fix babel-plugin-transform-regenerator README (#5852) 2017-06-13 09:19:36 -05:00
Hasan Bayat
1b29ab1289 Adding documentation and information (#5717) [skip ci] 2017-06-09 11:24:20 -04:00
Alex Rattray
dd82d7a653 Document babel-helper-plugin-test-runner usage (#5843) [skip ci]
* Document `babel-helper-plugin-test-runner` usage

* [skip ci]
2017-06-09 10:35:53 -04:00
Henry Zhu
ccd314cba7 6.25.0 changelog [skip ci] (#5844) 2017-06-08 17:30:39 -04:00
Henry Zhu
82f37841f5 v6.25.0 2017-06-08 17:29:04 -04:00
Henry Zhu
bc013e6d34 just make sure babylon is up to date [skip ci] 2017-06-08 17:10:51 -04:00
Bo Lingen
0c8fdc381d Backport array & object pattern fixes to 6.x (#5770)
* Backport array & object pattern fixes to 6.x

Original PRs merged to 7.0 as #5722 and #5762

* fix lint error
2017-06-08 16:58:37 -04:00
Justin Ridgewell
783d85ee4b Merge pull request #5780 from kentor/react-display-name-to-support-createReactClass
Backport support for createReactClass with transform-react-display-name
2017-06-05 16:13:16 -04:00
Justin Ridgewell
489cf90d23 Merge pull request #5796 from noinkling/add-inspect-brk-option
Allow --inspect-brk option to be used with babel-node [6.x backport]
2017-05-31 03:20:41 -04:00
noinkling
0230dc5067 Allow --inspect-brk option to be used with babel-node 2017-05-31 14:14:58 +12:00
Peeyush Kushwaha
dcbb6c5ce5 Add a section on troubleshooting [skip ci] (#5788)
* Add a section on troubleshooting [skip ci]

* Move troubleshooting section to be under the running tests section

* [skip ci]
2017-05-29 11:20:13 -04:00
Brian Vaughn
b296759852 Updated transform-react-display-name for createReactClass addon (#5554)
* Updated transform-react-display-name for ReactCreateClass addon

* Tweaked description for transform-react-display-name plugin

* Changed ReactCreateClass to createReactClass
2017-05-26 10:04:34 -07:00
Henry Zhu
51f3ab45c4 [skip ci] 2017-05-25 12:54:06 -04:00
Justin Ridgewell
5b261849e0 Merge pull request #5755 from u9lyfish/patch-1
Fix broken tables in README.md
2017-05-20 16:57:53 -04:00
u9lyfish@gmail.com
58c686378d Fix broken tables in README.md 2017-05-20 23:44:51 +08:00
Brian Ng
9a92933589 Fix incorrect property ordering with obj rest spread on nested (#5750) 2017-05-20 09:08:23 -04:00
Justin Ridgewell
5f866f2d92 Hoist toSequenceExpression's convert helper (#5693)
* Hoist toSequenceExpression's convert helper

* Adds tests

* lint

* dev-depend on babel-generator
2017-05-19 17:03:33 -04:00
Samuel Reed
3570ba7c28 Fix PathHoister error attaching after export declarations.
Fixes #5369.

See also 4ee385e96c/packages/babel-plugin-transform-class-properties/src/index.js (L167)
2017-05-01 14:22:38 -07:00
Sebastian McKenzie
60adcd68a0 Port flow object spread from #418 to 6.x (#5653)
* Add support for object type spread

* Type spread: remove variance and add stripping test

* Fix tests
2017-04-26 17:16:38 -04:00
ssuman
412180e203 Increase the code coverage for traverse evaluation (#5363)
* When applied this commit will increase the code coverage for evaluation.js

* Fixing linting issues
2017-04-09 16:49:37 -07:00
Jan Kassens
a1a795321a Update deprecation warning on flow bindings (#5615)
Babel 6 is at 6.24, doesn't seem like this is getting removed in version 6 anymore.
2017-04-09 16:11:06 -07:00
Brian Ng
11b7db05fb Merge pull request #5613 from babel/backport-doc-changes
Backport doc changes
2017-04-08 09:08:47 -05:00
Sven SAULEAU
ca435b6d48 Improve options documentation for babel-plugin-transform-runtime #5401 2017-04-08 10:18:44 +02:00
Sven SAULEAU
982aba38e4 [doc] Fix: comments in usage w/ options #5400 2017-04-08 10:18:01 +02:00
Sven SAULEAU
c1b3740707 document cache option for babel-register #5440 2017-04-08 10:16:55 +02:00
Sven SAULEAU
e9bc213b14 Update coffescript/register reference link address #5475 2017-04-08 10:15:43 +02:00
Sven SAULEAU
e2c2d7d742 Update babel-generator's README #5517 2017-04-08 10:14:56 +02:00
Sven SAULEAU
2cb4d08d19 Improve example of babel-plugin-transform-es2015-arrow-functions #5573 2017-04-08 10:14:19 +02:00
Sven SAULEAU
149acc40bd Remove incorrect docs. #5580 2017-04-08 10:13:47 +02:00
Sven SAULEAU
d40cb31685 Update transform-es2015-modules-commonjs doc #5588 2017-04-08 10:13:20 +02:00
Henry Zhu
f8da5e3457 v6.24.1 2017-04-07 11:19:02 -04:00
MrSpider
fd3a2c285a Fix replacing function declaration in export default (fixes #4468) (#5456) 2017-04-06 11:40:31 -04:00
Henry Zhu
3534bc872d Merge pull request #5567 from aickin/update-regenerator-transform
Update regenerator-transform to new version
2017-04-06 11:18:03 -04:00
Daniel Tschinder
66f8546107 Add test for regression 4219 2017-04-06 15:51:17 +02:00
Felix Yan
9b4c33d44e Fix a typo: occurences -> occurrences (#5575) 2017-04-03 22:38:12 -07:00
Sasha Aickin
60df9f3cad Updating regenerator-transform and adding a test for the issue in facebook/regenerator#267 2017-03-30 22:10:02 -07:00
Artem Yavorsky
f2f226b4f2 Add syntax-object-rest-spread as devDep for tests. 2017-03-23 00:52:10 +02:00
Artem Yavorsky
ddfb6f2c44 Remove object-rest-spread syntax. 2017-03-23 00:33:03 +02:00
Artem Yavorsky
70354013f1 Fix visitor inheritance. 2017-03-19 14:46:59 +02:00
Artem Yavorsky
c42e027602 Add object rest spread syntax using plugin. 2017-03-19 14:02:01 +02:00
Artem Yavorsky
18d6ba9947 Fix export array rest expected output. 2017-03-19 01:18:22 +02:00
Artem Yavorsky
c82b084927 Fix object rest params for exports. 2017-03-19 00:32:27 +02:00
Artem Yavorsky
45b41740d8 Consider default params for object pattern. 2017-03-18 16:26:22 +02:00
Artem Yavorsky
b608e28aa7 Consider rest params for array pattern in exports. 2017-03-18 16:02:06 +02:00
Artem Yavorsky
06f67e1ad3 Consider default parameters for array pattern. 2017-03-18 15:42:39 +02:00
Artem Yavorsky
b5bb89b30a Add array pattern to exports destructuring. 2017-03-18 15:12:46 +02:00
Artem Yavorsky
0c2e3b1045 Remove exports definition. 2017-03-15 16:02:21 +02:00
Artem Yavorsky
9b410be61c Add test for exports destructuring. 2017-03-15 15:37:17 +02:00
Artem Yavorsky
f81d7496b1 Fix exports while destructuring. 2017-03-15 15:35:45 +02:00
1636 changed files with 10852 additions and 3711 deletions

View File

@@ -1,3 +1,4 @@
# Ensure babel-register won't compile fixtures, or try to recompile compiled code.
packages/*/test/fixtures
packages/*/lib
packages/babel-standalone/babel.js

View File

@@ -6,12 +6,28 @@ let envOpts = {
module.exports = {
comments: false,
plugins: [
// temp until next release
function() {
return {
visitor: {
"Function": function(path) {
const node = path.node;
for (let i = 0; i < node.params.length; i++) {
const param = node.params[i];
if (param.type === "AssignmentPattern") {
param.left.optional = false;
}
}
}
}
};
}
],
presets: [
[
"env", envOpts
],
["env", envOpts],
"stage-0",
"flow",
"flow"
],
env: {
cov: {
@@ -21,9 +37,9 @@ module.exports = {
}
};
if (process.env.BABEL_ENV === 'development') {
if (process.env.BABEL_ENV === "development") {
envOpts.targets = {
node: "current"
};
envOpts.debug = true;
};
}

View File

@@ -7,3 +7,9 @@ packages/*/lib
packages/*/dist
packages/*/test/fixtures
packages/*/test/tmp
packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js
# Prettier tries to insert trailing commas in function calls, which Node.js
# doesn't natively support. This causes an error when loading the Gulp tasks.
packages/babel-standalone/src/gulpTasks.js

View File

@@ -13,6 +13,5 @@ lib/types.js
lib/third-party-libs.js.flow
[options]
strip_root=true
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
suppress_comment= \\(.\\|\n\\)*\\$FlowIssue

View File

@@ -2,20 +2,19 @@
Before making a PR please make sure to read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
For any issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR
For any issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. It should be underlined in the preview if done correctly.
-->
| Q | A <!--(yes/no) -->
| Q                       | A <!--(can use an emoji 👍 ) -->
| ------------------------ | ---
| Fixed Issues | `Fixes #1, Fixes #2` <!-- rm the quotes to link the issues -->
| Patch: Bug Fix? |
| Major: Breaking Change? |
| Minor: New Feature? |
| Deprecations? |
| Spec Compliancy? |
| Tests Added/Pass? |
| Fixed Tickets | `Fixes #1, Fixes #2` <!-- rm the quotes to link the issues -->
| Spec Compliancy? |
| License | MIT
| Doc PR | <!-- if yes, add `[skip ci]` to your commit message to skip CI builds -->
| Dependency Changes |
| Doc PR | <!-- if yes, can add `[skip ci]` to your commit message to skip CI builds -->
| Any Dependency Changes? |
<!-- Describe your changes below in as much detail as possible -->

3
.gitignore vendored
View File

@@ -23,6 +23,9 @@ package-lock.json
!/packages/babel-runtime/helpers/es6/toArray.js
/packages/babel-register/test/.babel
/packages/babel-cli/test/tmp
/packages/babel-node/test/tmp
/packages/*/lib
.nyc_output
/babel.sublime-workspace
packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js

View File

@@ -12,9 +12,17 @@ node_js:
- '4'
env:
- JOB=test
global:
- PATH=$HOME/.yarn/bin:$PATH
- JOB=test
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.28.1
script:
# Babel doesn't build correctly with npm v2 (which comes bundled with Node v4)
# so we manually upgrade to a known working npm version.
- npm install --global npm@4
- 'if [ "$JOB" = "test" ]; then make test-ci; fi'
- 'if [ "$JOB" = "lint" ]; then make lint && make flow; fi'

View File

@@ -13,6 +13,93 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
See [CHANGELOG - 6to5](CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
## 6.26.0 (2017-08-16)
> Backports for some folks (also other's when we accidently merged PRs from both 6.x/master)
> Lesson learned: just use `master` and backport on another branch.
#### :eyeglasses: Spec Compliancy
* `babel-core`, `babel-generator`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-traverse`, `babel-types`
* [#6081](https://github.com/babel/babel/pull/6081) Flow opaque type 6.x backport. ([@jbrown215](https://github.com/jbrown215))
#### :rocket: New Feature
* `babel-cli`
* [#5796](https://github.com/babel/babel/pull/5796) Allow --inspect-brk option to be used with babel-node [6.x backport]. ([@noinkling](https://github.com/noinkling))
#### :bug: Bug Fix
* `babel-plugin-transform-es2015-modules-commonjs`
* [#5811](https://github.com/babel/babel/pull/5811) Fix 5768. ([@joshwnj](https://github.com/joshwnj))
* [#5469](https://github.com/babel/babel/pull/5469) Fix commonjs exports with destructuring.. ([@yavorsky](https://github.com/yavorsky))
* `babel-types`
* [#5693](https://github.com/babel/babel/pull/5693) Hoist toSequenceExpression's convert helper. ([@jridgewell](https://github.com/jridgewell))
#### :memo: Documentation
* `babel-plugin-transform-class-properties`
* [#6005](https://github.com/babel/babel/pull/6005) FIX access to the prototype of an instance. ([@shuaibird](https://github.com/shuaibird))
* `babel-plugin-transform-runtime`
* [#5857](https://github.com/babel/babel/pull/5857) Fix typos in README.md. ([@danny-andrews](https://github.com/danny-andrews))
* `babel-plugin-transform-regenerator`
* [#5852](https://github.com/babel/babel/pull/5852) Fix babel-plugin-transform-regenerator README. ([@k15a](https://github.com/k15a))
* Other
* [#5788](https://github.com/babel/babel/pull/5788) Add a section on troubleshooting [skip ci]. ([@peey](https://github.com/peey))
* [#5755](https://github.com/babel/babel/pull/5755) Fix broken tables in README.md. ([@u9lyfish](https://github.com/u9lyfish))
* `babel-generator`, `babel-plugin-transform-es2015-arrow-functions`, `babel-plugin-transform-es2015-modules-commonjs`, `babel-plugin-transform-es2015-spread`, `babel-plugin-transform-runtime`, `babel-register`
* [#5613](https://github.com/babel/babel/pull/5613) Backport doc changes. ([@xtuc](https://github.com/xtuc))
#### :house: Internal
* `babel-traverse`
* [#5965](https://github.com/babel/babel/pull/5965) Remove unused functions from renamer.js.. ([@mcav](https://github.com/mcav))
* [#5363](https://github.com/babel/babel/pull/5363) Increase the code coverage for traverse evaluation. ([@ssuman](https://github.com/ssuman))
* Other
* [#5938](https://github.com/babel/babel/pull/5938) Remove codecov node package and use bash uploader. ([@existentialism](https://github.com/existentialism))
#### Committers: 19
- Artem Yavorsky ([yavorsky](https://github.com/yavorsky))
- Brian Ng ([existentialism](https://github.com/existentialism))
- Danny Andrews ([danny-andrews](https://github.com/danny-andrews))
- Henry Zhu ([hzoo](https://github.com/hzoo))
- Jeffrey Wear ([wearhere](https://github.com/wearhere))
- Jordan Brown ([jbrown215](https://github.com/jbrown215))
- Josh Johnston ([joshwnj](https://github.com/joshwnj))
- Justin Ridgewell ([jridgewell](https://github.com/jridgewell))
- Konstantin Pschera ([k15a](https://github.com/k15a))
- Malcolm ([noinkling](https://github.com/noinkling))
- Marcus Cavanaugh ([mcav](https://github.com/mcav))
- Peeyush Kushwaha ([peey](https://github.com/peey))
- Philipp Friedenberger ([MrSpider](https://github.com/MrSpider))
- Samuel Reed ([STRML](https://github.com/STRML))
- Shuaibird Hwang ([shuaibird](https://github.com/shuaibird))
- Suman ([ssuman](https://github.com/ssuman))
- Sven SAULEAU ([xtuc](https://github.com/xtuc))
- jonathan schatz ([modosc](https://github.com/modosc))
- u9lyfish@gmail.com ([u9lyfish](https://github.com/u9lyfish))
## 6.25.0 (2017-06-08)
Just backporting a few things.
#### :rocket: New Feature
* `babel-plugin-transform-react-display-name`
* [#5780](https://github.com/babel/babel/pull/5780) Backport support for createReactClass with transform-react-display-name. ([@kentor](https://github.com/kentor))
* [#5554](https://github.com/babel/babel/pull/5554) Updated transform-react-display-name for createReactClass addon. ([@bvaughn](https://github.com/bvaughn))
* `babel-generator`, `babel-plugin-transform-flow-strip-types`, `babel-types`
* [#5653](https://github.com/babel/babel/pull/5653) Port flow object spread from #418 to 6.x. ([@kittens](https://github.com/kittens))
#### :bug: Bug Fix
* `babel-types`
* [#5770](https://github.com/babel/babel/pull/5770) Backport array & object pattern fixes to 6.x. ([@citycide](https://github.com/citycide))
#### :nail_care: Polish
* `babel-traverse`
* [#5615](https://github.com/babel/babel/pull/5615) Update deprecation warning on flow bindings. ([@kassens](https://github.com/kassens))
#### Committers: 5
- Bo Lingen ([citycide](https://github.com/citycide))
- Brian Vaughn ([bvaughn](https://github.com/bvaughn))
- Jan Kassens ([kassens](https://github.com/kassens))
- Kenneth Chung ([kentor](https://github.com/kentor))
- Sebastian McKenzie ([kittens](https://github.com/kittens))
## 6.24.0 (2017-03-13)
A quick release for 2 features:
@@ -263,7 +350,7 @@ New/Expected Behavior
```js
const _ref = foo(); // should only be called once
const { x } = _ref;
const { x } = _ref;
const y = _objectWithoutProperties(_ref, ["x"]);
```
@@ -279,7 +366,7 @@ function fn({a = 1, ...b} = {}) {
return {a, b};
}
```
* `babel-plugin-transform-es2015-destructuring`
* [#5093](https://github.com/babel/babel/pull/5093) Ensure array is always copied during destructure. ([@existentialism](https://github.com/existentialism))
@@ -293,7 +380,7 @@ const arr = [1, 2, 3]
assign(arr, 1, 42)
console.log(arr) // [1, 2, 3]
```
* `babel-plugin-transform-es2015-function-name`
* [#5008](https://github.com/babel/babel/pull/5008) Don't try to visit ArrowFunctionExpression, they cannot be named. ([@Kovensky](https://github.com/Kovensky))
@@ -308,9 +395,9 @@ Output
```js
export const x = ({ x }) => x;
export const y = function y() {};
export const y = function y() {};
```
* `babel-types`
* [#5068](https://github.com/babel/babel/pull/5068) Fix getBindingIdentifiers in babel-types. ([@rtsao](https://github.com/rtsao))
* `babel-cli`
@@ -460,7 +547,7 @@ Will still error with `Spread children are not supported.`
```js
<div>{...this.props.children}</div>;
```
* `babel-plugin-transform-es2015-block-scoping`, `babel-plugin-transform-react-constant-elements`, `babel-traverse`
* [#4940](https://github.com/babel/babel/pull/4940) Fix React constant element bugs. ([@appden](https://github.com/appden))
@@ -469,7 +556,7 @@ When multiple declarators are present in a declaration, we want to insert the co
```js
function render() {
const bar = "bar", renderFoo = () => <foo bar={bar} baz={baz} />, baz = "baz";
return renderFoo();
}
```
@@ -480,12 +567,12 @@ When block scoped variables caused the block to be wrapped in a closure, the var
function render(flag) {
if (flag) {
let bar = "bar";
[].map(() => bar);
return <foo bar={bar} />;
}
return null;
}
```
@@ -526,7 +613,7 @@ for (let a of b) {
* [#4999](https://github.com/babel/babel/pull/4999) babel-helper-transform-fixture-test-runner: pass require as a global. ([@hzoo](https://github.com/hzoo))
Allows running `require()` in exec.js tests like for [babel/babel-preset-env#95](https://github.com/babel/babel-preset-env/pull/95)
* Other
* [#5005](https://github.com/babel/babel/pull/5005) internal: don't run watch with the test env (skip building with code …. ([@hzoo](https://github.com/hzoo))
@@ -648,8 +735,8 @@ try {
return x;
};
}
```
```
* `babel-helper-remap-async-to-generator`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-async-to-generator`
* [#4901](https://github.com/babel/babel/pull/4901) Only base async fn arity on non-default/non-rest params - Closes [#4891](https://github.com/babel/babel/issues/4891). ([@loganfsmyth](https://github.com/loganfsmyth))
@@ -660,7 +747,7 @@ console.log(foo.length) // 0
const asyncFoo = async (...args) => { }
console.log(asyncFoo.length) // 0
```
* `babel-generator`, `babel-types`
* [#4945](https://github.com/babel/babel/pull/4945) Add `babel-generator` support for `Import`. ([@TheLarkInn](https://github.com/TheLarkInn))
@@ -669,14 +756,14 @@ console.log(asyncFoo.length) // 0
```js
import("module.js");
```
* `babel-plugin-transform-object-rest-spread`
* [#4883](https://github.com/babel/babel/pull/4883) Fix for object-rest with parameters destructuring nested rest. ([@christophehurpeau](https://github.com/christophehurpeau))
```js
function a5({a3, b2: { ba1, ...ba2 }, ...c3}) {}
```
```
* `babel-traverse`
* [#4875](https://github.com/babel/babel/pull/4875) Fix `path.evaluate` for references before declarations. ([@boopathi](https://github.com/boopathi))
@@ -981,7 +1068,7 @@ function render(_ref) {
- Scott Stern ([sstern6](https://github.com/sstern6))
- Shine Wang ([shinew](https://github.com/shinew))
- lion ([lion-man44](https://github.com/lion-man44))
## v6.18.2 (2016-11-01)
Weird publishing issue with v6.18.1, same release.
@@ -1666,7 +1753,7 @@ export default {
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-transform-es2015-typeof-symbol`
* [#3686](https://github.com/babel/babel/pull/3686) Fix `typeof Symbol.prototype`. ([@brainlock](https://github.com/brainlock))
```js
// `typeof Symbol.prototype` should be 'object'
typeof Symbol.prototype === 'object'
@@ -1675,7 +1762,7 @@ typeof Symbol.prototype === 'object'
* `babel-cli`
* [#3456](https://github.com/babel/babel/pull/3456) Use the real sourcemap API and handle input sourcemaps - Fixes [#7259](https://github.com/babel/babel/issues/7259). ([@loganfsmyth](https://github.com/loganfsmyth))
* [#4507](https://github.com/babel/babel/pull/4507) Only set options in cli if different from default. ([@danez](https://github.com/danez))
Fix an issue with defaults not being overidden. This was causing options like `comments: false` not to work correctly.
* [#4508](https://github.com/babel/babel/pull/4508) Support custom ports for V8 --inspect. ([@andykant](https://github.com/andykant))
@@ -1730,7 +1817,7 @@ We noticed that we can not make this optimizations if there are function calls o
// was tranforming to
x = a();
y = obj.x;
// now transforms to
// now transforms to
var _ref = [a(), obj.x];
x = _ref[0];
y = _ref[1];
@@ -1796,7 +1883,7 @@ Cleanup tests, remove various unused dependencies, do not run CI with only readm
#### Commiters: 20
First PRs!
- Alberto Piai ([brainlock](https://github.com/brainlock))
- Alberto Piai ([brainlock](https://github.com/brainlock))
- Andy Kant ([andykant](https://github.com/andykant))
- Basil Hosmer ([bhosmer](https://github.com/bhosmer))
- Bo Borgerson ([gigabo](https://github.com/gigabo))
@@ -1879,7 +1966,7 @@ npm install babel-preset-latest --save-dev
{ "presets": [
["latest", {
"es2015": {
"modules": false
"modules": false
}
}]
] }
@@ -2117,7 +2204,7 @@ Can be `false` to not transform modules, or one of `["amd", "umd", "systemjs", "
## v6.11.5 (2016-07-23)
Thanks to Rob Eisenberg ([EisenbergEffect](https://github.com/EisenbergEffect)), Keyan Zhang ([keyanzhang](https://github.com/keyanzhang)), Rolf Timmermans ([rolftimmermans](https://github.com/rolftimmermans)), Thomas Grainger ([graingert](https://github.com/graingert)),
Thanks to Rob Eisenberg ([EisenbergEffect](https://github.com/EisenbergEffect)), Keyan Zhang ([keyanzhang](https://github.com/keyanzhang)), Rolf Timmermans ([rolftimmermans](https://github.com/rolftimmermans)), Thomas Grainger ([graingert](https://github.com/graingert)),
we have few fixes: fix `babel-register` file paths on error, infer class name for classes with class properties, fix `export *` to account for previously compiled modules.
@@ -2165,7 +2252,7 @@ In this release among other things are some more optimizations for babel-generat
## v6.11.3 (2016-07-13)
The main fix is @loganfsmyth's changes of some parts in babel-generator in [#3565](https://github.com/babel/babel/pull/3565) to fix issues with exponential code generation times in certain cases.
The main fix is @loganfsmyth's changes of some parts in babel-generator in [#3565](https://github.com/babel/babel/pull/3565) to fix issues with exponential code generation times in certain cases.
Items: the size of the array being generated
Time: The time in ms to generate the code

View File

@@ -31,6 +31,8 @@ Contributions are always welcome, no matter how large or small.
- Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin!
- Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser
- When you feel ready to jump into the Babel source code, a good place to start is to look for issues tagged with [help-wanted](https://github.com/babel/babel/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) and/or [beginner-friendly](https://github.com/babel/babel/issues?q=is%3Aissue+is%3Aopen+label%3A%22beginner-friendly%22).
- Follow along with what we are working on by joining our Slack, following our annoucements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes).
- Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website)
## Chat
@@ -40,11 +42,9 @@ Feel free to check out the `#discussion`/`#development` channels on our [Slack](
**Note:** Versions `< 5.1.10` can't be built.
Babel is built for Node.js 4 and up but we develop using Node.js 6. Make sure you are on npm 3.
Babel is built for Node 4 and up but we develop using Node 8 and yarn. You can check this with `node -v`.
You can check this with `node -v` and `npm -v`.
In addition, make sure that Yarn is installed.
Make sure that Yarn is installed with version >= `0.28.0`.
Installation instructions can be found here: https://yarnpkg.com/en/docs/install.
### Setup
@@ -114,12 +114,25 @@ To run tests for a specific package in [packages](https://github.com/babel/babel
$ TEST_ONLY=babel-cli make test
```
`TEST_ONLY` will also match substrings of the package name:
```sh
# Run tests for the babel-plugin-transform-es2015-classes package.
$ TEST_ONLY=es2015-class make test
```
Use the `TEST_GREP` variable to run a subset of tests by name:
```sh
$ TEST_GREP=transformation make test
```
Substitute spaces for hyphens and forward slashes when targeting specific test names:
```sh
$ TEST_GREP="arrow functions destructuring parameters" make test
```
To enable the Node.js debugger added in v6.3.0, set the `TEST_DEBUG` environment variable:
```sh
@@ -138,15 +151,15 @@ $ ./scripts/test-cov.sh
#### Troubleshooting Tests
In case you're not able to reproduce an error on CI locally, it may be due to
In case you're not able to reproduce an error on CI locally, it may be due to
- Node Version: Travis CI runs the tests against all major node versions. If your tests use JavaScript features unsupported by lower versions of node, then use [minNodeVersion option](#writing-tests) in options.json.
- Timeout: Check the CI log and if the only errors are timeout errors and you are sure that it's not related to the changes you made, ask someone in the slack channel to trigger rebuild on the CI build and it might be resolved
In case you're locally getting errors which are not on the CI, it may be due to
- Updates in Dependencies: Make sure you run `make bootstrap` before you run `make build` or `make watch` before you run the tests.
### Writing tests
Most packages in [`/packages`](https://github.com/babel/babel/tree/master/packages) have a `test` folder, however some tests might be in other packages or in [`/packages/babel-core`](https://github.com/babel/babel/tree/master/packages/babel-core/test/fixtures).
@@ -261,7 +274,7 @@ To start the debugging in Chrome DevTools, open the given URL.
The debugger starts at the first executed line of code, which is Mocha's first line by default.
Click _Resume script execution_ <img src="https://i.imgur.com/TmYBn9d.png" alt="Resume script execution button." width="16"> to jump to the set breakpoint.
Note that the code shown in Chrome DevTools is compiled code and therefore differs.
## Internals
- AST spec ([babylon/ast/spec.md](https://github.com/babel/babylon/blob/master/ast/spec.md))
- Versioning ([doc/design/versioning.md](https://github.com/babel/babel/blob/master/doc/design/versioning.md)

View File

@@ -8,7 +8,14 @@ export FORCE_COLOR = true
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
build: clean
rm -rf packages/*/lib
./node_modules/.bin/gulp build
ifneq ($(BABEL_ENV), "cov")
make build-standalone
endif
build-standalone:
./node_modules/.bin/gulp build-babel-standalone --cwd=packages/babel-standalone/
build-dist: build
cd packages/babel-polyfill; \
@@ -22,13 +29,13 @@ watch: clean
BABEL_ENV=development ./node_modules/.bin/gulp watch
lint:
./node_modules/.bin/eslint scripts packages *.js --format=codeframe
./node_modules/.bin/eslint scripts packages *.js --format=codeframe --rulesdir="./eslint_rules"
flow:
./node_modules/.bin/flow check
./node_modules/.bin/flow check --strip-root
fix:
./node_modules/.bin/eslint scripts packages *.js --format=codeframe --fix
./node_modules/.bin/eslint scripts packages *.js --format=codeframe --fix --rulesdir="./eslint_rules"
clean: test-clean
rm -rf packages/babel-polyfill/browser*

View File

@@ -77,7 +77,7 @@ https://phabricator.babeljs.io/T2168 mostly corresponds to https://github.com/ba
## Want to report an issue with [babeljs.io](https://babeljs.io) (the website)?
For documentation and website issues please visit the [babel/babel.github.io](https://github.com/babel/babel.github.io) repo.
For documentation and website issues please visit the [babel/website](https://github.com/babel/website) repo.
## Want to contribute to Babel?
@@ -86,6 +86,7 @@ Check out our [CONTRIBUTING.md](https://github.com/babel/babel/blob/master/CONTR
You can also start by checking out the issues with the [help-wanted](https://github.com/babel/babel/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) label.
Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals)
## Packages

View File

@@ -1,11 +1,17 @@
general:
artifacts:
- "packages/babel-standalone/babel.js"
- "packages/babel-standalone/babel.min.js"
machine:
node:
version:
6
8
dependencies:
pre:
- curl -o- -L https://yarnpkg.com/install.sh | bash
# Version number can be removed once 0.28.x or higher is released as stable
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.28.4
cache_directories:
- ~/.yarn-cache
override:
@@ -14,3 +20,9 @@ dependencies:
test:
override:
- make test-ci-coverage
# Builds babel-standalone with the regular Babel config
- make build
# test-ci-coverage doesn't test babel-standalone, as trying to gather coverage
# data for a JS file that's several megabytes large is bound to fail. Here,
# we just run the babel-standalone test separately.
- ./node_modules/mocha/bin/_mocha packages/babel-standalone/test/ --opts test/mocha.opts

View File

@@ -0,0 +1,46 @@
"use strict";
function argumentsIsUndefinedString(argumentsArray) {
return (
argumentsArray.length === 1 &&
argumentsArray[0].type === "Literal" &&
argumentsArray[0].value === "undefined"
);
}
module.exports = {
meta: {
schema: [],
},
create: function(context) {
if (context.getFilename().indexOf("packages/babel-plugin-") === -1) {
return {};
}
return {
CallExpression: function(node) {
const callee = node.callee;
if (
callee.type === "MemberExpression" &&
argumentsIsUndefinedString(node.arguments)
) {
const object = callee.object,
property = callee.property;
if (
object.type === "Identifier" &&
object.name === "t" &&
property.type === "Identifier" &&
property.name === "identifier"
) {
context.report(
node,
"Use path.scope.buildUndefinedNode() to create an undefined identifier directly."
);
}
}
},
};
},
};

View File

@@ -1,16 +1,16 @@
{
"lerna": "2.0.0-rc.4",
"version": "7.0.0-alpha.16",
"version": "7.0.0-beta.0",
"changelog": {
"repo": "babel/babel",
"labels": {
"tag: spec compliancy": ":eyeglasses: Spec Compliancy",
"tag: breaking change": ":boom: Breaking Change",
"tag: new feature": ":rocket: New Feature",
"tag: bug fix": ":bug: Bug Fix",
"tag: polish": ":nail_care: Polish",
"tag: documentation": ":memo: Documentation",
"tag: internal": ":house: Internal"
"Tag: Spec Compliancy": ":eyeglasses: Spec Compliancy",
"Tag: Breaking Change": ":boom: Breaking Change",
"Tag: New Feature": ":rocket: New Feature",
"Tag: Bug Fix": ":bug: Bug Fix",
"Tag: Polish": ":nail_care: Polish",
"Tag: Docs": ":memo: Documentation",
"Tag: Internal": ":house: Internal"
}
},
"cacheDir": ".changelog",

File diff suppressed because it is too large Load Diff

View File

@@ -11,39 +11,40 @@
},
"devDependencies": {
"async": "^1.5.0",
"babel-cli": "7.0.0-alpha.15",
"babel-core": "7.0.0-alpha.15",
"babel-cli": "7.0.0-alpha.18",
"babel-core": "7.0.0-alpha.18",
"babel-eslint": "8.0.0-alpha.15",
"babel-plugin-istanbul": "^4.1.4",
"babel-preset-env": "2.0.0-alpha.15",
"babel-preset-flow": "7.0.0-alpha.15",
"babel-preset-stage-0": "7.0.0-alpha.15",
"babel-register": "7.0.0-alpha.15",
"babel-preset-env": "2.0.0-alpha.18",
"babel-preset-flow": "7.0.0-alpha.18",
"babel-preset-stage-0": "7.0.0-alpha.18",
"babel-register": "7.0.0-alpha.18",
"babylon": "7.0.0-beta.22",
"browserify": "^13.1.1",
"bundle-collapser": "^1.2.1",
"chai": "^4.1.0",
"chalk": "^2.0.0",
"derequire": "^2.0.2",
"eslint": "^3.14.1",
"eslint-config-babel": "^7.0.1",
"eslint": "^4.5.0",
"eslint-config-babel": "^7.0.2",
"eslint-plugin-flowtype": "^2.20.0",
"eslint-plugin-prettier": "^2.1.2",
"flow-bin": "^0.41.0",
"eslint-plugin-prettier": "^2.2.0",
"flow-bin": "^0.53.1",
"gulp": "^3.9.0",
"gulp-babel": "babel/gulp-babel#b7-alpha",
"gulp-babel": "^7.0.0",
"gulp-newer": "^1.0.0",
"gulp-plumber": "^1.0.1",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.5",
"husky": "^0.13.2",
"lerna": "2.0.0-rc.4",
"lerna-changelog": "^0.2.0",
"lint-staged": "^3.6.1",
"husky": "^0.14.3",
"lerna": "2.0.0",
"lerna-changelog": "^0.5.0",
"lint-staged": "^4.0.4",
"lodash": "^4.2.0",
"mocha": "^3.0.0",
"nyc": "^11.0.3",
"output-file-sync": "^2.0.0",
"prettier": "^1.5.0",
"prettier": "^1.6.1",
"rimraf": "^2.4.3",
"semver": "^5.0.0",
"through2": "^2.0.0",
@@ -51,21 +52,22 @@
},
"engines": {
"node": ">= 4.x <= 8.x",
"npm": ">= 2.x <= 5.x"
"npm": ">= 2.x <= 5.x",
"yarn": ">=0.27.5 || >=1.0.0-20170811"
},
"nyc": {
"all": true,
"exclude": [
"scripts/*.js",
"packages/*/test/**"
"packages/*/test/**",
"packages/babel-standalone/**"
],
"sourceMap": false,
"instrument": false
},
"lint-staged": {
"*.js": [
"eslint --format=codeframe --fix",
"git add"
"eslint --format=codeframe --rulesdir='./eslint_rules'"
]
}
}

View File

@@ -1,5 +1,6 @@
{
"rules": {
"prettier/prettier": ["error", { "trailingComma": "all" }]
"prettier/prettier": ["error", { "trailingComma": "all" }],
"no-undefined-identifier": 2
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "babel-cli",
"version": "7.0.0-alpha.16",
"version": "7.0.0-beta.0",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -16,9 +16,9 @@
"compiler"
],
"dependencies": {
"babel-core": "7.0.0-alpha.16",
"babel-polyfill": "7.0.0-alpha.16",
"babel-register": "7.0.0-alpha.16",
"babel-core": "7.0.0-beta.0",
"babel-polyfill": "7.0.0-beta.0",
"babel-register": "7.0.0-beta.0",
"commander": "^2.8.1",
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.0.0",
@@ -33,7 +33,7 @@
"chokidar": "^1.6.1"
},
"devDependencies": {
"babel-helper-fixtures": "7.0.0-alpha.16"
"babel-helper-fixtures": "7.0.0-beta.0"
},
"bin": {
"babel-doctor": "./bin/babel-doctor.js",

View File

@@ -54,6 +54,10 @@ getV8Flags(function(err, v8Flags) {
args.unshift("--expose-gc");
break;
case "--expose-http2":
args.unshift("--expose-http2");
break;
case "--nolazy":
args.unshift(flag);
break;

View File

@@ -7,15 +7,15 @@ import fs from "fs";
import * as util from "./util";
export default function(commander, filenames, opts) {
function write(src, relative) {
function write(src, relative, base) {
if (!util.isCompilableExtension(relative, commander.extensions)) {
return false;
}
// remove extension and then append back on .js
relative = relative.replace(/\.(\w*?)$/, "") + ".js";
relative = util.adjustRelative(relative, commander.keepFileExtension);
const dest = path.join(commander.outDir, relative);
const dest = getDest(commander, relative, base);
const data = util.compile(
src,
@@ -45,11 +45,16 @@ export default function(commander, filenames, opts) {
return true;
}
function handleFile(src, filename) {
const didWrite = write(src, filename);
function getDest(commander, filename, base) {
if (commander.relative) return path.join(base, commander.outDir, filename);
return path.join(commander.outDir, filename);
}
function handleFile(src, filename, base) {
const didWrite = write(src, filename, base);
if (!didWrite && commander.copyFiles) {
const dest = path.join(commander.outDir, filename);
const dest = getDest(commander, filename, base);
outputFileSync(dest, fs.readFileSync(src));
util.chmod(src, dest);
}
@@ -63,12 +68,15 @@ export default function(commander, filenames, opts) {
if (stat.isDirectory(filename)) {
const dirname = filename;
if (commander.deleteDirOnStart) {
util.deleteDir(commander.outDir);
}
util.readdir(dirname).forEach(function(filename) {
const src = path.join(dirname, filename);
handleFile(src, filename);
handleFile(src, filename, dirname);
});
} else {
write(filename, filename);
write(filename, path.basename(filename), path.dirname(filename));
}
}

View File

@@ -48,6 +48,7 @@ commander.option(
"comma-separated list of plugin names",
collect,
);
commander.option("--config-file [path]", "Path a to .babelrc file to use");
// Basic file input configuration.
commander.option("--source-type [script|module]", "");
@@ -128,6 +129,10 @@ commander.option(
"List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx,.mjs]",
collect,
);
commander.option(
"--keep-file-extension",
"Preserve the file extensions of the input files",
);
commander.option("-w, --watch", "Recompile files on changes");
commander.option(
"--skip-initial-build",
@@ -141,11 +146,19 @@ commander.option(
"-d, --out-dir [out]",
"Compile an input directory of modules into an output directory",
);
commander.option(
"--relative",
"Compile into an output directory relative to input directory or file. Requires --out-dir [out]",
);
commander.option(
"-D, --copy-files",
"When compiling a directory copy over non-compilable files",
);
commander.option("-q, --quiet", "Don't log anything");
commander.option(
"--delete-dir-on-start",
"Delete's the out directory before compilation",
);
/* eslint-enable max-len */
commander.version(pkg.version + " (babel-core " + version + ")");
@@ -178,6 +191,10 @@ if (commander.outFile && commander.outDir) {
errors.push("cannot have --out-file and --out-dir");
}
if (commander.relative && !commander.outDir) {
errors.push("output directory required for --relative");
}
if (commander.watch) {
if (!commander.outFile && !commander.outDir) {
errors.push("--watch requires --out-file or --out-dir");
@@ -191,6 +208,9 @@ if (commander.watch) {
if (commander.skipInitialBuild && !commander.watch) {
errors.push("--skip-initial-build requires --watch");
}
if (commander.deleteDirOnStart && !commander.outDir) {
errors.push("--delete-dir-on-start requires --out-dir");
}
if (errors.length) {
console.error(errors.join(". "));
@@ -200,6 +220,10 @@ if (errors.length) {
//
const opts = commander.opts();
//the configFile CLI option maps to the extends option in the node API
if (opts.configFile) {
opts.extends = opts.configFile;
}
// Delete options that are specific to babel-cli and shouldn't be passed to babel-core.
delete opts.version;
@@ -210,6 +234,9 @@ delete opts.outFile;
delete opts.outDir;
delete opts.copyFiles;
delete opts.quiet;
delete opts.configFile;
delete opts.deleteDirOnStart;
delete opts.keepFileExtension;
// Commander will default the "--no-" arguments to true, but we want to leave them undefined so that
// babel-core can handle the default-assignment logic on its own.

View File

@@ -58,6 +58,22 @@ export function compile(filename, opts) {
}
}
export function deleteDir(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file) {
const curPath = path + "/" + file;
if (fs.lstatSync(curPath).isDirectory()) {
// recurse
deleteDir(curPath);
} else {
// delete file
fs.unlinkSync(curPath);
}
});
fs.rmdirSync(path);
}
}
function toErrorStack(err) {
if (err._babel && err instanceof SyntaxError) {
return `${err.name}: ${err.message}\n${err.codeFrame}`;
@@ -82,3 +98,10 @@ export function requireChokidar() {
throw err;
}
}
export function adjustRelative(relative, keepFileExtension) {
if (keepFileExtension) {
return relative;
}
return relative.replace(/\.(\w*?)$/, "") + ".js";
}

View File

@@ -0,0 +1,3 @@
{
"comments": false
}

View File

@@ -0,0 +1,3 @@
{
"args": ["--config-file", "../.othername_babelrc"]
}

View File

@@ -0,0 +1,7 @@
/*
Test comment
*/
arr.map(x => x * MULTIPLIER);
// END OF FILE

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,3 @@
{
"args": ["src", "--out-dir", "lib", "--copy-files"]
}

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1 @@
src/foo.js -> lib/foo.js

View File

@@ -0,0 +1 @@
arr.map(x => x / DIVIDER);

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,3 @@
{
"args": ["src", "--out-dir", "lib", "--keep-file-extension"]
}

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x / DIVIDER;
});

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1,2 @@
src/bar.mjs -> lib/bar.mjs
src/foo.js -> lib/foo.js

View File

@@ -0,0 +1,3 @@
class Test1 {
}

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,3 @@
class Test2 {
}

View File

@@ -0,0 +1 @@
arr.map(x => x / DIVIDER);

View File

@@ -0,0 +1,3 @@
{
"args": ["**/src", "--out-dir", "../lib", "--relative"]
}

View File

@@ -0,0 +1,7 @@
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test1 = function Test1() {
_classCallCheck(this, Test1);
};

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1,7 @@
"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Test2 = function Test2() {
_classCallCheck(this, Test2);
};

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x / DIVIDER;
});

View File

@@ -0,0 +1,4 @@
package1/src/bar/bar1.js -> package1/lib/bar/bar1.js
package1/src/foo1.js -> package1/lib/foo1.js
package2/src/bar/bar2.js -> package2/lib/bar/bar2.js
package2/src/foo2.js -> package2/lib/foo2.js

View File

@@ -0,0 +1,4 @@
{
"args": ["--out-dir", "lib"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
filenames required for --out-dir

View File

@@ -0,0 +1,4 @@
{
"args": ["--out-dir", "lib", "--out-file", "foo.js"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
cannot have --out-file and --out-dir

View File

@@ -0,0 +1,4 @@
{
"args": ["--relative"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
output directory required for --relative

View File

@@ -0,0 +1,4 @@
{
"args": ["--skip-initial-build"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
--skip-initial-build requires --watch

View File

@@ -0,0 +1,4 @@
{
"args": ["--watch"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
--watch requires filenames

View File

@@ -0,0 +1,4 @@
{
"args": ["--watch"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
--watch requires --out-file or --out-dir

View File

@@ -0,0 +1,4 @@
{
"args": ["foo.json"],
"stderrContains": true
}

View File

@@ -0,0 +1 @@
foo.json doesn't exist

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,3 @@
{
"args": ["src/foo.js", "--out-dir", "../lib", "--relative"]
}

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1 @@
src/foo.js -> lib/foo.js

View File

@@ -0,0 +1 @@
arr.map(x => x * MULTIPLIER);

View File

@@ -0,0 +1,3 @@
{
"args": ["src/foo.js", "--out-dir", "lib"]
}

View File

@@ -0,0 +1,5 @@
"use strict";
arr.map(function (x) {
return x * MULTIPLIER;
});

View File

@@ -0,0 +1 @@
src/foo.js -> lib/foo.js

View File

@@ -1,6 +1,6 @@
{
"name": "babel-code-frame",
"version": "7.0.0-alpha.16",
"version": "7.0.0-beta.0",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",

View File

@@ -51,7 +51,7 @@ const JSX_TAG = /^[a-z][\w-]*$/i;
* RegExp to test for the three types of brackets.
*/
const BRACKET = /^[()\[\]{}]$/;
const BRACKET = /^[()[\]{}]$/;
/**
* Get the type of token, specifying punctuator type.
@@ -94,7 +94,10 @@ function highlight(defs: Object, text: string) {
const type = getTokenType(args);
const colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
return args[0]
.split(NEWLINE)
.map(str => colorize(str))
.join("\n");
} else {
return args[0];
}

View File

@@ -1,6 +1,6 @@
{
"name": "babel-core",
"version": "7.0.0-alpha.16",
"version": "7.0.0-beta.0",
"description": "Babel compiler core.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -25,16 +25,16 @@
"./lib/config/loading/files/index.js": "./lib/config/loading/files/index-browser.js"
},
"dependencies": {
"babel-code-frame": "7.0.0-alpha.16",
"babel-generator": "7.0.0-alpha.16",
"babel-helpers": "7.0.0-alpha.16",
"babel-messages": "7.0.0-alpha.16",
"babel-template": "7.0.0-alpha.16",
"babel-traverse": "7.0.0-alpha.16",
"babel-types": "7.0.0-alpha.16",
"babylon": "7.0.0-beta.17",
"babel-code-frame": "7.0.0-beta.0",
"babel-generator": "7.0.0-beta.0",
"babel-helpers": "7.0.0-beta.0",
"babel-messages": "7.0.0-beta.0",
"babel-template": "7.0.0-beta.0",
"babel-traverse": "7.0.0-beta.0",
"babel-types": "7.0.0-beta.0",
"babylon": "7.0.0-beta.22",
"convert-source-map": "^1.1.0",
"debug": "^2.1.1",
"debug": "^3.0.1",
"json5": "^0.5.0",
"lodash": "^4.2.0",
"micromatch": "^2.3.11",
@@ -42,7 +42,7 @@
"source-map": "^0.5.0"
},
"devDependencies": {
"babel-helper-transform-fixture-test-runner": "7.0.0-alpha.16",
"babel-register": "7.0.0-alpha.16"
"babel-helper-transform-fixture-test-runner": "7.0.0-beta.0",
"babel-register": "7.0.0-beta.0"
}
}

View File

@@ -3,6 +3,9 @@
import { getEnv } from "./helpers/environment";
import path from "path";
import micromatch from "micromatch";
import buildDebug from "debug";
const debug = buildDebug("babel:config:config-chain");
import { findConfigs, loadConfig } from "./loading/files";
@@ -67,7 +70,15 @@ class ConfigChainBuilder {
);
}
if (this.matchesPatterns(ignore, dirname)) return true;
if (this.matchesPatterns(ignore, dirname)) {
debug(
"Ignored %o because it matched one of %O from %o",
this.filename,
ignore,
dirname,
);
return true;
}
}
if (only) {
@@ -77,7 +88,15 @@ class ConfigChainBuilder {
);
}
if (!this.matchesPatterns(only, dirname)) return true;
if (!this.matchesPatterns(only, dirname)) {
debug(
"Ignored %o because it failed to match one of %O from %o",
this.filename,
only,
dirname,
);
return true;
}
}
return false;

View File

@@ -1,5 +1,6 @@
// @flow
import buildDebug from "debug";
import path from "path";
import fs from "fs";
import json5 from "json5";
@@ -7,6 +8,8 @@ import resolve from "resolve";
import { getEnv } from "../../helpers/environment";
import { makeStrongCache } from "../../caching";
const debug = buildDebug("babel:config:loading:files:configuration");
type ConfigFile = {
filepath: string,
dirname: string,
@@ -31,6 +34,7 @@ export function findConfigs(dirname: string): Array<ConfigFile> {
const ignore = readIgnoreConfig(ignoreLoc);
if (ignore) {
debug("Found ignore %o from %o.", ignore.filepath, dirname);
confs.push(ignore);
foundIgnore = true;
}
@@ -57,6 +61,7 @@ export function findConfigs(dirname: string): Array<ConfigFile> {
}, null);
if (conf) {
debug("Found configuration %o from %o.", conf.filepath, dirname);
confs.push(conf);
foundConfig = true;
}
@@ -80,6 +85,7 @@ export function loadConfig(name: string, dirname: string): ConfigFile {
throw new Error(`Config file ${filepath} contains no configuration data`);
}
debug("Loaded config %o from $o.", name, dirname);
return conf;
}
@@ -93,14 +99,31 @@ function readConfig(filepath) {
: readConfigFile(filepath);
}
const LOADING_CONFIGS = new Set();
const readConfigJS = makeStrongCache((filepath, cache) => {
if (!fs.existsSync(filepath)) {
cache.forever();
return null;
}
// The `require()` call below can make this code reentrant if a require hook like babel-register has been
// loaded into the system. That would cause Babel to attempt to compile the `.babelrc.js` file as it loads
// below. To cover this case, we auto-ignore re-entrant config processing.
if (LOADING_CONFIGS.has(filepath)) {
cache.never();
debug("Auto-ignoring usage of config %o.", filepath);
return {
filepath,
dirname: path.dirname(filepath),
options: {},
};
}
let options;
try {
LOADING_CONFIGS.add(filepath);
// $FlowIssue
const configModule = (require(filepath): mixed);
options =
@@ -110,6 +133,8 @@ const readConfigJS = makeStrongCache((filepath, cache) => {
} catch (err) {
err.message = `${filepath}: Error while loading config - ${err.message}`;
throw err;
} finally {
LOADING_CONFIGS.delete(filepath);
}
if (typeof options === "function") {

View File

@@ -4,16 +4,19 @@
* This file handles all logic for converting string-based configuration references into loaded objects.
*/
import buildDebug from "debug";
import resolve from "resolve";
import path from "path";
const debug = buildDebug("babel:config:loading:files:plugins");
const EXACT_RE = /^module:/;
const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/\/]+[/\/]|babel-plugin-)/;
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/\/]+[/\/]|babel-preset-)/;
const BABEL_PLUGIN_ORG_RE = /^(@babel[/\/])(?!plugin-|[^/\/]+[/\/])/;
const BABEL_PRESET_ORG_RE = /^(@babel[/\/])(?!preset-|[^/\/]+[/\/])/;
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel[/\/])[^/\/]+[/\/])(?!babel-plugin-|[^/\/]+[/\/])/;
const OTHER_PRESET_ORG_RE = /^(@(?!babel[/\/])[^/\/]+[/\/])(?!babel-preset-|[^/\/]+[/\/])/;
const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-plugin-|[^/]+\/)/;
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-preset-|[^/]+\/)/;
export function resolvePlugin(name: string, dirname: string): string | null {
return resolveStandardizedName("plugin", name, dirname);
@@ -32,10 +35,10 @@ export function loadPlugin(
throw new Error(`Plugin ${name} not found relative to ${dirname}`);
}
return {
filepath,
value: requireModule(filepath),
};
const value = requireModule("plugin", filepath);
debug("Loaded plugin %o from %o.", name, dirname);
return { filepath, value };
}
export function loadPreset(
@@ -47,10 +50,11 @@ export function loadPreset(
throw new Error(`Preset ${name} not found relative to ${dirname}`);
}
return {
filepath,
value: requireModule(filepath),
};
const value = requireModule("preset", filepath);
debug("Loaded preset %o from %o.", name, dirname);
return { filepath, value };
}
export function loadParser(
@@ -59,7 +63,7 @@ export function loadParser(
): { filepath: string, value: Function } {
const filepath = resolve.sync(name, { basedir: dirname });
const mod = requireModule(filepath);
const mod = requireModule("parser", filepath);
if (!mod) {
throw new Error(
@@ -71,10 +75,13 @@ export function loadParser(
`Parser ${name} relative to ${dirname} does not export a .parse function`,
);
}
const value = mod.parse;
debug("Loaded parser %o from %o.", name, dirname);
return {
filepath,
value: mod.parse,
value,
};
}
@@ -84,7 +91,7 @@ export function loadGenerator(
): { filepath: string, value: Function } {
const filepath = resolve.sync(name, { basedir: dirname });
const mod = requireModule(filepath);
const mod = requireModule("generator", filepath);
if (!mod) {
throw new Error(
@@ -96,10 +103,13 @@ export function loadGenerator(
`Generator ${name} relative to ${dirname} does not export a .print function`,
);
}
const value = mod.print;
debug("Loaded generator %o from %o.", name, dirname);
return {
filepath,
value: mod.print,
value,
};
}
@@ -185,7 +195,20 @@ function resolveStandardizedName(
}
}
function requireModule(name: string): mixed {
// $FlowIssue
return require(name);
const LOADING_MODULES = new Set();
function requireModule(type: string, name: string): mixed {
if (LOADING_MODULES.has(name)) {
throw new Error(
// eslint-disable-next-line max-len
`Reentrant ${type} detected trying to load "${name}". This module is not ignored and is trying to load itself while compiling itself, leading to a dependency cycle. We recommend adding it to your "ignore" list in your babelrc, or to a .babelignore.`,
);
}
try {
LOADING_MODULES.add(name);
// $FlowIssue
return require(name);
} finally {
LOADING_MODULES.delete(name);
}
}

View File

@@ -1,5 +1,3 @@
// @flow
import * as context from "../index";
import Plugin from "./plugin";
import * as messages from "babel-messages";
@@ -27,6 +25,7 @@ type MergeOptions = {
};
const optionNames = new Set([
"relative",
"filename",
"filenameRelative",
"inputSourceMap",

View File

@@ -4,6 +4,8 @@ import * as messages from "babel-messages";
import template from "babel-template";
import * as t from "babel-types";
const keywordHelpers = ["typeof", "extends", "instanceof"];
const buildUmdWrapper = template(`
(function (root, factory) {
if (typeof define === "function" && define.amd) {
@@ -49,6 +51,44 @@ function buildGlobal(namespace, builder) {
return tree;
}
function buildModule(namespace, builder) {
const body = [];
builder(body);
const module = body
.map(helper => {
const originalIdentifier = helper.expression.left.property.name;
const isKeywordHelper = keywordHelpers.indexOf(originalIdentifier) !== -1;
const helperIndentifier = isKeywordHelper
? `_${originalIdentifier}`
: originalIdentifier;
const variableDeclaration = t.variableDeclaration("var", [
t.variableDeclarator(
t.identifier(helperIndentifier),
helper.expression.right,
),
]);
return isKeywordHelper
? variableDeclaration
: t.exportNamedDeclaration(variableDeclaration, []);
})
.concat(
t.exportNamedDeclaration(
null,
keywordHelpers.map(keywordHelper =>
t.exportSpecifier(
t.identifier(`_${keywordHelper}`),
t.identifier(keywordHelper),
),
),
),
);
return t.program(module);
}
function buildUmd(namespace, builder) {
const body = [];
body.push(
@@ -105,7 +145,7 @@ function buildHelpers(body, namespace, whitelist) {
}
export default function(
whitelist?: Array<string>,
outputType: "global" | "umd" | "var" = "global",
outputType: "global" | "module" | "umd" | "var" = "global",
) {
const namespace = t.identifier("babelHelpers");
@@ -117,6 +157,7 @@ export default function(
const build = {
global: buildGlobal,
module: buildModule,
umd: buildUmd,
var: buildVar,
}[outputType];

View File

@@ -180,9 +180,24 @@ export default class File extends Store {
addImport(
source: string,
imported: string,
imported?: string = "",
name?: string = imported,
): Object {
): Object | null {
const prependDeclaration = (
specifiers: Array<BabelNodeImportSpecifier>,
): void => {
const declar = t.importDeclaration(specifiers, t.stringLiteral(source));
declar._blockHoist = 3;
this.path.unshiftContainer("body", declar);
};
// import "module-name";
if (!imported) {
prependDeclaration([]);
return null;
}
const alias = `${source}:${imported}`;
let id = this.dynamicImportIds[alias];
@@ -202,10 +217,7 @@ export default class File extends Store {
specifiers.push(t.importSpecifier(id, t.identifier(imported)));
}
const declar = t.importDeclaration(specifiers, t.stringLiteral(source));
declar._blockHoist = 3;
this.path.unshiftContainer("body", declar);
prependDeclaration(specifiers);
}
return id;

View File

@@ -0,0 +1,30 @@
var res = transform("", {
plugins: [
function (b) {
return {
visitor: {
Program: function(path, state) {
var file = state.file;
file.addImport("import-star", "*", "lib");
file.addImport("import-default", "default", "foo");
file.addImport("import-alias", "bar", "baz");
file.addImport("import-default-alias", "quux");
file.addImport("import-empty", "");
file.addImport("import-none");
}
}
};
}
]
});
var expected = multiline([
'import "import-none";',
'import "import-empty";',
'import { quux as _quux } from "import-default-alias";',
'import { bar as _baz } from "import-alias";',
'import _foo from "import-default";',
'import * as _lib from "import-star";',
]);
assert.equal(res.code, expected);

View File

@@ -1,2 +1,2 @@
export function foo() {}
export function bar() {}
export function bar() {}

View File

@@ -1,4 +1,6 @@
var Foo = function (_Bar) {
var Foo =
/*#__PURE__*/
function (_Bar) {
babelHelpers.inherits(Foo, _Bar);
function Foo(options) {
@@ -13,4 +15,4 @@ var Foo = function (_Bar) {
}
return Foo;
}(Bar);
}(Bar);

View File

@@ -1,4 +1,4 @@
function test() {
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "hi";
return x;
}
}

View File

@@ -29,4 +29,4 @@ class Class {
})();
}
}
}

View File

@@ -7,9 +7,13 @@ Object.defineProperty(exports, "__esModule", {
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var foo = function () {
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee3() {
var _ref2 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3() {
var bar = function () {
var _ref3 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2() {
var _ref3 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2() {
var baz;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
@@ -50,7 +54,9 @@ function _asyncToGenerator(fn) { return function () { var _this = this, _argumen
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Foo = function () {
var Foo =
/*#__PURE__*/
function () {
function Foo() {
_classCallCheck(this, Foo);
}
@@ -58,7 +64,9 @@ var Foo = function () {
_createClass(Foo, [{
key: "bar",
value: function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
var _ref = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var baz;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {

View File

@@ -5,4 +5,4 @@ var _fieldName = fieldName;
value = _values[_fieldName];
rest = babelHelpers.objectWithoutProperties(_values, [_fieldName].map(babelHelpers.toPropertyKey));
_values;
var error = void 0;
var error = void 0;

View File

@@ -1,2 +1,2 @@
#!/usr/bin/env node
foobar();
foobar();

View File

@@ -1,4 +1,6 @@
var Test = function () {
var Test =
/*#__PURE__*/
function () {
function Test() {
babelHelpers.classCallCheck(this, Test);
}

View File

@@ -4,7 +4,7 @@
"column": 10
},
"generated": {
"line": 9,
"line": 11,
"column": 15
}
}]

View File

@@ -1,6 +1,6 @@
{
"name": "babel-generator",
"version": "7.0.0-alpha.16",
"version": "7.0.0-beta.0",
"description": "Turns an AST into code.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -11,15 +11,15 @@
"lib"
],
"dependencies": {
"babel-messages": "7.0.0-alpha.16",
"babel-types": "7.0.0-alpha.16",
"babel-messages": "7.0.0-beta.0",
"babel-types": "7.0.0-beta.0",
"jsesc": "^2.5.1",
"lodash": "^4.2.0",
"source-map": "^0.5.0",
"trim-right": "^1.0.1"
},
"devDependencies": {
"babel-helper-fixtures": "7.0.0-alpha.16",
"babylon": "^7.0.0-beta.17"
"babel-helper-fixtures": "7.0.0-beta.0",
"babylon": "^7.0.0-beta.22"
}
}

View File

@@ -8,6 +8,18 @@ export function ClassDeclaration(node: Object, parent: Object) {
this.printJoin(node.decorators, node);
}
if (node.declare) {
// TS
this.word("declare");
this.space();
}
if (node.abstract) {
// TS
this.word("abstract");
this.space();
}
this.word("class");
if (node.id) {
@@ -59,10 +71,25 @@ export function ClassBody(node: Object) {
export function ClassProperty(node: Object) {
this.printJoin(node.decorators, node);
if (node.accessibility) {
// TS
this.word(node.accessibility);
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
if (node.abstract) {
// TS
this.word("abstract");
this.space();
}
if (node.readonly) {
// TS
this.word("readonly");
this.space();
}
if (node.computed) {
this.token("[");
this.print(node.key, node);
@@ -71,6 +98,12 @@ export function ClassProperty(node: Object) {
this._variance(node);
this.print(node.key, node);
}
if (node.optional) {
// TS
this.token("?");
}
this.print(node.typeAnnotation, node);
if (node.value) {
this.space();
@@ -82,12 +115,30 @@ export function ClassProperty(node: Object) {
}
export function ClassMethod(node: Object) {
this._classMethodHead(node);
this.space();
this.print(node.body, node);
}
export function _classMethodHead(node) {
this.printJoin(node.decorators, node);
if (node.accessibility) {
// TS
this.word(node.accessibility);
this.space();
}
if (node.abstract) {
// TS
this.word("abstract");
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
this._method(node);
this._methodHead(node);
}

View File

@@ -65,6 +65,8 @@ export function NewExpression(node: Object, parent: Object) {
return;
}
this.print(node.typeParameters, node); // TS
if (node.optional) {
this.token("?.");
}
@@ -94,6 +96,8 @@ export function Decorator(node: Object) {
export function CallExpression(node: Object) {
this.print(node.callee, node);
this.print(node.typeParameters, node); // TS
if (node.optional) {
this.token("?.");
}

View File

@@ -95,6 +95,14 @@ export function DeclareTypeAlias(node: Object) {
this.TypeAlias(node);
}
export function DeclareOpaqueType(node: Object, parent: Object) {
if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare");
this.space();
}
this.OpaqueType(node);
}
export function DeclareVariable(node: Object, parent: Object) {
if (!t.isDeclareExportDeclaration(parent)) {
this.word("declare");
@@ -303,38 +311,27 @@ export function TypeAlias(node: Object) {
this.semicolon();
}
export function TypeAnnotation(node: Object) {
this.token(":");
export function OpaqueType(node: Object) {
this.word("opaque");
this.space();
if (node.optional) this.token("?");
this.print(node.typeAnnotation, node);
}
export function TypeParameter(node: Object) {
this._variance(node);
this.word(node.name);
if (node.bound) {
this.print(node.bound, node);
this.word("type");
this.space();
this.print(node.id, node);
this.print(node.typeParameters, node);
if (node.supertype) {
this.token(":");
this.space();
this.print(node.supertype, node);
}
if (node.default) {
if (node.impltype) {
this.space();
this.token("=");
this.space();
this.print(node.default, node);
this.print(node.impltype, node);
}
this.semicolon();
}
export function TypeParameterInstantiation(node: Object) {
this.token("<");
this.printList(node.params, node, {});
this.token(">");
}
export { TypeParameterInstantiation as TypeParameterDeclaration };
export function ObjectTypeAnnotation(node: Object) {
if (node.exact) {
this.token("{|");

View File

@@ -8,3 +8,5 @@ export * from "./types";
export * from "./flow";
export * from "./base";
export * from "./jsx";
export * from "./tsFlowCommon";
export * from "./typescript";

View File

@@ -3,20 +3,31 @@ import * as t from "babel-types";
export function _params(node: Object) {
this.print(node.typeParameters, node);
this.token("(");
this.printList(node.params, node, {
iterator: node => {
if (node.optional) this.token("?");
this.print(node.typeAnnotation, node);
},
});
this._parameters(node.params, node);
this.token(")");
if (node.returnType) {
this.print(node.returnType, node);
this.print(node.returnType, node);
}
export function _parameters(parameters, parent) {
for (let i = 0; i < parameters.length; i++) {
this._param(parameters[i], parent);
if (i < parameters.length - 1) {
this.token(",");
this.space();
}
}
}
export function _method(node: Object) {
export function _param(parameter, parent) {
this.printJoin(parameter.decorators, parameter);
this.print(parameter, parent);
if (parameter.optional) this.token("?"); // TS / flow
this.print(parameter.typeAnnotation, parameter); // TS / flow
}
export function _methodHead(node: Object) {
const kind = node.kind;
const key = node.key;
@@ -44,9 +55,12 @@ export function _method(node: Object) {
this.print(key, node);
}
if (node.optional) {
// TS
this.token("?");
}
this._params(node);
this.space();
this.print(node.body, node);
}
export function _predicate(node: Object) {
@@ -59,7 +73,7 @@ export function _predicate(node: Object) {
}
}
export function FunctionExpression(node: Object) {
export function _functionHead(node: Object) {
if (node.async) {
this.word("async");
this.space();
@@ -67,16 +81,17 @@ export function FunctionExpression(node: Object) {
this.word("function");
if (node.generator) this.token("*");
this.space();
if (node.id) {
this.space();
this.print(node.id, node);
} else {
this.space();
}
this._params(node);
this._predicate(node);
}
export function FunctionExpression(node: Object) {
this._functionHead(node);
this.space();
this.print(node.body, node);
}

View File

@@ -236,6 +236,12 @@ function constDeclarationIndent() {
}
export function VariableDeclaration(node: Object, parent: Object) {
if (node.declare) {
// TS
this.word("declare");
this.space();
}
this.word(node.kind);
this.space();

View File

@@ -0,0 +1,38 @@
export function TypeAnnotation(node) {
this.token(":");
this.space();
if (node.optional) this.token("?");
this.print(node.typeAnnotation, node);
}
export function TypeParameterInstantiation(node): void {
this.token("<");
this.printList(node.params, node, {});
this.token(">");
}
export { TypeParameterInstantiation as TypeParameterDeclaration };
export function TypeParameter(node) {
this._variance(node);
this.word(node.name);
if (node.bound) {
this.print(node.bound, node);
}
if (node.constraint) {
this.space();
this.word("extends");
this.space();
this.print(node.constraint, node);
}
if (node.default) {
this.space();
this.token("=");
this.space();
this.print(node.default, node);
}
}

View File

@@ -31,7 +31,9 @@ export { ObjectExpression as ObjectPattern };
export function ObjectMethod(node: Object) {
this.printJoin(node.decorators, node);
this._method(node);
this._methodHead(node);
this.space();
this.print(node.body, node);
}
export function ObjectProperty(node: Object) {

View File

@@ -0,0 +1,456 @@
export function TSParameterProperty(node) {
if (node.accessibility) {
this.word(node.accessibility);
this.space();
}
if (node.readonly) {
this.word("readonly");
this.space();
}
this._param(node.parameter);
}
export function TSDeclareFunction(node) {
if (node.declare) {
this.word("declare");
this.space();
}
this._functionHead(node);
this.token(";");
}
export function TSDeclareMethod(node) {
this._classMethodHead(node);
this.token(";");
}
export function TSQualifiedName(node) {
this.print(node.left, node);
this.token(".");
this.print(node.right, node);
}
export function TSCallSignatureDeclaration(node) {
this.tsPrintSignatureDeclarationBase(node);
}
export function TSConstructSignatureDeclaration(node) {
this.word("new");
this.space();
this.tsPrintSignatureDeclarationBase(node);
}
export function TSPropertySignature(node) {
const { readonly, initializer } = node;
if (readonly) {
this.word("readonly");
this.space();
}
this.tsPrintPropertyOrMethodName(node);
this.print(node.typeAnnotation, node);
if (initializer) {
this.space();
this.token("=");
this.space();
this.print(initializer, node);
}
this.token(";");
}
export function tsPrintPropertyOrMethodName(node) {
if (node.computed) {
this.token("[");
}
this.print(node.key, node);
if (node.computed) {
this.token("]");
}
if (node.optional) {
this.token("?");
}
}
export function TSMethodSignature(node) {
this.tsPrintPropertyOrMethodName(node);
this.tsPrintSignatureDeclarationBase(node);
this.token(";");
}
export function TSIndexSignature(node) {
const { readonly } = node;
if (readonly) {
this.word("readonly");
this.space();
}
this.token("[");
this._parameters(node.parameters, node);
this.token("]");
this.print(node.typeAnnotation, node);
this.token(";");
}
export function TSAnyKeyword() {
this.word("any");
}
export function TSNumberKeyword() {
this.word("number");
}
export function TSObjectKeyword() {
this.word("object");
}
export function TSBooleanKeyword() {
this.word("boolean");
}
export function TSStringKeyword() {
this.word("string");
}
export function TSSymbolKeyword() {
this.word("symbol");
}
export function TSVoidKeyword() {
this.word("void");
}
export function TSUndefinedKeyword() {
this.word("undefined");
}
export function TSNullKeyword() {
this.word("null");
}
export function TSNeverKeyword() {
this.word("never");
}
export function TSThisType() {
this.word("this");
}
export function TSFunctionType(node) {
this.tsPrintFunctionOrConstructorType(node);
}
export function TSConstructorType(node) {
this.word("new");
this.space();
this.tsPrintFunctionOrConstructorType(node);
}
export function tsPrintFunctionOrConstructorType(
node: FunctionOrConstructorType,
) {
const { typeParameters, parameters } = node;
this.print(typeParameters, node);
this.token("(");
this._parameters(parameters, node);
this.token(")");
this.space();
this.token("=>");
this.space();
this.print(node.typeAnnotation.typeAnnotation, node);
}
export function TSTypeReference(node) {
this.print(node.typeName, node);
this.print(node.typeParameters, node);
}
export function TSTypePredicate(node) {
this.print(node.parameterName);
this.space();
this.word("is");
this.space();
this.print(node.typeAnnotation.typeAnnotation);
}
export function TSTypeQuery(node) {
this.word("typeof");
this.space();
this.print(node.exprName);
}
export function TSTypeLiteral(node) {
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
}
export function tsPrintTypeLiteralOrInterfaceBody(members, node) {
this.tsPrintBraced(members, node);
}
export function tsPrintBraced(members, node) {
this.token("{");
if (members.length) {
this.indent();
this.newline();
for (const member of members) {
this.print(member, node);
//this.token(sep);
this.newline();
}
this.dedent();
this.rightBrace();
} else {
this.token("}");
}
}
export function TSArrayType(node) {
this.print(node.elementType);
this.token("[]");
}
export function TSTupleType(node) {
this.token("[");
this.printList(node.elementTypes, node);
this.token("]");
}
export function TSUnionType(node) {
this.tsPrintUnionOrIntersectionType(node, "|");
}
export function TSIntersectionType(node) {
this.tsPrintUnionOrIntersectionType(node, "&");
}
export function tsPrintUnionOrIntersectionType(node, sep) {
this.printJoin(node.types, node, {
separator() {
this.space();
this.token(sep);
this.space();
},
});
}
export function TSParenthesizedType(node) {
this.token("(");
this.print(node.typeAnnotation, node);
this.token(")");
}
export function TSTypeOperator(node) {
this.token(node.operator);
this.space();
this.print(node.typeAnnotation, node);
}
export function TSIndexedAccessType(node) {
this.print(node.objectType, node);
this.token("[");
this.print(node.indexType, node);
this.token("]");
}
export function TSMappedType(node) {
const { readonly, typeParameter, optional } = node;
this.token("{");
this.space();
if (readonly) {
this.word("readonly");
this.space();
}
this.token("[");
this.word(typeParameter.name);
this.space();
this.word("in");
this.space();
this.print(typeParameter.constraint, typeParameter);
this.token("]");
if (optional) {
this.token("?");
}
this.token(":");
this.space();
this.print(node.typeAnnotation, node);
this.space();
this.token("}");
}
export function TSLiteralType(node) {
this.print(node.literal, node);
}
export function TSExpressionWithTypeArguments(node) {
this.print(node.expression, node);
this.print(node.typeParameters, node);
}
export function TSInterfaceDeclaration(node) {
const { declare, id, typeParameters, extends: extendz, body } = node;
if (declare) {
this.word("declare");
this.space();
}
this.word("interface");
this.space();
this.print(id, node);
this.print(typeParameters, node);
if (extendz) {
this.space();
this.word("extends");
this.space();
this.printList(extendz, node);
}
this.space();
this.print(body, node);
}
export function TSInterfaceBody(node) {
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
}
export function TSTypeAliasDeclaration(node) {
const { declare, id, typeParameters, typeAnnotation } = node;
if (declare) {
this.word("declare");
this.space();
}
this.word("type");
this.space();
this.print(id, node);
this.print(typeParameters, node);
this.space();
this.token("=");
this.space();
this.print(typeAnnotation, node);
this.token(";");
}
export function TSAsExpression(node) {
const { expression, typeAnnotation } = node;
this.print(expression, node);
this.space();
this.word("as");
this.space();
this.print(typeAnnotation, node);
}
export function TSTypeAssertion(node) {
const { typeAnnotation, expression } = node;
this.token("<");
this.print(typeAnnotation, node);
this.token(">");
this.space();
this.print(expression, node);
}
export function TSEnumDeclaration(node) {
const { declare, const: isConst, id, members } = node;
if (declare) {
this.word("declare");
this.space();
}
if (isConst) {
this.word("const");
this.space();
}
this.word("enum");
this.space();
this.print(id, node);
this.space();
this.tsPrintBraced(members, node);
}
export function TSEnumMember(node) {
const { id, initializer } = node;
this.print(id, node);
if (initializer) {
this.space();
this.token("=");
this.space();
this.print(initializer, node);
}
this.token(",");
}
export function TSModuleDeclaration(node) {
const { declare, id } = node;
if (declare) {
this.word("declare");
this.space();
}
if (!node.global) {
this.word(id.type === "Identifier" ? "namespace" : "module");
this.space();
}
this.print(id, node);
if (!node.body) {
this.token(";");
return;
}
let body = node.body;
while (body.type === "TSModuleDeclaration") {
this.token(".");
this.print(body.id, body);
body = body.body;
}
this.space();
this.print(body, node);
}
export function TSModuleBlock(node) {
this.tsPrintBraced(node.body, node);
}
export function TSImportEqualsDeclaration(node) {
const { isExport, id, moduleReference } = node;
if (isExport) {
this.word("export");
this.space();
}
this.word("import");
this.space();
this.print(id, node);
this.space();
this.token("=");
this.space();
this.print(moduleReference, node);
this.token(";");
}
export function TSExternalModuleReference(node) {
this.token("require(");
this.print(node.expression, node);
this.token(")");
}
export function TSNonNullExpression(node) {
this.print(node.expression, node);
this.token("!");
}
export function TSExportAssignment(node) {
this.word("export");
this.space();
this.token("=");
this.space();
this.print(node.expression, node);
this.token(";");
}
export function TSNamespaceExportDeclaration(node) {
this.word("export");
this.space();
this.word("as");
this.space();
this.word("namespace");
this.space();
this.print(node.id, node);
}
export function tsPrintSignatureDeclarationBase(node) {
const { typeParameters, parameters } = node;
this.print(typeParameters, node);
this.token("(");
this._parameters(parameters, node);
this.token(")");
this.print(node.typeAnnotation, node);
}

View File

@@ -93,6 +93,14 @@ export function Binary(node: Object, parent: Object): boolean {
return false;
}
export function TSAsExpression() {
return true;
}
export function TSTypeAssertion() {
return true;
}
export function BinaryExpression(node: Object, parent: Object): boolean {
// let i = (1 in []);
// for ((1 in []);;);
@@ -173,7 +181,9 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
t.isBinary(parent) ||
t.isConditionalExpression(parent, { test: node }) ||
t.isAwaitExpression(parent) ||
t.isTaggedTemplateExpression(parent)
t.isTaggedTemplateExpression(parent) ||
t.isTSTypeAssertion(parent) ||
t.isTSAsExpression(parent)
) {
return true;
}

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