Compare commits

..

99 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
2974 changed files with 173418 additions and 5249 deletions

View File

@ -30,11 +30,20 @@ aliases:
- &artifact_env_min
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:
build:
test:
working_directory: ~/babel
docker:
- image: circleci/node:12
- image: circleci/node:13
steps:
- checkout
- restore-cache: *restore-yarn-cache
@ -54,3 +63,59 @@ jobs:
- store_artifacts: *artifact_env_min
- save_cache: *save-node-modules-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

2
.gitignore vendored
View File

@ -35,7 +35,7 @@ package-lock.json
!/packages/babel-runtime-corejs2/helpers/temporalRef.js
/packages/babel-runtime-corejs2/helpers/esm/*.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/core-js/**/*.js
!/packages/babel-runtime-corejs2/core-js/map.js

View File

@ -28,7 +28,7 @@ matrix:
- node_js: "node"
env: JOB=lint
# We test the latest version on circleci
- node_js: "11"
- node_js: "12"
# Move `windows` build to be the third since it is slow
- os: windows
node_js: "node"

View File

@ -17,6 +17,138 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
<!-- insert-new-changelog-here -->
## v7.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

View File

@ -191,9 +191,12 @@ new-version:
git pull --rebase
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
publish: prepublish
yarn lerna publish from-git --require-scripts
yarn lerna publish from-git
$(MAKE) clean
publish-ci: prepublish
@ -203,7 +206,7 @@ else
echo "Missing NPM_TOKEN env var"
exit 1
endif
yarn lerna publish from-git --require-scripts --yes
yarn lerna publish from-git --yes
rm -f .npmrc
$(MAKE) clean
@ -213,7 +216,7 @@ yarn-install: clean-all
yarn --ignore-engines
lerna-bootstrap: yarn-install
yarn lerna bootstrap -- --ignore-engines
yarn lerna bootstrap
bootstrap: bootstrap-only
$(MAKE) build

View File

@ -4,16 +4,23 @@
</a>
</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">
The compiler for writing next generation JavaScript.
</p>
<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="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a>
</p>
<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://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>

View File

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

View File

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

View File

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

View File

