13596 Commits

Author SHA1 Message Date
Huáng Jùnliàng
48d53f8fef
chore: bump json5 and minimist (#11276)
* chore: bump json5 and minimist

* update mkdirp to version 0.5.3
2020-03-18 10:21:22 +01:00
Huáng Jùnliàng
4bf36e64da
Create File class for babel helpers (#10575)
* add test

* fix: pass File to helper traverser

* pass babel.File to helpers.ensure
2020-03-17 09:58:46 +01:00
Luna Ruan
748897be07
Add experimental version of the `babel-plugin-transform-react-… (#11154)
* add next option for babel-plugin-transform-react-jsx

* address review comments

* chore: update test fixtures

* Update fixture

* Add "columnNumber" to the new React transform

* Update windows fixtures

* Delete unused output.js

* Update windows tests

* Fix windows again

* fix comments

Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Moti Zilberman <motiz88@gmail.com>
2020-03-17 09:16:53 +01:00
Nicolò Ribaudo
10aa97bc10
Allow rest/spread on polyfilled or builtin iterables without Symbol support (#11268)
* Allow rest/spread on polyfilled or builtin iterables when `Symbol` unsupported

Currently, when `Symbol` is not supported, we allow using rest/spread with:
- arrays
- strings
- arguments

With this PR, it will be also possible to use it with
- maps
- sets
- binary arrays

While in old browsers es6 builtins would still need to be polyfilled, it's way
easier to polyfill them because `Symbol` cannot be reliably polyfilled.

I didn't use `instanceof` becase:
- it doesn't work with polyfills not attatched to the global scope
- when using Babel to load polyfills, it would force the inclusion of `Map` and `Set` polyfills even if they are not used

Downside: the current approach of relying on `toString || construcor.name` doesn't work with subclasses.

* Don't use Array.from for array-like objects
2020-03-17 08:14:05 +01:00
Huáng Jùnliàng
841f4428e8
Rephrase parser error message (#11208)
* refactor: rephrase some parser error messages

* update test fixtures

* Update packages/babel-parser/src/parser/location.js

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* address review comments

* Update packages/babel-parser/src/parser/location.js

Co-Authored-By: Brian Ng <bng412@gmail.com>

* update test fixtures

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Brian Ng <bng412@gmail.com>
2020-03-16 21:48:32 -04:00
Nicolò Ribaudo
8e7ca22ed7
Create Npm_error.md issue template (#11217)
[skip ci]
2020-03-17 02:38:00 +01:00
Justin Ridgewell
56500603da
Add stricter Optional Chain node validation (#11250)
* Add stricter Optional Chain node validation

Optional chains cannot start with `optional: false`. Somewhere in the `object`/`callee` tree, there must be an optional with `optional: true`.

* Print current node's type when finding an error.
2020-03-17 02:17:11 +01:00
Nicolò Ribaudo
59976680df
Extract for-of iterator handling to a helper (#11262)
* Extract for-of iterator handling to a helper

Dis greatly recudes the code size when for-of is used multiple times across the
codebase. Also, makes it easier to read what's happening in a compiled loop.

* Unify spec and loose code

* Legacy implementation fallback

* Update tmp var name

* Updates from review and after rebase
2020-03-17 00:45:34 +01: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
f6c7bf36ce
Allow extending untranspiled classes (#8656) 2020-03-16 23:59:15 +01:00
Nicolò Ribaudo
a875560c31
Allow defining the moduleIds-related option in the transform p… (#11194)
* Update "moduleIds" tests

* Allow defining the moduleIds related options in the transform plugins

- moduleIds
- moduleId
- getModuleId
- moduleRoot

* Sort deps
2020-03-16 23:58:04 +01:00
Rick Button
3ce7c2e394
Added support for record and tuple syntax. (#10865)
* Added support for record and tuple syntax.

This commit adds support for both the hash #{} and bar {||}
syntaxes to babel-parser, as well as adds the supporting
babel-plugin-syntax-record-and-tuple plugin to enable support
for the syntax. Does not include any transform for records and
tuples.

* typo

* added check to ensure recordAndTuple in babel-parser

* switched to syntaxType option instead of explicit entries for each record and tuple type

* switched to using recordAndTupleSyntaxType for generator options instead of adding to node

* added tests for generator option recordAndTupleSyntaxType

* added test for record and tuple bar syntax with flow typings

* added tests for invalid/missing recordAndTuple syntaxType parser option

* fixed flowcheck errors

* fix merge with class privates in tokenizer

* Update packages/babel-parser/src/types.js

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>

* improved recordAndTuple generator error message, added tests for invalid,missing options

* updated error messages for invalid parser syntaxType option

* updated error message

* added better error messages for when the recordAndTuple syntaxType is doesn't match the syntax used

* updated record and tuple support to use new error message templates

* added recordAndTuple to missing plugin helpers

* Fix linting

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-03-16 23:57:44 +01:00
Ye Wei
e06bf8ffdb
Add numeric separator to shippedProposals (#10971)
* add plugins

* add plugin description

* run build-data

* set shipped proposals true

* update test fixtures

* corejs.proposals should not imply shipped proposals

* fix eslint errors
Please enter the commit message for your changes. Lines starting

* create new object in packages/babel-compat-data/scripts/data/plugin-features.js
2020-03-16 23:09:33 +01:00
Nicolò Ribaudo
5c1a8210da
Implement support for declare on class fields with Flow (#11178)
* Add parser support for Flow declare fields

* Add generator test

* Add "allowDeclareFields" option to flow-strip-types

* Add test

* Update error messages

* More tests
2020-03-16 23:08:26 +01:00
Taym Haddadi
286aaeadd9
Add cloneDeepWithoutLoc (#10680)
* feat: add cloneDeepWithoutLoc

* fix: sort functions alphabetically

* doc: add documentation for the withoutLoc parameter

* test: add a test for  shallow cloneWithoutLoc

* test: add loc object to node and fix test

* fix: set loc object on deeper node

* test: check loc on deeper node is null

* doc: adjust withoutLoc documentation

* fix: add withoutLoc param to deep clones

* fix: apply cloneIfNodeOrArray for leadingComments, innerComments and trailingComments

* test: add test for leadingComments, innerComments and trailingComments

* Cleanup PR

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2020-03-16 23:07:01 +01:00
Siddhant N Trivedi
f232d4d109
Added jsescOptions to Numeric Literals (#11028)
* Added jsescOptions to Numeric Literals

* Added tests and hexadecimal opts to NumericLiterals

* Fixed the bug of every numeric literal being coverted to hex

* Added conditions when jsesc should be applied

* Removed numbers and lowercaseHex from format object

* Added newline to test of jsonEscape (to exclude the change)

* Modified conditions to apply jsesc

* Made the required changes.

* Using node.value instead of value
2020-03-16 23:06:32 +01:00
Brian Ng
4f394e30d2
Add support for flow's SymbolTypeAnnotation (#11077) 2020-03-16 23:00:17 +01:00
Nicolò Ribaudo
2bce1e5e20
Parse BigInts by default (#11117) 2020-03-16 22:59:45 +01:00
Moti Zilberman
1971b7e87d
feat(react-jsx-source): add columnNumber property (#11139)
* feat(react-jsx-source): add column property

This will be useful to tools that consume the injected `__source` prop, allowing precise source locations to be displayed.

* Rename column -> columnNumber, make 1-based
2020-03-16 22:59:22 +01:00
Nicolò Ribaudo
740260b236
Add import type and export type support to TypeScript (#11171)
* Add support for type only imports in TS (#11053)
* Implement "export type {}" (#11122)
* Add "exportKind: type" when needed with TS (#11157)
* Add `onlyRemoveTypeImports` option to `transform-typescript` (#11173)
* Add onlyRemoveTypeImports to preset-typescript (#11179)

Co-authored-by: Brian Ng <bng412@gmail.com>
Co-authored-by: Raja Sekar <rajasekarm.dev@gmail.com>
Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Henry Zhu <smiley.we@gmail.com>
Co-authored-by: Siddhant N Trivedi <sidntrivedi012@gmail.com>
2020-03-16 22:58:51 +01:00
Brian Ng
20d9a10186
Add estree parsing support for export * as A (#11254) 2020-03-16 22:52:33 +01:00
Huáng Jùnliàng
4a4845585c
feat: align ID_Start/ID_Continue regex to Unicode 13.0.0 (#11246) 2020-03-16 22:52:08 +01:00
Arun Kumar Mohan
84a9ea455b
Allow await when it is not in AsyncArrowHead (#11148) 2020-03-16 22:26:48 +01:00
Nicolò Ribaudo
1ba41f2084
Throw better errors for non-iterables when Symbol doesn't exist (#11264) 2020-03-16 16:34:33 +01:00
Justin Ridgewell
10058901d0
Update Purish aliases (#11267)
* Update Purish aliases

- Adds `Purish` to `RegexLiteral`, since it can't cause any side-effects.
- Removes `Purish` from `ClassExpression` and `ClassDeclaration`, since they can be impure with static class fields.

* Update types
2020-03-16 16:30:38 +01:00
Carlos Lopez
7b9bc7c28b
fix(rest-spread): Do not require Symbol.iterator for strings (#9794) 2020-03-15 14:54:44 +01:00
Justin Ridgewell
661ffbd830
Support more node types in generateUidBasedOnNode (#11260)
* Support more node types in generateUidBasedOnNode

* More nodes
2020-03-14 16:24:50 +01:00
Brian Ng
b85d9f57f6
Remove unused gulp-rename (#11259) 2020-03-14 12:02:00 +01:00
Justin Ridgewell
b1a589f0aa
Fix printing edge cases in Nullish Coalescing and Optional Ch… (#11255)
This is a mix of changes, most importantly:

- Always print parens when mixing nullish coalescing and another logical
- Fixes assignment in the callee of an optional chain, which now blocks #11248

Also, cleans up a bit of code, and removes an unnecessary parens around `class A extends new B {}`
2020-03-13 16:35:28 +01:00
Babel Bot
420f2ee69a Add v7.8.8 to CHANGELOG.md [skip ci] 2020-03-12 18:51:08 +00:00
Nicolò Ribaudo
c831a2450d v7.8.8 2020-03-12 19:44:17 +01:00
Huáng Jùnliàng
565ab9a3fc
fix: preserve shadowed for-loop declarators (#11242)
* fix: do not remove for-loop declarators

* fix: do not remove uninitialized var declarators in for init
2020-03-12 14:07:59 -04:00
Huáng Jùnliàng
dadd22e161
chore: update caniuse fixtrues (#11253) 2020-03-12 12:27:40 -04:00
Nicolò Ribaudo
d030793248
Add support for Unicode 13 in regexps (update regexpu-core) (#11244)
* Update regexpu-core

* Add tests
2020-03-11 23:24:02 +01:00
Nicolò Ribaudo
cbbf0bc6ac
Archive @babel/plugin-syntax-export-namespace-from (#11236)
* Archive @babel/plugin-syntax-export-namespace-from

Enabled by default in https://github.com/babel/babel/pull/10521

5ccc77e287

* Fix tests
2020-03-11 21:50:23 +01:00
Huáng Jùnliàng
f9d4b799b7
chore: pin @rollup/plugin-json to 4.0.1 (#11235) 2020-03-11 01:21:27 +01:00
Brian Ng
0616f06b00
Bump kind-of for audit (#11232) 2020-03-10 17:40:20 -04:00
Brian Ng
a82e7399ed
Bump rollup deps (#11233) 2020-03-10 17:40:08 -04:00
Huáng Jùnliàng
3cc833da14
chore: update acorn to latest patch (#11230) 2020-03-10 17:39:49 -04:00
Brian Ng
5ee1433c2a
Bump ESLint-related deps (#11228) 2020-03-10 15:48:03 -04:00
Sergey Melyukov
cb9d28c42c
Force parentheses around array and conditional infer (#11227) 2020-03-10 12:27:52 -04:00
Brian Ng
eb65195f09
Update @babel deps (#11225)
* Update @babel deps

* fixture
2020-03-10 12:27:13 -04:00
Kai Cataldo
2057d2b159
fix: non-directive "use strict" should not enable parsing in strict mode (#11188)
* fix: non-directive "use strict" should not enable parsing in strict mode

* Remove dead code

* Add stricter type annotations

* set oldStrict explicitly to null

* Fix error

* label callback argument

* update comment

* Address feedback

* Remove this.state.octalPosition

* Add additional tests

* Revert "Remove this.state.octalPosition"

This reverts commit bcc78c9530f8c840f85e86053b75efce662f34d1.

* Remove containsOctal

* Report multiple octal literals in single token

* Fix comments

* remove Array.prototype.flat()
2020-03-05 17:34:27 -05:00
Huáng Jùnliàng
e297e406ce
refactor: remove redundant contextDescription empty check (#11219) 2020-03-05 16:17:01 -05:00
Gerald
8cafd8f820 fix(transform-destructuring): update scope info after replacing 2020-03-05 21:23:50 +01:00
Huáng Jùnliàng
1011e58c6c
update: preset-env-fixtures (#11218)
Co-authored-by: Kai Cataldo <kai@kaicataldo.com>
2020-03-05 15:01:29 -05:00
Babel Bot
1e7ab24bb3 Add v7.8.7 to CHANGELOG.md [skip ci] 2020-03-05 01:56:31 +00:00
Nicolò Ribaudo
595f65f33b v7.8.7 2020-03-05 02:52:13 +01:00
Nicolò Ribaudo
7127330f02
Allow using preset-env with newer versions of compat-data (#11201)
* Use ~ for preset-env's @babel/compat-data dependency

* Revert "Use ~ for preset-env's @babel/compat-data dependency"

This reverts commit e7d57c7894095d381670cddfbbce06bd2a480a32.

* Allow using `preset-env` with newer versions of `compat-data`
2020-03-05 02:35:31 +01:00
Nicolò Ribaudo
a12001a0f9
chore: bump browserslist to version 4.9.1 (#11207) 2020-03-05 00:46:10 +01:00