Compare commits
167 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbd5a26e57 | ||
|
|
42e5974fd4 | ||
|
|
735abc0ed8 | ||
|
|
aa7678f32a | ||
|
|
b64cb9aaf1 | ||
|
|
8da9d8b4b8 | ||
|
|
3e4889d649 | ||
|
|
da0af5fd99 | ||
|
|
b02e35c19a | ||
|
|
3e8a5c5e28 | ||
|
|
8769903284 | ||
|
|
5c859b1117 | ||
|
|
2e7bea4a6a | ||
|
|
29734b924a | ||
|
|
6813ee02d7 | ||
|
|
fcb77de901 | ||
|
|
d05bd9edc8 | ||
|
|
27ba292774 | ||
|
|
a08e856804 | ||
|
|
c0e3fa0081 | ||
|
|
e5afa57cca | ||
|
|
e7fa566442 | ||
|
|
7c0333e12a | ||
|
|
8a775a32ba | ||
|
|
94e47c30a9 | ||
|
|
1664cce681 | ||
|
|
a2bf68981f | ||
|
|
15aa511b8e | ||
|
|
11ed2e2bf5 | ||
|
|
eb3767d58b | ||
|
|
f0c2364d01 | ||
|
|
ee344c3e4c | ||
|
|
64041e1669 | ||
|
|
469a5a71cd | ||
|
|
75090f10e5 | ||
|
|
22df2ae244 | ||
|
|
051965052c | ||
|
|
ee397ff107 | ||
|
|
15535cf52c | ||
|
|
682d9f9f09 | ||
|
|
a112be2fa0 | ||
|
|
9ec26a7d3e | ||
|
|
ba2c0f7adf | ||
|
|
5fb4d84a33 | ||
|
|
3e4a9d588b | ||
|
|
be2cbde560 | ||
|
|
66727632e8 | ||
|
|
ba28f462bc | ||
|
|
f08062b1de | ||
|
|
4f0840ab88 | ||
|
|
6a9d2538e0 | ||
|
|
f160522ab0 | ||
|
|
4d30379d36 | ||
|
|
4d12c8971b | ||
|
|
4506590557 | ||
|
|
1e7ed5c461 | ||
|
|
fced5cea43 | ||
|
|
9bc9571381 | ||
|
|
fb910e063c | ||
|
|
3b4a86aea4 | ||
|
|
94b678c949 | ||
|
|
c84a4c8bfa | ||
|
|
dfd59c183e | ||
|
|
718017d896 | ||
|
|
a0cb7b1ab1 | ||
|
|
0b886418c8 | ||
|
|
0371979a3e | ||
|
|
0407f034f0 | ||
|
|
d919ecd254 | ||
|
|
d8da63c929 | ||
|
|
eb3230f9db | ||
|
|
7dc5fdb390 | ||
|
|
ee68d6d1b0 | ||
|
|
d3fe22f0e1 | ||
|
|
7f47cb65d0 | ||
|
|
8b9af1be2f | ||
|
|
f5ca0587d1 | ||
|
|
a9660cf559 | ||
|
|
8107a6faa2 | ||
|
|
42000b9907 | ||
|
|
5d9a786b2f | ||
|
|
e88a569e83 | ||
|
|
4eab157502 | ||
|
|
a9a7f4e690 | ||
|
|
fa5ec75c43 | ||
|
|
b961d39a4d | ||
|
|
759ff4d6df | ||
|
|
9e65472377 | ||
|
|
25f040caa4 | ||
|
|
0dbf99bedb | ||
|
|
f48b47c1f7 | ||
|
|
406a65c894 | ||
|
|
075a50242d | ||
|
|
c777e81e06 | ||
|
|
d0519fa907 | ||
|
|
019fbca3f6 | ||
|
|
24dde2e8e8 | ||
|
|
bff79e198a | ||
|
|
106bb41d47 | ||
|
|
d19f053482 | ||
|
|
49da9a07c8 | ||
|
|
b06663320e | ||
|
|
d50e78d45b | ||
|
|
5b86353b35 | ||
|
|
f588e4ec47 | ||
|
|
cbb482e2f9 | ||
|
|
595a349174 | ||
|
|
0bf0ae3410 | ||
|
|
ef3f555be9 | ||
|
|
38f8bbac1a | ||
|
|
a4170b5e32 | ||
|
|
6b8a37c413 | ||
|
|
0a98814329 | ||
|
|
8bf9714d69 | ||
|
|
ca67637da4 | ||
|
|
77fd7cd4c4 | ||
|
|
1d3f9815df | ||
|
|
31fc1d06bc | ||
|
|
b8bb93a838 | ||
|
|
8f8a457798 | ||
|
|
11fa2461ce | ||
|
|
505b2cc18d | ||
|
|
dcdf7c8fdd | ||
|
|
fdbbb743b6 | ||
|
|
6852bf6415 | ||
|
|
f92c2ae830 | ||
|
|
d7801c644c | ||
|
|
84961ebb05 | ||
|
|
3144ed131a | ||
|
|
ce4c374924 | ||
|
|
8d492b159b | ||
|
|
b4c9cb0222 | ||
|
|
a596da2822 | ||
|
|
1cfb92d66a | ||
|
|
888b9f6940 | ||
|
|
b6486a22cb | ||
|
|
a6392bd636 | ||
|
|
9dd8825eff | ||
|
|
ecf4667305 | ||
|
|
87fb6c4a8b | ||
|
|
58cf1a7d48 | ||
|
|
c96aef17e1 | ||
|
|
fc38638aeb | ||
|
|
33ab4f1661 | ||
|
|
54d257c105 | ||
|
|
9c06e4ed4d | ||
|
|
f5b8140580 | ||
|
|
0430a48775 | ||
|
|
45ca6751fa | ||
|
|
b1826bf0a0 | ||
|
|
2080042808 | ||
|
|
3f0590de2a | ||
|
|
5661de5908 | ||
|
|
c2d303f8be | ||
|
|
4da7a01aa9 | ||
|
|
47eb1ddfe0 | ||
|
|
9febf63882 | ||
|
|
85432e2c44 | ||
|
|
1969e6b6aa | ||
|
|
7942dc0f07 | ||
|
|
354666aa17 | ||
|
|
9e9b62f77a | ||
|
|
5da94bff87 | ||
|
|
eae7a33316 | ||
|
|
16e17c560b | ||
|
|
555d50a08c | ||
|
|
18ace84b88 |
@@ -6,7 +6,7 @@ charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
|
||||
[*.{js,json}]
|
||||
[*.{js,json,ts,tsx}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
|
||||
12
.github/CHANGELOG-6to5.md
vendored
12
.github/CHANGELOG-6to5.md
vendored
@@ -84,7 +84,7 @@
|
||||
* More performance improvements.
|
||||
* Parsing is now ~30% faster thanks to [marijnh/acorn@7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f](https://github.com/marijnh/acorn/commit/7264bc0178e7e6af7cfe02e9e0c6b26ee0e6007f).
|
||||
* **New Feature**
|
||||
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edgecases.
|
||||
* Optional `es6.blockScopingTDZ` is now completely functional and handles all edge cases.
|
||||
* `super` in object literals.
|
||||
* Tail call optimisation. Thanks [@RReverser](https://github.com/RReverser)!
|
||||
|
||||
@@ -474,7 +474,7 @@
|
||||
* **Polish**
|
||||
* Rest parameters now allocate the array before populating.
|
||||
* **Internal**
|
||||
* `for...in` loops have been changed to optimized `for` loops - better performance and no enumeration of protoype keys.
|
||||
* `for...in` loops have been changed to optimized `for` loops - better performance and no enumeration of prototype keys.
|
||||
* Parts of the code generator have now been optimized thanks to [gaearon](https://github.com/gaearon).
|
||||
|
||||
## 2.12.3
|
||||
@@ -643,7 +643,7 @@
|
||||
|
||||
* **Bug Fix**
|
||||
* Better handling of number literal property keys.
|
||||
* Handle `NewExpression` paren insertion edegcases better.
|
||||
* Handle `NewExpression` paren insertion edge cases better.
|
||||
* **Internal**
|
||||
* Fix incorrect AST node `identifier("this")`.
|
||||
* Better `toIdentifier` method that handles reserved words.
|
||||
@@ -850,7 +850,7 @@
|
||||
|
||||
## 1.14.10
|
||||
|
||||
* Fix let scoping unneccesary override.
|
||||
* Fix let scoping unnecessary override.
|
||||
|
||||
## 1.14.6
|
||||
|
||||
@@ -973,7 +973,7 @@
|
||||
|
||||
## 1.12.21
|
||||
|
||||
* Fix unneccesary let scoping replacement.
|
||||
* Fix unnecessary let scoping replacement.
|
||||
* Add `commonInterop` module formatter. Thanks [@Naddiseo](https://github.com/Naddiseo).
|
||||
* Fix `return` outside of function body bug. Thanks [@brentburg](https://github.com/brentburg).
|
||||
* Add more flexible option types.
|
||||
@@ -1020,7 +1020,7 @@
|
||||
|
||||
## 1.12.12
|
||||
|
||||
* Make scope tracker more reliable to handle all edgecases.
|
||||
* Make scope tracker more reliable to handle all edge cases.
|
||||
|
||||
## 1.12.11
|
||||
|
||||
|
||||
4
.github/CHANGELOG-v4.md
vendored
4
.github/CHANGELOG-v4.md
vendored
@@ -127,7 +127,7 @@
|
||||
## 4.6.4
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix `ForOfStatement` not proplery inheriting labels.
|
||||
* Fix `ForOfStatement` not properly inheriting labels.
|
||||
* When in closure mode in block scoping transformer, properly check for variable shadowing.
|
||||
* **New Feature**
|
||||
* New `utility.inlineEnvironmentVariables` and `utility.inlineExpression` transformers.
|
||||
@@ -153,7 +153,7 @@
|
||||
* **Spec Compliancy**
|
||||
* `for...of` now outputs in a lengthy `try...catch` this is to ensure spec compliancy in regards to iterator returns and abrupt completions. See [google/traceur-compiler#1773](https://github.com/google/traceur-compiler/issues/1773) and [babel/babel/#838](https://github.com/babel/babel/issues/838) for more information.
|
||||
* **Polish**
|
||||
* Rest parameters that are only refered 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.
|
||||
* **Internal**
|
||||
* Upgrade `browserify`.
|
||||
|
||||
13
.github/CHANGELOG-v5.md
vendored
13
.github/CHANGELOG-v5.md
vendored
@@ -262,8 +262,8 @@ Issues with publish process.
|
||||
* Register labels as bindings to fix undeclared variable checks.
|
||||
* **Polish**
|
||||
* Remove unnecessary string binary expressions when transforming template literals.
|
||||
* Support module live bindings in arbitary positions not in Program statement position.
|
||||
* Throw error when attemping to replace a `Program` root node with another node not of type `Program`.
|
||||
* Support module live bindings in arbitrary positions not in Program statement position.
|
||||
* Throw error when attempting to replace a `Program` root node with another node not of type `Program`.
|
||||
* Optimise rest parameters in spread element position and allocate rest array at the earliest common ancestor of all references.
|
||||
* Generate original number representation when value was not changed.
|
||||
* Check for invalid binding identifiers when generating inferred method names.
|
||||
@@ -543,12 +543,12 @@ Issues with publish process.
|
||||
* **Internal**
|
||||
* Removed native inheritance support from classes.
|
||||
* Added `replaceWithSourceString` path API.
|
||||
* Split up `es3.propertyLiterals` and `es3.memberExpressionLiterals` transformers to `minfication.propertyLiterals` and `es3.memberExpressionLiterals`.
|
||||
* Split up `es3.propertyLiterals` and `es3.memberExpressionLiterals` transformers to `minification.propertyLiterals` and `es3.memberExpressionLiterals`.
|
||||
|
||||
## 5.2.6
|
||||
|
||||
* **Internal**
|
||||
* Fix transformer aliases being accidently set as deprecated ones.
|
||||
* Fix transformer aliases being accidentally set as deprecated ones.
|
||||
* Expose `Pipeline` as `TransformerPipeline` instead.
|
||||
|
||||
## 5.2.5
|
||||
@@ -824,10 +824,10 @@ Issues with publish process.
|
||||
* Save register cache on tick instead of `SIGINT`.
|
||||
* Enable strict mode on babel-node eval flag.
|
||||
* **Bug Fixes**
|
||||
* Add support for live bindings. This change also increases the reliablity of export specifier renaming.
|
||||
* Add support for live bindings. This change also increases the reliability of export specifier renaming.
|
||||
* Add support for super update and non equals assignment expressions.
|
||||
* Rename shadow constructor binding in classes.
|
||||
* Seed next iteration bindings with previous fresh bindings when reassinging loop block scoped variables.
|
||||
* Seed next iteration bindings with previous fresh bindings when reassigning loop block scoped variables.
|
||||
* Fix new expression spread referencing the wrong constructor.
|
||||
* Call `resolveModuleSource` on dynamic imports.
|
||||
* Added `param` to list of duplicate declaration kinds.
|
||||
@@ -836,4 +836,3 @@ Issues with publish process.
|
||||
* ES7 Abstract References have been removed.
|
||||
* Experimental option has been removed in favor of a stage option.
|
||||
* Rename `returnUsedHelpers` to `metadataUsedHelpers`.
|
||||
|
||||
14
.github/CHANGELOG-v6.md
vendored
14
.github/CHANGELOG-v6.md
vendored
@@ -19,7 +19,7 @@
|
||||
|
||||
## 6.26.0 (2017-08-16)
|
||||
|
||||
> Backports for some folks (also other's when we accidently 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.
|
||||
|
||||
#### :eyeglasses: Spec Compliancy
|
||||
@@ -1767,7 +1767,7 @@ typeof Symbol.prototype === 'object'
|
||||
* [#3456](https://github.com/babel/babel/pull/3456) Use the real sourcemap API and handle input sourcemaps - Fixes [#7259](https://github.com/babel/babel/issues/7259). ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* [#4507](https://github.com/babel/babel/pull/4507) Only set options in cli if different from default. ([@danez](https://github.com/danez))
|
||||
|
||||
Fix an issue with defaults not being overidden. This was causing options like `comments: false` not to work correctly.
|
||||
Fix an issue with defaults not being overridden. This was causing options like `comments: false` not to work correctly.
|
||||
|
||||
* [#4508](https://github.com/babel/babel/pull/4508) Support custom ports for V8 --inspect. ([@andykant](https://github.com/andykant))
|
||||
* [#4562](https://github.com/babel/babel/pull/4562) Fixes [#2299](https://github.com/babel/babel/issues/2299): Prevent REPL from printing implicit 'use strict'. ([@hzoo](https://github.com/hzoo))
|
||||
@@ -2084,7 +2084,7 @@ Also added more tests and will update Babel to use the new preset options after
|
||||
|
||||
## v6.13.1 (2016-08-04)
|
||||
|
||||
We had a regression in our new babel-preset-es2015@6.13.0 that made it unexpectedly backward-incompatible. This release introduces a new alternative plugin-options approach that is uglier but supports backward-compatiblity. Ideally new plugins would use the new `module.exports = function(babel, options){ }` approach and simple skip supporting `babel-core@<6.13.x`.
|
||||
We had a regression in our new babel-preset-es2015@6.13.0 that made it unexpectedly backward-incompatible. This release introduces a new alternative plugin-options approach that is uglier but supports backward-compatibility. Ideally new plugins would use the new `module.exports = function(babel, options){ }` approach and simple skip supporting `babel-core@<6.13.x`.
|
||||
|
||||
#### Bug Fix
|
||||
* `babel-core`, `babel-preset-es2015`
|
||||
@@ -2092,7 +2092,7 @@ We had a regression in our new babel-preset-es2015@6.13.0 that made it unexpecte
|
||||
|
||||
## v6.13.0 (2016-08-04)
|
||||
|
||||
> Since the last release we've created https://github.com/babel/notes to track discussions on our slack and high level features/changes that could be added - definetely check it out if you're interested in Babel's development!
|
||||
> Since the last release we've created https://github.com/babel/notes to track discussions on our slack and high level features/changes that could be added - definitely check it out if you're interested in Babel's development!
|
||||
|
||||
Some small but very important additions in this release:
|
||||
|
||||
@@ -3817,7 +3817,7 @@ Thanks to @samwgoldman for all the new flow support!
|
||||
* **New Feature**
|
||||
* Add support for `function.sent`.
|
||||
* **Internal**
|
||||
* Bump `invariant` depenency version.
|
||||
* Bump `invariant` dependency version.
|
||||
* **Polish**
|
||||
* Infer filename from the base directory when resolving plugins and presets.
|
||||
* Allow JSX pragma to be specified in line comments.
|
||||
@@ -3887,7 +3887,7 @@ Thanks to @samwgoldman for all the new flow support!
|
||||
## 6.1.2
|
||||
|
||||
* **Bug Fix**
|
||||
* Fix bug where the parser wouldn't allow typed annotated default parametesr in arrow functions.
|
||||
* Fix bug where the parser wouldn't allow typed annotated default parameters in arrow functions.
|
||||
* Add existence check to `NodePath#has` to ensure safeness when making comparisons.
|
||||
* Protect against replacing a class expression with a name inferred version that would
|
||||
result in it never being transformed.
|
||||
@@ -3976,7 +3976,7 @@ Thanks to @samwgoldman for all the new flow support!
|
||||
* Fix SystemJS module formatter exporting function parameters.
|
||||
* Ensure that invalid identifier JSX attribute keys are quoted when transforming to calls.
|
||||
* Fix ES3 property literal plugin.
|
||||
* Fix parameters after defaults in arrow functions refering to the wrong `arguments`.
|
||||
* Fix parameters after defaults in arrow functions referring to the wrong `arguments`.
|
||||
|
||||
## 6.0.13
|
||||
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -2,6 +2,8 @@
|
||||
Before making a PR, please read our contributing guidelines
|
||||
https://github.com/babel/babel/blob/master/CONTRIBUTING.md
|
||||
|
||||
Please note that the Babel Team requires two approvals before merging most PRs.
|
||||
|
||||
For issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR. (it should be underlined in the preview if done correctly)
|
||||
|
||||
If you are making a change that should have a docs update: submit another PR to https://github.com/babel/website
|
||||
|
||||
16
.github/actions/create-release-tag/Dockerfile
vendored
16
.github/actions/create-release-tag/Dockerfile
vendored
@@ -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"]
|
||||
14
.github/actions/create-release-tag/entrypoint.sh
vendored
14
.github/actions/create-release-tag/entrypoint.sh
vendored
@@ -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"
|
||||
16
.github/actions/filter-commit-message/Dockerfile
vendored
16
.github/actions/filter-commit-message/Dockerfile
vendored
@@ -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"]
|
||||
@@ -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
|
||||
@@ -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"]
|
||||
@@ -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 :)"
|
||||
1415
.github/actions/trigger-github-release/package-lock.json
generated
vendored
1415
.github/actions/trigger-github-release/package-lock.json
generated
vendored
File diff suppressed because it is too large
Load Diff
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
93
.github/main.workflow
vendored
93
.github/main.workflow
vendored
@@ -1,53 +1,76 @@
|
||||
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",
|
||||
]
|
||||
resolves = ["Trigger GitHub release"]
|
||||
}
|
||||
|
||||
action "Is version tag" {
|
||||
uses = "actions/bin/filter@0dbb077f64d0ec1068a644d25c71b1db66148a24"
|
||||
args = "tag v*"
|
||||
}
|
||||
|
||||
action "Is tag from master" {
|
||||
uses = "babel/actions/commit-matches-branch@master"
|
||||
needs = [
|
||||
"Is version tag",
|
||||
]
|
||||
args = "master"
|
||||
}
|
||||
|
||||
action "Trigger GitHub release" {
|
||||
uses = "./.github/actions/trigger-github-release/"
|
||||
uses = "babel/actions/trigger-github-release@master"
|
||||
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",
|
||||
"Is version tag",
|
||||
"Is tag from master",
|
||||
]
|
||||
}
|
||||
|
||||
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+)?$"
|
||||
workflow "Welcome" {
|
||||
resolves = [
|
||||
"Create Welcome Comment"
|
||||
]
|
||||
on = "issues"
|
||||
}
|
||||
|
||||
action "On master branch" {
|
||||
action "Is action 'opened'" {
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "branch master"
|
||||
args = "action opened"
|
||||
}
|
||||
|
||||
action "Create Welcome Comment" {
|
||||
uses = "babel/actions/create-welcome-comment@master"
|
||||
secrets = ["GITHUB_TOKEN", "BOT_TOKEN"]
|
||||
needs = ["Is action 'opened'"]
|
||||
}
|
||||
|
||||
workflow "Needs Info" {
|
||||
resolves = [
|
||||
"Create Needs Info Comment"
|
||||
]
|
||||
on = "issues"
|
||||
}
|
||||
|
||||
action "Is action 'labeled'" {
|
||||
uses = "actions/bin/filter@master"
|
||||
args = "action labeled"
|
||||
}
|
||||
|
||||
action "Has label 'Needs Info'" {
|
||||
uses = "actions/bin/filter@master"
|
||||
needs = [
|
||||
"Is action 'labeled'"
|
||||
]
|
||||
args = "label 'Needs Info'"
|
||||
}
|
||||
|
||||
action "Create Needs Info Comment" {
|
||||
uses = "babel/actions/create-needs-info-comment@master"
|
||||
needs = [
|
||||
"Has label 'Needs Info'",
|
||||
]
|
||||
secrets = ["BOT_TOKEN", "GITHUB_TOKEN"]
|
||||
}
|
||||
|
||||
183
CHANGELOG.md
183
CHANGELOG.md
@@ -18,6 +18,179 @@ 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.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)
|
||||
|
||||
#### :eyeglasses: Spec Compliance
|
||||
* `babel-parser`
|
||||
* [#10099](https://github.com/babel/babel/pull/10099) Disallow "let" as name at lexical bindings ([@g-plane](https://github.com/g-plane))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-parser`
|
||||
* [#10091](https://github.com/babel/babel/pull/10091) BigInt type for Flow ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* [#9450](https://github.com/babel/babel/pull/9450) Implement f# pipeline in parser ([@mAAdhaTTah](https://github.com/mAAdhaTTah))
|
||||
* [#9912](https://github.com/babel/babel/pull/9912) [legacy decorators] Allow decorating generator methods ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#9864](https://github.com/babel/babel/pull/9864) [@babel/parser] Add "allowUndeclaredExports" option ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-proposal-dynamic-import`, `babel-preset-env-standalone`, `babel-preset-env`
|
||||
* [#10109](https://github.com/babel/babel/pull/10109) Add @babel/plugin-proposal-dynamic-import to @babel/preset-env ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-proposal-dynamic-import`, `babel-plugin-transform-modules-amd`, `babel-plugin-transform-modules-commonjs`, `babel-plugin-transform-modules-systemjs`
|
||||
* [#9552](https://github.com/babel/babel/pull/9552) Create @babel/plugin-proposal-dynamic-import ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-proposal-pipeline-operator`, `babel-plugin-syntax-pipeline-operator`
|
||||
* [#9984](https://github.com/babel/babel/pull/9984) Transform for F# Pipeline ([@thiagoarrais](https://github.com/thiagoarrais))
|
||||
* `babel-plugin-transform-typescript`, `babel-types`
|
||||
* [#9785](https://github.com/babel/babel/pull/9785) Implement TypeScript namespace support ([@Wolvereness](https://github.com/Wolvereness))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-plugin-proposal-do-expressions`, `babel-traverse`
|
||||
* [#10072](https://github.com/babel/babel/pull/10072) fix await and yield for do expression ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* `babel-helpers`, `babel-plugin-transform-react-constant-elements`
|
||||
* [#10155](https://github.com/babel/babel/pull/10155) Added es3 backward compatibility for react helper code ([@sormy](https://github.com/sormy))
|
||||
* `babel-preset-env`
|
||||
* [#10127](https://github.com/babel/babel/pull/10127) Bump compat-table and updating preset-env mappings ([@existentialism](https://github.com/existentialism))
|
||||
* [#8897](https://github.com/babel/babel/pull/8897) Allow `defaults` query in preset-env ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-parser`
|
||||
* [#10132](https://github.com/babel/babel/pull/10132) fix import typeof in declare module ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* [#10084](https://github.com/babel/babel/pull/10084) flow - allow type parameter defaults in function declarations ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* `babel-types`
|
||||
* [#10126](https://github.com/babel/babel/pull/10126) fix exportKind declaration in babel-types ([@zxbodya](https://github.com/zxbodya))
|
||||
* `babel-node`
|
||||
* [#9951](https://github.com/babel/babel/pull/9951) Prevents exception on PnP ([@arcanis](https://github.com/arcanis))
|
||||
* `babel-generator`
|
||||
* [#10041](https://github.com/babel/babel/pull/10041) Fix printer for explicitly inexact Flow types ([@mrtnzlml](https://github.com/mrtnzlml))
|
||||
* `babel-plugin-transform-typescript`
|
||||
* [#10034](https://github.com/babel/babel/pull/10034) Use scope for typescript export removals ([@Wolvereness](https://github.com/Wolvereness))
|
||||
* [#10019](https://github.com/babel/babel/pull/10019) fix(typescript): erase default export if exporting a TS type ([@airato](https://github.com/airato))
|
||||
* `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-class-properties`, `babel-traverse`
|
||||
* [#10029](https://github.com/babel/babel/pull/10029) Fixed computed keys for class expression ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
|
||||
* [#9384](https://github.com/babel/babel/pull/9384) Retry to fix object spread helper compatibility ([@saschanaz](https://github.com/saschanaz))
|
||||
* `babel-plugin-transform-destructuring`
|
||||
* [#10013](https://github.com/babel/babel/pull/10013) fix destructuring rest with template literal ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* `babel-helper-create-class-features-plugin`, `babel-plugin-transform-typescript`
|
||||
* [#9610](https://github.com/babel/babel/pull/9610) Use `injectInitialization` to generate ts parameter properties ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-core`
|
||||
* [#10157](https://github.com/babel/babel/pull/10157) Fix incorrect usage of $o instead of %o in debug ([@ChlorideCull](https://github.com/ChlorideCull))
|
||||
* `babel-helpers`
|
||||
* [#10117](https://github.com/babel/babel/pull/10117) Simplify the helpers for classPrivateField{Get,Set} ([@arv](https://github.com/arv))
|
||||
* `babel-plugin-transform-typescript`
|
||||
* [#10047](https://github.com/babel/babel/pull/10047) Refactor isImportTypeOnly helper function ([@Andarist](https://github.com/Andarist))
|
||||
|
||||
#### :memo: Documentation
|
||||
* `babel-plugin-proposal-partial-application`, `babel-plugin-syntax-partial-application`
|
||||
* [#10103](https://github.com/babel/babel/pull/10103) docs: update readmes ([@xtuc](https://github.com/xtuc))
|
||||
|
||||
## v7.4.5 (2019-05-21)
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#9998](https://github.com/babel/babel/pull/9998) Fix location for optional params in arrow functions ([@danez](https://github.com/danez))
|
||||
* [#9982](https://github.com/babel/babel/pull/9982) Avoid unnecessary work during lookahead ([@danez](https://github.com/danez))
|
||||
* [#9922](https://github.com/babel/babel/pull/9922) fix: allow shebang directive ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* `babel-preset-env`
|
||||
* [#10002](https://github.com/babel/babel/pull/10002) Update preset-env dependencies and fix fixtures ([@danez](https://github.com/danez))
|
||||
* [#9978](https://github.com/babel/babel/pull/9978) Fix mobile browsers support in preset-env ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#9902](https://github.com/babel/babel/pull/9902) Fix destructuring assignments being transpiled for edge 15 ([@eps1lon](https://github.com/eps1lon))
|
||||
* `babel-plugin-transform-typescript`
|
||||
* [#9944](https://github.com/babel/babel/pull/9944) fix(typescript): erase type exports ([@airato](https://github.com/airato))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-parser`
|
||||
* [#9995](https://github.com/babel/babel/pull/9995) Do not use lookahead when parsing construct signature declarations in TS ([@danez](https://github.com/danez))
|
||||
* [#9989](https://github.com/babel/babel/pull/9989) Only compute Position if not already in state ([@danez](https://github.com/danez))
|
||||
* [#9988](https://github.com/babel/babel/pull/9988) Do not use lookahead when parsing jsx expression containers ([@danez](https://github.com/danez))
|
||||
* [#9987](https://github.com/babel/babel/pull/9987) Do not use lookahead when parsing imports in declare module in flow ([@danez](https://github.com/danez))
|
||||
* [#9985](https://github.com/babel/babel/pull/9985) Do not use lookahead when parsing declare module or declare module.exports in flow ([@danez](https://github.com/danez))
|
||||
* [#9983](https://github.com/babel/babel/pull/9983) Do not use lookahead when parsing dynamic import or import.meta ([@danez](https://github.com/danez))
|
||||
* [#9979](https://github.com/babel/babel/pull/9979) Remove guardedHandlers from ASTs ([@danez](https://github.com/danez))
|
||||
* `babel-preset-env`
|
||||
* [#9992](https://github.com/babel/babel/pull/9992) use console.warn for warning ([@schu34](https://github.com/schu34))
|
||||
* `babel-core`
|
||||
* [#9945](https://github.com/babel/babel/pull/9945) Fixed null error in plugin opts and added a test for it ([@divbhasin](https://github.com/divbhasin))
|
||||
* `babel-core`, `babel-traverse`
|
||||
* [#9909](https://github.com/babel/babel/pull/9909) Add missing space in error messages ([@pnavarrc](https://github.com/pnavarrc))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-node`
|
||||
* [#9914](https://github.com/babel/babel/pull/9914) [babel-node] Do not hardcode node flags ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
## v7.4.4 (2019-04-26)
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-plugin-transform-flow-comments`
|
||||
* [#9897](https://github.com/babel/babel/pull/9897) fix flow-comments - class type paramters and implements ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* [#9893](https://github.com/babel/babel/pull/9893) fix flow-comment - object destructuring ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* `babel-parser`
|
||||
* [#9766](https://github.com/babel/babel/pull/9766) Add TS support to @babel/parser's Scope ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#9865](https://github.com/babel/babel/pull/9865) Always register global bindings as exportable ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#9887](https://github.com/babel/babel/pull/9887) Fix TypeScript readonly error location ([@existentialism](https://github.com/existentialism))
|
||||
* [#9869](https://github.com/babel/babel/pull/9869) ! remove constant context assertions ([@tanhauhau](https://github.com/tanhauhau))
|
||||
* [#9890](https://github.com/babel/babel/pull/9890) Fix parsing typescript bodiless methods with the estree plugin also enabled ([@devongovett](https://github.com/devongovett))
|
||||
* `babel-traverse`
|
||||
* [#9870](https://github.com/babel/babel/pull/9870) Fix flow types in traverse/path/family and enable flow ([@danez](https://github.com/danez))
|
||||
* `babel-plugin-proposal-class-properties`, `babel-plugin-transform-modules-commonjs`, `babel-types`
|
||||
* [#9861](https://github.com/babel/babel/pull/9861) Fix: PrivateName Identifier should not be isReferenced. ([@coreyfarrell](https://github.com/coreyfarrell))
|
||||
* `babel-types`
|
||||
* [#9832](https://github.com/babel/babel/pull/9832) Fix typo in cloneNode. ([@evandervalk](https://github.com/evandervalk))
|
||||
|
||||
|
||||
## v7.4.3 (2019-04-02)
|
||||
|
||||
@@ -351,7 +524,7 @@ Thanks to @jamesgeorge007 and @armano2 for their first PR!
|
||||
* [#9271](https://github.com/babel/babel/pull/9271) Bump license years for 2019. ([@berlamhenderson](https://github.com/berlamhenderson))
|
||||
* `babel-helpers`
|
||||
* [#9166](https://github.com/babel/babel/pull/9166) Add mixins support to the _decorate helper. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
|
||||
## v7.2.5 (2018-12-21)
|
||||
|
||||
`@babel/polyfill` didn't get published correctly in v7.2.3 (#9227).
|
||||
@@ -382,7 +555,7 @@ Half of the commits in this release are made by first time contributors! Thanks
|
||||
|
||||
## v7.2.2 (2018-12-15)
|
||||
|
||||
Mostrly bug fixes and internal changes.
|
||||
Mostly bug fixes and internal changes.
|
||||
Thanks to @paleite, @saschanaz and @joeldenning for their first PRs!
|
||||
|
||||
#### :bug: Bug Fix
|
||||
@@ -724,7 +897,7 @@ No change from rc.4. Finally released as https://babeljs.io/blog/2018/08/27/7.0.
|
||||
|
||||
## v7.0.0-rc.2 (2018-08-21)
|
||||
|
||||
A notable change is the addition of https://github.com/babel/babel/pull/8485 which enables https://github.com/babel/babel-loader/pull/660 (automatically doing `modules: false` for `@babel/preset-env` when using `babel-loader`.
|
||||
A notable change is the addition of https://github.com/babel/babel/pull/8485 which enables https://github.com/babel/babel-loader/pull/660 (automatically doing `modules: false` for `@babel/preset-env` when using `babel-loader`.
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-core`
|
||||
@@ -879,7 +1052,7 @@ Breaking Change in beta:
|
||||
## v7.0.0-beta.53 (2018-07-11)
|
||||
|
||||
- Fix for regression with paths on windows due to micromatch upgrade, remove yearly presets (not published)
|
||||
- (There was an issue with the Stage presets in this release, but it is also deprecated)
|
||||
- (There was an issue with the Stage presets in this release, but it is also deprecated)
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-*`
|
||||
@@ -2533,7 +2706,7 @@ Initial release of typescript equivalent of how Babel handles flow with a new `b
|
||||
* `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))
|
||||
|
||||
> 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.
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-plugin-transform-flow-comments`
|
||||
|
||||
@@ -32,6 +32,7 @@ contributing, please read the
|
||||
- Follow along with what we are working on by joining our [Slack](https://babeljs.slack.com) (you can sign-up [here](https://slack.babeljs.io/)
|
||||
for an invite), following our announcements on [Twitter](https://twitter.com/babeljs), and reading (or participating!) in our [meeting notes](https://github.com/babel/notes).
|
||||
- Check out our [website](http://babeljs.io/) and the [repo](https://github.com/babel/website)
|
||||
- You can contribute by triaging issues which may include reproducing bug reports or asking for vital information, such as version numbers or reproduction instructions. If you would like to start triaging issues, one easy way to get started is to [subscribe to babel on CodeTriage](https://www.codetriage.com/babel/babel). [](https://www.codetriage.com/babel/babel)
|
||||
|
||||
## Chat
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ const merge = require("merge-stream");
|
||||
const rollup = require("rollup");
|
||||
const rollupBabel = require("rollup-plugin-babel");
|
||||
const rollupNodeResolve = require("rollup-plugin-node-resolve");
|
||||
const rollupReplace = require("rollup-plugin-replace");
|
||||
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");
|
||||
|
||||
const sources = ["codemods", "packages"];
|
||||
@@ -92,6 +93,9 @@ function buildRollup(packages) {
|
||||
.rollup({
|
||||
input,
|
||||
plugins: [
|
||||
rollupReplace({
|
||||
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
||||
}),
|
||||
rollupBabel({
|
||||
envName: "babel-parser",
|
||||
}),
|
||||
@@ -103,6 +107,7 @@ function buildRollup(packages) {
|
||||
file: path.join(pkg, "lib/index.js"),
|
||||
format: "cjs",
|
||||
name: "babel-parser",
|
||||
sourcemap: process.env.NODE_ENV !== "production",
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
4
Makefile
4
Makefile
@@ -1,5 +1,5 @@
|
||||
MAKEFLAGS = -j1
|
||||
FLOW_COMMIT = 2ac56861e3ceff9ca406ae586fbafb3480c6c0b7
|
||||
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
|
||||
TEST262_COMMIT = de567d3aa5de4eaa11e00131d26b9fe77997dfb0
|
||||
|
||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||
@@ -124,7 +124,7 @@ prepublish-build:
|
||||
rm -rf packages/babel-runtime/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/core-js
|
||||
BABEL_ENV=production make build-dist
|
||||
NODE_ENV=production BABEL_ENV=production make build-dist
|
||||
make clone-license
|
||||
|
||||
prepublish:
|
||||
|
||||
21
README.md
21
README.md
@@ -80,14 +80,14 @@ Try it out at our [REPL](https://babeljs.io/repl/build/master#?code_lz=NoRgNATGD
|
||||
|
||||
Mostly a handful of volunteers, funded by you! Please check out our [team page](https://babeljs.io/team)!
|
||||
|
||||
### Looking for support?
|
||||
|
||||
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
|
||||
|
||||
### Is there a Babel song?
|
||||
|
||||
I'm so glad you asked: [Hallelujah —— In Praise of Babel](SONG.md) by [@angus-c](https://github.com/angus-c), [audio version](https://youtu.be/40abpedBKK8) by [@swyx](https://twitter.com/@swyx). Tweet us your recordings!
|
||||
|
||||
### Looking for support?
|
||||
|
||||
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
|
||||
|
||||
### Where are the docs?
|
||||
|
||||
Check out our website: [babeljs.io](https://babeljs.io/), and report issues/features at [babel/website](https://github.com/babel/website/issues).
|
||||
@@ -98,12 +98,19 @@ Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) and fill out the issu
|
||||
|
||||
### Want to contribute to Babel?
|
||||
|
||||
Check out our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
|
||||
Check out:
|
||||
|
||||
- If you have already joined Slack, join our [#development](https://babeljs.slack.com/messages/development) channel and say hi!
|
||||
- Check out the issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the closed ones to get a sense of the kinds of issues you can tackle.
|
||||
- Our [#development](https://babeljs.slack.com/messages/development) Slack channel and say hi ([signup](https://slack.babeljs.io))!
|
||||
- Issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the [closed ones](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aclosed+label%3A%22good+first+issue%22) to get a sense of the kinds of issues you can tackle.
|
||||
|
||||
Some resources:
|
||||
|
||||
- Our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
|
||||
- Our discussions/notes/roadmap: [babel/notes](https://github.com/babel/notes)
|
||||
- Our progress on TC39 proposals: [babel/proposals](https://github.com/babel/proposals)
|
||||
- Our blog which contains release posts and explainations: [/blog](https://babeljs.io/blog)
|
||||
- Our videos page with talks about open source and Babel: [/videos](https://babeljs.io/videos)
|
||||
- Our [podcast](https://podcast.babeljs.io)
|
||||
|
||||
### How is the repo structured?
|
||||
|
||||
|
||||
19
SECURITY.md
Normal file
19
SECURITY.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
This is the list of versions of `babel` which are
|
||||
currently being supported with security updates.
|
||||
|
||||
| Version | Supported |
|
||||
| -------- | ------------------ |
|
||||
| 7.x | :white_check_mark: |
|
||||
| 6.26.x | :white_check_mark: |
|
||||
| < 6.26.0 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
To report a vulnerability please send an email with the details to security@babeljs.io.
|
||||
This will help us to assess the risk and start the necessary steps.
|
||||
|
||||
Thanks for helping to keep babel secure.
|
||||
@@ -123,7 +123,7 @@ module.exports = function(api) {
|
||||
],
|
||||
plugins: [
|
||||
includeRuntime
|
||||
? ["@babel/transform-runtime", { version: "7.4.0" }]
|
||||
? ["@babel/transform-runtime", { version: "7.4.4" }]
|
||||
: null,
|
||||
].filter(Boolean),
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
@@ -10,7 +10,8 @@
|
||||
"PR: Bug Fix :bug:": ":bug: Bug Fix",
|
||||
"PR: Polish :nail_care:": ":nail_care: Polish",
|
||||
"PR: Docs :memo:": ":memo: Documentation",
|
||||
"PR: Internal :house:": ":house: Internal"
|
||||
"PR: Internal :house:": ":house: Internal",
|
||||
"PR: Performance :running_woman:": ":running_woman: Performance"
|
||||
}
|
||||
},
|
||||
"command": {
|
||||
|
||||
@@ -165,7 +165,7 @@ declare module "source-map" {
|
||||
}
|
||||
|
||||
declare module "convert-source-map" {
|
||||
import type { SourceMap } from "source-map";
|
||||
import type { SourceMap, SourceMapGenerator } from "source-map";
|
||||
|
||||
declare class Converter {
|
||||
toJSON(): string;
|
||||
@@ -177,11 +177,11 @@ declare module "convert-source-map" {
|
||||
declare module.exports: {
|
||||
SourceMap: SourceMap,
|
||||
Converter: Converter,
|
||||
fromObject(obj: SourceMap): Converter,
|
||||
fromObject(obj: SourceMap | SourceMapGenerator): Converter,
|
||||
fromJSON(str: string): Converter,
|
||||
fromBase64(str: string): Converter,
|
||||
fromComment(str: string): Converter,
|
||||
fromMapFileComment(str: string): Converter,
|
||||
fromMapFileComment(str: string, dir: string): Converter,
|
||||
fromSource(str: string): Converter,
|
||||
fromMapFileSource(str: string, dir: string): Converter,
|
||||
removeComments(str: string): string,
|
||||
|
||||
56
package.json
56
package.json
@@ -9,38 +9,38 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.3",
|
||||
"@babel/core": "^7.4.0",
|
||||
"@babel/cli": "^7.4.4",
|
||||
"@babel/core": "^7.4.5",
|
||||
"@babel/eslint-plugin-development": "^1.0.1",
|
||||
"@babel/plugin-proposal-class-properties": "^7.4.0",
|
||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.4.0",
|
||||
"@babel/plugin-transform-runtime": "^7.4.0",
|
||||
"@babel/preset-env": "^7.4.1",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
|
||||
"@babel/plugin-transform-runtime": "^7.4.4",
|
||||
"@babel/preset-env": "^7.4.5",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/register": "^7.4.0",
|
||||
"@babel/runtime": "^7.4.0",
|
||||
"@babel/register": "^7.4.4",
|
||||
"@babel/runtime": "^7.4.5",
|
||||
"babel-eslint": "^11.0.0-beta.0",
|
||||
"babel-jest": "^24.5.0",
|
||||
"babel-loader": "^8.0.5",
|
||||
"babel-jest": "^24.8.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-transform-charcodes": "^0.2.0",
|
||||
"browserify": "^16.2.3",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"chalk": "^2.3.2",
|
||||
"chalk": "^2.4.2",
|
||||
"charcodes": "^0.2.0",
|
||||
"derequire": "^2.0.2",
|
||||
"duplicate-package-checker-webpack-plugin": "^2.1.0",
|
||||
"enhanced-resolve": "^3.0.0",
|
||||
"eslint": "^5.15.1",
|
||||
"eslint": "^6.0.1",
|
||||
"eslint-config-babel": "^9.0.0",
|
||||
"eslint-plugin-flowtype": "^3.2.1",
|
||||
"eslint-plugin-import": "^2.16.0",
|
||||
"eslint-plugin-prettier": "^3.0.1",
|
||||
"eslint-plugin-flowtype": "^3.8.2",
|
||||
"eslint-plugin-import": "^2.17.2",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"fancy-log": "^1.3.3",
|
||||
"flow-bin": "^0.94.0",
|
||||
"flow-bin": "^0.102.0",
|
||||
"graceful-fs": "^4.1.15",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-babel": "^8.0.0",
|
||||
"gulp-filter": "^5.1.0",
|
||||
"gulp-newer": "^1.0.0",
|
||||
@@ -48,20 +48,21 @@
|
||||
"gulp-rename": "^1.4.0",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"gulp-watch": "^5.0.1",
|
||||
"husky": "^1.3.1",
|
||||
"jest": "^24.5.0",
|
||||
"lerna": "^3.6.0",
|
||||
"husky": "^3.0.0",
|
||||
"jest": "^24.8.0",
|
||||
"lerna": "^3.16.0",
|
||||
"lerna-changelog": "^0.5.0",
|
||||
"lint-staged": "^8.1.0",
|
||||
"lodash": "^4.17.11",
|
||||
"lint-staged": "^9.2.0",
|
||||
"lodash": "^4.17.13",
|
||||
"merge-stream": "^1.0.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "^1.16.1",
|
||||
"prettier": "^1.17.1",
|
||||
"pump": "^3.0.0",
|
||||
"rimraf": "^2.6.3",
|
||||
"rollup": "^1.6.0",
|
||||
"rollup": "^1.12.0",
|
||||
"rollup-plugin-babel": "^4.0.0",
|
||||
"rollup-plugin-node-resolve": "^4.0.1",
|
||||
"rollup-plugin-node-resolve": "^5.0.0",
|
||||
"rollup-plugin-replace": "^2.2.0",
|
||||
"test262-stream": "^1.2.0",
|
||||
"through2": "^2.0.0",
|
||||
"warnings-to-errors-webpack-plugin": "^2.0.0",
|
||||
@@ -70,7 +71,7 @@
|
||||
"webpack-stream": "^4.0.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"@lerna/**/@lerna/collect-updates": "https://github.com/nicolo-ribaudo/lerna.git#babel-collect-updates"
|
||||
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.9.0 < 13.0.0",
|
||||
@@ -133,6 +134,5 @@
|
||||
"moduleNameMapper": {
|
||||
"^@babel/([a-zA-Z0-9_-]+)$": "<rootDir>/packages/babel-$1/"
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -23,21 +23,21 @@
|
||||
"convert-source-map": "^1.1.0",
|
||||
"fs-readdir-recursive": "^1.1.0",
|
||||
"glob": "^7.0.0",
|
||||
"lodash": "^4.17.11",
|
||||
"lodash": "^4.17.13",
|
||||
"mkdirp": "^0.5.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"slash": "^2.0.0",
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"chokidar": "^2.0.4"
|
||||
"chokidar": "^2.1.8"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/helper-fixtures": "^7.4.4"
|
||||
"@babel/core": "^7.6.0",
|
||||
"@babel/helper-fixtures": "^7.6.0"
|
||||
},
|
||||
"bin": {
|
||||
"babel": "./bin/babel.js",
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
// @flow
|
||||
|
||||
import commander from "commander";
|
||||
import { buildExternalHelpers } from "@babel/core";
|
||||
|
||||
function collect(value, previousValue): Array<string> {
|
||||
function collect(
|
||||
value: string | any,
|
||||
previousValue: Array<string>,
|
||||
): Array<string> {
|
||||
// If the user passed the option with no value, like "babel-external-helpers --whitelist", do nothing.
|
||||
if (typeof value !== "string") return previousValue;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @flow
|
||||
|
||||
import defaults from "lodash/defaults";
|
||||
import outputFileSync from "output-file-sync";
|
||||
import { sync as mkdirpSync } from "mkdirp";
|
||||
@@ -6,11 +8,15 @@ import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
import * as util from "./util";
|
||||
import { type CmdOptions } from "./options";
|
||||
|
||||
export default async function({ cliOptions, babelOptions }) {
|
||||
export default async function({
|
||||
cliOptions,
|
||||
babelOptions,
|
||||
}: CmdOptions): Promise<void> {
|
||||
const filenames = cliOptions.filenames;
|
||||
|
||||
async function write(src, base) {
|
||||
async function write(src: string, base: string): Promise<boolean> {
|
||||
let relative = path.relative(base, src);
|
||||
|
||||
if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
|
||||
@@ -65,14 +71,14 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
}
|
||||
}
|
||||
|
||||
function getDest(filename, base) {
|
||||
function getDest(filename: string, base: string): string {
|
||||
if (cliOptions.relative) {
|
||||
return path.join(base, cliOptions.outDir, filename);
|
||||
}
|
||||
return path.join(cliOptions.outDir, filename);
|
||||
}
|
||||
|
||||
async function handleFile(src, base) {
|
||||
async function handleFile(src: string, base: string): Promise<boolean> {
|
||||
const written = await write(src, base);
|
||||
|
||||
if (!written && cliOptions.copyFiles) {
|
||||
@@ -84,7 +90,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
return written;
|
||||
}
|
||||
|
||||
async function handle(filenameOrDir) {
|
||||
async function handle(filenameOrDir: string): Promise<number> {
|
||||
if (!fs.existsSync(filenameOrDir)) return 0;
|
||||
|
||||
const stat = fs.statSync(filenameOrDir);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @flow
|
||||
|
||||
import convertSourceMap from "convert-source-map";
|
||||
import defaults from "lodash/defaults";
|
||||
import sourceMap from "source-map";
|
||||
@@ -6,9 +8,18 @@ import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
import * as util from "./util";
|
||||
import { type CmdOptions } from "./options";
|
||||
|
||||
export default async function({ cliOptions, babelOptions }) {
|
||||
function buildResult(fileResults) {
|
||||
type CompilationOutput = {
|
||||
code: string,
|
||||
map: Object,
|
||||
};
|
||||
|
||||
export default async function({
|
||||
cliOptions,
|
||||
babelOptions,
|
||||
}: CmdOptions): Promise<void> {
|
||||
function buildResult(fileResults: Array<Object>): CompilationOutput {
|
||||
const map = new sourceMap.SourceMapGenerator({
|
||||
file:
|
||||
cliOptions.sourceMapTarget ||
|
||||
@@ -74,7 +85,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
};
|
||||
}
|
||||
|
||||
function output(fileResults) {
|
||||
function output(fileResults: Array<string>): void {
|
||||
const result = buildResult(fileResults);
|
||||
|
||||
if (cliOptions.outFile) {
|
||||
@@ -91,14 +102,15 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
}
|
||||
}
|
||||
|
||||
function readStdin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
function readStdin(): Promise<string> {
|
||||
return new Promise((resolve: Function, reject: Function): void => {
|
||||
let code = "";
|
||||
|
||||
process.stdin.setEncoding("utf8");
|
||||
|
||||
process.stdin.on("readable", function() {
|
||||
const chunk = process.stdin.read();
|
||||
// $FlowIgnore
|
||||
if (chunk !== null) code += chunk;
|
||||
});
|
||||
|
||||
@@ -109,7 +121,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
});
|
||||
}
|
||||
|
||||
async function stdin() {
|
||||
async function stdin(): Promise<void> {
|
||||
const code = await readStdin();
|
||||
|
||||
const res = await util.transform(
|
||||
@@ -126,7 +138,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
output([res]);
|
||||
}
|
||||
|
||||
async function walk(filenames) {
|
||||
async function walk(filenames: Array<string>): Promise<void> {
|
||||
const _filenames = [];
|
||||
|
||||
filenames.forEach(function(filename) {
|
||||
@@ -151,7 +163,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
});
|
||||
|
||||
const results = await Promise.all(
|
||||
_filenames.map(async function(filename) {
|
||||
_filenames.map(async function(filename: string): Promise<Object> {
|
||||
let sourceFilename = filename;
|
||||
if (cliOptions.outFile) {
|
||||
sourceFilename = path.relative(
|
||||
@@ -168,7 +180,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
{
|
||||
sourceFileName: sourceFilename,
|
||||
// Since we're compiling everything to be merged together,
|
||||
// "inline" applies to the final output file, but to the individual
|
||||
// "inline" applies to the final output file, but not to the individual
|
||||
// files being concatenated.
|
||||
sourceMaps:
|
||||
babelOptions.sourceMaps === "inline"
|
||||
@@ -192,7 +204,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
output(results);
|
||||
}
|
||||
|
||||
async function files(filenames) {
|
||||
async function files(filenames: Array<string>): Promise<void> {
|
||||
if (!cliOptions.skipInitialBuild) {
|
||||
await walk(filenames);
|
||||
}
|
||||
@@ -208,7 +220,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
pollInterval: 10,
|
||||
},
|
||||
})
|
||||
.on("all", function(type, filename) {
|
||||
.on("all", function(type: string, filename: string) {
|
||||
if (!util.isCompilableExtension(filename, cliOptions.extensions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// @flow
|
||||
|
||||
import fs from "fs";
|
||||
|
||||
import commander from "commander";
|
||||
@@ -151,7 +153,12 @@ commander.option(
|
||||
commander.version(pkg.version + " (@babel/core " + version + ")");
|
||||
commander.usage("[options] <files ...>");
|
||||
|
||||
export default function parseArgv(args: Array<string>) {
|
||||
export type CmdOptions = {
|
||||
babelOptions: Object,
|
||||
cliOptions: Object,
|
||||
};
|
||||
|
||||
export default function parseArgv(args: Array<string>): CmdOptions {
|
||||
//
|
||||
commander.parse(args);
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
// @flow
|
||||
|
||||
import readdirRecursive from "fs-readdir-recursive";
|
||||
import * as babel from "@babel/core";
|
||||
import includes from "lodash/includes";
|
||||
import path from "path";
|
||||
import fs from "fs";
|
||||
|
||||
export function chmod(src, dest) {
|
||||
export function chmod(src: string, dest: string): void {
|
||||
fs.chmodSync(dest, fs.statSync(src).mode);
|
||||
}
|
||||
|
||||
@@ -13,8 +15,8 @@ type ReaddirFilter = (filename: string) => boolean;
|
||||
export function readdir(
|
||||
dirname: string,
|
||||
includeDotfiles: boolean,
|
||||
filter: ReaddirFilter,
|
||||
) {
|
||||
filter?: ReaddirFilter,
|
||||
): Array<string> {
|
||||
return readdirRecursive(dirname, (filename, _index, currentDirectory) => {
|
||||
const stat = fs.statSync(path.join(currentDirectory, filename));
|
||||
|
||||
@@ -30,7 +32,7 @@ export function readdirForCompilable(
|
||||
dirname: string,
|
||||
includeDotfiles: boolean,
|
||||
altExts?: Array<string>,
|
||||
) {
|
||||
): Array<string> {
|
||||
return readdir(dirname, includeDotfiles, function(filename) {
|
||||
return isCompilableExtension(filename, altExts);
|
||||
});
|
||||
@@ -48,7 +50,7 @@ export function isCompilableExtension(
|
||||
return includes(exts, ext);
|
||||
}
|
||||
|
||||
export function addSourceMappingUrl(code, loc) {
|
||||
export function addSourceMappingUrl(code: string, loc: string): string {
|
||||
return code + "\n//# sourceMappingURL=" + path.basename(loc);
|
||||
}
|
||||
|
||||
@@ -56,7 +58,11 @@ const CALLER = {
|
||||
name: "@babel/cli",
|
||||
};
|
||||
|
||||
export function transform(filename, code, opts) {
|
||||
export function transform(
|
||||
filename: string,
|
||||
code: string,
|
||||
opts: Object,
|
||||
): Promise<Object> {
|
||||
opts = {
|
||||
...opts,
|
||||
caller: CALLER,
|
||||
@@ -71,7 +77,10 @@ export function transform(filename, code, opts) {
|
||||
});
|
||||
}
|
||||
|
||||
export function compile(filename, opts) {
|
||||
export function compile(
|
||||
filename: string,
|
||||
opts: Object | Function,
|
||||
): Promise<Object> {
|
||||
opts = {
|
||||
...opts,
|
||||
caller: CALLER,
|
||||
@@ -85,7 +94,7 @@ export function compile(filename, opts) {
|
||||
});
|
||||
}
|
||||
|
||||
export function deleteDir(path) {
|
||||
export function deleteDir(path: string): void {
|
||||
if (fs.existsSync(path)) {
|
||||
fs.readdirSync(path).forEach(function(file) {
|
||||
const curPath = path + "/" + file;
|
||||
@@ -106,7 +115,7 @@ process.on("uncaughtException", function(err) {
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
export function requireChokidar() {
|
||||
export function requireChokidar(): Object {
|
||||
try {
|
||||
return require("chokidar");
|
||||
} catch (err) {
|
||||
@@ -118,7 +127,10 @@ export function requireChokidar() {
|
||||
}
|
||||
}
|
||||
|
||||
export function adjustRelative(relative, keepFileExtension) {
|
||||
export function adjustRelative(
|
||||
relative: string,
|
||||
keepFileExtension: boolean,
|
||||
): string {
|
||||
if (keepFileExtension) {
|
||||
return relative;
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ const assertTest = function(stdout, stderr, opts, cwd) {
|
||||
}
|
||||
|
||||
if (opts.outFiles) {
|
||||
const actualFiles = readDir(path.join(tmpLoc), fileFilter);
|
||||
const actualFiles = readDir(tmpLoc, fileFilter);
|
||||
|
||||
Object.keys(actualFiles).forEach(function(filename) {
|
||||
if (
|
||||
// saveInFiles always creates an empty .babelrc, so lets exclude for now
|
||||
filename !== ".babelrc" &&
|
||||
!opts.inFiles.hasOwnProperty(filename)
|
||||
!Object.prototype.hasOwnProperty.call(opts.inFiles, filename)
|
||||
) {
|
||||
const expected = opts.outFiles[filename];
|
||||
const actual = actualFiles[filename];
|
||||
@@ -171,12 +171,12 @@ const buildTest = function(binName, testName, opts) {
|
||||
};
|
||||
|
||||
fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
||||
if (binName[0] === ".") return;
|
||||
if (binName.startsWith(".")) return;
|
||||
|
||||
const suiteLoc = path.join(fixtureLoc, binName);
|
||||
describe("bin/" + binName, function() {
|
||||
fs.readdirSync(suiteLoc).forEach(function(testName) {
|
||||
if (testName[0] === ".") return;
|
||||
if (testName.startsWith(".")) return;
|
||||
|
||||
const testLoc = path.join(suiteLoc, testName);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/code-frame",
|
||||
"version": "7.0.0",
|
||||
"version": "7.5.5",
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
|
||||
@@ -76,7 +76,7 @@ function getMarkerLines(
|
||||
} else if (i === 0) {
|
||||
const sourceLength = source[lineNumber - 1].length;
|
||||
|
||||
markerLines[lineNumber] = [startColumn, sourceLength - startColumn];
|
||||
markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];
|
||||
} else if (i === lineDiff) {
|
||||
markerLines[lineNumber] = [0, endColumn];
|
||||
} else {
|
||||
@@ -112,15 +112,16 @@ export function codeFrameColumns(
|
||||
const maybeHighlight = (chalkFn, string) => {
|
||||
return highlighted ? chalkFn(string) : string;
|
||||
};
|
||||
if (highlighted) rawLines = highlight(rawLines, opts);
|
||||
|
||||
const lines = rawLines.split(NEWLINE);
|
||||
const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
|
||||
const hasColumns = loc.start && typeof loc.start.column === "number";
|
||||
|
||||
const numberMaxWidth = String(end).length;
|
||||
|
||||
let frame = lines
|
||||
const highlightedLines = highlighted ? highlight(rawLines, opts) : rawLines;
|
||||
|
||||
let frame = highlightedLines
|
||||
.split(NEWLINE)
|
||||
.slice(start, end)
|
||||
.map((line, index) => {
|
||||
const number = start + 1 + index;
|
||||
|
||||
@@ -102,6 +102,45 @@ describe("@babel/code-frame", function() {
|
||||
);
|
||||
});
|
||||
|
||||
test("opts.highlightCode with multiple columns and lines", function() {
|
||||
// prettier-ignore
|
||||
const rawLines = [
|
||||
"function a(b, c) {",
|
||||
" return b + c;",
|
||||
"}"
|
||||
].join("\n");
|
||||
|
||||
const result = codeFrameColumns(
|
||||
rawLines,
|
||||
{
|
||||
start: {
|
||||
line: 1,
|
||||
column: 1,
|
||||
},
|
||||
end: {
|
||||
line: 3,
|
||||
column: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
highlightCode: true,
|
||||
message: "Message about things",
|
||||
},
|
||||
);
|
||||
const stripped = stripAnsi(result);
|
||||
expect(stripped).toEqual(
|
||||
// prettier-ignore
|
||||
[
|
||||
"> 1 | function a(b, c) {",
|
||||
" | ^^^^^^^^^^^^^^^^^^",
|
||||
"> 2 | return b + c;",
|
||||
" | ^^^^^^^^^^^^^^^",
|
||||
"> 3 | }",
|
||||
" | ^ Message about things",
|
||||
].join('\n'),
|
||||
);
|
||||
});
|
||||
|
||||
test("opts.linesAbove", function() {
|
||||
const rawLines = [
|
||||
"/**",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
@@ -33,23 +33,23 @@
|
||||
"./lib/transform-file.js": "./lib/transform-file-browser.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.4.4",
|
||||
"@babel/helpers": "^7.4.4",
|
||||
"@babel/parser": "^7.4.4",
|
||||
"@babel/template": "^7.4.4",
|
||||
"@babel/traverse": "^7.4.4",
|
||||
"@babel/types": "^7.4.4",
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/generator": "^7.6.0",
|
||||
"@babel/helpers": "^7.6.0",
|
||||
"@babel/parser": "^7.6.0",
|
||||
"@babel/template": "^7.6.0",
|
||||
"@babel/traverse": "^7.6.0",
|
||||
"@babel/types": "^7.6.0",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^4.1.0",
|
||||
"json5": "^2.1.0",
|
||||
"lodash": "^4.17.11",
|
||||
"lodash": "^4.17.13",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.4.4",
|
||||
"@babel/register": "^7.4.4"
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.6.0",
|
||||
"@babel/register": "^7.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,13 +268,11 @@ function babelrcLoadEnabled(
|
||||
});
|
||||
}
|
||||
|
||||
const validateConfigFile = makeWeakCache(
|
||||
(file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("configfile", file.options),
|
||||
}),
|
||||
);
|
||||
const validateConfigFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("configfile", file.options),
|
||||
}));
|
||||
|
||||
const validateBabelrcFile = makeWeakCache(
|
||||
(file: ConfigFile): ValidatedFile => ({
|
||||
@@ -284,13 +282,11 @@ const validateBabelrcFile = makeWeakCache(
|
||||
}),
|
||||
);
|
||||
|
||||
const validateExtendFile = makeWeakCache(
|
||||
(file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("extendsfile", file.options),
|
||||
}),
|
||||
);
|
||||
const validateExtendFile = makeWeakCache((file: ConfigFile): ValidatedFile => ({
|
||||
filepath: file.filepath,
|
||||
dirname: file.dirname,
|
||||
options: validate("extendsfile", file.options),
|
||||
}));
|
||||
|
||||
/**
|
||||
* Build a config chain for just the programmatic options passed into Babel.
|
||||
@@ -549,7 +545,7 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
|
||||
|
||||
// "sourceMap" is just aliased to sourceMap, so copy it over as
|
||||
// we merge the options together.
|
||||
if (options.hasOwnProperty("sourceMap")) {
|
||||
if (Object.prototype.hasOwnProperty.call(options, "sourceMap")) {
|
||||
options.sourceMaps = options.sourceMap;
|
||||
delete options.sourceMap;
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export function findRootConfig(
|
||||
|
||||
const conf = readConfig(filepath, envName, caller);
|
||||
if (conf) {
|
||||
debug("Found root config %o in $o.", BABEL_CONFIG_JS_FILENAME, dirname);
|
||||
debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname);
|
||||
}
|
||||
return conf;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ export function loadConfig(
|
||||
throw new Error(`Config file ${filepath} contains no configuration data`);
|
||||
}
|
||||
|
||||
debug("Loaded config %o from $o.", name, dirname);
|
||||
debug("Loaded config %o from %o.", name, dirname);
|
||||
return conf;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import { validatePluginObject } from "./validation/plugins";
|
||||
import makeAPI from "./helpers/config-api";
|
||||
|
||||
import loadPrivatePartialConfig from "./partial";
|
||||
import type { ValidatedOptions } from "./validation/options";
|
||||
|
||||
type LoadedDescriptor = {
|
||||
value: {},
|
||||
@@ -202,7 +203,7 @@ const loadDescriptor = makeWeakCache(
|
||||
if (typeof item.then === "function") {
|
||||
throw new Error(
|
||||
`You appear to be using an async 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 your @babel/core version.`,
|
||||
);
|
||||
@@ -278,6 +279,42 @@ const instantiatePlugin = makeWeakCache(
|
||||
},
|
||||
);
|
||||
|
||||
const validateIfOptionNeedsFilename = (
|
||||
options: ValidatedOptions,
|
||||
descriptor: UnloadedDescriptor,
|
||||
): void => {
|
||||
if (options.test || options.include || options.exclude) {
|
||||
const formattedPresetName = descriptor.name
|
||||
? `"${descriptor.name}"`
|
||||
: "/* your preset */";
|
||||
throw new Error(
|
||||
[
|
||||
`Preset ${formattedPresetName} requires a filename to be set when babel is called directly,`,
|
||||
`\`\`\``,
|
||||
`babel.transform(code, { filename: 'file.ts', presets: [${formattedPresetName}] });`,
|
||||
`\`\`\``,
|
||||
`See https://babeljs.io/docs/en/options#filename for more information.`,
|
||||
].join("\n"),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const validatePreset = (
|
||||
preset: PresetInstance,
|
||||
context: ConfigContext,
|
||||
descriptor: UnloadedDescriptor,
|
||||
): void => {
|
||||
if (!context.filename) {
|
||||
const { options } = preset;
|
||||
validateIfOptionNeedsFilename(options, descriptor);
|
||||
if (options.overrides) {
|
||||
options.overrides.forEach(overrideOptions =>
|
||||
validateIfOptionNeedsFilename(overrideOptions, descriptor),
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a config object that will act as the root of a new nested config.
|
||||
*/
|
||||
@@ -285,10 +322,9 @@ const loadPresetDescriptor = (
|
||||
descriptor: UnloadedDescriptor,
|
||||
context: ConfigContext,
|
||||
): ConfigChain | null => {
|
||||
return buildPresetChain(
|
||||
instantiatePreset(loadDescriptor(descriptor, context)),
|
||||
context,
|
||||
);
|
||||
const preset = instantiatePreset(loadDescriptor(descriptor, context));
|
||||
validatePreset(preset, context, descriptor);
|
||||
return buildPresetChain(preset, context);
|
||||
};
|
||||
|
||||
const instantiatePreset = makeWeakCache(
|
||||
|
||||
@@ -231,7 +231,7 @@ function assertIgnoreItem(loc: GeneralPath, value: mixed): IgnoreItem {
|
||||
throw new Error(
|
||||
`${msg(
|
||||
loc,
|
||||
)} must be an array of string/Funtion/RegExp values, or undefined`,
|
||||
)} must be an array of string/Function/RegExp values, or undefined`,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
@@ -278,7 +278,7 @@ export function assertConfigFileSearch(
|
||||
) {
|
||||
throw new Error(
|
||||
`${msg(loc)} must be a undefined, a boolean, a string, ` +
|
||||
`got ${JSON.stringify(value)}`,
|
||||
`got ${JSON.stringify((value: any))}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ export function assertBabelrcSearch(
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error(
|
||||
`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` +
|
||||
`or an array of those, got ${JSON.stringify(value)}`,
|
||||
`or an array of those, got ${JSON.stringify((value: any))}`,
|
||||
);
|
||||
}
|
||||
return (value: any);
|
||||
@@ -337,7 +337,7 @@ function assertPluginItem(loc: GeneralPath, value: mixed): PluginItem {
|
||||
if (
|
||||
opts !== undefined &&
|
||||
opts !== false &&
|
||||
(typeof opts !== "object" || Array.isArray(opts))
|
||||
(typeof opts !== "object" || Array.isArray(opts) || opts === null)
|
||||
) {
|
||||
throw new Error(
|
||||
`${msg(access(loc, 1))} must be an object, false, or undefined`,
|
||||
|
||||
@@ -183,7 +183,7 @@ export default class File {
|
||||
// and this fails because a prerelease version can only satisfy a range
|
||||
// if it is a prerelease within the same major/minor/patch range.
|
||||
//
|
||||
// Note: If this is found to have issues, please also revist the logic in
|
||||
// Note: If this is found to have issues, please also revisit the logic in
|
||||
// transform-runtime's definitions.js file.
|
||||
if (semver.valid(versionRange)) versionRange = `^${versionRange}`;
|
||||
|
||||
@@ -203,6 +203,9 @@ export default class File {
|
||||
if (res) return res;
|
||||
}
|
||||
|
||||
// make sure that the helper exists
|
||||
helpers.ensure(name);
|
||||
|
||||
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
|
||||
name,
|
||||
));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @flow
|
||||
|
||||
import type { PluginPasses } from "../../config";
|
||||
import convertSourceMap, { type SourceMap } from "convert-source-map";
|
||||
import convertSourceMap, { typeof SourceMap } from "convert-source-map";
|
||||
import generate from "@babel/generator";
|
||||
|
||||
import type File from "./file";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
|
||||
import type { SourceMap } from "convert-source-map";
|
||||
import typeof { SourceMap } from "convert-source-map";
|
||||
import sourceMap from "source-map";
|
||||
|
||||
export default function mergeSourceMap(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// @flow
|
||||
import traverse from "@babel/traverse";
|
||||
import type { SourceMap } from "convert-source-map";
|
||||
import typeof { SourceMap } from "convert-source-map";
|
||||
|
||||
import type { ResolvedConfig, PluginPasses } from "../config";
|
||||
|
||||
@@ -93,7 +93,7 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
|
||||
if (isThenable(result)) {
|
||||
throw new Error(
|
||||
`You appear to be using an plugin with an async .pre, ` +
|
||||
`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 ` +
|
||||
`your @babel/core version.`,
|
||||
);
|
||||
@@ -117,7 +117,7 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
|
||||
if (isThenable(result)) {
|
||||
throw new Error(
|
||||
`You appear to be using an plugin with an async .post, ` +
|
||||
`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 ` +
|
||||
`your @babel/core version.`,
|
||||
);
|
||||
|
||||
@@ -27,49 +27,6 @@ export default function normalizeFile(
|
||||
): File {
|
||||
code = `${code || ""}`;
|
||||
|
||||
let inputMap = null;
|
||||
if (options.inputSourceMap !== false) {
|
||||
// If an explicit object is passed in, it overrides the processing of
|
||||
// source maps that may be in the file itself.
|
||||
if (typeof options.inputSourceMap === "object") {
|
||||
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
try {
|
||||
inputMap = convertSourceMap.fromSource(code);
|
||||
|
||||
if (inputMap) {
|
||||
code = convertSourceMap.removeComments(code);
|
||||
}
|
||||
} catch (err) {
|
||||
debug("discarding unknown inline input sourcemap", err);
|
||||
code = convertSourceMap.removeComments(code);
|
||||
}
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
if (typeof options.filename === "string") {
|
||||
try {
|
||||
inputMap = convertSourceMap.fromMapFileSource(
|
||||
code,
|
||||
path.dirname(options.filename),
|
||||
);
|
||||
|
||||
if (inputMap) {
|
||||
code = convertSourceMap.removeMapFileComments(code);
|
||||
}
|
||||
} catch (err) {
|
||||
debug("discarding unknown file input sourcemap", err);
|
||||
code = convertSourceMap.removeMapFileComments(code);
|
||||
}
|
||||
} else {
|
||||
debug("discarding un-loadable file input sourcemap");
|
||||
code = convertSourceMap.removeMapFileComments(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ast) {
|
||||
if (ast.type === "Program") {
|
||||
ast = t.file(ast, [], []);
|
||||
@@ -84,6 +41,42 @@ export default function normalizeFile(
|
||||
ast = parser(pluginPasses, options, code);
|
||||
}
|
||||
|
||||
let inputMap = null;
|
||||
if (options.inputSourceMap !== false) {
|
||||
// If an explicit object is passed in, it overrides the processing of
|
||||
// source maps that may be in the file itself.
|
||||
if (typeof options.inputSourceMap === "object") {
|
||||
inputMap = convertSourceMap.fromObject(options.inputSourceMap);
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
|
||||
if (lastComment) {
|
||||
try {
|
||||
inputMap = convertSourceMap.fromComment(lastComment);
|
||||
} catch (err) {
|
||||
debug("discarding unknown inline input sourcemap", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!inputMap) {
|
||||
const lastComment = extractComments(EXTERNAL_SOURCEMAP_REGEX, ast);
|
||||
if (typeof options.filename === "string" && lastComment) {
|
||||
try {
|
||||
inputMap = convertSourceMap.fromMapFileComment(
|
||||
lastComment,
|
||||
path.dirname(options.filename),
|
||||
);
|
||||
} catch (err) {
|
||||
debug("discarding unknown file input sourcemap", err);
|
||||
}
|
||||
} else if (lastComment) {
|
||||
debug("discarding un-loadable file input sourcemap");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new File(options, {
|
||||
code,
|
||||
ast,
|
||||
@@ -156,3 +149,48 @@ function parser(
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// These regexps are copied from the convert-source-map package,
|
||||
// but without // or /* at the beginning of the comment.
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
||||
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$/;
|
||||
|
||||
function extractCommentsFromList(regex, comments, lastComment) {
|
||||
if (comments) {
|
||||
comments = comments.filter(({ value }) => {
|
||||
if (regex.test(value)) {
|
||||
lastComment = value;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
return [comments, lastComment];
|
||||
}
|
||||
|
||||
function extractComments(regex, ast) {
|
||||
let lastComment = null;
|
||||
t.traverseFast(ast, node => {
|
||||
// $FlowIgnore destructuring with expressions is not supported
|
||||
[node.leadingComments, lastComment] = extractCommentsFromList(
|
||||
regex,
|
||||
node.leadingComments,
|
||||
lastComment,
|
||||
);
|
||||
// $FlowIgnore destructuring with expressions is not supported
|
||||
[node.innerComments, lastComment] = extractCommentsFromList(
|
||||
regex,
|
||||
node.innerComments,
|
||||
lastComment,
|
||||
);
|
||||
// $FlowIgnore destructuring with expressions is not supported
|
||||
[node.trailingComments, lastComment] = extractCommentsFromList(
|
||||
regex,
|
||||
node.trailingComments,
|
||||
lastComment,
|
||||
);
|
||||
});
|
||||
return lastComment;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1049,5 +1049,27 @@ describe("buildConfigChain", function() {
|
||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
||||
).toThrow(/Error while parsing JSON - /);
|
||||
});
|
||||
|
||||
it("should throw when `test` presents but `filename` is not passed", () => {
|
||||
expect(() => loadOptions({ test: /\.ts$/, plugins: [] })).toThrow(
|
||||
/Configuration contains string\/RegExp pattern/,
|
||||
);
|
||||
});
|
||||
|
||||
it("should throw when `preset` requires `filename` but it was not passed", () => {
|
||||
expect(() => {
|
||||
loadOptions({
|
||||
presets: [require("./fixtures/config-loading/preset4")],
|
||||
});
|
||||
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
|
||||
});
|
||||
|
||||
it("should throw when `preset.overrides` requires `filename` but it was not passed", () => {
|
||||
expect(() => {
|
||||
loadOptions({
|
||||
presets: [require("./fixtures/config-loading/preset5")],
|
||||
});
|
||||
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
6
packages/babel-core/test/fixtures/config-loading/preset4.js
vendored
Normal file
6
packages/babel-core/test/fixtures/config-loading/preset4.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
test: /\.ts$/,
|
||||
plugins: []
|
||||
}
|
||||
};
|
||||
8
packages/babel-core/test/fixtures/config-loading/preset5.js
vendored
Normal file
8
packages/babel-core/test/fixtures/config-loading/preset5.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = function() {
|
||||
return {
|
||||
overrides: [{
|
||||
test: /\.ts$/,
|
||||
plugins: []
|
||||
}]
|
||||
}
|
||||
};
|
||||
8
packages/babel-core/test/fixtures/transformation/source-maps/comment-inside-string/input.js
vendored
Normal file
8
packages/babel-core/test/fixtures/transformation/source-maps/comment-inside-string/input.js
vendored
Normal 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>`;
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"inputSourceMap": true
|
||||
}
|
||||
5
packages/babel-core/test/fixtures/transformation/source-maps/comment-inside-string/output.js
vendored
Normal file
5
packages/babel-core/test/fixtures/transformation/source-maps/comment-inside-string/output.js
vendored
Normal 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>`;
|
||||
@@ -38,6 +38,17 @@ describe("option-manager", () => {
|
||||
expect(calls).toEqual([]);
|
||||
});
|
||||
|
||||
it("throws for null options", () => {
|
||||
const { calls, plugin } = makePlugin();
|
||||
expect(() => {
|
||||
loadOptions({
|
||||
plugins: [[plugin, null]],
|
||||
}).toThrow(/.plugins[0][1] must be an object, false, or undefined/);
|
||||
});
|
||||
|
||||
expect(calls).toEqual([]);
|
||||
});
|
||||
|
||||
it("should not throw if a repeated plugin has a different name", () => {
|
||||
const { calls: calls1, plugin: plugin1 } = makePlugin();
|
||||
const { calls: calls2, plugin: plugin2 } = makePlugin();
|
||||
@@ -87,7 +98,6 @@ describe("option-manager", () => {
|
||||
expect(calls1).toEqual([{ arg: 1 }]);
|
||||
expect(calls2).toEqual([{ arg: 2 }]);
|
||||
});
|
||||
|
||||
it("should merge .env[] presets with parent presets", () => {
|
||||
const { calls: calls1, plugin: preset1 } = makePlugin();
|
||||
const { calls: calls2, plugin: preset2 } = makePlugin();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/generator",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"description": "Turns an AST into code.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -14,14 +14,14 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.4.4",
|
||||
"@babel/types": "^7.6.0",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.17.11",
|
||||
"lodash": "^4.17.13",
|
||||
"source-map": "^0.5.0",
|
||||
"trim-right": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-fixtures": "^7.4.4",
|
||||
"@babel/parser": "^7.4.4"
|
||||
"@babel/helper-fixtures": "^7.6.0",
|
||||
"@babel/parser": "^7.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ export default class Buffer {
|
||||
source(prop: string, loc: Location, force?: boolean): void {
|
||||
if (prop && !loc) return;
|
||||
|
||||
// Since this is called extremly often, we re-use the same _sourcePosition
|
||||
// Since this is called extremely often, we re-use the same _sourcePosition
|
||||
// object for the whole lifetime of the buffer.
|
||||
this._normalizePosition(prop, loc, this._sourcePosition, force);
|
||||
}
|
||||
|
||||
@@ -264,3 +264,8 @@ export function PrivateName(node: Object) {
|
||||
this.token("#");
|
||||
this.print(node.id, node);
|
||||
}
|
||||
|
||||
export function V8IntrinsicIdentifier(node: Object) {
|
||||
this.token("%");
|
||||
this.word(node.name);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ export function ObjectTypeAnnotation(node: Object) {
|
||||
indent: true,
|
||||
statement: true,
|
||||
iterator: () => {
|
||||
if (props.length !== 1) {
|
||||
if (props.length !== 1 || node.inexact) {
|
||||
this.token(",");
|
||||
this.space();
|
||||
}
|
||||
@@ -419,6 +419,15 @@ export function ObjectTypeAnnotation(node: Object) {
|
||||
this.space();
|
||||
}
|
||||
|
||||
if (node.inexact) {
|
||||
this.indent();
|
||||
this.token("...");
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.dedent();
|
||||
}
|
||||
|
||||
if (node.exact) {
|
||||
this.token("|}");
|
||||
} else {
|
||||
|
||||
@@ -67,12 +67,14 @@ export function TSQualifiedName(node) {
|
||||
|
||||
export function TSCallSignatureDeclaration(node) {
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.token(";");
|
||||
}
|
||||
|
||||
export function TSPropertySignature(node) {
|
||||
@@ -127,6 +129,9 @@ export function TSIndexSignature(node) {
|
||||
export function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
}
|
||||
export function TSBigIntKeyword() {
|
||||
this.word("bigint");
|
||||
}
|
||||
export function TSUnknownKeyword() {
|
||||
this.word("unknown");
|
||||
}
|
||||
|
||||
@@ -97,5 +97,18 @@ export function needsParens(node, parent, printStack) {
|
||||
if (isOrHasCallExpression(node)) return true;
|
||||
}
|
||||
|
||||
/* this check is for NullishCoalescing being used with LogicalOperators like && and ||
|
||||
* For example when someone creates an ast programmaticaly like this
|
||||
* t.logicalExpression(
|
||||
* "??",
|
||||
* t.logicalExpression("||", t.identifier("a"), t.identifier("b")),
|
||||
* t.identifier("c"),
|
||||
* );
|
||||
* In the example above the AST is equivalent to writing a || b ?? c
|
||||
* This is incorrect because NullishCoalescing when used with LogicalExpressions should have parenthesis
|
||||
* The correct syntax is (a || b) ?? c, that is why we need parenthesis in this case
|
||||
*/
|
||||
if (t.isLogicalExpression(node) && parent.operator === "??") return true;
|
||||
|
||||
return find(expandedParens, node, parent, printStack);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"parserOpts": {"createParenthesizedExpressions": true}
|
||||
"parserOpts": { "createParenthesizedExpressions": true }
|
||||
}
|
||||
|
||||
4
packages/babel-generator/test/fixtures/flow/object-literal-types-compact/input.js
vendored
Normal file
4
packages/babel-generator/test/fixtures/flow/object-literal-types-compact/input.js
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
type T1 = { ... };
|
||||
type T2 = { a: { b: { c: {...}, ... }, ... } }
|
||||
type T3 = { foo: number, ... };
|
||||
type T4 = { foo: number, bar: string, ... };
|
||||
3
packages/babel-generator/test/fixtures/flow/object-literal-types-compact/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/flow/object-literal-types-compact/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"compact": true
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/flow/object-literal-types-compact/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/flow/object-literal-types-compact/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
type T1={...};type T2={a:{b:{c:{...},...},...}};type T3={foo:number,...};type T4={foo:number,bar:string,...};
|
||||
@@ -9,3 +9,7 @@ type T6 = { foo(): number }
|
||||
type T7 = { foo: () => number }
|
||||
type T8 = { [string]: U };
|
||||
type T9 = { [param: string]: U };
|
||||
type T10 = { ... };
|
||||
type T11 = { a: { b: { c: {...}, ... }, ... } }
|
||||
type T12 = { foo: number, ... };
|
||||
type T13 = { foo: number, bar: string, ... };
|
||||
|
||||
@@ -27,4 +27,23 @@ type T8 = {
|
||||
};
|
||||
type T9 = {
|
||||
[param: string]: U
|
||||
};
|
||||
};
|
||||
type T10 = {...};
|
||||
type T11 = {
|
||||
a: {
|
||||
b: {
|
||||
c: {...},
|
||||
...
|
||||
},
|
||||
...
|
||||
}
|
||||
};
|
||||
type T12 = {
|
||||
foo: number,
|
||||
...
|
||||
};
|
||||
type T13 = {
|
||||
foo: number,
|
||||
bar: string,
|
||||
...
|
||||
};
|
||||
|
||||
1
packages/babel-generator/test/fixtures/misc/V8IntrinsicIdentifier/input.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/misc/V8IntrinsicIdentifier/input.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
%DebugPrint(foo);
|
||||
3
packages/babel-generator/test/fixtures/misc/V8IntrinsicIdentifier/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/misc/V8IntrinsicIdentifier/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["v8intrinsic"]
|
||||
}
|
||||
1
packages/babel-generator/test/fixtures/misc/V8IntrinsicIdentifier/output.js
vendored
Normal file
1
packages/babel-generator/test/fixtures/misc/V8IntrinsicIdentifier/output.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
%DebugPrint(foo);
|
||||
@@ -1,4 +1,5 @@
|
||||
foo ||bar;
|
||||
(x => x)|| bar;
|
||||
(function a(x){return x;})|| 2;
|
||||
0||(function(){return alpha;});
|
||||
0||(function(){return alpha;});
|
||||
a ?? (b || c);
|
||||
|
||||
3
packages/babel-generator/test/fixtures/types/LogicalExpression/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/types/LogicalExpression/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"plugins": ["nullishCoalescingOperator"]
|
||||
}
|
||||
@@ -7,4 +7,6 @@ foo || bar;
|
||||
|
||||
0 || function () {
|
||||
return alpha;
|
||||
};
|
||||
};
|
||||
|
||||
a ?? (b || c);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
interface I {
|
||||
(x: number): void;
|
||||
(x: string): void;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
interface I {
|
||||
(x: number): void
|
||||
}
|
||||
(x: number): void;
|
||||
(x: string): void;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
interface I {
|
||||
new (x: number): void;
|
||||
new (x: string): void;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
interface I {
|
||||
new (x: number): void
|
||||
}
|
||||
new (x: number): void;
|
||||
new (x: string): void;
|
||||
}
|
||||
|
||||
@@ -298,6 +298,31 @@ describe("generation", function() {
|
||||
});
|
||||
|
||||
describe("programmatic generation", function() {
|
||||
it("should add parenthesis when NullishCoalescing is used along with ||", function() {
|
||||
// https://github.com/babel/babel/issues/10260
|
||||
const nullishCoalesc = t.logicalExpression(
|
||||
"??",
|
||||
t.logicalExpression("||", t.identifier("a"), t.identifier("b")),
|
||||
t.identifier("c"),
|
||||
);
|
||||
const output = generate(nullishCoalesc).code;
|
||||
expect(output).toBe(`(a || b) ?? c`);
|
||||
});
|
||||
|
||||
it("should add parenthesis when NullishCoalesing is used with &&", function() {
|
||||
const nullishCoalesc = t.logicalExpression(
|
||||
"??",
|
||||
t.identifier("a"),
|
||||
t.logicalExpression(
|
||||
"&&",
|
||||
t.identifier("b"),
|
||||
t.logicalExpression("&&", t.identifier("c"), t.identifier("d")),
|
||||
),
|
||||
);
|
||||
const output = generate(nullishCoalesc).code;
|
||||
expect(output).toBe(`a ?? (b && c && d)`);
|
||||
});
|
||||
|
||||
it("numeric member expression", function() {
|
||||
// Should not generate `0.foo`
|
||||
const mem = t.memberExpression(
|
||||
@@ -427,7 +452,7 @@ describe("programmatic generation", function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe("typescript generate parantheses if necessary", function() {
|
||||
describe("typescript generate parentheses if necessary", function() {
|
||||
it("wraps around union for array", () => {
|
||||
const typeStatement = t.TSArrayType(
|
||||
t.TSUnionType([
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-create-class-features-plugin",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"author": "The Babel Team (https://babeljs.io/team)",
|
||||
"license": "MIT",
|
||||
"description": "Compile class public and private fields, private methods and decorators to ES6",
|
||||
@@ -15,17 +15,17 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-function-name": "^7.1.0",
|
||||
"@babel/helper-member-expression-to-functions": "^7.0.0",
|
||||
"@babel/helper-member-expression-to-functions": "^7.5.5",
|
||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
||||
"@babel/helper-plugin-utils": "^7.0.0",
|
||||
"@babel/helper-replace-supers": "^7.4.4",
|
||||
"@babel/helper-replace-supers": "^7.5.5",
|
||||
"@babel/helper-split-export-declaration": "^7.4.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/core": "^7.6.0",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,12 +66,6 @@ export function verifyUsedFeatures(path, file) {
|
||||
if (!hasFeature(file, FEATURES.privateMethods)) {
|
||||
throw path.buildCodeFrameError("Class private methods are not enabled.");
|
||||
}
|
||||
|
||||
if (path.node.static && path.node.kind !== "method") {
|
||||
throw path.buildCodeFrameError(
|
||||
"@babel/plugin-class-features doesn't support class static private accessors yet.",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@@ -44,6 +44,7 @@ export function buildPrivateNamesNodes(privateNamesMap, loose, state) {
|
||||
// because static fields are directly assigned to a variable in the
|
||||
// buildPrivateStaticFieldInitSpec function.
|
||||
const { id, static: isStatic, method: isMethod, getId, setId } = value;
|
||||
const isAccessor = getId || setId;
|
||||
if (loose) {
|
||||
initNodes.push(
|
||||
template.statement.ast`
|
||||
@@ -51,7 +52,7 @@ export function buildPrivateNamesNodes(privateNamesMap, loose, state) {
|
||||
`,
|
||||
);
|
||||
} else if (isMethod && !isStatic) {
|
||||
if (getId || setId) {
|
||||
if (isAccessor) {
|
||||
initNodes.push(template.statement.ast`var ${id} = new WeakMap();`);
|
||||
} else {
|
||||
initNodes.push(template.statement.ast`var ${id} = new WeakSet();`);
|
||||
@@ -140,11 +141,13 @@ const privateNameHandlerSpec = {
|
||||
getId,
|
||||
setId,
|
||||
} = privateNamesMap.get(name);
|
||||
const isAccessor = getId || setId;
|
||||
|
||||
if (isStatic) {
|
||||
const helperName = isMethod
|
||||
? "classStaticPrivateMethodGet"
|
||||
: "classStaticPrivateFieldSpecGet";
|
||||
const helperName =
|
||||
isMethod && !isAccessor
|
||||
? "classStaticPrivateMethodGet"
|
||||
: "classStaticPrivateFieldSpecGet";
|
||||
|
||||
return t.callExpression(file.addHelper(helperName), [
|
||||
this.receiver(member),
|
||||
@@ -154,7 +157,7 @@ const privateNameHandlerSpec = {
|
||||
}
|
||||
|
||||
if (isMethod) {
|
||||
if (getId || setId) {
|
||||
if (isAccessor) {
|
||||
return t.callExpression(file.addHelper("classPrivateFieldGet"), [
|
||||
this.receiver(member),
|
||||
t.cloneNode(id),
|
||||
@@ -180,12 +183,15 @@ const privateNameHandlerSpec = {
|
||||
static: isStatic,
|
||||
method: isMethod,
|
||||
setId,
|
||||
getId,
|
||||
} = privateNamesMap.get(name);
|
||||
const isAccessor = getId || setId;
|
||||
|
||||
if (isStatic) {
|
||||
const helperName = isMethod
|
||||
? "classStaticPrivateMethodSet"
|
||||
: "classStaticPrivateFieldSpecSet";
|
||||
const helperName =
|
||||
isMethod && !isAccessor
|
||||
? "classStaticPrivateMethodSet"
|
||||
: "classStaticPrivateFieldSpecSet";
|
||||
|
||||
return t.callExpression(file.addHelper(helperName), [
|
||||
this.receiver(member),
|
||||
@@ -211,6 +217,19 @@ const privateNameHandlerSpec = {
|
||||
]);
|
||||
},
|
||||
|
||||
destructureSet(member) {
|
||||
const { privateNamesMap, file } = this;
|
||||
const { name } = member.node.property.id;
|
||||
const { id } = privateNamesMap.get(name);
|
||||
return t.memberExpression(
|
||||
t.callExpression(file.addHelper("classPrivateFieldDestructureSet"), [
|
||||
this.receiver(member),
|
||||
t.cloneNode(id),
|
||||
]),
|
||||
t.identifier("value"),
|
||||
);
|
||||
},
|
||||
|
||||
call(member, args) {
|
||||
// The first access (the get) should do the memo assignment.
|
||||
this.memoise(member, 1);
|
||||
@@ -287,9 +306,30 @@ function buildPrivateInstanceFieldInitSpec(ref, prop, privateNamesMap) {
|
||||
}
|
||||
|
||||
function buildPrivateStaticFieldInitSpec(prop, privateNamesMap) {
|
||||
const { id } = privateNamesMap.get(prop.node.key.id.name);
|
||||
const value = prop.node.value || prop.scope.buildUndefinedNode();
|
||||
const privateName = privateNamesMap.get(prop.node.key.id.name);
|
||||
const { id, getId, setId, initAdded } = privateName;
|
||||
const isAccessor = getId || setId;
|
||||
|
||||
if (!prop.isProperty() && (initAdded || !isAccessor)) return;
|
||||
|
||||
if (isAccessor) {
|
||||
privateNamesMap.set(prop.node.key.id.name, {
|
||||
...privateName,
|
||||
initAdded: true,
|
||||
});
|
||||
|
||||
return template.statement.ast`
|
||||
var ${id.name} = {
|
||||
// configurable is false by default
|
||||
// enumerable is false by default
|
||||
// writable is false by default
|
||||
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
|
||||
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
const value = prop.node.value || prop.scope.buildUndefinedNode();
|
||||
return template.statement.ast`
|
||||
var ${id} = {
|
||||
// configurable is false by default
|
||||
@@ -315,76 +355,44 @@ function buildPrivateMethodInitLoose(ref, prop, privateNamesMap) {
|
||||
});
|
||||
`;
|
||||
}
|
||||
|
||||
if (getId || setId) {
|
||||
const isAccessor = getId || setId;
|
||||
if (isAccessor) {
|
||||
privateNamesMap.set(prop.node.key.id.name, {
|
||||
...privateName,
|
||||
initAdded: true,
|
||||
});
|
||||
|
||||
if (getId && setId) {
|
||||
return template.statement.ast`
|
||||
Object.defineProperty(${ref}, ${id}, {
|
||||
// configurable is false by default
|
||||
// enumerable is false by default
|
||||
// writable is false by default
|
||||
get: ${getId.name},
|
||||
set: ${setId.name}
|
||||
});
|
||||
`;
|
||||
} else if (getId && !setId) {
|
||||
return template.statement.ast`
|
||||
Object.defineProperty(${ref}, ${id}, {
|
||||
// configurable is false by default
|
||||
// enumerable is false by default
|
||||
// writable is false by default
|
||||
get: ${getId.name}
|
||||
});
|
||||
`;
|
||||
} else if (!getId && setId) {
|
||||
return template.statement.ast`
|
||||
Object.defineProperty(${ref}, ${id}, {
|
||||
// configurable is false by default
|
||||
// enumerable is false by default
|
||||
// writable is false by default
|
||||
set: ${setId.name}
|
||||
});
|
||||
`;
|
||||
}
|
||||
return template.statement.ast`
|
||||
Object.defineProperty(${ref}, ${id}, {
|
||||
// configurable is false by default
|
||||
// enumerable is false by default
|
||||
// writable is false by default
|
||||
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
|
||||
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
|
||||
});
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
function buildPrivateInstanceMethodInitSpec(ref, prop, privateNamesMap) {
|
||||
const privateName = privateNamesMap.get(prop.node.key.id.name);
|
||||
const { id, getId, setId, initAdded } = privateName;
|
||||
|
||||
if (initAdded) return;
|
||||
|
||||
if (getId || setId) {
|
||||
const isAccessor = getId || setId;
|
||||
if (isAccessor) {
|
||||
privateNamesMap.set(prop.node.key.id.name, {
|
||||
...privateName,
|
||||
initAdded: true,
|
||||
});
|
||||
|
||||
if (getId && setId) {
|
||||
return template.statement.ast`
|
||||
${id}.set(${ref}, {
|
||||
get: ${getId.name},
|
||||
set: ${setId.name}
|
||||
});
|
||||
`;
|
||||
} else if (getId && !setId) {
|
||||
return template.statement.ast`
|
||||
${id}.set(${ref}, {
|
||||
get: ${getId.name}
|
||||
});
|
||||
`;
|
||||
} else if (!getId && setId) {
|
||||
return template.statement.ast`
|
||||
${id}.set(${ref}, {
|
||||
set: ${setId.name}
|
||||
});
|
||||
`;
|
||||
}
|
||||
return template.statement.ast`
|
||||
${id}.set(${ref}, {
|
||||
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
|
||||
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
|
||||
});
|
||||
`;
|
||||
}
|
||||
return template.statement.ast`${id}.add(${ref})`;
|
||||
}
|
||||
@@ -416,7 +424,29 @@ function buildPublicFieldInitSpec(ref, prop, state) {
|
||||
}
|
||||
|
||||
function buildPrivateStaticMethodInitLoose(ref, prop, state, privateNamesMap) {
|
||||
const { id, methodId } = privateNamesMap.get(prop.node.key.id.name);
|
||||
const privateName = privateNamesMap.get(prop.node.key.id.name);
|
||||
const { id, methodId, getId, setId, initAdded } = privateName;
|
||||
|
||||
if (initAdded) return;
|
||||
|
||||
const isAccessor = getId || setId;
|
||||
if (isAccessor) {
|
||||
privateNamesMap.set(prop.node.key.id.name, {
|
||||
...privateName,
|
||||
initAdded: true,
|
||||
});
|
||||
|
||||
return template.statement.ast`
|
||||
Object.defineProperty(${ref}, ${id}, {
|
||||
// configurable is false by default
|
||||
// enumerable is false by default
|
||||
// writable is false by default
|
||||
get: ${getId ? getId.name : prop.scope.buildUndefinedNode()},
|
||||
set: ${setId ? setId.name : prop.scope.buildUndefinedNode()}
|
||||
})
|
||||
`;
|
||||
}
|
||||
|
||||
return template.statement.ast`
|
||||
Object.defineProperty(${ref}, ${id}, {
|
||||
// configurable is false by default
|
||||
@@ -602,14 +632,14 @@ export function buildFieldsInitNodes(
|
||||
case isStatic && isPrivate && isMethod && !loose:
|
||||
needsClassRef = true;
|
||||
staticNodes.push(
|
||||
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
|
||||
);
|
||||
staticNodes.unshift(
|
||||
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
|
||||
);
|
||||
break;
|
||||
case isStatic && isPrivate && isMethod && loose:
|
||||
needsClassRef = true;
|
||||
staticNodes.push(
|
||||
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
|
||||
);
|
||||
staticNodes.push(
|
||||
buildPrivateStaticMethodInitLoose(
|
||||
t.cloneNode(ref),
|
||||
@@ -618,6 +648,9 @@ export function buildFieldsInitNodes(
|
||||
privateNamesMap,
|
||||
),
|
||||
);
|
||||
staticNodes.unshift(
|
||||
buildPrivateMethodDeclaration(prop, privateNamesMap, loose),
|
||||
);
|
||||
break;
|
||||
case isInstance && isPublic && isField && loose:
|
||||
instanceNodes.push(buildPublicFieldInitLoose(t.thisExpression(), prop));
|
||||
@@ -633,7 +666,7 @@ export function buildFieldsInitNodes(
|
||||
}
|
||||
|
||||
return {
|
||||
staticNodes,
|
||||
staticNodes: staticNodes.filter(Boolean),
|
||||
instanceNodes: instanceNodes.filter(Boolean),
|
||||
wrapClass(path) {
|
||||
for (const prop of props) {
|
||||
|
||||
@@ -21,11 +21,11 @@ import {
|
||||
|
||||
import pkg from "../package.json";
|
||||
|
||||
export { FEATURES };
|
||||
export { FEATURES, injectInitialization };
|
||||
|
||||
// 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 relese x.y.z where x, y or z are
|
||||
// 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 versionKey = "@babel/plugin-class-features/version";
|
||||
|
||||
@@ -98,10 +98,16 @@ export function extractComputedKeys(ref, path, computedPaths, file) {
|
||||
const ident = path.scope.generateUidIdentifierBasedOnNode(
|
||||
computedNode.key,
|
||||
);
|
||||
// Declaring in the same block scope
|
||||
// Ref: https://github.com/babel/babel/pull/10029/files#diff-fbbdd83e7a9c998721c1484529c2ce92
|
||||
path.scope.push({
|
||||
id: ident,
|
||||
kind: "let",
|
||||
});
|
||||
declarations.push(
|
||||
t.variableDeclaration("var", [
|
||||
t.variableDeclarator(ident, computedNode.key),
|
||||
]),
|
||||
t.expressionStatement(
|
||||
t.assignmentExpression("=", t.cloneNode(ident), computedNode.key),
|
||||
),
|
||||
);
|
||||
computedNode.key = t.cloneNode(ident);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{
|
||||
"plugins": [
|
||||
["proposal-private-methods", { "loose": false }]
|
||||
]
|
||||
"plugins": [["proposal-private-methods", { "loose": false }]]
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
{
|
||||
"plugins": [
|
||||
["proposal-private-methods", { "loose": true }]
|
||||
]
|
||||
"plugins": [["proposal-private-methods", { "loose": true }]]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-define-map",
|
||||
"version": "7.4.4",
|
||||
"version": "7.5.5",
|
||||
"description": "Helper function to define a map",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-define-map",
|
||||
"license": "MIT",
|
||||
@@ -10,7 +10,7 @@
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-function-name": "^7.1.0",
|
||||
"@babel/types": "^7.4.4",
|
||||
"lodash": "^4.17.11"
|
||||
"@babel/types": "^7.5.5",
|
||||
"lodash": "^4.17.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-fixtures",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"description": "Helper function to support fixtures",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"license": "MIT",
|
||||
@@ -10,7 +10,7 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-fixtures",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11",
|
||||
"lodash": "^4.17.13",
|
||||
"semver": "^5.3.0",
|
||||
"try-resolve": "^1.0.0"
|
||||
}
|
||||
|
||||
@@ -120,6 +120,8 @@ export default function get(entryLoc): Array<Suite> {
|
||||
const expectLoc =
|
||||
findFile(taskDir + "/output", true /* allowJSON */) ||
|
||||
taskDir + "/output.js";
|
||||
const stdoutLoc = taskDir + "/stdout.txt";
|
||||
const stderrLoc = taskDir + "/stderr.txt";
|
||||
|
||||
const actualLocAlias =
|
||||
suiteName + "/" + taskName + "/" + path.basename(actualLoc);
|
||||
@@ -146,6 +148,10 @@ export default function get(entryLoc): Array<Suite> {
|
||||
title: humanize(taskName, true),
|
||||
disabled: taskName[0] === ".",
|
||||
options: taskOpts,
|
||||
validateLogs: taskOpts.validateLogs,
|
||||
ignoreOutput: taskOpts.ignoreOutput,
|
||||
stdout: { loc: stdoutLoc, code: readFile(stdoutLoc) },
|
||||
stderr: { loc: stderrLoc, code: readFile(stderrLoc) },
|
||||
exec: {
|
||||
loc: execLoc,
|
||||
code: readFile(execLoc),
|
||||
@@ -169,9 +175,7 @@ export default function get(entryLoc): Array<Suite> {
|
||||
|
||||
if (minimumVersion == null) {
|
||||
throw new Error(
|
||||
`'minNodeVersion' has invalid semver format: ${
|
||||
taskOpts.minNodeVersion
|
||||
}`,
|
||||
`'minNodeVersion' has invalid semver format: ${taskOpts.minNodeVersion}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -224,6 +228,30 @@ export default function get(entryLoc): Array<Suite> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!test.validateLogs && (test.stdout.code || test.stderr.code)) {
|
||||
throw new Error(
|
||||
"stdout.txt and stderr.txt are only allowed when the 'validateLogs' option is enabled: " +
|
||||
(test.stdout.code ? stdoutLoc : stderrLoc),
|
||||
);
|
||||
}
|
||||
if (test.options.ignoreOutput) {
|
||||
if (test.expect.code) {
|
||||
throw new Error(
|
||||
"Test cannot ignore its output and also validate it: " + expectLoc,
|
||||
);
|
||||
}
|
||||
if (!test.validateLogs) {
|
||||
throw new Error(
|
||||
"ignoreOutput can only be used when validateLogs is true: " +
|
||||
taskOptsLoc,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Delete to avoid option validation error
|
||||
delete test.options.validateLogs;
|
||||
delete test.options.ignoreOutput;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-member-expression-to-functions",
|
||||
"version": "7.0.0",
|
||||
"version": "7.5.5",
|
||||
"description": "Helper function to replace certain member expressions with function calls",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-member-expression-to-functions",
|
||||
"license": "MIT",
|
||||
@@ -10,6 +10,6 @@
|
||||
"main": "lib/index.js",
|
||||
"author": "Justin Ridgewell <justin@ridgewell.name>",
|
||||
"dependencies": {
|
||||
"@babel/types": "^7.0.0"
|
||||
"@babel/types": "^7.5.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,34 @@ const handle = {
|
||||
return;
|
||||
}
|
||||
|
||||
// { KEY: MEMBER } = OBJ -> { KEY: _destructureSet(MEMBER) } = OBJ
|
||||
// { KEY: MEMBER = _VALUE } = OBJ -> { KEY: _destructureSet(MEMBER) = _VALUE } = OBJ
|
||||
// {...MEMBER} -> {..._destructureSet(MEMBER)}
|
||||
//
|
||||
// [MEMBER] = ARR -> [_destructureSet(MEMBER)] = ARR
|
||||
// [MEMBER = _VALUE] = ARR -> [_destructureSet(MEMBER) = _VALUE] = ARR
|
||||
// [...MEMBER] -> [..._destructureSet(MEMBER)]
|
||||
if (
|
||||
// { KEY: MEMBER } = OBJ
|
||||
(parentPath.isObjectProperty({ value: node }) &&
|
||||
parentPath.parentPath.isObjectPattern()) ||
|
||||
// { KEY: MEMBER = _VALUE } = OBJ
|
||||
(parentPath.isAssignmentPattern({ left: node }) &&
|
||||
parentPath.parentPath.isObjectProperty({ value: parent }) &&
|
||||
parentPath.parentPath.parentPath.isObjectPattern()) ||
|
||||
// [MEMBER] = ARR
|
||||
parentPath.isArrayPattern() ||
|
||||
// [MEMBER = _VALUE] = ARR
|
||||
(parentPath.isAssignmentPattern({ left: node }) &&
|
||||
parentPath.parentPath.isArrayPattern()) ||
|
||||
// {...MEMBER}
|
||||
// [...MEMBER]
|
||||
parentPath.isRestElement()
|
||||
) {
|
||||
member.replaceWith(this.destructureSet(member));
|
||||
return;
|
||||
}
|
||||
|
||||
// MEMBER -> _get(MEMBER)
|
||||
member.replaceWith(this.get(member));
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-module-transforms",
|
||||
"version": "7.4.4",
|
||||
"version": "7.5.5",
|
||||
"description": "Babel helper functions for implementing ES6 module transformations",
|
||||
"author": "Logan Smyth <loganfsmyth@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -15,7 +15,7 @@
|
||||
"@babel/helper-simple-access": "^7.1.0",
|
||||
"@babel/helper-split-export-declaration": "^7.4.4",
|
||||
"@babel/template": "^7.4.4",
|
||||
"@babel/types": "^7.4.4",
|
||||
"lodash": "^4.17.11"
|
||||
"@babel/types": "^7.5.5",
|
||||
"lodash": "^4.17.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-regex",
|
||||
"version": "7.4.4",
|
||||
"version": "7.5.5",
|
||||
"description": "Helper function to check for literal RegEx",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-regex",
|
||||
"license": "MIT",
|
||||
@@ -9,6 +9,6 @@
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.11"
|
||||
"lodash": "^4.17.13"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-replace-supers",
|
||||
"version": "7.4.4",
|
||||
"version": "7.5.5",
|
||||
"description": "Helper function to replace supers",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-replace-supers",
|
||||
"license": "MIT",
|
||||
@@ -9,9 +9,9 @@
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/helper-member-expression-to-functions": "^7.0.0",
|
||||
"@babel/helper-member-expression-to-functions": "^7.5.5",
|
||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
||||
"@babel/traverse": "^7.4.4",
|
||||
"@babel/types": "^7.4.4"
|
||||
"@babel/traverse": "^7.5.5",
|
||||
"@babel/types": "^7.5.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,12 @@ const specHandlers = {
|
||||
]);
|
||||
},
|
||||
|
||||
destructureSet(superMember) {
|
||||
throw superMember.buildCodeFrameError(
|
||||
`Destructuring to a super field is not supported yet.`,
|
||||
);
|
||||
},
|
||||
|
||||
call(superMember, args) {
|
||||
return optimiseCall(this.get(superMember), t.thisExpression(), args);
|
||||
},
|
||||
@@ -174,6 +180,13 @@ const looseHandlers = {
|
||||
value,
|
||||
);
|
||||
},
|
||||
|
||||
destructureSet(superMember) {
|
||||
const { computed } = superMember.node;
|
||||
const prop = this.prop(superMember);
|
||||
|
||||
return t.memberExpression(t.thisExpression(), prop, computed);
|
||||
},
|
||||
};
|
||||
|
||||
export default class ReplaceSupers {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-transform-fixture-test-runner",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"description": "Transform test runner for @babel/helper-fixtures module",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -11,14 +11,14 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-transform-fixture-test-runner",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/core": "^7.4.4",
|
||||
"@babel/helper-fixtures": "^7.4.4",
|
||||
"@babel/polyfill": "^7.4.4",
|
||||
"@babel/code-frame": "^7.5.5",
|
||||
"@babel/core": "^7.6.0",
|
||||
"@babel/helper-fixtures": "^7.6.0",
|
||||
"@babel/polyfill": "^7.6.0",
|
||||
"babel-check-duplicated-nodes": "^1.0.0",
|
||||
"jest": "^22.4.2",
|
||||
"jest-diff": "^22.4.0",
|
||||
"lodash": "^4.17.11",
|
||||
"jest": "^24.8.0",
|
||||
"jest-diff": "^24.8.0",
|
||||
"lodash": "^4.17.13",
|
||||
"resolve": "^1.3.2",
|
||||
"source-map": "^0.5.0"
|
||||
}
|
||||
|
||||
@@ -131,11 +131,17 @@ function wrapPackagesArray(type, names, optionsDir) {
|
||||
}
|
||||
|
||||
function run(task) {
|
||||
const actual = task.actual;
|
||||
const expected = task.expect;
|
||||
const exec = task.exec;
|
||||
const opts = task.options;
|
||||
const optionsDir = task.optionsDir;
|
||||
const {
|
||||
actual,
|
||||
expect: expected,
|
||||
exec,
|
||||
options: opts,
|
||||
optionsDir,
|
||||
validateLogs,
|
||||
ignoreOutput,
|
||||
stdout,
|
||||
stderr,
|
||||
} = task;
|
||||
|
||||
function getOpts(self) {
|
||||
const newOpts = merge(
|
||||
@@ -191,56 +197,67 @@ function run(task) {
|
||||
}
|
||||
}
|
||||
|
||||
let actualCode = actual.code;
|
||||
const expectCode = expected.code;
|
||||
if (!execCode || actualCode) {
|
||||
result = babel.transform(actualCode, getOpts(actual));
|
||||
const expectedCode = result.code.replace(
|
||||
escapeRegExp(path.resolve(__dirname, "../../../")),
|
||||
"<CWD>",
|
||||
);
|
||||
const inputCode = actual.code;
|
||||
const expectedCode = expected.code;
|
||||
if (!execCode || inputCode) {
|
||||
const actualLogs = { stdout: "", stderr: "" };
|
||||
let restoreSpies = null;
|
||||
if (validateLogs) {
|
||||
const spy1 = jest.spyOn(console, "log").mockImplementation(msg => {
|
||||
actualLogs.stdout += `${msg}\n`;
|
||||
});
|
||||
const spy2 = jest.spyOn(console, "warn").mockImplementation(msg => {
|
||||
actualLogs.stderr += `${msg}\n`;
|
||||
});
|
||||
restoreSpies = () => {
|
||||
spy1.mockRestore();
|
||||
spy2.mockRestore();
|
||||
};
|
||||
}
|
||||
|
||||
result = babel.transform(inputCode, getOpts(actual));
|
||||
|
||||
if (restoreSpies) restoreSpies();
|
||||
|
||||
const outputCode = normalizeOutput(result.code);
|
||||
|
||||
checkDuplicatedNodes(babel, result.ast);
|
||||
if (
|
||||
!expected.code &&
|
||||
expectedCode &&
|
||||
!opts.throws &&
|
||||
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
|
||||
!process.env.CI
|
||||
) {
|
||||
const expectedFile = expected.loc.replace(
|
||||
/\.m?js$/,
|
||||
result.sourceType === "module" ? ".mjs" : ".js",
|
||||
);
|
||||
|
||||
console.log(`New test file created: ${expectedFile}`);
|
||||
fs.writeFileSync(expectedFile, `${expectedCode}\n`);
|
||||
|
||||
if (expected.loc !== expectedFile) {
|
||||
try {
|
||||
fs.unlinkSync(expected.loc);
|
||||
} catch (e) {}
|
||||
}
|
||||
} else {
|
||||
actualCode = expectedCode.trim();
|
||||
try {
|
||||
expect(actualCode).toEqualFile({
|
||||
filename: expected.loc,
|
||||
code: expectCode,
|
||||
});
|
||||
} catch (e) {
|
||||
if (!process.env.OVERWRITE) throw e;
|
||||
|
||||
console.log(`Updated test file: ${expected.loc}`);
|
||||
fs.writeFileSync(expected.loc, `${expectedCode}\n`);
|
||||
}
|
||||
|
||||
if (actualCode) {
|
||||
expect(expected.loc).toMatch(
|
||||
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
|
||||
if (!ignoreOutput) {
|
||||
if (
|
||||
!expected.code &&
|
||||
outputCode &&
|
||||
!opts.throws &&
|
||||
fs.statSync(path.dirname(expected.loc)).isDirectory() &&
|
||||
!process.env.CI
|
||||
) {
|
||||
const expectedFile = expected.loc.replace(
|
||||
/\.m?js$/,
|
||||
result.sourceType === "module" ? ".mjs" : ".js",
|
||||
);
|
||||
|
||||
console.log(`New test file created: ${expectedFile}`);
|
||||
fs.writeFileSync(expectedFile, `${outputCode}\n`);
|
||||
|
||||
if (expected.loc !== expectedFile) {
|
||||
try {
|
||||
fs.unlinkSync(expected.loc);
|
||||
} catch (e) {}
|
||||
}
|
||||
} else {
|
||||
validateFile(outputCode, expected.loc, expectedCode);
|
||||
|
||||
if (inputCode) {
|
||||
expect(expected.loc).toMatch(
|
||||
result.sourceType === "module" ? /\.mjs$/ : /\.js$/,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (validateLogs) {
|
||||
validateFile(normalizeOutput(actualLogs.stdout), stdout.loc, stdout.code);
|
||||
validateFile(normalizeOutput(actualLogs.stderr), stderr.loc, stderr.code);
|
||||
}
|
||||
}
|
||||
|
||||
if (task.sourceMap) {
|
||||
@@ -263,6 +280,29 @@ function run(task) {
|
||||
}
|
||||
}
|
||||
|
||||
function validateFile(actualCode, expectedLoc, expectedCode) {
|
||||
try {
|
||||
expect(actualCode).toEqualFile({
|
||||
filename: expectedLoc,
|
||||
code: expectedCode,
|
||||
});
|
||||
} catch (e) {
|
||||
if (!process.env.OVERWRITE) throw e;
|
||||
|
||||
console.log(`Updated test file: ${expectedLoc}`);
|
||||
fs.writeFileSync(expectedLoc, `${actualCode}\n`);
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeOutput(code) {
|
||||
return code
|
||||
.trim()
|
||||
.replace(
|
||||
new RegExp(escapeRegExp(path.resolve(__dirname, "../../../")), "g"),
|
||||
"<CWD>",
|
||||
);
|
||||
}
|
||||
|
||||
const toEqualFile = () => ({
|
||||
compare: (actual, { filename, code }) => {
|
||||
const pass = actual === code;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helpers",
|
||||
"version": "7.4.4",
|
||||
"version": "7.6.0",
|
||||
"description": "Collection of helper functions used by Babel transforms.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
@@ -11,9 +11,9 @@
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helpers",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/template": "^7.4.4",
|
||||
"@babel/traverse": "^7.4.4",
|
||||
"@babel/types": "^7.4.4"
|
||||
"@babel/template": "^7.6.0",
|
||||
"@babel/traverse": "^7.6.0",
|
||||
"@babel/types": "^7.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
|
||||
@@ -26,13 +26,14 @@ helpers.typeof = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
|
||||
// "for" is a reserved keyword in ES3 so escaping it here for backward compatibility
|
||||
helpers.jsx = helper("7.0.0-beta.0")`
|
||||
var REACT_ELEMENT_TYPE;
|
||||
|
||||
export default function _createRawReactElement(type, props, key, children) {
|
||||
if (!REACT_ELEMENT_TYPE) {
|
||||
REACT_ELEMENT_TYPE = (
|
||||
typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")
|
||||
typeof Symbol === "function" && Symbol["for"] && Symbol["for"]("react.element")
|
||||
) || 0xeac7;
|
||||
}
|
||||
|
||||
@@ -46,15 +47,6 @@ helpers.jsx = helper("7.0.0-beta.0")`
|
||||
children: void 0,
|
||||
};
|
||||
}
|
||||
if (props && defaultProps) {
|
||||
for (var propName in defaultProps) {
|
||||
if (props[propName] === void 0) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
} else if (!props) {
|
||||
props = defaultProps || {};
|
||||
}
|
||||
|
||||
if (childrenLength === 1) {
|
||||
props.children = children;
|
||||
@@ -66,6 +58,16 @@ helpers.jsx = helper("7.0.0-beta.0")`
|
||||
props.children = childArray;
|
||||
}
|
||||
|
||||
if (props && defaultProps) {
|
||||
for (var propName in defaultProps) {
|
||||
if (props[propName] === void 0) {
|
||||
props[propName] = defaultProps[propName];
|
||||
}
|
||||
}
|
||||
} else if (!props) {
|
||||
props = defaultProps || {};
|
||||
}
|
||||
|
||||
return {
|
||||
$$typeof: REACT_ELEMENT_TYPE,
|
||||
type: type,
|
||||
@@ -384,6 +386,7 @@ helpers.extends = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
|
||||
// This old helper can be removed in babel v8
|
||||
helpers.objectSpread = helper("7.0.0-beta.0")`
|
||||
import defineProperty from "defineProperty";
|
||||
|
||||
@@ -404,6 +407,48 @@ helpers.objectSpread = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.objectSpread2 = helper("7.5.0")`
|
||||
import defineProperty from "defineProperty";
|
||||
|
||||
// This function is different to "Reflect.ownKeys". The enumerableOnly
|
||||
// filters on symbol properties only. Returned string properties are always
|
||||
// enumerable. It is good to use in objectSpread.
|
||||
|
||||
function ownKeys(object, enumerableOnly) {
|
||||
var keys = Object.keys(object);
|
||||
if (Object.getOwnPropertySymbols) {
|
||||
var symbols = Object.getOwnPropertySymbols(object);
|
||||
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
||||
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
||||
});
|
||||
keys.push.apply(keys, symbols);
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
export default function _objectSpread2(target) {
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = (arguments[i] != null) ? arguments[i] : {};
|
||||
if (i % 2) {
|
||||
ownKeys(source, true).forEach(function (key) {
|
||||
defineProperty(target, key, source[key]);
|
||||
});
|
||||
} else if (Object.getOwnPropertyDescriptors) {
|
||||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
||||
} else {
|
||||
ownKeys(source).forEach(function (key) {
|
||||
Object.defineProperty(
|
||||
target,
|
||||
key,
|
||||
Object.getOwnPropertyDescriptor(source, key)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.inherits = helper("7.0.0-beta.0")`
|
||||
import setPrototypeOf from "setPrototypeOf";
|
||||
|
||||
@@ -548,7 +593,7 @@ helpers.wrapNativeSuper = helper("7.0.0-beta.0")`
|
||||
helpers.instanceof = helper("7.0.0-beta.0")`
|
||||
export default function _instanceof(left, right) {
|
||||
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
||||
return right[Symbol.hasInstance](left);
|
||||
return !!right[Symbol.hasInstance](left);
|
||||
} else {
|
||||
return left instanceof right;
|
||||
}
|
||||
@@ -562,28 +607,45 @@ helpers.interopRequireDefault = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
|
||||
helpers.interopRequireWildcard = helper("7.0.0-beta.0")`
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () { return cache; };
|
||||
return cache;
|
||||
}
|
||||
|
||||
export default function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -676,7 +738,6 @@ helpers.superPropBase = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
|
||||
helpers.get = helper("7.0.0-beta.0")`
|
||||
import getPrototypeOf from "getPrototypeOf";
|
||||
import superPropBase from "superPropBase";
|
||||
|
||||
export default function _get(target, property, receiver) {
|
||||
@@ -701,7 +762,6 @@ helpers.get = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
|
||||
helpers.set = helper("7.0.0-beta.0")`
|
||||
import getPrototypeOf from "getPrototypeOf";
|
||||
import superPropBase from "superPropBase";
|
||||
import defineProperty from "defineProperty";
|
||||
|
||||
@@ -775,18 +835,6 @@ helpers.taggedTemplateLiteralLoose = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.temporalRef = helper("7.0.0-beta.0")`
|
||||
import undef from "temporalUndefined";
|
||||
|
||||
export default function _temporalRef(val, name) {
|
||||
if (val === undef) {
|
||||
throw new ReferenceError(name + " is not defined - temporal dead zone");
|
||||
} else {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.readOnlyError = helper("7.0.0-beta.0")`
|
||||
export default function _readOnlyError(name) {
|
||||
throw new Error("\\"" + name + "\\" is read-only");
|
||||
@@ -800,7 +848,24 @@ helpers.classNameTDZError = helper("7.0.0-beta.0")`
|
||||
`;
|
||||
|
||||
helpers.temporalUndefined = helper("7.0.0-beta.0")`
|
||||
export default {};
|
||||
// This function isn't mean to be called, but to be used as a reference.
|
||||
// We can't use a normal object because it isn't hoisted.
|
||||
export default function _temporalUndefined() {}
|
||||
`;
|
||||
|
||||
helpers.tdz = helper("7.5.5")`
|
||||
export default function _tdzError(name) {
|
||||
throw new ReferenceError(name + " is not defined - temporal dead zone");
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.temporalRef = helper("7.0.0-beta.0")`
|
||||
import undef from "temporalUndefined";
|
||||
import err from "tdz";
|
||||
|
||||
export default function _temporalRef(val, name) {
|
||||
return val === undef ? err(name) : val;
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.slicedToArray = helper("7.0.0-beta.0")`
|
||||
@@ -878,7 +943,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
|
||||
// _e = _iteratorError
|
||||
// _i = _iterator
|
||||
// _s = _step
|
||||
|
||||
if (!(
|
||||
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
|
||||
)) { return }
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
@@ -904,6 +971,9 @@ helpers.iterableToArrayLimit = helper("7.0.0-beta.0")`
|
||||
|
||||
helpers.iterableToArrayLimitLoose = helper("7.0.0-beta.0")`
|
||||
export default function _iterableToArrayLimitLoose(arr, i) {
|
||||
if (!(
|
||||
Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]"
|
||||
)) { return }
|
||||
var _arr = [];
|
||||
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
_arr.push(_step.value);
|
||||
@@ -1045,10 +1115,10 @@ helpers.classPrivateFieldLooseBase = helper("7.0.0-beta.0")`
|
||||
|
||||
helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
|
||||
export default function _classPrivateFieldGet(receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (!descriptor) {
|
||||
throw new TypeError("attempted to get private field on non-instance");
|
||||
}
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (descriptor.get) {
|
||||
return descriptor.get.call(receiver);
|
||||
}
|
||||
@@ -1058,10 +1128,10 @@ helpers.classPrivateFieldGet = helper("7.0.0-beta.0")`
|
||||
|
||||
helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
|
||||
export default function _classPrivateFieldSet(receiver, privateMap, value) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (!descriptor) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (descriptor.set) {
|
||||
descriptor.set.call(receiver, value);
|
||||
} else {
|
||||
@@ -1079,11 +1149,42 @@ helpers.classPrivateFieldSet = helper("7.0.0-beta.0")`
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.classPrivateFieldDestructureSet = helper("7.4.4")`
|
||||
export default function _classPrivateFieldDestructureSet(receiver, privateMap) {
|
||||
if (!privateMap.has(receiver)) {
|
||||
throw new TypeError("attempted to set private field on non-instance");
|
||||
}
|
||||
var descriptor = privateMap.get(receiver);
|
||||
if (descriptor.set) {
|
||||
if (!("__destrObj" in descriptor)) {
|
||||
descriptor.__destrObj = {
|
||||
set value(v) {
|
||||
descriptor.set.call(receiver, v)
|
||||
},
|
||||
};
|
||||
}
|
||||
return descriptor.__destrObj;
|
||||
} else {
|
||||
if (!descriptor.writable) {
|
||||
// This should only throw in strict mode, but class bodies are
|
||||
// always strict and private fields can only be used inside
|
||||
// class bodies.
|
||||
throw new TypeError("attempted to set read only private field");
|
||||
}
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
helpers.classStaticPrivateFieldSpecGet = helper("7.0.2")`
|
||||
export default function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
|
||||
if (receiver !== classConstructor) {
|
||||
throw new TypeError("Private static access of wrong provenance");
|
||||
}
|
||||
if (descriptor.get) {
|
||||
return descriptor.get.call(receiver);
|
||||
}
|
||||
return descriptor.value;
|
||||
}
|
||||
`;
|
||||
@@ -1093,13 +1194,18 @@ helpers.classStaticPrivateFieldSpecSet = helper("7.0.2")`
|
||||
if (receiver !== classConstructor) {
|
||||
throw new TypeError("Private static access of wrong provenance");
|
||||
}
|
||||
if (!descriptor.writable) {
|
||||
// This should only throw in strict mode, but class bodies are
|
||||
// always strict and private fields can only be used inside
|
||||
// class bodies.
|
||||
throw new TypeError("attempted to set read only private field");
|
||||
if (descriptor.set) {
|
||||
descriptor.set.call(receiver, value);
|
||||
} else {
|
||||
if (!descriptor.writable) {
|
||||
// This should only throw in strict mode, but class bodies are
|
||||
// always strict and private fields can only be used inside
|
||||
// class bodies.
|
||||
throw new TypeError("attempted to set read only private field");
|
||||
}
|
||||
descriptor.value = value;
|
||||
}
|
||||
descriptor.value = value;
|
||||
|
||||
return value;
|
||||
}
|
||||
`;
|
||||
@@ -1816,16 +1922,17 @@ helpers.wrapRegExp = helper("7.2.6")`
|
||||
|
||||
export default function _wrapRegExp(re, groups) {
|
||||
_wrapRegExp = function(re, groups) {
|
||||
return new BabelRegExp(re, groups);
|
||||
return new BabelRegExp(re, undefined, groups);
|
||||
};
|
||||
|
||||
var _RegExp = wrapNativeSuper(RegExp);
|
||||
var _super = RegExp.prototype;
|
||||
var _groups = new WeakMap();
|
||||
|
||||
function BabelRegExp(re, groups) {
|
||||
var _this = _RegExp.call(this, re);
|
||||
_groups.set(_this, groups);
|
||||
function BabelRegExp(re, flags, groups) {
|
||||
var _this = _RegExp.call(this, re, flags);
|
||||
// if the regex is recreated with 'g' flag
|
||||
_groups.set(_this, groups || _groups.get(re));
|
||||
return _this;
|
||||
}
|
||||
inherits(BabelRegExp, _RegExp);
|
||||
|
||||
@@ -280,6 +280,10 @@ export function getDependencies(name: string): $ReadOnlyArray<string> {
|
||||
return Array.from(loadHelper(name).dependencies.values());
|
||||
}
|
||||
|
||||
export function ensure(name: string) {
|
||||
loadHelper(name);
|
||||
}
|
||||
|
||||
export const list = Object.keys(helpers)
|
||||
.map(name => name.replace(/^_/, ""))
|
||||
.filter(name => name !== "__esModule");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user