1631 Commits

Author SHA1 Message Date
Samuel Gaus
830b99dc83
Add support for rhino as a compilation target (#13448)
* Add support for rhino as a compilation target

* Add tests for target: rhino

* Fix test failing due to whitespace

* Keep consistent names for rhino tests in babel 7 and 8

* Bump core-js-compat to 3.15.0

* Change references to rhino to include patch version

* Update compat table data import

* Split transpilation of arrow function features more finely

* Rename rhino fixtures to include the patch number and update to include syntax that is and isn't supported for better testing

* Only use the relevant features for transform-new-target and transform-classes
2021-08-03 23:03:16 +02:00
Bogdan Savluk
8b1bcd1079
convert @babel/helper-compilation-targets to typescript (#13218)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-05-21 00:20:42 +02:00
Bogdan Savluk
053f94fc77
convert @babel/plugin-transform-classes to typescript (#13220)
* babel-plugin-transform-classes flowts rename

* babel-plugin-transform-classes flowts convert

* babel-plugin-transform-classes

* babel-plugin-transform-classes add optional paramter

* babel-plugin-transform-classes

* babel-plugin-transform-classes

* make generate-tsconfig

* yarn install

* Fix type checking

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-05-19 16:15:09 +02:00
Henry Zhu
6b39bafab6
Remove lodash deps (#13057)
* inline escapeRegExp instead of using any dep

* inline camelCase

* replace merge with object spread

* copy if array instead of using clone

* inline isRegExp

* review fixes!

* remove escape-string-regexp from package.json and in test

* add error for field defaults that are not primitives or empty arrays

* replace merge with object spread

* yarn
2021-03-27 17:59:34 +01:00
Bogdan Savluk
6ac07a1647
convert @babel/helper-module-transforms to typescript (#12928)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-03-27 01:40:32 +01:00
Huáng Jùnliàng
c2a42492db
Implement @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining (#13009) 2021-03-19 13:26:28 -04:00
Justin Ridgewell
78cf07767a
Remove lodash/has (#13023) 2021-03-19 15:50:52 +01:00
Nicolò Ribaudo
d04842a700
Avoid using CJS globals in internal source files (#12963)
* Lint against CJS globals in modules

* Use `import.meta.url` instead of `__filename` in `src` files

* Prepare fixtures runner for `import.meta.url`

* Use `import.meta.url` instead of `__filename` in `test/index` files

* Remove `__dirname` from remaining test files

dirname

* Avoid using `module` in `src` files

* Avoid using `require` in `src` files

* Avoid using `require` in `test` files

* Update `@types/node`

* Compile dynamic import in `@babel/node`

* Fix windows

* Use `@babel/plugin-proposal-dynamic-import` from npm
2021-03-05 19:55:36 +01:00
Nicolò Ribaudo
d9ebfab07f
[internal] Use the Node.js behavior for default imports (#12795) 2021-03-04 13:55:15 +01:00
Bogdan Savluk
0a4dc05806
convert @babel/highlight to typescript (#12432)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-02-25 01:38:47 +01:00
Nicolò Ribaudo
143ee801e6
Use the babel-plugin-polyfill-* packages in preset-env (#12583) 2021-02-21 17:40:29 +01:00
Nicolò Ribaudo
e735266dee
Avoid importing .json files (#12759)
* Avoid importing `.json` files

* Use ESold in babel.config.json

* Use `import/extensions` eslint plugin
2021-02-05 23:34:36 +01:00
Bogdan Savluk
9ac36b136a
convert @babel/generator to TypeScript (#12487)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-01-27 19:21:07 +01:00
Bogdan Savluk
d98418efbe
Convert @babel/traverse to TypeScript (#12488)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2021-01-24 01:33:09 +01:00
Bogdan Savluk
e29742717d
convert @babel/helper-split-export-declaration to TypeScript (#12485)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-12-16 00:05:48 +01:00
Bogdan Savluk
4f1df9a713
convert @babel/helper-function-name to TypeScript (#12486)
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
2020-12-15 23:19:58 +01:00
Huáng Jùnliàng
73f30329a6
refactor: move @babel/helper-validator-option to ts (#12410) 2020-12-15 11:56:14 +01:00
Huáng Jùnliàng
fc82169b4e
refactor: move @babel/helper-validator-identifier to ts (#12409)
* refactor: rename helper-validator-identifier to ts

* fix flow errors
2020-12-11 17:41:56 -05:00
Bogdan Savluk
a46cd643ab
convert @babel/code-frame to typescript (#12433) 2020-12-10 23:03:47 +01:00
Nicolò Ribaudo
208acb1d6c
Use require.resolve instead of the resolve package (#12439) 2020-12-04 08:57:09 +01:00
Huáng Jùnliàng
7000ae04a5
refactor: move @babel/helper-annotate-as-pure to ts (#12415)
* refactor: move @babel/helper-annotate-as-pure to ts

* chore: add flow types
2020-12-01 11:23:23 -05:00
Huáng Jùnliàng
5e4b85ab1c
refactor: move @babel/helper-get-function-arity to ts (#12414)
* refactor: move @babel/helper-get-function-arity to ts

* Review comments

* chore: add flow interface
2020-12-01 10:45:05 -05:00
Huáng Jùnliàng
3266d2679a
move @babel/helper-optimise-call-expression to ts (#12411)
* move @babel/helper-optimise-call-expression to ts

* chore: add flow interface
2020-12-01 10:31:39 -05:00
Bogdan Savluk
089c200c8b Convert @babel/template from Flow to TS (#12317)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-11-09 23:17:25 +01:00
Nicolò Ribaudo
f80478c06d Prepare repository for gradual flow->ts migration (#12317)
Co-authored-by: Bogdan Savluk <savluk.bogdan@gmail.com>
2020-11-09 23:17:24 +01:00
Huáng Jùnliàng
601c824873
Refine babel core types (#11544)
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-06-21 22:04:12 +02:00
Nicolò Ribaudo
a11855e586
Include preset modules (#11083)
* Prepare preset-env and compat-data for preset-modules

* Add transform-edge-default-parameters from preset-modules

* AUtomatically generate data from compat-table

* Add compat data for other plugins

* Updates after rebase

* Add more bugfixes to preset-env

* Update tests

* Add bugfix/transform-safari-for-shadowing

* Fix build script

* bugfix/transform-safari-block-shadowing

* Fix flow

* Include changes from 7127330f02b423d9cb0555b3d2a24dbccbc149b5

* Fix check-compat-data
2020-03-17 00:36:29 +01:00
Nicolò Ribaudo
282f81bd67
Prepare @babel/core for asynchronicity (#10507)
* Prepare @babel/core for asynchronicity

* Include regenerator-runtime in standalone build

* Fix rollup build
2020-01-10 22:44:13 +01:00
Nicolò Ribaudo
30f3b07ebf Replace custom "findSuggestion" function with "levenary" (#10924)
* Replace custom "findSuggestion" function with "levenary"

* Update
2019-12-26 00:45:26 +01:00
Huáng Jùnliàng
e85c9b9ec8 fix: skip merging large input sourcemaps (#10890) 2019-12-19 01:16:20 +01:00
Nicolò Ribaudo
f0c2364d01
Do not delete "fake" source map comments from strings (#9960)
Instead of using `convert-source-map`'s `removeComments` method before
parsing the file, we can first parse the file with `@babel/parser` and then
analyze the comments.
This is needed because it is not possible to reliabily detect comments in
JavaScript without fully parsing the file:
https://github.com/thlorenz/convert-source-map/issues/63
2019-08-14 17:05:55 +02:00
Letladi Sebesho
4d12c8971b added flow to babel cli (#10244)
* added flow to babel cli

* added 'SourceMapGenerator' as a argument to 'fromObject'
2019-07-25 09:59:41 +02:00
Denis Pushkarev
3303b079c5 Update to core-js@3 (#7646)
### `@babel/runtime`
- Added `@babel/runtime-corejs3` package and `corejs: 3` options to `@babel/plugin-transform-runtime`.
- Added support of instance methods, fixes #8928.
- Added flag `proposals` (in `corejs: { version: 3, proposals: true }` format) for support all proposals polyfills from `core-js`.
- Used separate directories in runtime for `core-js` entry points with proposals and without.
- Used `get-iterator-method` helper for getting iterators, fixes #2500.
- As a cheap bonus, added support of IE8- (except some cases of `regenerator`).

### `@babel/polyfill`
- Should be deprecated in favor of separate usage required features from `core-js` and `regenerator-runtime` with an informative message.

### `@babel/preset-env`
- Uses for built-ins data from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) instead of `compat-table` since information from `compat-table` [is not enough](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat).
- `useBuilIns` now requires direct setting of `corejs` version option, without it will be used `2` by default and shown deprecation warning.
- Added support of minor `core-js` versions for simplify updating in the future.
- For preventing some order-related problems, polyfills in the both `core-js@3` plugins added on `post` stage in the order of `core-js-compat` data.
- Divided plugins and polyfills parts of `preset-env`, instead of 2 internal plugins for adding polyfills, we have 6: usage and entry versions of plugins for `core-js@2`, ### Current state:
`core-js@3`, `regenerator-runtime`.
- Added support `samsung` target (for Samsung Internet) since `core-js-compat` and `compat-table` now contains mapping for this, fixes #6602.

#### `useBuilIns: entry` with `corejs: 3`
- No longer transforms `@babel/polyfill`.
- Transforms **all possible** `core-js` entry points to import of related modules (based on data from [`core-js-compat`](https://unpkg.com/core-js-compat@3.0.0-beta.15/entries.json)).
- Since of this, we no longer need `shippedProposals` / `proposals` flags with `useBuilIns: entry`.
- Removes `regenerator-runtime/runtime` import where it's not required.

#### `useBuilIns: usage` with `corejs: 3`
- In addition to `shippedProposals`, added flag `proposals`  (in `corejs: { version: 3, proposals: true }` format) for polyfill all proposals from `core-js`.
- Fixed list of dependencies in built-in definitions.
- Improved the way of determination method / built-in name and source of this method.
- Adds import of required polyfills on `MemberExpression`, `ObjectPattern`, `in` operator.
- Adds import of required polyfills on access to global object properties.
- Adds import of all required common iterators on all syntax features which use iterators protocol (`for-of`, destructuring, spread, `yield` delegation, etc.).
- Adds import of promises on syntax features which use promises (async functions/generators, dynamic import, etc.), fixes #9250, #7402, etc.

### `core-js@2` stuff
I didn't want to tough `core-js@2`-related stuff, however
- Fixed some serious errors in definitions which breaks `Object.getOwnPropertySymbols`, `Symbol.toStringTag` logic, `Promise#finally`, `Array#forEach`, etc.
- `Array#flatMap` and trim methods moved to stable features as a part of ES2019 and loaded by deprecated `@babel/polyfill` and `@babel/preset-env` with `corejs: 2` option.
2019-03-19 21:07:45 +01:00
Daniel Tschinder
756ded4d64 Remove definition of micromatch which was removed. (#8988) 2018-11-07 16:49:27 -06:00
Logan Smyth
810b7916c2 Expose an API to check if a helper is available in a given version range. 2018-08-02 18:44:56 -07:00
Logan Smyth
9bd4b46fd6
Merge pull request #8198 from loganfsmyth/sourcemap-loading
Prefer explicit object maps, and properly load relative maps.
2018-07-04 15:39:42 -07:00
Logan Smyth
532c25c8db Ensure that file-path sourcemaps load relative to the file containing the comment. 2018-06-18 22:06:08 -07:00
Serhii Nanovskyi
3de053cc6c Validate @babel/preset-env options (#8031) 2018-06-09 18:38:14 -05:00
Logan Smyth
9e7fe0ab49 Add type definitions for source-map library. 2018-04-25 12:02:05 -07:00
Logan Smyth
7ff4a73916
Upgrade flow to 0.66 and fix a few minor errors. (#7431) 2018-02-25 19:22:23 -08:00
Boris Cherny
c3654d83c8 Generate TypeScript typings, and improve generated Flow typings (#7101)
* generate typescript types

* improve type generator output

* move generator scripts to scripts/generators

* use new stringifier for generating flow types too

* export summary types

* add support for oneOfNodeOrValueTypes to improve type generation

* export typescript types from top level, and remove module declaration

* generate typescript/flow types and copy typescript types to babel-types/lib as part of make build

* copy flow types to babel-types/lib as part of make build (fix #6839)

* improve typing: Identifier->name should be a string, not any

* avoid destructuring, to support node 4

* update doc generator to share more code, regenerate babel-types readme, pipe all generator output to stdout

* regenerate babel-types readme as part of make build

* improve typing: ClassProperty->key should be Identifier | StringLiteral | NumericLiteral | Expression, not any

* improve typing: optional node properties are nullable, not undefinedable

* improve docs: FlowClassImplements should be ClassImplements

* make ts usage more friendly: when using babel-types api, make optional params | undefined, and when reading nodes keep optional params | null

* rm lib/types.d.ts and lib/types.js in favor of packages/babel-types/lib

* add missing variance node type, address review comments

* add tests for flow variance

* Comment should be a disjoint union of tagged types

* update .flowconfig
2018-01-17 10:31:46 -05:00
Brian Ng
3e5fce07e4
Regen lib/types (#7180) 2018-01-09 09:25:45 -06:00
Francisco Ryan Tolmasky I
f0e46772a6 babel-types lists JSXIdentifier as an Expression (#6960)
Currently, Babel is treating JSXIdentifier, JSXMemberExpression, and JSXEmptyExpression as expressions as well, which means Babel will for example incorrectly allow you to place these anywhere an expression is wanted.

Closes #6851.
2017-12-18 09:27:43 -06:00
Daniel Poindexter
12ac1bccd7 Fix type definitions to fully support Typescript (#6939) 2017-12-08 17:03:01 -06:00
Brian Ng
ccd7c25174
Regen babel-types docsdocs and interfaces [skip ci] 2017-11-22 08:53:16 -06:00
Henry Zhu
bede73122d
fixup places that aren not scoped [skip ci] (#6646) 2017-10-30 16:47:13 -04:00
Logan Smyth
191624d800 Add a new utility for traversing the AST. 2017-10-18 13:55:14 -07:00
Logan Smyth
cc22ea04bb Add type declaration for t.validate. 2017-10-18 13:55:13 -07:00
Logan Smyth
ad05c9935e Generate types with %checks annotations. 2017-10-18 13:55:13 -07:00
Logan Smyth
e6beb7cb61 Regenerate flow types and add more types. 2017-10-18 13:55:13 -07:00