Compare commits
137 Commits
v7.6.2
...
initialize
| Author | SHA1 | Date | |
|---|---|---|---|
| 4fd9f6e6a2 | |||
| 08550a076c | |||
| d50037be8f | |||
| fd2c2f61bb | |||
| 0e5c224ff1 | |||
| b0b6a92b90 | |||
| a5c141ea85 | |||
| e488c32244 | |||
| 0febc4f55f | |||
| 5415a390a9 | |||
| 7dd772001d | |||
| d314e28457 | |||
| b248b3f4e9 | |||
| c8c6ff7c4c | |||
|
|
8e5f2dc929 | ||
|
|
2b082601a7 | ||
|
|
70c0ed512a | ||
|
|
8c2ed89aaa | ||
|
|
e315d65a7a | ||
|
|
0287c0f02f | ||
|
|
c2bace4b73 | ||
|
|
35f4d12763 | ||
|
|
9082e68d6f | ||
|
|
bdb4318f47 | ||
|
|
3ab035bab6 | ||
|
|
2cd5ad0c80 | ||
|
|
2640e5a27c | ||
|
|
0f949990c3 | ||
|
|
f544753bb8 | ||
|
|
d3db02da30 | ||
|
|
42c8e0fb2f | ||
|
|
bf48fca6a0 | ||
|
|
f8eb290da1 | ||
|
|
5f2240e7ab | ||
|
|
97faa83953 | ||
|
|
cdbffe3990 | ||
|
|
b114486bc1 | ||
|
|
e9c1bce50f | ||
|
|
87feda7c2a | ||
|
|
d25262ec4b | ||
|
|
861844761f | ||
|
|
43aa7e262c | ||
|
|
5e24016623 | ||
|
|
d023e105b7 | ||
|
|
abce0ef49d | ||
|
|
5c0d8a9de7 | ||
|
|
bea1b0d0af | ||
|
|
58a646be59 | ||
|
|
c7d8b8a377 | ||
|
|
d08702c9d2 | ||
|
|
a2b5437b01 | ||
|
|
0b0edc3e3d | ||
|
|
e419e5fe42 | ||
|
|
4e6a4b08bb | ||
|
|
3d2f365074 | ||
|
|
8ffca0475a | ||
|
|
ec3345bb57 | ||
|
|
4b3a19ea9f | ||
|
|
198b4a0fbd | ||
|
|
143d159982 | ||
|
|
63f9a3c946 | ||
|
|
3a5e8a8dd4 | ||
|
|
38a3063111 | ||
|
|
4cd93ab5f3 | ||
|
|
d248e2d188 | ||
|
|
f47fbd5f39 | ||
|
|
be0fcaaf49 | ||
|
|
4e5ac1fd5c | ||
|
|
1d1fab4ea2 | ||
|
|
f1bc6c4e18 | ||
|
|
b6ef9689b2 | ||
|
|
01927babe2 | ||
|
|
9ada30c207 | ||
|
|
43065a9e24 | ||
|
|
fce1b74105 | ||
|
|
562b6c3bbb | ||
|
|
1770dace34 | ||
|
|
5b40845afe | ||
|
|
fe258dec04 | ||
|
|
78cd63d9cf | ||
|
|
43b623c1f1 | ||
|
|
b5b8055cc0 | ||
|
|
da9c9a64c2 | ||
|
|
8c94b3f209 | ||
|
|
095f28a913 | ||
|
|
487f10f84d | ||
|
|
5800fc97b3 | ||
|
|
2254542010 | ||
|
|
d234ff6572 | ||
|
|
800eccc046 | ||
|
|
cd5d3abc32 | ||
|
|
272d85d0ad | ||
|
|
686186cabc | ||
|
|
06313a6288 | ||
|
|
dcf7d89b8e | ||
|
|
1b19608a5a | ||
|
|
e28c8ac612 | ||
|
|
99035ca96e | ||
|
|
c455d2af86 | ||
|
|
a422ea64ee | ||
|
|
34d30e28d6 | ||
|
|
3ad4c70d3a | ||
|
|
34937f13d5 | ||
|
|
c7add11fdc | ||
|
|
d329156ebc | ||
|
|
25b35261ca | ||
|
|
563874c06c | ||
|
|
b0acfb24dd | ||
|
|
599d2ff324 | ||
|
|
0856618ed5 | ||
|
|
bc0966a46f | ||
|
|
3498195ae2 | ||
|
|
fbf3cb0ac4 | ||
|
|
e6264a0992 | ||
|
|
0b37ab0362 | ||
|
|
57ae306457 | ||
|
|
fa5a40c8d5 | ||
|
|
a219b6de7a | ||
|
|
fa5057f9fb | ||
|
|
02f2d17e83 | ||
|
|
b351f29033 | ||
|
|
298c9a6c33 | ||
|
|
80d99b4d4e | ||
|
|
94fcabc4e3 | ||
|
|
5f1970433d | ||
|
|
b459f6a0a4 | ||
|
|
66062c2a8c | ||
|
|
8d4f95de45 | ||
|
|
d0f093e716 | ||
|
|
490798a26d | ||
|
|
eaa1474541 | ||
|
|
0e9502685a | ||
|
|
26be14b24d | ||
|
|
6f3460c767 | ||
|
|
cc080417b9 | ||
|
|
a00f371610 | ||
|
|
af66d521bd |
@ -30,11 +30,20 @@ aliases:
|
|||||||
- &artifact_env_min
|
- &artifact_env_min
|
||||||
path: ~/babel/packages/babel-preset-env-standalone/babel-preset-env.min.js
|
path: ~/babel/packages/babel-preset-env-standalone/babel-preset-env.min.js
|
||||||
|
|
||||||
|
- &test262_workdir
|
||||||
|
working_directory: ~/babel/babel-test262-runner
|
||||||
|
|
||||||
|
- &artifact_test262_tap
|
||||||
|
path: ~/test262.tap
|
||||||
|
|
||||||
|
- &artifact_test262_xunit
|
||||||
|
path: ~/test-results
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
test:
|
||||||
working_directory: ~/babel
|
working_directory: ~/babel
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/node:12
|
- image: circleci/node:13
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- restore-cache: *restore-yarn-cache
|
- restore-cache: *restore-yarn-cache
|
||||||
@ -54,3 +63,59 @@ jobs:
|
|||||||
- store_artifacts: *artifact_env_min
|
- store_artifacts: *artifact_env_min
|
||||||
- save_cache: *save-node-modules-cache
|
- save_cache: *save-node-modules-cache
|
||||||
- save_cache: *save-yarn-cache
|
- save_cache: *save-yarn-cache
|
||||||
|
test262:
|
||||||
|
working_directory: ~/babel
|
||||||
|
docker:
|
||||||
|
- image: circleci/node:12
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- restore-cache: *restore-yarn-cache
|
||||||
|
- restore-cache: *restore-node-modules-cache
|
||||||
|
- run:
|
||||||
|
name: Build Babel
|
||||||
|
command: BABEL_ENV=test make bootstrap
|
||||||
|
- run:
|
||||||
|
name: Link Babel
|
||||||
|
command: |
|
||||||
|
cd packages
|
||||||
|
for package in */; do
|
||||||
|
cd $package
|
||||||
|
yarn link
|
||||||
|
cd ..
|
||||||
|
done
|
||||||
|
- run:
|
||||||
|
name: Setup Test Runner
|
||||||
|
command: |
|
||||||
|
git clone --recurse-submodules https://github.com/babel/babel-test262-runner
|
||||||
|
cd babel-test262-runner
|
||||||
|
yarn
|
||||||
|
yarn add tap-mocha-reporter --dev
|
||||||
|
curl -L https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 > jq
|
||||||
|
chmod +x ./jq
|
||||||
|
for package in ../packages/*/package.json; do
|
||||||
|
yarn link $(./jq -j ".name" $package)
|
||||||
|
done
|
||||||
|
node lib/download-node
|
||||||
|
- run:
|
||||||
|
name: Run Test262
|
||||||
|
command: node lib/run-tests I_AM_SURE | tee ~/test262.tap
|
||||||
|
<<: *test262_workdir
|
||||||
|
- store_artifacts: *artifact_test262_tap
|
||||||
|
- run:
|
||||||
|
name: Output test262 results
|
||||||
|
command: |
|
||||||
|
cat ~/test262.tap | $(npm bin)/tap-mocha-reporter spec || true
|
||||||
|
<<: *test262_workdir
|
||||||
|
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
test:
|
||||||
|
jobs:
|
||||||
|
- test
|
||||||
|
master:
|
||||||
|
jobs:
|
||||||
|
- test262:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
|||||||
@ -24,4 +24,6 @@ suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
|
|||||||
suppress_type=$FlowFixMe
|
suppress_type=$FlowFixMe
|
||||||
suppress_type=$FlowSubtype
|
suppress_type=$FlowSubtype
|
||||||
esproposal.export_star_as=enable
|
esproposal.export_star_as=enable
|
||||||
|
esproposal.optional_chaining=enable
|
||||||
|
esproposal.nullish_coalescing=enable
|
||||||
module.name_mapper='^@babel\/\([a-zA-Z0-9_\-]+\)$' -> '<PROJECT_ROOT>/packages/babel-\1/src/index'
|
module.name_mapper='^@babel\/\([a-zA-Z0-9_\-]+\)$' -> '<PROJECT_ROOT>/packages/babel-\1/src/index'
|
||||||
|
|||||||
2
.github/lock.yml
vendored
2
.github/lock.yml
vendored
@ -4,7 +4,7 @@
|
|||||||
daysUntilLock: 91
|
daysUntilLock: 91
|
||||||
# Comment to post before locking. Set to `false` to disable
|
# Comment to post before locking. Set to `false` to disable
|
||||||
lockComment: false
|
lockComment: false
|
||||||
only: issues
|
# The label to be applied when an issue is locked
|
||||||
lockLabel: 'outdated'
|
lockLabel: 'outdated'
|
||||||
|
|
||||||
# Issues or pull requests with these labels will not be locked
|
# Issues or pull requests with these labels will not be locked
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -35,7 +35,7 @@ package-lock.json
|
|||||||
!/packages/babel-runtime-corejs2/helpers/temporalRef.js
|
!/packages/babel-runtime-corejs2/helpers/temporalRef.js
|
||||||
/packages/babel-runtime-corejs2/helpers/esm/*.js
|
/packages/babel-runtime-corejs2/helpers/esm/*.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js
|
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
|
/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
|
||||||
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
|
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
|
||||||
/packages/babel-runtime-corejs2/core-js/**/*.js
|
/packages/babel-runtime-corejs2/core-js/**/*.js
|
||||||
!/packages/babel-runtime-corejs2/core-js/map.js
|
!/packages/babel-runtime-corejs2/core-js/map.js
|
||||||
|
|||||||
42
.travis.yml
42
.travis.yml
@ -3,41 +3,43 @@ git:
|
|||||||
language: node_js
|
language: node_js
|
||||||
cache:
|
cache:
|
||||||
yarn: true
|
yarn: true
|
||||||
node_js:
|
|
||||||
# We test the latest version on circleci
|
os: linux
|
||||||
- '11'
|
|
||||||
- '10'
|
|
||||||
- '8'
|
|
||||||
- '6'
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- PATH=$HOME/.yarn/bin:$PATH
|
- PATH=$HOME/.yarn/bin:$PATH
|
||||||
- JOB=test
|
- JOB=test
|
||||||
|
|
||||||
before_install:
|
install: skip
|
||||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
|
||||||
|
|
||||||
install:
|
|
||||||
# the `make test-ci` script runs this command already
|
|
||||||
- if [ "$JOB" != "test" ] && [ "$JOB" != "lint" ]; then yarn install; fi
|
|
||||||
- if [ "$JOB" = "lint" ]; then make bootstrap; fi
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi
|
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi
|
- if [ "$TRAVIS_OS_NAME" = "windows" ]; then choco install make; fi
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- if [ "$JOB" = "test" ]; then make test-ci; fi
|
- if [ "$JOB" = "test" ]; then make -j test-ci; fi
|
||||||
- if [ "$JOB" = "lint" ]; then make lint && make flow; fi
|
- if [ "$JOB" = "lint" ]; then make -j code-quality-ci; fi
|
||||||
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi
|
- if [ "$JOB" = "babel-parser-flow-tests" ]; then make -j test-flow-ci; fi
|
||||||
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi
|
- if [ "$JOB" = "babel-parser-test262-tests" ]; then make -j test-test262-ci; fi
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- node_js: "node"
|
- node_js: "node"
|
||||||
env: JOB=lint
|
env: JOB=lint
|
||||||
|
# We test the latest version on circleci
|
||||||
|
- node_js: "12"
|
||||||
|
# Move `windows` build to be the third since it is slow
|
||||||
|
- os: windows
|
||||||
|
node_js: "node"
|
||||||
|
env:
|
||||||
|
- JOB=test
|
||||||
|
# https://travis-ci.community/t/build-doesnt-finish-after-completing-tests/288/9
|
||||||
|
- YARN_GPG=no
|
||||||
|
# Continue node_js matrix
|
||||||
|
- node_js: "6"
|
||||||
|
- node_js: "10"
|
||||||
|
- node_js: "8"
|
||||||
- node_js: "node"
|
- node_js: "node"
|
||||||
env: JOB=babel-parser-flow-tests
|
env: JOB=babel-parser-flow-tests
|
||||||
- node_js: "node"
|
- node_js: "node"
|
||||||
|
|||||||
213
CHANGELOG.md
213
CHANGELOG.md
@ -17,6 +17,219 @@ See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0
|
|||||||
|
|
||||||
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
|
<!-- DO NOT CHANGE THESE COMMENTS - See .github/actions/trigger-github-release/update-changelog.js -->
|
||||||
<!-- insert-new-changelog-here -->
|
<!-- insert-new-changelog-here -->
|
||||||
|
## v7.7.3 (2019-11-08)
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10682](https://github.com/babel/babel/pull/10682) Don't recover from "adjacent jsx elements" parser error ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
## v7.7.2 (2019-11-07)
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10669](https://github.com/babel/babel/pull/10669) Parse arrows with params annotations in conditional expressions ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-plugin-transform-typescript`
|
||||||
|
* [#10658](https://github.com/babel/babel/pull/10658) fix: remove accessibility of constructor ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-traverse`
|
||||||
|
* [#10656](https://github.com/babel/babel/pull/10656) fix: add inList setter for compatibility with babel-minify ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
## v7.7.1 (2019-11-05)
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-types`
|
||||||
|
* [#10650](https://github.com/babel/babel/pull/10650) Revert "throw a TypeError if identifier validation fails (#10621)" ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-preset-env`
|
||||||
|
* [#10649](https://github.com/babel/babel/pull/10649) Fix(babel-preset-env): check api.caller is a function to avoid to thr… ([@love2me](https://github.com/love2me))
|
||||||
|
|
||||||
|
## v7.7.0 (2019-11-05)
|
||||||
|
|
||||||
|
#### :eyeglasses: Spec Compliance
|
||||||
|
* `babel-types`
|
||||||
|
* [#10621](https://github.com/babel/babel/pull/10621) throw a TypeError if identifier validation fails. ([@dentrado](https://github.com/dentrado))
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10559](https://github.com/babel/babel/pull/10559) fix: Exclude catch clause from let identifier error. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
|
||||||
|
* [#10567](https://github.com/babel/babel/pull/10567) [parser] Exception to 8 and 9 in tagged template. ([@pnowak](https://github.com/pnowak))
|
||||||
|
* [#10532](https://github.com/babel/babel/pull/10532) Allow duplicate __proto__ keys in patterns, simple case (#6705). ([@alejo90](https://github.com/alejo90))
|
||||||
|
|
||||||
|
#### :rocket: New Feature
|
||||||
|
* `babel-generator`, `babel-helper-create-class-features-plugin`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-preset-typescript`, `babel-types`
|
||||||
|
* [#10545](https://github.com/babel/babel/pull/10545) Add support for TS declare modifier on fields. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-core`, `babel-parser`, `babel-preset-typescript`
|
||||||
|
* [#10363](https://github.com/babel/babel/pull/10363) @babel/parser error recovery. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-core`
|
||||||
|
* [#10599](https://github.com/babel/babel/pull/10599) Add support for .cjs config files. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10501](https://github.com/babel/babel/pull/10501) Add support for babel.config.json. ([@devongovett](https://github.com/devongovett))
|
||||||
|
* [#10361](https://github.com/babel/babel/pull/10361) feat: if code frame error is on a single line, highlight the whole path. ([@SimenB](https://github.com/SimenB))
|
||||||
|
* `babel-plugin-syntax-top-level-await`, `babel-preset-env`
|
||||||
|
* [#10573](https://github.com/babel/babel/pull/10573) Create @babel/plugin-syntax-top-level-await. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-helper-builder-react-jsx`, `babel-plugin-transform-react-jsx`, `babel-preset-react`
|
||||||
|
* [#10572](https://github.com/babel/babel/pull/10572) [transform-react-jsx] Add useSpread option to transform JSX. ([@ivandevp](https://github.com/ivandevp))
|
||||||
|
* `babel-generator`, `babel-parser`, `babel-plugin-proposal-decorators`, `babel-plugin-syntax-flow`, `babel-types`
|
||||||
|
* [#10344](https://github.com/babel/babel/pull/10344) Flow enums parsing. ([@gkz](https://github.com/gkz))
|
||||||
|
* `babel-plugin-transform-function-name`, `babel-plugin-transform-modules-umd`, `babel-preset-env`
|
||||||
|
* [#10477](https://github.com/babel/babel/pull/10477) Changes UMD callsite to be more likely to pass in the intended object.. ([@MicahZoltu](https://github.com/MicahZoltu))
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10449](https://github.com/babel/babel/pull/10449) Create parser plugin "topLevelAwait". ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10521](https://github.com/babel/babel/pull/10521) [parser] Enable "exportNamespaceFrom" by default. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10483](https://github.com/babel/babel/pull/10483) [parser] Add support for private fields in TypeScript. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-generator`, `babel-parser`, `babel-types`
|
||||||
|
* [#10543](https://github.com/babel/babel/pull/10543) add assertions signature for TypeScript. ([@tanhauhau](https://github.com/tanhauhau))
|
||||||
|
* `babel-cli`, `babel-register`
|
||||||
|
* [#8622](https://github.com/babel/babel/pull/8622) Make dir for babel --out-file. ([@TrySound](https://github.com/TrySound))
|
||||||
|
* `babel-cli`
|
||||||
|
* [#10399](https://github.com/babel/babel/pull/10399) Closes [#8326](https://github.com/babel/babel/issues/8326), add back --quiet option.. ([@chris-peng-1244](https://github.com/chris-peng-1244))
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-helpers`, `babel-plugin-proposal-async-generator-functions`, `babel-plugin-proposal-function-sent`, `babel-preset-env`
|
||||||
|
* [#10422](https://github.com/babel/babel/pull/10422) Correctly delegate .return() in async generator. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-helper-module-transforms`, `babel-plugin-transform-modules-commonjs`
|
||||||
|
* [#10628](https://github.com/babel/babel/pull/10628) Don't throw when destructuring into a var named as an import. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-plugin-transform-modules-systemjs`
|
||||||
|
* [#10638](https://github.com/babel/babel/pull/10638) fix: remove ExportNamedDeclaration when the specifier is empty. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10631](https://github.com/babel/babel/pull/10631) [TS] Parse calls with type args in optional chains. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10607](https://github.com/babel/babel/pull/10607) fixed missing errors on assignment pattern in object expression. ([@vivek12345](https://github.com/vivek12345))
|
||||||
|
* [#10594](https://github.com/babel/babel/pull/10594) [parser] Parse only modifiers of actual methods. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
|
||||||
|
* `babel-plugin-transform-typescript`
|
||||||
|
* [#10555](https://github.com/babel/babel/pull/10555) [TS] Correctly transform computed strings and templates in enums. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-core`
|
||||||
|
* [#10623](https://github.com/babel/babel/pull/10623) Fix: inputSourceMap should work when it is an external file. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* [#10539](https://github.com/babel/babel/pull/10539) fix: remove filename annotation in buildCodeFrameError. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-plugin-proposal-decorators`
|
||||||
|
* [#10578](https://github.com/babel/babel/pull/10578) [decorators] fix: support string literal properties. ([@mwhitworth](https://github.com/mwhitworth))
|
||||||
|
* `babel-helpers`, `babel-plugin-proposal-dynamic-import`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
|
||||||
|
* [#10574](https://github.com/babel/babel/pull/10574) fix: _interopRequireWildcard should only cache objects. ([@samMeow](https://github.com/samMeow))
|
||||||
|
* `babel-traverse`
|
||||||
|
* [#9777](https://github.com/babel/babel/pull/9777) [traverse] Allow skipping nodes inserted with .replaceWith(). ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-preset-env`
|
||||||
|
* [#10146](https://github.com/babel/babel/pull/10146) Inject core-js@3 imports in Program:exit instead of on post(). ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-generator`
|
||||||
|
* [#10519](https://github.com/babel/babel/pull/10519) Fix generator missing parens around an arrow returning function type. ([@existentialism](https://github.com/existentialism))
|
||||||
|
* `babel-plugin-transform-async-to-generator`, `babel-preset-env`, `babel-traverse`
|
||||||
|
* [#9939](https://github.com/babel/babel/pull/9939) Don't use args rest/spread to hoist super method calls. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
|
||||||
|
#### :nail_care: Polish
|
||||||
|
* `babel-plugin-transform-classes`, `babel-plugin-transform-regenerator`, `babel-preset-env`
|
||||||
|
* [#9481](https://github.com/babel/babel/pull/9481) [preset-env] Don't use async-to-generator when already using regenerator. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-helpers`, `babel-plugin-transform-modules-commonjs`, `babel-preset-env`
|
||||||
|
* [#10585](https://github.com/babel/babel/pull/10585) fix(babel‑helpers/interopRequireWildcard): Avoid double nullish check. ([@ExE-Boss](https://github.com/ExE-Boss))
|
||||||
|
* `babel-register`
|
||||||
|
* [#10557](https://github.com/babel/babel/pull/10557) fix: disable caching when babel could not read/write cache. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
|
||||||
|
#### :house: Internal
|
||||||
|
* `babel-cli`, `babel-node`
|
||||||
|
* [#10619](https://github.com/babel/babel/pull/10619) chore: remove output-file-sync dependency. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-register`
|
||||||
|
* [#10614](https://github.com/babel/babel/pull/10614) chore: bump source-map-support to 0.5.14. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-helper-create-regexp-features-plugin`, `babel-plugin-proposal-unicode-property-regex`, `babel-plugin-transform-dotall-regex`, `babel-plugin-transform-named-capturing-groups-regex`, `babel-plugin-transform-unicode-regex`, `babel-preset-env`
|
||||||
|
* [#10447](https://github.com/babel/babel/pull/10447) Merge multiple regex transform plugin. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-preset-env`
|
||||||
|
* [#10612](https://github.com/babel/babel/pull/10612) chore: update web.immediate support fixtures. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-helper-module-imports`
|
||||||
|
* [#10608](https://github.com/babel/babel/pull/10608) Use .find instead of .filter to get targetPath in ImportInjector. ([@Andarist](https://github.com/Andarist))
|
||||||
|
* Other
|
||||||
|
* [#10600](https://github.com/babel/babel/pull/10600) Test node@13 on circle. ([@existentialism](https://github.com/existentialism))
|
||||||
|
* [#10593](https://github.com/babel/babel/pull/10593) chore: replace outdated travis-ci.org badges [ci skip]. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* [#10591](https://github.com/babel/babel/pull/10591) chore: test against Node.js 13. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* [#10556](https://github.com/babel/babel/pull/10556) Add master branch workflow for test262 tests. ([@jbhoosreddy](https://github.com/jbhoosreddy))
|
||||||
|
* [#10553](https://github.com/babel/babel/pull/10553) chore: introduce envinfo into environment section. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-runtime`
|
||||||
|
* [#10418](https://github.com/babel/babel/pull/10418) docs: add homepage link. ([@DanArthurGallagher](https://github.com/DanArthurGallagher))
|
||||||
|
* `babel-helper-annotate-as-pure`, `babel-helper-bindify-decorators`, `babel-helper-builder-binary-assignment-operator-visitor`, `babel-helper-builder-react-jsx`, `babel-helper-call-delegate`, `babel-helper-define-map`, `babel-helper-explode-assignable-expression`, `babel-helper-explode-class`, `babel-helper-function-name`, `babel-helper-get-function-arity`, `babel-helper-hoist-variables`, `babel-helper-member-expression-to-functions`, `babel-helper-module-imports`, `babel-helper-module-transforms`, `babel-helper-optimise-call-expression`, `babel-helper-remap-async-to-generator`, `babel-helper-replace-supers`, `babel-helper-simple-access`, `babel-helper-split-export-declaration`, `babel-helper-wrap-function`, `babel-helpers`, `babel-template`
|
||||||
|
* [#10568](https://github.com/babel/babel/pull/10568) Bump babel-types to ^7.6.3. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
|
||||||
|
#### :running_woman: Performance
|
||||||
|
* `babel-traverse`
|
||||||
|
* [#10480](https://github.com/babel/babel/pull/10480) Traverse performance. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
|
||||||
|
## v7.6.4 (2019-10-10)
|
||||||
|
|
||||||
|
#### :eyeglasses: Spec Compliance
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10491](https://github.com/babel/babel/pull/10491) Trailing comma after rest - The final fix ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-transform-fixture-test-runner`
|
||||||
|
* [#10536](https://github.com/babel/babel/pull/10536) Revert "chore: Upgrade source-map to 0.6.1 (#10446)" ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
## v7.6.3 (2019-10-08)
|
||||||
|
|
||||||
|
#### :eyeglasses: Spec Compliance
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10469](https://github.com/babel/babel/pull/10469) Disallow await inside async arrow params ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10493](https://github.com/babel/babel/pull/10493) [parser] Disallow numeric separators in legacy octal like integers ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
|
||||||
|
|
||||||
|
#### :rocket: New Feature
|
||||||
|
* `babel-types`
|
||||||
|
* [#10504](https://github.com/babel/babel/pull/10504) Add declarations for more of @babel/types exports ([@Jessidhia](https://github.com/Jessidhia))
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-plugin-transform-block-scoping`
|
||||||
|
* [#10343](https://github.com/babel/babel/pull/10343) Do not remove let bindings even they are wrapped in closure ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10119](https://github.com/babel/babel/pull/10119) add scope to TSModuleDeclaration ([@tanhauhau](https://github.com/tanhauhau))
|
||||||
|
* [#10332](https://github.com/babel/babel/pull/10332) Do not allow member expressions to start async arrows ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10490](https://github.com/babel/babel/pull/10490) [parser] Don't crash on comment after trailing comma after elision ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-plugin-transform-react-constant-elements`, `babel-traverse`
|
||||||
|
* [#10529](https://github.com/babel/babel/pull/10529) Do not hoist jsx referencing a mutable binding ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-generator`, `babel-parser`, `babel-plugin-transform-block-scoping`, `babel-plugin-transform-flow-comments`, `babel-plugin-transform-flow-strip-types`, `babel-plugin-transform-typescript`
|
||||||
|
* [#10220](https://github.com/babel/babel/pull/10220) Flow: interface identifier should be declared in the scope ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
|
||||||
|
#### :nail_care: Polish
|
||||||
|
* `babel-core`
|
||||||
|
* [#10419](https://github.com/babel/babel/pull/10419) assertNoDuplicates throw with more context ([@hjdivad](https://github.com/hjdivad))
|
||||||
|
* [#10511](https://github.com/babel/babel/pull/10511) Add filename to transform error ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
|
||||||
|
#### :house: Internal
|
||||||
|
* Other
|
||||||
|
* [#10506](https://github.com/babel/babel/pull/10506) Use `make -j` for parallel build ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* [#10443](https://github.com/babel/babel/pull/10443) perf: only apply lazy cjs module transform on cli and core ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* [#10494](https://github.com/babel/babel/pull/10494) Enable optional chaining and nullish coalescing plugins ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-fixtures`, `babel-helper-transform-fixture-test-runner`, `babel-node`, `babel-plugin-transform-react-jsx-source`, `babel-plugin-transform-runtime`, `babel-preset-env`, `babel-preset-react`
|
||||||
|
* [#10249](https://github.com/babel/babel/pull/10249) Add windows to travis ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
|
||||||
|
#### :running_woman: Performance
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10371](https://github.com/babel/babel/pull/10371) perf: replace lookahead by lookaheadCharCode ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* Other
|
||||||
|
* [#10443](https://github.com/babel/babel/pull/10443) perf: only apply lazy cjs module transform on cli and core ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
## v7.6.2 (2019-09-23)
|
||||||
|
|
||||||
|
#### :eyeglasses: Spec Compliance
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10472](https://github.com/babel/babel/pull/10472) added check to disallow super.private variable access and test case added. ([@vivek12345](https://github.com/vivek12345))
|
||||||
|
* [#10468](https://github.com/babel/babel/pull/10468) [parser] Disallow numeric separator in unicode scape sequences. ([@ivandevp](https://github.com/ivandevp))
|
||||||
|
* [#10467](https://github.com/babel/babel/pull/10467) [parser] Invalid NonOctal Decimal. ([@gonzarodriguezt](https://github.com/gonzarodriguezt))
|
||||||
|
* [#10461](https://github.com/babel/babel/pull/10461) [parser] Disallow static fields named `constructor`. ([@guywaldman](https://github.com/guywaldman))
|
||||||
|
* [#10455](https://github.com/babel/babel/pull/10455) [parser] Report escapes in kws only if they won't be used as identifiers. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10445](https://github.com/babel/babel/pull/10445) Leave trailing comments after handling a possible trailing comma. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-cli`
|
||||||
|
* [#10400](https://github.com/babel/babel/pull/10400) fix: allow the process to exit naturally. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-core`
|
||||||
|
* [#10402](https://github.com/babel/babel/pull/10402) fix: pass optionLoc when validating plugin object. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-plugin-transform-block-scoping`, `babel-plugin-transform-spread`, `babel-traverse`
|
||||||
|
* [#10417](https://github.com/babel/babel/pull/10417) Do not guess relative execution status for exported fns. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* `babel-plugin-proposal-object-rest-spread`, `babel-preset-env`
|
||||||
|
* [#10275](https://github.com/babel/babel/pull/10275) fix object rest in array pattern. ([@tanhauhau](https://github.com/tanhauhau))
|
||||||
|
|
||||||
|
#### :house: Internal
|
||||||
|
* `babel-plugin-transform-named-capturing-groups-regex`
|
||||||
|
* [#10430](https://github.com/babel/babel/pull/10430) refactor: replace regexp-tree by regexpu. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* Other
|
||||||
|
* [#10441](https://github.com/babel/babel/pull/10441) Update GitHub actions to v2. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
* [#10427](https://github.com/babel/babel/pull/10427) chore: add lint-ts rule. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-helper-fixtures`
|
||||||
|
* [#10428](https://github.com/babel/babel/pull/10428) chore: remove tryResolve dependency. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-node`
|
||||||
|
* [#10429](https://github.com/babel/babel/pull/10429) Remove babel polyfill dependency of babel-node. ([@bdwain](https://github.com/bdwain))
|
||||||
|
* `babel-generator`, `babel-helper-fixtures`
|
||||||
|
* [#10420](https://github.com/babel/babel/pull/10420) chore: remove trim-right dependency. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
* `babel-core`, `babel-plugin-transform-runtime`, `babel-register`
|
||||||
|
* [#10405](https://github.com/babel/babel/pull/10405) Remove circular dependency. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||||
|
|
||||||
|
#### :running_woman: Performance
|
||||||
|
* `babel-parser`
|
||||||
|
* [#10421](https://github.com/babel/babel/pull/10421) Miscellaneous perf tweak. ([@JLHwung](https://github.com/JLHwung))
|
||||||
|
|
||||||
## v7.6.1 (2019-09-06)
|
## v7.6.1 (2019-09-06)
|
||||||
|
|
||||||
|
|||||||
56
Gulpfile.js
56
Gulpfile.js
@ -11,25 +11,20 @@ const filter = require("gulp-filter");
|
|||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const merge = require("merge-stream");
|
|
||||||
const rollup = require("rollup");
|
const rollup = require("rollup");
|
||||||
const rollupBabel = require("rollup-plugin-babel");
|
const rollupBabel = require("rollup-plugin-babel");
|
||||||
const rollupNodeResolve = require("rollup-plugin-node-resolve");
|
const rollupNodeResolve = require("rollup-plugin-node-resolve");
|
||||||
const rollupReplace = require("rollup-plugin-replace");
|
const rollupReplace = require("rollup-plugin-replace");
|
||||||
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");
|
const { registerStandalonePackageTask } = require("./scripts/gulp-tasks");
|
||||||
|
|
||||||
const sources = ["codemods", "packages"];
|
const defaultSourcesGlob = "./@(codemods|packages)/*/src/**/*.js";
|
||||||
|
|
||||||
function swapSrcWithLib(srcPath) {
|
function swapSrcWithLib(srcPath) {
|
||||||
const parts = srcPath.split(path.sep);
|
const parts = srcPath.split(path.sep);
|
||||||
parts[1] = "lib";
|
parts[2] = "lib";
|
||||||
return parts.join(path.sep);
|
return parts.join(path.sep);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGlobFromSource(source) {
|
|
||||||
return `./${source}/*/src/**/*.js`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIndexFromPackage(name) {
|
function getIndexFromPackage(name) {
|
||||||
return `${name}/src/index.js`;
|
return `${name}/src/index.js`;
|
||||||
}
|
}
|
||||||
@ -56,32 +51,28 @@ function rename(fn) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildBabel(exclude) {
|
function buildBabel(exclude, sourcesGlob = defaultSourcesGlob) {
|
||||||
return merge(
|
const base = __dirname;
|
||||||
sources.map(source => {
|
|
||||||
const base = path.join(__dirname, source);
|
|
||||||
|
|
||||||
let stream = gulp.src(getGlobFromSource(source), { base: base });
|
let stream = gulp.src(sourcesGlob, { base: __dirname });
|
||||||
|
|
||||||
if (exclude) {
|
if (exclude) {
|
||||||
const filters = exclude.map(p => `!**/${p}/**`);
|
const filters = exclude.map(p => `!**/${p}/**`);
|
||||||
filters.unshift("**");
|
filters.unshift("**");
|
||||||
stream = stream.pipe(filter(filters));
|
stream = stream.pipe(filter(filters));
|
||||||
}
|
}
|
||||||
|
|
||||||
return stream
|
return stream
|
||||||
.pipe(errorsLogger())
|
.pipe(errorsLogger())
|
||||||
.pipe(newer({ dest: base, map: swapSrcWithLib }))
|
.pipe(newer({ dest: base, map: swapSrcWithLib }))
|
||||||
.pipe(compilationLogger())
|
.pipe(compilationLogger())
|
||||||
.pipe(babel())
|
.pipe(babel())
|
||||||
.pipe(
|
.pipe(
|
||||||
// Passing 'file.relative' because newer() above uses a relative
|
// Passing 'file.relative' because newer() above uses a relative
|
||||||
// path and this keeps it consistent.
|
// path and this keeps it consistent.
|
||||||
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
|
rename(file => path.resolve(file.base, swapSrcWithLib(file.relative)))
|
||||||
)
|
)
|
||||||
.pipe(gulp.dest(base));
|
.pipe(gulp.dest(base));
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildRollup(packages) {
|
function buildRollup(packages) {
|
||||||
@ -118,6 +109,9 @@ const bundles = ["packages/babel-parser"];
|
|||||||
|
|
||||||
gulp.task("build-rollup", () => buildRollup(bundles));
|
gulp.task("build-rollup", () => buildRollup(bundles));
|
||||||
gulp.task("build-babel", () => buildBabel(/* exclude */ bundles));
|
gulp.task("build-babel", () => buildBabel(/* exclude */ bundles));
|
||||||
|
gulp.task("build-babel-types", () =>
|
||||||
|
buildBabel(/* exclude */ bundles, "packages/babel-types/src/**/*.js")
|
||||||
|
);
|
||||||
gulp.task("build", gulp.parallel("build-rollup", "build-babel"));
|
gulp.task("build", gulp.parallel("build-rollup", "build-babel"));
|
||||||
|
|
||||||
gulp.task("default", gulp.series("build"));
|
gulp.task("default", gulp.series("build"));
|
||||||
@ -128,7 +122,7 @@ gulp.task(
|
|||||||
"watch",
|
"watch",
|
||||||
gulp.series("build-no-bundle", function watch() {
|
gulp.series("build-no-bundle", function watch() {
|
||||||
gulpWatch(
|
gulpWatch(
|
||||||
sources.map(getGlobFromSource),
|
defaultSourcesGlob,
|
||||||
{ debounceDelay: 200 },
|
{ debounceDelay: 200 },
|
||||||
gulp.task("build-no-bundle")
|
gulp.task("build-no-bundle")
|
||||||
);
|
);
|
||||||
|
|||||||
188
Makefile
188
Makefile
@ -1,6 +1,5 @@
|
|||||||
MAKEFLAGS = -j1
|
|
||||||
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
|
FLOW_COMMIT = 09669846b7a7ca5a6c23c12d56bb3bebdafd67e9
|
||||||
TEST262_COMMIT = ef7fd2bc27e7c10b4a71d2edc632a2934742a13e
|
TEST262_COMMIT = 8688c4ab79059c3097098605e69f1ee5eda6c409
|
||||||
|
|
||||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||||
export FORCE_COLOR = true
|
export FORCE_COLOR = true
|
||||||
@ -9,64 +8,110 @@ SOURCES = packages codemods
|
|||||||
|
|
||||||
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
|
||||||
|
|
||||||
build: clean clean-lib
|
build: build-bundle
|
||||||
./node_modules/.bin/gulp build
|
|
||||||
node ./packages/babel-standalone/scripts/generate.js
|
|
||||||
node ./packages/babel-types/scripts/generateTypeHelpers.js
|
|
||||||
# call build again as the generated files might need to be compiled again.
|
|
||||||
./node_modules/.bin/gulp build
|
|
||||||
# generate flow and typescript typings
|
|
||||||
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
|
|
||||||
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
|
|
||||||
ifneq ("$(BABEL_COVERAGE)", "true")
|
ifneq ("$(BABEL_COVERAGE)", "true")
|
||||||
make build-standalone
|
$(MAKE) build-standalone
|
||||||
make build-preset-env-standalone
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
build-standalone:
|
build-bundle: clean clean-lib
|
||||||
./node_modules/.bin/gulp build-babel-standalone
|
yarn gulp build
|
||||||
|
$(MAKE) generate-standalone generate-type-helpers
|
||||||
|
# call build again as the generated files might need to be compiled again.
|
||||||
|
yarn gulp build
|
||||||
|
$(MAKE) build-typings
|
||||||
|
$(MAKE) build-dist
|
||||||
|
|
||||||
|
build-bundle-ci: bootstrap-only
|
||||||
|
$(MAKE) build-bundle
|
||||||
|
|
||||||
|
generate-standalone:
|
||||||
|
node packages/babel-standalone/scripts/generate.js
|
||||||
|
|
||||||
|
generate-type-helpers:
|
||||||
|
node packages/babel-types/scripts/generateTypeHelpers.js
|
||||||
|
|
||||||
|
build-typings: build-flow-typings build-typescript-typings
|
||||||
|
|
||||||
|
build-flow-typings:
|
||||||
|
node packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow
|
||||||
|
|
||||||
|
build-typescript-typings:
|
||||||
|
node packages/babel-types/scripts/generators/typescript.js > packages/babel-types/lib/index.d.ts
|
||||||
|
|
||||||
|
build-standalone: build-babel-standalone build-preset-env-standalone
|
||||||
|
|
||||||
|
build-standalone-ci: build-bundle-ci
|
||||||
|
$(MAKE) build-standalone
|
||||||
|
|
||||||
|
build-babel-standalone:
|
||||||
|
yarn gulp build-babel-standalone
|
||||||
|
|
||||||
build-preset-env-standalone:
|
build-preset-env-standalone:
|
||||||
./node_modules/.bin/gulp build-babel-preset-env-standalone
|
yarn gulp build-babel-preset-env-standalone
|
||||||
|
|
||||||
prepublish-build-standalone:
|
prepublish-build-standalone:
|
||||||
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-standalone
|
BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-standalone
|
||||||
|
|
||||||
prepublish-build-preset-env-standalone:
|
prepublish-build-preset-env-standalone:
|
||||||
BABEL_ENV=production IS_PUBLISH=true ./node_modules/.bin/gulp build-babel-preset-env-standalone
|
BABEL_ENV=production IS_PUBLISH=true yarn gulp build-babel-preset-env-standalone
|
||||||
|
|
||||||
build-dist: build
|
build-dist: build-polyfill-dist build-plugin-transform-runtime-dist
|
||||||
|
|
||||||
|
build-polyfill-dist:
|
||||||
cd packages/babel-polyfill; \
|
cd packages/babel-polyfill; \
|
||||||
scripts/build-dist.sh
|
scripts/build-dist.sh
|
||||||
|
|
||||||
|
build-plugin-transform-runtime-dist:
|
||||||
cd packages/babel-plugin-transform-runtime; \
|
cd packages/babel-plugin-transform-runtime; \
|
||||||
node scripts/build-dist.js
|
node scripts/build-dist.js
|
||||||
|
|
||||||
watch: clean clean-lib
|
build-no-bundle: clean clean-lib
|
||||||
|
BABEL_ENV=development yarn gulp build-no-bundle
|
||||||
# Ensure that build artifacts for types are created during local
|
# Ensure that build artifacts for types are created during local
|
||||||
# development too.
|
# development too.
|
||||||
BABEL_ENV=development ./node_modules/.bin/gulp build-no-bundle
|
$(MAKE) generate-type-helpers
|
||||||
node ./packages/babel-types/scripts/generateTypeHelpers.js
|
$(MAKE) build-typings
|
||||||
node packages/babel-types/scripts/generators/flow.js > ./packages/babel-types/lib/index.js.flow
|
|
||||||
node packages/babel-types/scripts/generators/typescript.js > ./packages/babel-types/lib/index.d.ts
|
watch: build-no-bundle
|
||||||
BABEL_ENV=development ./node_modules/.bin/gulp watch
|
BABEL_ENV=development yarn gulp watch
|
||||||
|
|
||||||
|
code-quality-ci: flowcheck-ci lint-ci
|
||||||
|
|
||||||
|
flowcheck-ci: bootstrap-flowcheck
|
||||||
|
$(MAKE) flow
|
||||||
|
|
||||||
|
code-quality: flow lint
|
||||||
|
|
||||||
flow:
|
flow:
|
||||||
./node_modules/.bin/flow check --strip-root
|
yarn flow check --strip-root
|
||||||
|
|
||||||
|
bootstrap-flowcheck: bootstrap-only
|
||||||
|
yarn gulp build-babel-types
|
||||||
|
$(MAKE) build-typings
|
||||||
|
|
||||||
|
lint-ci: lint-js-ci lint-ts-ci
|
||||||
|
|
||||||
|
lint-js-ci: bootstrap-only
|
||||||
|
$(MAKE) lint-js
|
||||||
|
|
||||||
|
lint-ts-ci: bootstrap-flowcheck
|
||||||
|
$(MAKE) lint-ts
|
||||||
|
|
||||||
lint: lint-js lint-ts
|
lint: lint-js lint-ts
|
||||||
|
|
||||||
lint-js:
|
lint-js:
|
||||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe
|
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe
|
||||||
|
|
||||||
lint-ts:
|
lint-ts:
|
||||||
./scripts/tests/typescript/lint.sh
|
scripts/tests/typescript/lint.sh
|
||||||
|
|
||||||
fix: fix-json
|
fix: fix-json fix-js
|
||||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
|
|
||||||
|
fix-js:
|
||||||
|
yarn eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
|
||||||
|
|
||||||
fix-json:
|
fix-json:
|
||||||
./node_modules/.bin/prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
|
yarn prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
|
||||||
|
|
||||||
clean: test-clean
|
clean: test-clean
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
@ -79,72 +124,80 @@ test-clean:
|
|||||||
$(foreach source, $(SOURCES), \
|
$(foreach source, $(SOURCES), \
|
||||||
$(call clean-source-test, $(source)))
|
$(call clean-source-test, $(source)))
|
||||||
|
|
||||||
|
# Does not work on Windows; use "yarn jest" instead
|
||||||
test-only:
|
test-only:
|
||||||
BABEL_ENV=test ./scripts/test.sh
|
BABEL_ENV=test ./scripts/test.sh
|
||||||
make test-clean
|
$(MAKE) test-clean
|
||||||
|
|
||||||
test: lint test-only
|
test: lint test-only
|
||||||
|
|
||||||
test-ci: bootstrap test-only
|
test-ci: jest-ci
|
||||||
|
|
||||||
|
jest-ci: build-standalone-ci
|
||||||
|
BABEL_ENV=test yarn jest --maxWorkers=4 --ci
|
||||||
|
$(MAKE) test-clean
|
||||||
|
|
||||||
|
# Does not work on Windows
|
||||||
test-ci-coverage: SHELL:=/bin/bash
|
test-ci-coverage: SHELL:=/bin/bash
|
||||||
test-ci-coverage:
|
test-ci-coverage:
|
||||||
BABEL_COVERAGE=true BABEL_ENV=test make bootstrap
|
BABEL_COVERAGE=true BABEL_ENV=test $(MAKE) bootstrap
|
||||||
BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
|
BABEL_ENV=test TEST_TYPE=cov ./scripts/test-cov.sh
|
||||||
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
|
bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
|
||||||
|
|
||||||
bootstrap-flow:
|
bootstrap-flow:
|
||||||
rm -rf ./build/flow
|
rm -rf build/flow
|
||||||
mkdir -p ./build
|
mkdir -p build
|
||||||
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git ./build/flow
|
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/facebook/flow.git build/flow
|
||||||
cd build/flow && git checkout $(FLOW_COMMIT)
|
cd build/flow && git checkout $(FLOW_COMMIT)
|
||||||
|
|
||||||
test-flow:
|
test-flow:
|
||||||
node scripts/tests/flow/run_babel_parser_flow_tests.js
|
node scripts/tests/flow/run_babel_parser_flow_tests.js
|
||||||
|
|
||||||
test-flow-ci: bootstrap test-flow
|
test-flow-ci: build-bundle-ci bootstrap-flow
|
||||||
|
$(MAKE) test-flow
|
||||||
|
|
||||||
test-flow-update-whitelist:
|
test-flow-update-whitelist:
|
||||||
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
|
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist
|
||||||
|
|
||||||
bootstrap-test262:
|
bootstrap-test262:
|
||||||
rm -rf ./build/test262
|
rm -rf build/test262
|
||||||
mkdir -p ./build
|
mkdir -p build
|
||||||
git clone --branch=master --single-branch --shallow-since=2019-01-01 https://github.com/tc39/test262.git ./build/test262
|
git clone --branch=master --single-branch --shallow-since=2019-09-01 https://github.com/tc39/test262.git build/test262
|
||||||
cd build/test262 && git checkout $(TEST262_COMMIT)
|
cd build/test262 && git checkout $(TEST262_COMMIT)
|
||||||
|
|
||||||
test-test262:
|
test-test262:
|
||||||
node scripts/tests/test262/run_babel_parser_test262.js
|
node scripts/tests/test262/run_babel_parser_test262.js
|
||||||
|
|
||||||
test-test262-ci: bootstrap test-test262
|
test-test262-ci: build-bundle-ci bootstrap-test262
|
||||||
|
$(MAKE) test-test262
|
||||||
|
|
||||||
test-test262-update-whitelist:
|
test-test262-update-whitelist:
|
||||||
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
|
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
|
||||||
|
|
||||||
|
# Does not work on Windows
|
||||||
clone-license:
|
clone-license:
|
||||||
./scripts/clone-license.sh
|
./scripts/clone-license.sh
|
||||||
|
|
||||||
prepublish-build:
|
prepublish-build: clean-lib clean-runtime-helpers
|
||||||
make clean-lib
|
NODE_ENV=production BABEL_ENV=production $(MAKE) build
|
||||||
rm -rf packages/babel-runtime/helpers
|
$(MAKE) clone-license
|
||||||
rm -rf packages/babel-runtime-corejs2/helpers
|
|
||||||
rm -rf packages/babel-runtime-corejs2/core-js
|
|
||||||
NODE_ENV=production BABEL_ENV=production make build-dist
|
|
||||||
make clone-license
|
|
||||||
|
|
||||||
prepublish:
|
prepublish:
|
||||||
make bootstrap-only
|
$(MAKE) bootstrap-only
|
||||||
make prepublish-build
|
$(MAKE) prepublish-build
|
||||||
make test
|
$(MAKE) test
|
||||||
|
|
||||||
new-version:
|
new-version:
|
||||||
git pull --rebase
|
git pull --rebase
|
||||||
./node_modules/.bin/lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
|
yarn lerna version --force-publish="@babel/runtime,@babel/runtime-corejs2,@babel/runtime-corejs3,@babel/standalone,@babel/preset-env-standalone"
|
||||||
|
|
||||||
|
publish-cerxes: prepublish
|
||||||
|
yarn lerna publish --registry="https://npm.cerxes.net" --force-publish --allow-branch initializers-fix --canary --preid csx --dist-tag csx
|
||||||
|
|
||||||
# NOTE: Run make new-version first
|
# NOTE: Run make new-version first
|
||||||
publish: prepublish
|
publish: prepublish
|
||||||
./node_modules/.bin/lerna publish from-git --require-scripts
|
yarn lerna publish from-git
|
||||||
make clean
|
$(MAKE) clean
|
||||||
|
|
||||||
publish-ci: prepublish
|
publish-ci: prepublish
|
||||||
ifneq ("$(NPM_TOKEN)", "")
|
ifneq ("$(NPM_TOKEN)", "")
|
||||||
@ -153,23 +206,30 @@ else
|
|||||||
echo "Missing NPM_TOKEN env var"
|
echo "Missing NPM_TOKEN env var"
|
||||||
exit 1
|
exit 1
|
||||||
endif
|
endif
|
||||||
./node_modules/.bin/lerna publish from-git --require-scripts --yes
|
yarn lerna publish from-git --yes
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
make clean
|
$(MAKE) clean
|
||||||
|
|
||||||
bootstrap-only: clean-all
|
bootstrap-only: lerna-bootstrap
|
||||||
|
|
||||||
|
yarn-install: clean-all
|
||||||
yarn --ignore-engines
|
yarn --ignore-engines
|
||||||
./node_modules/.bin/lerna bootstrap -- --ignore-engines
|
|
||||||
|
lerna-bootstrap: yarn-install
|
||||||
|
yarn lerna bootstrap
|
||||||
|
|
||||||
bootstrap: bootstrap-only
|
bootstrap: bootstrap-only
|
||||||
make build
|
$(MAKE) build
|
||||||
cd packages/babel-plugin-transform-runtime; \
|
|
||||||
node scripts/build-dist.js
|
|
||||||
|
|
||||||
clean-lib:
|
clean-lib:
|
||||||
$(foreach source, $(SOURCES), \
|
$(foreach source, $(SOURCES), \
|
||||||
$(call clean-source-lib, $(source)))
|
$(call clean-source-lib, $(source)))
|
||||||
|
|
||||||
|
clean-runtime-helpers:
|
||||||
|
rm -rf packages/babel-runtime/helpers
|
||||||
|
rm -rf packages/babel-runtime-corejs2/helpers
|
||||||
|
rm -rf packages/babel-runtime-corejs2/core-js
|
||||||
|
|
||||||
clean-all:
|
clean-all:
|
||||||
rm -rf node_modules
|
rm -rf node_modules
|
||||||
rm -rf package-lock.json
|
rm -rf package-lock.json
|
||||||
@ -178,7 +238,7 @@ clean-all:
|
|||||||
$(foreach source, $(SOURCES), \
|
$(foreach source, $(SOURCES), \
|
||||||
$(call clean-source-all, $(source)))
|
$(call clean-source-all, $(source)))
|
||||||
|
|
||||||
make clean
|
$(MAKE) clean
|
||||||
|
|
||||||
define clean-source-lib
|
define clean-source-lib
|
||||||
rm -rf $(1)/*/lib
|
rm -rf $(1)/*/lib
|
||||||
|
|||||||
@ -4,16 +4,23 @@
|
|||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<span style="color:darkred">
|
||||||
|
<b><i>WARNING</i> This is a fork of babel to test a fix for initializer-variables with class-properties (proposals-stuff)</b>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
The compiler for writing next generation JavaScript.
|
The compiler for writing next generation JavaScript.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a>
|
<a href="https://www.npmjs.com/package/@babel/core"><img alt="v7 npm Downloads" src="https://img.shields.io/npm/dm/@babel/core.svg?maxAge=43200&label=v7%20downloads"></a>
|
||||||
<a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a>
|
<a href="https://www.npmjs.com/package/babel-core"><img alt="v6 npm Downloads" src="https://img.shields.io/npm/dm/babel-core.svg?maxAge=43200&label=v6%20downloads"></a>
|
||||||
</p>
|
</p>
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://travis-ci.org/babel/babel"><img alt="Travis Status" src="https://img.shields.io/travis/babel/babel/master.svg?label=travis&maxAge=43200"></a>
|
<a href="https://travis-ci.com/babel/babel"><img alt="Travis Status" src="https://img.shields.io/travis/com/babel/babel/master.svg?label=travis&maxAge=43200"></a>
|
||||||
<a href="https://circleci.com/gh/babel/babel"><img alt="CircleCI Status" src="https://img.shields.io/circleci/project/github/babel/babel/master.svg?label=circle&maxAge=43200"></a>
|
<a href="https://circleci.com/gh/babel/babel"><img alt="CircleCI Status" src="https://img.shields.io/circleci/project/github/babel/babel/master.svg?label=circle&maxAge=43200"></a>
|
||||||
<a href="https://codecov.io/github/babel/babel"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/babel/babel/master.svg?maxAge=43200"></a>
|
<a href="https://codecov.io/github/babel/babel"><img alt="Coverage Status" src="https://img.shields.io/codecov/c/github/babel/babel/master.svg?maxAge=43200"></a>
|
||||||
<a href="https://slack.babeljs.io/"><img alt="Slack Status" src="https://slack.babeljs.io/badge.svg"></a>
|
<a href="https://slack.babeljs.io/"><img alt="Slack Status" src="https://slack.babeljs.io/badge.svg"></a>
|
||||||
|
|||||||
@ -77,9 +77,10 @@ module.exports = function(api) {
|
|||||||
"@babel/proposal-object-rest-spread",
|
"@babel/proposal-object-rest-spread",
|
||||||
{ useBuiltIns: true, loose: true },
|
{ useBuiltIns: true, loose: true },
|
||||||
],
|
],
|
||||||
|
"@babel/plugin-proposal-optional-chaining",
|
||||||
|
"@babel/plugin-proposal-nullish-coalescing-operator",
|
||||||
|
|
||||||
// Explicitly use the lazy version of CommonJS modules.
|
convertESM ? "@babel/transform-modules-commonjs" : null,
|
||||||
convertESM ? ["@babel/transform-modules-commonjs", { lazy: true }] : null,
|
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
@ -90,18 +91,17 @@ module.exports = function(api) {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: "./packages/babel-register",
|
test: ["./packages/babel-cli", "./packages/babel-core"],
|
||||||
plugins: [
|
plugins: [
|
||||||
// Override the root options to disable lazy imports for babel-register
|
// Explicitly use the lazy version of CommonJS modules.
|
||||||
// because otherwise the require hook will try to lazy-import things
|
convertESM
|
||||||
// leading to dependency cycles.
|
? ["@babel/transform-modules-commonjs", { lazy: true }]
|
||||||
convertESM ? "@babel/transform-modules-commonjs" : null,
|
: null,
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: "./packages/babel-polyfill",
|
test: "./packages/babel-polyfill",
|
||||||
presets: [["@babel/env", envOptsNoTargets]],
|
presets: [["@babel/env", envOptsNoTargets]],
|
||||||
plugins: [["@babel/transform-modules-commonjs", { lazy: false }]],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// The vast majority of our src files are modules, but we use
|
// The vast majority of our src files are modules, but we use
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
"@babel/plugin-syntax-object-rest-spread": "^7.0.0"
|
"@babel/plugin-syntax-object-rest-spread": "^7.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0-0"
|
"@babel/core": "^7.0.0-0 || csx"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.0.0",
|
"@babel/core": "^7.0.0",
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
"@babel/plugin-syntax-optional-catch-binding": "^7.0.0"
|
"@babel/plugin-syntax-optional-catch-binding": "^7.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0-0"
|
"@babel/core": "^7.0.0-0 || csx"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.0.0",
|
"@babel/core": "^7.0.0",
|
||||||
|
|||||||
@ -15,7 +15,7 @@ This is quite taboo but let's look at the pros and cons:
|
|||||||
* Easy to coordinate changes across modules.
|
* Easy to coordinate changes across modules.
|
||||||
* Single place to report issues.
|
* Single place to report issues.
|
||||||
* Easier to setup a development environment.
|
* Easier to setup a development environment.
|
||||||
* Tests across modules are run together which finds bugs that touch multiple modules easier.
|
* Tests across modules are run together which finds bugs that touch multiple modules more easily.
|
||||||
|
|
||||||
**Cons:**
|
**Cons:**
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "7.6.2",
|
"version": "7.7.3",
|
||||||
"changelog": {
|
"changelog": {
|
||||||
"repo": "babel/babel",
|
"repo": "babel/babel",
|
||||||
"cacheDir": ".changelog",
|
"cacheDir": ".changelog",
|
||||||
@ -33,5 +33,8 @@
|
|||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"npmClientArgs": [
|
"npmClientArgs": [
|
||||||
"--no-lockfile"
|
"--no-lockfile"
|
||||||
]
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"registry": "https://npm.cerxes.net"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
12
package.json
12
package.json
@ -14,7 +14,9 @@
|
|||||||
"@babel/eslint-plugin-development": "^1.0.1",
|
"@babel/eslint-plugin-development": "^1.0.1",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
"@babel/plugin-proposal-class-properties": "^7.5.5",
|
||||||
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
|
"@babel/plugin-proposal-export-namespace-from": "^7.5.2",
|
||||||
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4",
|
||||||
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
|
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
|
||||||
|
"@babel/plugin-proposal-optional-chaining": "^7.6.0",
|
||||||
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
|
"@babel/plugin-transform-modules-commonjs": "^7.6.0",
|
||||||
"@babel/plugin-transform-runtime": "^7.6.0",
|
"@babel/plugin-transform-runtime": "^7.6.0",
|
||||||
"@babel/preset-env": "^7.6.0",
|
"@babel/preset-env": "^7.6.0",
|
||||||
@ -22,7 +24,7 @@
|
|||||||
"@babel/register": "^7.6.0",
|
"@babel/register": "^7.6.0",
|
||||||
"@babel/runtime": "^7.6.0",
|
"@babel/runtime": "^7.6.0",
|
||||||
"babel-eslint": "^11.0.0-beta.0",
|
"babel-eslint": "^11.0.0-beta.0",
|
||||||
"babel-jest": "^24.8.0",
|
"babel-jest": "^24.9.0",
|
||||||
"babel-loader": "^8.0.6",
|
"babel-loader": "^8.0.6",
|
||||||
"babel-plugin-transform-charcodes": "^0.2.0",
|
"babel-plugin-transform-charcodes": "^0.2.0",
|
||||||
"browserify": "^16.2.3",
|
"browserify": "^16.2.3",
|
||||||
@ -38,7 +40,7 @@
|
|||||||
"eslint-plugin-import": "^2.17.2",
|
"eslint-plugin-import": "^2.17.2",
|
||||||
"eslint-plugin-prettier": "^3.1.0",
|
"eslint-plugin-prettier": "^3.1.0",
|
||||||
"fancy-log": "^1.3.3",
|
"fancy-log": "^1.3.3",
|
||||||
"flow-bin": "^0.102.0",
|
"flow-bin": "^0.108.0",
|
||||||
"graceful-fs": "^4.1.15",
|
"graceful-fs": "^4.1.15",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-babel": "^8.0.0",
|
"gulp-babel": "^8.0.0",
|
||||||
@ -49,12 +51,11 @@
|
|||||||
"gulp-uglify": "^3.0.2",
|
"gulp-uglify": "^3.0.2",
|
||||||
"gulp-watch": "^5.0.1",
|
"gulp-watch": "^5.0.1",
|
||||||
"husky": "^3.0.0",
|
"husky": "^3.0.0",
|
||||||
"jest": "^24.8.0",
|
"jest": "^24.9.0",
|
||||||
"lerna": "^3.16.0",
|
"lerna": "^3.16.0",
|
||||||
"lerna-changelog": "^0.5.0",
|
"lerna-changelog": "^0.5.0",
|
||||||
"lint-staged": "^9.2.0",
|
"lint-staged": "^9.2.0",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.13",
|
||||||
"merge-stream": "^1.0.1",
|
|
||||||
"output-file-sync": "^2.0.0",
|
"output-file-sync": "^2.0.0",
|
||||||
"prettier": "^1.17.1",
|
"prettier": "^1.17.1",
|
||||||
"pump": "^3.0.0",
|
"pump": "^3.0.0",
|
||||||
@ -75,7 +76,7 @@
|
|||||||
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
|
"@lerna/**/@lerna/collect-updates": "https://github.com/babel/lerna.git#babel-collect-updates"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 6.9.0 < 13.0.0",
|
"node": ">= 6.9.0 < 14.0.0",
|
||||||
"npm": ">= 3.x <= 6.x",
|
"npm": ">= 3.x <= 6.x",
|
||||||
"yarn": ">=0.27.5 || >=1.0.0-20170811"
|
"yarn": ">=0.27.5 || >=1.0.0-20170811"
|
||||||
},
|
},
|
||||||
@ -115,6 +116,7 @@
|
|||||||
],
|
],
|
||||||
"transformIgnorePatterns": [
|
"transformIgnorePatterns": [
|
||||||
"/node_modules/",
|
"/node_modules/",
|
||||||
|
"/packages/babel-standalone/babel.js",
|
||||||
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
|
"<rootDir>/packages/babel-standalone/babel(\\.min)?\\.js",
|
||||||
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
|
"<rootDir>/packages/babel-preset-env-standalone/babel-preset-env(\\.min)?\\.js",
|
||||||
"/test/(fixtures|tmp|__data__)/",
|
"/test/(fixtures|tmp|__data__)/",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/cli",
|
"name": "@babel/cli",
|
||||||
"version": "7.6.2",
|
"version": "7.7.0",
|
||||||
"description": "Babel command line.",
|
"description": "Babel command line.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -24,8 +24,7 @@
|
|||||||
"fs-readdir-recursive": "^1.1.0",
|
"fs-readdir-recursive": "^1.1.0",
|
||||||
"glob": "^7.0.0",
|
"glob": "^7.0.0",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.13",
|
||||||
"mkdirp": "^0.5.1",
|
"make-dir": "^2.1.0",
|
||||||
"output-file-sync": "^2.0.0",
|
|
||||||
"slash": "^2.0.0",
|
"slash": "^2.0.0",
|
||||||
"source-map": "^0.5.0"
|
"source-map": "^0.5.0"
|
||||||
},
|
},
|
||||||
@ -33,11 +32,11 @@
|
|||||||
"chokidar": "^2.1.8"
|
"chokidar": "^2.1.8"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0-0"
|
"@babel/core": "^7.0.0-0 || csx"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.6.2",
|
"@babel/core": "^7.7.0",
|
||||||
"@babel/helper-fixtures": "^7.6.2"
|
"@babel/helper-fixtures": "^7.6.3"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"babel": "./bin/babel.js",
|
"babel": "./bin/babel.js",
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import defaults from "lodash/defaults";
|
import defaults from "lodash/defaults";
|
||||||
import outputFileSync from "output-file-sync";
|
import { sync as makeDirSync } from "make-dir";
|
||||||
import { sync as mkdirpSync } from "mkdirp";
|
|
||||||
import slash from "slash";
|
import slash from "slash";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
@ -10,6 +9,11 @@ import fs from "fs";
|
|||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
import { type CmdOptions } from "./options";
|
import { type CmdOptions } from "./options";
|
||||||
|
|
||||||
|
function outputFileSync(filePath: string, data: string | Buffer): void {
|
||||||
|
makeDirSync(path.dirname(filePath));
|
||||||
|
fs.writeFileSync(filePath, data);
|
||||||
|
}
|
||||||
|
|
||||||
export default async function({
|
export default async function({
|
||||||
cliOptions,
|
cliOptions,
|
||||||
babelOptions,
|
babelOptions,
|
||||||
@ -122,18 +126,20 @@ export default async function({
|
|||||||
util.deleteDir(cliOptions.outDir);
|
util.deleteDir(cliOptions.outDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdirpSync(cliOptions.outDir);
|
makeDirSync(cliOptions.outDir);
|
||||||
|
|
||||||
let compiledFiles = 0;
|
let compiledFiles = 0;
|
||||||
for (const filename of cliOptions.filenames) {
|
for (const filename of cliOptions.filenames) {
|
||||||
compiledFiles += await handle(filename);
|
compiledFiles += await handle(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(
|
if (!cliOptions.quiet) {
|
||||||
`Successfully compiled ${compiledFiles} ${
|
console.log(
|
||||||
compiledFiles !== 1 ? "files" : "file"
|
`Successfully compiled ${compiledFiles} ${
|
||||||
} with Babel.`,
|
compiledFiles !== 1 ? "files" : "file"
|
||||||
);
|
} with Babel.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cliOptions.watch) {
|
if (cliOptions.watch) {
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import convertSourceMap from "convert-source-map";
|
|||||||
import defaults from "lodash/defaults";
|
import defaults from "lodash/defaults";
|
||||||
import sourceMap from "source-map";
|
import sourceMap from "source-map";
|
||||||
import slash from "slash";
|
import slash from "slash";
|
||||||
|
import { sync as makeDirSync } from "make-dir";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
|
||||||
@ -89,6 +90,8 @@ export default async function({
|
|||||||
const result = buildResult(fileResults);
|
const result = buildResult(fileResults);
|
||||||
|
|
||||||
if (cliOptions.outFile) {
|
if (cliOptions.outFile) {
|
||||||
|
makeDirSync(path.dirname(cliOptions.outFile));
|
||||||
|
|
||||||
// we've requested for a sourcemap to be written to disk
|
// we've requested for a sourcemap to be written to disk
|
||||||
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
|
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
|
||||||
const mapLoc = cliOptions.outFile + ".map";
|
const mapLoc = cliOptions.outFile + ".map";
|
||||||
|
|||||||
@ -12,19 +12,19 @@ import pkg from "../../package.json";
|
|||||||
// Standard Babel input configs.
|
// Standard Babel input configs.
|
||||||
commander.option(
|
commander.option(
|
||||||
"-f, --filename [filename]",
|
"-f, --filename [filename]",
|
||||||
"filename to use when reading from stdin - this will be used in source-maps, errors etc",
|
"The filename to use when reading from stdin. This will be used in source-maps, errors etc.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--presets [list]",
|
"--presets [list]",
|
||||||
"comma-separated list of preset names",
|
"A comma-separated list of preset names.",
|
||||||
collect,
|
collect,
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--plugins [list]",
|
"--plugins [list]",
|
||||||
"comma-separated list of plugin names",
|
"A comma-separated list of plugin names.",
|
||||||
collect,
|
collect,
|
||||||
);
|
);
|
||||||
commander.option("--config-file [path]", "Path to a .babelrc file to use");
|
commander.option("--config-file [path]", "Path to a .babelrc file to use.");
|
||||||
commander.option(
|
commander.option(
|
||||||
"--env-name [name]",
|
"--env-name [name]",
|
||||||
"The name of the 'env' to use when loading configs and plugins. " +
|
"The name of the 'env' to use when loading configs and plugins. " +
|
||||||
@ -40,97 +40,101 @@ commander.option(
|
|||||||
commander.option("--source-type [script|module]", "");
|
commander.option("--source-type [script|module]", "");
|
||||||
commander.option(
|
commander.option(
|
||||||
"--no-babelrc",
|
"--no-babelrc",
|
||||||
"Whether or not to look up .babelrc and .babelignore files",
|
"Whether or not to look up .babelrc and .babelignore files.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--ignore [list]",
|
"--ignore [list]",
|
||||||
"list of glob paths to **not** compile",
|
"List of glob paths to **not** compile.",
|
||||||
collect,
|
collect,
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--only [list]",
|
"--only [list]",
|
||||||
"list of glob paths to **only** compile",
|
"List of glob paths to **only** compile.",
|
||||||
collect,
|
collect,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Misc babel config.
|
// Misc babel config.
|
||||||
commander.option(
|
commander.option(
|
||||||
"--no-highlight-code",
|
"--no-highlight-code",
|
||||||
"enable/disable ANSI syntax highlighting of code frames (on by default)",
|
"Enable or disable ANSI syntax highlighting of code frames. (on by default)",
|
||||||
);
|
);
|
||||||
|
|
||||||
// General output formatting.
|
// General output formatting.
|
||||||
commander.option(
|
commander.option(
|
||||||
"--no-comments",
|
"--no-comments",
|
||||||
"write comments to generated output (true by default)",
|
"Write comments to generated output. (true by default)",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--retain-lines",
|
"--retain-lines",
|
||||||
"retain line numbers - will result in really ugly code",
|
"Retain line numbers. This will result in really ugly code.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--compact [true|false|auto]",
|
"--compact [true|false|auto]",
|
||||||
"do not include superfluous whitespace characters and line terminators",
|
"Do not include superfluous whitespace characters and line terminators.",
|
||||||
booleanify,
|
booleanify,
|
||||||
);
|
);
|
||||||
commander.option("--minified", "save as much bytes when printing [true|false]");
|
commander.option(
|
||||||
|
"--minified [true|false]",
|
||||||
|
"Save as many bytes when printing.",
|
||||||
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--auxiliary-comment-before [string]",
|
"--auxiliary-comment-before [string]",
|
||||||
"print a comment before any injected non-user code",
|
"Print a comment before any injected non-user code.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--auxiliary-comment-after [string]",
|
"--auxiliary-comment-after [string]",
|
||||||
"print a comment after any injected non-user code",
|
"Print a comment after any injected non-user code.",
|
||||||
);
|
);
|
||||||
|
|
||||||
// General source map formatting.
|
// General source map formatting.
|
||||||
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
|
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--source-map-target [string]",
|
"--source-map-target [string]",
|
||||||
"set `file` on returned source map",
|
"Set `file` on returned source map.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--source-file-name [string]",
|
"--source-file-name [string]",
|
||||||
"set `sources[0]` on returned source map",
|
"Set `sources[0]` on returned source map.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--source-root [filename]",
|
"--source-root [filename]",
|
||||||
"the root from which all sources are relative",
|
"The root from which all sources are relative.",
|
||||||
);
|
);
|
||||||
|
|
||||||
// Config params for certain module output formats.
|
// Config params for certain module output formats.
|
||||||
commander.option(
|
commander.option(
|
||||||
"--module-root [filename]",
|
"--module-root [filename]",
|
||||||
"optional prefix for the AMD module formatter that will be prepend to the filename on module definitions",
|
// eslint-disable-next-line max-len
|
||||||
|
"Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.",
|
||||||
);
|
);
|
||||||
commander.option("-M, --module-ids", "insert an explicit id for modules");
|
commander.option("-M, --module-ids", "Insert an explicit id for modules.");
|
||||||
commander.option(
|
commander.option(
|
||||||
"--module-id [string]",
|
"--module-id [string]",
|
||||||
"specify a custom name for module ids",
|
"Specify a custom name for module ids.",
|
||||||
);
|
);
|
||||||
|
|
||||||
// "babel" command specific arguments that are not passed to @babel/core.
|
// "babel" command specific arguments that are not passed to @babel/core.
|
||||||
commander.option(
|
commander.option(
|
||||||
"-x, --extensions [extensions]",
|
"-x, --extensions [extensions]",
|
||||||
"List of extensions to compile when a directory has been input [.es6,.js,.es,.jsx,.mjs]",
|
"List of extensions to compile when a directory has been the input. [.es6,.js,.es,.jsx,.mjs]",
|
||||||
collect,
|
collect,
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--keep-file-extension",
|
"--keep-file-extension",
|
||||||
"Preserve the file extensions of the input files",
|
"Preserve the file extensions of the input files.",
|
||||||
);
|
);
|
||||||
commander.option("-w, --watch", "Recompile files on changes");
|
commander.option("-w, --watch", "Recompile files on changes.");
|
||||||
commander.option(
|
commander.option(
|
||||||
"--skip-initial-build",
|
"--skip-initial-build",
|
||||||
"Do not compile files before watching",
|
"Do not compile files before watching.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"-o, --out-file [out]",
|
"-o, --out-file [out]",
|
||||||
"Compile all input files into a single file",
|
"Compile all input files into a single file.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"-d, --out-dir [out]",
|
"-d, --out-dir [out]",
|
||||||
"Compile an input directory of modules into an output directory",
|
"Compile an input directory of modules into an output directory.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--relative",
|
"--relative",
|
||||||
@ -138,16 +142,23 @@ commander.option(
|
|||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"-D, --copy-files",
|
"-D, --copy-files",
|
||||||
"When compiling a directory copy over non-compilable files",
|
"When compiling a directory copy over non-compilable files.",
|
||||||
);
|
);
|
||||||
commander.option(
|
commander.option(
|
||||||
"--include-dotfiles",
|
"--include-dotfiles",
|
||||||
"Include dotfiles when compiling and copying non-compilable files",
|
"Include dotfiles when compiling and copying non-compilable files.",
|
||||||
|
);
|
||||||
|
commander.option(
|
||||||
|
"--verbose",
|
||||||
|
"Log everything. This option conflicts with --quiet",
|
||||||
|
);
|
||||||
|
commander.option(
|
||||||
|
"--quiet",
|
||||||
|
"Don't log anything. This option conflicts with --verbose",
|
||||||
);
|
);
|
||||||
commander.option("--verbose", "Log everything");
|
|
||||||
commander.option(
|
commander.option(
|
||||||
"--delete-dir-on-start",
|
"--delete-dir-on-start",
|
||||||
"Delete the out directory before compilation",
|
"Delete the out directory before compilation.",
|
||||||
);
|
);
|
||||||
|
|
||||||
commander.version(pkg.version + " (@babel/core " + version + ")");
|
commander.version(pkg.version + " (@babel/core " + version + ")");
|
||||||
@ -207,6 +218,10 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
|
|||||||
errors.push("--delete-dir-on-start requires --out-dir");
|
errors.push("--delete-dir-on-start requires --out-dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commander.verbose && commander.quiet) {
|
||||||
|
errors.push("--verbose and --quiet cannot be used together");
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!commander.outDir &&
|
!commander.outDir &&
|
||||||
filenames.length === 0 &&
|
filenames.length === 0 &&
|
||||||
@ -282,6 +297,7 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
|
|||||||
copyFiles: opts.copyFiles,
|
copyFiles: opts.copyFiles,
|
||||||
includeDotfiles: opts.includeDotfiles,
|
includeDotfiles: opts.includeDotfiles,
|
||||||
verbose: opts.verbose,
|
verbose: opts.verbose,
|
||||||
|
quiet: opts.quiet,
|
||||||
deleteDirOnStart: opts.deleteDirOnStart,
|
deleteDirOnStart: opts.deleteDirOnStart,
|
||||||
sourceMapTarget: opts.sourceMapTarget,
|
sourceMapTarget: opts.sourceMapTarget,
|
||||||
},
|
},
|
||||||
|
|||||||
1
packages/babel-cli/test/fixtures/babel/filename --out-file deep/in-files/script.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/filename --out-file deep/in-files/script.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
arr.map(x => x * MULTIPLIER);
|
||||||
3
packages/babel-cli/test/fixtures/babel/filename --out-file deep/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/filename --out-file deep/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"args": ["script.js", "--out-file", "folder/nested/script.js"]
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
arr.map(function (x) {
|
||||||
|
return x * MULTIPLIER;
|
||||||
|
});
|
||||||
5
packages/babel-cli/test/fixtures/babel/stdin --filename windows/options.json
vendored
Normal file
5
packages/babel-cli/test/fixtures/babel/stdin --filename windows/options.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"args": ["--filename", "test.js"],
|
||||||
|
"stderrContains": true,
|
||||||
|
"os": ["win32"]
|
||||||
|
}
|
||||||
1
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stderr.txt
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stderr.txt
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
SyntaxError: <CWD>\test.js: Unexpected token, expected ";" (2:10)
|
||||||
3
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stdin.txt
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin --filename windows/stdin.txt
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
arr.map(function () {
|
||||||
|
return $]!;
|
||||||
|
});
|
||||||
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"args": ["--filename", "test.js"],
|
"args": ["--filename", "test.js"],
|
||||||
"stderrContains": true
|
"stderrContains": true,
|
||||||
|
"os": ["linux", "darwin"]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const readdir = require("fs-readdir-recursive");
|
const readdir = require("fs-readdir-recursive");
|
||||||
const helper = require("@babel/helper-fixtures");
|
const helper = require("@babel/helper-fixtures");
|
||||||
const rimraf = require("rimraf");
|
const rimraf = require("rimraf");
|
||||||
const outputFileSync = require("output-file-sync");
|
const { sync: makeDirSync } = require("make-dir");
|
||||||
const child = require("child_process");
|
const child = require("child_process");
|
||||||
const merge = require("lodash/merge");
|
const merge = require("lodash/merge");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
@ -14,6 +14,11 @@ const fileFilter = function(x) {
|
|||||||
return x !== ".DS_Store";
|
return x !== ".DS_Store";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const outputFileSync = function(filePath, data) {
|
||||||
|
makeDirSync(path.dirname(filePath));
|
||||||
|
fs.writeFileSync(filePath, data);
|
||||||
|
};
|
||||||
|
|
||||||
const presetLocs = [path.join(__dirname, "../../babel-preset-react")];
|
const presetLocs = [path.join(__dirname, "../../babel-preset-react")];
|
||||||
|
|
||||||
const pluginLocs = [
|
const pluginLocs = [
|
||||||
@ -115,13 +120,6 @@ const buildTest = function(binName, testName, opts) {
|
|||||||
const binLoc = path.join(__dirname, "../lib", binName);
|
const binLoc = path.join(__dirname, "../lib", binName);
|
||||||
|
|
||||||
return function(callback) {
|
return function(callback) {
|
||||||
const dir = process.cwd();
|
|
||||||
|
|
||||||
process.chdir(__dirname);
|
|
||||||
if (fs.existsSync(tmpLoc)) rimraf.sync(tmpLoc);
|
|
||||||
fs.mkdirSync(tmpLoc);
|
|
||||||
process.chdir(tmpLoc);
|
|
||||||
|
|
||||||
saveInFiles(opts.inFiles);
|
saveInFiles(opts.inFiles);
|
||||||
|
|
||||||
let args = [binLoc];
|
let args = [binLoc];
|
||||||
@ -159,7 +157,6 @@ const buildTest = function(binName, testName, opts) {
|
|||||||
args.map(arg => `"${arg}"`).join(" ") + ": " + err.message;
|
args.map(arg => `"${arg}"`).join(" ") + ": " + err.message;
|
||||||
}
|
}
|
||||||
|
|
||||||
process.chdir(dir);
|
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -175,6 +172,26 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
|||||||
|
|
||||||
const suiteLoc = path.join(fixtureLoc, binName);
|
const suiteLoc = path.join(fixtureLoc, binName);
|
||||||
describe("bin/" + binName, function() {
|
describe("bin/" + binName, function() {
|
||||||
|
let cwd;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
cwd = process.cwd();
|
||||||
|
|
||||||
|
if (fs.existsSync(tmpLoc)) {
|
||||||
|
for (const child of fs.readdirSync(tmpLoc)) {
|
||||||
|
rimraf.sync(path.join(tmpLoc, child));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fs.mkdirSync(tmpLoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.chdir(tmpLoc);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
process.chdir(cwd);
|
||||||
|
});
|
||||||
|
|
||||||
fs.readdirSync(suiteLoc).forEach(function(testName) {
|
fs.readdirSync(suiteLoc).forEach(function(testName) {
|
||||||
if (testName.startsWith(".")) return;
|
if (testName.startsWith(".")) return;
|
||||||
|
|
||||||
@ -185,7 +202,29 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const optionsLoc = path.join(testLoc, "options.json");
|
const optionsLoc = path.join(testLoc, "options.json");
|
||||||
if (fs.existsSync(optionsLoc)) merge(opts, require(optionsLoc));
|
if (fs.existsSync(optionsLoc)) {
|
||||||
|
const taskOpts = require(optionsLoc);
|
||||||
|
if (taskOpts.os) {
|
||||||
|
let os = taskOpts.os;
|
||||||
|
|
||||||
|
if (!Array.isArray(os) && typeof os !== "string") {
|
||||||
|
throw new Error(
|
||||||
|
`'os' should be either string or string array: ${taskOpts.os}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof os === "string") {
|
||||||
|
os = [os];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!os.includes(process.platform)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete taskOpts.os;
|
||||||
|
}
|
||||||
|
merge(opts, taskOpts);
|
||||||
|
}
|
||||||
|
|
||||||
["stdout", "stdin", "stderr"].forEach(function(key) {
|
["stdout", "stdin", "stderr"].forEach(function(key) {
|
||||||
const loc = path.join(testLoc, key + ".txt");
|
const loc = path.join(testLoc, key + ".txt");
|
||||||
@ -205,7 +244,7 @@ fs.readdirSync(fixtureLoc).forEach(function(binName) {
|
|||||||
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
|
opts.inFiles[".babelrc"] = helper.readFile(babelrcLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
it(testName, buildTest(binName, testName, opts));
|
it(testName, buildTest(binName, testName, opts), 20000);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/core",
|
"name": "@babel/core",
|
||||||
"version": "7.6.2",
|
"version": "7.7.2",
|
||||||
"description": "Babel compiler core.",
|
"description": "Babel compiler core.",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
@ -34,13 +34,13 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": "^7.5.5",
|
"@babel/code-frame": "^7.5.5",
|
||||||
"@babel/generator": "^7.6.2",
|
"@babel/generator": "^7.7.2",
|
||||||
"@babel/helpers": "^7.6.2",
|
"@babel/helpers": "^7.7.0",
|
||||||
"@babel/parser": "^7.6.2",
|
"@babel/parser": "^7.7.2",
|
||||||
"@babel/template": "^7.6.0",
|
"@babel/template": "^7.7.0",
|
||||||
"@babel/traverse": "^7.6.2",
|
"@babel/traverse": "^7.7.2",
|
||||||
"@babel/types": "^7.6.0",
|
"@babel/types": "^7.7.2",
|
||||||
"convert-source-map": "^1.1.0",
|
"convert-source-map": "^1.7.0",
|
||||||
"debug": "^4.1.0",
|
"debug": "^4.1.0",
|
||||||
"json5": "^2.1.0",
|
"json5": "^2.1.0",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.13",
|
||||||
@ -49,6 +49,6 @@
|
|||||||
"source-map": "^0.5.0"
|
"source-map": "^0.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/helper-transform-fixture-test-runner": "^7.6.0"
|
"@babel/helper-transform-fixture-test-runner": "^7.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -345,6 +345,7 @@ function assertNoDuplicates(items: Array<UnloadedDescriptor>): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nameMap.has(item.name)) {
|
if (nameMap.has(item.name)) {
|
||||||
|
const conflicts = items.filter(i => i.value === item.value);
|
||||||
throw new Error(
|
throw new Error(
|
||||||
[
|
[
|
||||||
`Duplicate plugin/preset detected.`,
|
`Duplicate plugin/preset detected.`,
|
||||||
@ -355,6 +356,9 @@ function assertNoDuplicates(items: Array<UnloadedDescriptor>): void {
|
|||||||
` ['some-plugin', {}],`,
|
` ['some-plugin', {}],`,
|
||||||
` ['some-plugin', {}, 'some unique name'],`,
|
` ['some-plugin', {}, 'some unique name'],`,
|
||||||
` ]`,
|
` ]`,
|
||||||
|
``,
|
||||||
|
`Duplicates detected are:`,
|
||||||
|
`${JSON.stringify(conflicts, null, 2)}`,
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,18 +18,22 @@ import type { CallerMetadata } from "../validation/options";
|
|||||||
|
|
||||||
const debug = buildDebug("babel:config:loading:files:configuration");
|
const debug = buildDebug("babel:config:loading:files:configuration");
|
||||||
|
|
||||||
const BABEL_CONFIG_JS_FILENAME = "babel.config.js";
|
const ROOT_CONFIG_FILENAMES = [
|
||||||
|
"babel.config.js",
|
||||||
|
"babel.config.cjs",
|
||||||
|
"babel.config.json",
|
||||||
|
];
|
||||||
|
const RELATIVE_CONFIG_FILENAMES = [".babelrc", ".babelrc.js", ".babelrc.cjs"];
|
||||||
|
|
||||||
const BABELRC_FILENAME = ".babelrc";
|
|
||||||
const BABELRC_JS_FILENAME = ".babelrc.js";
|
|
||||||
const BABELIGNORE_FILENAME = ".babelignore";
|
const BABELIGNORE_FILENAME = ".babelignore";
|
||||||
|
|
||||||
export function findConfigUpwards(rootDir: string): string | null {
|
export function findConfigUpwards(rootDir: string): string | null {
|
||||||
let dirname = rootDir;
|
let dirname = rootDir;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (fs.existsSync(path.join(dirname, BABEL_CONFIG_JS_FILENAME))) {
|
const configFileFound = ROOT_CONFIG_FILENAMES.some(filename =>
|
||||||
return dirname;
|
fs.existsSync(path.join(dirname, filename)),
|
||||||
}
|
);
|
||||||
|
if (configFileFound) return dirname;
|
||||||
|
|
||||||
const nextDir = path.dirname(dirname);
|
const nextDir = path.dirname(dirname);
|
||||||
if (dirname === nextDir) break;
|
if (dirname === nextDir) break;
|
||||||
@ -51,45 +55,15 @@ export function findRelativeConfig(
|
|||||||
|
|
||||||
for (const loc of packageData.directories) {
|
for (const loc of packageData.directories) {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce(
|
config = loadOneConfig(
|
||||||
(previousConfig: ConfigFile | null, name) => {
|
RELATIVE_CONFIG_FILENAMES,
|
||||||
const filepath = path.join(loc, name);
|
loc,
|
||||||
const config = readConfig(filepath, envName, caller);
|
envName,
|
||||||
|
caller,
|
||||||
if (config && previousConfig) {
|
|
||||||
throw new Error(
|
|
||||||
`Multiple configuration files found. Please remove one:\n` +
|
|
||||||
` - ${path.basename(previousConfig.filepath)}\n` +
|
|
||||||
` - ${name}\n` +
|
|
||||||
`from ${loc}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return config || previousConfig;
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
|
|
||||||
const pkgConfig =
|
|
||||||
packageData.pkg && packageData.pkg.dirname === loc
|
packageData.pkg && packageData.pkg.dirname === loc
|
||||||
? packageToBabelConfig(packageData.pkg)
|
? packageToBabelConfig(packageData.pkg)
|
||||||
: null;
|
: null,
|
||||||
|
);
|
||||||
if (pkgConfig) {
|
|
||||||
if (config) {
|
|
||||||
throw new Error(
|
|
||||||
`Multiple configuration files found. Please remove one:\n` +
|
|
||||||
` - ${path.basename(pkgConfig.filepath)}#babel\n` +
|
|
||||||
` - ${path.basename(config.filepath)}\n` +
|
|
||||||
`from ${loc}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
config = pkgConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config) {
|
|
||||||
debug("Found configuration %o from %o.", config.filepath, dirname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignore) {
|
if (!ignore) {
|
||||||
@ -110,13 +84,36 @@ export function findRootConfig(
|
|||||||
envName: string,
|
envName: string,
|
||||||
caller: CallerMetadata | void,
|
caller: CallerMetadata | void,
|
||||||
): ConfigFile | null {
|
): ConfigFile | null {
|
||||||
const filepath = path.resolve(dirname, BABEL_CONFIG_JS_FILENAME);
|
return loadOneConfig(ROOT_CONFIG_FILENAMES, dirname, envName, caller);
|
||||||
|
}
|
||||||
|
|
||||||
const conf = readConfig(filepath, envName, caller);
|
function loadOneConfig(
|
||||||
if (conf) {
|
names: string[],
|
||||||
debug("Found root config %o in %o.", BABEL_CONFIG_JS_FILENAME, dirname);
|
dirname: string,
|
||||||
|
envName: string,
|
||||||
|
caller: CallerMetadata | void,
|
||||||
|
previousConfig?: ConfigFile | null = null,
|
||||||
|
): ConfigFile | null {
|
||||||
|
const config = names.reduce((previousConfig: ConfigFile | null, name) => {
|
||||||
|
const filepath = path.resolve(dirname, name);
|
||||||
|
const config = readConfig(filepath, envName, caller);
|
||||||
|
|
||||||
|
if (config && previousConfig) {
|
||||||
|
throw new Error(
|
||||||
|
`Multiple configuration files found. Please remove one:\n` +
|
||||||
|
` - ${path.basename(previousConfig.filepath)}\n` +
|
||||||
|
` - ${name}\n` +
|
||||||
|
`from ${dirname}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return config || previousConfig;
|
||||||
|
}, previousConfig);
|
||||||
|
|
||||||
|
if (config) {
|
||||||
|
debug("Found configuration %o from %o.", config.filepath, dirname);
|
||||||
}
|
}
|
||||||
return conf;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadConfig(
|
export function loadConfig(
|
||||||
@ -141,7 +138,8 @@ export function loadConfig(
|
|||||||
* throw if there are parsing errors while loading a config.
|
* throw if there are parsing errors while loading a config.
|
||||||
*/
|
*/
|
||||||
function readConfig(filepath, envName, caller): ConfigFile | null {
|
function readConfig(filepath, envName, caller): ConfigFile | null {
|
||||||
return path.extname(filepath) === ".js"
|
const ext = path.extname(filepath);
|
||||||
|
return ext === ".js" || ext === ".cjs"
|
||||||
? readConfigJS(filepath, { envName, caller })
|
? readConfigJS(filepath, { envName, caller })
|
||||||
: readConfigJSON5(filepath);
|
: readConfigJSON5(filepath);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ function assertVersion(range: string | number): void {
|
|||||||
throw new Error("Expected string or integer value.");
|
throw new Error("Expected string or integer value.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (semver.satisfies(coreVersion, range)) return;
|
if (semver.satisfies(semver.coerce(coreVersion).raw, range)) return;
|
||||||
|
|
||||||
const limit = Error.stackTraceLimit;
|
const limit = Error.stackTraceLimit;
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,17 @@ const errorVisitor = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type NodeLocation = {
|
||||||
|
loc?: {
|
||||||
|
end?: { line: number, column: number },
|
||||||
|
start: { line: number, column: number },
|
||||||
|
},
|
||||||
|
_loc?: {
|
||||||
|
end?: { line: number, column: number },
|
||||||
|
start: { line: number, column: number },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export default class File {
|
export default class File {
|
||||||
_map: Map<any, any> = new Map();
|
_map: Map<any, any> = new Map();
|
||||||
opts: Object;
|
opts: Object;
|
||||||
@ -250,17 +261,12 @@ export default class File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildCodeFrameError(
|
buildCodeFrameError(
|
||||||
node: ?{
|
node: ?NodeLocation,
|
||||||
loc?: { start: { line: number, column: number } },
|
|
||||||
_loc?: { start: { line: number, column: number } },
|
|
||||||
},
|
|
||||||
msg: string,
|
msg: string,
|
||||||
Error: typeof Error = SyntaxError,
|
Error: typeof Error = SyntaxError,
|
||||||
): Error {
|
): Error {
|
||||||
let loc = node && (node.loc || node._loc);
|
let loc = node && (node.loc || node._loc);
|
||||||
|
|
||||||
msg = `${this.opts.filename}: ${msg}`;
|
|
||||||
|
|
||||||
if (!loc && node) {
|
if (!loc && node) {
|
||||||
const state = {
|
const state = {
|
||||||
loc: null,
|
loc: null,
|
||||||
@ -287,6 +293,13 @@ export default class File {
|
|||||||
line: loc.start.line,
|
line: loc.start.line,
|
||||||
column: loc.start.column + 1,
|
column: loc.start.column + 1,
|
||||||
},
|
},
|
||||||
|
end:
|
||||||
|
loc.end && loc.start.line === loc.end.line
|
||||||
|
? {
|
||||||
|
line: loc.end.line,
|
||||||
|
column: loc.end.column + 1,
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
{ highlightCode },
|
{ highlightCode },
|
||||||
);
|
);
|
||||||
|
|||||||
@ -41,7 +41,7 @@ export default function generateCode(
|
|||||||
|
|
||||||
if (typeof result.then === "function") {
|
if (typeof result.then === "function") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`You appear to be using an async parser plugin, ` +
|
`You appear to be using an async codegen plugin, ` +
|
||||||
`which your current version of Babel does not support. ` +
|
`which your current version of Babel does not support. ` +
|
||||||
`If you're using a published plugin, ` +
|
`If you're using a published plugin, ` +
|
||||||
`you may need to upgrade your @babel/core version.`,
|
`you may need to upgrade your @babel/core version.`,
|
||||||
|
|||||||
@ -55,11 +55,29 @@ export function runSync(
|
|||||||
ast,
|
ast,
|
||||||
);
|
);
|
||||||
|
|
||||||
transformFile(file, config.passes);
|
|
||||||
|
|
||||||
const opts = file.opts;
|
const opts = file.opts;
|
||||||
const { outputCode, outputMap } =
|
try {
|
||||||
opts.code !== false ? generateCode(config.passes, file) : {};
|
transformFile(file, config.passes);
|
||||||
|
} catch (e) {
|
||||||
|
e.message = `${opts.filename ?? "unknown"}: ${e.message}`;
|
||||||
|
if (!e.code) {
|
||||||
|
e.code = "BABEL_TRANSFORM_ERROR";
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
let outputCode, outputMap;
|
||||||
|
try {
|
||||||
|
if (opts.code !== false) {
|
||||||
|
({ outputCode, outputMap } = generateCode(config.passes, file));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
e.message = `${opts.filename ?? "unknown"}: ${e.message}`;
|
||||||
|
if (!e.code) {
|
||||||
|
e.code = "BABEL_GENERATE_ERROR";
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
metadata: file.metadata,
|
metadata: file.metadata,
|
||||||
|
|||||||
@ -65,7 +65,8 @@ export default function normalizeFile(
|
|||||||
if (typeof options.filename === "string" && lastComment) {
|
if (typeof options.filename === "string" && lastComment) {
|
||||||
try {
|
try {
|
||||||
inputMap = convertSourceMap.fromMapFileComment(
|
inputMap = convertSourceMap.fromMapFileComment(
|
||||||
lastComment,
|
// fromMapFileComment requires the whole comment block
|
||||||
|
`//${lastComment}`,
|
||||||
path.dirname(options.filename),
|
path.dirname(options.filename),
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -107,7 +108,7 @@ function parser(
|
|||||||
} else if (results.length === 1) {
|
} else if (results.length === 1) {
|
||||||
if (typeof results[0].then === "function") {
|
if (typeof results[0].then === "function") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`You appear to be using an async codegen plugin, ` +
|
`You appear to be using an async parser plugin, ` +
|
||||||
`which your current version of Babel does not support. ` +
|
`which your current version of Babel does not support. ` +
|
||||||
`If you're using a published plugin, you may need to upgrade ` +
|
`If you're using a published plugin, you may need to upgrade ` +
|
||||||
`your @babel/core version.`,
|
`your @babel/core version.`,
|
||||||
@ -121,6 +122,7 @@ function parser(
|
|||||||
err.message +=
|
err.message +=
|
||||||
"\nConsider renaming the file to '.mjs', or setting sourceType:module " +
|
"\nConsider renaming the file to '.mjs', or setting sourceType:module " +
|
||||||
"or sourceType:unambiguous in your Babel config for this file.";
|
"or sourceType:unambiguous in your Babel config for this file.";
|
||||||
|
// err.code will be changed to BABEL_PARSE_ERROR later.
|
||||||
}
|
}
|
||||||
|
|
||||||
const { loc, missingPlugin } = err;
|
const { loc, missingPlugin } = err;
|
||||||
@ -155,7 +157,7 @@ function parser(
|
|||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
const INLINE_SOURCEMAP_REGEX = /^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
|
||||||
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=([^\s'"`]+?)[ \t]*$/;
|
const EXTERNAL_SOURCEMAP_REGEX = /^[@#][ \t]+sourceMappingURL=(?:[^\s'"`]+?)[ \t]*$/;
|
||||||
|
|
||||||
function extractCommentsFromList(regex, comments, lastComment) {
|
function extractCommentsFromList(regex, comments, lastComment) {
|
||||||
if (comments) {
|
if (comments) {
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import type File from "./file/file";
|
import type File from "./file/file";
|
||||||
|
import type NodeLocation from "./file/file";
|
||||||
|
|
||||||
export default class PluginPass {
|
export default class PluginPass {
|
||||||
_map: Map<mixed, mixed> = new Map();
|
_map: Map<mixed, mixed> = new Map();
|
||||||
@ -47,14 +48,7 @@ export default class PluginPass {
|
|||||||
return this.file.getModuleName();
|
return this.file.getModuleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCodeFrameError(
|
buildCodeFrameError(node: ?NodeLocation, msg: string, Error?: typeof Error) {
|
||||||
node: ?{
|
|
||||||
loc?: { start: { line: number, column: number } },
|
|
||||||
_loc?: { start: { line: number, column: number } },
|
|
||||||
},
|
|
||||||
msg: string,
|
|
||||||
Error?: typeof Error,
|
|
||||||
) {
|
|
||||||
return this.file.buildCodeFrameError(node, msg, Error);
|
return this.file.buildCodeFrameError(node, msg, Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,44 @@
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
|
import os from "os";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import escapeRegExp from "lodash/escapeRegExp";
|
||||||
import { loadOptions as loadOptionsOrig } from "../lib";
|
import { loadOptions as loadOptionsOrig } from "../lib";
|
||||||
|
|
||||||
|
// TODO: In Babel 8, we can directly uses fs.promises which is supported by
|
||||||
|
// node 8+
|
||||||
|
const pfs =
|
||||||
|
fs.promises ??
|
||||||
|
new Proxy(fs, {
|
||||||
|
get(target, name) {
|
||||||
|
if (name === "copyFile") {
|
||||||
|
// fs.copyFile is only supported since node 8.5
|
||||||
|
// https://stackoverflow.com/a/30405105/2359289
|
||||||
|
return function copyFile(source, target) {
|
||||||
|
const rd = fs.createReadStream(source);
|
||||||
|
const wr = fs.createWriteStream(target);
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
rd.on("error", reject);
|
||||||
|
wr.on("error", reject);
|
||||||
|
wr.on("finish", resolve);
|
||||||
|
rd.pipe(wr);
|
||||||
|
}).catch(function(error) {
|
||||||
|
rd.destroy();
|
||||||
|
wr.end();
|
||||||
|
throw error;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return (...args) =>
|
||||||
|
new Promise((resolve, reject) =>
|
||||||
|
target[name](...args, (error, result) => {
|
||||||
|
if (error) reject(error);
|
||||||
|
else resolve(result);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
function fixture(...args) {
|
function fixture(...args) {
|
||||||
return path.join(__dirname, "fixtures", "config", ...args);
|
return path.join(__dirname, "fixtures", "config", ...args);
|
||||||
}
|
}
|
||||||
@ -13,6 +50,24 @@ function loadOptions(opts) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pairs(items) {
|
||||||
|
const pairs = [];
|
||||||
|
for (let i = 0; i < items.length - 1; i++) {
|
||||||
|
for (let j = i + 1; j < items.length; j++) {
|
||||||
|
pairs.push([items[i], items[j]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getTemp(name) {
|
||||||
|
const cwd = await pfs.mkdtemp(os.tmpdir() + path.sep + name);
|
||||||
|
const tmp = name => path.join(cwd, name);
|
||||||
|
const config = name =>
|
||||||
|
pfs.copyFile(fixture("config-files-templates", name), tmp(name));
|
||||||
|
return { cwd, tmp, config };
|
||||||
|
}
|
||||||
|
|
||||||
describe("buildConfigChain", function() {
|
describe("buildConfigChain", function() {
|
||||||
describe("test", () => {
|
describe("test", () => {
|
||||||
describe("single", () => {
|
describe("single", () => {
|
||||||
@ -33,7 +88,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
test: new RegExp(fixture("nonexistant-fake")),
|
test: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,7 +124,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
test: new RegExp(fixture("nonexistant-unknown")),
|
test: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -107,7 +162,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
test: [new RegExp(fixture("nonexistant-fake"))],
|
test: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -143,7 +198,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
test: [new RegExp(fixture("nonexistant-unknown"))],
|
test: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -183,7 +238,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
include: new RegExp(fixture("nonexistant-fake")),
|
include: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -219,7 +274,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
include: new RegExp(fixture("nonexistant-unknown")),
|
include: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -257,7 +312,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
include: [new RegExp(fixture("nonexistant-fake"))],
|
include: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -293,7 +348,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
include: [new RegExp(fixture("nonexistant-unknown"))],
|
include: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -333,7 +388,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
exclude: new RegExp(fixture("nonexistant-fake")),
|
exclude: new RegExp(escapeRegExp(fixture("nonexistant-fake"))),
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -369,7 +424,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
exclude: new RegExp(fixture("nonexistant-unknown")),
|
exclude: new RegExp(escapeRegExp(fixture("nonexistant-unknown"))),
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -407,7 +462,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
exclude: [new RegExp(fixture("nonexistant-fake"))],
|
exclude: [new RegExp(escapeRegExp(fixture("nonexistant-fake")))],
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -443,7 +498,7 @@ describe("buildConfigChain", function() {
|
|||||||
cwd: fixture("nonexistant-fake"),
|
cwd: fixture("nonexistant-fake"),
|
||||||
filename: fixture("nonexistant-fake", "src.js"),
|
filename: fixture("nonexistant-fake", "src.js"),
|
||||||
babelrc: false,
|
babelrc: false,
|
||||||
exclude: [new RegExp(fixture("nonexistant-unknown"))],
|
exclude: [new RegExp(escapeRegExp(fixture("nonexistant-unknown")))],
|
||||||
comments: true,
|
comments: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -943,113 +998,122 @@ describe("buildConfigChain", function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load .babelrc", () => {
|
describe("root", () => {
|
||||||
const filename = fixture("config-files", "babelrc", "src.js");
|
test.each(["babel.config.json", "babel.config.js", "babel.config.cjs"])(
|
||||||
|
"should load %s",
|
||||||
|
async name => {
|
||||||
|
const { cwd, tmp, config } = await getTemp(
|
||||||
|
`babel-test-load-config-${name}`,
|
||||||
|
);
|
||||||
|
const filename = tmp("src.js");
|
||||||
|
|
||||||
expect(
|
await config(name);
|
||||||
loadOptions({
|
|
||||||
filename,
|
expect(
|
||||||
|
loadOptions({
|
||||||
|
filename,
|
||||||
|
cwd,
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
...getDefaults(),
|
||||||
|
filename,
|
||||||
|
cwd,
|
||||||
|
root: cwd,
|
||||||
|
comments: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
test.each(
|
||||||
|
pairs(["babel.config.json", "babel.config.js", "babel.config.cjs"]),
|
||||||
|
)("should throw if both %s and %s are used", async (name1, name2) => {
|
||||||
|
const { cwd, tmp, config } = await getTemp(
|
||||||
|
`babel-test-dup-config-${name1}-${name2}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all([config(name1), config(name2)]);
|
||||||
|
|
||||||
|
expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow(
|
||||||
|
/Multiple configuration files found/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("relative", () => {
|
||||||
|
test.each(["package.json", ".babelrc", ".babelrc.js", ".babelrc.cjs"])(
|
||||||
|
"should load %s",
|
||||||
|
async name => {
|
||||||
|
const { cwd, tmp, config } = await getTemp(
|
||||||
|
`babel-test-load-config-${name}`,
|
||||||
|
);
|
||||||
|
const filename = tmp("src.js");
|
||||||
|
|
||||||
|
await config(name);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
loadOptions({
|
||||||
|
filename,
|
||||||
|
cwd,
|
||||||
|
}),
|
||||||
|
).toEqual({
|
||||||
|
...getDefaults(),
|
||||||
|
filename,
|
||||||
|
cwd,
|
||||||
|
root: cwd,
|
||||||
|
comments: true,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
it("should load .babelignore", () => {
|
||||||
|
const filename = fixture("config-files", "babelignore", "src.js");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
loadOptions({ filename, cwd: path.dirname(filename) }),
|
||||||
|
).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(
|
||||||
|
pairs(["package.json", ".babelrc", ".babelrc.js", ".babelrc.cjs"]),
|
||||||
|
)("should throw if both %s and %s are used", async (name1, name2) => {
|
||||||
|
const { cwd, tmp, config } = await getTemp(
|
||||||
|
`babel-test-dup-config-${name1}-${name2}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all([config(name1), config(name2)]);
|
||||||
|
|
||||||
|
expect(() => loadOptions({ filename: tmp("src.js"), cwd })).toThrow(
|
||||||
|
/Multiple configuration files found/,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should ignore package.json without a 'babel' property", () => {
|
||||||
|
const filename = fixture("config-files", "pkg-ignored", "src.js");
|
||||||
|
|
||||||
|
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
|
||||||
|
...getDefaults(),
|
||||||
|
filename: filename,
|
||||||
cwd: path.dirname(filename),
|
cwd: path.dirname(filename),
|
||||||
}),
|
root: path.dirname(filename),
|
||||||
).toEqual({
|
comments: true,
|
||||||
...getDefaults(),
|
});
|
||||||
filename: filename,
|
|
||||||
cwd: path.dirname(filename),
|
|
||||||
root: path.dirname(filename),
|
|
||||||
comments: true,
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
it("should load .babelrc.js", () => {
|
test.each`
|
||||||
const filename = fixture("config-files", "babelrc-js", "src.js");
|
config | dir | error
|
||||||
|
${".babelrc"} | ${"babelrc-error"} | ${/Error while parsing config - /}
|
||||||
|
${".babelrc.js"} | ${"babelrc-js-error"} | ${/Babelrc threw an error/}
|
||||||
|
${".babelrc.cjs"} | ${"babelrc-cjs-error"} | ${/Babelrc threw an error/}
|
||||||
|
${"package.json"} | ${"pkg-error"} | ${/Error while parsing JSON - /}
|
||||||
|
`("should show helpful errors for $config", ({ dir, error }) => {
|
||||||
|
const filename = fixture("config-files", dir, "src.js");
|
||||||
|
|
||||||
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
|
expect(() =>
|
||||||
...getDefaults(),
|
loadOptions({ filename, cwd: path.dirname(filename) }),
|
||||||
filename: filename,
|
).toThrow(error);
|
||||||
cwd: path.dirname(filename),
|
|
||||||
root: path.dirname(filename),
|
|
||||||
comments: true,
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should load package.json#babel", () => {
|
|
||||||
const filename = fixture("config-files", "pkg", "src.js");
|
|
||||||
|
|
||||||
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
|
|
||||||
...getDefaults(),
|
|
||||||
filename: filename,
|
|
||||||
cwd: path.dirname(filename),
|
|
||||||
root: path.dirname(filename),
|
|
||||||
comments: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should load .babelignore", () => {
|
|
||||||
const filename = fixture("config-files", "babelignore", "src.js");
|
|
||||||
|
|
||||||
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should throw if there are both .babelrc and .babelrc.js", () => {
|
|
||||||
const filename = fixture("config-files", "both-babelrc", "src.js");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
|
||||||
).toThrow(/Multiple configuration files found/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should throw if there are both .babelrc and package.json", () => {
|
|
||||||
const filename = fixture("config-files", "pkg-babelrc", "src.js");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
|
||||||
).toThrow(/Multiple configuration files found/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should throw if there are both .babelrc.js and package.json", () => {
|
|
||||||
const filename = fixture("config-files", "pkg-babelrc-js", "src.js");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
|
||||||
).toThrow(/Multiple configuration files found/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should ignore package.json without a 'babel' property", () => {
|
|
||||||
const filename = fixture("config-files", "pkg-ignored", "src.js");
|
|
||||||
|
|
||||||
expect(loadOptions({ filename, cwd: path.dirname(filename) })).toEqual({
|
|
||||||
...getDefaults(),
|
|
||||||
filename: filename,
|
|
||||||
cwd: path.dirname(filename),
|
|
||||||
root: path.dirname(filename),
|
|
||||||
comments: true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show helpful errors for .babelrc", () => {
|
|
||||||
const filename = fixture("config-files", "babelrc-error", "src.js");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
|
||||||
).toThrow(/Error while parsing config - /);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show helpful errors for .babelrc.js", () => {
|
|
||||||
const filename = fixture("config-files", "babelrc-js-error", "src.js");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
|
||||||
).toThrow(/Babelrc threw an error/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should show helpful errors for package.json", () => {
|
|
||||||
const filename = fixture("config-files", "pkg-error", "src.js");
|
|
||||||
|
|
||||||
expect(() =>
|
|
||||||
loadOptions({ filename, cwd: path.dirname(filename) }),
|
|
||||||
).toThrow(/Error while parsing JSON - /);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should throw when `test` presents but `filename` is not passed", () => {
|
it("should throw when `test` presents but `filename` is not passed", () => {
|
||||||
expect(() => loadOptions({ test: /\.ts$/, plugins: [] })).toThrow(
|
expect(() => loadOptions({ test: /\.ts$/, plugins: [] })).toThrow(
|
||||||
/Configuration contains string\/RegExp pattern/,
|
/Configuration contains string\/RegExp pattern/,
|
||||||
|
|||||||
3
packages/babel-core/test/fixtures/config/config-files-templates/.babelrc
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files-templates/.babelrc
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"comments": true
|
||||||
|
}
|
||||||
3
packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.cjs
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.cjs
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
comments: true
|
||||||
|
};
|
||||||
3
packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.js
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files-templates/.babelrc.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
comments: true
|
||||||
|
};
|
||||||
3
packages/babel-core/test/fixtures/config/config-files-templates/babel.config.cjs
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files-templates/babel.config.cjs
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
comments: true
|
||||||
|
};
|
||||||
3
packages/babel-core/test/fixtures/config/config-files-templates/babel.config.js
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files-templates/babel.config.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
comments: true
|
||||||
|
};
|
||||||
3
packages/babel-core/test/fixtures/config/config-files-templates/babel.config.json
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files-templates/babel.config.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"comments": true
|
||||||
|
}
|
||||||
3
packages/babel-core/test/fixtures/config/config-files/babelrc-cjs-error/.babelrc.cjs
vendored
Normal file
3
packages/babel-core/test/fixtures/config/config-files/babelrc-cjs-error/.babelrc.cjs
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function() {
|
||||||
|
throw new Error("Babelrc threw an error");
|
||||||
|
};
|
||||||
@ -1,3 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
comments: true,
|
|
||||||
};
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
comments: true,
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
module.exports = {};
|
|
||||||
@ -1 +0,0 @@
|
|||||||
module.exports = {};
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"babel": {}
|
|
||||||
}
|
|
||||||
@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"babel": {}
|
|
||||||
}
|
|
||||||
@ -2,6 +2,7 @@
|
|||||||
"type": "File",
|
"type": "File",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 91,
|
"end": 91,
|
||||||
|
"errors": [],
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
|
|||||||
@ -1,16 +1,18 @@
|
|||||||
var code = "function f() {}";
|
expect(() => {
|
||||||
transform(code, {
|
var code = "function f() {}";
|
||||||
plugins: [
|
transform(code, {
|
||||||
function() {
|
plugins: [
|
||||||
return {
|
function() {
|
||||||
visitor: {
|
return {
|
||||||
FunctionDeclaration: function(path) {
|
visitor: {
|
||||||
throw path.buildCodeFrameError("someMsg");
|
FunctionDeclaration: function(path) {
|
||||||
|
throw path.buildCodeFrameError("someMsg");
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
};
|
},
|
||||||
},
|
],
|
||||||
],
|
// hard to assert on ANSI escape codes
|
||||||
// hard to assert on ANSI escape codes
|
highlightCode: false,
|
||||||
highlightCode: false,
|
});
|
||||||
});
|
}).toThrow(/^unknown: someMsg\s+> 1 \| function f\(\) {}/);
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
{
|
|
||||||
"throws": "undefined: someMsg\n> 1 | function f() {}"
|
|
||||||
}
|
|
||||||
15
packages/babel-core/test/fixtures/plugins/transform-error/exec.js
vendored
Normal file
15
packages/babel-core/test/fixtures/plugins/transform-error/exec.js
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
var code = "function f() {}";
|
||||||
|
transform(code, {
|
||||||
|
plugins: [
|
||||||
|
function() {
|
||||||
|
return {
|
||||||
|
visitor: {
|
||||||
|
FunctionDeclaration: function(path) {
|
||||||
|
throw new Error("someMsg");
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
],
|
||||||
|
filename: "/fake/path/example.js"
|
||||||
|
});
|
||||||
4
packages/babel-core/test/fixtures/plugins/transform-error/options.json
vendored
Normal file
4
packages/babel-core/test/fixtures/plugins/transform-error/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"throws": "/fake/path/example.js: someMsg",
|
||||||
|
"os": ["linux", "darwin"]
|
||||||
|
}
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
var foo = function () {
|
||||||
|
return 4;
|
||||||
|
};
|
||||||
|
|
||||||
|
//# sourceMappingURL=input.js.map
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"sources":["original.js"],"names":[],"mappings":"AAAA,UAAU,Y;SAAM,C;CAAC","sourcesContent":["var foo = () => 4;"]}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"inputSourceMap": true
|
||||||
|
}
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
var foo = function () {
|
||||||
|
return 4;
|
||||||
|
};
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"mappings": "AAAA,IAAA,GAAA,GAAU,Y;SAAM,C;AAAC,CAAjB",
|
||||||
|
"names": [],
|
||||||
|
"sources": ["original.js"],
|
||||||
|
"sourcesContent": ["var foo = () => 4;"],
|
||||||
|
"version": 3
|
||||||
|
}
|
||||||
@ -27,14 +27,19 @@ describe("option-manager", () => {
|
|||||||
return { plugin, calls };
|
return { plugin, calls };
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should throw if a plugin is repeated", () => {
|
it("should throw if a plugin is repeated, with information about the repeated plugin", () => {
|
||||||
const { calls, plugin } = makePlugin();
|
const { calls, plugin } = makePlugin("my-plugin");
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
loadOptions({
|
loadOptions({
|
||||||
plugins: [plugin, plugin],
|
plugins: [
|
||||||
|
[plugin, undefined, "my-plugin"],
|
||||||
|
[plugin, undefined, "my-plugin"],
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}).toThrow(/Duplicate plugin\/preset detected/);
|
}).toThrow(
|
||||||
|
/Duplicate plugin\/preset detected.*Duplicates detected are.*my-plugin.*my-plugin/ms,
|
||||||
|
);
|
||||||
expect(calls).toEqual([]);
|
expect(calls).toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
3676
packages/babel-core/yarn.lock
Normal file
3676
packages/babel-core/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/generator",
|
"name": "@babel/generator",
|
||||||
"version": "7.6.2",
|
"version": "7.7.2",
|
||||||
"description": "Turns an AST into code.",
|
"description": "Turns an AST into code.",
|
||||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||||
"homepage": "https://babeljs.io/",
|
"homepage": "https://babeljs.io/",
|
||||||
@ -14,13 +14,13 @@
|
|||||||
"lib"
|
"lib"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/types": "^7.6.0",
|
"@babel/types": "^7.7.2",
|
||||||
"jsesc": "^2.5.1",
|
"jsesc": "^2.5.1",
|
||||||
"lodash": "^4.17.13",
|
"lodash": "^4.17.13",
|
||||||
"source-map": "^0.5.0"
|
"source-map": "^0.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/helper-fixtures": "^7.6.2",
|
"@babel/helper-fixtures": "^7.6.3",
|
||||||
"@babel/parser": "^7.6.2"
|
"@babel/parser": "^7.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,26 +71,8 @@ export function ClassBody(node: Object) {
|
|||||||
|
|
||||||
export function ClassProperty(node: Object) {
|
export function ClassProperty(node: Object) {
|
||||||
this.printJoin(node.decorators, node);
|
this.printJoin(node.decorators, node);
|
||||||
|
this.tsPrintClassMemberModifiers(node, /* isField */ true);
|
||||||
|
|
||||||
if (node.accessibility) {
|
|
||||||
// TS
|
|
||||||
this.word(node.accessibility);
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
if (node.static) {
|
|
||||||
this.word("static");
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
if (node.abstract) {
|
|
||||||
// TS
|
|
||||||
this.word("abstract");
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
if (node.readonly) {
|
|
||||||
// TS
|
|
||||||
this.word("readonly");
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
if (node.computed) {
|
if (node.computed) {
|
||||||
this.token("[");
|
this.token("[");
|
||||||
this.print(node.key, node);
|
this.print(node.key, node);
|
||||||
@ -148,23 +130,6 @@ export function ClassPrivateMethod(node: Object) {
|
|||||||
|
|
||||||
export function _classMethodHead(node) {
|
export function _classMethodHead(node) {
|
||||||
this.printJoin(node.decorators, node);
|
this.printJoin(node.decorators, node);
|
||||||
|
this.tsPrintClassMemberModifiers(node, /* isField */ false);
|
||||||
if (node.accessibility) {
|
|
||||||
// TS
|
|
||||||
this.word(node.accessibility);
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.abstract) {
|
|
||||||
// TS
|
|
||||||
this.word("abstract");
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.static) {
|
|
||||||
this.word("static");
|
|
||||||
this.space();
|
|
||||||
}
|
|
||||||
|
|
||||||
this._methodHead(node);
|
this._methodHead(node);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,6 +134,92 @@ export function DeclareExportAllDeclaration(/*node: Object*/) {
|
|||||||
ExportAllDeclaration.apply(this, arguments);
|
ExportAllDeclaration.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function EnumDeclaration(node: Object) {
|
||||||
|
const { id, body } = node;
|
||||||
|
this.word("enum");
|
||||||
|
this.space();
|
||||||
|
this.print(id, node);
|
||||||
|
this.print(body, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
function enumExplicitType(
|
||||||
|
context: Object,
|
||||||
|
name: string,
|
||||||
|
hasExplicitType: boolean,
|
||||||
|
) {
|
||||||
|
if (hasExplicitType) {
|
||||||
|
context.space();
|
||||||
|
context.word("of");
|
||||||
|
context.space();
|
||||||
|
context.word(name);
|
||||||
|
}
|
||||||
|
context.space();
|
||||||
|
}
|
||||||
|
|
||||||
|
function enumBody(context: Object, node: Object) {
|
||||||
|
const { members } = node;
|
||||||
|
context.token("{");
|
||||||
|
context.indent();
|
||||||
|
context.newline();
|
||||||
|
for (const member of members) {
|
||||||
|
context.print(member, node);
|
||||||
|
context.newline();
|
||||||
|
}
|
||||||
|
context.dedent();
|
||||||
|
context.token("}");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumBooleanBody(node: Object) {
|
||||||
|
const { explicitType } = node;
|
||||||
|
enumExplicitType(this, "boolean", explicitType);
|
||||||
|
enumBody(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumNumberBody(node: Object) {
|
||||||
|
const { explicitType } = node;
|
||||||
|
enumExplicitType(this, "number", explicitType);
|
||||||
|
enumBody(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumStringBody(node: Object) {
|
||||||
|
const { explicitType } = node;
|
||||||
|
enumExplicitType(this, "string", explicitType);
|
||||||
|
enumBody(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumSymbolBody(node: Object) {
|
||||||
|
enumExplicitType(this, "symbol", true);
|
||||||
|
enumBody(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumDefaultedMember(node: Object) {
|
||||||
|
const { id } = node;
|
||||||
|
this.print(id, node);
|
||||||
|
this.token(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
function enumInitializedMember(context: Object, node: Object) {
|
||||||
|
const { id, init } = node;
|
||||||
|
context.print(id, node);
|
||||||
|
context.space();
|
||||||
|
context.token("=");
|
||||||
|
context.space();
|
||||||
|
context.print(init, node);
|
||||||
|
context.token(",");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumBooleanMember(node: Object) {
|
||||||
|
enumInitializedMember(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumNumberMember(node: Object) {
|
||||||
|
enumInitializedMember(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EnumStringMember(node: Object) {
|
||||||
|
enumInitializedMember(this, node);
|
||||||
|
}
|
||||||
|
|
||||||
function FlowExportDeclaration(node: Object) {
|
function FlowExportDeclaration(node: Object) {
|
||||||
if (node.declaration) {
|
if (node.declaration) {
|
||||||
const declar = node.declaration;
|
const declar = node.declaration;
|
||||||
|
|||||||
@ -197,11 +197,17 @@ export function TSTypeReference(node) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function TSTypePredicate(node) {
|
export function TSTypePredicate(node) {
|
||||||
|
if (node.asserts) {
|
||||||
|
this.word("asserts");
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
this.print(node.parameterName);
|
this.print(node.parameterName);
|
||||||
this.space();
|
if (node.typeAnnotation) {
|
||||||
this.word("is");
|
this.space();
|
||||||
this.space();
|
this.word("is");
|
||||||
this.print(node.typeAnnotation.typeAnnotation);
|
this.space();
|
||||||
|
this.print(node.typeAnnotation.typeAnnotation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function TSTypeQuery(node) {
|
export function TSTypeQuery(node) {
|
||||||
@ -550,3 +556,26 @@ export function tsPrintSignatureDeclarationBase(node) {
|
|||||||
this.token(")");
|
this.token(")");
|
||||||
this.print(node.typeAnnotation, node);
|
this.print(node.typeAnnotation, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function tsPrintClassMemberModifiers(node, isField) {
|
||||||
|
if (isField && node.declare) {
|
||||||
|
this.word("declare");
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
|
if (node.accessibility) {
|
||||||
|
this.word(node.accessibility);
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
|
if (node.static) {
|
||||||
|
this.word("static");
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
|
if (node.abstract) {
|
||||||
|
this.word("abstract");
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
|
if (isField && node.readonly) {
|
||||||
|
this.word("readonly");
|
||||||
|
this.space();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -35,14 +35,22 @@ export function NullableTypeAnnotation(node: Object, parent: Object): boolean {
|
|||||||
return t.isArrayTypeAnnotation(parent);
|
return t.isArrayTypeAnnotation(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FunctionTypeAnnotation(node: Object, parent: Object): boolean {
|
export function FunctionTypeAnnotation(
|
||||||
|
node: Object,
|
||||||
|
parent: Object,
|
||||||
|
printStack: Array<Object>,
|
||||||
|
): boolean {
|
||||||
return (
|
return (
|
||||||
// (() => A) | (() => B)
|
// (() => A) | (() => B)
|
||||||
t.isUnionTypeAnnotation(parent) ||
|
t.isUnionTypeAnnotation(parent) ||
|
||||||
// (() => A) & (() => B)
|
// (() => A) & (() => B)
|
||||||
t.isIntersectionTypeAnnotation(parent) ||
|
t.isIntersectionTypeAnnotation(parent) ||
|
||||||
// (() => A)[]
|
// (() => A)[]
|
||||||
t.isArrayTypeAnnotation(parent)
|
t.isArrayTypeAnnotation(parent) ||
|
||||||
|
// <T>(A: T): (T => T[]) => B => [A, B]
|
||||||
|
(t.isTypeAnnotation(parent) &&
|
||||||
|
// Check grandparent
|
||||||
|
t.isArrowFunctionExpression(printStack[printStack.length - 3]))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,14 +24,20 @@ export default class SourceMap {
|
|||||||
|
|
||||||
const code = this._code;
|
const code = this._code;
|
||||||
if (typeof code === "string") {
|
if (typeof code === "string") {
|
||||||
map.setSourceContent(this._opts.sourceFileName, code);
|
map.setSourceContent(
|
||||||
|
this._opts.sourceFileName.replace(/\\/g, "/"),
|
||||||
|
code,
|
||||||
|
);
|
||||||
} else if (typeof code === "object") {
|
} else if (typeof code === "object") {
|
||||||
Object.keys(code).forEach(sourceFileName => {
|
Object.keys(code).forEach(sourceFileName => {
|
||||||
map.setSourceContent(sourceFileName, code[sourceFileName]);
|
map.setSourceContent(
|
||||||
|
sourceFileName.replace(/\\/g, "/"),
|
||||||
|
code[sourceFileName],
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this._rawMappings.forEach(map.addMapping, map);
|
this._rawMappings.forEach(mapping => map.addMapping(mapping), map);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this._cachedMap.toJSON();
|
return this._cachedMap.toJSON();
|
||||||
@ -83,7 +89,10 @@ export default class SourceMap {
|
|||||||
line: generatedLine,
|
line: generatedLine,
|
||||||
column: generatedColumn,
|
column: generatedColumn,
|
||||||
},
|
},
|
||||||
source: line == null ? undefined : filename || this._opts.sourceFileName,
|
source:
|
||||||
|
line == null
|
||||||
|
? undefined
|
||||||
|
: (filename || this._opts.sourceFileName).replace(/\\/g, "/"),
|
||||||
original:
|
original:
|
||||||
line == null
|
line == null
|
||||||
? undefined
|
? undefined
|
||||||
|
|||||||
@ -5,3 +5,4 @@ const bar4 = x => {};
|
|||||||
const bar5 = (x): string => {};
|
const bar5 = (x): string => {};
|
||||||
const bar6 = (x: number) => {};
|
const bar6 = (x: number) => {};
|
||||||
const bar7 = <T>(x) => {};
|
const bar7 = <T>(x) => {};
|
||||||
|
const bar8 = <T>(x: T): (T => T[]) => y => [x, y];
|
||||||
|
|||||||
@ -10,4 +10,6 @@ const bar5 = (x): string => {};
|
|||||||
|
|
||||||
const bar6 = (x: number) => {};
|
const bar6 = (x: number) => {};
|
||||||
|
|
||||||
const bar7 = <T>(x) => {};
|
const bar7 = <T>(x) => {};
|
||||||
|
|
||||||
|
const bar8 = <T>(x: T): ((T) => T[]) => y => [x, y];
|
||||||
|
|||||||
@ -11,13 +11,13 @@ declare class A { static [ indexer: number]: string }
|
|||||||
declare class A { static () : number }
|
declare class A { static () : number }
|
||||||
declare class B { (): number }
|
declare class B { (): number }
|
||||||
declare class A mixins B<T>, C {}
|
declare class A mixins B<T>, C {}
|
||||||
declare type A = string
|
declare type A1 = string
|
||||||
declare type T<U> = { [k:string]: U }
|
declare type T<U> = { [k:string]: U }
|
||||||
declare type B = {
|
declare type B1 = {
|
||||||
fn?: (foo: string) => void,
|
fn?: (foo: string) => void,
|
||||||
}
|
}
|
||||||
declare interface I { foo: string }
|
declare interface I1 { foo: string }
|
||||||
declare interface I<T> { foo: T }
|
declare interface I2<T> { foo: T }
|
||||||
declare module.exports: { foo: string }
|
declare module.exports: { foo: string }
|
||||||
declare opaque type Foo<T>: Bar<T>;
|
declare opaque type Foo<T>: Bar<T>;
|
||||||
declare opaque type ID;
|
declare opaque type ID;
|
||||||
|
|||||||
@ -22,17 +22,17 @@ declare class B {
|
|||||||
(): number
|
(): number
|
||||||
}
|
}
|
||||||
declare class A mixins B<T>, C {}
|
declare class A mixins B<T>, C {}
|
||||||
declare type A = string;
|
declare type A1 = string;
|
||||||
declare type T<U> = {
|
declare type T<U> = {
|
||||||
[k: string]: U
|
[k: string]: U
|
||||||
};
|
};
|
||||||
declare type B = {
|
declare type B1 = {
|
||||||
fn?: (foo: string) => void
|
fn?: (foo: string) => void
|
||||||
};
|
};
|
||||||
declare interface I {
|
declare interface I1 {
|
||||||
foo: string
|
foo: string
|
||||||
}
|
}
|
||||||
declare interface I<T> {
|
declare interface I2<T> {
|
||||||
foo: T
|
foo: T
|
||||||
}
|
}
|
||||||
declare module.exports: {
|
declare module.exports: {
|
||||||
|
|||||||
@ -5,10 +5,10 @@ type T2 = { +p: T };
|
|||||||
type T3 = { -p: T };
|
type T3 = { -p: T };
|
||||||
type T4 = { +[k:K]: V };
|
type T4 = { +[k:K]: V };
|
||||||
type T5 = { -[k:K]: V };
|
type T5 = { -[k:K]: V };
|
||||||
interface I { +p: T }
|
interface I1 { +p: T }
|
||||||
interface I { -p: T }
|
interface I2 { -p: T }
|
||||||
interface I { +[k:K]: V }
|
interface I3 { +[k:K]: V }
|
||||||
interface I { -[k:K]: V }
|
interface I4 { -[k:K]: V }
|
||||||
declare class I { +p: T }
|
declare class I { +p: T }
|
||||||
declare class I { -p: T }
|
declare class I { -p: T }
|
||||||
declare class I { +[k:K]: V }
|
declare class I { +[k:K]: V }
|
||||||
|
|||||||
@ -15,16 +15,16 @@ type T4 = {
|
|||||||
type T5 = {
|
type T5 = {
|
||||||
-[k: K]: V
|
-[k: K]: V
|
||||||
};
|
};
|
||||||
interface I {
|
interface I1 {
|
||||||
+p: T
|
+p: T
|
||||||
}
|
}
|
||||||
interface I {
|
interface I2 {
|
||||||
-p: T
|
-p: T
|
||||||
}
|
}
|
||||||
interface I {
|
interface I3 {
|
||||||
+[k: K]: V
|
+[k: K]: V
|
||||||
}
|
}
|
||||||
interface I {
|
interface I4 {
|
||||||
-[k: K]: V
|
-[k: K]: V
|
||||||
}
|
}
|
||||||
declare class I {
|
declare class I {
|
||||||
|
|||||||
36
packages/babel-generator/test/fixtures/flow/enum-declaration/input.js
vendored
Normal file
36
packages/babel-generator/test/fixtures/flow/enum-declaration/input.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
enum E {
|
||||||
|
A = true,
|
||||||
|
B = false,
|
||||||
|
}
|
||||||
|
enum E of boolean {
|
||||||
|
A = true,
|
||||||
|
B = false,
|
||||||
|
}
|
||||||
|
enum E {
|
||||||
|
A = 1,
|
||||||
|
B = 2,
|
||||||
|
}
|
||||||
|
enum E of number {
|
||||||
|
A = 1,
|
||||||
|
B = 2,
|
||||||
|
}
|
||||||
|
enum E {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
enum E of string {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
enum E {
|
||||||
|
A = "a",
|
||||||
|
B = "b",
|
||||||
|
}
|
||||||
|
enum E of string {
|
||||||
|
A = "a",
|
||||||
|
B = "b",
|
||||||
|
}
|
||||||
|
enum E of symbol {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
3
packages/babel-generator/test/fixtures/flow/enum-declaration/options.json
vendored
Normal file
3
packages/babel-generator/test/fixtures/flow/enum-declaration/options.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"plugins": [["flow", { "enums": true }]]
|
||||||
|
}
|
||||||
36
packages/babel-generator/test/fixtures/flow/enum-declaration/output.js
vendored
Normal file
36
packages/babel-generator/test/fixtures/flow/enum-declaration/output.js
vendored
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
enum E {
|
||||||
|
A = true,
|
||||||
|
B = false,
|
||||||
|
}
|
||||||
|
enum E of boolean {
|
||||||
|
A = true,
|
||||||
|
B = false,
|
||||||
|
}
|
||||||
|
enum E {
|
||||||
|
A = 1,
|
||||||
|
B = 2,
|
||||||
|
}
|
||||||
|
enum E of number {
|
||||||
|
A = 1,
|
||||||
|
B = 2,
|
||||||
|
}
|
||||||
|
enum E {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
enum E of string {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
|
enum E {
|
||||||
|
A = "a",
|
||||||
|
B = "b",
|
||||||
|
}
|
||||||
|
enum E of string {
|
||||||
|
A = "a",
|
||||||
|
B = "b",
|
||||||
|
}
|
||||||
|
enum E of symbol {
|
||||||
|
A,
|
||||||
|
B,
|
||||||
|
}
|
||||||
@ -1,7 +1,7 @@
|
|||||||
declare class C { static [[foo]]: T }
|
declare class C { static [[foo]]: T }
|
||||||
declare class C { [[foo]]: T }
|
declare class C { [[foo]]: T }
|
||||||
interface I { [[foo]]: X }
|
interface I1 { [[foo]]: X }
|
||||||
interface I { [[foo]](): X }
|
interface I2 { [[foo]](): X }
|
||||||
type T1 = { [[foo]]: X }
|
type T1 = { [[foo]]: X }
|
||||||
type T2 = { [[foo]](): X }
|
type T2 = { [[foo]](): X }
|
||||||
type T3 = { [[foo]]?: X }
|
type T3 = { [[foo]]?: X }
|
||||||
|
|||||||
@ -4,10 +4,10 @@ declare class C {
|
|||||||
declare class C {
|
declare class C {
|
||||||
[[foo]]: T
|
[[foo]]: T
|
||||||
}
|
}
|
||||||
interface I {
|
interface I1 {
|
||||||
[[foo]]: X
|
[[foo]]: X
|
||||||
}
|
}
|
||||||
interface I {
|
interface I2 {
|
||||||
[[foo]]() => X
|
[[foo]]() => X
|
||||||
}
|
}
|
||||||
type T1 = {
|
type T1 = {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
interface A {
|
interface A1 {
|
||||||
@@iterator(): Iterator<File>;
|
@@iterator(): Iterator<File>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface A {
|
interface A2 {
|
||||||
@@asyncIterator(): Iterator<File>;
|
@@asyncIterator(): Iterator<File>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
interface A {
|
interface A1 {
|
||||||
@@iterator(): Iterator<File>
|
@@iterator(): Iterator<File>
|
||||||
}
|
}
|
||||||
interface A {
|
interface A2 {
|
||||||
@@asyncIterator(): Iterator<File>
|
@@asyncIterator(): Iterator<File>
|
||||||
}
|
}
|
||||||
2
packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/input.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
(x: any): asserts x => true;
|
||||||
|
(x: any): asserts x is boolean => true;
|
||||||
3
packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/output.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/arrow-function-assertion/output.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
(x: any): asserts x => true;
|
||||||
|
|
||||||
|
(x: any): asserts x is boolean => true;
|
||||||
5
packages/babel-generator/test/fixtures/typescript/class-field-declare/input.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/typescript/class-field-declare/input.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
declare foo;
|
||||||
|
declare bar: string;
|
||||||
|
declare readonly bax: number;
|
||||||
|
}
|
||||||
4
packages/babel-generator/test/fixtures/typescript/class-field-declare/options.json
vendored
Normal file
4
packages/babel-generator/test/fixtures/typescript/class-field-declare/options.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"sourceType": "module",
|
||||||
|
"plugins": ["typescript", "classProperties"]
|
||||||
|
}
|
||||||
5
packages/babel-generator/test/fixtures/typescript/class-field-declare/output.js
vendored
Normal file
5
packages/babel-generator/test/fixtures/typescript/class-field-declare/output.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class A {
|
||||||
|
declare foo;
|
||||||
|
declare bar: string;
|
||||||
|
declare readonly bax: number;
|
||||||
|
}
|
||||||
2
packages/babel-generator/test/fixtures/typescript/function-assertion/input.js
vendored
Normal file
2
packages/babel-generator/test/fixtures/typescript/function-assertion/input.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
function f(x: any): asserts x {}
|
||||||
|
(function(x: any): asserts x is boolean {})
|
||||||
3
packages/babel-generator/test/fixtures/typescript/function-assertion/output.js
vendored
Normal file
3
packages/babel-generator/test/fixtures/typescript/function-assertion/output.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function f(x: any): asserts x {}
|
||||||
|
|
||||||
|
(function (x: any): asserts x is boolean {});
|
||||||
@ -197,7 +197,7 @@ describe("generation", function() {
|
|||||||
|
|
||||||
const id2 = fn.body.body[0].expression;
|
const id2 = fn.body.body[0].expression;
|
||||||
id2.name += "2";
|
id2.name += "2";
|
||||||
id2.loc.identiferName = "bar";
|
id2.loc.identifierName = "bar";
|
||||||
|
|
||||||
const generated = generate(
|
const generated = generate(
|
||||||
ast,
|
ast,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/helper-annotate-as-pure",
|
"name": "@babel/helper-annotate-as-pure",
|
||||||
"version": "7.0.0",
|
"version": "7.7.0",
|
||||||
"description": "Helper function to annotate paths and nodes with #__PURE__ comment",
|
"description": "Helper function to annotate paths and nodes with #__PURE__ comment",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-annotate-as-pure",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,6 +9,6 @@
|
|||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/types": "^7.0.0"
|
"@babel/types": "^7.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/helper-bindify-decorators",
|
"name": "@babel/helper-bindify-decorators",
|
||||||
"version": "7.1.0",
|
"version": "7.7.0",
|
||||||
"description": "Helper function to bindify decorators",
|
"description": "Helper function to bindify decorators",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-bindify-decorators",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-bindify-decorators",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/traverse": "^7.1.0",
|
"@babel/traverse": "^7.7.0",
|
||||||
"@babel/types": "^7.0.0"
|
"@babel/types": "^7.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/helper-builder-binary-assignment-operator-visitor",
|
"name": "@babel/helper-builder-binary-assignment-operator-visitor",
|
||||||
"version": "7.1.0",
|
"version": "7.7.0",
|
||||||
"description": "Helper function to build binary assignment operator visitors",
|
"description": "Helper function to build binary assignment operator visitors",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-binary-assignment-operator-visitor",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-explode-assignable-expression": "^7.1.0",
|
"@babel/helper-explode-assignable-expression": "^7.7.0",
|
||||||
"@babel/types": "^7.0.0"
|
"@babel/types": "^7.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/helper-builder-react-jsx",
|
"name": "@babel/helper-builder-react-jsx",
|
||||||
"version": "7.3.0",
|
"version": "7.7.0",
|
||||||
"description": "Helper function to build react jsx",
|
"description": "Helper function to build react jsx",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-builder-react-jsx",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/types": "^7.3.0",
|
"@babel/types": "^7.7.0",
|
||||||
"esutils": "^2.0.0"
|
"esutils": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,13 +87,15 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
|
|||||||
function convertAttribute(node) {
|
function convertAttribute(node) {
|
||||||
const value = convertAttributeValue(node.value || t.booleanLiteral(true));
|
const value = convertAttributeValue(node.value || t.booleanLiteral(true));
|
||||||
|
|
||||||
|
if (t.isJSXSpreadAttribute(node)) {
|
||||||
|
return t.spreadElement(node.argument);
|
||||||
|
}
|
||||||
|
|
||||||
if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
|
if (t.isStringLiteral(value) && !t.isJSXExpressionContainer(node.value)) {
|
||||||
value.value = value.value.replace(/\n\s+/g, " ");
|
value.value = value.value.replace(/\n\s+/g, " ");
|
||||||
|
|
||||||
// "raw" JSXText should not be used from a StringLiteral because it needs to be escaped.
|
// "raw" JSXText should not be used from a StringLiteral because it needs to be escaped.
|
||||||
if (value.extra && value.extra.raw) {
|
delete value.extra?.raw;
|
||||||
delete value.extra.raw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t.isJSXNamespacedName(node.name)) {
|
if (t.isJSXNamespacedName(node.name)) {
|
||||||
@ -172,6 +174,14 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
|
|||||||
let _props = [];
|
let _props = [];
|
||||||
const objs = [];
|
const objs = [];
|
||||||
|
|
||||||
|
const { useSpread = false } = file.opts;
|
||||||
|
if (typeof useSpread !== "boolean") {
|
||||||
|
throw new Error(
|
||||||
|
"transform-react-jsx currently only accepts a boolean option for " +
|
||||||
|
"useSpread (defaults to false)",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const useBuiltIns = file.opts.useBuiltIns || false;
|
const useBuiltIns = file.opts.useBuiltIns || false;
|
||||||
if (typeof useBuiltIns !== "boolean") {
|
if (typeof useBuiltIns !== "boolean") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -180,6 +190,18 @@ You can turn on the 'throwIfNamespace' flag to bypass this warning.`,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useSpread && useBuiltIns) {
|
||||||
|
throw new Error(
|
||||||
|
"transform-react-jsx currently only accepts useBuiltIns or useSpread " +
|
||||||
|
"but not both",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (useSpread) {
|
||||||
|
const props = attribs.map(convertAttribute);
|
||||||
|
return t.objectExpression(props);
|
||||||
|
}
|
||||||
|
|
||||||
while (attribs.length) {
|
while (attribs.length) {
|
||||||
const prop = attribs.shift();
|
const prop = attribs.shift();
|
||||||
if (t.isJSXSpreadAttribute(prop)) {
|
if (t.isJSXSpreadAttribute(prop)) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/helper-call-delegate",
|
"name": "@babel/helper-call-delegate",
|
||||||
"version": "7.4.4",
|
"version": "7.7.0",
|
||||||
"description": "Helper function to call delegate",
|
"description": "Helper function to call delegate",
|
||||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate",
|
"repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-call-delegate",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@ -9,8 +9,8 @@
|
|||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-hoist-variables": "^7.4.4",
|
"@babel/helper-hoist-variables": "^7.7.0",
|
||||||
"@babel/traverse": "^7.4.4",
|
"@babel/traverse": "^7.7.0",
|
||||||
"@babel/types": "^7.4.4"
|
"@babel/types": "^7.7.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@babel/helper-create-class-features-plugin",
|
"name": "@babel/helper-create-class-features-plugin",
|
||||||
"version": "7.6.0",
|
"version": "7.7.0",
|
||||||
"author": "The Babel Team (https://babeljs.io/team)",
|
"author": "The Babel Team (https://babeljs.io/team)",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "Compile class public and private fields, private methods and decorators to ES6",
|
"description": "Compile class public and private fields, private methods and decorators to ES6",
|
||||||
@ -14,18 +14,19 @@
|
|||||||
"babel-plugin"
|
"babel-plugin"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/helper-function-name": "^7.1.0",
|
"@babel/helper-function-name": "^7.7.0",
|
||||||
"@babel/helper-member-expression-to-functions": "^7.5.5",
|
"@babel/helper-member-expression-to-functions": "^7.7.0",
|
||||||
"@babel/helper-optimise-call-expression": "^7.0.0",
|
"@babel/helper-optimise-call-expression": "^7.7.0",
|
||||||
"@babel/helper-plugin-utils": "^7.0.0",
|
"@babel/helper-plugin-utils": "^7.0.0",
|
||||||
"@babel/helper-replace-supers": "^7.5.5",
|
"@babel/helper-replace-supers": "^7.7.0",
|
||||||
"@babel/helper-split-export-declaration": "^7.4.4"
|
"@babel/helper-split-export-declaration": "^7.7.0",
|
||||||
|
"semver": "^5.5.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@babel/core": "^7.0.0"
|
"@babel/core": "^7.0.0 || csx"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.6.0",
|
"@babel/core": "^7.7.0",
|
||||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import ReplaceSupers, {
|
|||||||
import memberExpressionToFunctions from "@babel/helper-member-expression-to-functions";
|
import memberExpressionToFunctions from "@babel/helper-member-expression-to-functions";
|
||||||
import optimiseCall from "@babel/helper-optimise-call-expression";
|
import optimiseCall from "@babel/helper-optimise-call-expression";
|
||||||
|
|
||||||
|
import * as ts from "./typescript";
|
||||||
|
|
||||||
export function buildPrivateNamesMap(props) {
|
export function buildPrivateNamesMap(props) {
|
||||||
const privateNamesMap = new Map();
|
const privateNamesMap = new Map();
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
@ -556,6 +558,8 @@ export function buildFieldsInitNodes(
|
|||||||
let needsClassRef = false;
|
let needsClassRef = false;
|
||||||
|
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
|
ts.assertFieldTransformed(prop);
|
||||||
|
|
||||||
const isStatic = prop.node.static;
|
const isStatic = prop.node.static;
|
||||||
const isInstance = !isStatic;
|
const isInstance = !isStatic;
|
||||||
const isPrivate = prop.isPrivate();
|
const isPrivate = prop.isPrivate();
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user