13609 Commits

Author SHA1 Message Date
Huáng Jùnliàng
e39b508030
Add @babel/helper-validator-identifier (#11289)
* refactor: replace esutils.keywords.isIdentifierNameES6 by helper-validator-identifier

* refactor: replace esutils isReservedWordES6 by isKeyword || isReservedWord

* address review comments

* chore: specify both “main” and “exports”

* build helper-validator-identifier before babel-types
2020-03-20 12:23:14 +01:00
Oliver Dunk
693a5df7a9
Memoize call expressions in optional chains in loose mode (#11261)
* Memoize in loose mode when callee is a CallExpression

* Handle more complex OptionalCallExpressions where memoization is needed

* Convert calls to Function#call when member needs memoization

* Only update call context for member expressions
2020-03-20 08:59:03 +01:00
Nicolò Ribaudo
2e6f9583ca
Pass the correct this to JSX's __self with the old plugin (#11290) 2020-03-19 23:26:05 +01:00
Nicolò Ribaudo
11292a3c74
Use the correct this in __self for JSX elements in arrows (#11288)
* Inject `__source` and `__self` in JSX elements earlier

This fixes an issue where `this` was not correct inside arrow functions, similar to
906f8be24d

* Add test

* Remove try-catch

* Update error

* Update fixtures

* Update windows fixtures
2020-03-19 20:01:17 +01:00
Huáng Jùnliàng
0a02a12235
Move object-rest-spread after transform-parameters (#11280)
* fix: move proposal-object-rest-spread after transform-parameters

* update test fixtures

* fix: update plugin-features.js
2020-03-19 17:08:54 +01:00
Nicolò Ribaudo
f3912ac08f
Mark transpiled JSX elements as pure (#11126)
* Mark transpiled JSX elements as pure

* Avoid duble annotation

* Add "pure" option to the React preset

* Fix generator indentation

* Update tests

* Add tests for the "pure" option

* Update windows fixtures
2020-03-19 15:43:54 +01:00
Nicolò Ribaudo
fa7ec81771
Allow for-of on polyfilled or builtin iterables without Symbol support (#11285) 2020-03-19 11:02:12 +01:00
Nicolò Ribaudo
6f932978f8
Add for-of fallback for arrays in browsers without symbol supp… (#11263)
* Add for-of fallback for arrays in browsers without symbol support

* Update after rebase

* Re-throw error when iterating array

* Update fixture
2020-03-19 02:17:41 +01:00
Huáng Jùnliàng
d60802bf73
fix: object-rest-spread should not transform array rest (#11282) 2020-03-18 20:55:38 -04:00
Guy Bedford
375847b671
fix: ensure explicit file extensions in "exports" (#11283) 2020-03-19 00:23:02 +01:00
Andrew Neitsch
6892d51472
Add path separator to @babel/register sourceRoot (#11249) 2020-03-18 22:34:19 +01:00
Nicolò Ribaudo
78ace99615
Silence dynamic import() warnings in tests (#11279) 2020-03-18 15:42:19 +01:00
Brian Ng
f405cd809c
Update compat-data (#11277) 2020-03-18 10:24:14 +01:00
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