@ -76,7 +76,7 @@
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
},
"engines": {
"node": ">= 6.9.0 < 13.0.0",
"node": ">= 6.9.0 < 14.0.0",
"npm": ">= 3.x <= 6.x",
"yarn": ">=0.27.5 || >=1.0.0-20170811"
},
@ -116,6 +116,7 @@
],
"transformIgnorePatterns": [
"/node_modules/",
"/packages/babel-standalone/babel.js",
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
"/test/(fixtures|tmp|__data__)/",

View File

@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.6.4",
"version": "7.7.0",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@ -24,8 +24,7 @@
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.0.0",
"lodash": "^4.17.13",
"mkdirp": "^0.5.1",
"output-file-sync": "^2.0.0",
"make-dir": "^2.1.0",
"slash": "^2.0.0",
"source-map": "^0.5.0"
},
@ -33,10 +32,10 @@
"chokidar": "^2.1.8"
},
"peerDependencies": {
"@babel/core": "^7.0.0-0"
"@babel/core": "^7.0.0-0 || csx"
},
"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/core": "^7.7.0",
"@babel/helper-fixtures": "^7.6.3"
},
"bin": {

View File

@ -1,8 +1,7 @@
// @flow
import defaults from "lodash/defaults";
import outputFileSync from "output-file-sync";
import { sync as mkdirpSync } from "mkdirp";
import { sync as makeDirSync } from "make-dir";
import slash from "slash";
import path from "path";
import fs from "fs";
@ -10,6 +9,11 @@ import fs from "fs";
import * as util from "./util";
import { type CmdOptions } from "./options";
function outputFileSync(filePath: string, data: string | Buffer): void {
makeDirSync(path.dirname(filePath));
fs.writeFileSync(filePath, data);
}
export default async function({
cliOptions,
babelOptions,
@ -122,19 +126,21 @@ export default async function({
util.deleteDir(cliOptions.outDir);
}
mkdirpSync(cliOptions.outDir);
makeDirSync(cliOptions.outDir);
let compiledFiles = 0;
for (const filename of cliOptions.filenames) {
compiledFiles += await handle(filename);
}
if (!cliOptions.quiet) {
console.log(
`Successfully compiled ${compiledFiles} ${
compiledFiles !== 1 ? "files" : "file"
} with Babel.`,
);
}
}
if (cliOptions.watch) {
const chokidar = util.requireChokidar();

View File

@ -4,6 +4,7 @@ import convertSourceMap from "convert-source-map";
import defaults from "lodash/defaults";
import sourceMap from "source-map";
import slash from "slash";
import { sync as makeDirSync } from "make-dir";
import path from "path";
import fs from "fs";
@ -89,6 +90,8 @@ export default async function({
const result = buildResult(fileResults);
if (cliOptions.outFile) {
makeDirSync(path.dirname(cliOptions.outFile));
// we've requested for a sourcemap to be written to disk
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
const mapLoc = cliOptions.outFile + ".map";

View File

@ -12,19 +12,19 @@ import pkg from "../../package.json";
// Standard Babel input configs.
commander.option(
"-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(
"--presets [list]",
"comma-separated list of preset names",
"A comma-separated list of preset names.",
collect,
);
commander.option(
"--plugins [list]",
"comma-separated list of plugin names",
"A comma-separated list of plugin names.",
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(
"--env-name [name]",
"The name of the 'env' to use when loading configs and plugins. " +
@ -40,97 +40,101 @@ commander.option(
commander.option("--source-type [script|module]", "");
commander.option(
"--no-babelrc",
"Whether or not to look up .babelrc and .babelignore files",
"Whether or not to look up .babelrc and .babelignore files.",
);
commander.option(
"--ignore [list]",
"list of glob paths to **not** compile",
"List of glob paths to **not** compile.",
collect,
);
commander.option(
"--only [list]",
"list of glob paths to **only** compile",
"List of glob paths to **only** compile.",
collect,
);
// Misc babel config.
commander.option(
"--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.
commander.option(
"--no-comments",
"write comments to generated output (true by default)",
"Write comments to generated output. (true by default)",
);
commander.option(
"--retain-lines",
"retain line numbers - will result in really ugly code",
"Retain line numbers. This will result in really ugly code.",
);
commander.option(
"--compact [true|false|auto]",
"do not include superfluous whitespace characters and line terminators",
"Do not include superfluous whitespace characters and line terminators.",
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(
"--auxiliary-comment-before [string]",
"print a comment before any injected non-user code",
"Print a comment before any injected non-user code.",
);
commander.option(
"--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.
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
commander.option(
"--source-map-target [string]",
"set `file` on returned source map",
"Set `file` on returned source map.",
);
commander.option(
"--source-file-name [string]",
"set `sources[0]` on returned source map",
"Set `sources[0]` on returned source map.",
);
commander.option(
"--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.
commander.option(
"--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(
"--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.
commander.option(
"-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,
);
commander.option(
"--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(
"--skip-initial-build",
"Do not compile files before watching",
"Do not compile files before watching.",
);
commander.option(
"-o, --out-file [out]",
"Compile all input files into a single file",
"Compile all input files into a single file.",
);
commander.option(
"-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(
"--relative",
@ -138,16 +142,23 @@ commander.option(
);
commander.option(
"-D, --copy-files",
"When compiling a directory copy over non-compilable files",
"When compiling a directory copy over non-compilable files.",
);
commander.option(
"--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(
"--delete-dir-on-start",
"Delete the out directory before compilation",
"Delete the out directory before compilation.",
);
commander.version(pkg.version + " (@babel/core " + version + ")");
@ -207,6 +218,10 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
errors.push("--delete-dir-on-start requires --out-dir");
}
if (commander.verbose && commander.quiet) {
errors.push("--verbose and --quiet cannot be used together");
}
if (
!commander.outDir &&
filenames.length === 0 &&
@ -282,6 +297,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
copyFiles: opts.copyFiles,
includeDotfiles: opts.includeDotfiles,
verbose: opts.verbose,
quiet: opts.quiet,
deleteDirOnStart: opts.deleteDirOnStart,
sourceMapTarget: opts.sourceMapTarget,
},

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

@ -1,7 +1,7 @@
const readdir = require("fs-readdir-recursive");
const helper = require("@babel/helper-fixtures");
const rimraf = require("rimraf");
const outputFileSync = require("output-file-sync");
const { sync: makeDirSync } = require("make-dir");
const child = require("child_process");
const merge = require("lodash/merge");
const path = require("path");
@ -14,6 +14,11 @@ const fileFilter = function(x) {
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 pluginLocs = [
@ -115,13 +120,6 @@ const buildTest = function(binName, testName, opts) {
const binLoc = path.join(__dirname, "../lib", binName);
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);
let args = [binLoc];
@ -159,7 +157,6 @@ const buildTest = function(binName, testName, opts) {
args.map(arg => `"${arg}"`).join(" ") + ": " + err.message;
}
process.chdir(dir);
callback(err);
});
@ -175,6 +172,26 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
const suiteLoc = path.join(fixtureLoc, binName);
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) {
if (testName.startsWith(".")) return;

View File

@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.6.4",
"version": "7.7.2",
"description": "Babel compiler core.",
"main": "lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
@ -34,13 +34,13 @@
},
"dependencies": {
"@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.6.4",
"@babel/helpers": "^7.6.2",
"@babel/parser": "^7.6.4",
"@babel/template": "^7.6.0",
"@babel/traverse": "^7.6.3",
"@babel/types": "^7.6.3",
"convert-source-map": "^1.1.0",
"@babel/generator": "^7.7.2",
"@babel/helpers": "^7.7.0",
"@babel/parser": "^7.7.2",
"@babel/template": "^7.7.0",
"@babel/traverse": "^7.7.2",
"@babel/types": "^7.7.2",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
"lodash": "^4.17.13",

View File

@ -18,18 +18,22 @@ import type { CallerMetadata } from "../validation/options";
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";
export function findConfigUpwards(rootDir: string): string | null {
let dirname = rootDir;
while (true) {
if (fs.existsSync(path.join(dirname, BABEL_CONFIG_JS_FILENAME))) {
return dirname;
}
const configFileFound = ROOT_CONFIG_FILENAMES.some(filename =>
fs.existsSync(path.join(dirname, filename)),
);
if (configFileFound) return dirname;
const nextDir = path.dirname(dirname);
if (dirname === nextDir) break;
@ -51,46 +55,16 @@ export function findRelativeConfig(
for (const loc of packageData.directories) {
if (!config) {
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce(
(previousConfig: ConfigFile | null, name) => {
const filepath = path.join(loc, 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 ${loc}`,
);
}
return config || previousConfig;
},
null,
);
const pkgConfig =
config = loadOneConfig(
RELATIVE_CONFIG_FILENAMES,
loc,
envName,
caller,
packageData.pkg && packageData.pkg.dirname === loc
? packageToBabelConfig(packageData.pkg)
: 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}`,
: null,
);
}
config = pkgConfig;
}
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
}
}
if (!ignore) {
const ignoreLoc = path.join(loc, BABELIGNORE_FILENAME);
@ -110,13 +84,36 @@ export function findRootConfig(
envName: string,
caller: CallerMetadata | void,
): 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);
if (conf) {
debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname);
function loadOneConfig(
names: string[],
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 conf;
return config || previousConfig;
}, previousConfig);
if (config) {
debug("Found configuration %o from %o.", config.filepath, dirname);
}
return config;
}
export function loadConfig(
@ -141,7 +138,8 @@ export function loadConfig(
* throw if there are parsing errors while loading a config.
*/
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 })
: readConfigJSON5(filepath);
}

View File

@ -70,7 +70,7 @@ function assertVersion(range: string | number): void {
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;

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 {
_map: Map<any, any> = new Map();
opts: Object;
@ -250,17 +261,12 @@ export default class File {
}
buildCodeFrameError(
node: ?{
loc?: { start: { line: number, column: number } },
_loc?: { start: { line: number, column: number } },
},
node: ?NodeLocation,
msg: string,
Error: typeof Error = SyntaxError,
): Error {
let loc = node && (node.loc || node._loc);
msg = `${this.opts.filename ?? "unknown"}: ${msg}`;
if (!loc && node) {
const state = {
loc: null,
@ -287,6 +293,13 @@ export default class File {
line: loc.start.line,
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 },
);

View File

@ -65,7 +65,8 @@ export default function normalizeFile(
if (typeof options.filename === "string" && lastComment) {
try {
inputMap = convertSourceMap.fromMapFileComment(
lastComment,
// fromMapFileComment requires the whole comment block
`//${lastComment}`,
path.dirname(options.filename),
);
} catch (err) {
@ -156,7 +157,7 @@ function parser(
// 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]*$/;
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=(?:[^\s'"`]+?)[ \t]*$/;
function extractCommentsFromList(regex, comments, lastComment) {
if (comments) {

View File

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

View File

@ -1,8 +1,44 @@
import fs from "fs";
import os from "os";
import path from "path";
import escapeRegExp from "lodash/escapeRegExp";
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) {
return path.join(__dirname, "fixtures", "config", ...args);
}
@ -14,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("test", () => {
describe("single", () => {
@ -944,75 +998,93 @@ describe("buildConfigChain", function() {
}
});
it("should load .babelrc", () => {
const filename = fixture("config-files", "babelrc", "src.js");
describe("root", () => {
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");
await config(name);
expect(
loadOptions({
filename,
cwd: path.dirname(filename),
cwd,
}),
).toEqual({
...getDefaults(),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
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/,
);
});
});
it("should load .babelrc.js", () => {
const filename = fixture("config-files", "babelrc-js", "src.js");
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");
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
await config(name);
expect(
loadOptions({
filename,
cwd,
}),
).toEqual({
...getDefaults(),
filename: filename,
cwd: path.dirname(filename),
root: path.dirname(filename),
filename,
cwd,
root: cwd,
comments: true,
});
});
it("should load package.json#babel", () => {
const filename = fixture("config-files", "pkg", "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 load .babelignore", () => {
const filename = fixture("config-files", "babelignore", "src.js");
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toBeNull();
expect(
loadOptions({ filename, cwd: path.dirname(filename) }),
).toBeNull();
});
it("should throw if there are both .babelrc and .babelrc.js", () => {
const filename = fixture("config-files", "both-babelrc", "src.js");
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}`,
);
expect(() =>
loadOptions({ filename, cwd: path.dirname(filename) }),
).toThrow(/Multiple configuration files found/);
});
await Promise.all([config(name1), config(name2)]);
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/);
expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow(
/Multiple configuration files found/,
);
});
it("should ignore package.json without a 'babel' property", () => {
@ -1027,28 +1099,19 @@ describe("buildConfigChain", function() {
});
});
it("should show helpful errors for .babelrc", () => {
const filename = fixture("config-files", "babelrc-error", "src.js");
test.each`
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 while parsing config - /);
).toThrow(error);
});
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 - /);
});
it("should throw when `test` presents but `filename` is not passed", () => {

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",
"start": 0,
"end": 91,
"errors": [],
"loc": {
"start": {
"line": 1,

View File

@ -1,5 +1,6 @@
var code = "function f() {}";
transform(code, {
expect(() => {
var code = "function f() {}";
transform(code, {
plugins: [
function() {
return {
@ -13,4 +14,5 @@ transform(code, {
],
// hard to assert on ANSI escape codes
highlightCode: false,
});
});
}).toThrow(/^unknown: someMsg\s+> 1 \| function f\(\) {}/);

View File

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

View File

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

View File

@ -0,0 +1 @@
{"version":3,"sources":["original.js"],"names":[],"mappings":"AAAA,UAAU,Y;SAAM,C;CAAC","sourcesContent":["var foo = () => 4;"]}

View File

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

View File

@ -0,0 +1,3 @@
var foo = function () {
return 4;
};

View File

@ -0,0 +1,7 @@
{
"mappings": "AAAA,IAAA,GAAA,GAAU,Y;SAAM,C;AAAC,CAAjB",
"names": [],
"sources": ["original.js"],
"sourcesContent": ["var foo = () => 4;"],
"version": 3
}

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -71,26 +71,8 @@ export function ClassBody(node: Object) {
export function ClassProperty(node: Object) {
this.printJoin(node.decorators, node);
this.tsPrintClassMemberModifiers(node, /* isField */ true);
if (node.accessibility) {
// TS
this.word(node.accessibility);
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
if (node.abstract) {
// TS
this.word("abstract");
this.space();
}
if (node.readonly) {
// TS
this.word("readonly");
this.space();
}
if (node.computed) {
this.token("[");
this.print(node.key, node);
@ -148,23 +130,6 @@ export function ClassPrivateMethod(node: Object) {
export function _classMethodHead(node) {
this.printJoin(node.decorators, node);
if (node.accessibility) {
// TS
this.word(node.accessibility);
this.space();
}
if (node.abstract) {
// TS
this.word("abstract");
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
this.tsPrintClassMemberModifiers(node, /* isField */ false);
this._methodHead(node);
}

View File

@ -134,6 +134,92 @@ export function DeclareExportAllDeclaration(/*node: Object*/) {
ExportAllDeclaration.apply(this, arguments);
}
export function EnumDeclaration(node: Object) {
const { id, body } = node;
this.word("enum");
this.space();
this.print(id, node);
this.print(body, node);
}
function enumExplicitType(
context: Object,
name: string,
hasExplicitType: boolean,
) {
if (hasExplicitType) {
context.space();
context.word("of");
context.space();
context.word(name);
}
context.space();
}
function enumBody(context: Object, node: Object) {
const { members } = node;
context.token("{");
context.indent();
context.newline();
for (const member of members) {
context.print(member, node);
context.newline();
}
context.dedent();
context.token("}");
}
export function EnumBooleanBody(node: Object) {
const { explicitType } = node;
enumExplicitType(this, "boolean", explicitType);
enumBody(this, node);
}
export function EnumNumberBody(node: Object) {
const { explicitType } = node;
enumExplicitType(this, "number", explicitType);
enumBody(this, node);
}
export function EnumStringBody(node: Object) {
const { explicitType } = node;
enumExplicitType(this, "string", explicitType);
enumBody(this, node);
}
export function EnumSymbolBody(node: Object) {
enumExplicitType(this, "symbol", true);
enumBody(this, node);
}
export function EnumDefaultedMember(node: Object) {
const { id } = node;
this.print(id, node);
this.token(",");
}
function enumInitializedMember(context: Object, node: Object) {
const { id, init } = node;
context.print(id, node);
context.space();
context.token("=");
context.space();
context.print(init, node);
context.token(",");
}
export function EnumBooleanMember(node: Object) {
enumInitializedMember(this, node);
}
export function EnumNumberMember(node: Object) {
enumInitializedMember(this, node);
}
export function EnumStringMember(node: Object) {
enumInitializedMember(this, node);
}
function FlowExportDeclaration(node: Object) {
if (node.declaration) {
const declar = node.declaration;

View File

@ -197,11 +197,17 @@ export function TSTypeReference(node) {
}
export function TSTypePredicate(node) {
if (node.asserts) {
this.word("asserts");
this.space();
}
this.print(node.parameterName);
if (node.typeAnnotation) {
this.space();
this.word("is");
this.space();
this.print(node.typeAnnotation.typeAnnotation);
}
}
export function TSTypeQuery(node) {
@ -550,3 +556,26 @@ export function tsPrintSignatureDeclarationBase(node) {
this.token(")");
this.print(node.typeAnnotation, node);
}
export function tsPrintClassMemberModifiers(node, isField) {
if (isField && node.declare) {
this.word("declare");
this.space();
}
if (node.accessibility) {
this.word(node.accessibility);
this.space();
}
if (node.static) {
this.word("static");
this.space();
}
if (node.abstract) {
this.word("abstract");
this.space();
}
if (isField && node.readonly) {
this.word("readonly");
this.space();
}
}

View File

@ -35,14 +35,22 @@ export function NullableTypeAnnotation(node: Object, parent: Object): boolean {
return t.isArrayTypeAnnotation(parent);
}
export function FunctionTypeAnnotation(node: Object, parent: Object): boolean {
export function FunctionTypeAnnotation(
node: Object,
parent: Object,
printStack: Array<Object>,
): boolean {
return (
// (() => A) | (() => B)
t.isUnionTypeAnnotation(parent) ||
// (() => A) & (() => B)
t.isIntersectionTypeAnnotation(parent) ||
// (() => A)[]
t.isArrayTypeAnnotation(parent)
t.isArrayTypeAnnotation(parent) ||
// <T>(A: T): (T => T[]) => B => [A, B]
(t.isTypeAnnotation(parent) &&
// Check grandparent
t.isArrowFunctionExpression(printStack[printStack.length - 3]))
);
}

View File

@ -5,3 +5,4 @@ const bar4 = x => {};
const bar5 = (x): string => {};
const bar6 = (x: number) => {};
const bar7 = <T>(x) => {};
const bar8 = <T>(x: T): (T => T[]) => y => [x, y];

View File

@ -11,3 +11,5 @@ const bar5 = (x): string => {};
const bar6 = (x: number) => {};
const bar7 = <T>(x) => {};
const bar8 = <T>(x: T): ((T) => T[]) => y => [x, y];

View File

@ -0,0 +1,36 @@
enum E {
A = true,
B = false,
}
enum E of boolean {
A = true,
B = false,
}
enum E {
A = 1,
B = 2,
}
enum E of number {
A = 1,
B = 2,
}
enum E {
A,
B,
}
enum E of string {
A,
B,
}
enum E {
A = "a",
B = "b",
}
enum E of string {
A = "a",
B = "b",
}
enum E of symbol {
A,
B,
}

View File

@ -0,0 +1,3 @@
{
"plugins": [["flow", { "enums": true }]]
}

View File

@ -0,0 +1,36 @@
enum E {
A = true,
B = false,
}
enum E of boolean {
A = true,
B = false,
}
enum E {
A = 1,
B = 2,
}
enum E of number {
A = 1,
B = 2,
}
enum E {
A,
B,
}
enum E of string {
A,
B,
}
enum E {
A = "a",
B = "b",
}
enum E of string {
A = "a",
B = "b",
}
enum E of symbol {
A,
B,
}

View File

@ -0,0 +1,2 @@
(x: any): asserts x => true;
(x: any): asserts x is boolean => true;

View File

@ -0,0 +1,3 @@
(x: any): asserts x => true;
(x: any): asserts x is boolean => true;

View File

@ -0,0 +1,5 @@
class A {
declare foo;
declare bar: string;
declare readonly bax: number;
}

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"plugins": ["typescript", "classProperties"]
}

View File

@ -0,0 +1,5 @@
class A {
declare foo;
declare bar: string;
declare readonly bax: number;
}

View File

@ -0,0 +1,2 @@
function f(x: any): asserts x {}
(function(x: any): asserts x is boolean {})

View File

@ -0,0 +1,3 @@
function f(x: any): asserts x {}
(function (x: any): asserts x is boolean {});

View File

@ -197,7 +197,7 @@ describe("generation", function() {
const id2 = fn.body.body[0].expression;
id2.name += "2";
id2.loc.identiferName = "bar";
id2.loc.identifierName = "bar";
const generated = generate(
ast,

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-annotate-as-pure",
"version": "7.0.0",
"version": "7.7.0",
"description": "Helper function to annotate paths and nodes with #__PURE__ comment",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure",
"license": "MIT",
@ -9,6 +9,6 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/types": "^7.0.0"
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-bindify-decorators",
"version": "7.1.0",
"version": "7.7.0",
"description": "Helper function to bindify decorators",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-bindify-decorators",
"license": "MIT",
@ -9,7 +9,7 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/traverse": "^7.1.0",
"@babel/types": "^7.0.0"
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-builder-binary-assignment-operator-visitor",
"version": "7.1.0",
"version": "7.7.0",
"description": "Helper function to build binary assignment operator visitors",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor",
"license": "MIT",
@ -9,7 +9,7 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/helper-explode-assignable-expression": "^7.1.0",
"@babel/types": "^7.0.0"
"@babel/helper-explode-assignable-expression": "^7.7.0",
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-builder-react-jsx",
"version": "7.3.0",
"version": "7.7.0",
"description": "Helper function to build react jsx",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx",
"license": "MIT",
@ -9,7 +9,7 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/types": "^7.3.0",
"@babel/types": "^7.7.0",
"esutils": "^2.0.0"
}
}

View File

@ -87,13 +87,15 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
function convertAttribute(node) {
const value = convertAttributeValue(node.value || t.booleanLiteral(true));
if (t.isJSXSpreadAttribute(node)) {
return t.spreadElement(node.argument);
}
if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
value.value = value.value.replace(/\n\s+/g, " ");
// "raw" JSXText should not be used from a StringLiteral because it needs to be escaped.
if (value.extra && value.extra.raw) {
delete value.extra.raw;
}
delete value.extra?.raw;
}
if (t.isJSXNamespacedName(node.name)) {
@ -172,6 +174,14 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
let _props = [];
const objs = [];
const { useSpread = false } = file.opts;
if (typeof useSpread !== "boolean") {
throw new Error(
"transform-react-jsx currently only accepts a boolean option for " +
"useSpread (defaults to false)",
);
}
const useBuiltIns = file.opts.useBuiltIns || false;
if (typeof useBuiltIns !== "boolean") {
throw new Error(
@ -180,6 +190,18 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
);
}
if (useSpread && useBuiltIns) {
throw new Error(
"transform-react-jsx currently only accepts useBuiltIns or useSpread " +
"but not both",
);
}
if (useSpread) {
const props = attribs.map(convertAttribute);
return t.objectExpression(props);
}
while (attribs.length) {
const prop = attribs.shift();
if (t.isJSXSpreadAttribute(prop)) {

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-call-delegate",
"version": "7.4.4",
"version": "7.7.0",
"description": "Helper function to call delegate",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate",
"license": "MIT",
@ -9,8 +9,8 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/helper-hoist-variables": "^7.4.4",
"@babel/traverse": "^7.4.4",
"@babel/types": "^7.4.4"
"@babel/helper-hoist-variables": "^7.7.0",
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
}
}

View File

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

View File

@ -5,6 +5,8 @@ import ReplaceSupers, {
import memberExpressionToFunctions from "@babel/helper-member-expression-to-functions";
import optimiseCall from "@babel/helper-optimise-call-expression";
import * as ts from "./typescript";
export function buildPrivateNamesMap(props) {
const privateNamesMap = new Map();
for (const prop of props) {
@ -556,6 +558,8 @@ export function buildFieldsInitNodes(
let needsClassRef = false;
for (const prop of props) {
ts.assertFieldTransformed(prop);
const isStatic = prop.node.static;
const isInstance = !isStatic;
const isPrivate = prop.isPrivate();

View File

@ -1,5 +1,6 @@
import nameFunction from "@babel/helper-function-name";
import splitExportDeclaration from "@babel/helper-split-export-declaration";
import semver from "semver";
import {
buildPrivateNamesNodes,
buildPrivateNamesMap,
@ -27,7 +28,10 @@ export { FEATURES, injectInitialization };
// as 70000100005. This method is easier than using a semver-parsing
// package, but it breaks if we release x.y.z where x, y or z are
// greater than 99_999.
const version = pkg.version.split(".").reduce((v, x) => v * 1e5 + +x, 0);
const version = semver
.coerce(pkg.version)
.raw.split(".")
.reduce((v, x) => v * 1e5 + +x, 0);
const versionKey = "@babel/plugin-class-features/version";
export function createClassFeaturePlugin({

View File

@ -0,0 +1,19 @@
// @flow
import type { NodePath } from "@babel/traverse";
export function assertFieldTransformed(path: NodePath) {
// TODO (Babel 8): Also check path.node.definite
if (path.node.declare) {
throw path.buildCodeFrameError(
`TypeScript 'declare' fields must first be transformed by ` +
`@babel/plugin-transform-typescript.\n` +
`If you have already enabled that plugin (or '@babel/preset-typescript'), make sure ` +
`that it runs before any plugin related to additional class features:\n` +
` - @babel/plugin-proposal-class-properties\n` +
` - @babel/plugin-proposal-private-methods\n` +
` - @babel/plugin-proposal-decorators`,
);
}
}

View File

@ -0,0 +1,3 @@
src
test
*.log

View File

@ -0,0 +1,19 @@
# @babel/helper-create-regexp-features-plugin
> Compile ESNext Regular Expressions to ES5
See our website [@babel/helper-create-regexp-features-plugin](https://babeljs.io/docs/en/next/babel-helper-create-regexp-features-plugin.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/helper-create-regexp-features-plugin
```
or using yarn:
```sh
yarn add @babel/helper-create-regexp-features-plugin --dev
```

View File

@ -0,0 +1,32 @@
{
"name": "@babel/helper-create-regexp-features-plugin",
"version": "7.7.2",
"author": "The Babel Team (https://babeljs.io/team)",
"license": "MIT",
"description": "Compile ESNext Regular Expressions to ES5",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel",
"directory": "packages/babel-helper-create-regexp-features-plugin"
},
"main": "lib/index.js",
"publishConfig": {
"access": "public"
},
"keywords": [
"babel",
"babel-plugin"
],
"dependencies": {
"@babel/helper-regex": "^7.4.4",
"regexpu-core": "^4.6.0",
"semver": "^5.5.0"
},
"peerDependencies": {
"@babel/core": "^7.0.0 || csx"
},
"devDependencies": {
"@babel/core": "^7.7.2",
"@babel/helper-plugin-test-runner": "^7.0.0"
}
}

View File

@ -0,0 +1,27 @@
// @flow
export const FEATURES = Object.freeze({
unicodeFlag: 1 << 0,
dotAllFlag: 1 << 1,
unicodePropertyEscape: 1 << 2,
namedCaptureGroups: 1 << 3,
});
// We can't use a symbol because this needs to always be the same, even if
// this package isn't deduped by npm. e.g.
// - node_modules/
// - @babel/plugin-regexp-features
// - @babel/plugin-proposal-unicode-property-regex
// - node_modules
// - @babel-plugin-regexp-features
export const featuresKey = "@babel/plugin-regexp-features/featuresKey";
export const runtimeKey = "@babel/plugin-regexp-features/runtimeKey";
type FeatureType = $Values<typeof FEATURES>;
export function enableFeature(features: number, feature: FeatureType): number {
return features | feature;
}
export function hasFeature(features: number, feature: FeatureType) {
return !!(features & feature);
}

View File

@ -0,0 +1,100 @@
import semver from "semver";
import rewritePattern from "regexpu-core";
import {
featuresKey,
FEATURES,
enableFeature,
runtimeKey,
hasFeature,
} from "./features";
import { generateRegexpuOptions } from "./util";
import pkg from "../package.json";
import { types as t } from "@babel/core";
import { pullFlag } from "@babel/helper-regex";
// Note: Versions are represented as an integer. e.g. 7.1.5 is represented
// as 70000100005. This method is easier than using a semver-parsing
// package, but it breaks if we release x.y.z where x, y or z are
// greater than 99_999.
const version = semver
.coerce(pkg.version)
.raw.split(".")
.reduce((v, x) => v * 1e5 + +x, 0);
const versionKey = "@babel/plugin-regexp-features/version";
export function createRegExpFeaturePlugin({ name, feature, options = {} }) {
return {
name,
pre() {
const { file } = this;
const features = file.get(featuresKey) ?? 0;
let newFeatures = enableFeature(features, FEATURES[feature]);
const { useUnicodeFlag, runtime = true } = options;
if (useUnicodeFlag === false) {
newFeatures = enableFeature(newFeatures, FEATURES.unicodeFlag);
}
if (newFeatures !== features) {
file.set(featuresKey, newFeatures);
}
if (!runtime) {
file.set(runtimeKey, false);
}
if (!file.has(versionKey) || file.get(versionKey) < version) {
file.set(versionKey, version);
}
},
visitor: {
RegExpLiteral(path) {
const { node } = path;
const { file } = this;
const features = file.get(featuresKey);
const runtime = file.get(runtimeKey) ?? true;
const regexpuOptions = generateRegexpuOptions(node, features);
if (regexpuOptions === null) {
return;
}
const namedCaptureGroups = {};
if (regexpuOptions.namedGroup) {
regexpuOptions.onNamedGroup = (name, index) => {
namedCaptureGroups[name] = index;
};
}
node.pattern = rewritePattern(node.pattern, node.flags, regexpuOptions);
if (
regexpuOptions.namedGroup &&
Object.keys(namedCaptureGroups).length > 0 &&
runtime &&
!isRegExpTest(path)
) {
path.replaceWith(
t.callExpression(this.addHelper("wrapRegExp"), [
node,
t.valueToNode(namedCaptureGroups),
]),
);
}
if (hasFeature(features, FEATURES.unicodeFlag)) {
pullFlag(node, "u");
}
if (hasFeature(features, FEATURES.dotAllFlag)) {
pullFlag(node, "s");
}
},
},
};
}
function isRegExpTest(path) {
return (
path.parentPath.isMemberExpression({
object: path.node,
computed: false,
}) && path.parentPath.get("property").isIdentifier({ name: "test" })
);
}

View File

@ -0,0 +1,56 @@
import { FEATURES, hasFeature } from "./features";
export function generateRegexpuOptions(node, features) {
let useUnicodeFlag = false,
dotAllFlag = false,
unicodePropertyEscape = false,
namedGroup = false;
const { flags, pattern } = node;
const flagsIncludesU = flags.includes("u");
if (flagsIncludesU) {
if (!hasFeature(features, FEATURES.unicodeFlag)) {
useUnicodeFlag = true;
}
if (
hasFeature(features, FEATURES.unicodePropertyEscape) &&
/\\[pP]{/.test(pattern)
) {
unicodePropertyEscape = true;
}
}
if (hasFeature(features, FEATURES.dotAllFlag) && flags.indexOf("s") >= 0) {
dotAllFlag = true;
}
if (
hasFeature(features, FEATURES.namedCaptureGroups) &&
/\(\?<(?![=!])/.test(pattern)
) {
namedGroup = true;
}
if (
!namedGroup &&
!unicodePropertyEscape &&
!dotAllFlag &&
(!flagsIncludesU || useUnicodeFlag)
) {
return null;
}
// Now we have to feed regexpu-core the regex
if (flagsIncludesU && flags.indexOf("s") >= 0) {
// When flags includes u, `config.unicode` will be enabled even if `u` is supported natively.
// In this case we have to enable dotAllFlag, otherwise `rewritePattern(/./su)` will return
// incorrect result
// https://github.com/mathiasbynens/regexpu-core/blob/v4.6.0/rewrite-pattern.js#L191
dotAllFlag = true;
}
return {
useUnicodeFlag,
onNamedGroup: () => {},
namedGroup,
unicodePropertyEscape,
dotAllFlag,
lookbehind: true,
};
}

View File

@ -0,0 +1,6 @@
{
"plugins": [
["proposal-unicode-property-regex", { "useUnicodeFlag": false }, "name 1"],
["proposal-unicode-property-regex", { "useUnicodeFlag": true }, "name 2"]
]
}

View File

@ -0,0 +1,6 @@
{
"plugins": [
["transform-named-capturing-groups-regex", { "runtime": false }, "name 1"],
["transform-named-capturing-groups-regex", { "runtime": true }, "name 2"]
]
}

View File

@ -0,0 +1,3 @@
import runner from "@babel/helper-plugin-test-runner";
runner(__dirname);

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-explode-assignable-expression",
"version": "7.1.0",
"version": "7.7.0",
"description": "Helper function to explode an assignable expression",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-assignable-expression",
"license": "MIT",
@ -9,7 +9,7 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/traverse": "^7.1.0",
"@babel/types": "^7.0.0"
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-explode-class",
"version": "7.1.0",
"version": "7.7.0",
"description": "Helper function to explode class",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-explode-class",
"license": "MIT",
@ -9,8 +9,8 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/helper-bindify-decorators": "^7.1.0",
"@babel/traverse": "^7.1.0",
"@babel/types": "^7.0.0"
"@babel/helper-bindify-decorators": "^7.7.0",
"@babel/traverse": "^7.7.0",
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-function-name",
"version": "7.1.0",
"version": "7.7.0",
"description": "Helper function to change the property 'name' of every function",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-function-name",
"license": "MIT",
@ -9,8 +9,8 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/helper-get-function-arity": "^7.0.0",
"@babel/template": "^7.1.0",
"@babel/types": "^7.0.0"
"@babel/helper-get-function-arity": "^7.7.0",
"@babel/template": "^7.7.0",
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-get-function-arity",
"version": "7.0.0",
"version": "7.7.0",
"description": "Helper function to get function arity",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-get-function-arity",
"license": "MIT",
@ -9,6 +9,6 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/types": "^7.0.0"
"@babel/types": "^7.7.0"
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-hoist-variables",
"version": "7.4.4",
"version": "7.7.0",
"description": "Helper function to hoist variables",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-hoist-variables",
"license": "MIT",
@ -9,6 +9,6 @@
},
"main": "lib/index.js",
"dependencies": {
"@babel/types": "^7.4.4"
"@babel/types": "^7.7.0"
}
}

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@babel/helper-module-imports",
"version": "7.0.0",
"version": "7.7.0",
"description": "Babel helper functions for inserting module loads",
"author": "Logan Smyth <loganfsmyth@gmail.com>",
"homepage": "https://babeljs.io/",
@ -11,9 +11,9 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-module-imports",
"main": "lib/index.js",
"dependencies": {
"@babel/types": "^7.0.0"
"@babel/types": "^7.7.0"
},
"devDependencies": {
"@babel/core": "^7.0.0"
"@babel/core": "^7.7.0"
}
}

View File

@ -417,10 +417,10 @@ export default class ImportInjector {
node._blockHoist = blockHoist;
});
const targetPath = this._programPath.get("body").filter(p => {
const targetPath = this._programPath.get("body").find(p => {
const val = p.node._blockHoist;
return Number.isFinite(val) && val < 4;
})[0];
});
if (targetPath) {
targetPath.insertBefore(statements);

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