Compare commits

...

264 Commits

Author SHA1 Message Date
4fd9f6e6a2 Fixed semver coercing 2019-11-14 23:00:40 +01:00
08550a076c Attempt to fix babel's assertVersion(7) from not seeing our 7.#.#.csx-.. as valid version of babel 7 2019-11-12 01:02:54 +01:00
d50037be8f Fixing peerDependencies 2019-11-11 23:46:12 +01:00
fd2c2f61bb Fix @babel/core to use csx-version of helpers 2019-11-11 20:28:35 +01:00
0e5c224ff1 Resolving to csx won't work, thus this... (and let's hope it doesnt fuckup things once it reaches npm) 2019-11-11 19:17:58 +01:00
b0b6a92b90 Trying with local package-references 2019-11-11 19:08:20 +01:00
a5c141ea85 Updated the makefile to match the lerna command currently used to publish packages 2019-11-11 19:02:43 +01:00
e488c32244 Nearly there, pointing dependencies of @babel/helpers to the CSX version 2019-11-11 19:01:53 +01:00
0febc4f55f Attempt #n+1 to figure out what lerna's "lerna ERR! Only absolute URLs are supported" is about (and it not outputing a lerna-debug.out like it says it would...) 2019-11-11 16:50:00 +01:00
5415a390a9 Fixed a test-error that mysteriously popped up 2019-11-11 15:10:30 +01:00
7dd772001d Working around odd backslash issue with corejs2 iterableToArray-helper 2019-11-11 14:35:07 +01:00
d314e28457 Fixed tests 2019-11-11 14:18:26 +01:00
b248b3f4e9 Adding the prepublish step to the custom publish-cerxes makefile-target 2019-11-11 11:37:07 +01:00
c8c6ff7c4c Implemented a fix to initializers+class-properties 2019-11-11 11:33:32 +01:00
Mohammad Ahmadi
8e5f2dc929 corrected the grammar of an option description (#10691)
* grammar correction of an option description

(missed in #10589)

* changed description to be consistent with others

Co-Authored-By: Huáng Jùnliàng <jlhwung@gmail.com>

* ran prettier
2019-11-11 12:39:36 +03:00
Kenza Houmani
2b082601a7 Fix parentheses on replaceWithMultiple for JSX (#10598)
* Closes #9851 Fix parentheses on replaceWithMultiple for JSX

* Rename test

* Use generate(ast) directly
2019-11-11 12:36:17 +03:00
chrishinrichs
70c0ed512a Fix: Don't call Object.keys on non-objects (babel#10482) (#10683) 2019-11-08 21:31:46 -06:00
Babel Bot
8c2ed89aaa Add v7.7.3 to CHANGELOG.md [skip ci] 2019-11-08 20:52:12 +00:00
Nicolò Ribaudo
e315d65a7a v7.7.3 2019-11-08 23:45:00 +03:00
Nicolò Ribaudo
0287c0f02f
Don't recover from "adjacent jsx elements" parser error (#10682) 2019-11-08 23:23:04 +03:00
Babel Bot
c2bace4b73 Add v7.7.2 to CHANGELOG.md [skip ci] 2019-11-06 23:28:38 +00:00
Nicolò Ribaudo
35f4d12763 v7.7.2 2019-11-07 02:20:52 +03:00
Nicolò Ribaudo
9082e68d6f
Parse arrows with params annotations in conditional expressions (#10669) 2019-11-07 02:18:36 +03:00
Vojtech Miksu
bdb4318f47 chore: update convert-source-map dep (#10667) 2019-11-06 14:30:32 -06:00
Maksim Ryzhikov
3ab035bab6 fix: Use the recommended property to specify repository URL (#10665) [ci-skip]
Use recommended by npm property to specify repository URL
https://docs.npmjs.com/files/package.json#repository

Otherwise, it breaks some tools which relay on this convention for example "nlf" package
https://github.com/iandotkelly/nlf/blob/master/lib/nlf.js#L284-L285
2019-11-06 07:34:09 -05:00
Leonid Shevtsov
2cd5ad0c80 fix typo: identifer -> identifier (#10647) 2019-11-06 09:13:08 +01:00
Huáng Jùnliàng
2640e5a27c fix: remove accessibility of constructor (#10658) 2019-11-05 13:52:57 -06:00
Huáng Jùnliàng
0f949990c3
fix: add inList setter for compatibility with babel-minify (#10656) 2019-11-05 12:28:16 -05:00
njlr
f544753bb8 code style: consistent spacing (#10643) [ci-skip]
Makes spacing consistent
2019-11-05 09:40:57 -05:00
Babel Bot
d3db02da30 Add v7.7.1 to CHANGELOG.md [skip ci] 2019-11-05 13:50:36 +00:00
Nicolò Ribaudo
42c8e0fb2f v7.7.1 2019-11-05 14:44:00 +01:00
Nicolò Ribaudo
bf48fca6a0
Revert "throw a TypeError if identifier validation fails (#106… (#10650)
This reverts commit c7d8b8a37752f42163128cf4d5e8b54c2637cec4.
2019-11-05 14:43:23 +01:00
Archer
f8eb290da1 Fix(babel-preset-env): check api.caller is a function to avoid… (#10649) 2019-11-05 14:39:14 +01:00
Nicolò Ribaudo
5f2240e7ab Add v7.7.0 to CHANGELOG.md [skip ci] 2019-11-05 12:06:52 +01:00
Nicolò Ribaudo
97faa83953 v7.7.0 2019-11-05 11:27:14 +01:00
Nicolò Ribaudo
cdbffe3990 Remove --require-scripts from publish-ci [skip ci] 2019-11-05 11:25:29 +01:00
Huáng Jùnliàng
b114486bc1 Traverse performance (#10480)
* perf: remove this.inList assignment

* perf: convert NodePath.parentKey into accessor function

* perf: compress shouldSkip/shouldStop/removed traverse flags

* perf: lazy initialize this.skipKeys

* perf: lazily initialize NodePath.data

* add code comments before bit operations

* remove unused typeAnnotation property

# Conflicts:
#	packages/babel-traverse/src/path/index.js

* early return when visitor keys are empty
2019-11-05 11:11:58 +01:00
Nicolò Ribaudo
e9c1bce50f
Add support for TS declare modifier on fields (#10545)
* [parser] Add support for TS declare modifier on fields (#10484)

* [parser] Add support for TS declare modifier on fields

* Use Object.create(null)

* Comment

* Add support for TS declare types to types and generator (#10544)

* Transform TypeScript "declare" fields (#10546)

* Transform TypeScript "declare" fields

* Remove multiple spaces

* declareFields -> allowDeclareFields

* Update after rebase
2019-11-05 10:56:57 +01:00
Nicolò Ribaudo
87feda7c2a
@babel/parser error recovery (#10363)
* Add error recovery support to @babel/parser

* Update @babel/parser tests to always recover from errors

* Update this.raise usage in @babel/parser:

- expression.js
- lval.js
- statement.js
- estree.js
- flow.js
- jsx/index.js
- tokenizer/index.js

* Update @babel/parser fixtures with recovered errors

* Fix tests out of @babel/parser

* Do not use try/catch for control flow

* Update invalid fixtures

* Do not report invalid lhs in toAssignable

* Do not validate function id multiple times

* Dedupe reserved await errors

* Remove duplicate errors about strict reserved bindings

* Remove duplicated error about yield/await inside params

* Don't error twice for methods in object patterns

* Don't report invalid super() twice

* Remove dup error about reserved param for expr arrows

* Remove double escapes in migrated tests

* Dedupe errors about invalid escapes in identifiers

* Remove duplicated error about decorated constructor

* Remove duplicated error about spread in flow class

* Don't throw for invalid super usage

* Don't fail for object decorators with stage 2

* Fix flow inexact type errors

* Fix flow

* Fix errors about escapes in keywords (ref: #10455)

* Update after rebase

* Fix todo

* Remove duplicated error when using += for defaults

* Remove unnecessary throw

* Nit: use ??
2019-11-05 10:15:00 +01:00
Nicolò Ribaudo
d25262ec4b
Correctly delegate .return() in async generator (#10422)
* Correctly delegate .return() in async generator

* Add catch param

* minNodeVersion

* Add another test
2019-11-05 00:35:40 +01:00
Nicolò Ribaudo
861844761f
[preset-env] Don't use async-to-generator when already using re… (#9481)
* [preset-env] Don't use async-to-generator when already using regenerator

* Add tests

* Update fixtures
2019-11-04 22:53:53 +01:00
Nicolò Ribaudo
43aa7e262c
Don't throw when destructuring into a var named as an import (#10628) 2019-11-04 22:50:36 +01:00
Huáng Jùnliàng
5e24016623 fix: remove ExportNamedDeclaration when the specifier is empty (#10638) 2019-11-04 21:51:24 +01:00
Nicolò Ribaudo
d023e105b7 [TS] Parse calls with type args in optional chains (#10631)
* [TS] Parse calls with type args in optional chains

* Test output
2019-11-04 13:25:15 -05:00
Nicolò Ribaudo
abce0ef49d [TS] Correctly transform computed strings and templates in enums (#10555)
* [TS] Correctly transform computed strings and templates in enums

* Typo [skip ci]
2019-11-04 13:22:49 -05:00
Chris Garrett
5c0d8a9de7 add legacy decorators support to strict class fields (#10616)
This PR allows legacy decorators to work with strict class fields, which
are now stage 3 and have shipped in a number of browsers. Allowing this will
allow users of the legacy transform (which is currently recommended by the
champions of the decorator proposal) to use the proper class field semantics
for non-decorated fields, which should help prevent breakage later on.

This change is not a breaking change, since users had to explicitly opt into
loose mode in class fields before. This just gives them the option to remove
that opt-in.
2019-11-04 13:05:42 -05:00
Nicolò Ribaudo
bea1b0d0af
Add support for .cjs config files (#10599)
* Remove duplicate config loading logic and errors

* Add support for .cjs config files

* Add tests

* [tests] Fallback for fs.promises on node 6
2019-11-04 00:24:44 +01:00
Mohammad Ahmadi
58a646be59 corrected the grammar of option descriptions (#10589)
* corrected the grammar of option descriptions

* added comment
2019-11-04 00:24:00 +01:00
Martin Forsgren
c7d8b8a377 throw a TypeError if identifier validation fails (#10621)
* throw a TypeError if Identifier validation fails

* Relax identifier validation, reserved words are ok
2019-11-02 12:04:16 +01:00
Huáng Jùnliàng
d08702c9d2
inputSourceMap should work when it is in an external file (#10623)
* fix: construct comment block for fromMapFileComment

* add test

* small tweak: redundant capturing group
2019-10-31 16:12:44 -04:00
Huáng Jùnliàng
a2b5437b01 chore: remove output-file-sync dependency (#10619) 2019-10-31 11:51:36 -07:00
Linus Unnebäck
0b0edc3e3d chore: bump source-map-support to 0.5.16 (#10615) 2019-10-30 07:56:52 -04:00
Huáng Jùnliàng
e419e5fe42
chore: bump source-map-support to 0.5.14 (#10614) 2019-10-29 19:19:16 -04:00
Nicolò Ribaudo
4e6a4b08bb
Create @babel/plugin-syntax-top-level-await (#10573) 2019-10-29 23:27:56 +01:00
Ivan Medina
3d2f365074 [transform-react-jsx] Add useSpread option to transform JSX (#10572)
* [transform-react-jsx] Add useSpread option to transform JSX

* Add validation for default option

* Add error when using useSpread and useBuiltIns at the same time

* Move useSpread to convertAttribute helper function

* Add useSpread option to presect-react

* Remove casting useSpread to boolean in preset-react option.

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2019-10-29 23:02:53 +01:00
Huáng Jùnliàng
8ffca0475a Merge multiple regex transform plugin (#10447)
* feat: implement create-regexp-features-plugin

* fix: test input is not effective

* refactor: leverage create-regexp-features-plugin

* test: add more test cases

* test: update test fixture

* chore: add type annotation to features

* test: add regression test for issue 9892

* add regression test for issue 9199

* address review comments from Nicolò

* address review comments from Brian

* small tweaks

* Enable dotAllFlag when flags includes u
2019-10-29 22:58:04 +01:00
George Zahariev
ec3345bb57 Flow enums parsing (#10344)
* Flow enums parsing

* Parse exporting enums

* Enums parsing remove lookahead, other improvements

* Enums: add EnumBody and EnumMember aliases, change boolean members to use BooleaLiteral value

* Fix enum member init flow type, now that boolean members have a BooleanLiteral value

* Flow enums: use contextual utils, change members length checks to use logic operators, remove reserved word logic modification

* Flow enums: remove unnecessary code in generator, fix error message
2019-10-29 22:55:12 +01:00
Vivek Nayyar
4b3a19ea9f fixed missing errors on assignment pattern in object expression (#10607)
* 🐛 fixed missing errors on assignment pattern in object expression

* ♻️ remove a non-needed comment

* 🐛 missed adding comma in the test input

* 🐛 fixed the failing valid-property-initializer test
2019-10-29 22:32:02 +01:00
Micah Zoltu
198b4a0fbd Changes UMD callsite to be more likely to pass in the intended… (#10477)
* Changes UMD callsite to be more likely to pass in the intended object.

Fixes #10476
Note: This PR should be considered pseudocode and used as an illustration of the proposed fix.  I do not know nearly enough about this project to know if this is an appropriate solution to the problem, nor do I have the confidence to update the tests appropriately.

* Update tests
2019-10-29 22:19:49 +01:00
Nicolò Ribaudo
143d159982
Create parser plugin "topLevelAwait" (#10449)
* Create parser plugin "topLevelAwait"

* Update test262 whitelist

* Update ts typings

* Fix "sourceType: unambiguous" with TLA

* Ambiguous tokens after await

* Update await %x(0)

* typo [skip ci]

* Typo [skip ci]

Co-Authored-By: Brian Ng <bng412@gmail.com>
2019-10-29 22:18:39 +01:00
Georgii Dolzhykov
63f9a3c946 rename assertsModifier to asserts (#10613)
see https://github.com/babel/babel/pull/10543#issuecomment-547571501
2019-10-29 16:25:42 -04:00
Devon Govett
3a5e8a8dd4 Add support for babel.config.json (#10501)
* Add support for babel.config.json root config

* Throw if multiple configuration files are found

* Add tests
2019-10-29 19:37:50 +01:00
Tan Li Hau
38a3063111 add assertions signature for TypeScript (#10543)
* add asserts predicate

* fix flow

* babel-generator for typescript assertions

* babel-types for typescript assertions

* asserts modifier as boolean
2019-10-29 18:51:33 +01:00
Nicolò Ribaudo
4cd93ab5f3
[parser] Enable "exportNamespaceFrom" by default (#10521) 2019-10-29 18:44:32 +01:00
Eugene Myunster
d248e2d188 moving proposalNullishCoalescingOperator and proposalOptionalChaining to stage 3 (#10590) 2019-10-29 18:44:01 +01:00
Nicolò Ribaudo
f47fbd5f39
Nit: Use ?. in the example used by the proposal readme (#10604) 2019-10-29 18:35:15 +01:00
Bogdan Chadkin
be0fcaaf49 Make dir for babel --out-file (#8622)
* Make dir for babel --out-file

Currently there's unexpected regression after upgrade from babel 6.
On creating file with any depth like dist/index.js the error about
not existing directory is thrown.

In this diff I modified babel-cli to create deep directory for out-file
command.

I also replaced `mkdirp` with more supported `make-dir` package which
also have official promise support.

* Fix test
2019-10-29 18:29:45 +01:00
彭驰
4e5ac1fd5c Fix #8326, add back --quiet option. (#10399)
* Fix issue #8326, quiet the @babel/cli with --quiet cli option.

* --quiet and --verbose options now conflict with each other.
2019-10-29 18:28:52 +01:00
Nicolò Ribaudo
1d1fab4ea2
[parser] Add support for private fields in TypeScript (#10483)
* [parser] Add support for private fields in TypeScript

* Fix flow
2019-10-29 18:27:54 +01:00
Simen Bekkhus
f1bc6c4e18 feat: if code frame error is on a single line, highlight the w… (#10361)
* feat: if code frame error is on a single line, highlight the whole path

* flow
2019-10-29 18:23:54 +01:00
gr
b6ef9689b2 [parser] Parse only modifiers of actual methods (#10594)
* Parse only modifiers of actual methods

* Throw question token if is used before the real name
2019-10-29 17:56:05 +01:00
Huáng Jùnliàng
01927babe2 chore: update web.immediate support fixtures (#10612) 2019-10-29 16:23:59 +01:00
Mateusz Burzyński
9ada30c207 Use .find instead of .filter to get targetPath in ImportInjector (#10608) 2019-10-27 15:09:03 -04:00
ExE Boss
43065a9e24 fix(babel‑helpers/interopRequireWildcard): Avoid double nullis… (#10585)
* fix(babel‑helpers/interopRequireWildcard): Avoid double nullish check

* Update fixtures
2019-10-24 23:14:44 +02:00
Brian Ng
fce1b74105 Test node@13 on CircleCI (#10600) 2019-10-24 09:28:01 -04:00
Huáng Jùnliàng
562b6c3bbb chore: replace outdated travis-ci.org badges [ci skip] (#10593) 2019-10-22 21:35:02 -04:00
Huáng Jùnliàng
1770dace34 chore: test against Node.js 13 (#10591) 2019-10-23 00:23:20 +02:00
Matthew Whitworth
5b40845afe add test and fix for string literal case (#10578) 2019-10-21 17:39:03 +02:00
samuel kwok
fe258dec04 fix: _interopRequireWildcard should only cache objects (#10574)
* fix: [#10561] _interopRequireWildcard should cache object only

* fix: narrow down cache restriction to object/function type

* test: add interop require null module case
2019-10-19 12:01:38 +02:00
Nicolò Ribaudo
78cd63d9cf
Fix invalid test layout in @babel/parser 2019-10-18 11:16:17 +02:00
Nicolò Ribaudo
43b623c1f1
[traverse] Allow skipping nodes inserted with .replaceWith() (#9777)
* Avoid regression
2019-10-18 00:16:35 +02:00
Daniel Arthur Gallagher
b5b8055cc0 docs: add homepage link to @babel/runtime package.json (#10418)
* docs: add homepage link

Adds a homepage link to populate npmjs.com.
Update the repository property syntax.

* Update the repository link

Point to the root repo plus a reference to the subdirectory.

* style: drop HTML extension
2019-10-17 23:26:14 +02:00
Jaideep Bhoosreddy
da9c9a64c2 Add master branch workflow for test262 tests (#10556)
The results of these tests will be stored in build artifacts which will be used to compare with test262 runs on PR (future work!). Robin has also done a
lot of work to ensure all babel packages are properly linked to the
test runner. Additionally, Nicolo has helped in mentorship and
contributions to babel-test262-runner which is used here.

We're no longer giving xunit output to CircleCI because once it sees failing tests it will mark babel's master as broken. As a stopgap, it will render the test results in the mocha spec format, which is human readable.

Co-Authored-By: Robin Ricard <rricard2@bloomberg.net>
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2019-10-17 13:52:31 -04:00
Huáng Jùnliàng
8c94b3f209
Bump babel-types to ^7.6.3 (#10568)
* fix incorrect lerna bootstrap options

* chore: bump @babel/types dependencies to v7.6.3

* chore: remove ignore-engines on lerna bootstrap
2019-10-17 07:49:41 -04:00
gr
095f28a913 fix: Exclude catch clause from let identifier error (#10559)
* Exclude catch clause from let identifier error

* Disallow let binding based on parameter

* Add test

* Remove unused getter

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

Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
2019-10-17 09:30:36 +02:00
Huáng Jùnliàng
487f10f84d fix: disable caching when babel could not read/write cache (#10557)
* fix: disable caching when babel could not read/write cache

* emit warning when cache folder resides in readonly fs

* fix: always register save handler

* cache: maintain old behaviour

* test: add more test case

* fix: next tick tasks are FIFO

* test: disable test on Windows
2019-10-17 09:30:01 +02:00
piotr
5800fc97b3 [parser] Exception to 8 and 9 in tagged template (#10567) 2019-10-17 00:01:22 +02:00
Nicolò Ribaudo
2254542010
Don't use deprecated "lerna publish --require-scripts" (#10558) [skip ci] 2019-10-16 22:13:21 +02:00
Brian Ng
d234ff6572 Revert "chore: introduce envinfo into environment section (#10553)" (#10564)
This reverts commit 800eccc046ff71e4c2a0cbdb3fdddbae87933a71.
2019-10-16 10:56:35 -04:00
Huáng Jùnliàng
800eccc046 chore: introduce envinfo into environment section (#10553)
* chore: introduce envinfo into environment section [skip ci]

* Apply suggestions from code review

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

* Address review comments from Nicolò

* Update .github/ISSUE_TEMPLATE/Bug_report.md [skip ci]

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

* chore: simplify issue template [skip ci]
2019-10-16 09:12:13 -05:00
Gerald
cd5d3abc32 fix: String#italics is incorrectly defined in babel-preset-env (#10563) 2019-10-16 09:23:47 -04:00
Nicolò Ribaudo
272d85d0ad
Inject core-js@3 imports in Program:exit instead of on post() (#10146)
* Inject corejs3 imports in Program:exit instead of post

This allows them to be requeued and transformed by other plugins.

* Also entry

* Rebase

* Update packages/babel-preset-env/src/polyfills/corejs3/entry-plugin.js [skip ci]

Co-Authored-By: Brian Ng <bng412@gmail.com>
2019-10-15 23:46:10 +02:00
Nicolò Ribaudo
686186cabc
Attemp fixing @babel/node and cli errors on Travis on Windows (#10547)
For some reason, it looks like that the rimraf call didn't properly delete
the folder:

   EEXIST: file already exists, mkdir 'C:\Users\travis\build\babel\babel\packages\babel-node\test\tmp'
      150 |   process.chdir(__dirname);
      151 |   if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
    > 152 |   fs.mkdirSync(tmpLoc);
          |      ^
      153 |   process.chdir(tmpLoc);
      154 | };

Lets try to reuse the existing folder rather than deleting and recreating it
2019-10-15 23:00:23 +02:00
Alejandro Sánchez
06313a6288 Allow duplicate __proto__ keys in patterns, simple case (#6705) (#10532)
* Allow duplicate __proto__ keys in patterns, simple case (#6705)

* Update test262 whitelist

* Rename checkDuplicatedProto's parameter and adjust type

* Store first __proto__ redefinition's position
2019-10-15 00:18:33 +02:00
Huáng Jùnliàng
dcf7d89b8e fix: remove filename annotation in buildCodeFrameError (#10539) 2019-10-14 18:19:55 +02:00
Nicolò Ribaudo
1b19608a5a
Update fixtures for core-js new version 2019-10-14 00:59:02 +02:00
Brian Ng
e28c8ac612 Fix generator missing parens around an arrow returning function type (#10519) 2019-10-11 21:22:42 -04:00
Nicolò Ribaudo
99035ca96e
Don't use args rest/spread to hoist super method calls (#9939)
* Don't use args rest/spread to hoist super method calls

* Hoist this in hoisted super method calls

* Make the code more readable

Review by edoardocavazza
2019-10-11 10:18:54 +02:00
Babel Bot
c455d2af86 Add v7.6.4 to CHANGELOG.md [skip ci] 2019-10-10 14:30:50 +00:00
Nicolò Ribaudo
a422ea64ee
v7.6.4 2019-10-10 16:25:04 +02:00
Nicolò Ribaudo
34d30e28d6 Revert "chore: Upgrade source-map to 0.6.1 (#10446)" (#10536)
This reverts commit cc080417b995e2903352e7956890e0c74b23d4c9.
2019-10-10 09:03:49 -05:00
Huáng Jùnliàng
3ad4c70d3a fix prepublish-build (#10530) 2019-10-09 07:40:02 +02:00
Nicolò Ribaudo
34937f13d5
Trailing comma after rest - The final fix (#10491)
* [parser] Track trailing commas in extras instead of state

* Update existing tests

* Update test262 whitelist

* Improve error message and location

* nit

* Use lookaheadCharCode
2019-10-08 23:08:50 +02:00
Babel Bot
c7add11fdc Add v7.6.3 to CHANGELOG.md [skip ci] 2019-10-08 19:33:00 +00:00
Nicolò Ribaudo
d329156ebc
v7.6.3 2019-10-08 21:31:40 +02:00
Nicolò Ribaudo
25b35261ca
Update test262 [skip ci] 2019-10-08 20:39:07 +02:00
Huáng Jùnliàng
563874c06c Do not remove let bindings even they are wrapped in closure (#10343)
* fix: should not remove let binding even it is wrapped in closure

Fixes #10339

* fix: remove bindings defined in blockScope when wrapped in closure

* Move test assertions to the top level to ensure that they run
2019-10-08 19:43:12 +02:00
Tan Li Hau
b0acfb24dd add scope to TSModuleDeclaration (#10119) 2019-10-08 19:35:40 +02:00
Nicolò Ribaudo
599d2ff324
Update yarn.lock [skip ci] 2019-10-08 19:16:36 +02:00
Huáng Jùnliàng
0856618ed5 perf: replace lookahead by lookaheadCharCode (#10371)
* perf: replace lookahead by lookaheadCharCode

* fix: flow ignore

* refactor: add nextTokenStart method

* refactor: duplicated isNewLine code

* refactor: remove lookahead usage from babylon core
2019-10-08 19:09:05 +02:00
Jessica Franco
bc0966a46f Add declarations for more of @babel/types exports (#10504)
This adds lots of missing declarations to the types of @babel/types,
including many utility functions useful to plugin authors.

With the typescript types, I tried to make them as useful as possible
for control flow analysis / inference, but Flow doesn't seem to
support overloads and I'm not as familiar with it anyway so it has
simpler types.
2019-10-08 19:07:57 +02:00
Nicolò Ribaudo
3498195ae2
Do not hoist jsx referencing a mutable binding (#10529) 2019-10-08 18:50:03 +02:00
Henry Zhu
fbf3cb0ac4 Misc: also lock old PRs [skip ci] (#10524) 2019-10-03 15:46:07 -05:00
Brian Ng
e6264a0992
Bump jest@24.9.0 (#10520) 2019-10-02 18:32:34 -05:00
Huáng Jùnliàng
0b37ab0362 Use make -j for parallel build (#10506)
* build: add build-babel-types task

* chore: revamp Makefile to for parallel builds

* chore: style fix

* chore: skip install step as we handle yarn in makefile

* test job execution order
2019-10-03 00:17:04 +02:00
Brian Ng
57ae306457
Bump flow@0.108.0 (#10516) 2019-10-02 12:13:58 -05:00
David J. Hamilton
fa5a40c8d5 assertNoDuplicates throw with more context (#10419)
When users see errors like

```
Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
```

It can be difficult to determine the source of the conflict, especially
in a larger build system.

This commit outputs what is known about the plugins that actually
conflict, which can be helpful for users to determine the root cause of
the conflict.

Partially addresses #9778
2019-10-02 16:45:03 +02:00
Nicolò Ribaudo
a219b6de7a
Disallow await inside async arrow params (#10469)
* Disallow await inside async arrow params

* Use -1 as default for awaitPos/yieldPos
2019-10-02 07:37:40 +02:00
Huáng Jùnliàng
fa5057f9fb Flow: interface identifier should be declared in the scope (#10220)
* fix: typo

* declare name for flow interface

* add test case for export overload function, typescript

* test: add test

Fixes #10044

* test: update test

* test(flow): add multiple declarations regression test

* re-enable flow test case

# Conflicts:
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/def-site-variance/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-declare-statements/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-interfaces-module-and-script/input.js
#	packages/babel-plugin-transform-flow-strip-types/test/fixtures/strip-types/strip-iterator/input.js

* test: disable two flow dupl-decl test

* fix: do not declare name for declare function until we figure out a better way

* test: duplicate declare function and function would not throw
2019-10-02 07:32:42 +02:00
Brian Ng
02f2d17e83 Revert "Try different name for used-by feature again [skip ci]" (#10515)
This reverts commit b351f29033ac109c2140dc6762758ffbf88522c9.
2019-10-01 23:29:04 -04:00
Henry Zhu
b351f29033 Try different name for used-by feature again [skip ci] (#10513) 2019-10-01 21:36:22 +02:00
Huáng Jùnliàng
298c9a6c33 Add filename to transform error (#10511)
* polish: use “unknown” as a default filename in buildCodeFrameError

* feat: add filename to transform error

* fix: incorrect warning message

* fix: add filename to generate phrase error message

* address review comment from Nicolò
2019-10-01 17:19:29 +02:00
Nicolò Ribaudo
80d99b4d4e
Do not allow member expressions to start async arrows (#10332)
* Do not allow member expressions to start async arrows

* Boolean -> boolean
2019-10-01 11:40:42 +02:00
Huáng Jùnliàng
94fcabc4e3 Update test262 whitelist 2019-09-30 11:37:09 -04:00
Huáng Jùnliàng
5f1970433d
chore: only apply lazy cjs module transform on cli and core (#10443) 2019-09-27 16:53:27 -04:00
Nicolò Ribaudo
b459f6a0a4
Add windows to travis (#10249)
* Add windows to travis

* Update

* Do not use sh file on windows

* Fix whitespace

* Unify command

* ./ doesn't work on windows

* Remove all ./ usages

* Run windows test before others

* fix: normalize filename when generating sources

sources should be URL.

* fix: replace normalized path to cwd

* chore: add nodePlatform task options

* fix: normalize preset-env filename output

* chore: replace normalized path to CWD on win32 platform

* limit transform-react-source to run on linux and darwin

* test: escapeRegExp on testcases

* test: add test for babel --filename on windows

* test: double babel-node/cli test timeout

* chore: workaround windows build does not stop

* chore: remove redundant condition

* refactor: rename `nodePlatform` to `os`
2019-09-26 20:59:17 +02:00
Michael J. Currie
66062c2a8c Template literal validation (#10492)
* add template literal validation

* avoid null/undefined error when validating

* simplify validation logic and fix tests

Co-authored-by: Michael J. Currie <michaeljcurrie136@gmail.com>
2019-09-26 19:58:36 +02:00
Phoenix
8d4f95de45 Fix grammar in doc/design/monorepo.md 🤓 (#10496) [skip ci] 2019-09-26 12:37:15 +02:00
Nicolò Ribaudo
d0f093e716
Update test262 whitelist 2019-09-25 02:03:58 +02:00
Gonzalo Rodríguez
490798a26d [parser] Disallow numeric separators in legacy octal like inte… (#10493)
* Disallow numeric separators in lols

* Update whitelist

* Rename test

* Better syntax when checking
2019-09-25 01:32:50 +02:00
Nicolò Ribaudo
eaa1474541
Enable optional chaining and nullish coalescing plugins (#10494)
* Add optional chaining plugin

* Nullish coalescing
2019-09-24 23:11:56 +02:00
Nicolò Ribaudo
0e9502685a
[parser] Don't crash on comment after trailing comma after eli… (#10490) 2019-09-24 17:08:58 +02:00
Huáng Jùnliàng
26be14b24d chore: add access: public where missing (#10489) [skip ci]
* @babel/types
* @babel/plugin-transform-named-capturing-groups-regex
2019-09-24 14:04:54 +02:00
Huáng Jùnliàng
6f3460c767 chore: add access: public to babel parser publish config (#10487) [skip ci] 2019-09-24 10:03:07 +02:00
Corey Farrell
cc080417b9 chore: Upgrade source-map to 0.6.1 (#10446) 2019-09-24 02:01:32 +02:00
Nicolò Ribaudo
a00f371610
Update v7.6.2 changelog [skip ci] 2019-09-23 23:27:03 +02:00
Babel Bot
af66d521bd Add v7.6.2 to CHANGELOG.md [skip ci] 2019-09-23 21:16:32 +00:00
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
Nicolò Ribaudo
a9a7f4e690
v7.5.4 2019-07-09 20:52:37 +02:00
Nicolò Ribaudo
fa5ec75c43
Fix _objectSpread2 for real (#10188)
* Fix _objectSpread2 for real

* Tests

* Test 2
2019-07-09 20:50:07 +02:00
Babel Bot
b961d39a4d Add v7.5.3 to CHANGELOG.md [skip ci] 2019-07-09 14:52:52 +00:00
Nicolò Ribaudo
759ff4d6df
v7.5.3 2019-07-09 16:41:44 +02:00
Nicolò Ribaudo
9e65472377
[_objectSpread2] Do not use hoisted var from prev iteration (#10180) 2019-07-09 16:38:40 +02:00
Babel Bot
25f040caa4 Add v7.5.2 to CHANGELOG.md [skip ci] 2019-07-08 19:53:06 +00:00
Nicolò Ribaudo
0dbf99bedb
v7.5.2 2019-07-08 21:46:49 +02:00
Nicolò Ribaudo
f48b47c1f7
Do not trust Scope when removing TypeScript types (#10174)
* Do not trust Scope when removing TypeScript types

* Warn

* Update warning message

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

* Add test

* Node 6
2019-07-08 21:44:26 +02:00
Nicolò Ribaudo
406a65c894
Don't rely on getOwnPropertyDescriptors in objectSpread2 (#10171) 2019-07-07 11:24:36 +02:00
Huáng Jùnliàng
075a50242d fix: register injected importDeclaration (#10172) 2019-07-06 10:44:14 -05:00
Babel Bot
c777e81e06 Add v7.5.1 to CHANGELOG.md [skip ci] 2019-07-06 08:13:08 +00:00
4393 changed files with 201387 additions and 19015 deletions

View File

@ -30,11 +30,20 @@ aliases:
- &artifact_env_min - &artifact_env_min
path: ~/babel/packages/babel-preset-env-standalone/babel-preset-env.min.js path: ~/babel/packages/babel-preset-env-standalone/babel-preset-env.min.js
- &test262_workdir
working_directory: ~/babel/babel-test262-runner
- &artifact_test262_tap
path: ~/test262.tap
- &artifact_test262_xunit
path: ~/test-results
jobs: jobs:
build: test:
working_directory: ~/babel working_directory: ~/babel
docker: docker:
- image: circleci/node:12 - image: circleci/node:13
steps: steps:
- checkout - checkout
- restore-cache: *restore-yarn-cache - restore-cache: *restore-yarn-cache
@ -54,3 +63,59 @@ jobs:
- store_artifacts: *artifact_env_min - store_artifacts: *artifact_env_min
- save_cache: *save-node-modules-cache - save_cache: *save-node-modules-cache
- save_cache: *save-yarn-cache - save_cache: *save-yarn-cache
test262:
working_directory: ~/babel
docker:
- image: circleci/node:12
steps:
- checkout
- restore-cache: *restore-yarn-cache
- restore-cache: *restore-node-modules-cache
- run:
name: Build Babel
command: BABEL_ENV=test make bootstrap
- run:
name: Link Babel
command: |
cd packages
for package in */; do
cd $package
yarn link
cd ..
done
- run:
name: Setup Test Runner
command: |
git clone --recurse-submodules https://github.com/babel/babel-test262-runner
cd babel-test262-runner
yarn
yarn add tap-mocha-reporter --dev
curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 > jq
chmod +x ./jq
for package in ../packages/*/package.json; do
yarn link $(./jq -j ".name" $package)
done
node lib/download-node
- run:
name: Run Test262
command: node lib/run-tests I_AM_SURE | tee ~/test262.tap
<<: *test262_workdir
- store_artifacts: *artifact_test262_tap
- run:
name: Output test262 results
command: |
cat ~/test262.tap | $(npm bin)/tap-mocha-reporter spec || true
<<: *test262_workdir
workflows:
version: 2
test:
jobs:
- test
master:
jobs:
- test262:
filters:
branches:
only:
- master

View File

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

View File

@ -24,4 +24,6 @@ suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
suppress_type=$FlowFixMe suppress_type=$FlowFixMe
suppress_type=$FlowSubtype suppress_type=$FlowSubtype
esproposal.export_star_as=enable esproposal.export_star_as=enable
esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable
module.name_mapper='^@babel\/\([a-zA-Z0-9_\-]+\)$' -> '<PROJECT_ROOT>/packages/babel-\1/src/index' module.name_mapper='^@babel\/\([a-zA-Z0-9_\-]+\)$' -> '<PROJECT_ROOT>/packages/babel-\1/src/index'

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. * Restructure transformers so they're only ran if the AST contains nodes that they need to worry about. Improves transpilation speed significantly.
* **Bug Fix** * **Bug Fix**
* Fix source maps not tracking end of node locations. * 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. * Use static super references as the home object is actually done at definition time.
* **Polish** * **Polish**
* Force the `es6.destructuring` transformer to be whitelisted when the `es7.objectSpread` transformer is. * Force the `es6.destructuring` transformer to be whitelisted when the `es7.objectSpread` transformer is.
@ -479,7 +479,7 @@
## 2.12.3 ## 2.12.3
* **Spec Compliancy** * **Spec Compliance**
* Optional `typeof` transformer checks for `undefined` before passing it to the helper. * Optional `typeof` transformer checks for `undefined` before passing it to the helper.
* Class methods are now named. * Class methods are now named.
@ -551,7 +551,7 @@
* Add `classesFastSuper` optional transformer that doesn't support parent getters and prototype changing. * 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 `forOfFast` transformer that speeds up `for...of` on arrays but produces more code.
* Add `--react-compat` to `bin/6to5`. * Add `--react-compat` to `bin/6to5`.
* **Spec Compliancy** * **Spec Compliance**
* Disallow setters without a single parameter. * Disallow setters without a single parameter.
* Add `configurable` and `writable` to defined properties. * Add `configurable` and `writable` to defined properties.
* Use define instead of assignment for class methods. * Use define instead of assignment for class methods.
@ -619,7 +619,7 @@
## 2.7.0 ## 2.7.0
* **Spec Compliancy** * **Spec Compliance**
* Disallow reassignments of imports. * Disallow reassignments of imports.
* **New Feature** * **New Feature**
* `reactCompat` option to enable pre-v0.12 react components. * `reactCompat` option to enable pre-v0.12 react components.
@ -662,7 +662,7 @@
* **Polish** * **Polish**
* Move `"use strict";` to inside module bodies instead of at the top of the file. * Move `"use strict";` to inside module bodies instead of at the top of the file.
* Better handling of dynamic imports. * Better handling of dynamic imports.
* **Spec Compliancy** * **Spec Compliance**
* Class inheritance now has a `function` or `null` type check. * Class inheritance now has a `function` or `null` type check.
* Add `interopRequireWildcard` around wildcard imports and exports to handle non-object exports. * 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. * Throw an error on different `babel` and `babel-runtime` versions.
* Replicate module environment for `babel-node` eval. * Replicate module environment for `babel-node` eval.
* Clean up classes output. * Clean up classes output.
* **Spec Compliancy** * **Spec Compliance**
* Make it illegal to use a rest parameter on a setter. * Make it illegal to use a rest parameter on a setter.
## 4.6.6 ## 4.6.6
@ -150,8 +150,8 @@
* **New Feature** * **New Feature**
* Desugar sticky regexes to a new constructor expression so it can be handled by a polyfill. * Desugar sticky regexes to a new constructor expression so it can be handled by a polyfill.
* **Spec Compliancy** * **Spec Compliance**
* `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. * `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** * **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)! * 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. * `$ babel` no longer exits on syntax errors.

View File

@ -12,7 +12,7 @@
## 5.8.24 ## 5.8.24
* **Spec Compliancy** * **Spec Compliance**
* Updated `optimisation.react.inlineElements` transformer to React 0.14 output. Thanks [@spicyj](https://github.com/spicyj)! * Updated `optimisation.react.inlineElements` transformer to React 0.14 output. Thanks [@spicyj](https://github.com/spicyj)!
* **Polish** * **Polish**
* Add support for evaluating more static nodes. Thanks [@hzoo](https://github.com/hzoo)! * 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) ![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. * Allow trailing param commas for methods when using the `es7.trailingCommas` transformer.
* **Bug Fix** * **Bug Fix**
* Fix `es6.blockScoping` transformer not properly ignoring `break` in `SwitchCase`. * 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 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 incorrect extensions reference causing weird issues when using the Babel CLI.
* Fix destructuring param reference replacements not inheriting from their original param. * Fix destructuring param reference replacements not inheriting from their original param.
* **Spec Compliancy** * **Spec Compliance**
* Fix order that method decorators are ran in. * Fix order that method decorators are ran in.
## 5.2.15 ## 5.2.15
@ -616,7 +616,7 @@ Issues with publish process.
* Fix `externalHelpers` option being incorrectly listed as type `string`. * Fix `externalHelpers` option being incorrectly listed as type `string`.
* **Internal** * **Internal**
* Upgrade `core-js` to `0.9.0`. * Upgrade `core-js` to `0.9.0`.
* **Spec Compliancy** * **Spec Compliance**
* Fix object decorators not using the `initializer` pattern. * Fix object decorators not using the `initializer` pattern.
* Remove property initializer descriptor reflection. * 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) > 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. > 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` * `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)) * [#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) ## v6.17.0 (2016-10-01)
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-preset-stage-2`, `babel-preset-stage-3` * `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)) * [#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 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 ```js
// async generator syntax // async generator syntax
@ -1569,7 +1569,7 @@ First PR!
Babel 6.16: Happy 2nd Birthday 🎂! 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`, ... * `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)) * [#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` * `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)) * [#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` * `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)) * [#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` * `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)) * [#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` * `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)) * [#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. - Reverting the class properties semicolon parser error.
- Fix regression with plugin ordering with `babel-register`. - Fix regression with plugin ordering with `babel-register`.
#### Spec Compliancy #### Spec Compliance
* `babel-plugin-transform-class-properties`, `babylon` * `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)) * [#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-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 * `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)). * `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** * **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. * 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 `buildExternalHelpers` script ignoring non-underscored helpers.
* Fix exported classes with static class properties. * Fix exported classes with static class properties.
* **Spec Compliancy** * **Spec Compliance**
* Add support for computed mutators in `babel-plugin-transform-es2015-computed-properties`. * Add support for computed mutators in `babel-plugin-transform-es2015-computed-properties`.
* **Polish** * **Polish**
* Make interop for plugins with the `__esModule` work for all plugins no matter how they're imported/specified. * 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** * **Polish**
* Add npm 3 check to `babel-doctor`. * Add npm 3 check to `babel-doctor`.
* Autoclear the `babel/register` cache when it gets too big to be serialised. * Autoclear the `babel/register` cache when it gets too big to be serialised.
* **Spec Compliancy** * **Spec Compliance**
* Add support for flow existential type parameters. * Add support for flow existential type parameters.
## 6.1.1 ## 6.1.1
@ -3969,7 +3969,7 @@ Thanks to @samwgoldman for all the new flow support!
## 6.0.14 ## 6.0.14
* **Spec Compliancy** * **Spec Compliance**
* Update exponentiation operator precedence. * Update exponentiation operator precedence.
* Fix parser bug where arrow functions have a higher precedence than they should. * Fix parser bug where arrow functions have a higher precedence than they should.
* **Bug Fix** * **Bug Fix**

View File

@ -2,6 +2,8 @@
Before making a PR, please read our contributing guidelines Before making a PR, please read our contributing guidelines
https://github.com/babel/babel/blob/master/CONTRIBUTING.md 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) 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 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 👍) --> | 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? | | Patch: Bug Fix? |
| Major: Breaking Change? | | Major: Breaking Change? |
| Minor: New Feature? | | 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);
}

2
.github/lock.yml vendored
View File

@ -4,7 +4,7 @@
daysUntilLock: 91 daysUntilLock: 91
# Comment to post before locking. Set to `false` to disable # Comment to post before locking. Set to `false` to disable
lockComment: false lockComment: false
only: issues # The label to be applied when an issue is locked
lockLabel: 'outdated' lockLabel: 'outdated'
# Issues or pull requests with these labels will not be locked # Issues or pull requests with these labels will not be locked

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

2
.gitignore vendored
View File

@ -35,7 +35,7 @@ package-lock.json
!/packages/babel-runtime-corejs2/helpers/temporalRef.js !/packages/babel-runtime-corejs2/helpers/temporalRef.js
/packages/babel-runtime-corejs2/helpers/esm/*.js /packages/babel-runtime-corejs2/helpers/esm/*.js
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js !/packages/babel-runtime-corejs2/helpers/esm/toArray.js
!/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js /packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js !/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
/packages/babel-runtime-corejs2/core-js/**/*.js /packages/babel-runtime-corejs2/core-js/**/*.js
!/packages/babel-runtime-corejs2/core-js/map.js !/packages/babel-runtime-corejs2/core-js/map.js

View File

@ -3,41 +3,43 @@ git:
language: node_js language: node_js
cache: cache:
yarn: true yarn: true
node_js:
# We test the latest version on circleci os: linux
- '11'
- '10'
- '8'
- '6'
env: env:
global: global:
- PATH=$HOME/.yarn/bin:$PATH - PATH=$HOME/.yarn/bin:$PATH
- JOB=test - JOB=test
before_install: install: skip
- curl -o- -L https://yarnpkg.com/install.sh | bash
install:
# the `make test-ci` script runs this command already
- if [ "$JOB" != "test" ] && [ "$JOB" != "lint" ]; then yarn install; fi
- if [ "$JOB" = "lint" ]; then make bootstrap; fi
before_script: before_script:
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi - curl -o- -L https://yarnpkg.com/install.sh | bash
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi - if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install make; fi
script: script:
- if [ "$JOB" = "test" ]; then make test-ci; fi - if [ "$JOB" = "test" ]; then make -j test-ci; fi
- if [ "$JOB" = "lint" ]; then make lint && make flow; fi - if [ "$JOB" = "lint" ]; then make -j code-quality-ci; fi
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi - if [ "$JOB" = "babel-parser-flow-tests" ]; then make -j test-flow-ci; fi
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi - if [ "$JOB" = "babel-parser-test262-tests" ]; then make -j test-test262-ci; fi
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
- node_js: "node" - node_js: "node"
env: JOB=lint env: JOB=lint
# We test the latest version on circleci
- node_js: "12"
# Move `windows` build to be the third since it is slow
- os: windows
node_js: "node"
env:
- JOB=test
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9
- YARN_GPG=no
# Continue node_js matrix
- node_js: "6"
- node_js: "10"
- node_js: "8"
- node_js: "node" - node_js: "node"
env: JOB=babel-parser-flow-tests env: JOB=babel-parser-flow-tests
- node_js: "node" - node_js: "node"

View File

@ -2,7 +2,7 @@
> **Tags:** > **Tags:**
> - :boom: [Breaking Change] > - :boom: [Breaking Change]
> - :eyeglasses: [Spec Compliancy] > - :eyeglasses: [Spec Compliance]
> - :rocket: [New Feature] > - :rocket: [New Feature]
> - :bug: [Bug Fix] > - :bug: [Bug Fix]
> - :memo: [Documentation] > - :memo: [Documentation]
@ -17,6 +17,372 @@ 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 --> <!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
<!-- insert-new-changelog-here --> <!-- insert-new-changelog-here -->
## v7.7.3 (2019-11-08)
#### :bug: Bug Fix
* `babel-parser`
* [#10682](https://github.com/babel/babel/pull/10682) Don't recover from "adjacent jsx elements" parser error ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.7.2 (2019-11-07)
#### :bug: Bug Fix
* `babel-parser`
* [#10669](https://github.com/babel/babel/pull/10669) Parse arrows with params annotations in conditional expressions ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-typescript`
* [#10658](https://github.com/babel/babel/pull/10658) fix: remove accessibility of constructor ([@JLHwung](https://github.com/JLHwung))
* `babel-traverse`
* [#10656](https://github.com/babel/babel/pull/10656) fix: add inList setter for compatibility with babel-minify ([@JLHwung](https://github.com/JLHwung))
## v7.7.1 (2019-11-05)
#### :bug: Bug Fix
* `babel-types`
* [#10650](https://github.com/babel/babel/pull/10650) Revert "throw a TypeError if identifier validation fails (#10621)" ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-preset-env`
* [#10649](https://github.com/babel/babel/pull/10649) Fix(babel-preset-env): check api.caller is a function to avoid to thr… ([@love2me](https://github.com/love2me))
## v7.7.0 (2019-11-05)
#### :eyeglasses: Spec Compliance
* `babel-types`
* [#10621](https://github.com/babel/babel/pull/10621) throw a TypeError if identifier validation fails. ([@dentrado](https://github.com/dentrado))
* `babel-parser`
* [#10559](https://github.com/babel/babel/pull/10559) fix: Exclude catch clause from let identifier error. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
* [#10567](https://github.com/babel/babel/pull/10567) [parser] Exception to 8 and 9 in tagged template. ([@pnowak](https://github.com/pnowak))
* [#10532](https://github.com/babel/babel/pull/10532) Allow duplicate __proto__ keys in patterns, simple case (#6705). ([@alejo90](https://github.com/alejo90))
#### :rocket: New Feature
* `babel-generator`, `babel-helper-create-class-features-plugin`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-preset-typescript`, `babel-types`
* [#10545](https://github.com/babel/babel/pull/10545) Add support for TS declare modifier on fields. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-core`, `babel-parser`, `babel-preset-typescript`
* [#10363](https://github.com/babel/babel/pull/10363) @babel/parser error recovery. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-core`
* [#10599](https://github.com/babel/babel/pull/10599) Add support for .cjs config files. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10501](https://github.com/babel/babel/pull/10501) Add support for babel.config.json. ([@devongovett](https://github.com/devongovett))
* [#10361](https://github.com/babel/babel/pull/10361) feat: if code frame error is on a single line, highlight the whole path. ([@SimenB](https://github.com/SimenB))
* `babel-plugin-syntax-top-level-await`, `babel-preset-env`
* [#10573](https://github.com/babel/babel/pull/10573) Create @babel/plugin-syntax-top-level-await. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helper-builder-react-jsx`, `babel-plugin-transform-react-jsx`, `babel-preset-react`
* [#10572](https://github.com/babel/babel/pull/10572) [transform-react-jsx] Add useSpread option to transform JSX. ([@ivandevp](https://github.com/ivandevp))
* `babel-generator`, `babel-parser`, `babel-plugin-proposal-decorators`, `babel-plugin-syntax-flow`, `babel-types`
* [#10344](https://github.com/babel/babel/pull/10344) Flow enums parsing. ([@gkz](https://github.com/gkz))
* `babel-plugin-transform-function-name`, `babel-plugin-transform-modules-umd`, `babel-preset-env`
* [#10477](https://github.com/babel/babel/pull/10477) Changes UMD callsite to be more likely to pass in the intended object.. ([@MicahZoltu](https://github.com/MicahZoltu))
* `babel-parser`
* [#10449](https://github.com/babel/babel/pull/10449) Create parser plugin "topLevelAwait". ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10521](https://github.com/babel/babel/pull/10521) [parser] Enable "exportNamespaceFrom" by default. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10483](https://github.com/babel/babel/pull/10483) [parser] Add support for private fields in TypeScript. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-generator`, `babel-parser`, `babel-types`
* [#10543](https://github.com/babel/babel/pull/10543) add assertions signature for TypeScript. ([@tanhauhau](https://github.com/tanhauhau))
* `babel-cli`, `babel-register`
* [#8622](https://github.com/babel/babel/pull/8622) Make dir for babel --out-file. ([@TrySound](https://github.com/TrySound))
* `babel-cli`
* [#10399](https://github.com/babel/babel/pull/10399) Closes [#8326](https://github.com/babel/babel/issues/8326), add back --quiet option.. ([@chris-peng-1244](https://github.com/chris-peng-1244))
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-proposal-async-generator-functions`, `babel-plugin-proposal-function-sent`, `babel-preset-env`
* [#10422](https://github.com/babel/babel/pull/10422) Correctly delegate .return() in async generator. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helper-module-transforms`, `babel-plugin-transform-modules-commonjs`
* [#10628](https://github.com/babel/babel/pull/10628) Don't throw when destructuring into a var named as an import. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-modules-systemjs`
* [#10638](https://github.com/babel/babel/pull/10638) fix: remove ExportNamedDeclaration when the specifier is empty. ([@JLHwung](https://github.com/JLHwung))
* `babel-parser`
* [#10631](https://github.com/babel/babel/pull/10631) [TS] Parse calls with type args in optional chains. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10607](https://github.com/babel/babel/pull/10607) fixed missing errors on assignment pattern in object expression. ([@vivek12345](https://github.com/vivek12345))
* [#10594](https://github.com/babel/babel/pull/10594) [parser] Parse only modifiers of actual methods. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
* `babel-plugin-transform-typescript`
* [#10555](https://github.com/babel/babel/pull/10555) [TS] Correctly transform computed strings and templates in enums. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-core`
* [#10623](https://github.com/babel/babel/pull/10623) Fix: inputSourceMap should work when it is an external file. ([@JLHwung](https://github.com/JLHwung))
* [#10539](https://github.com/babel/babel/pull/10539) fix: remove filename annotation in buildCodeFrameError. ([@JLHwung](https://github.com/JLHwung))
* `babel-plugin-proposal-decorators`
* [#10578](https://github.com/babel/babel/pull/10578) [decorators] fix: support string literal properties. ([@mwhitworth](https://github.com/mwhitworth))
* `babel-helpers`, `babel-plugin-proposal-dynamic-import`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
* [#10574](https://github.com/babel/babel/pull/10574) fix: _interopRequireWildcard should only cache objects. ([@samMeow](https://github.com/samMeow))
* `babel-traverse`
* [#9777](https://github.com/babel/babel/pull/9777) [traverse] Allow skipping nodes inserted with .replaceWith(). ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-preset-env`
* [#10146](https://github.com/babel/babel/pull/10146) Inject core-js@3 imports in Program:exit instead of on post(). ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-generator`
* [#10519](https://github.com/babel/babel/pull/10519) Fix generator missing parens around an arrow returning function type. ([@existentialism](https://github.com/existentialism))
* `babel-plugin-transform-async-to-generator`, `babel-preset-env`, `babel-traverse`
* [#9939](https://github.com/babel/babel/pull/9939) Don't use args rest/spread to hoist super method calls. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :nail_care: Polish
* `babel-plugin-transform-classes`, `babel-plugin-transform-regenerator`, `babel-preset-env`
* [#9481](https://github.com/babel/babel/pull/9481) [preset-env] Don't use async-to-generator when already using regenerator. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helpers`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
* [#10585](https://github.com/babel/babel/pull/10585) fix(babelhelpers/interopRequireWildcard): Avoid double nullish check. ([@ExE-Boss](https://github.com/ExE-Boss))
* `babel-register`
* [#10557](https://github.com/babel/babel/pull/10557) fix: disable caching when babel could not read/write cache. ([@JLHwung](https://github.com/JLHwung))
#### :house: Internal
* `babel-cli`, `babel-node`
* [#10619](https://github.com/babel/babel/pull/10619) chore: remove output-file-sync dependency. ([@JLHwung](https://github.com/JLHwung))
* `babel-register`
* [#10614](https://github.com/babel/babel/pull/10614) chore: bump source-map-support to 0.5.14. ([@JLHwung](https://github.com/JLHwung))
* `babel-helper-create-regexp-features-plugin`, `babel-plugin-proposal-unicode-property-regex`, `babel-plugin-transform-dotall-regex`, `babel-plugin-transform-named-capturing-groups-regex`, `babel-plugin-transform-unicode-regex`, `babel-preset-env`
* [#10447](https://github.com/babel/babel/pull/10447) Merge multiple regex transform plugin. ([@JLHwung](https://github.com/JLHwung))
* `babel-preset-env`
* [#10612](https://github.com/babel/babel/pull/10612) chore: update web.immediate support fixtures. ([@JLHwung](https://github.com/JLHwung))
* `babel-helper-module-imports`
* [#10608](https://github.com/babel/babel/pull/10608) Use .find instead of .filter to get targetPath in ImportInjector. ([@Andarist](https://github.com/Andarist))
* Other
* [#10600](https://github.com/babel/babel/pull/10600) Test node@13 on circle. ([@existentialism](https://github.com/existentialism))
* [#10593](https://github.com/babel/babel/pull/10593) chore: replace outdated travis-ci.org badges [ci skip]. ([@JLHwung](https://github.com/JLHwung))
* [#10591](https://github.com/babel/babel/pull/10591) chore: test against Node.js 13. ([@JLHwung](https://github.com/JLHwung))
* [#10556](https://github.com/babel/babel/pull/10556) Add master branch workflow for test262 tests. ([@jbhoosreddy](https://github.com/jbhoosreddy))
* [#10553](https://github.com/babel/babel/pull/10553) chore: introduce envinfo into environment section. ([@JLHwung](https://github.com/JLHwung))
* `babel-runtime`
* [#10418](https://github.com/babel/babel/pull/10418) docs: add homepage link. ([@DanArthurGallagher](https://github.com/DanArthurGallagher))
* `babel-helper-annotate-as-pure`, `babel-helper-bindify-decorators`, `babel-helper-builder-binary-assignment-operator-visitor`, `babel-helper-builder-react-jsx`, `babel-helper-call-delegate`, `babel-helper-define-map`, `babel-helper-explode-assignable-expression`, `babel-helper-explode-class`, `babel-helper-function-name`, `babel-helper-get-function-arity`, `babel-helper-hoist-variables`, `babel-helper-member-expression-to-functions`, `babel-helper-module-imports`, `babel-helper-module-transforms`, `babel-helper-optimise-call-expression`, `babel-helper-remap-async-to-generator`, `babel-helper-replace-supers`, `babel-helper-simple-access`, `babel-helper-split-export-declaration`, `babel-helper-wrap-function`, `babel-helpers`, `babel-template`
* [#10568](https://github.com/babel/babel/pull/10568) Bump babel-types to ^7.6.3. ([@JLHwung](https://github.com/JLHwung))
#### :running_woman: Performance
* `babel-traverse`
* [#10480](https://github.com/babel/babel/pull/10480) Traverse performance. ([@JLHwung](https://github.com/JLHwung))
## v7.6.4 (2019-10-10)
#### :eyeglasses: Spec Compliance
* `babel-parser`
* [#10491](https://github.com/babel/babel/pull/10491) Trailing comma after rest - The final fix ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :bug: Bug Fix
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-transform-fixture-test-runner`
* [#10536](https://github.com/babel/babel/pull/10536) Revert "chore: Upgrade source-map to 0.6.1 (#10446)" ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.6.3 (2019-10-08)
#### :eyeglasses: Spec Compliance
* `babel-parser`
* [#10469](https://github.com/babel/babel/pull/10469) Disallow await inside async arrow params ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10493](https://github.com/babel/babel/pull/10493) [parser] Disallow numeric separators in legacy octal like integers ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
#### :rocket: New Feature
* `babel-types`
* [#10504](https://github.com/babel/babel/pull/10504) Add declarations for more of @babel/types exports ([@Jessidhia](https://github.com/Jessidhia))
#### :bug: Bug Fix
* `babel-plugin-transform-block-scoping`
* [#10343](https://github.com/babel/babel/pull/10343) Do not remove let bindings even they are wrapped in closure ([@JLHwung](https://github.com/JLHwung))
* `babel-parser`
* [#10119](https://github.com/babel/babel/pull/10119) add scope to TSModuleDeclaration ([@tanhauhau](https://github.com/tanhauhau))
* [#10332](https://github.com/babel/babel/pull/10332) Do not allow member expressions to start async arrows ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10490](https://github.com/babel/babel/pull/10490) [parser] Don't crash on comment after trailing comma after elision ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-react-constant-elements`, `babel-traverse`
* [#10529](https://github.com/babel/babel/pull/10529) Do not hoist jsx referencing a mutable binding ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-generator`, `babel-parser`, `babel-plugin-transform-block-scoping`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-plugin-transform-typescript`
* [#10220](https://github.com/babel/babel/pull/10220) Flow: interface identifier should be declared in the scope ([@JLHwung](https://github.com/JLHwung))
#### :nail_care: Polish
* `babel-core`
* [#10419](https://github.com/babel/babel/pull/10419) assertNoDuplicates throw with more context ([@hjdivad](https://github.com/hjdivad))
* [#10511](https://github.com/babel/babel/pull/10511) Add filename to transform error ([@JLHwung](https://github.com/JLHwung))
#### :house: Internal
* Other
* [#10506](https://github.com/babel/babel/pull/10506) Use `make -j` for parallel build ([@JLHwung](https://github.com/JLHwung))
* [#10443](https://github.com/babel/babel/pull/10443) perf: only apply lazy cjs module transform on cli and core ([@JLHwung](https://github.com/JLHwung))
* [#10494](https://github.com/babel/babel/pull/10494) Enable optional chaining and nullish coalescing plugins ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-node`, `babel-plugin-transform-react-jsx-source`, `babel-plugin-transform-runtime`, `babel-preset-env`, `babel-preset-react`
* [#10249](https://github.com/babel/babel/pull/10249) Add windows to travis ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :running_woman: Performance
* `babel-parser`
* [#10371](https://github.com/babel/babel/pull/10371) perf: replace lookahead by lookaheadCharCode ([@JLHwung](https://github.com/JLHwung))
* Other
* [#10443](https://github.com/babel/babel/pull/10443) perf: only apply lazy cjs module transform on cli and core ([@JLHwung](https://github.com/JLHwung))
## v7.6.2 (2019-09-23)
#### :eyeglasses: Spec Compliance
* `babel-parser`
* [#10472](https://github.com/babel/babel/pull/10472) added check to disallow super.private variable access and test case added. ([@vivek12345](https://github.com/vivek12345))
* [#10468](https://github.com/babel/babel/pull/10468) [parser] Disallow numeric separator in unicode scape sequences. ([@ivandevp](https://github.com/ivandevp))
* [#10467](https://github.com/babel/babel/pull/10467) [parser] Invalid NonOctal Decimal. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
* [#10461](https://github.com/babel/babel/pull/10461) [parser] Disallow static fields named `constructor`. ([@guywaldman](https://github.com/guywaldman))
* [#10455](https://github.com/babel/babel/pull/10455) [parser] Report escapes in kws only if they won't be used as identifiers. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :bug: Bug Fix
* `babel-parser`
* [#10445](https://github.com/babel/babel/pull/10445) Leave trailing comments after handling a possible trailing comma. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-cli`
* [#10400](https://github.com/babel/babel/pull/10400) fix: allow the process to exit naturally. ([@JLHwung](https://github.com/JLHwung))
* `babel-core`
* [#10402](https://github.com/babel/babel/pull/10402) fix: pass optionLoc when validating plugin object. ([@JLHwung](https://github.com/JLHwung))
* `babel-plugin-transform-block-scoping`, `babel-plugin-transform-spread`, `babel-traverse`
* [#10417](https://github.com/babel/babel/pull/10417) Do not guess relative execution status for exported fns. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10275](https://github.com/babel/babel/pull/10275) fix object rest in array pattern. ([@tanhauhau](https://github.com/tanhauhau))
#### :house: Internal
* `babel-plugin-transform-named-capturing-groups-regex`
* [#10430](https://github.com/babel/babel/pull/10430) refactor: replace regexp-tree by regexpu. ([@JLHwung](https://github.com/JLHwung))
* Other
* [#10441](https://github.com/babel/babel/pull/10441) Update GitHub actions to v2. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* [#10427](https://github.com/babel/babel/pull/10427) chore: add lint-ts rule. ([@JLHwung](https://github.com/JLHwung))
* `babel-helper-fixtures`
* [#10428](https://github.com/babel/babel/pull/10428) chore: remove tryResolve dependency. ([@JLHwung](https://github.com/JLHwung))
* `babel-node`
* [#10429](https://github.com/babel/babel/pull/10429) Remove babel polyfill dependency of babel-node. ([@bdwain](https://github.com/bdwain))
* `babel-generator`, `babel-helper-fixtures`
* [#10420](https://github.com/babel/babel/pull/10420) chore: remove trim-right dependency. ([@JLHwung](https://github.com/JLHwung))
* `babel-core`, `babel-plugin-transform-runtime`, `babel-register`
* [#10405](https://github.com/babel/babel/pull/10405) Remove circular dependency. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
#### :running_woman: Performance
* `babel-parser`
* [#10421](https://github.com/babel/babel/pull/10421) Miscellaneous perf tweak. ([@JLHwung](https://github.com/JLHwung))
## 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
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10180](https://github.com/babel/babel/pull/10180) [_objectSpread2] Do not use hoisted var from prev iteration ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
## v7.5.2 (2019-07-08)
#### :bug: Bug Fix
* `babel-plugin-transform-typescript`
* [#10174](https://github.com/babel/babel/pull/10174) Do not trust Scope when removing TypeScript types ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
* [#10171](https://github.com/babel/babel/pull/10171) Don't rely on getOwnPropertyDescriptors in objectSpread2 ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-proposal-export-default-from`, `babel-plugin-proposal-export-namespace-from`
* [#10172](https://github.com/babel/babel/pull/10172) fix: register injected importDeclaration ([@JLHwung](https://github.com/JLHwung))
## v7.5.1 (2019-07-06)
#### :bug: Bug Fix
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`
* [#10170](https://github.com/babel/babel/pull/10170) Fix objectSpread2 backward compatibility ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
* `babel-plugin-transform-typescript`
* [#10167](https://github.com/babel/babel/pull/10167) Retain typescript export-from-source ([@Wolvereness](https://github.com/Wolvereness))
## v7.5.0 (2019-07-04) ## v7.5.0 (2019-07-04)
@ -331,7 +697,7 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
## v7.3.3 (2019-02-15) ## v7.3.3 (2019-02-15)
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-generator` * `babel-generator`
* [#9501](https://github.com/babel/babel/pull/9501) Correctly output escapes in directives ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) * [#9501](https://github.com/babel/babel/pull/9501) Correctly output escapes in directives ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
@ -353,11 +719,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)) * [#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) ## 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! Thanks @gverni, @naffiq, @spondbob and @dstaley for their first PRs!
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-parser` * `babel-parser`
* [#9403](https://github.com/babel/babel/pull/9403) Fix line continuation with Unicode line terminators. ([@danez](https://github.com/danez)) * [#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)) * [#9400](https://github.com/babel/babel/pull/9400) Make yield a contextual keyword. ([@danez](https://github.com/danez))
@ -405,7 +771,7 @@ This release fixes some regressions introduced in v7.3.0
Thanks to @jamesgeorge007 and @armano2 for their first PR! Thanks to @jamesgeorge007 and @armano2 for their first PR!
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-parser` * `babel-parser`
* [#9314](https://github.com/babel/babel/pull/9314) Disallow async functions as loop body. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo)) * [#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)) * [#9315](https://github.com/babel/babel/pull/9315) Parse class heritage as strict mode code. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
@ -626,7 +992,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) ## v7.1.5 (2018-11-06)
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-parser`, `babylon` * `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)) * [#7727](https://github.com/babel/babel/pull/7727) Fix await in function name and parameters. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
@ -1089,7 +1455,7 @@ Fixed a peerDep issue
Mostly bug fixes and some decorator updates Mostly bug fixes and some decorator updates
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-plugin-proposal-unicode-property-regex` * `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)) * [#8127](https://github.com/babel/babel/pull/8127) Update plugin-proposal-unicode-property-regex for Unicode v11. ([@mathiasbynens](https://github.com/mathiasbynens))
* `babel-parser` * `babel-parser`
@ -1189,7 +1555,7 @@ Mostly bugfix release for a regression in decorators, and a quick fix for some n
- Fix IE10 class regression - Fix IE10 class regression
- Various fixes, many TS fixes - 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` * `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)) * [#7985](https://github.com/babel/babel/pull/7985) Subsume json. ([@jridgewell](https://github.com/jridgewell))
@ -1379,7 +1745,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` * `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)) * [#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` * `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)) * [#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` * `babel-core`, `babel-generator`, `babel-plugin-proposal-decorators`, `babel-types`, `babylon`
@ -1467,7 +1833,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). 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` * `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)) * [#7604](https://github.com/babel/babel/pull/7604) Logical Assignment: ensure computed key isn't recomputed. ([@jridgewell](https://github.com/jridgewell))
@ -1566,7 +1932,7 @@ We'll need to update tooling for this ^. Also published `gulp-babel@8.0.0-beta.2
* `babel-register` * `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)) * [#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` * `babylon`
* [#7503](https://github.com/babel/babel/pull/7503) Update test262 test script and a few keyword escape fixes. ([@existentialism](https://github.com/existentialism)) * [#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)) * [#7498](https://github.com/babel/babel/pull/7498) Disallow setters to have RestElement. ([@danez](https://github.com/danez))
@ -1714,7 +2080,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) ## v7.0.0-beta.39 (2018-01-30)
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-plugin-proposal-optional-chaining` * `babel-plugin-proposal-optional-chaining`
* [#6345](https://github.com/babel/babel/pull/6345) Remove old optional chain features. ([@jridgewell](https://github.com/jridgewell)) * [#6345](https://github.com/babel/babel/pull/6345) Remove old optional chain features. ([@jridgewell](https://github.com/jridgewell))
@ -1927,7 +2293,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` Various bug fixes, first version of Babel to use the MIT version of `regenerator`
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babylon` * `babylon`
* [#6986](https://github.com/babel/babel/pull/6986) Fix destructuring assignment spec violation. ([@ksashikumar](https://github.com/ksashikumar)) * [#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` * `babel-helper-replace-supers`, `babel-helpers`, `babel-plugin-proposal-class-properties`, `babel-plugin-transform-classes`, `babel-plugin-transform-parameters`
@ -1980,7 +2346,7 @@ Various bug fixes, first version of Babel to use the MIT version of `regenerator
* `babel-preset-stage-1`, `babel-preset-stage-2` * `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)) * [#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` * `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)) * [#6943](https://github.com/babel/babel/pull/6943) Moving Do expression to stage 1. ([@rajzshkr](https://github.com/rajzshkr))
@ -1994,7 +2360,7 @@ Various bug fixes, first version of Babel to use the MIT version of `regenerator
## v7.0.0-beta.33 (2017-12-01) ## 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` * `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)) * [#6920](https://github.com/babel/babel/pull/6920) Split exportExtensions into exportDefault and exportNamespace plugins…. ([@existentialism](https://github.com/existentialism))
* `babylon` * `babylon`
@ -2179,7 +2545,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"` > 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` * `babel-plugin-transform-optional-chaining`
* [#6525](https://github.com/babel/babel/pull/6525) Optional Chaining: Account for document.all. ([@azz](https://github.com/azz)) * [#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` * `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`
@ -2459,7 +2825,7 @@ let {...{}} = {}; let {...[]} = {};
- Add `--config-file` CLI flag to explicitly pass a config location - 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`) - 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-*` * `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)) * [#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` * `babel-helpers`, `babel-plugin-transform-es2015-computed-properties`
@ -2595,7 +2961,7 @@ Initial release of typescript equivalent of how Babel handles flow with a new `b
## v7.0.0-alpha.18 (2017-08-03) ## 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` * `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)) * [#5990](https://github.com/babel/babel/pull/5990) Flow opaque type aliases. ([@jbrown215](https://github.com/jbrown215))
* `babel-preset-stage-3` * `babel-preset-stage-3`
@ -2644,9 +3010,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` - Optional catch binding `try {} catch {}`: `babel-plugin-transform-optional-catch-binding`
- es2015-parameters `loose` mode that doesn't use `arguments` - es2015-parameters `loose` mode that doesn't use `arguments`
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-plugin-check-es2015-constants` * `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. > Instead of throwing a compile time error when const is violated, Babel should insert a throw statement before the violation.
@ -2951,7 +3317,7 @@ var A = function A() {
## v7.0.0-alpha.12 (2017-05-31) ## 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` * `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)) * [#5793](https://github.com/babel/babel/pull/5793) Support for NumericLiteralSeparator, Stage 1 feature. ([@rwaldron](https://github.com/rwaldron))
@ -2992,7 +3358,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 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` * `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)) * [#5525](https://github.com/babel/babel/pull/5525) Add support for object type spread. ([@conartist6](https://github.com/conartist6))
@ -3066,7 +3432,7 @@ Update Babylon: https://github.com/babel/babylon/releases/tag/v7.0.0-beta.9, htt
## v7.0.0-alpha.8 (2017-04-17) ## v7.0.0-alpha.8 (2017-04-17)
#### :eyeglasses: Spec Compliancy #### :eyeglasses: Spec Compliance
* `babel-preset-stage-2`, `babel-preset-stage-3` * `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)) * [#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/) - 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). 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) - 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 ## Chat

View File

@ -11,25 +11,20 @@ const filter = require("gulp-filter");
const gulp = require("gulp"); const gulp = require("gulp");
const path = require("path"); const path = require("path");
const webpack = require("webpack"); const webpack = require("webpack");
const merge = require("merge-stream");
const rollup = require("rollup"); const rollup = require("rollup");
const rollupBabel = require("rollup-plugin-babel"); const rollupBabel = require("rollup-plugin-babel");
const rollupNodeResolve = require("rollup-plugin-node-resolve"); const rollupNodeResolve = require("rollup-plugin-node-resolve");
const rollupReplace = require("rollup-plugin-replace"); const rollupReplace = require("rollup-plugin-replace");
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks"); const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");
const sources = ["codemods", "packages"]; const defaultSourcesGlob = "./@(codemods|packages)/*/src/**/*.js";
function swapSrcWithLib(srcPath) { function swapSrcWithLib(srcPath) {
const parts = srcPath.split(path.sep); const parts = srcPath.split(path.sep);
parts[1] = "lib"; parts[2] = "lib";
return parts.join(path.sep); return parts.join(path.sep);
} }
function getGlobFromSource(source) {
return `./${source}/*/src/**/*.js`;
}
function getIndexFromPackage(name) { function getIndexFromPackage(name) {
return `${name}/src/index.js`; return `${name}/src/index.js`;
} }
@ -56,32 +51,28 @@ function rename(fn) {
}); });
} }
function buildBabel(exclude) { function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {
return merge( const base = __dirname;
sources.map(source => {
const base = path.join(__dirname, source);
let stream = gulp.src(getGlobFromSource(source), { base: base }); let stream = gulp.src(sourcesGlob, { base: __dirname });
if (exclude) { if (exclude) {
const filters = exclude.map(p => `!**/${p}/**`); const filters = exclude.map(p => `!**/${p}/**`);
filters.unshift("**"); filters.unshift("**");
stream = stream.pipe(filter(filters)); stream = stream.pipe(filter(filters));
} }
return stream return stream
.pipe(errorsLogger()) .pipe(errorsLogger())
.pipe(newer({ dest: base, map: swapSrcWithLib })) .pipe(newer({ dest: base, map: swapSrcWithLib }))
.pipe(compilationLogger()) .pipe(compilationLogger())
.pipe(babel()) .pipe(babel())
.pipe( .pipe(
// Passing 'file.relative' because newer() above uses a relative // Passing 'file.relative' because newer() above uses a relative
// path and this keeps it consistent. // path and this keeps it consistent.
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative))) rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
) )
.pipe(gulp.dest(base)); .pipe(gulp.dest(base));
})
);
} }
function buildRollup(packages) { function buildRollup(packages) {
@ -118,6 +109,9 @@ const bundles = ["packages/babel-parser"];
gulp.task("build-rollup", () => buildRollup(bundles)); gulp.task("build-rollup", () => buildRollup(bundles));
gulp.task("build-babel", () => buildBabel(/* exclude */ bundles)); gulp.task("build-babel", () => buildBabel(/* exclude */ bundles));
gulp.task("build-babel-types", () =>
buildBabel(/* exclude */ bundles, "packages/babel-types/src/**/*.js")
);
gulp.task("build", gulp.parallel("build-rollup", "build-babel")); gulp.task("build", gulp.parallel("build-rollup", "build-babel"));
gulp.task("default", gulp.series("build")); gulp.task("default", gulp.series("build"));
@ -128,7 +122,7 @@ gulp.task(
"watch", "watch",
gulp.series("build-no-bundle", function watch() { gulp.series("build-no-bundle", function watch() {
gulpWatch( gulpWatch(
sources.map(getGlobFromSource), defaultSourcesGlob,
{ debounceDelay: 200 }, { debounceDelay: 200 },
gulp.task("build-no-bundle") gulp.task("build-no-bundle")
); );

193
Makefile
View File

@ -1,6 +1,5 @@
MAKEFLAGS = -j1
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9 FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
TEST262_COMMIT = de567d3aa5de4eaa11e00131d26b9fe77997dfb0 TEST262_COMMIT = 8688c4ab79059c3097098605e69f1ee5eda6c409
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967 # Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
export FORCE_COLOR = true export FORCE_COLOR = true
@ -9,59 +8,110 @@ SOURCES = packages codemods
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
build: clean clean-lib build: build-bundle
./node_modules/.bin/gulp build
node ./packages/babel-standalone/scripts/generate.js
node ./packages/babel-types/scripts/generateTypeHelpers.js
# call build again as the generated files might need to be compiled again.
./node_modules/.bin/gulp build
# generate flow and typescript typings
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
ifneq ("$(BABEL_COVERAGE)", "true") ifneq ("$(BABEL_COVERAGE)", "true")
make build-standalone $(MAKE) build-standalone
make build-preset-env-standalone
endif endif
build-standalone: build-bundle: clean clean-lib
./node_modules/.bin/gulp build-babel-standalone yarn gulp build
$(MAKE) generate-standalone generate-type-helpers
# call build again as the generated files might need to be compiled again.
yarn gulp build
$(MAKE) build-typings
$(MAKE) build-dist
build-bundle-ci: bootstrap-only
$(MAKE) build-bundle
generate-standalone:
node packages/babel-standalone/scripts/generate.js
generate-type-helpers:
node packages/babel-types/scripts/generateTypeHelpers.js
build-typings: build-flow-typings build-typescript-typings
build-flow-typings:
node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
build-typescript-typings:
node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
build-standalone: build-babel-standalone build-preset-env-standalone
build-standalone-ci: build-bundle-ci
$(MAKE) build-standalone
build-babel-standalone:
yarn gulp build-babel-standalone
build-preset-env-standalone: build-preset-env-standalone:
./node_modules/.bin/gulp build-babel-preset-env-standalone yarn gulp build-babel-preset-env-standalone
prepublish-build-standalone: prepublish-build-standalone:
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-standalone BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-standalone
prepublish-build-preset-env-standalone: prepublish-build-preset-env-standalone:
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-preset-env-standalone BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-preset-env-standalone
build-dist: build build-dist: build-polyfill-dist build-plugin-transform-runtime-dist
build-polyfill-dist:
cd packages/babel-polyfill; \ cd packages/babel-polyfill; \
scripts/build-dist.sh scripts/build-dist.sh
build-plugin-transform-runtime-dist:
cd packages/babel-plugin-transform-runtime; \ cd packages/babel-plugin-transform-runtime; \
node scripts/build-dist.js node scripts/build-dist.js
watch: clean clean-lib build-no-bundle: clean clean-lib
BABEL_ENV=development yarn gulp build-no-bundle
# Ensure that build artifacts for types are created during local # Ensure that build artifacts for types are created during local
# development too. # development too.
BABEL_ENV=development ./node_modules/.bin/gulp build-no-bundle $(MAKE) generate-type-helpers
node ./packages/babel-types/scripts/generateTypeHelpers.js $(MAKE) build-typings
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts watch: build-no-bundle
BABEL_ENV=development ./node_modules/.bin/gulp watch BABEL_ENV=development yarn gulp watch
code-quality-ci: flowcheck-ci lint-ci
flowcheck-ci: bootstrap-flowcheck
$(MAKE) flow
code-quality: flow lint
flow: flow:
./node_modules/.bin/flow check --strip-root yarn flow check --strip-root
lint: bootstrap-flowcheck: bootstrap-only
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe yarn gulp build-babel-types
$(MAKE) build-typings
fix: fix-json lint-ci: lint-js-ci lint-ts-ci
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
lint-js-ci: bootstrap-only
$(MAKE) lint-js
lint-ts-ci: bootstrap-flowcheck
$(MAKE) lint-ts
lint: lint-js lint-ts
lint-js:
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe
lint-ts:
scripts/tests/typescript/lint.sh
fix: fix-json fix-js
fix-js:
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
fix-json: fix-json:
./node_modules/.bin/prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn yarn prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
clean: test-clean clean: test-clean
rm -f .npmrc rm -f .npmrc
@ -74,72 +124,80 @@ test-clean:
$(foreach source, $(SOURCES), \ $(foreach source, $(SOURCES), \
$(call clean-source-test, $(source))) $(call clean-source-test, $(source)))
# Does not work on Windows; use "yarn jest" instead
test-only: test-only:
BABEL_ENV=test ./scripts/test.sh BABEL_ENV=test ./scripts/test.sh
make test-clean $(MAKE) test-clean
test: lint test-only test: lint test-only
test-ci: bootstrap test-only test-ci: jest-ci
jest-ci: build-standalone-ci
BABEL_ENV=test yarn jest --maxWorkers=4 --ci
$(MAKE) test-clean
# Does not work on Windows
test-ci-coverage: SHELL:=/bin/bash test-ci-coverage: SHELL:=/bin/bash
test-ci-coverage: test-ci-coverage:
BABEL_COVERAGE=true BABEL_ENV=test make bootstrap BABEL_COVERAGE=true BABEL_ENV=test $(MAKE) bootstrap
BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
bootstrap-flow: bootstrap-flow:
rm -rf ./build/flow rm -rf build/flow
mkdir -p ./build mkdir -p build
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git ./build/flow git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git build/flow
cd build/flow && git checkout $(FLOW_COMMIT) cd build/flow && git checkout $(FLOW_COMMIT)
test-flow: test-flow:
node scripts/tests/flow/run_babel_parser_flow_tests.js node scripts/tests/flow/run_babel_parser_flow_tests.js
test-flow-ci: bootstrap test-flow test-flow-ci: build-bundle-ci bootstrap-flow
$(MAKE) test-flow
test-flow-update-whitelist: test-flow-update-whitelist:
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
bootstrap-test262: bootstrap-test262:
rm -rf ./build/test262 rm -rf build/test262
mkdir -p ./build mkdir -p build
git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git ./build/test262 git clone --branch=master --single-branch --shallow-since=2019-09-01 https://github.com/tc39/test262.git build/test262
cd build/test262 && git checkout $(TEST262_COMMIT) cd build/test262 && git checkout $(TEST262_COMMIT)
test-test262: test-test262:
node scripts/tests/test262/run_babel_parser_test262.js node scripts/tests/test262/run_babel_parser_test262.js
test-test262-ci: bootstrap test-test262 test-test262-ci: build-bundle-ci bootstrap-test262
$(MAKE) test-test262
test-test262-update-whitelist: test-test262-update-whitelist:
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
# Does not work on Windows
clone-license: clone-license:
./scripts/clone-license.sh ./scripts/clone-license.sh
prepublish-build: prepublish-build: clean-lib clean-runtime-helpers
make clean-lib NODE_ENV=production BABEL_ENV=production $(MAKE) build
rm -rf packages/babel-runtime/helpers $(MAKE) clone-license
rm -rf packages/babel-runtime-corejs2/helpers
rm -rf packages/babel-runtime-corejs2/core-js
NODE_ENV=production BABEL_ENV=production make build-dist
make clone-license
prepublish: prepublish:
make bootstrap-only $(MAKE) bootstrap-only
make prepublish-build $(MAKE) prepublish-build
make test $(MAKE) test
new-version: new-version:
git pull --rebase git pull --rebase
./node_modules/.bin/lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone" yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
publish-cerxes: prepublish
yarn lerna publish --registry="https://npm.cerxes.net" --force-publish --allow-branch initializers-fix --canary --preid csx --dist-tag csx
# NOTE: Run make new-version first # NOTE: Run make new-version first
publish: prepublish publish: prepublish
./node_modules/.bin/lerna publish from-git --require-scripts yarn lerna publish from-git
make clean $(MAKE) clean
publish-ci: prepublish publish-ci: prepublish
ifneq ("$(NPM_TOKEN)", "") ifneq ("$(NPM_TOKEN)", "")
@ -148,23 +206,30 @@ else
echo "Missing NPM_TOKEN env var" echo "Missing NPM_TOKEN env var"
exit 1 exit 1
endif endif
./node_modules/.bin/lerna publish from-git --require-scripts --yes yarn lerna publish from-git --yes
rm -f .npmrc rm -f .npmrc
make clean $(MAKE) clean
bootstrap-only: clean-all bootstrap-only: lerna-bootstrap
yarn-install: clean-all
yarn --ignore-engines yarn --ignore-engines
./node_modules/.bin/lerna bootstrap -- --ignore-engines
lerna-bootstrap: yarn-install
yarn lerna bootstrap
bootstrap: bootstrap-only bootstrap: bootstrap-only
make build $(MAKE) build
cd packages/babel-plugin-transform-runtime; \
node scripts/build-dist.js
clean-lib: clean-lib:
$(foreach source, $(SOURCES), \ $(foreach source, $(SOURCES), \
$(call clean-source-lib, $(source))) $(call clean-source-lib, $(source)))
clean-runtime-helpers:
rm -rf packages/babel-runtime/helpers
rm -rf packages/babel-runtime-corejs2/helpers
rm -rf packages/babel-runtime-corejs2/core-js
clean-all: clean-all:
rm -rf node_modules rm -rf node_modules
rm -rf package-lock.json rm -rf package-lock.json
@ -173,7 +238,7 @@ clean-all:
$(foreach source, $(SOURCES), \ $(foreach source, $(SOURCES), \
$(call clean-source-all, $(source))) $(call clean-source-all, $(source)))
make clean $(MAKE) clean
define clean-source-lib define clean-source-lib
rm -rf $(1)/*/lib rm -rf $(1)/*/lib

View File

@ -4,16 +4,23 @@
</a> </a>
</p> </p>
<p align="center">
<span style="color:darkred">
<b><i>WARNING</i> This is a fork of babel to test a fix for initializer-variables with class-properties (proposals-stuff)</b>
</span>
</p>
<p align="center"> <p align="center">
The compiler for writing next generation JavaScript. The compiler for writing next generation JavaScript.
</p> </p>
<p align="center"> <p align="center">
<a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a> <a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a>
<a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a> <a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a>
</p> </p>
<p align="center"> <p align="center">
<a href="https://travis-ci.org/babel/babel"><img alt="Travis Status" src="https://img.shields.io/travis/babel/babel/master.svg?label=travis&maxAge=43200"></a> <a href="https://travis-ci.com/babel/babel"><img alt="Travis Status" src="https://img.shields.io/travis/com/babel/babel/master.svg?label=travis&maxAge=43200"></a>
<a href="https://circleci.com/gh/babel/babel"><img alt="CircleCI Status" src="https://img.shields.io/circleci/project/github/babel/babel/master.svg?label=circle&maxAge=43200"></a> <a href="https://circleci.com/gh/babel/babel"><img alt="CircleCI Status" src="https://img.shields.io/circleci/project/github/babel/babel/master.svg?label=circle&maxAge=43200"></a>
<a href="https://codecov.io/github/babel/babel"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/babel/babel/master.svg?maxAge=43200"></a> <a href="https://codecov.io/github/babel/babel"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/babel/babel/master.svg?maxAge=43200"></a>
<a href="https://slack.babeljs.io/"><img alt="Slack Status" src="https://slack.babeljs.io/badge.svg"></a> <a href="https://slack.babeljs.io/"><img alt="Slack Status" src="https://slack.babeljs.io/badge.svg"></a>
@ -80,14 +87,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)! 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? ### 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! 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? ### 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). Check out our website: [babeljs.io](https://babeljs.io/), and report issues/features at [babel/website](https://github.com/babel/website/issues).
@ -98,12 +105,19 @@ Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) and fill out the issu
### Want to contribute to Babel? ### 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! - Our [#development](https://babeljs.slack.com/messages/development) Slack channel and say hi ([signup](https://slack.babeljs.io))!
- 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. - 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 discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
- Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals) - 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? ### How is the repo structured?

View File

@ -77,9 +77,10 @@ module.exports = function(api) {
"@babel/proposal-object-rest-spread", "@babel/proposal-object-rest-spread",
{ useBuiltIns: true, loose: true }, { useBuiltIns: true, loose: true },
], ],
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator",
// Explicitly use the lazy version of CommonJS modules. convertESM ? "@babel/transform-modules-commonjs" : null,
convertESM ? ["@babel/transform-modules-commonjs", { lazy: true }] : null,
].filter(Boolean), ].filter(Boolean),
overrides: [ overrides: [
{ {
@ -90,18 +91,17 @@ module.exports = function(api) {
], ],
}, },
{ {
test: "./packages/babel-register", test: ["./packages/babel-cli", "./packages/babel-core"],
plugins: [ plugins: [
// Override the root options to disable lazy imports for babel-register // Explicitly use the lazy version of CommonJS modules.
// because otherwise the require hook will try to lazy-import things convertESM
// leading to dependency cycles. ? ["@babel/transform-modules-commonjs", { lazy: true }]
convertESM ? "@babel/transform-modules-commonjs" : null, : null,
].filter(Boolean), ].filter(Boolean),
}, },
{ {
test: "./packages/babel-polyfill", test: "./packages/babel-polyfill",
presets: [["@babel/env", envOptsNoTargets]], presets: [["@babel/env", envOptsNoTargets]],
plugins: [["@babel/transform-modules-commonjs", { lazy: false }]],
}, },
{ {
// The vast majority of our src files are modules, but we use // The vast majority of our src files are modules, but we use

View File

@ -16,7 +16,7 @@
"@babel/plugin-syntax-object-rest-spread": "^7.0.0" "@babel/plugin-syntax-object-rest-spread": "^7.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0-0" "@babel/core": "^7.0.0-0 || csx"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0", "@babel/core": "^7.0.0",

View File

@ -16,7 +16,7 @@
"@babel/plugin-syntax-optional-catch-binding": "^7.0.0" "@babel/plugin-syntax-optional-catch-binding": "^7.0.0"
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": "^7.0.0-0" "@babel/core": "^7.0.0-0 || csx"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0", "@babel/core": "^7.0.0",

View File

@ -15,7 +15,7 @@ This is quite taboo but let's look at the pros and cons:
* Easy to coordinate changes across modules. * Easy to coordinate changes across modules.
* Single place to report issues. * Single place to report issues.
* Easier to setup a development environment. * Easier to setup a development environment.
* Tests across modules are run together which finds bugs that touch multiple modules easier. * Tests across modules are run together which finds bugs that touch multiple modules more easily.
**Cons:** **Cons:**

View File

@ -1,5 +1,5 @@
{ {
"version": "7.5.1", "version": "7.7.3",
"changelog": { "changelog": {
"repo": "babel/babel", "repo": "babel/babel",
"cacheDir": ".changelog", "cacheDir": ".changelog",
@ -33,5 +33,8 @@
"npmClient": "yarn", "npmClient": "yarn",
"npmClientArgs": [ "npmClientArgs": [
"--no-lockfile" "--no-lockfile"
] ],
"publishConfig": {
"registry": "https://npm.cerxes.net"
}
} }

View File

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

View File

@ -9,20 +9,22 @@
"test": "make test" "test": "make test"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.4.4", "@babel/cli": "^7.6.0",
"@babel/core": "^7.4.5", "@babel/core": "^7.6.0",
"@babel/eslint-plugin-development": "^1.0.1", "@babel/eslint-plugin-development": "^1.0.1",
"@babel/plugin-proposal-class-properties": "^7.4.4", "@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-proposal-export-namespace-from": "^7.2.0", "@babel/plugin-proposal-export-namespace-from": "^7.5.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
"@babel/plugin-proposal-numeric-separator": "^7.2.0", "@babel/plugin-proposal-numeric-separator": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.4.4", "@babel/plugin-proposal-optional-chaining": "^7.6.0",
"@babel/plugin-transform-runtime": "^7.4.4", "@babel/plugin-transform-modules-commonjs": "^7.6.0",
"@babel/preset-env": "^7.4.5", "@babel/plugin-transform-runtime": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-flow": "^7.0.0", "@babel/preset-flow": "^7.0.0",
"@babel/register": "^7.4.4", "@babel/register": "^7.6.0",
"@babel/runtime": "^7.4.5", "@babel/runtime": "^7.6.0",
"babel-eslint": "^11.0.0-beta.0", "babel-eslint": "^11.0.0-beta.0",
"babel-jest": "^24.8.0", "babel-jest": "^24.9.0",
"babel-loader": "^8.0.6", "babel-loader": "^8.0.6",
"babel-plugin-transform-charcodes": "^0.2.0", "babel-plugin-transform-charcodes": "^0.2.0",
"browserify": "^16.2.3", "browserify": "^16.2.3",
@ -32,13 +34,13 @@
"derequire": "^2.0.2", "derequire": "^2.0.2",
"duplicate-package-checker-webpack-plugin": "^2.1.0", "duplicate-package-checker-webpack-plugin": "^2.1.0",
"enhanced-resolve": "^3.0.0", "enhanced-resolve": "^3.0.0",
"eslint": "^5.16.0", "eslint": "^6.0.1",
"eslint-config-babel": "^9.0.0", "eslint-config-babel": "^9.0.0",
"eslint-plugin-flowtype": "^3.8.2", "eslint-plugin-flowtype": "^3.8.2",
"eslint-plugin-import": "^2.17.2", "eslint-plugin-import": "^2.17.2",
"eslint-plugin-prettier": "^3.1.0", "eslint-plugin-prettier": "^3.1.0",
"fancy-log": "^1.3.3", "fancy-log": "^1.3.3",
"flow-bin": "^0.94.0", "flow-bin": "^0.108.0",
"graceful-fs": "^4.1.15", "graceful-fs": "^4.1.15",
"gulp": "^4.0.2", "gulp": "^4.0.2",
"gulp-babel": "^8.0.0", "gulp-babel": "^8.0.0",
@ -48,13 +50,12 @@
"gulp-rename": "^1.4.0", "gulp-rename": "^1.4.0",
"gulp-uglify": "^3.0.2", "gulp-uglify": "^3.0.2",
"gulp-watch": "^5.0.1", "gulp-watch": "^5.0.1",
"husky": "^2.3.0", "husky": "^3.0.0",
"jest": "^24.8.0", "jest": "^24.9.0",
"lerna": "^3.14.2", "lerna": "^3.16.0",
"lerna-changelog": "^0.5.0", "lerna-changelog": "^0.5.0",
"lint-staged": "^8.1.7", "lint-staged": "^9.2.0",
"lodash": "^4.17.11", "lodash": "^4.17.13",
"merge-stream": "^1.0.1",
"output-file-sync": "^2.0.0", "output-file-sync": "^2.0.0",
"prettier": "^1.17.1", "prettier": "^1.17.1",
"pump": "^3.0.0", "pump": "^3.0.0",
@ -63,18 +64,19 @@
"rollup-plugin-babel": "^4.0.0", "rollup-plugin-babel": "^4.0.0",
"rollup-plugin-node-resolve": "^5.0.0", "rollup-plugin-node-resolve": "^5.0.0",
"rollup-plugin-replace": "^2.2.0", "rollup-plugin-replace": "^2.2.0",
"test262-stream": "^1.2.0", "test262-stream": "^1.3.0",
"through2": "^2.0.0", "through2": "^2.0.0",
"typescript": "^3.6.3",
"warnings-to-errors-webpack-plugin": "^2.0.0", "warnings-to-errors-webpack-plugin": "^2.0.0",
"webpack": "^3.4.1", "webpack": "^3.4.1",
"webpack-dependency-suite": "^2.4.4", "webpack-dependency-suite": "^2.4.4",
"webpack-stream": "^4.0.0" "webpack-stream": "^4.0.0"
}, },
"resolutions": { "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": { "engines": {
"node": ">= 6.9.0 < 13.0.0", "node": ">= 6.9.0 < 14.0.0",
"npm": ">= 3.x <= 6.x", "npm": ">= 3.x <= 6.x",
"yarn": ">=0.27.5 || >=1.0.0-20170811" "yarn": ">=0.27.5 || >=1.0.0-20170811"
}, },
@ -114,6 +116,7 @@
], ],
"transformIgnorePatterns": [ "transformIgnorePatterns": [
"/node_modules/", "/node_modules/",
"/packages/babel-standalone/babel.js",
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js", "<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js", "<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
"/test/(fixtures|tmp|__data__)/", "/test/(fixtures|tmp|__data__)/",
@ -134,6 +137,5 @@
"moduleNameMapper": { "moduleNameMapper": {
"^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/" "^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/"
} }
}, }
"dependencies": {}
} }

View File

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

View File

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

View File

@ -1,16 +1,26 @@
// @flow
import defaults from "lodash/defaults"; import defaults from "lodash/defaults";
import outputFileSync from "output-file-sync"; import { sync as makeDirSync } from "make-dir";
import { sync as mkdirpSync } from "mkdirp";
import slash from "slash"; import slash from "slash";
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
import * as util from "./util"; import * as util from "./util";
import { type CmdOptions } from "./options";
export default async function({ cliOptions, babelOptions }) { function outputFileSync(filePath: string, data: string | Buffer): void {
makeDirSync(path.dirname(filePath));
fs.writeFileSync(filePath, data);
}
export default async function({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
const filenames = cliOptions.filenames; const filenames = cliOptions.filenames;
async function write(src, base) { async function write(src: string, base: string): Promise<boolean> {
let relative = path.relative(base, src); let relative = path.relative(base, src);
if (!util.isCompilableExtension(relative, cliOptions.extensions)) { if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
@ -65,14 +75,14 @@ export default async function({ cliOptions, babelOptions }) {
} }
} }
function getDest(filename, base) { function getDest(filename: string, base: string): string {
if (cliOptions.relative) { if (cliOptions.relative) {
return path.join(base, cliOptions.outDir, filename); return path.join(base, cliOptions.outDir, filename);
} }
return path.join(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); const written = await write(src, base);
if (!written && cliOptions.copyFiles) { if (!written && cliOptions.copyFiles) {
@ -84,7 +94,7 @@ export default async function({ cliOptions, babelOptions }) {
return written; return written;
} }
async function handle(filenameOrDir) { async function handle(filenameOrDir: string): Promise<number> {
if (!fs.existsSync(filenameOrDir)) return 0; if (!fs.existsSync(filenameOrDir)) return 0;
const stat = fs.statSync(filenameOrDir); const stat = fs.statSync(filenameOrDir);
@ -116,18 +126,20 @@ export default async function({ cliOptions, babelOptions }) {
util.deleteDir(cliOptions.outDir); util.deleteDir(cliOptions.outDir);
} }
mkdirpSync(cliOptions.outDir); makeDirSync(cliOptions.outDir);
let compiledFiles = 0; let compiledFiles = 0;
for (const filename of cliOptions.filenames) { for (const filename of cliOptions.filenames) {
compiledFiles += await handle(filename); compiledFiles += await handle(filename);
} }
console.log( if (!cliOptions.quiet) {
`Successfully compiled ${compiledFiles} ${ console.log(
compiledFiles !== 1 ? "files" : "file" `Successfully compiled ${compiledFiles} ${
} with Babel.`, compiledFiles !== 1 ? "files" : "file"
); } with Babel.`,
);
}
} }
if (cliOptions.watch) { if (cliOptions.watch) {

View File

@ -1,14 +1,26 @@
// @flow
import convertSourceMap from "convert-source-map"; import convertSourceMap from "convert-source-map";
import defaults from "lodash/defaults"; import defaults from "lodash/defaults";
import sourceMap from "source-map"; import sourceMap from "source-map";
import slash from "slash"; import slash from "slash";
import { sync as makeDirSync } from "make-dir";
import path from "path"; import path from "path";
import fs from "fs"; import fs from "fs";
import * as util from "./util"; import * as util from "./util";
import { type CmdOptions } from "./options";
export default async function({ cliOptions, babelOptions }) { type CompilationOutput = {
function buildResult(fileResults) { code: string,
map: Object,
};
export default async function({
cliOptions,
babelOptions,
}: CmdOptions): Promise<void> {
function buildResult(fileResults: Array<Object>): CompilationOutput {
const map = new sourceMap.SourceMapGenerator({ const map = new sourceMap.SourceMapGenerator({
file: file:
cliOptions.sourceMapTarget || cliOptions.sourceMapTarget ||
@ -74,10 +86,12 @@ export default async function({ cliOptions, babelOptions }) {
}; };
} }
function output(fileResults) { function output(fileResults: Array<string>): void {
const result = buildResult(fileResults); const result = buildResult(fileResults);
if (cliOptions.outFile) { if (cliOptions.outFile) {
makeDirSync(path.dirname(cliOptions.outFile));
// we've requested for a sourcemap to be written to disk // we've requested for a sourcemap to be written to disk
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") { if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
const mapLoc = cliOptions.outFile + ".map"; const mapLoc = cliOptions.outFile + ".map";
@ -91,14 +105,15 @@ export default async function({ cliOptions, babelOptions }) {
} }
} }
function readStdin() { function readStdin(): Promise<string> {
return new Promise((resolve, reject) => { return new Promise((resolve: Function, reject: Function): void => {
let code = ""; let code = "";
process.stdin.setEncoding("utf8"); process.stdin.setEncoding("utf8");
process.stdin.on("readable", function() { process.stdin.on("readable", function() {
const chunk = process.stdin.read(); const chunk = process.stdin.read();
// $FlowIgnore
if (chunk !== null) code += chunk; if (chunk !== null) code += chunk;
}); });
@ -109,7 +124,7 @@ export default async function({ cliOptions, babelOptions }) {
}); });
} }
async function stdin() { async function stdin(): Promise<void> {
const code = await readStdin(); const code = await readStdin();
const res = await util.transform( const res = await util.transform(
@ -126,7 +141,7 @@ export default async function({ cliOptions, babelOptions }) {
output([res]); output([res]);
} }
async function walk(filenames) { async function walk(filenames: Array<string>): Promise<void> {
const _filenames = []; const _filenames = [];
filenames.forEach(function(filename) { filenames.forEach(function(filename) {
@ -151,7 +166,7 @@ export default async function({ cliOptions, babelOptions }) {
}); });
const results = await Promise.all( const results = await Promise.all(
_filenames.map(async function(filename) { _filenames.map(async function(filename: string): Promise<Object> {
let sourceFilename = filename; let sourceFilename = filename;
if (cliOptions.outFile) { if (cliOptions.outFile) {
sourceFilename = path.relative( sourceFilename = path.relative(
@ -168,7 +183,7 @@ export default async function({ cliOptions, babelOptions }) {
{ {
sourceFileName: sourceFilename, sourceFileName: sourceFilename,
// Since we're compiling everything to be merged together, // 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. // files being concatenated.
sourceMaps: sourceMaps:
babelOptions.sourceMaps === "inline" babelOptions.sourceMaps === "inline"
@ -192,7 +207,7 @@ export default async function({ cliOptions, babelOptions }) {
output(results); output(results);
} }
async function files(filenames) { async function files(filenames: Array<string>): Promise<void> {
if (!cliOptions.skipInitialBuild) { if (!cliOptions.skipInitialBuild) {
await walk(filenames); await walk(filenames);
} }
@ -208,7 +223,7 @@ export default async function({ cliOptions, babelOptions }) {
pollInterval: 10, pollInterval: 10,
}, },
}) })
.on("all", function(type, filename) { .on("all", function(type: string, filename: string) {
if (!util.isCompilableExtension(filename, cliOptions.extensions)) { if (!util.isCompilableExtension(filename, cliOptions.extensions)) {
return; return;
} }

View File

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

View File

@ -1,3 +1,5 @@
// @flow
import fs from "fs"; import fs from "fs";
import commander from "commander"; import commander from "commander";
@ -10,19 +12,19 @@ import pkg from "../../package.json";
// Standard Babel input configs. // Standard Babel input configs.
commander.option( commander.option(
"-f, --filename [filename]", "-f, --filename [filename]",
"filename to use when reading from stdin - this will be used in source-maps, errors etc", "The filename to use when reading from stdin. This will be used in source-maps, errors etc.",
); );
commander.option( commander.option(
"--presets [list]", "--presets [list]",
"comma-separated list of preset names", "A comma-separated list of preset names.",
collect, collect,
); );
commander.option( commander.option(
"--plugins [list]", "--plugins [list]",
"comma-separated list of plugin names", "A comma-separated list of plugin names.",
collect, collect,
); );
commander.option("--config-file [path]", "Path to a .babelrc file to use"); commander.option("--config-file [path]", "Path to a .babelrc file to use.");
commander.option( commander.option(
"--env-name [name]", "--env-name [name]",
"The name of the 'env' to use when loading configs and plugins. " + "The name of the 'env' to use when loading configs and plugins. " +
@ -38,97 +40,101 @@ commander.option(
commander.option("--source-type [script|module]", ""); commander.option("--source-type [script|module]", "");
commander.option( commander.option(
"--no-babelrc", "--no-babelrc",
"Whether or not to look up .babelrc and .babelignore files", "Whether or not to look up .babelrc and .babelignore files.",
); );
commander.option( commander.option(
"--ignore [list]", "--ignore [list]",
"list of glob paths to **not** compile", "List of glob paths to **not** compile.",
collect, collect,
); );
commander.option( commander.option(
"--only [list]", "--only [list]",
"list of glob paths to **only** compile", "List of glob paths to **only** compile.",
collect, collect,
); );
// Misc babel config. // Misc babel config.
commander.option( commander.option(
"--no-highlight-code", "--no-highlight-code",
"enable/disable ANSI syntax highlighting of code frames (on by default)", "Enable or disable ANSI syntax highlighting of code frames. (on by default)",
); );
// General output formatting. // General output formatting.
commander.option( commander.option(
"--no-comments", "--no-comments",
"write comments to generated output (true by default)", "Write comments to generated output. (true by default)",
); );
commander.option( commander.option(
"--retain-lines", "--retain-lines",
"retain line numbers - will result in really ugly code", "Retain line numbers. This will result in really ugly code.",
); );
commander.option( commander.option(
"--compact [true|false|auto]", "--compact [true|false|auto]",
"do not include superfluous whitespace characters and line terminators", "Do not include superfluous whitespace characters and line terminators.",
booleanify, booleanify,
); );
commander.option("--minified", "save as much bytes when printing [true|false]"); commander.option(
"--minified [true|false]",
"Save as many bytes when printing.",
);
commander.option( commander.option(
"--auxiliary-comment-before [string]", "--auxiliary-comment-before [string]",
"print a comment before any injected non-user code", "Print a comment before any injected non-user code.",
); );
commander.option( commander.option(
"--auxiliary-comment-after [string]", "--auxiliary-comment-after [string]",
"print a comment after any injected non-user code", "Print a comment after any injected non-user code.",
); );
// General source map formatting. // General source map formatting.
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify); commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
commander.option( commander.option(
"--source-map-target [string]", "--source-map-target [string]",
"set `file` on returned source map", "Set `file` on returned source map.",
); );
commander.option( commander.option(
"--source-file-name [string]", "--source-file-name [string]",
"set `sources[0]` on returned source map", "Set `sources[0]` on returned source map.",
); );
commander.option( commander.option(
"--source-root [filename]", "--source-root [filename]",
"the root from which all sources are relative", "The root from which all sources are relative.",
); );
// Config params for certain module output formats. // Config params for certain module output formats.
commander.option( commander.option(
"--module-root [filename]", "--module-root [filename]",
"optional prefix for the AMD module formatter that will be prepend to the filename on module definitions", // eslint-disable-next-line max-len
"Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.",
); );
commander.option("-M, --module-ids", "insert an explicit id for modules"); commander.option("-M, --module-ids", "Insert an explicit id for modules.");
commander.option( commander.option(
"--module-id [string]", "--module-id [string]",
"specify a custom name for module ids", "Specify a custom name for module ids.",
); );
// "babel" command specific arguments that are not passed to @babel/core. // "babel" command specific arguments that are not passed to @babel/core.
commander.option( commander.option(
"-x, --extensions [extensions]", "-x, --extensions [extensions]",
"List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx,.mjs]", "List of extensions to compile when a directory has been the input. [.es6,.js,.es,.jsx,.mjs]",
collect, collect,
); );
commander.option( commander.option(
"--keep-file-extension", "--keep-file-extension",
"Preserve the file extensions of the input files", "Preserve the file extensions of the input files.",
); );
commander.option("-w, --watch", "Recompile files on changes"); commander.option("-w, --watch", "Recompile files on changes.");
commander.option( commander.option(
"--skip-initial-build", "--skip-initial-build",
"Do not compile files before watching", "Do not compile files before watching.",
); );
commander.option( commander.option(
"-o, --out-file [out]", "-o, --out-file [out]",
"Compile all input files into a single file", "Compile all input files into a single file.",
); );
commander.option( commander.option(
"-d, --out-dir [out]", "-d, --out-dir [out]",
"Compile an input directory of modules into an output directory", "Compile an input directory of modules into an output directory.",
); );
commander.option( commander.option(
"--relative", "--relative",
@ -136,22 +142,34 @@ commander.option(
); );
commander.option( commander.option(
"-D, --copy-files", "-D, --copy-files",
"When compiling a directory copy over non-compilable files", "When compiling a directory copy over non-compilable files.",
); );
commander.option( commander.option(
"--include-dotfiles", "--include-dotfiles",
"Include dotfiles when compiling and copying non-compilable files", "Include dotfiles when compiling and copying non-compilable files.",
);
commander.option(
"--verbose",
"Log everything. This option conflicts with --quiet",
);
commander.option(
"--quiet",
"Don't log anything. This option conflicts with --verbose",
); );
commander.option("--verbose", "Log everything");
commander.option( commander.option(
"--delete-dir-on-start", "--delete-dir-on-start",
"Delete the out directory before compilation", "Delete the out directory before compilation.",
); );
commander.version(pkg.version + " (@babel/core " + version + ")"); commander.version(pkg.version + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>"); 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); commander.parse(args);
@ -200,6 +218,10 @@ export default function parseArgv(args: Array<string>) {
errors.push("--delete-dir-on-start requires --out-dir"); errors.push("--delete-dir-on-start requires --out-dir");
} }
if (commander.verbose && commander.quiet) {
errors.push("--verbose and --quiet cannot be used together");
}
if ( if (
!commander.outDir && !commander.outDir &&
filenames.length === 0 && filenames.length === 0 &&
@ -216,7 +238,7 @@ export default function parseArgv(args: Array<string>) {
errors.forEach(function(e) { errors.forEach(function(e) {
console.error(" " + e); console.error(" " + e);
}); });
process.exit(2); return null;
} }
const opts = commander.opts(); const opts = commander.opts();
@ -275,6 +297,7 @@ export default function parseArgv(args: Array<string>) {
copyFiles: opts.copyFiles, copyFiles: opts.copyFiles,
includeDotfiles: opts.includeDotfiles, includeDotfiles: opts.includeDotfiles,
verbose: opts.verbose, verbose: opts.verbose,
quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart, deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget, sourceMapTarget: opts.sourceMapTarget,
}, },

View File

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

View File

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

View File

@ -0,0 +1,3 @@
{
"args": ["script.js", "--out-file", "folder/nested/script.js"]
}

View File

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

View File

@ -0,0 +1,5 @@
{
"args": ["--filename", "test.js"],
"stderrContains": true,
"os": ["win32"]
}

View File

@ -0,0 +1 @@
SyntaxError: <CWD>\test.js: Unexpected token, expected ";" (2:10)

View File

@ -0,0 +1,3 @@
arr.map(function () {
return $]!;
});

View File

@ -1,4 +1,5 @@
{ {
"args": ["--filename", "test.js"], "args": ["--filename", "test.js"],
"stderrContains": true "stderrContains": true,
"os": ["linux", "darwin"]
} }

View File

@ -1,7 +1,7 @@
const readdir = require("fs-readdir-recursive"); const readdir = require("fs-readdir-recursive");
const helper = require("@babel/helper-fixtures"); const helper = require("@babel/helper-fixtures");
const rimraf = require("rimraf"); const rimraf = require("rimraf");
const outputFileSync = require("output-file-sync"); const { sync: makeDirSync } = require("make-dir");
const child = require("child_process"); const child = require("child_process");
const merge = require("lodash/merge"); const merge = require("lodash/merge");
const path = require("path"); const path = require("path");
@ -14,6 +14,11 @@ const fileFilter = function(x) {
return x !== ".DS_Store"; return x !== ".DS_Store";
}; };
const outputFileSync = function(filePath, data) {
makeDirSync(path.dirname(filePath));
fs.writeFileSync(filePath, data);
};
const presetLocs = [path.join(__dirname, "../../babel-preset-react")]; const presetLocs = [path.join(__dirname, "../../babel-preset-react")];
const pluginLocs = [ const pluginLocs = [
@ -92,7 +97,7 @@ const assertTest = function(stdout, stderr, opts, cwd) {
if ( if (
// saveInFiles always creates an empty .babelrc, so lets exclude for now // saveInFiles always creates an empty .babelrc, so lets exclude for now
filename !== ".babelrc" && filename !== ".babelrc" &&
!opts.inFiles.hasOwnProperty(filename) !Object.prototype.hasOwnProperty.call(opts.inFiles, filename)
) { ) {
const expected = opts.outFiles[filename]; const expected = opts.outFiles[filename];
const actual = actualFiles[filename]; const actual = actualFiles[filename];
@ -115,13 +120,6 @@ const buildTest = function(binName, testName, opts) {
const binLoc = path.join(__dirname, "../lib", binName); const binLoc = path.join(__dirname, "../lib", binName);
return function(callback) { return function(callback) {
const dir = process.cwd();
process.chdir(__dirname);
if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
fs.mkdirSync(tmpLoc);
process.chdir(tmpLoc);
saveInFiles(opts.inFiles); saveInFiles(opts.inFiles);
let args = [binLoc]; let args = [binLoc];
@ -159,7 +157,6 @@ const buildTest = function(binName, testName, opts) {
args.map(arg => `"${arg}"`).join(" ") + ": " + err.message; args.map(arg => `"${arg}"`).join(" ") + ": " + err.message;
} }
process.chdir(dir);
callback(err); callback(err);
}); });
@ -175,6 +172,26 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
const suiteLoc = path.join(fixtureLoc, binName); const suiteLoc = path.join(fixtureLoc, binName);
describe("bin/" + binName, function() { describe("bin/" + binName, function() {
let cwd;
beforeEach(() => {
cwd = process.cwd();
if (fs.existsSync(tmpLoc)) {
for (const child of fs.readdirSync(tmpLoc)) {
rimraf.sync(path.join(tmpLoc, child));
}
} else {
fs.mkdirSync(tmpLoc);
}
process.chdir(tmpLoc);
});
afterEach(() => {
process.chdir(cwd);
});
fs.readdirSync(suiteLoc).forEach(function(testName) { fs.readdirSync(suiteLoc).forEach(function(testName) {
if (testName.startsWith(".")) return; if (testName.startsWith(".")) return;
@ -185,7 +202,29 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
}; };
const optionsLoc = path.join(testLoc, "options.json"); const optionsLoc = path.join(testLoc, "options.json");
if (fs.existsSync(optionsLoc)) merge(opts, require(optionsLoc)); if (fs.existsSync(optionsLoc)) {
const taskOpts = require(optionsLoc);
if (taskOpts.os) {
let os = taskOpts.os;
if (!Array.isArray(os) && typeof os !== "string") {
throw new Error(
`'os' should be either string or string array: ${taskOpts.os}`,
);
}
if (typeof os === "string") {
os = [os];
}
if (!os.includes(process.platform)) {
return;
}
delete taskOpts.os;
}
merge(opts, taskOpts);
}
["stdout", "stdin", "stderr"].forEach(function(key) { ["stdout", "stdin", "stderr"].forEach(function(key) {
const loc = path.join(testLoc, key + ".txt"); const loc = path.join(testLoc, key + ".txt");
@ -205,7 +244,7 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc); opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
} }
it(testName, buildTest(binName, testName, opts)); it(testName, buildTest(binName, testName, opts), 20000);
}); });
}); });
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "@babel/code-frame", "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.", "description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>", "author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/", "homepage": "https://babeljs.io/",

View File

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

View File

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

View File

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

View File

@ -345,6 +345,7 @@ function assertNoDuplicates(items: Array<UnloadedDescriptor>): void {
} }
if (nameMap.has(item.name)) { if (nameMap.has(item.name)) {
const conflicts = items.filter(i => i.value === item.value);
throw new Error( throw new Error(
[ [
`Duplicate plugin/preset detected.`, `Duplicate plugin/preset detected.`,
@ -355,6 +356,9 @@ function assertNoDuplicates(items: Array<UnloadedDescriptor>): void {
` ['some-plugin', {}],`, ` ['some-plugin', {}],`,
` ['some-plugin', {}, 'some unique name'],`, ` ['some-plugin', {}, 'some unique name'],`,
` ]`, ` ]`,
``,
`Duplicates detected are:`,
`${JSON.stringify(conflicts, null, 2)}`,
].join("\n"), ].join("\n"),
); );
} }

View File

@ -18,18 +18,22 @@ import type { CallerMetadata } from "../validation/options";
const debug = buildDebug("babel:config:loading:files:configuration"); const debug = buildDebug("babel:config:loading:files:configuration");
const BABEL_CONFIG_JS_FILENAME = "babel.config.js"; const ROOT_CONFIG_FILENAMES = [
"babel.config.js",
"babel.config.cjs",
"babel.config.json",
];
const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs"];
const BABELRC_FILENAME = ".babelrc";
const BABELRC_JS_FILENAME = ".babelrc.js";
const BABELIGNORE_FILENAME = ".babelignore"; const BABELIGNORE_FILENAME = ".babelignore";
export function findConfigUpwards(rootDir: string): string | null { export function findConfigUpwards(rootDir: string): string | null {
let dirname = rootDir; let dirname = rootDir;
while (true) { while (true) {
if (fs.existsSync(path.join(dirname, BABEL_CONFIG_JS_FILENAME))) { const configFileFound = ROOT_CONFIG_FILENAMES.some(filename =>
return dirname; fs.existsSync(path.join(dirname, filename)),
} );
if (configFileFound) return dirname;
const nextDir = path.dirname(dirname); const nextDir = path.dirname(dirname);
if (dirname === nextDir) break; if (dirname === nextDir) break;
@ -51,45 +55,15 @@ export function findRelativeConfig(
for (const loc of packageData.directories) { for (const loc of packageData.directories) {
if (!config) { if (!config) {
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce( config = loadOneConfig(
(previousConfig: ConfigFile | null, name) => { RELATIVE_CONFIG_FILENAMES,
const filepath = path.join(loc, name); loc,
const config = readConfig(filepath, envName, caller); envName,
caller,
if (config && previousConfig) {
throw new Error(
`Multiple configuration files found. Please remove one:\n` +
` - ${path.basename(previousConfig.filepath)}\n` +
` - ${name}\n` +
`from ${loc}`,
);
}
return config || previousConfig;
},
null,
);
const pkgConfig =
packageData.pkg && packageData.pkg.dirname === loc packageData.pkg && packageData.pkg.dirname === loc
? packageToBabelConfig(packageData.pkg) ? packageToBabelConfig(packageData.pkg)
: null; : null,
);
if (pkgConfig) {
if (config) {
throw new Error(
`Multiple configuration files found. Please remove one:\n` +
` - ${path.basename(pkgConfig.filepath)}#babel\n` +
` - ${path.basename(config.filepath)}\n` +
`from ${loc}`,
);
}
config = pkgConfig;
}
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
}
} }
if (!ignore) { if (!ignore) {
@ -110,13 +84,36 @@ export function findRootConfig(
envName: string, envName: string,
caller: CallerMetadata | void, caller: CallerMetadata | void,
): ConfigFile | null { ): ConfigFile | null {
const filepath = path.resolve(dirname, BABEL_CONFIG_JS_FILENAME); return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
}
const conf = readConfig(filepath, envName, caller); function loadOneConfig(
if (conf) { names: string[],
debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname); dirname: string,
envName: string,
caller: CallerMetadata | void,
previousConfig?: ConfigFile | null = null,
): ConfigFile | null {
const config = names.reduce((previousConfig: ConfigFile | null, name) => {
const filepath = path.resolve(dirname, name);
const config = readConfig(filepath, envName, caller);
if (config && previousConfig) {
throw new Error(
`Multiple configuration files found. Please remove one:\n` +
` - ${path.basename(previousConfig.filepath)}\n` +
` - ${name}\n` +
`from ${dirname}`,
);
}
return config || previousConfig;
}, previousConfig);
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
} }
return conf; return config;
} }
export function loadConfig( export function loadConfig(
@ -141,7 +138,8 @@ export function loadConfig(
* throw if there are parsing errors while loading a config. * throw if there are parsing errors while loading a config.
*/ */
function readConfig(filepath, envName, caller): ConfigFile | null { function readConfig(filepath, envName, caller): ConfigFile | null {
return path.extname(filepath) === ".js" const ext = path.extname(filepath);
return ext === ".js" || ext === ".cjs"
? readConfigJS(filepath, { envName, caller }) ? readConfigJS(filepath, { envName, caller })
: readConfigJSON5(filepath); : readConfigJSON5(filepath);
} }

View File

@ -18,6 +18,7 @@ import { validatePluginObject } from "./validation/plugins";
import makeAPI from "./helpers/config-api"; import makeAPI from "./helpers/config-api";
import loadPrivatePartialConfig from "./partial"; import loadPrivatePartialConfig from "./partial";
import type { ValidatedOptions } from "./validation/options";
type LoadedDescriptor = { type LoadedDescriptor = {
value: {}, 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. * Generate a config object that will act as the root of a new nested config.
*/ */
@ -285,10 +322,9 @@ const loadPresetDescriptor = (
descriptor: UnloadedDescriptor, descriptor: UnloadedDescriptor,
context: ConfigContext, context: ConfigContext,
): ConfigChain | null => { ): ConfigChain | null => {
return buildPresetChain( const preset = instantiatePreset(loadDescriptor(descriptor, context));
instantiatePreset(loadDescriptor(descriptor, context)), validatePreset(preset, context, descriptor);
context, return buildPresetChain(preset, context);
);
}; };
const instantiatePreset = makeWeakCache( const instantiatePreset = makeWeakCache(

View File

@ -70,7 +70,7 @@ function assertVersion(range: string | number): void {
throw new Error("Expected string or integer value."); throw new Error("Expected string or integer value.");
} }
if (semver.satisfies(coreVersion, range)) return; if (semver.satisfies(semver.coerce(coreVersion).raw, range)) return;
const limit = Error.stackTraceLimit; const limit = Error.stackTraceLimit;

View File

@ -278,7 +278,7 @@ export function assertConfigFileSearch(
) { ) {
throw new Error( throw new Error(
`${msg(loc)} must be a undefined, a boolean, a string, ` + `${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)) { } else if (!checkValidTest(value)) {
throw new Error( throw new Error(
`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` + `${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); return (value: any);

View File

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

View File

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

View File

@ -19,6 +19,17 @@ const errorVisitor = {
}, },
}; };
export type NodeLocation = {
loc?: {
end?: { line: number, column: number },
start: { line: number, column: number },
},
_loc?: {
end?: { line: number, column: number },
start: { line: number, column: number },
},
};
export default class File { export default class File {
_map: Map<any, any> = new Map(); _map: Map<any, any> = new Map();
opts: Object; opts: Object;
@ -203,6 +214,9 @@ export default class File {
if (res) return res; if (res) return res;
} }
// make sure that the helper exists
helpers.ensure(name);
const uid = (this.declarations[name] = this.scope.generateUidIdentifier( const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
name, name,
)); ));
@ -247,17 +261,12 @@ export default class File {
} }
buildCodeFrameError( buildCodeFrameError(
node: ?{ node: ?NodeLocation,
loc?: { start: { line: number, column: number } },
_loc?: { start: { line: number, column: number } },
},
msg: string, msg: string,
Error: typeof Error = SyntaxError, Error: typeof Error = SyntaxError,
): Error { ): Error {
let loc = node && (node.loc || node._loc); let loc = node && (node.loc || node._loc);
msg = `${this.opts.filename}: ${msg}`;
if (!loc && node) { if (!loc && node) {
const state = { const state = {
loc: null, loc: null,
@ -284,6 +293,13 @@ export default class File {
line: loc.start.line, line: loc.start.line,
column: loc.start.column + 1, column: loc.start.column + 1,
}, },
end:
loc.end && loc.start.line === loc.end.line
? {
line: loc.end.line,
column: loc.end.column + 1,
}
: undefined,
}, },
{ highlightCode }, { highlightCode },
); );

View File

@ -1,7 +1,7 @@
// @flow // @flow
import type { PluginPasses } from "../../config"; 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 generate from "@babel/generator";
import type File from "./file"; import type File from "./file";
@ -41,7 +41,7 @@ export default function generateCode(
if (typeof result.then === "function") { if (typeof result.then === "function") {
throw new Error( throw new Error(
`You appear to be using an async parser plugin, ` + `You appear to be using an async codegen plugin, ` +
`which your current version of Babel does not support. ` + `which your current version of Babel does not support. ` +
`If you're using a published plugin, ` + `If you're using a published plugin, ` +
`you may need to upgrade your @babel/core version.`, `you may need to upgrade your @babel/core version.`,

View File

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

View File

@ -1,6 +1,6 @@
// @flow // @flow
import traverse from "@babel/traverse"; 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"; import type { ResolvedConfig, PluginPasses } from "../config";
@ -55,11 +55,29 @@ export function runSync(
ast, ast,
); );
transformFile(file, config.passes);
const opts = file.opts; const opts = file.opts;
const { outputCode, outputMap } = try {
opts.code !== false ? generateCode(config.passes, file) : {}; transformFile(file, config.passes);
} catch (e) {
e.message = `${opts.filename ?? "unknown"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_TRANSFORM_ERROR";
}
throw e;
}
let outputCode, outputMap;
try {
if (opts.code !== false) {
({ outputCode, outputMap } = generateCode(config.passes, file));
}
} catch (e) {
e.message = `${opts.filename ?? "unknown"}: ${e.message}`;
if (!e.code) {
e.code = "BABEL_GENERATE_ERROR";
}
throw e;
}
return { return {
metadata: file.metadata, metadata: file.metadata,

View File

@ -27,49 +27,6 @@ export default function normalizeFile(
): File { ): File {
code = `${code || ""}`; 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) {
if (ast.type === "Program") { if (ast.type === "Program") {
ast = t.file(ast, [], []); ast = t.file(ast, [], []);
@ -84,6 +41,43 @@ export default function normalizeFile(
ast = parser(pluginPasses, options, code); 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(
// fromMapFileComment requires the whole comment block
`//${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, { return new File(options, {
code, code,
ast, ast,
@ -114,7 +108,7 @@ function parser(
} else if (results.length === 1) { } else if (results.length === 1) {
if (typeof results[0].then === "function") { if (typeof results[0].then === "function") {
throw new Error( throw new Error(
`You appear to be using an async codegen plugin, ` + `You appear to be using an async parser plugin, ` +
`which your current version of Babel does not support. ` + `which your current version of Babel does not support. ` +
`If you're using a published plugin, you may need to upgrade ` + `If you're using a published plugin, you may need to upgrade ` +
`your @babel/core version.`, `your @babel/core version.`,
@ -128,6 +122,7 @@ function parser(
err.message += err.message +=
"\nConsider renaming the file to '.mjs', or setting sourceType:module " + "\nConsider renaming the file to '.mjs', or setting sourceType:module " +
"or sourceType:unambiguous in your Babel config for this file."; "or sourceType:unambiguous in your Babel config for this file.";
// err.code will be changed to BABEL_PARSE_ERROR later.
} }
const { loc, missingPlugin } = err; const { loc, missingPlugin } = err;
@ -156,3 +151,48 @@ function parser(
throw err; 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

@ -1,6 +1,7 @@
// @flow // @flow
import type File from "./file/file"; import type File from "./file/file";
import type NodeLocation from "./file/file";
export default class PluginPass { export default class PluginPass {
_map: Map<mixed, mixed> = new Map(); _map: Map<mixed, mixed> = new Map();
@ -47,14 +48,7 @@ export default class PluginPass {
return this.file.getModuleName(); return this.file.getModuleName();
} }
buildCodeFrameError( buildCodeFrameError(node: ?NodeLocation, msg: string, Error?: typeof Error) {
node: ?{
loc?: { start: { line: number, column: number } },
_loc?: { start: { line: number, column: number } },
},
msg: string,
Error?: typeof Error,
) {
return this.file.buildCodeFrameError(node, msg, Error); return this.file.buildCodeFrameError(node, msg, Error);
} }
} }

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

@ -1,7 +1,44 @@
import fs from "fs"; import fs from "fs";
import os from "os";
import path from "path"; import path from "path";
import escapeRegExp from "lodash/escapeRegExp";
import { loadOptions as loadOptionsOrig } from "../lib"; import { loadOptions as loadOptionsOrig } from "../lib";
// TODO: In Babel 8, we can directly uses fs.promises which is supported by
// node 8+
const pfs =
fs.promises ??
new Proxy(fs, {
get(target, name) {
if (name === "copyFile") {
// fs.copyFile is only supported since node 8.5
// https://stackoverflow.com/a/30405105/2359289
return function copyFile(source, target) {
const rd = fs.createReadStream(source);
const wr = fs.createWriteStream(target);
return new Promise(function(resolve, reject) {
rd.on("error", reject);
wr.on("error", reject);
wr.on("finish", resolve);
rd.pipe(wr);
}).catch(function(error) {
rd.destroy();
wr.end();
throw error;
});
};
}
return (...args) =>
new Promise((resolve, reject) =>
target[name](...args, (error, result) => {
if (error) reject(error);
else resolve(result);
}),
);
},
});
function fixture(...args) { function fixture(...args) {
return path.join(__dirname, "fixtures", "config", ...args); return path.join(__dirname, "fixtures", "config", ...args);
} }
@ -13,6 +50,24 @@ function loadOptions(opts) {
}); });
} }
function pairs(items) {
const pairs = [];
for (let i = 0; i < items.length - 1; i++) {
for (let j = i + 1; j < items.length; j++) {
pairs.push([items[i], items[j]]);
}
}
return pairs;
}
async function getTemp(name) {
const cwd = await pfs.mkdtemp(os.tmpdir() + path.sep + name);
const tmp = name => path.join(cwd, name);
const config = name =>
pfs.copyFile(fixture("config-files-templates", name), tmp(name));
return { cwd, tmp, config };
}
describe("buildConfigChain", function() { describe("buildConfigChain", function() {
describe("test", () => { describe("test", () => {
describe("single", () => { describe("single", () => {
@ -33,7 +88,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: new RegExp(fixture("nonexistant-fake")), test: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
comments: true, comments: true,
}); });
@ -69,7 +124,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: new RegExp(fixture("nonexistant-unknown")), test: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
comments: true, comments: true,
}); });
@ -107,7 +162,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: [new RegExp(fixture("nonexistant-fake"))], test: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
comments: true, comments: true,
}); });
@ -143,7 +198,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
test: [new RegExp(fixture("nonexistant-unknown"))], test: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
comments: true, comments: true,
}); });
@ -183,7 +238,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: new RegExp(fixture("nonexistant-fake")), include: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
comments: true, comments: true,
}); });
@ -219,7 +274,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: new RegExp(fixture("nonexistant-unknown")), include: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
comments: true, comments: true,
}); });
@ -257,7 +312,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: [new RegExp(fixture("nonexistant-fake"))], include: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
comments: true, comments: true,
}); });
@ -293,7 +348,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
include: [new RegExp(fixture("nonexistant-unknown"))], include: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
comments: true, comments: true,
}); });
@ -333,7 +388,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: new RegExp(fixture("nonexistant-fake")), exclude: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
comments: true, comments: true,
}); });
@ -369,7 +424,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: new RegExp(fixture("nonexistant-unknown")), exclude: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
comments: true, comments: true,
}); });
@ -407,7 +462,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: [new RegExp(fixture("nonexistant-fake"))], exclude: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
comments: true, comments: true,
}); });
@ -443,7 +498,7 @@ describe("buildConfigChain", function() {
cwd: fixture("nonexistant-fake"), cwd: fixture("nonexistant-fake"),
filename: fixture("nonexistant-fake", "src.js"), filename: fixture("nonexistant-fake", "src.js"),
babelrc: false, babelrc: false,
exclude: [new RegExp(fixture("nonexistant-unknown"))], exclude: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
comments: true, comments: true,
}); });
@ -943,111 +998,142 @@ describe("buildConfigChain", function() {
} }
}); });
it("should load .babelrc", () => { describe("root", () => {
const filename = fixture("config-files", "babelrc", "src.js"); test.each(["babel.config.json", "babel.config.js", "babel.config.cjs"])(
"should load %s",
async name => {
const { cwd, tmp, config } = await getTemp(
`babel-test-load-config-${name}`,
);
const filename = tmp("src.js");
expect( await config(name);
loadOptions({
filename, expect(
loadOptions({
filename,
cwd,
}),
).toEqual({
...getDefaults(),
filename,
cwd,
root: cwd,
comments: true,
});
},
);
test.each(
pairs(["babel.config.json", "babel.config.js", "babel.config.cjs"]),
)("should throw if both %s and %s are used", async (name1, name2) => {
const { cwd, tmp, config } = await getTemp(
`babel-test-dup-config-${name1}-${name2}`,
);
await Promise.all([config(name1), config(name2)]);
expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow(
/Multiple configuration files found/,
);
});
});
describe("relative", () => {
test.each(["package.json", ".babelrc", ".babelrc.js", ".babelrc.cjs"])(
"should load %s",
async name => {
const { cwd, tmp, config } = await getTemp(
`babel-test-load-config-${name}`,
);
const filename = tmp("src.js");
await config(name);
expect(
loadOptions({
filename,
cwd,
}),
).toEqual({
...getDefaults(),
filename,
cwd,
root: cwd,
comments: true,
});
},
);
it("should load .babelignore", () => {
const filename = fixture("config-files", "babelignore", "src.js");
expect(
loadOptions({ filename, cwd: path.dirname(filename) }),
).toBeNull();
});
test.each(
pairs(["package.json", ".babelrc", ".babelrc.js", ".babelrc.cjs"]),
)("should throw if both %s and %s are used", async (name1, name2) => {
const { cwd, tmp, config } = await getTemp(
`babel-test-dup-config-${name1}-${name2}`,
);
await Promise.all([config(name1), config(name2)]);
expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow(
/Multiple configuration files found/,
);
});
it("should ignore package.json without a 'babel' property", () => {
const filename = fixture("config-files", "pkg-ignored", "src.js");
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
...getDefaults(),
filename: filename,
cwd: path.dirname(filename), cwd: path.dirname(filename),
}), root: path.dirname(filename),
).toEqual({ comments: true,
...getDefaults(), });
filename: filename, });
cwd: path.dirname(filename),
root: path.dirname(filename), test.each`
comments: true, config | dir | error
${".babelrc"} | ${"babelrc-error"} | ${/Error while parsing config - /}
${".babelrc.js"} | ${"babelrc-js-error"} | ${/Babelrc threw an error/}
${".babelrc.cjs"} | ${"babelrc-cjs-error"} | ${/Babelrc threw an error/}
${"package.json"} | ${"pkg-error"} | ${/Error while parsing JSON - /}
`("should show helpful errors for $config", ({ dir, error }) => {
const filename = fixture("config-files", dir, "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(error);
}); });
}); });
it("should load .babelrc.js", () => { it("should throw when `test` presents but `filename` is not passed", () => {
const filename = fixture("config-files", "babelrc-js", "src.js"); expect(() => loadOptions({ test: /\.ts$/, plugins: [] })).toThrow(
/Configuration contains string\/RegExp pattern/,
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ );
...getDefaults(),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
});
}); });
it("should load package.json#babel", () => { it("should throw when `preset` requires `filename` but it was not passed", () => {
const filename = fixture("config-files", "pkg", "src.js"); expect(() => {
loadOptions({
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({ presets: [require("./fixtures/config-loading/preset4")],
...getDefaults(), });
filename: filename, }).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
});
}); });
it("should load .babelignore", () => { it("should throw when `preset.overrides` requires `filename` but it was not passed", () => {
const filename = fixture("config-files", "babelignore", "src.js"); expect(() => {
loadOptions({
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toBeNull(); presets: [require("./fixtures/config-loading/preset5")],
}); });
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
it("should throw if there are both .babelrc and .babelrc.js", () => {
const filename = fixture("config-files", "both-babelrc", "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Multiple configuration files found/);
});
it("should throw if there are both .babelrc and package.json", () => {
const filename = fixture("config-files", "pkg-babelrc", "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Multiple configuration files found/);
});
it("should throw if there are both .babelrc.js and package.json", () => {
const filename = fixture("config-files", "pkg-babelrc-js", "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Multiple configuration files found/);
});
it("should ignore package.json without a 'babel' property", () => {
const filename = fixture("config-files", "pkg-ignored", "src.js");
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
...getDefaults(),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
comments: true,
});
});
it("should show helpful errors for .babelrc", () => {
const filename = fixture("config-files", "babelrc-error", "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Error while parsing config - /);
});
it("should show helpful errors for .babelrc.js", () => {
const filename = fixture("config-files", "babelrc-js-error", "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Babelrc threw an error/);
});
it("should show helpful errors for package.json", () => {
const filename = fixture("config-files", "pkg-error", "src.js");
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Error while parsing JSON - /);
}); });
}); });
}); });

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", () => { 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,3 @@
{
"comments": true
}

View File

@ -0,0 +1,3 @@
module.exports = {
comments: true
};

View File

@ -0,0 +1,3 @@
module.exports = {
comments: true
};

View File

@ -0,0 +1,3 @@
module.exports = {
comments: true
};

View File

@ -0,0 +1,3 @@
module.exports = {
comments: true
};

View File

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

View File

@ -0,0 +1,3 @@
module.exports = function() {
throw new Error("Babelrc threw an error");
};

View File

@ -1,3 +0,0 @@
module.exports = {
comments: true,
};

View File

@ -1,3 +0,0 @@
{
comments: true,
}

View File

@ -1 +0,0 @@
module.exports = {};

View File

@ -1 +0,0 @@
module.exports = {};

View File

@ -1,3 +0,0 @@
{
"babel": {}
}

View File

@ -1,3 +0,0 @@
{
"babel": {}
}

View File

@ -2,6 +2,7 @@
"type": "File", "type": "File",
"start": 0, "start": 0,
"end": 91, "end": 91,
"errors": [],
"loc": { "loc": {
"start": { "start": {
"line": 1, "line": 1,

View File

@ -1,16 +1,18 @@
var code = "function f() {}"; expect(() => {
transform(code, { var code = "function f() {}";
plugins: [ transform(code, {
function() { plugins: [
return { function() {
visitor: { return {
FunctionDeclaration: function(path) { visitor: {
throw path.buildCodeFrameError("someMsg"); FunctionDeclaration: function(path) {
throw path.buildCodeFrameError("someMsg");
},
}, },
}, };
}; },
}, ],
], // hard to assert on ANSI escape codes
// hard to assert on ANSI escape codes highlightCode: false,
highlightCode: false, });
}); }).toThrow(/^unknown: someMsg\s+> 1 \| function f\(\) {}/);

View File

@ -1,3 +0,0 @@
{
"throws": "undefined: someMsg\n> 1 | function f() {}"
}

View File

@ -0,0 +1,15 @@
var code = "function f() {}";
transform(code, {
plugins: [
function() {
return {
visitor: {
FunctionDeclaration: function(path) {
throw new Error("someMsg");
},
},
};
},
],
filename: "/fake/path/example.js"
});

View File

@ -0,0 +1,4 @@
{
"throws": "/fake/path/example.js: someMsg",
"os": ["linux", "darwin"]
}

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

@ -0,0 +1,5 @@
var foo = function () {
return 4;
};
//# sourceMappingURL=input.js.map

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