Compare commits

...

116 Commits

Author SHA1 Message Date
Nicolò Ribaudo
b9cb4af953 v7.6.2 2019-09-23 23:14:37 +02:00
Gonzalo Rodríguez
69d00dc5b0 [parser] Invalid NonOctal Decimal (#10467)
* Add test

* Add nonOctalDecimal verification

* Update regex and code style

* Refactor non octal detection

* Add numeric separator test

* Disallow numeric separators in non octals

* Update whitelist

* Better test naming

* Disallow numeric separators in non oct for all numbers

* Specific error above the general error

* Add test for invalid leading zero in num separator

* Add start position to error
2019-09-23 23:07:52 +02:00
Ivan Medina
f339d2d034 [parser] Disallow numeric separator in unicode scape sequences (#10468)
* [parser] Disallow numeric separator in unicode scape sequences (#10460)

* raise error only when numeric separator plugin is set

* Adds argument for checking numeric separator

* Fix condition for readability

* Add test for hex escape sequence and rephrase error message

* Remove exposure for allowNumSeparator in readHexChar method
2019-09-23 22:47:18 +02:00
Nicolò Ribaudo
3069747a81 Leave trailing comments after handling a possible trailing com… (#10445)
* Leave trailing comments aftre handling a possible trailing comma

* perf
2019-09-23 19:14:43 +02:00
Tomer Aberbach
962015f7e7 docs: updates docs of findParent and find (#10479) [skip ci]
Makes the documentation of `findParent` and `find` consistent and documents their `null` cases.
2019-09-22 23:00:13 +02:00
Vivek Nayyar
b7333ea97a added check to disallow super.private variable access and test case added (#10472)
* 🚀 added check to disallow super.private variable access and test case added

* ♻️ change the other linting change back to how it was

* ♻️ change the other linting change back to how it was

* ♻️ added newline at the end test output.json file

* ♻️ changed the linting style to the way it was

* ♻️ updated error message, removed super private member access test cases from whitelist of flow and test 262 suite

* ♻️ added newline in output.json
2019-09-21 00:22:37 +02:00
Nicolò Ribaudo
46c70ad734 Update PULL_REQUEST_TEMPLATE.md (#10473) [skip ci] 2019-09-20 11:27:49 -04:00
Nicolò Ribaudo
3a7b6e1c22 Force update of test262-stream
v1.2.0 doesn't support Test262 v4
2019-09-20 12:54:28 +02:00
Guy Waldman
9c1ad0a9f7 [parser] Disallow static fields named constructor (#10461)
* Disallow static fields named `constructor` in a class

    - Disallowed static fields named `constructor` in a class (previously only non-static were disallowed)
    - Updated the text for the error for one consolidated warning, for both static and non-static fields
    - Added a test
    - Updated an existing test in the `flow` test suite of the parser to reflect the parse error.
  Strangely, the test used to pass and started failing when inlining the `isNonstaticConstructor` method, without any changes.
  In that test, `constructor` was a field, so in theory it should never have passed.
  Would appreciate some feedback on this, as I'm not 100% sure if this is somehow related to Flow

* Update test262 whitelist

* Add comment and fix && operator
2019-09-18 01:19:45 +02:00
Huáng Jùnliàng
87dc201411 refactor: replace regexp-tree by regexpu (#10430) 2019-09-17 17:38:15 -05:00
Nicolò Ribaudo
0ef4972295 Ignore regexp tests from test262 (#10458) 2019-09-18 00:14:27 +02:00
Nicolò Ribaudo
cb881e6b3f [parser] Report escapes in kws only if they won't be used as i… (#10455)
We can do it by tokenizing escaped keywords as normal identifiers, so that they won't
be accidentally used as real keywords.
2019-09-18 00:13:51 +02:00
Nicolò Ribaudo
45a484f0a2 Enable optional chaining in test262 (#10457) 2019-09-17 12:10:57 -05:00
Nicolò Ribaudo
99f4f6c3b0 Update Test262 (#10448) 2019-09-17 02:14:14 +02:00
Nicolò Ribaudo
e4b4831100 Update GitHub actions to v2 (#10441)
* Update GitHub actions to v2 [skip ci]

* Only run when needed for issues [skip ci]
2019-09-16 22:38:12 +02:00
Huáng Jùnliàng
256fa5aa04 chore: bump regexpu-core to version 4.6.0 (#10439)
* chore: update test fixtures

* chore: test against regexpu-core 4.6.0

* chore: bump regexpu-core dependency
2019-09-13 17:51:24 +02:00
Huáng Jùnliàng
0ee2c42b55 chore: add lint-ts rule (#10427) 2019-09-11 20:24:08 +02:00
Huáng Jùnliàng
1b352ca8a1 chore: remove tryResolve dependency (#10428) 2019-09-11 12:25:18 +02:00
Huáng Jùnliàng
53af9e8b7a fix: allow the process to exit naturally (#10400) 2019-09-11 12:24:44 +02:00
Huáng Jùnliàng
af04f40ee0 fix: pass optionLoc when validating plugin object (#10402) 2019-09-11 12:23:20 +02:00
Bryan Wain
98b14843ba Remove babel polyfill dependency of babel-node (#10429) 2019-09-11 01:57:44 +02:00
Huáng Jùnliàng
4395c22f3a Miscellaneous perf tweak (#10421)
* refactor: early return on hot path

* refactor: read next2 only when next is dot

* perf: mini refactor
2019-09-10 19:47:52 +02:00
Nicolò Ribaudo
610d6bdc62 Do not guess relative execution status for exported fns (#10417) 2019-09-10 19:47:27 +02:00
Tan Li Hau
8027dca501 fix object rest in array pattern (#10275)
* fix object rest in array pattern

* update test fixtures

* early return

* use path.stop() at the right path
2019-09-10 15:18:45 +02:00
Huáng Jùnliàng
81831032c3 chore: remove trim-right dependency (#10420) 2019-09-10 15:17:22 +02:00
FND
daf25af47c Fix typo in changelog (#10409) [skip ci]
s/compliancy/compliancy/g - seems both correct and consistent with more
recent occurrences
2019-09-09 09:22:33 +02:00
Nicolò Ribaudo
6a5cee8f27 Remove circular dependency (#10405)
* Remove circular dependency

* Move @babel/runtime test to @babel/runtime
2019-09-08 22:53:42 +02:00
Nicolò Ribaudo
2096d0cfcb Update @babel deps (#10407)
* Update @babel deps

* Add core-js to transform-named-capturing-groups-regex devDeps

* Don't use fixed deps (they were added by yarn)

* Lockfile
2019-09-08 22:53:20 +02:00
Babel Bot
a79fbe62e4 Add v7.6.1 to CHANGELOG.md [skip ci] 2019-09-06 20:55:50 +00:00
Nicolò Ribaudo
381b066bd0 v7.6.1 2019-09-06 22:50:54 +02:00
Matt Forster
15b63bc89e fix(types): correct typescript function headers (#10404)
Flow maybe types state;

> Maybe types accept the provided type as well as null or undefined. So ?number would mean number, null, or undefined.

So in this case, explicitly allow the type, null, or undefined in the
typescript definition.

Fixes #10403
2019-09-06 22:38:21 +02:00
Dword
fc8e14264c Remove process.exit(1) from babel-node (#9758)
Because it breaked graceful shutdown of the sub process.
2019-09-06 14:32:45 -04:00
Babel Bot
7e4f48139c Add v7.6.0 to CHANGELOG.md [skip ci] 2019-09-06 17:36:19 +00:00
Nicolò Ribaudo
cbd5a26e57 v7.6.0 2019-09-06 19:25:16 +02:00
Nicolò Ribaudo
42e5974fd4 Remove old uglify option
It's false by default
2019-09-06 19:24:15 +02:00
Nicolò Ribaudo
735abc0ed8 Update lerna
v3.16 includes https://github.com/lerna/lerna/pull/2185,
which fixes an issue we had in the v7.5 releases
2019-09-06 18:40:06 +02:00
Corey Farrell
aa7678f32a Remove core-js from @babel/register. (#9847)
This module doesn't use core-js at all.
2019-09-06 18:11:38 +02:00
Huáng Jùnliàng
b64cb9aaf1 fix: early return when instance is not iterable (#10396)
* fix: early return when instance is not iterable

* chore: update test fixtures

* fix: gaurd against arguments for old browsers
2019-09-06 18:09:57 +02:00
Huáng Jùnliàng
8da9d8b4b8 feat(errors): validate preset when filename is absent (#10181)
* feat(errors): validate preset when filename is absent

Closes #10154

* fix: test overrides for filename compulsory

* docs: rewrite validate error message

per https://github.com/babel/babel/pull/10181#discussion_r301607986

* polish error message
2019-09-06 18:09:19 +02:00
Tim McClure
3e4889d649 Class Private Static Accessors (#10217)
* Remove error for static private accessors

* Private static accessors strict

* Add loose mode support

* Move `value` decl for early return

* Reuse getter/setter template

* Reuse getter/setter templates

* Use `buildUndefinedNode` in accessor templates

* Extract `isAccessor` variable
2019-09-06 18:08:10 +02:00
Huáng Jùnliàng
da0af5fd99 V8intrinsic syntax plugin (#10148)
* feat: v8intrinsic syntax plugin

Implement V8 Intrinsic Syntax Extension. Here we check the execution branch inside the parseSubscript to make sure the V8IntrinsicIdentifier is immediately followed by a call expression.

* feat: disable combining placeholders and v8intrisic

per https://github.com/babel/babel/issues/10104#issuecomment-506950969

* test: add more error cases

* refactor: parse v8 intrinsic in parseExprAtom

This approach is identical to V8’s implementation. Move the test cases as the behaviour changes.

* fix: plugin-name typo

* test: add yield-expression test case

* feat: require startsExpr on modulo for v8intrinsic

* perf: skip eof and braceR check as they must return false

* Print V8IntrinsicIdentifier

* feat: add v8intrinsic to parser typings

* Add generated type helpers

* fix: incorrect type definition

* fix: allow V8IntrinsicIdentifier to be callee
2019-09-06 17:43:19 +02:00
Vivek Nayyar
b02e35c19a Fix parenthesis for nullish coalescing (#10269)
* ♻️ added condition to check for left and right of nullish coalescing operator and if any is a logical expression without a paren then throw an error

* 🐛 bugs fixed and test cases updated for babel parser

* ♻️ code comments added

* 🐛 spell error rectified

* ♻️ failing test updated

* 🐛 push tests after make build

* Skip nullish-coalescing flow precedence tests

They're now incorrect

* ♻️ error message updated, binop priority of other logical operators +1 from ?? and

* ♻️ increaed the binOp for in and instanceOf, added logic to print the brackets in an ?? && || expression, test cases added

* 🐛 failing test fixed and comments updated

* ♻️ new lines added between tests

* ♻️ basic tests for checking the binOp of instanceOf, in and relational operators to be equal added

* ♻️ new lines added in between tests
2019-09-06 17:35:44 +02:00
Nicolò Ribaudo
3e8a5c5e28 Use "validateLogs" for preset-env's debug fixtures (#10401)
* Add ability to ignore output to the test runner

* Use normal fixtures instead of custom debug-fixtures in preset-env
2019-09-06 17:32:20 +02:00
Bin Xin
8769903284 Add supports for polyfill computed methods (#10398) 2019-09-06 01:35:03 +02:00
Bin Xin
5c859b1117 Don't polyfill if evaluation is not confident (#10397) 2019-09-06 00:29:19 +02:00
Huáng Jùnliàng
2e7bea4a6a fix: transform name capturing regex once (#10395)
* fix: transform name capturing regex once

* refactor: early return when pattern contains only lookbehind

* chore: simplify test regex

* chore: run test on >=8.0.0
2019-09-05 17:35:57 +02:00
Bin Xin
29734b924a Don't allow instance properties transformation on namespace (#10372) 2019-09-05 10:32:57 -05:00
Huáng Jùnliàng
6813ee02d7 chore: update regexp-tree to version 0.1.13 (#10376) 2019-09-05 10:07:18 -05:00
Adam Ramberg
fcb77de901 [preset-env] Include / exclude module plugins properly (#10218)
* Include / exclude module plugins properly

* Use filter-items to excl / incl module plugins

* Move transform selection to getModulesPluginNames

* Remove unnecessary spread operator

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

* Adjust tests to changes in #10218
2019-09-05 15:58:29 +02:00
Ajay Sagar
d05bd9edc8 Bumped chokidar dependency of babel-cli to 2.1.8 (#10394) 2019-09-04 21:33:31 -04:00
Nicolò Ribaudo
27ba292774 Silence remaining test warnings (#10392) 2019-09-04 22:56:47 +02:00
Tan Li Hau
a08e856804 fix typescript for babel-types (#10098)
* fix typescript for babel-types

* fix missing typescript/flow types for babel-types

* Add cloneNode to flow.js

* Add cloneNode to typescript.js
2019-09-04 15:35:19 +02:00
Shrey Banga
c0e3fa0081 Refactor trailing comma comment adjustment (#10380)
* Refactor trailing comment adjustment

Following up from https://github.com/babel/babel/pull/10369

- Unify the logic for adjusting trailing comments into a separate
  function
- Use it for all three cases, which fixes a bug for ObjectExpressions
  and CallExpressions
- Update tests to check for the fixed bug

* Fix tests

- Only modify trailingComments if necessary
- Update snapshots of a couple of affected tests

* Drop the underscore in adjustCommentsAfterTrailingComma_

* Handle ArrayPattern

* Handle ObjectPattern

* Handle import and export declarations

These have to be handled a bit differently, because the  node is visited after the  and before the declaration. So we intercept when we are going from the last specifier to the source node.

* Remove unnecessary check
2019-09-02 20:35:15 -04:00
Dylan Kirkby
e5afa57cca Allow setting 'allowNamespaces' in typescript preset (#10382)
* Support 'allowNamespaces' in typescript preset

* Remove default for allowNamespaces
2019-09-02 20:33:01 -04:00
Thiago Arrais
e7fa566442 Includes test for #8354 (#10385) 2019-09-02 21:58:54 +02:00
Nicolò Ribaudo
7c0333e12a Move preset-env old changelog
Fixes #9730
2019-09-02 12:41:55 +02:00
Shrey Banga
8a775a32ba Retain trailing comments in array expressions (#10369)
* Retain trailing comments in array expressions

This is a proposed fix for https://github.com/babel/babel/issues/10368
with a simple test.

* Move lastElement in the block where it's used

* Test trailing comment after array expression

* Don't move comments after the array expression

* Retain trailing comment after the array expression
2019-08-28 14:03:37 -04:00
dependabot[bot]
94e47c30a9 Bump eslint-utils from 1.4.0 to 1.4.2 (#10370)
Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.4.0 to 1.4.2.
- [Release notes](https://github.com/mysticatea/eslint-utils/releases)
- [Commits](https://github.com/mysticatea/eslint-utils/compare/v1.4.0...v1.4.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-08-27 09:50:33 +02:00
Justin Ridgewell
1664cce681 Don't allow JSXNamespacedName to chain (#10366)
Eg, `namespace:foo.bar` used to parse but is invalid in the [spec](https://facebook.github.io/jsx/).

Also, allow `JSXNamespacedName` in the `JSXOpeningElement`/`JSXClosingElement` builders.
2019-08-26 13:16:22 -04:00
Nicolò Ribaudo
a2bf68981f Add TSBigIntKeyword to @babel/types (#10341) 2019-08-20 17:31:45 -05:00
Nicolò Ribaudo
15aa511b8e Do not register ambient classes to the TS scope (#10352) 2019-08-20 17:22:47 -05:00
Henry Zhu
11ed2e2bf5 readme: links/contributing updates (#10206) [skip ci]
* readme: links/contributing updates

* Update README.md
2019-08-19 09:31:37 +02:00
Even Alander
eb3767d58b Add a builder definition including name for tsTypeParameter (#10319) 2019-08-15 19:59:08 +02: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
Huáng Jùnliàng
ee344c3e4c Revert "chore: remove FORCE_COLOR workaround" (#10336)
This reverts commit 347ee036becdca3c9e158311d44a48ed89df9a94.
2019-08-14 16:58:01 +02:00
Ziad El Khoury Hanna
64041e1669 Fix flow comments plugin issues (#10329)
* Fix issues in flow-comments to preserve comments and there order (fixes #10324)

* Add support in flow-comments for extends in class declarations (fixes #10323, #10321)

* Refactoring and cleanup of flow-comments plugin

* Fix comments preservation logic of flow-comments

* Fix flow-comments where comments are class identifier and extends keyword
2019-08-14 15:46:26 +02:00
Nicolò Ribaudo
469a5a71cd Allow testing logs with @babel/helper-transform-fixture-test-runner (#10326)
* Add support for logs to transform-fixture-test-runner

* Test some warnings

* Use stderr/stdout, and add a validateLogs test option

* Normalize CWD in logs and rename vars

* Silence preset-env tests

* Restore old methods
2019-08-14 08:03:03 +02:00
Huáng Jùnliàng
75090f10e5 fix: assign comment to ObjectProperty only when inside an ObjectExpression (#10292)
Fixes #10230
2019-08-13 13:49:16 -05:00
Huáng Jùnliàng
22df2ae244 Commit generated code (#10331)
* update prettier generated artifacts

* chore: sync babel-helpers to artifacts
2019-08-13 16:31:28 +02:00
Nicolò Ribaudo
051965052c Update @lerna/collect-updates git hash 2019-08-13 12:03:34 +02:00
Thiago Arrais
ee397ff107 Adds note about two approval policy to PR template (#10313)
* Adds note about two approval policy to PR template

* Adds qualifier to approval policy

Because, although two approvals is the general case, some PRs maybe merged with more or fewer approvals

[skip ci]
2019-08-12 17:32:31 +02:00
Huáng Jùnliàng
15535cf52c Update preset-env text fixtures (#10318)
* chore: update preset-env text fixtures

* chore: remove FORCE_COLOR workaround
2019-08-12 00:55:27 +02:00
README Bot
682d9f9f09 Add CodeTriage badge to babel/babel (#10088) [skip ci]
Adds a badge showing the number of people helping this repo on CodeTriage.

[![Open Source Helpers](https://www.codetriage.com/babel/babel/badges/users.svg)](https://www.codetriage.com/babel/babel)

## What is CodeTriage?

CodeTriage is an Open Source app that is designed to make contributing to Open Source projects easier. It works by sending subscribers a few open issues in their inbox. If subscribers get busy, there is an algorithm that backs off issue load so they do not get overwhelmed

[Read more about the CodeTriage project](https://www.codetriage.com/what).

## Why am I getting this PR?

Your project was picked by the human, @schneems. They selected it from the projects submitted to https://www.codetriage.com and hand edited the PR. How did your project get added to [CodeTriage](https://www.codetriage.com/what)? Roughly over 3 years ago, [iamsolankiamit](https://github.com/iamsolankiamit) added this project to CodeTriage in order to start contributing. Since then, 94 people have subscribed to help this repo.

## What does adding a badge accomplish?

Adding a badge invites people to help contribute to your project. It also lets developers know that others are invested in the longterm success and maintainability of the project.

You can see an example of a CodeTriage badge on these popular OSS READMEs:

- [![Email clients like GMAIL do not render SVG images](https://www.codetriage.com/rails/rails/badges/users.svg)](https://www.codetriage.com/rails/rails) https://github.com/rails/rails
- [![Email clients like GMAIL do not render SVG images](https://www.codetriage.com/crystal-lang/crystal/badges/users.svg)](https://www.codetriage.com/crystal-lang/crystal) https://github.com/crystal-lang/crystal

## Have a question or comment?

While I am a bot, this PR was manually reviewed and monitored by a human - @schneems. My job is writing commit messages and handling PR logistics.

If you have any questions, you can reply back to this PR and they will be answered by @schneems. If you do not want a badge right now, no worries, close the PR, you will not hear from me again.

Thanks for making your project Open Source! Any feedback is greatly appreciated.
2019-08-09 19:18:18 +02:00
Serge Havas
a112be2fa0 [fix] jsx helper calls order (#10307)
imitate properly react createElement calls order
2019-08-08 22:43:57 +02:00
ifsnow
9ec26a7d3e Improves the logic to import objects in helpers (#10161)
* Improves the logic to import objects in helpers

* Modified to work with more cases.

* Modified by considering exception cases

* Fixed not using bundler's polyfill

Co-Authored-By: Jordan Harband <ljharb@gmail.com>

* Updated test output files

* Changes to cache logic

* Modified to use if statement
2019-08-08 11:11:50 +02:00
Thiago Arrais
ba2c0f7adf fix: register inserted class declaration (#10302)
* Decorators legacy: register inserted declaration

For compatibility with the Typescript plugin

Fixes #10264

* Register declaration but also keep replaceWithMultiple
2019-08-08 07:14:23 +02:00
Huáng Jùnliàng
5fb4d84a33 perf: always return void 0 as undefined node (#10243) 2019-08-01 09:53:40 +02:00
Tan Li Hau
3e4a9d588b Do expressions transform for switch statements (#10070)
* lint fix

* switch inside do expression

* review comments

* review comments

* make min diff

* adding more test

* review changes

* review changes

* handle block statement and added more test cases

* fix implementation and add more test cases

* fix last swtich case

* disable block fallthrough case

* fix nitpick reviews
2019-08-01 09:36:35 +02:00
Tan Li Hau
be2cbde560 remove finally from completion record in trystatement (#10277) 2019-08-01 09:24:08 +02:00
Ashwin Ramaswami
66727632e8 fix: replace es.string.reverse with es.array.reverse (#10284) 2019-08-01 09:20:52 +02:00
Brian Donovan
ba28f462bc Fix typo "to" → "so". (#10288) 2019-07-31 16:04:53 -04:00
Huáng Jùnliàng
f08062b1de chore: fix ESLint errors (#10278) 2019-07-29 10:14:11 -05:00
Daniel Tschinder
4f0840ab88 Update dev dependencies and fix linting errors (#10228)
* chore: Uppate dev dependencies

* chore: Fix lint errors

* chore: Format options.json files

* chore: Fix stupid flow errors

* Update test262 whitelist

Seems test262-stream was updated and now these tests work.
2019-07-27 15:09:30 +02:00
Tan Li Hau
6a9d2538e0 fix capturing group for matchAll (#10136)
* fix capturing group for matchAll

* update test case

* add core-js/features/string/match-all to test
2019-07-26 18:53:22 -04:00
Letladi Sebesho
f160522ab0 updated ParsePlugin type definition (#10259)
* added 'placeholders', 'logicalAssignment', 'partialApplication' to the ParserPlugin type. closes #10186

* put the ParserPlugin names in alphabetical order
2019-07-26 10:22:23 +02:00
Serhii Muryhin
4d30379d36 Add ";" token to the end of TS construct & call signature declaration (#10258)
* Add ";" token to the end of TS construct signature declaration

* Add ";" token to the end of TS call signature declaration. Update construct signature test fixtures
2019-07-25 10:14:35 +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
Yuri Karadzhov
4506590557 Add static parameter to class property builder (#10248) 2019-07-25 09:55:03 +02:00
Brian Donovan
1e7ed5c461 Add allowUndeclaredExports option to typings. (#10263)
This should have been included in https://github.com/babel/babel/pull/9864 but was not.
2019-07-25 09:53:56 +02:00
Nicolò Ribaudo
fced5cea43 Fix tdz checks in transform-block-scoping plugin (#9498)
* Better tdz tests

- Use jest's expect.toThrow/expect.not.toThrow
- Add input/output tests

* Fix basic tdz (a = 2; let a)

Fixes #6848

* Make _guessExecutionStatusRelativeTo more robust

* Add tests

* Return less "unkown" execution status

* "function" execution status does not exist

* Fix recursive functions

* Update helper version

* "finally" blocks are always executed

* Typo
2019-07-21 06:34:43 +02:00
Nicolò Ribaudo
9bc9571381 Extract release actions to babel/actions 2019-07-20 16:43:22 +02:00
Nicolò Ribaudo
fb910e063c [gh action] Release on tag push 2019-07-20 16:39:10 +02:00
Daniel Tschinder
3b4a86aea4 Separate workflows as otherwise they interfere with eachother 2019-07-20 15:26:52 +02:00
Daniel Tschinder
94b678c949 Fix workflow 2019-07-20 15:22:21 +02:00
Daniel Tschinder
c84a4c8bfa Use latest version of filter action 2019-07-20 15:14:07 +02:00
Daniel Tschinder
dfd59c183e Add 'Needs Info' workflow 2019-07-20 15:13:29 +02:00
Nicolò Ribaudo
718017d896 Use "release" event instead of "push" 2019-07-20 14:30:33 +02:00
Daniel Tschinder
a0cb7b1ab1 Rename github action 2019-07-19 15:46:51 +02:00
Daniel Tschinder
0b886418c8 Use github actions for welcome comment 2019-07-19 14:44:40 +02:00
Babel Bot
0371979a3e Add v7.5.5 to CHANGELOG.md [skip ci] 2019-07-17 21:29:47 +00:00
Nicolò Ribaudo
0407f034f0 v7.5.5 2019-07-17 23:08:08 +02:00
Nicolò Ribaudo
d919ecd254 Move lerna fork to the babel org 2019-07-17 00:02:41 +02:00
Daniel Tschinder
d8da63c929 Use correct extension for typescript fixtures (#10014)
* Use correct extension for typescript fixtures

* Change transform fixtures

* Adjust editorconfig for ts files

* Rename new tests

Co-authored-by: Nicolò Ribaudo (nicolo.ribaudo@gmail.com)
2019-07-15 22:46:03 +02:00
Tan Li Hau
eb3230f9db fix code-frame marker with highlighting (#10211) 2019-07-15 21:16:18 +02:00
Nicolò Ribaudo
7dc5fdb390 Workaround #10179 in proposal-object-rest-spread (#10200) 2019-07-15 19:01:29 +02:00
Tan Li Hau
ee68d6d1b0 add assertShape to validate templateElement (#10198)
* add assertShape to validate templateElement

* Update packages/babel-types/src/definitions/utils.js

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

* templateElement optional cooked
2019-07-15 01:03:50 +02:00
Tan Li Hau
d3fe22f0e1 destructuring private fields with array pattern / object patte… (#10017)
* destructuring private fields with array pattern / object pattern

* wip: new test cases

* destrucuring and rest for private properties

* test case for loose private-loose

* add transform-desturcturing for exec

* update test case

* remove getPrototypeOf imports from get and set

* wip: destructure super assignment

* throw "Destructuring to a super field is not supported yet."

* fix tests and fix assignment pattern

* remove CallExpression from AssignmentPattern
2019-07-15 01:00:20 +02:00
James DiGioia
7f47cb65d0 Add Pipeline nodes to ast.spec [skip ci] (#10214) 2019-07-13 19:11:51 +02:00
Tan Li Hau
8b9af1be2f fix transform-flow-comments for import types (#9901)
* fix transform-flow-comments for import types

* update: dependencies
2019-07-13 16:06:42 +02:00
Tan Li Hau
f5ca0587d1 always throw when add missing helpers (#10208) 2019-07-12 12:53:55 -05:00
Sagiv ben giat
a9660cf559 resolve #10205 (#10207) 2019-07-12 11:00:25 -05:00
dependabot[bot]
8107a6faa2 Bump lodash.template from 4.4.0 to 4.5.0 (#10204)
Bumps [lodash.template](https://github.com/lodash/lodash) from 4.4.0 to 4.5.0.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.4.0...4.5.0)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-12 10:29:48 +02:00
cybai
42000b9907 Upgrade lodash to 4.17.13 (#10191) 2019-07-12 10:29:06 +02:00
Huáng Jùnliàng
5d9a786b2f perf: match ownKeys perf to the one of objectSpread (#10189) 2019-07-10 21:03:01 -05:00
Huáng Jùnliàng
e88a569e83 fix: custom instOfHandler result should be cast to boolean (#10197) 2019-07-10 23:38:46 +02:00
Babel Bot
4eab157502 Add v7.5.4 to CHANGELOG.md [skip ci] 2019-07-09 18:58:16 +00:00
1491 changed files with 15967 additions and 6576 deletions

View File

@@ -6,7 +6,7 @@ charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
[*.{js,json}]
[*.{js,json,ts,tsx}]
indent_style = space
indent_size = 2

View File

@@ -122,7 +122,7 @@
* Restructure transformers so they're only ran if the AST contains nodes that they need to worry about. Improves transpilation speed significantly.
* **Bug Fix**
* Fix source maps not tracking end of node locations.
* **Spec Compliancy**
* **Spec Compliance**
* Use static super references as the home object is actually done at definition time.
* **Polish**
* Force the `es6.destructuring` transformer to be whitelisted when the `es7.objectSpread` transformer is.
@@ -479,7 +479,7 @@
## 2.12.3
* **Spec Compliancy**
* **Spec Compliance**
* Optional `typeof` transformer checks for `undefined` before passing it to the helper.
* Class methods are now named.
@@ -551,7 +551,7 @@
* Add `classesFastSuper` optional transformer that doesn't support parent getters and prototype changing.
* Add `forOfFast` transformer that speeds up `for...of` on arrays but produces more code.
* Add `--react-compat` to `bin/6to5`.
* **Spec Compliancy**
* **Spec Compliance**
* Disallow setters without a single parameter.
* Add `configurable` and `writable` to defined properties.
* Use define instead of assignment for class methods.
@@ -619,7 +619,7 @@
## 2.7.0
* **Spec Compliancy**
* **Spec Compliance**
* Disallow reassignments of imports.
* **New Feature**
* `reactCompat` option to enable pre-v0.12 react components.
@@ -662,7 +662,7 @@
* **Polish**
* Move `"use strict";` to inside module bodies instead of at the top of the file.
* Better handling of dynamic imports.
* **Spec Compliancy**
* **Spec Compliance**
* Class inheritance now has a `function` or `null` type check.
* Add `interopRequireWildcard` around wildcard imports and exports to handle non-object exports.

View File

@@ -110,7 +110,7 @@
* Throw an error on different `babel` and `babel-runtime` versions.
* Replicate module environment for `babel-node` eval.
* Clean up classes output.
* **Spec Compliancy**
* **Spec Compliance**
* Make it illegal to use a rest parameter on a setter.
## 4.6.6
@@ -150,8 +150,8 @@
* **New Feature**
* Desugar sticky regexes to a new constructor expression so it can be handled by a polyfill.
* **Spec Compliancy**
* `for...of` now outputs in a lengthy `try...catch` this is to ensure spec compliancy in regards to iterator returns and abrupt completions. See [google/traceur-compiler#1773](https://github.com/google/traceur-compiler/issues/1773) and [babel/babel/#838](https://github.com/babel/babel/issues/838) for more information.
* **Spec Compliance**
* `for...of` now outputs in a lengthy `try...catch` this is to ensure spec compliance in regards to iterator returns and abrupt completions. See [google/traceur-compiler#1773](https://github.com/google/traceur-compiler/issues/1773) and [babel/babel/#838](https://github.com/babel/babel/issues/838) for more information.
* **Polish**
* Rest parameters that are only referred to via number properties on member expressions are desugared into a direct `arguments` reference. Thanks [@neVERberleRfellerER](https://github.com/neVERberleRfellerER)!
* `$ babel` no longer exits on syntax errors.

View File

@@ -12,7 +12,7 @@
## 5.8.24
* **Spec Compliancy**
* **Spec Compliance**
* Updated `optimisation.react.inlineElements` transformer to React 0.14 output. Thanks [@spicyj](https://github.com/spicyj)!
* **Polish**
* Add support for evaluating more static nodes. Thanks [@hzoo](https://github.com/hzoo)!
@@ -451,7 +451,7 @@ Issues with publish process.
![gifs lol](https://31.media.tumblr.com/568205a0e37ae15eca510fa639589a59/tumblr_n8kw8kpcSb1sg6cg8o1_500.gif)
* **Spec Compliancy**
* **Spec Compliance**
* Allow trailing param commas for methods when using the `es7.trailingCommas` transformer.
* **Bug Fix**
* Fix `es6.blockScoping` transformer not properly ignoring `break` in `SwitchCase`.
@@ -481,7 +481,7 @@ Issues with publish process.
* Fix correct function scope being passed to `nameMethod.property` when inferring the function name for class methods.
* Fix incorrect extensions reference causing weird issues when using the Babel CLI.
* Fix destructuring param reference replacements not inheriting from their original param.
* **Spec Compliancy**
* **Spec Compliance**
* Fix order that method decorators are ran in.
## 5.2.15
@@ -616,7 +616,7 @@ Issues with publish process.
* Fix `externalHelpers` option being incorrectly listed as type `string`.
* **Internal**
* Upgrade `core-js` to `0.9.0`.
* **Spec Compliancy**
* **Spec Compliance**
* Fix object decorators not using the `initializer` pattern.
* Remove property initializer descriptor reflection.

View File

@@ -22,7 +22,7 @@
> Backports for some folks (also other's when we accidentally merged PRs from both 6.x/master)
> Lesson learned: just use `master` and backport on another branch.
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `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))
@@ -1468,7 +1468,7 @@ It's a one-time use tool (helpful after the initial release when upgrading from
## v6.17.0 (2016-10-01)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-preset-stage-2`, `babel-preset-stage-3`
* [#4617](https://github.com/babel/babel/pull/4617) Move async-generators to stage-3. ([@hzoo](https://github.com/hzoo))
@@ -1476,7 +1476,7 @@ It's a one-time use tool (helpful after the initial release when upgrading from
Specification repo: https://github.com/tc39/proposal-async-iteration
Asynchronous Iteration was already added in [6.16.0](http://babeljs.io/blog/2016/09/28/6.16.0#spec-compliancy) under stage-2 but it was moved to stage-3 at the [latest TC-39 meeting](https://github.com/tc39/agendas/blob/master/2016/09.md#agenda-for-the-54th-meeting-of-ecma-tc39).
Asynchronous Iteration was already added in [6.16.0](http://babeljs.io/blog/2016/09/28/6.16.0#spec-compliance) under stage-2 but it was moved to stage-3 at the [latest TC-39 meeting](https://github.com/tc39/agendas/blob/master/2016/09.md#agenda-for-the-54th-meeting-of-ecma-tc39).
```js
// async generator syntax
@@ -1569,7 +1569,7 @@ First PR!
Babel 6.16: Happy 2nd Birthday 🎂!
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-core`, `babel-generator`, `babel-helper-remap-async-to-generator`, `babel-helpers`, `babel-plugin-transform-async-generator-functions`, `babel-types`, `babel-preset-stage-2`, ...
* [#3473](https://github.com/babel/babel/pull/3473) via [#4576](https://github.com/babel/babel/pull/4576) Implement support for async generator functions and for-await statements. ([@zenparsing](https://github.com/zenparsing))
@@ -2036,7 +2036,7 @@ It's also a lot folk's first PR (or first code PR)!
* `babel-generator`, `babel-types`
* [#3570](https://github.com/babel/babel/pull/3570) Add support for the new declare module.exports of flow. ([@danez](https://github.com/danez))
#### Spec Compliancy
#### Spec Compliance
* `babel-plugin-transform-es2015-modules-amd`, `babel-plugin-transform-es2015-modules-commonjs`, `babel-plugin-transform-es2015-modules-umd`
* [#3518](https://github.com/babel/babel/pull/3518) Throw error for multiple exports default. ([@kaicataldo](https://github.com/kaicataldo))
@@ -2332,7 +2332,7 @@ Length: The number of characters in the output code
* `babel-plugin-transform-react-jsx-self`, `babel-preset-react`
* [#3540](https://github.com/babel/babel/pull/3540) Added jsx-self babel transform plugin. ([@jimfb](https://github.com/jimfb))
#### Spec Compliancy
#### Spec Compliance
* `babel-plugin-transform-es2015-unicode-regex`
* [#3338](https://github.com/babel/babel/pull/3338) Update to `regexpu-core@2.0.0` for ES2016 compliance. ([@mathiasbynens](https://github.com/mathiasbynens))
@@ -3206,7 +3206,7 @@ Changes to note:
- Reverting the class properties semicolon parser error.
- Fix regression with plugin ordering with `babel-register`.
#### Spec Compliancy
#### Spec Compliance
* `babel-plugin-transform-class-properties`, `babylon`
* [#3332](https://github.com/babel/babel/pull/3332) Revert to standard ASI behavior for class properties. ([@loganfsmyth](https://github.com/loganfsmyth))
@@ -3628,7 +3628,7 @@ Thanks to @samwgoldman for all the new flow support!
* `babel-plugin-transform-es2015-parameters`: [#3191](https://github.com/babel/babel/pull/3191) Fix the order of arguments initialization (fixes [T6809](http://phabricator.babeljs.io/T6809))
* `babel-traverse`: [#3198](https://github.com/babel/babel/pull/3198) In `evaluate()`, it should not mistake lack of confidence for falsy
* **Spec Compliancy**
* **Spec Compliance**
* `babylon`, `babel-generator`, `babel-plugin-transform-regenerator`: [#3190](https://github.com/babel/babel/pull/3190): Remove `await *` from `babylon` and raise an error for that syntax since it was removed from the proposal and was causing an issue at runtime but not at compile time (fixes [T6688](http://phabricator.babeljs.io/T6688)).
* **Internal**
@@ -3863,7 +3863,7 @@ Thanks to @samwgoldman for all the new flow support!
* Move `children` prop pushing to after props to ensure correct order in the react inline elements plugin.
* Fix `buildExternalHelpers` script ignoring non-underscored helpers.
* Fix exported classes with static class properties.
* **Spec Compliancy**
* **Spec Compliance**
* Add support for computed mutators in `babel-plugin-transform-es2015-computed-properties`.
* **Polish**
* Make interop for plugins with the `__esModule` work for all plugins no matter how they're imported/specified.
@@ -3904,7 +3904,7 @@ Thanks to @samwgoldman for all the new flow support!
* **Polish**
* Add npm 3 check to `babel-doctor`.
* Autoclear the `babel/register` cache when it gets too big to be serialised.
* **Spec Compliancy**
* **Spec Compliance**
* Add support for flow existential type parameters.
## 6.1.1
@@ -3969,7 +3969,7 @@ Thanks to @samwgoldman for all the new flow support!
## 6.0.14
* **Spec Compliancy**
* **Spec Compliance**
* Update exponentiation operator precedence.
* Fix parser bug where arrow functions have a higher precedence than they should.
* **Bug Fix**

View File

@@ -2,6 +2,8 @@
Before making a PR, please read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
Please note that the Babel Team requires two approvals before merging most PRs.
For 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)
If you are making a change that should have a docs update: submit another PR to https://github.com/babel/website
@@ -9,7 +11,7 @@ If you are making a change that should have a docs update: submit another PR to
| Q                       | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues? | `Fixes #1, Fixes #2` <!-- remove the (`) quotes to link the issues -->
| Fixed Issues? | `Fixes #1, Fixes #2` <!-- remove the (`) quotes and write "Fixes" before the number to link the issues -->
| Patch: Bug Fix? |
| Major: Breaking Change? |
| Minor: New Feature? |

View File

@@ -1,16 +0,0 @@
FROM debian:stable-slim
LABEL "name"="create-release-tag"
LABEL "version"="0.0.1"
LABEL "com.github.actions.name"="Create release tag"
LABEL "com.github.actions.description"="Creates a release tag equal to the last commit message"
LABEL "com.github.actions.icon"="tag"
LABEL "com.github.actions.color"="gray-dark"
ADD entrypoint.sh /action/entrypoint.sh
RUN chmod +x /action/entrypoint.sh
RUN apt-get update && apt-get install -y --no-install-recommends git
ENTRYPOINT ["/action/entrypoint.sh"]

View File

@@ -1,14 +0,0 @@
#!/bin/sh
set -e
# GitHub doesn't support running actions on new tags yet: we need to run it on the commit.
# For this reason, we can't be sure that the tag already exists. We can use the commit
# message to create the tag. If the tag already exists locally, they won't conflict because
# they have the same name and are on the same commit.
echo "INFO: Getting release version..."
tag_name=$(git log --oneline --format=%B -1 $GITHUB_SHA)
echo "INFO: Creating new tag..."
(git tag $tag_name $GITHUB_SHA) || echo "INFO: Tag already exists"

View File

@@ -1,16 +0,0 @@
FROM debian:stable-slim
LABEL "name"="filter"
LABEL "version"="1.1.0"
LABEL "com.github.actions.name"="Filter commit message"
LABEL "com.github.actions.description"="Stop a workflow if the message of the current commit doesn't match the pattern"
LABEL "com.github.actions.icon"="filter"
LABEL "com.github.actions.color"="gray-dark"
ADD entrypoint.sh /action/entrypoint.sh
RUN chmod +x /action/entrypoint.sh
RUN apt-get update && apt-get install -y --no-install-recommends git
ENTRYPOINT ["/action/entrypoint.sh"]

View File

@@ -1,15 +0,0 @@
#!/bin/sh
set -e
pattern=$1
message=$(git log --oneline --format=%B -1 $GITHUB_SHA)
if echo "$message" | grep -Pq "$pattern"; then
echo "INFO: $message matches $pattern"
exit 0
else
echo "INFO: $message does not match $pattern"
# 78 is the "neutral" exit status
exit 78
fi

View File

@@ -1,19 +0,0 @@
FROM node:10
LABEL "name" = "trigger-github-release"
LABEL "version" = "0.0.1"
LABEL "com.github.actions.name" = "Trigger GitHub release"
LABEL "com.github.actions.description" = "Trigger a new GitHub release and generate the changelog using lerna-changelog."
LABEL "com.github.actions.icon" = "tag"
LABEL "com.github.actions.color" = "yellow"
ADD entrypoint.sh /action/entrypoint.sh
ADD package.json /action/package.json
ADD package-lock.json /action/package-lock.json
ADD release.js /action/release.js
ADD update-changelog.js /action/update-changelog.js
RUN chmod +x /action/entrypoint.sh
ENTRYPOINT ["/action/entrypoint.sh"]

View File

@@ -1,38 +0,0 @@
#!/bin/sh
set -e
echo "INFO: Installing action dependencies..."
(cd /action; npm ci)
echo "INFO: Getting release version..."
current_tag=$(git describe --abbrev=0 --tags $GITHUB_SHA)
last_tag=$(git describe --abbrev=0 --tags $current_tag^)
echo "INFO: New version is $current_tag; last version is $last_tag."
echo "INFO: Generating the changelog..."
# lerna-changelog expects the token to be provided as GITHUB_AUTH,
# but GitHub actions don't allow to predefine custom env vars prefixed with
# GITHUB_. We need to define it here.
changelog=$(
GITHUB_AUTH="$GITHUB_TOKEN" \
node /action/node_modules/.bin/lerna-changelog --tag-from $last_tag --tag-to $current_tag
)
echo "INFO: Publishing the new GitHub release..."
echo "$changelog" | node /action/release $current_tag
echo "INFO: Updating CHANGELOG.md..."
echo "$changelog" | node /action/update-changelog
echo "INFO: Committing changelog..."
git add CHANGELOG.md
git -c user.name="$COMMIT_AUTHOR_NAME" -c user.email="$COMMIT_AUTHOR_EMAIL" \
commit -m "Add $current_tag to CHANGELOG.md [skip ci]" --no-verify --quiet
echo "INFO: Pushing updates..."
git push "https://${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" master
echo "INFO: Done! Don't forget to thank new contributors :)"

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +0,0 @@
{
"private": true,
"name": "@internal/trigger-github-release",
"version": "0.0.1",
"author": "Nicolò Ribaudo <nicolo.ribaudo@gmail.com>",
"license": "MIT",
"dependencies": {
"@octokit/rest": "^16.3.0",
"get-stdin": "^6.0.0",
"lerna-changelog": "^0.8.2"
}
}

View File

@@ -1,26 +0,0 @@
"use strict";
const [ /* node */, /* file */, tag ] = process.argv;
const getStdin = require("get-stdin");
const octokit = require("@octokit/rest")();
octokit.authenticate({
type: "token",
token: process.env.GITHUB_TOKEN
});
const [ repoOwner, repoName ] = process.env.GITHUB_REPOSITORY.split("/");
getStdin()
.then(changelog => octokit.repos.createRelease({
owner: repoOwner,
repo: repoName,
tag_name: tag,
body: changelog,
draft: true,
}))
.catch(err => {
console.error(err);
process.exit(1);
});

View File

@@ -1,31 +0,0 @@
"use strict";
const getStdin = require("get-stdin");
const fs = require("fs").promises;
const path = require("path");
const { GITHUB_WORKSPACE } = process.env;
const INSERTION_POINT = "<!-- insert-new-changelog-here -->";
const CHANGELOG = path.resolve(GITHUB_WORKSPACE, "CHANGELOG.md");
main();
async function main() {
let [stdin, changelog] = await Promise.all([
getStdin(),
fs.readFile(CHANGELOG, "utf8"),
]);
if (!changelog.includes(INSERTION_POINT)) {
throw new Error(`Missing "${INSERTION_POINT}" in CHANGELOG.md`);
}
// Remove committers
stdin = stdin.split("\n\n#### Committers")[0];
changelog = changelog.replace(
INSERTION_POINT,
INSERTION_POINT + "\n" + stdin
);
await fs.writeFile(CHANGELOG, changelog);
}

53
.github/main.workflow vendored
View File

@@ -1,53 +0,0 @@
workflow "Release" {
on = "push"
resolves = [
"Trigger GitHub release",
# GitHub actions are too slow for this, it takes more than 15 mins.
# Publishing to npm from GH actions is a cool idea, but it's a lot faster to
# publish locally.
# "Publish to npm",
]
}
action "Trigger GitHub release" {
uses = "./.github/actions/trigger-github-release/"
secrets = ["GITHUB_TOKEN"]
env = {
COMMIT_AUTHOR_NAME = "Babel Bot"
COMMIT_AUTHOR_EMAIL = "babel-bot@users.noreply.github.com"
}
needs = ["Create release tag"]
}
action "Publish to npm" {
uses = "docker://node:10"
secrets = ["NPM_TOKEN"]
runs = "make"
args = "publish-ci"
env = {
CI = "true"
}
needs = ["Create release tag"]
}
# When GitHub Actions will support the "release" event for public
# repositories, we won't need this checks anymore.
action "Create release tag" {
uses = "./.github/actions/create-release-tag"
needs = [
"Is version commit",
"On master branch",
]
}
action "Is version commit" {
uses = "./.github/actions/filter-commit-message"
# This regex is run using "grep -P".
# The (-\\S+) part is for 7.0.0-beta.1 releases.
args = "^v(\\d+\\.){2}\\d+(-\\S+)?$"
}
action "On master branch" {
uses = "actions/bin/filter@master"
args = "branch master"
}

81
.github/workflows/issue-triage.yml vendored Normal file
View File

@@ -0,0 +1,81 @@
name: Issue Triage
on:
issues:
types: [opened, labeled]
jobs:
welcome:
name: Welcome comment
runs-on: ubuntu-latest
steps:
- name: Check if Babel member
id: is_babel_member
if: github.event.action == 'opened'
uses: babel/actions/is-org-member@v2
with:
org: babel
username: ${{ github.event.issue.user.login }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Welcome Comment
uses: babel/actions/create-comment@v2
if: |
github.event.action == 'opened' &&
steps.is_babel_member.outputs.result == 0
with:
token: ${{ secrets.BOT_TOKEN }}
issue: ${{ github.event.issue.number }}
comment: >
Hey @${{ github.event.issue.user.login }}!
We really appreciate you taking the time to report an issue. The
collaborators on this project attempt to help as many people as
possible, but we're a limited number of volunteers, so it's
possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a
vibrant [Slack community](https://babeljs.slack.com) that typically always has someone
willing to help. You can sign-up [here](https://slack.babeljs.io/) for an invite."
needs_info:
name: Needs Info
runs-on: ubuntu-latest
steps:
- name: Create Needs Info Comment
uses: babel/actions/create-comment@v2
if: |
github.event.action == 'labeled' &&
github.event.label.name == 'Needs Info'
with:
token: ${{ secrets.BOT_TOKEN }}
issue: ${{ github.event.issue.number }}
comment: >
Hi @${{ github.event.issue.user.login }}!
This issue is missing some important information we'll need
to be able to reproduce this issue.
Please understand that we receive a high volume of issues,
and there are only a limited number of volunteers that help
maintain this project. The easier it is for us to decipher an
issue with the info provided, the more likely it is that we'll
be able to help.
Please make sure you have the following information documented in
this ticket:
1. Your Babel configuration (typically from `.babelrc` or `babel.config.js`)
2. The current (incorrect) behavior you're seeing
3. The behavior you expect
4. A [short, self-contained example](http://sscce.org/)
Please provide either a link to the problem via the
[`repl`](https://babeljs.io/repl/), or if the `repl` is
insufficient, a new and minimal repository with instructions on
how to build/replicate the issue.

53
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: Release
on:
push:
tags: ["v*"]
jobs:
github_release:
name: Trigger GitHub release
runs-on: ubuntu-latest
steps:
- name: Checkout the new tag
uses: actions/checkout@v1.0.0
- name: Get tag info
id: tags
uses: babel/actions/get-release-tags@v2
- name: Generate the changelog
id: changelog
uses: babel/actions/generate-lerna-changelog@v2
with:
from: ${{ steps.tags.outputs.old }}
to: ${{ steps.tags.outputs.new }}
env:
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
- name: Create a draft GitHub release
uses: babel/actions/publish-github-release@v2
with:
tag: ${{ steps.tags.outputs.new }}
changelog: ${{ steps.changelog.outputs.changelog }}
token: ${{ secrets.BOT_TOKEN }}
- name: Check if releasing from master
id: is_master
uses: babel/actions/ref-matches-branch@v2
with:
name: master
- name: Update CHANGELOG.md
if: steps.is_master.outputs.result == 1
uses: babel/actions/update-changelog@v2
with:
changelog: ${{ steps.changelog.outputs.changelog }}
- name: Commit CHANGELOG.md
if: steps.is_master.outputs.result == 1
run: |
git add CHANGELOG.md
git -c user.name="Babel Bot" -c user.email="babel-bot@users.noreply.github.com" \
commit -m "Add ${{ steps.tags.outputs.new }} to CHANGELOG.md [skip ci]" --no-verify --quiet
git push "https://babel-bot:${{ secrets.BOT_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" master

View File

@@ -2,7 +2,7 @@
> **Tags:**
> - :boom: [Breaking Change]
> - :eyeglasses: [Spec Compliancy]
> - :eyeglasses: [Spec Compliance]
> - :rocket: [New Feature]
> - :bug: [Bug Fix]
> - :memo: [Documentation]
@@ -18,6 +18,135 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
<!-- insert-new-changelog-here -->
## v7.6.1 (2019-09-06)
#### :bug: Bug Fix
* `babel-types`
* [#10404](https://github.com/babel/babel/pull/10404) fix(types): correct typescript function headers ([@forstermatth](https://github.com/forstermatth))
* `babel-node`
* [#9758](https://github.com/babel/babel/pull/9758) Remove process.exit(1) from babel-node ([@dword-design](https://github.com/dword-design))
## v7.6.0 (2019-09-06)
#### :eyeglasses: Spec Compliance
* `babel-generator`, `babel-parser`
* [#10269](https://github.com/babel/babel/pull/10269) Fix parenthesis for nullish coalescing ([@vivek12345](https://github.com/vivek12345))
* `babel-helpers`, `babel-plugin-transform-block-scoping`, `babel-traverse`
* [#9498](https://github.com/babel/babel/pull/9498) Fix tdz checks in transform-block-scoping plugin ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :rocket: New Feature
* `babel-core`
* [#10181](https://github.com/babel/babel/pull/10181) feat(errors): validate preset when filename is absent ([@JLHwung](https://github.com/JLHwung))
* `babel-helper-create-class-features-plugin`, `babel-helpers`, `babel-plugin-proposal-private-methods`
* [#10217](https://github.com/babel/babel/pull/10217) Class Private Static Accessors ([@tim-mc](https://github.com/tim-mc))
* `babel-generator`, `babel-parser`, `babel-types`
* [#10148](https://github.com/babel/babel/pull/10148) V8intrinsic syntax plugin ([@JLHwung](https://github.com/JLHwung))
* `babel-preset-typescript`
* [#10382](https://github.com/babel/babel/pull/10382) Allow setting 'allowNamespaces' in typescript preset ([@dsgkirkby](https://github.com/dsgkirkby))
* `babel-parser`
* [#10352](https://github.com/babel/babel/pull/10352) Do not register ambient classes to the TS scope ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-types`
* [#10248](https://github.com/babel/babel/pull/10248) Add static to class property builder ([@yuri-karadzhov](https://github.com/yuri-karadzhov))
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-transform-destructuring`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
* [#10396](https://github.com/babel/babel/pull/10396) fix: early return when instance is not iterable ([@JLHwung](https://github.com/JLHwung))
* `babel-plugin-transform-runtime`
* [#10398](https://github.com/babel/babel/pull/10398) Add supports for polyfill computed methods ([@rhyzx](https://github.com/rhyzx))
* `babel-preset-env`
* [#10397](https://github.com/babel/babel/pull/10397) Don't polyfill when evaluation is not confident ([@rhyzx](https://github.com/rhyzx))
* [#10218](https://github.com/babel/babel/pull/10218) [preset-env] Include / exclude module plugins properly ([@AdamRamberg](https://github.com/AdamRamberg))
* [#10284](https://github.com/babel/babel/pull/10284) Replace es.string.reverse with es.array.reverse ([@epicfaace](https://github.com/epicfaace))
* `babel-plugin-transform-named-capturing-groups-regex`
* [#10395](https://github.com/babel/babel/pull/10395) fix: transform name capturing regex once ([@JLHwung](https://github.com/JLHwung))
* `babel-types`
* [#10098](https://github.com/babel/babel/pull/10098) fix typescript for babel-types ([@tanhauhau](https://github.com/tanhauhau))
* [#10319](https://github.com/babel/babel/pull/10319) Add a builder definition including name for tsTypeParameter ([@deificx](https://github.com/deificx))
* `babel-parser`
* [#10380](https://github.com/babel/babel/pull/10380) Refactor trailing comment adjustment ([@banga](https://github.com/banga))
* [#10369](https://github.com/babel/babel/pull/10369) Retain trailing comments in array expressions ([@banga](https://github.com/banga))
* [#10292](https://github.com/babel/babel/pull/10292) fix: assign trailing comment to ObjectProperty only when inside an ObjectExpression ([@JLHwung](https://github.com/JLHwung))
* `babel-parser`, `babel-types`
* [#10366](https://github.com/babel/babel/pull/10366) Don't allow JSXNamespacedName to chain ([@jridgewell](https://github.com/jridgewell))
* `babel-generator`, `babel-plugin-transform-typescript`, `babel-types`
* [#10341](https://github.com/babel/babel/pull/10341) Add TSBigIntKeyword to @babel/types ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-core`, `babel-types`
* [#9960](https://github.com/babel/babel/pull/9960) Do not delete "fake" source map comments from strings ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-flow-comments`
* [#10329](https://github.com/babel/babel/pull/10329) Fix flow comments plugin issues ([@zaygraveyard](https://github.com/zaygraveyard))
* `babel-helpers`, `babel-plugin-transform-react-constant-elements`
* [#10307](https://github.com/babel/babel/pull/10307) [fix] jsx helper calls order ([@Sinewyk](https://github.com/Sinewyk))
* `babel-plugin-proposal-decorators`
* [#10302](https://github.com/babel/babel/pull/10302) fix: register inserted class declaration ([@thiagoarrais](https://github.com/thiagoarrais))
* `babel-plugin-proposal-do-expressions`, `babel-traverse`
* [#10070](https://github.com/babel/babel/pull/10070) Do expressions transform for switch statements ([@tanhauhau](https://github.com/tanhauhau))
* [#10277](https://github.com/babel/babel/pull/10277) remove finally from completion record in try statement ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helpers`, `babel-plugin-transform-named-capturing-groups-regex`
* [#10136](https://github.com/babel/babel/pull/10136) fix capturing group for matchAll ([@tanhauhau](https://github.com/tanhauhau))
#### :nail_care: Polish
* `babel-plugin-transform-runtime`, `babel-preset-env`
* [#10372](https://github.com/babel/babel/pull/10372) Don't allow instance properties transformation on namespace ([@rhyzx](https://github.com/rhyzx))
#### :memo: Documentation
* [#10313](https://github.com/babel/babel/pull/10313) Adds note about two approval policy to PR template ([@thiagoarrais](https://github.com/thiagoarrais))
#### :house: Internal
* `babel-register`
* [#9847](https://github.com/babel/babel/pull/9847) Remove core-js dependency from @babel/register ([@coreyfarrell](https://github.com/coreyfarrell))
* `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-preset-env`
* [#10401](https://github.com/babel/babel/pull/10401) Use "validateLogs" for preset-env's debug fixtures ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-parser`
* [#10380](https://github.com/babel/babel/pull/10380) Refactor trailing comment adjustment ([@banga](https://github.com/banga))
* `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-plugin-proposal-dynamic-import`, `babel-preset-env`
* [#10326](https://github.com/babel/babel/pull/10326) Allow testing logs with `@babel/helper-transform-fixture-test-runner` ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-runtime-corejs2`, `babel-runtime`, `babel-types`
* [#10331](https://github.com/babel/babel/pull/10331) Commit generated code ([@JLHwung](https://github.com/JLHwung))
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-create-class-features-plugin`, `babel-helper-fixtures`, `babel-node`, `babel-parser`, `babel-plugin-proposal-do-expressions`, `babel-plugin-proposal-pipeline-operator`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-runtime`, `babel-preset-env`, `babel-standalone`, `babel-template`, `babel-traverse`, `babel-types`
* [#10228](https://github.com/babel/babel/pull/10228) Update dev dependencies and fix linting errors ([@danez](https://github.com/danez))
* `babel-cli`
* [#10244](https://github.com/babel/babel/pull/10244) added flow to babel cli ([@Letladi](https://github.com/Letladi))
#### :running_woman: Performance
* `babel-helpers`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
* [#10161](https://github.com/babel/babel/pull/10161) Improves the logic to import objects in helpers ([@ifsnow](https://github.com/ifsnow))
* `babel-traverse`
* [#10243](https://github.com/babel/babel/pull/10243) perf: always return `void 0` as undefined node ([@JLHwung](https://github.com/JLHwung))
## v7.5.5 (2019-07-17)
#### :bug: Bug Fix
* `babel-code-frame`
* [#10211](https://github.com/babel/babel/pull/10211) fix code-frame marker with highlighting ([@tanhauhau](https://github.com/tanhauhau))
* `babel-plugin-proposal-object-rest-spread`
* [#10200](https://github.com/babel/babel/pull/10200) Workaround #10179 in proposal-object-rest-spread ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-types`
* [#10198](https://github.com/babel/babel/pull/10198) add assertShape to validate templateElement ([@tanhauhau](https://github.com/tanhauhau))
* `babel-helper-create-class-features-plugin`, `babel-helper-member-expression-to-functions`, `babel-helper-replace-supers`, `babel-helpers`, `babel-plugin-proposal-class-properties`, `babel-plugin-transform-classes`, `babel-plugin-transform-object-super`, `babel-types`
* [#10017](https://github.com/babel/babel/pull/10017) destructuring private fields with array pattern / object pattern ([@tanhauhau](https://github.com/tanhauhau))
* `babel-plugin-transform-flow-comments`
* [#9901](https://github.com/babel/babel/pull/9901) fix transform-flow-comments for import types ([@tanhauhau](https://github.com/tanhauhau))
* `babel-core`, `babel-helpers`
* [#10208](https://github.com/babel/babel/pull/10208) always throw when add missing helpers ([@tanhauhau](https://github.com/tanhauhau))
* `babel-plugin-transform-runtime`
* [#10207](https://github.com/babel/babel/pull/10207) Closes [#10205](https://github.com/babel/babel/issues/10205) ([@sag1v](https://github.com/sag1v))
* `babel-helpers`, `babel-plugin-transform-instanceof`
* [#10197](https://github.com/babel/babel/pull/10197) fix: custom instOfHandler result should be cast to boolean ([@JLHwung](https://github.com/JLHwung))
#### :house: Internal
* `babel-parser`, `babel-plugin-transform-typescript`
* [#10014](https://github.com/babel/babel/pull/10014) Use correct extension for typescript fixtures ([@danez](https://github.com/danez))
#### :running_woman: Performance
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10189](https://github.com/babel/babel/pull/10189) perf: match ownKeys perf to the one of objectSpread ([@JLHwung](https://github.com/JLHwung))
## v7.5.4 (2019-07-09)
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10188](https://github.com/babel/babel/pull/10188) Fix _objectSpread2 for real ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.5.3 (2019-07-09)
#### :bug: Bug Fix
@@ -355,7 +484,7 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
## v7.3.3 (2019-02-15)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-generator`
* [#9501](https://github.com/babel/babel/pull/9501) Correctly output escapes in directives ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
@@ -377,11 +506,11 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
* [#9491](https://github.com/babel/babel/pull/9491) Better error output in parser tests ([@danez](https://github.com/danez))
## v7.3.2 (2019-02-04)
Various spec compliancy fixes and better support for smart pipelines and private methods.
Various spec compliance fixes and better support for smart pipelines and private methods.
Thanks @gverni, @naffiq, @spondbob and @dstaley for their first PRs!
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-parser`
* [#9403](https://github.com/babel/babel/pull/9403) Fix line continuation with Unicode line terminators. ([@danez](https://github.com/danez))
* [#9400](https://github.com/babel/babel/pull/9400) Make yield a contextual keyword. ([@danez](https://github.com/danez))
@@ -429,7 +558,7 @@ This release fixes some regressions introduced in v7.3.0
Thanks to @jamesgeorge007 and @armano2 for their first PR!
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-parser`
* [#9314](https://github.com/babel/babel/pull/9314) Disallow async functions as loop body. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#9315](https://github.com/babel/babel/pull/9315) Parse class heritage as strict mode code. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
@@ -650,7 +779,7 @@ You can read more about this release at https://babeljs.io/blog/2018/12/03/7.2.0
## v7.1.5 (2018-11-06)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-parser`, `babylon`
* [#7727](https://github.com/babel/babel/pull/7727) Fix await in function name and parameters. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
@@ -1113,7 +1242,7 @@ Fixed a peerDep issue
Mostly bug fixes and some decorator updates
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-plugin-proposal-unicode-property-regex`
* [#8127](https://github.com/babel/babel/pull/8127) Update plugin-proposal-unicode-property-regex for Unicode v11. ([@mathiasbynens](https://github.com/mathiasbynens))
* `babel-parser`
@@ -1213,7 +1342,7 @@ Mostly bugfix release for a regression in decorators, and a quick fix for some n
- Fix IE10 class regression
- Various fixes, many TS fixes
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-parser`, `babel-plugin-proposal-json-strings`, `babel-plugin-syntax-json-strings`, `babel-preset-stage-3`
* [#7985](https://github.com/babel/babel/pull/7985) Subsume json. ([@jridgewell](https://github.com/jridgewell))
@@ -1403,7 +1532,7 @@ Mostly bugfix release for a regression in decorators, and a quick fix for some n
* `babel-generator`, `babel-helper-define-map`, `babel-plugin-syntax-class-properties`, `babel-plugin-transform-parameters`, `babel-plugin-transform-react-constant-elements`, `babel-traverse`, `babel-types`
* [#7666](https://github.com/babel/babel/pull/7666) Private Properties phase 1. ([@jridgewell](https://github.com/jridgewell))
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-helper-simple-access`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-modules-systemjs`
* [#7766](https://github.com/babel/babel/pull/7766) Correct update expression Number coercion. ([@jridgewell](https://github.com/jridgewell))
* `babel-core`, `babel-generator`, `babel-plugin-proposal-decorators`, `babel-types`, `babylon`
@@ -1491,7 +1620,7 @@ Mostly bugfix release for a regression in decorators, and a quick fix for some n
Various fixes, also lazy-load `@babel/core` dependencies (should make config lookup and other API methods fast for other projects to use).
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-plugin-proposal-logical-assignment-operators`
* [#7604](https://github.com/babel/babel/pull/7604) Logical Assignment: ensure computed key isn't recomputed. ([@jridgewell](https://github.com/jridgewell))
@@ -1590,7 +1719,7 @@ We'll need to update tooling for this ^. Also published `gulp-babel@8.0.0-beta.2
* `babel-register`
* [#7416](https://github.com/babel/babel/pull/7416) Replace instead of merging babel-register options, and resolve cwd up front. ([@loganfsmyth](https://github.com/loganfsmyth))
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babylon`
* [#7503](https://github.com/babel/babel/pull/7503) Update test262 test script and a few keyword escape fixes. ([@existentialism](https://github.com/existentialism))
* [#7498](https://github.com/babel/babel/pull/7498) Disallow setters to have RestElement. ([@danez](https://github.com/danez))
@@ -1738,7 +1867,7 @@ We'll need to update tooling for this ^. Also published `gulp-babel@8.0.0-beta.2
## v7.0.0-beta.39 (2018-01-30)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-plugin-proposal-optional-chaining`
* [#6345](https://github.com/babel/babel/pull/6345) Remove old optional chain features. ([@jridgewell](https://github.com/jridgewell))
@@ -1951,7 +2080,7 @@ Fixes + [overrides](https://github.com/babel/babel/pull/7091) config feature
Various bug fixes, first version of Babel to use the MIT version of `regenerator`
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babylon`
* [#6986](https://github.com/babel/babel/pull/6986) Fix destructuring assignment spec violation. ([@ksashikumar](https://github.com/ksashikumar))
* `babel-helper-replace-supers`, `babel-helpers`, `babel-plugin-proposal-class-properties`, `babel-plugin-transform-classes`, `babel-plugin-transform-parameters`
@@ -2004,7 +2133,7 @@ Various bug fixes, first version of Babel to use the MIT version of `regenerator
* `babel-preset-stage-1`, `babel-preset-stage-2`
* [#6949](https://github.com/babel/babel/pull/6949) Fix stage refs to exportNamespaceFrom and exportDefaultFrom. ([@existentialism](https://github.com/existentialism))
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-preset-stage-0`, `babel-preset-stage-1`
* [#6943](https://github.com/babel/babel/pull/6943) Moving Do expression to stage 1. ([@rajzshkr](https://github.com/rajzshkr))
@@ -2018,7 +2147,7 @@ Various bug fixes, first version of Babel to use the MIT version of `regenerator
## v7.0.0-beta.33 (2017-12-01)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-generator`, `babel-plugin-proposal-export-default-from`, `babel-plugin-proposal-export-default`, `babel-plugin-proposal-export-namespace-from`, `babel-plugin-proposal-export-namespace`, `babel-plugin-syntax-export-default-from`, `babel-plugin-syntax-export-extensions`, `babel-plugin-syntax-export-namespace-from`, `babel-standalone`, `babylon`
* [#6920](https://github.com/babel/babel/pull/6920) Split exportExtensions into exportDefault and exportNamespace plugins…. ([@existentialism](https://github.com/existentialism))
* `babylon`
@@ -2203,7 +2332,7 @@ Various bug fixes, first version of Babel to use the MIT version of `regenerator
> Note: don't use ^ in your dependencies when using a beta. It can still break between (we should try not to do it but it can), so pin all the packages like `"@babel/cli" : "7.0.0-beta.4"`
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-plugin-transform-optional-chaining`
* [#6525](https://github.com/babel/babel/pull/6525) Optional Chaining: Account for document.all. ([@azz](https://github.com/azz))
* `babel-preset-env`, `babel-helper-remap-async-to-generator`, `babel-helpers`, `babel-plugin-transform-async-generator-functions`, `babel-plugin-transform-async-to-generator`, `babel-plugin-transform-function-sent`
@@ -2483,7 +2612,7 @@ let {...{}} = {}; let {...[]} = {};
- Add `--config-file` CLI flag to explicitly pass a config location
- Move `babel-standalone` into the repo (another form of this used to be `babel-browser`)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-plugin-transform-async-to-generator`, `babel-*`
* [#6094](https://github.com/babel/babel/pull/6094) Spec compatibility for iteratorClose condition.. ([@yavorsky](https://github.com/yavorsky))
* `babel-helpers`, `babel-plugin-transform-es2015-computed-properties`
@@ -2619,7 +2748,7 @@ Initial release of typescript equivalent of how Babel handles flow with a new `b
## v7.0.0-alpha.18 (2017-08-03)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-generator`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-types`
* [#5990](https://github.com/babel/babel/pull/5990) Flow opaque type aliases. ([@jbrown215](https://github.com/jbrown215))
* `babel-preset-stage-3`
@@ -2668,9 +2797,9 @@ Initial release of typescript equivalent of how Babel handles flow with a new `b
- Optional catch binding `try {} catch {}`: `babel-plugin-transform-optional-catch-binding`
- es2015-parameters `loose` mode that doesn't use `arguments`
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-plugin-check-es2015-constants`
* [#5930](https://github.com/babel/babel/pull/5930) Spec compliancy of check-es2015-constants plugin. ([@maurobringolf](https://github.com/maurobringolf))
* [#5930](https://github.com/babel/babel/pull/5930) Spec compliance of check-es2015-constants plugin. ([@maurobringolf](https://github.com/maurobringolf))
> Instead of throwing a compile time error when const is violated, Babel should insert a throw statement before the violation.
@@ -2975,7 +3104,7 @@ var A = function A() {
## v7.0.0-alpha.12 (2017-05-31)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-core`, `babel-generator`, `babel-plugin-syntax-numeric-separator`, `babel-plugin-transform-numeric-separator`, `babel-preset-stage-1`, `babel-template`, `babel-traverse`, `babel-types`
* [#5793](https://github.com/babel/babel/pull/5793) Support for NumericLiteralSeparator, Stage 1 feature. ([@rwaldron](https://github.com/rwaldron))
@@ -3016,7 +3145,7 @@ var A = function A() {
Update Babylon: https://github.com/babel/babylon/releases/tag/v7.0.0-beta.9, https://github.com/babel/babylon/releases/tag/v7.0.0-beta.10
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-generator`, `babel-plugin-transform-flow-strip-types`, `babel-types`
* [#5525](https://github.com/babel/babel/pull/5525) Add support for object type spread. ([@conartist6](https://github.com/conartist6))
@@ -3090,7 +3219,7 @@ Update Babylon: https://github.com/babel/babylon/releases/tag/v7.0.0-beta.9, htt
## v7.0.0-alpha.8 (2017-04-17)
#### :eyeglasses: Spec Compliancy
#### :eyeglasses: Spec Compliance
* `babel-preset-stage-2`, `babel-preset-stage-3`
* [#5610](https://github.com/babel/babel/pull/5610) Move syntax-dynamic-import to stage-3. ([@dkaoster](https://github.com/dkaoster))

View File

@@ -32,6 +32,7 @@ contributing, please read the
- Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/)
for an invite), following our announcements 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)
- You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to babel on CodeTriage](https://www.codetriage.com/babel/babel). [![Open Source Helpers](https://www.codetriage.com/babel/babel/badges/users.svg)](https://www.codetriage.com/babel/babel)
## Chat

View File

@@ -1,6 +1,6 @@
MAKEFLAGS = -j1
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
TEST262_COMMIT = de567d3aa5de4eaa11e00131d26b9fe77997dfb0
TEST262_COMMIT = ef7fd2bc27e7c10b4a71d2edc632a2934742a13e
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
export FORCE_COLOR = true
@@ -54,9 +54,14 @@ watch: clean clean-lib
flow:
./node_modules/.bin/flow check --strip-root
lint:
lint: lint-js lint-ts
lint-js:
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe
lint-ts:
./scripts/tests/typescript/lint.sh
fix: fix-json
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix

View File

@@ -80,14 +80,14 @@ Try it out at our [REPL](https://babeljs.io/repl/build/master#?code_lz=NoRgNATGD
Mostly a handful of volunteers, funded by you! Please check out our [team page](https://babeljs.io/team)!
### Looking for support?
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Is there a Babel song?
I'm so glad you asked: [Hallelujah —— In Praise of Babel](SONG.md) by [@angus-c](https://github.com/angus-c), [audio version](https://youtu.be/40abpedBKK8) by [@swyx](https://twitter.com/@swyx). Tweet us your recordings!
### Looking for support?
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Where are the docs?
Check out our website: [babeljs.io](https://babeljs.io/), and report issues/features at [babel/website](https://github.com/babel/website/issues).
@@ -98,12 +98,19 @@ Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) and fill out the issu
### Want to contribute to Babel?
Check out our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
Check out:
- If you have already joined Slack, join our [#development](https://babeljs.slack.com/messages/development) channel and say hi!
- Check out the issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the closed ones to get a sense of the kinds of issues you can tackle.
- Our [#development](https://babeljs.slack.com/messages/development) Slack channel and say hi ([signup](https://slack.babeljs.io))!
- Issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the [closed ones](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aclosed+label%3A%22good+first+issue%22) to get a sense of the kinds of issues you can tackle.
Some resources:
- Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
- Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
- Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals)
- Our blog which contains release posts and explainations: [/blog](https://babeljs.io/blog)
- Our videos page with talks about open source and Babel: [/videos](https://babeljs.io/videos)
- Our [podcast](https://podcast.babeljs.io)
### How is the repo structured?

View File

@@ -1,5 +1,5 @@
{
"version": "7.5.4",
"version": "7.6.2",
"changelog": {
"repo": "babel/babel",
"cacheDir": ".changelog",

View File

@@ -165,7 +165,7 @@ declare module "source-map" {
}
declare module "convert-source-map" {
import type { SourceMap } from "source-map";
import type { SourceMap, SourceMapGenerator } from "source-map";
declare class Converter {
toJSON(): string;
@@ -177,11 +177,11 @@ declare module "convert-source-map" {
declare module.exports: {
SourceMap: SourceMap,
Converter: Converter,
fromObject(obj: SourceMap): Converter,
fromObject(obj: SourceMap | SourceMapGenerator): Converter,
fromJSON(str: string): Converter,
fromBase64(str: string): Converter,
fromComment(str: string): Converter,
fromMapFileComment(str: string): Converter,
fromMapFileComment(str: string, dir: string): Converter,
fromSource(str: string): Converter,
fromMapFileSource(str: string, dir: string): Converter,
removeComments(str: string): string,

View File

@@ -9,18 +9,18 @@
"test": "make test"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/eslint-plugin-development": "^1.0.1",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
"@babel/plugin-transform-runtime": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-flow": "^7.0.0",
"@babel/register": "^7.4.4",
"@babel/runtime": "^7.4.5",
"@babel/register": "^7.6.0",
"@babel/runtime": "^7.6.0",
"babel-eslint": "^11.0.0-beta.0",
"babel-jest": "^24.8.0",
"babel-loader": "^8.0.6",
@@ -32,13 +32,13 @@
"derequire": "^2.0.2",
"duplicate-package-checker-webpack-plugin": "^2.1.0",
"enhanced-resolve": "^3.0.0",
"eslint": "^5.16.0",
"eslint": "^6.0.1",
"eslint-config-babel": "^9.0.0",
"eslint-plugin-flowtype": "^3.8.2",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.1.0",
"fancy-log": "^1.3.3",
"flow-bin": "^0.94.0",
"flow-bin": "^0.102.0",
"graceful-fs": "^4.1.15",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
@@ -48,12 +48,12 @@
"gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1",
"husky": "^2.3.0",
"husky": "^3.0.0",
"jest": "^24.8.0",
"lerna": "^3.14.2",
"lerna": "^3.16.0",
"lerna-changelog": "^0.5.0",
"lint-staged": "^8.1.7",
"lodash": "^4.17.11",
"lint-staged": "^9.2.0",
"lodash": "^4.17.13",
"merge-stream": "^1.0.1",
"output-file-sync": "^2.0.0",
"prettier": "^1.17.1",
@@ -63,15 +63,16 @@
"rollup-plugin-babel": "^4.0.0",
"rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-replace": "^2.2.0",
"test262-stream": "^1.2.0",
"test262-stream": "^1.3.0",
"through2": "^2.0.0",
"typescript": "^3.6.3",
"warnings-to-errors-webpack-plugin": "^2.0.0",
"webpack": "^3.4.1",
"webpack-dependency-suite": "^2.4.4",
"webpack-stream": "^4.0.0"
},
"resolutions": {
"@lerna/**/@lerna/collect-updates": "https://github.com/nicolo-ribaudo/lerna.git#babel-collect-updates"
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
},
"engines": {
"node": ">= 6.9.0 < 13.0.0",
@@ -134,6 +135,5 @@
"moduleNameMapper": {
"^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/"
}
},
"dependencies": {}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.5.0",
"version": "7.6.2",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -23,21 +23,21 @@
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.0.0",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"mkdirp": "^0.5.1",
"output-file-sync": "^2.0.0",
"slash": "^2.0.0",
"source-map": "^0.5.0"
},
"optionalDependencies": {
"chokidar": "^2.0.4"
"chokidar": "^2.1.8"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.4.4"
"@babel/core": "^7.6.2",
"@babel/helper-fixtures": "^7.6.2"
},
"bin": {
"babel": "./bin/babel.js",

View File

@@ -1,7 +1,12 @@
// @flow
import commander from "commander";
import { buildExternalHelpers } from "@babel/core";
function collect(value, previousValue): Array<string> {
function collect(
value: string | any,
previousValue: Array<string>,
): Array<string> {
// If the user passed the option with no value, like "babel-external-helpers --whitelist", do nothing.
if (typeof value !== "string") return previousValue;

View File

@@ -1,3 +1,5 @@
// @flow
import defaults from "lodash/defaults";
import outputFileSync from "output-file-sync";
import { sync as mkdirpSync } from "mkdirp";
@@ -6,11 +8,15 @@ import path from "path";
import fs from "fs";
import * as util from "./util";
import { type CmdOptions } from "./options";
export default async function({ cliOptions, babelOptions }) {
export default async function({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
const filenames = cliOptions.filenames;
async function write(src, base) {
async function write(src: string, base: string): Promise<boolean> {
let relative = path.relative(base, src);
if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
@@ -65,14 +71,14 @@ export default async function({ cliOptions, babelOptions }) {
}
}
function getDest(filename, base) {
function getDest(filename: string, base: string): string {
if (cliOptions.relative) {
return path.join(base, cliOptions.outDir, filename);
}
return path.join(cliOptions.outDir, filename);
}
async function handleFile(src, base) {
async function handleFile(src: string, base: string): Promise<boolean> {
const written = await write(src, base);
if (!written && cliOptions.copyFiles) {
@@ -84,7 +90,7 @@ export default async function({ cliOptions, babelOptions }) {
return written;
}
async function handle(filenameOrDir) {
async function handle(filenameOrDir: string): Promise<number> {
if (!fs.existsSync(filenameOrDir)) return 0;
const stat = fs.statSync(filenameOrDir);

View File

@@ -1,3 +1,5 @@
// @flow
import convertSourceMap from "convert-source-map";
import defaults from "lodash/defaults";
import sourceMap from "source-map";
@@ -6,9 +8,18 @@ import path from "path";
import fs from "fs";
import * as util from "./util";
import { type CmdOptions } from "./options";
export default async function({ cliOptions, babelOptions }) {
function buildResult(fileResults) {
type CompilationOutput = {
code: string,
map: Object,
};
export default async function({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
function buildResult(fileResults: Array<Object>): CompilationOutput {
const map = new sourceMap.SourceMapGenerator({
file:
cliOptions.sourceMapTarget ||
@@ -74,7 +85,7 @@ export default async function({ cliOptions, babelOptions }) {
};
}
function output(fileResults) {
function output(fileResults: Array<string>): void {
const result = buildResult(fileResults);
if (cliOptions.outFile) {
@@ -91,14 +102,15 @@ export default async function({ cliOptions, babelOptions }) {
}
}
function readStdin() {
return new Promise((resolve, reject) => {
function readStdin(): Promise<string> {
return new Promise((resolve: Function, reject: Function): void => {
let code = "";
process.stdin.setEncoding("utf8");
process.stdin.on("readable", function() {
const chunk = process.stdin.read();
// $FlowIgnore
if (chunk !== null) code += chunk;
});
@@ -109,7 +121,7 @@ export default async function({ cliOptions, babelOptions }) {
});
}
async function stdin() {
async function stdin(): Promise<void> {
const code = await readStdin();
const res = await util.transform(
@@ -126,7 +138,7 @@ export default async function({ cliOptions, babelOptions }) {
output([res]);
}
async function walk(filenames) {
async function walk(filenames: Array<string>): Promise<void> {
const _filenames = [];
filenames.forEach(function(filename) {
@@ -151,7 +163,7 @@ export default async function({ cliOptions, babelOptions }) {
});
const results = await Promise.all(
_filenames.map(async function(filename) {
_filenames.map(async function(filename: string): Promise<Object> {
let sourceFilename = filename;
if (cliOptions.outFile) {
sourceFilename = path.relative(
@@ -168,7 +180,7 @@ export default async function({ cliOptions, babelOptions }) {
{
sourceFileName: sourceFilename,
// Since we're compiling everything to be merged together,
// "inline" applies to the final output file, but to the individual
// "inline" applies to the final output file, but not to the individual
// files being concatenated.
sourceMaps:
babelOptions.sourceMaps === "inline"
@@ -192,7 +204,7 @@ export default async function({ cliOptions, babelOptions }) {
output(results);
}
async function files(filenames) {
async function files(filenames: Array<string>): Promise<void> {
if (!cliOptions.skipInitialBuild) {
await walk(filenames);
}
@@ -208,7 +220,7 @@ export default async function({ cliOptions, babelOptions }) {
pollInterval: 10,
},
})
.on("all", function(type, filename) {
.on("all", function(type: string, filename: string) {
if (!util.isCompilableExtension(filename, cliOptions.extensions)) {
return;
}

View File

@@ -6,8 +6,12 @@ import fileCommand from "./file";
const opts = parseArgv(process.argv);
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
fn(opts).catch(err => {
console.error(err);
process.exit(1);
});
if (opts) {
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
fn(opts).catch(err => {
console.error(err);
process.exitCode = 1;
});
} else {
process.exitCode = 2;
}

View File

@@ -1,3 +1,5 @@
// @flow
import fs from "fs";
import commander from "commander";
@@ -151,7 +153,12 @@ commander.option(
commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>");
export default function parseArgv(args: Array<string>) {
export type CmdOptions = {
babelOptions: Object,
cliOptions: Object,
};
export default function parseArgv(args: Array<string>): CmdOptions | null {
//
commander.parse(args);
@@ -216,7 +223,7 @@ export default function parseArgv(args: Array<string>) {
errors.forEach(function(e) {
console.error(" " + e);
});
process.exit(2);
return null;
}
const opts = commander.opts();

View File

@@ -1,10 +1,12 @@
// @flow
import readdirRecursive from "fs-readdir-recursive";
import * as babel from "@babel/core";
import includes from "lodash/includes";
import path from "path";
import fs from "fs";
export function chmod(src, dest) {
export function chmod(src: string, dest: string): void {
fs.chmodSync(dest, fs.statSync(src).mode);
}
@@ -13,8 +15,8 @@ type ReaddirFilter = (filename: string) => boolean;
export function readdir(
dirname: string,
includeDotfiles: boolean,
filter: ReaddirFilter,
) {
filter?: ReaddirFilter,
): Array<string> {
return readdirRecursive(dirname, (filename, _index, currentDirectory) => {
const stat = fs.statSync(path.join(currentDirectory, filename));
@@ -30,7 +32,7 @@ export function readdirForCompilable(
dirname: string,
includeDotfiles: boolean,
altExts?: Array<string>,
) {
): Array<string> {
return readdir(dirname, includeDotfiles, function(filename) {
return isCompilableExtension(filename, altExts);
});
@@ -48,7 +50,7 @@ export function isCompilableExtension(
return includes(exts, ext);
}
export function addSourceMappingUrl(code, loc) {
export function addSourceMappingUrl(code: string, loc: string): string {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
}
@@ -56,7 +58,11 @@ const CALLER = {
name: "@babel/cli",
};
export function transform(filename, code, opts) {
export function transform(
filename: string,
code: string,
opts: Object,
): Promise<Object> {
opts = {
...opts,
caller: CALLER,
@@ -71,7 +77,10 @@ export function transform(filename, code, opts) {
});
}
export function compile(filename, opts) {
export function compile(
filename: string,
opts: Object | Function,
): Promise<Object> {
opts = {
...opts,
caller: CALLER,
@@ -85,7 +94,7 @@ export function compile(filename, opts) {
});
}
export function deleteDir(path) {
export function deleteDir(path: string): void {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function(file) {
const curPath = path + "/" + file;
@@ -103,10 +112,10 @@ export function deleteDir(path) {
process.on("uncaughtException", function(err) {
console.error(err);
process.exit(1);
process.exitCode = 1;
});
export function requireChokidar() {
export function requireChokidar(): Object {
try {
return require("chokidar");
} catch (err) {
@@ -118,7 +127,10 @@ export function requireChokidar() {
}
}
export function adjustRelative(relative, keepFileExtension) {
export function adjustRelative(
relative: string,
keepFileExtension: boolean,
): string {
if (keepFileExtension) {
return relative;
}

View File

@@ -92,7 +92,7 @@ const assertTest = function(stdout, stderr, opts, cwd) {
if (
// saveInFiles always creates an empty .babelrc, so lets exclude for now
filename !== ".babelrc" &&
!opts.inFiles.hasOwnProperty(filename)
!Object.prototype.hasOwnProperty.call(opts.inFiles, filename)
) {
const expected = opts.outFiles[filename];
const actual = actualFiles[filename];

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/code-frame",
"version": "7.0.0",
"version": "7.5.5",
"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

@@ -76,7 +76,7 @@ function getMarkerLines(
} else if (i === 0) {
const sourceLength = source[lineNumber - 1].length;
markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
} else if (i === lineDiff) {
markerLines[lineNumber] = [0, endColumn];
} else {
@@ -112,15 +112,16 @@ export function codeFrameColumns(
const maybeHighlight = (chalkFn, string) => {
return highlighted ? chalkFn(string) : string;
};
if (highlighted) rawLines = highlight(rawLines, opts);
const lines = rawLines.split(NEWLINE);
const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
const hasColumns = loc.start && typeof loc.start.column === "number";
const numberMaxWidth = String(end).length;
let frame = lines
const highlightedLines = highlighted ? highlight(rawLines, opts) : rawLines;
let frame = highlightedLines
.split(NEWLINE)
.slice(start, end)
.map((line, index) => {
const number = start + 1 + index;

View File

@@ -102,6 +102,45 @@ describe("@babel/code-frame", function() {
);
});
test("opts.highlightCode with multiple columns and lines", function() {
// prettier-ignore
const rawLines = [
"function a(b, c) {",
" return b + c;",
"}"
].join("\n");
const result = codeFrameColumns(
rawLines,
{
start: {
line: 1,
column: 1,
},
end: {
line: 3,
column: 1,
},
},
{
highlightCode: true,
message: "Message about things",
},
);
const stripped = stripAnsi(result);
expect(stripped).toEqual(
// prettier-ignore
[
"> 1 | function a(b, c) {",
" | ^^^^^^^^^^^^^^^^^^",
"> 2 | return b + c;",
" | ^^^^^^^^^^^^^^^",
"> 3 | }",
" | ^ Message about things",
].join('\n'),
);
});
test("opts.linesAbove", function() {
const rawLines = [
"/**",

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.5.4",
"version": "7.6.2",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
@@ -33,23 +33,22 @@
"./lib/transform-file.js": "./lib/transform-file-browser.js"
},
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/generator": "^7.5.0",
"@babel/helpers": "^7.5.4",
"@babel/parser": "^7.5.0",
"@babel/template": "^7.4.4",
"@babel/traverse": "^7.5.0",
"@babel/types": "^7.5.0",
"@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.6.2",
"@babel/helpers": "^7.6.2",
"@babel/parser": "^7.6.2",
"@babel/template": "^7.6.0",
"@babel/traverse": "^7.6.2",
"@babel/types": "^7.6.0",
"convert-source-map": "^1.1.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^7.5.0",
"@babel/register": "^7.4.4"
"@babel/helper-transform-fixture-test-runner": "^7.6.0"
}
}

View File

@@ -268,13 +268,11 @@ function babelrcLoadEnabled(
});
}
const validateConfigFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("configfile", file.options),
}),
);
const validateConfigFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("configfile", file.options),
}));
const validateBabelrcFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
@@ -284,13 +282,11 @@ const validateBabelrcFile = makeWeakCache(
}),
);
const validateExtendFile = makeWeakCache(
(file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("extendsfile", file.options),
}),
);
const validateExtendFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
filepath: file.filepath,
dirname: file.dirname,
options: validate("extendsfile", file.options),
}));
/**
* Build a config chain for just the programmatic options passed into Babel.
@@ -549,7 +545,7 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
// "sourceMap" is just aliased to sourceMap, so copy it over as
// we merge the options together.
if (options.hasOwnProperty("sourceMap")) {
if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}

View File

@@ -18,6 +18,7 @@ import { validatePluginObject } from "./validation/plugins";
import makeAPI from "./helpers/config-api";
import loadPrivatePartialConfig from "./partial";
import type { ValidatedOptions } from "./validation/options";
type LoadedDescriptor = {
value: {},
@@ -278,6 +279,42 @@ const instantiatePlugin = makeWeakCache(
},
);
const validateIfOptionNeedsFilename = (
options: ValidatedOptions,
descriptor: UnloadedDescriptor,
): void => {
if (options.test || options.include || options.exclude) {
const formattedPresetName = descriptor.name
? `"${descriptor.name}"`
: "/* your preset */";
throw new Error(
[
`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`,
`\`\`\``,
`babel.transform(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`,
`\`\`\``,
`See https://babeljs.io/docs/en/options#filename for more information.`,
].join("\n"),
);
}
};
const validatePreset = (
preset: PresetInstance,
context: ConfigContext,
descriptor: UnloadedDescriptor,
): void => {
if (!context.filename) {
const { options } = preset;
validateIfOptionNeedsFilename(options, descriptor);
if (options.overrides) {
options.overrides.forEach(overrideOptions =>
validateIfOptionNeedsFilename(overrideOptions, descriptor),
);
}
}
};
/**
* Generate a config object that will act as the root of a new nested config.
*/
@@ -285,10 +322,9 @@ const loadPresetDescriptor = (
descriptor: UnloadedDescriptor,
context: ConfigContext,
): ConfigChain | null => {
return buildPresetChain(
instantiatePreset(loadDescriptor(descriptor, context)),
context,
);
const preset = instantiatePreset(loadDescriptor(descriptor, context));
validatePreset(preset, context, descriptor);
return buildPresetChain(preset, context);
};
const instantiatePreset = makeWeakCache(

View File

@@ -278,7 +278,7 @@ export function assertConfigFileSearch(
) {
throw new Error(
`${msg(loc)} must be a undefined, a boolean, a string, ` +
`got ${JSON.stringify(value)}`,
`got ${JSON.stringify((value: any))}`,
);
}
@@ -302,7 +302,7 @@ export function assertBabelrcSearch(
} else if (!checkValidTest(value)) {
throw new Error(
`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` +
`or an array of those, got ${JSON.stringify(value)}`,
`or an array of those, got ${JSON.stringify((value: any))}`,
);
}
return (value: any);

View File

@@ -272,7 +272,8 @@ export type OptionsSource =
| "configfile"
| "babelrcfile"
| "extendsfile"
| "preset";
| "preset"
| "plugin";
type RootPath = $ReadOnly<{
type: "root",

View File

@@ -84,10 +84,19 @@ export type PluginObject = {
};
export function validatePluginObject(obj: {}): PluginObject {
const rootPath: RootPath = {
type: "root",
source: "plugin",
};
Object.keys(obj).forEach(key => {
const validator = VALIDATORS[key];
const optLoc = {
type: "option",
name: key,
parent: rootPath,
};
if (validator) validator(key, obj[key]);
if (validator) validator(optLoc, obj[key]);
else throw new Error(`.${key} is not a valid Plugin property`);
});

View File

@@ -203,6 +203,9 @@ export default class File {
if (res) return res;
}
// make sure that the helper exists
helpers.ensure(name);
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
name,
));

View File

@@ -1,7 +1,7 @@
// @flow
import type { PluginPasses } from "../../config";
import convertSourceMap, { type SourceMap } from "convert-source-map";
import convertSourceMap, { typeof SourceMap } from "convert-source-map";
import generate from "@babel/generator";
import type File from "./file";

View File

@@ -1,6 +1,6 @@
// @flow
import type { SourceMap } from "convert-source-map";
import typeof { SourceMap } from "convert-source-map";
import sourceMap from "source-map";
export default function mergeSourceMap(

View File

@@ -1,6 +1,6 @@
// @flow
import traverse from "@babel/traverse";
import type { SourceMap } from "convert-source-map";
import typeof { SourceMap } from "convert-source-map";
import type { ResolvedConfig, PluginPasses } from "../config";

View File

@@ -27,49 +27,6 @@ export default function normalizeFile(
): File {
code = `${code || ""}`;
let inputMap = null;
if (options.inputSourceMap !== false) {
// If an explicit object is passed in, it overrides the processing of
// source maps that may be in the file itself.
if (typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
if (!inputMap) {
try {
inputMap = convertSourceMap.fromSource(code);
if (inputMap) {
code = convertSourceMap.removeComments(code);
}
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
code = convertSourceMap.removeComments(code);
}
}
if (!inputMap) {
if (typeof options.filename === "string") {
try {
inputMap = convertSourceMap.fromMapFileSource(
code,
path.dirname(options.filename),
);
if (inputMap) {
code = convertSourceMap.removeMapFileComments(code);
}
} catch (err) {
debug("discarding unknown file input sourcemap", err);
code = convertSourceMap.removeMapFileComments(code);
}
} else {
debug("discarding un-loadable file input sourcemap");
code = convertSourceMap.removeMapFileComments(code);
}
}
}
if (ast) {
if (ast.type === "Program") {
ast = t.file(ast, [], []);
@@ -84,6 +41,42 @@ export default function normalizeFile(
ast = parser(pluginPasses, options, code);
}
let inputMap = null;
if (options.inputSourceMap !== false) {
// If an explicit object is passed in, it overrides the processing of
// source maps that may be in the file itself.
if (typeof options.inputSourceMap === "object") {
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
}
if (!inputMap) {
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {
try {
inputMap = convertSourceMap.fromComment(lastComment);
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
}
}
}
if (!inputMap) {
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
if (typeof options.filename === "string" && lastComment) {
try {
inputMap = convertSourceMap.fromMapFileComment(
lastComment,
path.dirname(options.filename),
);
} catch (err) {
debug("discarding unknown file input sourcemap", err);
}
} else if (lastComment) {
debug("discarding un-loadable file input sourcemap");
}
}
}
return new File(options, {
code,
ast,
@@ -156,3 +149,48 @@ function parser(
throw err;
}
}
// These regexps are copied from the convert-source-map package,
// but without // or /* at the beginning of the comment.
// eslint-disable-next-line max-len
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$/;
function extractCommentsFromList(regex, comments, lastComment) {
if (comments) {
comments = comments.filter(({ value }) => {
if (regex.test(value)) {
lastComment = value;
return false;
}
return true;
});
}
return [comments, lastComment];
}
function extractComments(regex, ast) {
let lastComment = null;
t.traverseFast(ast, node => {
// $FlowIgnore destructuring with expressions is not supported
[node.leadingComments, lastComment] = extractCommentsFromList(
regex,
node.leadingComments,
lastComment,
);
// $FlowIgnore destructuring with expressions is not supported
[node.innerComments, lastComment] = extractCommentsFromList(
regex,
node.innerComments,
lastComment,
);
// $FlowIgnore destructuring with expressions is not supported
[node.trailingComments, lastComment] = extractCommentsFromList(
regex,
node.trailingComments,
lastComment,
);
});
return lastComment;
}

View File

@@ -788,4 +788,28 @@ describe("api", function() {
);
});
});
describe("missing helpers", function() {
it("should always throw", function() {
expect(() =>
babel.transformSync(``, {
configFile: false,
plugins: [
function() {
return {
visitor: {
Program(path) {
try {
path.pushContainer("body", this.addHelper("fooBar"));
} catch {}
path.pushContainer("body", this.addHelper("fooBar"));
},
},
};
},
],
}),
).toThrow();
});
});
});

View File

@@ -1049,5 +1049,27 @@ describe("buildConfigChain", function() {
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Error while parsing JSON - /);
});
it("should throw when `test` presents but `filename` is not passed", () => {
expect(() => loadOptions({ test: /\.ts$/, plugins: [] })).toThrow(
/Configuration contains string\/RegExp pattern/,
);
});
it("should throw when `preset` requires `filename` but it was not passed", () => {
expect(() => {
loadOptions({
presets: [require("./fixtures/config-loading/preset4")],
});
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
});
it("should throw when `preset.overrides` requires `filename` but it was not passed", () => {
expect(() => {
loadOptions({
presets: [require("./fixtures/config-loading/preset5")],
});
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
});
});
});

View File

@@ -322,6 +322,21 @@ describe("@babel/core config loading", () => {
}
}
});
it("should thrown when plugin is not valid", () => {
const fooPlugin = {
inherits: "inhertis-should-not-be-string",
};
const opts = {
cwd: path.dirname(FILEPATH),
filename: FILEPATH,
plugins: [fooPlugin],
};
expect(() => loadConfig(opts)).toThrow(
/\.inherits must be a function, or undefined/,
);
});
});
describe("caller metadata", () => {

View File

@@ -0,0 +1,6 @@
module.exports = function() {
return {
test: /\.ts$/,
plugins: []
}
};

View File

@@ -0,0 +1,8 @@
module.exports = function() {
return {
overrides: [{
test: /\.ts$/,
plugins: []
}]
}
};

View File

@@ -0,0 +1,8 @@
// https://github.com/babel/babel/issues/9790
const comment = `//# sourceMappingURL=${path.basename(
sourceMapFilename
)}`
// https://github.com/babel/babel/issues/9956
this.shadowRoot.innerHTML = `<style>div{display:block}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmllbGQuaHRtbCIsInNvdXJjZXMiOlsiZmllbGQuaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8c3ZlbHRlOm9wdGlvbnMgdGFnPVwiZGxzLWZpZWxkXCIgLz5cblxuPHN0eWxlPlxuICBkaXYgeyBkaXNwbGF5OiBibG9jazsgfVxuPC9zdHlsZT5cblxuPGRpdiBjbGFzcz1cImZpZWxkXCI+XG4gIDxkaXYgY2xhc3M9XCJfZmllbGRMYWJlbExheW91dFwiPlxuICAgIDxkaXYgY2xhc3M9XCJmaWVsZExhYmVsXCI+XG4gICAgICA8c2xvdCBuYW1lPVwiZmllbGQtbGFiZWxcIj48L3Nsb3Q+XG4gICAgPC9kaXY+XG4gICAgPGRpdiBjbGFzcz1cImZpZWxkT3B0aW9uYWxcIiBjbGFzczpvcHRpb25hbD5cbiAgICAgIE9wdGlvbmFsXG4gICAgPC9kaXY+XG4gIDwvZGl2PlxuICA8ZGl2IGNsYXNzPVwiZmllbGREZXRhaWxcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtZGV0YWlsXCI+PC9zbG90PlxuICA8L2Rpdj5cbiAgPGRpdiBjbGFzcz1cImZpZWxkQ29udHJvbFwiPlxuICAgIDxzbG90IG5hbWU9XCJmaWVsZC1jb250cm9sXCI+PC9zbG90PlxuICAgIDxzbG90Pjwvc2xvdD5cbiAgPC9kaXY+XG4gIDxkaXYgY2xhc3M9XCJmaWVsZE1lc3NhZ2VcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtbWVzc2FnZVwiPjwvc2xvdD5cbiAgPC9kaXY+XG48L2Rpdj5cblxuPHNjcmlwdD5cbiAgZXhwb3J0IGxldCB0aGVtZSA9ICcnO1xuICBleHBvcnQgbGV0IG9wdGlvbmFsID0gZmFsc2U7XG48L3NjcmlwdD5cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHRSxHQUFHLEFBQUMsQ0FBQyxBQUFDLE9BQU8sQ0FBRSxLQUFLLEFBQUUsQ0FBQyJ9 */</style>`;

View File

@@ -0,0 +1,3 @@
{
"inputSourceMap": true
}

View File

@@ -0,0 +1,5 @@
// https://github.com/babel/babel/issues/9790
const comment = `//# sourceMappingURL=${path.basename(sourceMapFilename)}`; // https://github.com/babel/babel/issues/9956
this.shadowRoot.innerHTML = `<style>div{display:block}
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmllbGQuaHRtbCIsInNvdXJjZXMiOlsiZmllbGQuaHRtbCJdLCJzb3VyY2VzQ29udGVudCI6WyI8c3ZlbHRlOm9wdGlvbnMgdGFnPVwiZGxzLWZpZWxkXCIgLz5cblxuPHN0eWxlPlxuICBkaXYgeyBkaXNwbGF5OiBibG9jazsgfVxuPC9zdHlsZT5cblxuPGRpdiBjbGFzcz1cImZpZWxkXCI+XG4gIDxkaXYgY2xhc3M9XCJfZmllbGRMYWJlbExheW91dFwiPlxuICAgIDxkaXYgY2xhc3M9XCJmaWVsZExhYmVsXCI+XG4gICAgICA8c2xvdCBuYW1lPVwiZmllbGQtbGFiZWxcIj48L3Nsb3Q+XG4gICAgPC9kaXY+XG4gICAgPGRpdiBjbGFzcz1cImZpZWxkT3B0aW9uYWxcIiBjbGFzczpvcHRpb25hbD5cbiAgICAgIE9wdGlvbmFsXG4gICAgPC9kaXY+XG4gIDwvZGl2PlxuICA8ZGl2IGNsYXNzPVwiZmllbGREZXRhaWxcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtZGV0YWlsXCI+PC9zbG90PlxuICA8L2Rpdj5cbiAgPGRpdiBjbGFzcz1cImZpZWxkQ29udHJvbFwiPlxuICAgIDxzbG90IG5hbWU9XCJmaWVsZC1jb250cm9sXCI+PC9zbG90PlxuICAgIDxzbG90Pjwvc2xvdD5cbiAgPC9kaXY+XG4gIDxkaXYgY2xhc3M9XCJmaWVsZE1lc3NhZ2VcIj5cbiAgICA8c2xvdCBuYW1lPVwiZmllbGQtbWVzc2FnZVwiPjwvc2xvdD5cbiAgPC9kaXY+XG48L2Rpdj5cblxuPHNjcmlwdD5cbiAgZXhwb3J0IGxldCB0aGVtZSA9ICcnO1xuICBleHBvcnQgbGV0IG9wdGlvbmFsID0gZmFsc2U7XG48L3NjcmlwdD5cbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFHRSxHQUFHLEFBQUMsQ0FBQyxBQUFDLE9BQU8sQ0FBRSxLQUFLLEFBQUUsQ0FBQyJ9 */</style>`;

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/generator",
"version": "7.5.0",
"version": "7.6.2",
"description": "Turns an AST into code.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -14,14 +14,13 @@
"lib"
],
"dependencies": {
"@babel/types": "^7.5.0",
"@babel/types": "^7.6.0",
"jsesc": "^2.5.1",
"lodash": "^4.17.11",
"source-map": "^0.5.0",
"trim-right": "^1.0.1"
"lodash": "^4.17.13",
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-fixtures": "^7.4.4",
"@babel/parser": "^7.5.0"
"@babel/helper-fixtures": "^7.6.2",
"@babel/parser": "^7.6.2"
}
}

View File

@@ -1,5 +1,4 @@
import type SourceMap from "./source-map";
import trimRight from "trim-right";
const SPACES_RE = /^[ \t]+$/;
@@ -43,7 +42,7 @@ export default class Buffer {
const result = {
// Whatever trim is used here should not execute a regex against the
// source string since it may be arbitrarily large after all transformations
code: trimRight(this._buf.join("")),
code: this._buf.join("").trimRight(),
map: null,
rawMappings: map && map.getRawMappings(),
};

View File

@@ -264,3 +264,8 @@ export function PrivateName(node: Object) {
this.token("#");
this.print(node.id, node);
}
export function V8IntrinsicIdentifier(node: Object) {
this.token("%");
this.word(node.name);
}

View File

@@ -67,12 +67,14 @@ export function TSQualifiedName(node) {
export function TSCallSignatureDeclaration(node) {
this.tsPrintSignatureDeclarationBase(node);
this.token(";");
}
export function TSConstructSignatureDeclaration(node) {
this.word("new");
this.space();
this.tsPrintSignatureDeclarationBase(node);
this.token(";");
}
export function TSPropertySignature(node) {
@@ -127,6 +129,9 @@ export function TSIndexSignature(node) {
export function TSAnyKeyword() {
this.word("any");
}
export function TSBigIntKeyword() {
this.word("bigint");
}
export function TSUnknownKeyword() {
this.word("unknown");
}

View File

@@ -97,5 +97,18 @@ export function needsParens(node, parent, printStack) {
if (isOrHasCallExpression(node)) return true;
}
/* this check is for NullishCoalescing being used with LogicalOperators like && and ||
* For example when someone creates an ast programmaticaly like this
* t.logicalExpression(
* "??",
* t.logicalExpression("||", t.identifier("a"), t.identifier("b")),
* t.identifier("c"),
* );
* In the example above the AST is equivalent to writing a || b ?? c
* This is incorrect because NullishCoalescing when used with LogicalExpressions should have parenthesis
* The correct syntax is (a || b) ?? c, that is why we need parenthesis in this case
*/
if (t.isLogicalExpression(node) && parent.operator === "??") return true;
return find(expandedParens, node, parent, printStack);
}

View File

@@ -1,3 +1,3 @@
{
"parserOpts": {"createParenthesizedExpressions": true}
"parserOpts": { "createParenthesizedExpressions": true }
}

View File

@@ -0,0 +1 @@
%DebugPrint(foo);

View File

@@ -0,0 +1,3 @@
{
"plugins": ["v8intrinsic"]
}

View File

@@ -0,0 +1 @@
%DebugPrint(foo);

View File

@@ -1,4 +1,5 @@
foo ||bar;
(x => x)|| bar;
(function a(x){return x;})|| 2;
0||(function(){return alpha;});
0||(function(){return alpha;});
a ?? (b || c);

View File

@@ -0,0 +1,3 @@
{
"plugins": ["nullishCoalescingOperator"]
}

View File

@@ -7,4 +7,6 @@ foo || bar;
0 || function () {
return alpha;
};
};
a ?? (b || c);

View File

@@ -1,3 +1,4 @@
interface I {
(x: number): void;
(x: string): void;
}

View File

@@ -1,3 +1,4 @@
interface I {
(x: number): void
}
(x: number): void;
(x: string): void;
}

View File

@@ -1,3 +1,4 @@
interface I {
new (x: number): void;
new (x: string): void;
}

View File

@@ -1,3 +1,4 @@
interface I {
new (x: number): void
}
new (x: number): void;
new (x: string): void;
}

View File

@@ -298,6 +298,31 @@ describe("generation", function() {
});
describe("programmatic generation", function() {
it("should add parenthesis when NullishCoalescing is used along with ||", function() {
// https://github.com/babel/babel/issues/10260
const nullishCoalesc = t.logicalExpression(
"??",
t.logicalExpression("||", t.identifier("a"), t.identifier("b")),
t.identifier("c"),
);
const output = generate(nullishCoalesc).code;
expect(output).toBe(`(a || b) ?? c`);
});
it("should add parenthesis when NullishCoalesing is used with &&", function() {
const nullishCoalesc = t.logicalExpression(
"??",
t.identifier("a"),
t.logicalExpression(
"&&",
t.identifier("b"),
t.logicalExpression("&&", t.identifier("c"), t.identifier("d")),
),
);
const output = generate(nullishCoalesc).code;
expect(output).toBe(`a ?? (b && c && d)`);
});
it("numeric member expression", function() {
// Should not generate `0.foo`
const mem = t.memberExpression(

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-create-class-features-plugin",
"version": "7.5.0",
"version": "7.6.0",
"author": "The Babel Team (https://babeljs.io/team)",
"license": "MIT",
"description": "Compile class public and private fields, private methods and decorators to ES6",
@@ -15,17 +15,17 @@
],
"dependencies": {
"@babel/helper-function-name": "^7.1.0",
"@babel/helper-member-expression-to-functions": "^7.0.0",
"@babel/helper-member-expression-to-functions": "^7.5.5",
"@babel/helper-optimise-call-expression": "^7.0.0",
"@babel/helper-plugin-utils": "^7.0.0",
"@babel/helper-replace-supers": "^7.4.4",
"@babel/helper-replace-supers": "^7.5.5",
"@babel/helper-split-export-declaration": "^7.4.4"
},
"peerDependencies": {
"@babel/core": "^7.0.0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/core": "^7.6.0",
"@babel/helper-plugin-test-runner": "^7.0.0"
}
}

View File

@@ -66,12 +66,6 @@ export function verifyUsedFeatures(path, file) {
if (!hasFeature(file, FEATURES.privateMethods)) {
throw path.buildCodeFrameError("Class private methods are not enabled.");
}
if (path.node.static && path.node.kind !== "method") {
throw path.buildCodeFrameError(
"@babel/plugin-class-features doesn't support class static private accessors yet.",
);
}
}
if (

View File

@@ -44,6 +44,7 @@ export function buildPrivateNamesNodes(privateNamesMap, loose, state) {
// because static fields are directly assigned to a variable in the
// buildPrivateStaticFieldInitSpec function.
const { id, static: isStatic, method: isMethod, getId, setId } = value;
const isAccessor = getId || setId;
if (loose) {
initNodes.push(
template.statement.ast`
@@ -51,7 +52,7 @@ export function buildPrivateNamesNodes(privateNamesMap, loose, state) {
`,
);
} else if (isMethod && !isStatic) {
if (getId || setId) {
if (isAccessor) {
initNodes.push(template.statement.ast`var ${id} = new WeakMap();`);
} else {
initNodes.push(template.statement.ast`var ${id} = new WeakSet();`);
@@ -140,11 +141,13 @@ const privateNameHandlerSpec = {
getId,
setId,
} = privateNamesMap.get(name);
const isAccessor = getId || setId;
if (isStatic) {
const helperName = isMethod
? "classStaticPrivateMethodGet"
: "classStaticPrivateFieldSpecGet";
const helperName =
isMethod && !isAccessor
? "classStaticPrivateMethodGet"
: "classStaticPrivateFieldSpecGet";
return t.callExpression(file.addHelper(helperName), [
this.receiver(member),
@@ -154,7 +157,7 @@ const privateNameHandlerSpec = {
}
if (isMethod) {
if (getId || setId) {
if (isAccessor) {
return t.callExpression(file.addHelper("classPrivateFieldGet"), [
this.receiver(member),
t.cloneNode(id),
@@ -180,12 +183,15 @@ const privateNameHandlerSpec = {
static: isStatic,
method: isMethod,
setId,
getId,
} = privateNamesMap.get(name);
const isAccessor = getId || setId;
if (isStatic) {
const helperName = isMethod
? "classStaticPrivateMethodSet"
: "classStaticPrivateFieldSpecSet";
const helperName =
isMethod && !isAccessor
? "classStaticPrivateMethodSet"
: "classStaticPrivateFieldSpecSet";
return t.callExpression(file.addHelper(helperName), [
this.receiver(member),
@@ -211,6 +217,19 @@ const privateNameHandlerSpec = {
]);
},
destructureSet(member) {
const { privateNamesMap, file } = this;
const { name } = member.node.property.id;
const { id } = privateNamesMap.get(name);
return t.memberExpression(
t.callExpression(file.addHelper("classPrivateFieldDestructureSet"), [
this.receiver(member),
t.cloneNode(id),
]),
t.identifier("value"),
);
},
call(member, args) {
// The first access (the get) should do the memo assignment.
this.memoise(member, 1);
@@ -287,9 +306,30 @@ function buildPrivateInstanceFieldInitSpec(ref, prop, privateNamesMap) {
}
function buildPrivateStaticFieldInitSpec(prop, privateNamesMap) {
const { id } = privateNamesMap.get(prop.node.key.id.name);
const value = prop.node.value || prop.scope.buildUndefinedNode();
const privateName = privateNamesMap.get(prop.node.key.id.name);
const { id, getId, setId, initAdded } = privateName;
const isAccessor = getId || setId;
if (!prop.isProperty() && (initAdded || !isAccessor)) return;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
return template.statement.ast`
var ${id.name} = {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
}
`;
}
const value = prop.node.value || prop.scope.buildUndefinedNode();
return template.statement.ast`
var ${id} = {
// configurable is false by default
@@ -315,76 +355,44 @@ function buildPrivateMethodInitLoose(ref, prop, privateNamesMap) {
});
`;
}
if (getId || setId) {
const isAccessor = getId || setId;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
if (getId && setId) {
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId.name},
set: ${setId.name}
});
`;
} else if (getId && !setId) {
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId.name}
});
`;
} else if (!getId && setId) {
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
set: ${setId.name}
});
`;
}
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
});
`;
}
}
function buildPrivateInstanceMethodInitSpec(ref, prop, privateNamesMap) {
const privateName = privateNamesMap.get(prop.node.key.id.name);
const { id, getId, setId, initAdded } = privateName;
if (initAdded) return;
if (getId || setId) {
const isAccessor = getId || setId;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
if (getId && setId) {
return template.statement.ast`
${id}.set(${ref}, {
get: ${getId.name},
set: ${setId.name}
});
`;
} else if (getId && !setId) {
return template.statement.ast`
${id}.set(${ref}, {
get: ${getId.name}
});
`;
} else if (!getId && setId) {
return template.statement.ast`
${id}.set(${ref}, {
set: ${setId.name}
});
`;
}
return template.statement.ast`
${id}.set(${ref}, {
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
});
`;
}
return template.statement.ast`${id}.add(${ref})`;
}
@@ -416,7 +424,29 @@ function buildPublicFieldInitSpec(ref, prop, state) {
}
function buildPrivateStaticMethodInitLoose(ref, prop, state, privateNamesMap) {
const { id, methodId } = privateNamesMap.get(prop.node.key.id.name);
const privateName = privateNamesMap.get(prop.node.key.id.name);
const { id, methodId, getId, setId, initAdded } = privateName;
if (initAdded) return;
const isAccessor = getId || setId;
if (isAccessor) {
privateNamesMap.set(prop.node.key.id.name, {
...privateName,
initAdded: true,
});
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
// enumerable is false by default
// writable is false by default
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
})
`;
}
return template.statement.ast`
Object.defineProperty(${ref}, ${id}, {
// configurable is false by default
@@ -602,14 +632,14 @@ export function buildFieldsInitNodes(
case isStatic && isPrivate && isMethod && !loose:
needsClassRef = true;
staticNodes.push(
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
);
staticNodes.unshift(
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
);
break;
case isStatic && isPrivate && isMethod && loose:
needsClassRef = true;
staticNodes.push(
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
);
staticNodes.push(
buildPrivateStaticMethodInitLoose(
t.cloneNode(ref),
@@ -618,6 +648,9 @@ export function buildFieldsInitNodes(
privateNamesMap,
),
);
staticNodes.unshift(
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
);
break;
case isInstance && isPublic && isField && loose:
instanceNodes.push(buildPublicFieldInitLoose(t.thisExpression(), prop));
@@ -633,7 +666,7 @@ export function buildFieldsInitNodes(
}
return {
staticNodes,
staticNodes: staticNodes.filter(Boolean),
instanceNodes: instanceNodes.filter(Boolean),
wrapClass(path) {
for (const prop of props) {

View File

@@ -1,5 +1,3 @@
{
"plugins": [
["proposal-private-methods", { "loose": false }]
]
"plugins": [["proposal-private-methods", { "loose": false }]]
}

View File

@@ -1,5 +1,3 @@
{
"plugins": [
["proposal-private-methods", { "loose": true }]
]
"plugins": [["proposal-private-methods", { "loose": true }]]
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-define-map",
"version": "7.4.4",
"version": "7.5.5",
"description": "Helper function to define a map",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
"license": "MIT",
@@ -10,7 +10,7 @@
"main": "lib/index.js",
"dependencies": {
"@babel/helper-function-name": "^7.1.0",
"@babel/types": "^7.4.4",
"lodash": "^4.17.11"
"@babel/types": "^7.5.5",
"lodash": "^4.17.13"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-fixtures",
"version": "7.4.4",
"version": "7.6.2",
"description": "Helper function to support fixtures",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"license": "MIT",
@@ -10,8 +10,7 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-fixtures",
"main": "lib/index.js",
"dependencies": {
"lodash": "^4.17.11",
"semver": "^5.3.0",
"try-resolve": "^1.0.0"
"lodash": "^4.17.13",
"semver": "^5.3.0"
}
}

View File

@@ -1,6 +1,4 @@
import cloneDeep from "lodash/cloneDeep";
import trimEnd from "lodash/trimEnd";
import resolve from "try-resolve";
import clone from "lodash/clone";
import extend from "lodash/extend";
import semver from "semver";
@@ -36,6 +34,13 @@ type Suite = {
filename: string,
};
function tryResolve(module) {
try {
return require.resolve(module);
} catch (e) {
return null;
}
}
function assertDirectory(loc) {
if (!fs.statSync(loc).isDirectory()) {
throw new Error(`Expected ${loc} to be a directory.`);
@@ -77,7 +82,7 @@ export default function get(entryLoc): Array<Suite> {
const suites = [];
let rootOpts = {};
const rootOptsLoc = resolve(entryLoc + "/options");
const rootOptsLoc = tryResolve(entryLoc + "/options");
if (rootOptsLoc) rootOpts = require(rootOptsLoc);
for (const suiteName of fs.readdirSync(entryLoc)) {
@@ -93,7 +98,7 @@ export default function get(entryLoc): Array<Suite> {
assertDirectory(suite.filename);
suites.push(suite);
const suiteOptsLoc = resolve(suite.filename + "/options");
const suiteOptsLoc = tryResolve(suite.filename + "/options");
if (suiteOptsLoc) suite.options = require(suiteOptsLoc);
for (const taskName of fs.readdirSync(suite.filename)) {
@@ -120,6 +125,8 @@ export default function get(entryLoc): Array<Suite> {
const expectLoc =
findFile(taskDir + "/output", true /* allowJSON */) ||
taskDir + "/output.js";
const stdoutLoc = taskDir + "/stdout.txt";
const stderrLoc = taskDir + "/stderr.txt";
const actualLocAlias =
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
@@ -138,7 +145,7 @@ export default function get(entryLoc): Array<Suite> {
const taskOpts = cloneDeep(suite.options);
const taskOptsLoc = resolve(taskDir + "/options");
const taskOptsLoc = tryResolve(taskDir + "/options");
if (taskOptsLoc) extend(taskOpts, require(taskOptsLoc));
const test = {
@@ -146,6 +153,10 @@ export default function get(entryLoc): Array<Suite> {
title: humanize(taskName, true),
disabled: taskName[0] === ".",
options: taskOpts,
validateLogs: taskOpts.validateLogs,
ignoreOutput: taskOpts.ignoreOutput,
stdout: { loc: stdoutLoc, code: readFile(stdoutLoc) },
stderr: { loc: stderrLoc, code: readFile(stderrLoc) },
exec: {
loc: execLoc,
code: readFile(execLoc),
@@ -169,9 +180,7 @@ export default function get(entryLoc): Array<Suite> {
if (minimumVersion == null) {
throw new Error(
`'minNodeVersion' has invalid semver format: ${
taskOpts.minNodeVersion
}`,
`'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersion}`,
);
}
@@ -224,6 +233,30 @@ export default function get(entryLoc): Array<Suite> {
);
}
}
if (!test.validateLogs && (test.stdout.code || test.stderr.code)) {
throw new Error(
"stdout.txt and stderr.txt are only allowed when the 'validateLogs' option is enabled: " +
(test.stdout.code ? stdoutLoc : stderrLoc),
);
}
if (test.options.ignoreOutput) {
if (test.expect.code) {
throw new Error(
"Test cannot ignore its output and also validate it: " + expectLoc,
);
}
if (!test.validateLogs) {
throw new Error(
"ignoreOutput can only be used when validateLogs is true: " +
taskOptsLoc,
);
}
}
// Delete to avoid option validation error
delete test.options.validateLogs;
delete test.options.ignoreOutput;
}
}
@@ -247,7 +280,7 @@ export function multiple(entryLoc, ignore?: Array<string>) {
export function readFile(filename) {
if (fs.existsSync(filename)) {
let file = trimEnd(fs.readFileSync(filename, "utf8"));
let file = fs.readFileSync(filename, "utf8").trimRight();
file = file.replace(/\r\n/g, "\n");
return file;
} else {

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-member-expression-to-functions",
"version": "7.0.0",
"version": "7.5.5",
"description": "Helper function to replace certain member expressions with function calls",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-member-expression-to-functions",
"license": "MIT",
@@ -10,6 +10,6 @@
"main": "lib/index.js",
"author": "Justin Ridgewell <justin@ridgewell.name>",
"dependencies": {
"@babel/types": "^7.0.0"
"@babel/types": "^7.5.5"
}
}

View File

@@ -100,6 +100,34 @@ const handle = {
return;
}
// { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ
// { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ
// {...MEMBER} -> {..._destructureSet(MEMBER)}
//
// [MEMBER] = ARR -> [_destructureSet(MEMBER)] = ARR
// [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR
// [...MEMBER] -> [..._destructureSet(MEMBER)]
if (
// { KEY: MEMBER } = OBJ
(parentPath.isObjectProperty({ value: node }) &&
parentPath.parentPath.isObjectPattern()) ||
// { KEY: MEMBER = _VALUE } = OBJ
(parentPath.isAssignmentPattern({ left: node }) &&
parentPath.parentPath.isObjectProperty({ value: parent }) &&
parentPath.parentPath.parentPath.isObjectPattern()) ||
// [MEMBER] = ARR
parentPath.isArrayPattern() ||
// [MEMBER = _VALUE] = ARR
(parentPath.isAssignmentPattern({ left: node }) &&
parentPath.parentPath.isArrayPattern()) ||
// {...MEMBER}
// [...MEMBER]
parentPath.isRestElement()
) {
member.replaceWith(this.destructureSet(member));
return;
}
// MEMBER -> _get(MEMBER)
member.replaceWith(this.get(member));
},

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-module-transforms",
"version": "7.4.4",
"version": "7.5.5",
"description": "Babel helper functions for implementing ES6 module transformations",
"author": "Logan Smyth <loganfsmyth@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -15,7 +15,7 @@
"@babel/helper-simple-access": "^7.1.0",
"@babel/helper-split-export-declaration": "^7.4.4",
"@babel/template": "^7.4.4",
"@babel/types": "^7.4.4",
"lodash": "^4.17.11"
"@babel/types": "^7.5.5",
"lodash": "^4.17.13"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-regex",
"version": "7.4.4",
"version": "7.5.5",
"description": "Helper function to check for literal RegEx",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-regex",
"license": "MIT",
@@ -9,6 +9,6 @@
},
"main": "lib/index.js",
"dependencies": {
"lodash": "^4.17.11"
"lodash": "^4.17.13"
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-replace-supers",
"version": "7.4.4",
"version": "7.5.5",
"description": "Helper function to replace supers",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers",
"license": "MIT",
@@ -9,9 +9,9 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/helper-member-expression-to-functions": "^7.0.0",
"@babel/helper-member-expression-to-functions": "^7.5.5",
"@babel/helper-optimise-call-expression": "^7.0.0",
"@babel/traverse": "^7.4.4",
"@babel/types": "^7.4.4"
"@babel/traverse": "^7.5.5",
"@babel/types": "^7.5.5"
}
}

View File

@@ -125,6 +125,12 @@ const specHandlers = {
]);
},
destructureSet(superMember) {
throw superMember.buildCodeFrameError(
`Destructuring to a super field is not supported yet.`,
);
},
call(superMember, args) {
return optimiseCall(this.get(superMember), t.thisExpression(), args);
},
@@ -174,6 +180,13 @@ const looseHandlers = {
value,
);
},
destructureSet(superMember) {
const { computed } = superMember.node;
const prop = this.prop(superMember);
return t.memberExpression(t.thisExpression(), prop, computed);
},
};
export default class ReplaceSupers {

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helper-transform-fixture-test-runner",
"version": "7.5.0",
"version": "7.6.0",
"description": "Transform test runner for @babel/helper-fixtures module",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -11,14 +11,14 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-transform-fixture-test-runner",
"main": "lib/index.js",
"dependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.4.4",
"@babel/polyfill": "^7.4.4",
"@babel/code-frame": "^7.5.5",
"@babel/core": "^7.6.0",
"@babel/helper-fixtures": "^7.6.0",
"@babel/polyfill": "^7.6.0",
"babel-check-duplicated-nodes": "^1.0.0",
"jest": "^24.8.0",
"jest-diff": "^24.8.0",
"lodash": "^4.17.11",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"source-map": "^0.5.0"
}

View File

@@ -131,11 +131,17 @@ function wrapPackagesArray(type, names, optionsDir) {
}
function run(task) {
const actual = task.actual;
const expected = task.expect;
const exec = task.exec;
const opts = task.options;
const optionsDir = task.optionsDir;
const {
actual,
expect: expected,
exec,
options: opts,
optionsDir,
validateLogs,
ignoreOutput,
stdout,
stderr,
} = task;
function getOpts(self) {
const newOpts = merge(
@@ -191,56 +197,67 @@ function run(task) {
}
}
let actualCode = actual.code;
const expectCode = expected.code;
if (!execCode || actualCode) {
result = babel.transform(actualCode, getOpts(actual));
const expectedCode = result.code.replace(
escapeRegExp(path.resolve(__dirname, "../../../")),
"<CWD>",
);
const inputCode = actual.code;
const expectedCode = expected.code;
if (!execCode || inputCode) {
const actualLogs = { stdout: "", stderr: "" };
let restoreSpies = null;
if (validateLogs) {
const spy1 = jest.spyOn(console, "log").mockImplementation(msg => {
actualLogs.stdout += `${msg}\n`;
});
const spy2 = jest.spyOn(console, "warn").mockImplementation(msg => {
actualLogs.stderr += `${msg}\n`;
});
restoreSpies = () => {
spy1.mockRestore();
spy2.mockRestore();
};
}
result = babel.transform(inputCode, getOpts(actual));
if (restoreSpies) restoreSpies();
const outputCode = normalizeOutput(result.code);
checkDuplicatedNodes(babel, result.ast);
if (
!expected.code &&
expectedCode &&
!opts.throws &&
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
!process.env.CI
) {
const expectedFile = expected.loc.replace(
/\.m?js$/,
result.sourceType === "module" ? ".mjs" : ".js",
);
console.log(`New test file created: ${expectedFile}`);
fs.writeFileSync(expectedFile, `${expectedCode}\n`);
if (expected.loc !== expectedFile) {
try {
fs.unlinkSync(expected.loc);
} catch (e) {}
}
} else {
actualCode = expectedCode.trim();
try {
expect(actualCode).toEqualFile({
filename: expected.loc,
code: expectCode,
});
} catch (e) {
if (!process.env.OVERWRITE) throw e;
console.log(`Updated test file: ${expected.loc}`);
fs.writeFileSync(expected.loc, `${expectedCode}\n`);
}
if (actualCode) {
expect(expected.loc).toMatch(
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
if (!ignoreOutput) {
if (
!expected.code &&
outputCode &&
!opts.throws &&
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
!process.env.CI
) {
const expectedFile = expected.loc.replace(
/\.m?js$/,
result.sourceType === "module" ? ".mjs" : ".js",
);
console.log(`New test file created: ${expectedFile}`);
fs.writeFileSync(expectedFile, `${outputCode}\n`);
if (expected.loc !== expectedFile) {
try {
fs.unlinkSync(expected.loc);
} catch (e) {}
}
} else {
validateFile(outputCode, expected.loc, expectedCode);
if (inputCode) {
expect(expected.loc).toMatch(
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
);
}
}
}
if (validateLogs) {
validateFile(normalizeOutput(actualLogs.stdout), stdout.loc, stdout.code);
validateFile(normalizeOutput(actualLogs.stderr), stderr.loc, stderr.code);
}
}
if (task.sourceMap) {
@@ -263,6 +280,29 @@ function run(task) {
}
}
function validateFile(actualCode, expectedLoc, expectedCode) {
try {
expect(actualCode).toEqualFile({
filename: expectedLoc,
code: expectedCode,
});
} catch (e) {
if (!process.env.OVERWRITE) throw e;
console.log(`Updated test file: ${expectedLoc}`);
fs.writeFileSync(expectedLoc, `${actualCode}\n`);
}
}
function normalizeOutput(code) {
return code
.trim()
.replace(
new RegExp(escapeRegExp(path.resolve(__dirname, "../../../")), "g"),
"<CWD>",
);
}
const toEqualFile = () => ({
compare: (actual, { filename, code }) => {
const pass = actual === code;

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/helpers",
"version": "7.5.4",
"version": "7.6.2",
"description": "Collection of helper functions used by Babel transforms.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -11,9 +11,9 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helpers",
"main": "lib/index.js",
"dependencies": {
"@babel/template": "^7.4.4",
"@babel/traverse": "^7.5.0",
"@babel/types": "^7.5.0"
"@babel/template": "^7.6.0",
"@babel/traverse": "^7.6.2",
"@babel/types": "^7.6.0"
},
"devDependencies": {
"@babel/helper-plugin-test-runner": "^7.0.0"

View File

@@ -47,15 +47,6 @@ helpers.jsx = helper("7.0.0-beta.0")`
children: void 0,
};
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
if (childrenLength === 1) {
props.children = children;
@@ -67,6 +58,16 @@ helpers.jsx = helper("7.0.0-beta.0")`
props.children = childArray;
}
if (props && defaultProps) {
for (var propName in defaultProps) {
if (props[propName] === void 0) {
props[propName] = defaultProps[propName];
}
}
} else if (!props) {
props = defaultProps || {};
}
return {
$$typeof: REACT_ELEMENT_TYPE,
type: type,
@@ -409,14 +410,19 @@ helpers.objectSpread = helper("7.0.0-beta.0")`
helpers.objectSpread2 = helper("7.5.0")`
import defineProperty from "defineProperty";
// This function is different to "Reflect.ownKeys". The enumerableOnly
// filters on symbol properties only. Returned string properties are always
// enumerable. It is good to use in objectSpread.
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
keys.push.apply(keys, Object.getOwnPropertySymbols(object));
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
if (enumerableOnly) keys = keys.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
return keys;
}
@@ -587,7 +593,7 @@ helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
helpers.instanceof = helper("7.0.0-beta.0")`
export default function _instanceof(left, right) {
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
return right[Symbol.hasInstance](left);
return !!right[Symbol.hasInstance](left);
} else {
return left instanceof right;
}
@@ -601,28 +607,45 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")`
`;
helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
function _getRequireWildcardCache() {
if (typeof WeakMap !== "function") return null;
var cache = new WeakMap();
_getRequireWildcardCache = function () { return cache; };
return cache;
}
export default function _interopRequireWildcard(obj) {
if (obj && obj.__esModule) {
return obj;
} else {
var newObj = {};
if (obj != null) {
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: {};
if (desc.get || desc.set) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
var cache = _getRequireWildcardCache();
if (cache && cache.has(obj)) {
return cache.get(obj);
}
var newObj = {};
if (obj != null) {
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
var desc = hasPropertyDescriptor
? Object.getOwnPropertyDescriptor(obj, key)
: null;
if (desc && (desc.get || desc.set)) {
Object.defineProperty(newObj, key, desc);
} else {
newObj[key] = obj[key];
}
}
}
newObj.default = obj;
return newObj;
}
newObj.default = obj;
if (cache) {
cache.set(obj, newObj);
}
return newObj;
}
`;
@@ -715,7 +738,6 @@ helpers.superPropBase = helper("7.0.0-beta.0")`
`;
helpers.get = helper("7.0.0-beta.0")`
import getPrototypeOf from "getPrototypeOf";
import superPropBase from "superPropBase";
export default function _get(target, property, receiver) {
@@ -740,7 +762,6 @@ helpers.get = helper("7.0.0-beta.0")`
`;
helpers.set = helper("7.0.0-beta.0")`
import getPrototypeOf from "getPrototypeOf";
import superPropBase from "superPropBase";
import defineProperty from "defineProperty";
@@ -814,18 +835,6 @@ helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
}
`;
helpers.temporalRef = helper("7.0.0-beta.0")`
import undef from "temporalUndefined";
export default function _temporalRef(val, name) {
if (val === undef) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
} else {
return val;
}
}
`;
helpers.readOnlyError = helper("7.0.0-beta.0")`
export default function _readOnlyError(name) {
throw new Error("\\"" + name + "\\" is read-only");
@@ -839,7 +848,24 @@ helpers.classNameTDZError = helper("7.0.0-beta.0")`
`;
helpers.temporalUndefined = helper("7.0.0-beta.0")`
export default {};
// This function isn't mean to be called, but to be used as a reference.
// We can't use a normal object because it isn't hoisted.
export default function _temporalUndefined() {}
`;
helpers.tdz = helper("7.5.5")`
export default function _tdzError(name) {
throw new ReferenceError(name + " is not defined - temporal dead zone");
}
`;
helpers.temporalRef = helper("7.0.0-beta.0")`
import undef from "temporalUndefined";
import err from "tdz";
export default function _temporalRef(val, name) {
return val === undef ? err(name) : val;
}
`;
helpers.slicedToArray = helper("7.0.0-beta.0")`
@@ -910,14 +936,16 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
export default function _iterableToArrayLimit(arr, i) {
// this is an expanded form of \`for...of\` that properly supports abrupt completions of
// iterators etc. variable names have been minimised to reduce the size of this massive
// helper. sometimes spec compliancy is annoying :(
// helper. sometimes spec compliance is annoying :(
//
// _n = _iteratorNormalCompletion
// _d = _didIteratorError
// _e = _iteratorError
// _i = _iterator
// _s = _step
if (!(
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
)) { return }
var _arr = [];
var _n = true;
var _d = false;
@@ -943,6 +971,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
export default function _iterableToArrayLimitLoose(arr, i) {
if (!(
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
)) { return }
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
@@ -1118,11 +1149,42 @@ helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
}
`;
helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v)
},
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
`;
helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
`;
@@ -1132,13 +1194,18 @@ helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
// This should only throw in strict mode, but class bodies are
// always strict and private fields can only be used inside
// class bodies.
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
descriptor.value = value;
return value;
}
`;
@@ -1855,16 +1922,17 @@ helpers.wrapRegExp = helper("7.2.6")`
export default function _wrapRegExp(re, groups) {
_wrapRegExp = function(re, groups) {
return new BabelRegExp(re, groups);
return new BabelRegExp(re, undefined, groups);
};
var _RegExp = wrapNativeSuper(RegExp);
var _super = RegExp.prototype;
var _groups = new WeakMap();
function BabelRegExp(re, groups) {
var _this = _RegExp.call(this, re);
_groups.set(_this, groups);
function BabelRegExp(re, flags, groups) {
var _this = _RegExp.call(this, re, flags);
// if the regex is recreated with 'g' flag
_groups.set(_this, groups || _groups.get(re));
return _this;
}
inherits(BabelRegExp, _RegExp);

View File

@@ -280,6 +280,10 @@ export function getDependencies(name: string): $ReadOnlyArray<string> {
return Array.from(loadHelper(name).dependencies.values());
}
export function ensure(name: string) {
loadHelper(name);
}
export const list = Object.keys(helpers)
.map(name => name.replace(/^_/, ""))
.filter(name => name !== "__esModule");

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/node",
"version": "7.5.0",
"version": "7.6.2",
"description": "Babel command line",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -19,19 +19,20 @@
"compiler"
],
"dependencies": {
"@babel/polyfill": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/register": "^7.6.2",
"commander": "^2.8.1",
"lodash": "^4.17.11",
"core-js": "^3.2.1",
"lodash": "^4.17.13",
"node-environment-flags": "^1.0.5",
"regenerator-runtime": "^0.13.3",
"v8flags": "^3.1.1"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"devDependencies": {
"@babel/core": "^7.5.0",
"@babel/helper-fixtures": "^7.2.0",
"@babel/core": "^7.6.2",
"@babel/helper-fixtures": "^7.6.2",
"fs-readdir-recursive": "^1.0.0",
"output-file-sync": "^2.0.0"
},

View File

@@ -5,7 +5,8 @@ import path from "path";
import repl from "repl";
import * as babel from "@babel/core";
import vm from "vm";
import "@babel/polyfill";
import "core-js/stable";
import "regenerator-runtime/runtime";
import register from "@babel/register";
import pkg from "../package.json";

View File

@@ -93,9 +93,6 @@ getV8Flags(function(err, v8Flags) {
}
});
});
process.on("SIGINT", () => {
proc.kill("SIGINT");
process.exit(1);
});
process.on("SIGINT", () => proc.kill("SIGINT"));
}
});

View File

@@ -77,7 +77,7 @@ const assertTest = function(stdout, stderr, opts) {
const actualFiles = readDir(path.join(tmpLoc));
Object.keys(actualFiles).forEach(function(filename) {
if (!opts.inFiles.hasOwnProperty(filename)) {
if (!Object.prototype.hasOwnProperty.call(opts.inFiles, filename)) {
const expected = opts.outFiles[filename];
const actual = actualFiles[filename];

View File

@@ -2,7 +2,7 @@
> **Tags:**
> - :boom: [Breaking Change]
> - :eyeglasses: [Spec Compliancy]
> - :eyeglasses: [Spec Compliance]
> - :rocket: [New Feature]
> - :bug: [Bug Fix]
> - :memo: [Documentation]
@@ -56,7 +56,7 @@ See the [Babel Changelog](https://github.com/babel/babel/blob/master/CHANGELOG.m
## 7.0.0-beta.7 (2017-03-22)
### Spec Compliancy
### Spec Compliance
* Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu)
### Bug Fix
@@ -200,7 +200,7 @@ declare module "C" {
}
```
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
@@ -305,7 +305,7 @@ AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon
## 6.15.0 (2017-01-10)
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison)
@@ -411,7 +411,7 @@ Will include all parser plugins instead of specifying each one individually. Use
## 6.14.0 (2016-11-16)
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo)
@@ -491,7 +491,7 @@ With that test case, there was a ~95ms savings by removing the need for node to
## v6.13.0 (2016-10-21)
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman)
@@ -549,7 +549,7 @@ Fixes two tests that are failing after the merge of #172 ([#177](https://github.
## v6.12.0 (2016-10-14)
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler)
@@ -643,7 +643,7 @@ export const { foo: [ ,, qux7 ] } = bar;
## v6.11.5 (2016-10-12)
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo)
@@ -689,7 +689,7 @@ Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu)
## v6.11.3 (2016-10-01)
### :eyeglasses: Spec Compliancy
### :eyeglasses: Spec Compliance
Add static errors for object rest (#149) ([@danez](https://github.com/danez))
@@ -782,7 +782,7 @@ export toString from './toString';
## 6.11.0 (2016-09-22)
### Spec Compliancy (will break CI)
### Spec Compliance (will break CI)
- Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo
@@ -862,9 +862,9 @@ for (+i in {});
## 6.10.0 (2016-09-19)
> We plan to include some spec compliancy bugs in patch versions. An example was the multiple default exports issue.
> We plan to include some spec compliance bugs in patch versions. An example was the multiple default exports issue.
### Spec Compliancy
### Spec Compliance
* Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu)
@@ -1023,7 +1023,7 @@ declare module "foo" {
- The existential type `*` is not a valid type parameter.
- The existential type `*` is a primary type
### Spec Compliancy
### Spec Compliance
- The param list for type parameter declarations now consists of `TypeParameter` nodes
- New `TypeParameter` AST Node (replaces using the `Identifier` node before)

View File

@@ -898,6 +898,54 @@ interface BindExpression <: Expression {
If `object` is `null`, then `callee` should be a `MemberExpression`.
### Pipeline
These nodes are used by the Smart Pipeline to determine the type of the expression in a Pipeline Operator Expression. The F# Pipeline uses simple `BinaryExpression`s.
#### PipelineBody
```js
interface PipelineBody <: NodeBase {
type: "PipelineBody";
}
```
#### PipelineBareFunctionBody
```js
interface PipelineBody <: NodeBase {
type: "PipelineBareFunctionBody";
callee: Expression;
}
```
#### PipelineBareConstructorBody
```js
interface PipelineBareConstructorBody <: NodeBase {
type: "PipelineBareConstructorBody";
callee: Expression;
}
```
#### PipelineBareAwaitedFunctionBody
```js
interface PipelineBareConstructorBody <: NodeBase {
type: "PipelineTopicBody";
expression: Expression;
}
```
#### PipelineTopicBody
```js
interface PipelineBareConstructorBody <: NodeBase {
type: "PipelineBareAwaitedFunctionBody";
callee: Expression;
}
```
## ConditionalExpression
```js

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/parser",
"version": "7.5.0",
"version": "7.6.2",
"description": "A JavaScript parser",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -28,8 +28,8 @@
"node": ">=6.0.0"
},
"devDependencies": {
"@babel/code-frame": "^7.0.0",
"@babel/helper-fixtures": "^7.4.4",
"@babel/code-frame": "^7.5.5",
"@babel/helper-fixtures": "^7.6.2",
"charcodes": "^0.2.0",
"unicode-12.0.0": "^0.7.9"
},

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