Compare commits
307 Commits
v7.0.0-bet
...
v7.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
282129ea66 | ||
|
|
fc5d49b6f6 | ||
|
|
6c2771c116 | ||
|
|
fdc869ce16 | ||
|
|
fa9df678ac | ||
|
|
3932830535 | ||
|
|
07eaa3c63f | ||
|
|
3530d11418 | ||
|
|
806e133473 | ||
|
|
2bf8dde782 | ||
|
|
4e28459a2f | ||
|
|
c4d6f6dcce | ||
|
|
0859535b62 | ||
|
|
6e39b58f8a | ||
|
|
559d649994 | ||
|
|
3fda01b185 | ||
|
|
4f2eacf615 | ||
|
|
0047ae84b3 | ||
|
|
2bb24f996f | ||
|
|
61f2aed5b0 | ||
|
|
9308c870f5 | ||
|
|
1b8d664bbe | ||
|
|
844dd33f3d | ||
|
|
856edbf95f | ||
|
|
100b38784d | ||
|
|
4cbd22a15f | ||
|
|
d2971a1959 | ||
|
|
4f16a12c03 | ||
|
|
e7f0c065cf | ||
|
|
70318c9413 | ||
|
|
6e84352b51 | ||
|
|
0eb9b2463d | ||
|
|
445b14148e | ||
|
|
61c1c77a28 | ||
|
|
5979b0669b | ||
|
|
a2afb974be | ||
|
|
c11cdcb6d8 | ||
|
|
8c7d4b55c9 | ||
|
|
88696601e1 | ||
|
|
20a9d71016 | ||
|
|
1af57e6f71 | ||
|
|
4e1d6e7ff4 | ||
|
|
efb71ea12b | ||
|
|
cbbb3c7962 | ||
|
|
4fcee1751a | ||
|
|
efa571a42c | ||
|
|
bf8c4785f2 | ||
|
|
4f206b2416 | ||
|
|
504b331da4 | ||
|
|
74f969b603 | ||
|
|
4dfd801887 | ||
|
|
62233ed7c9 | ||
|
|
7b54ab620b | ||
|
|
343f776ca5 | ||
|
|
756ded4d64 | ||
|
|
b706e34fc8 | ||
|
|
5d5cd8612f | ||
|
|
afe67a7035 | ||
|
|
2fa1984635 | ||
|
|
2194842d11 | ||
|
|
e3b2c1afff | ||
|
|
b95cbc4a8e | ||
|
|
24c4901ff5 | ||
|
|
c125b1dd74 | ||
|
|
f216a7b06f | ||
|
|
c6d2f45cab | ||
|
|
1d4d760ffc | ||
|
|
a0e94ec24d | ||
|
|
b593af17a9 | ||
|
|
4521204ea0 | ||
|
|
d35563ee1a | ||
|
|
38397ce11f | ||
|
|
cd81b079ee | ||
|
|
e85faec47d | ||
|
|
0d9e77f559 | ||
|
|
c82750a48a | ||
|
|
de80aefece | ||
|
|
e4929e11f6 | ||
|
|
d942d47e10 | ||
|
|
84e7884d9c | ||
|
|
9d0dcedb2b | ||
|
|
b576bf4b41 | ||
|
|
e541d6031a | ||
|
|
5fa3628506 | ||
|
|
f71e4660d4 | ||
|
|
929567523c | ||
|
|
5080059138 | ||
|
|
8ee857e268 | ||
|
|
6b8261bbb7 | ||
|
|
ce1a6526e5 | ||
|
|
842c164be5 | ||
|
|
d2c75c2d38 | ||
|
|
3951acbff5 | ||
|
|
08454ece46 | ||
|
|
4b8cb75b74 | ||
|
|
3fa4f53d0a | ||
|
|
850bc1d3dd | ||
|
|
36d12b5969 | ||
|
|
2575312d1f | ||
|
|
a5b5ed928d | ||
|
|
3c87401714 | ||
|
|
07862e7272 | ||
|
|
ca89212b45 | ||
|
|
3f5b7554b8 | ||
|
|
ead23d7112 | ||
|
|
626f47982e | ||
|
|
55faa27b93 | ||
|
|
090c364a90 | ||
|
|
f38be13113 | ||
|
|
889cdb8da5 | ||
|
|
af694ebae1 | ||
|
|
a19b72e46d | ||
|
|
38cf318f61 | ||
|
|
be027fd36c | ||
|
|
5150f5f500 | ||
|
|
9f407e0735 | ||
|
|
3b0f9a9f1e | ||
|
|
9e7c7f5683 | ||
|
|
fad74959f8 | ||
|
|
2b68181af2 | ||
|
|
9b4b436e1f | ||
|
|
aa33303112 | ||
|
|
bd0c62dc0c | ||
|
|
aac8118b7f | ||
|
|
8897b67f40 | ||
|
|
380f2a0297 | ||
|
|
402bd1cc42 | ||
|
|
6059637f09 | ||
|
|
880fc1f54e | ||
|
|
fc1a52cb75 | ||
|
|
82a0e681ab | ||
|
|
8f5e9e143b | ||
|
|
13798feefb | ||
|
|
9ad8b2bb2c | ||
|
|
d2b559af59 | ||
|
|
252660f248 | ||
|
|
0e7d7cfccc | ||
|
|
53c6c98bdb | ||
|
|
802fc2ac80 | ||
|
|
e372129d00 | ||
|
|
79b2af5997 | ||
|
|
45c28fa785 | ||
|
|
1e1a89ca70 | ||
|
|
1b03906da4 | ||
|
|
7accee9c24 | ||
|
|
7273cf8fe5 | ||
|
|
dad55ef1d6 | ||
|
|
9aec4ad159 | ||
|
|
29a2878973 | ||
|
|
9eef660daa | ||
|
|
d9149aa2f3 | ||
|
|
58017044a3 | ||
|
|
c5279eeca4 | ||
|
|
f6643d1804 | ||
|
|
07fae82a8a | ||
|
|
fc91b94a86 | ||
|
|
d4e23b5b2a | ||
|
|
262787bd92 | ||
|
|
9232e8b405 | ||
|
|
dd985c3be3 | ||
|
|
4beb977f15 | ||
|
|
679e4b8f37 | ||
|
|
fc9becfdf2 | ||
|
|
6893b7e7d2 | ||
|
|
ffc82374d2 | ||
|
|
2921f6cdb1 | ||
|
|
fb66fa6f90 | ||
|
|
eda804da11 | ||
|
|
15f456651a | ||
|
|
9d244ae66b | ||
|
|
04d09cc754 | ||
|
|
5447a40719 | ||
|
|
d45ea2e5ff | ||
|
|
aeefec5f13 | ||
|
|
9a3af17560 | ||
|
|
bcec62c0ac | ||
|
|
90fb82a535 | ||
|
|
8a45fba510 | ||
|
|
079780b432 | ||
|
|
4e64807afc | ||
|
|
814c564c45 | ||
|
|
7a104e3e1d | ||
|
|
b98799557a | ||
|
|
1ac46a256d | ||
|
|
50d3c09883 | ||
|
|
508bfad55a | ||
|
|
130814342a | ||
|
|
e0ee0570be | ||
|
|
edbffda091 | ||
|
|
72ee1816a4 | ||
|
|
e875fc7bc1 | ||
|
|
524d847763 | ||
|
|
5899940156 | ||
|
|
595240f071 | ||
|
|
cada040bec | ||
|
|
1f9b2a5c41 | ||
|
|
39fa102ee8 | ||
|
|
e841ccca34 | ||
|
|
4249dbc8ea | ||
|
|
a7cc3325cd | ||
|
|
023044c1d4 | ||
|
|
22bcfbe469 | ||
|
|
47e05d70f3 | ||
|
|
c5e3b6d4bc | ||
|
|
b04de1196a | ||
|
|
d07cef244e | ||
|
|
6c68ca8e0a | ||
|
|
f1d774b34f | ||
|
|
8874c5c481 | ||
|
|
b439013cd4 | ||
|
|
f8b0a5579f | ||
|
|
2a4f162366 | ||
|
|
55295cc545 | ||
|
|
59e9c6322b | ||
|
|
0fd3da110d | ||
|
|
d60c5e1736 | ||
|
|
90bebe7186 | ||
|
|
8d6ed7e0aa | ||
|
|
8f4bae8ea4 | ||
|
|
2c3c12fdf7 | ||
|
|
25d2f59018 | ||
|
|
3a399d1eb9 | ||
|
|
c2a2e24965 | ||
|
|
ef68114d67 | ||
|
|
ca639b4262 | ||
|
|
7a51d72345 | ||
|
|
ab8555a867 | ||
|
|
0136a26af7 | ||
|
|
c75a00bd56 | ||
|
|
ffa8e6cbae | ||
|
|
5043ec78bc | ||
|
|
3989213e37 | ||
|
|
d79b5eeeff | ||
|
|
1e0b649485 | ||
|
|
8c65230258 | ||
|
|
427aff559f | ||
|
|
122906d525 | ||
|
|
25d01460fd | ||
|
|
de16ac08be | ||
|
|
ba5642d4ee | ||
|
|
15e6d844ae | ||
|
|
d1cae2dec2 | ||
|
|
11aee13ff2 | ||
|
|
0a958861c9 | ||
|
|
904bcaffe3 | ||
|
|
e855987c51 | ||
|
|
8b1406127a | ||
|
|
c8bb450032 | ||
|
|
b6db036ff7 | ||
|
|
6476a0d089 | ||
|
|
6695f5e2f7 | ||
|
|
86ce2e4e0d | ||
|
|
8cffbbae75 | ||
|
|
cb51704745 | ||
|
|
a8224d40e2 | ||
|
|
3210a7a873 | ||
|
|
9c598a8e28 | ||
|
|
a149466001 | ||
|
|
ec8330870e | ||
|
|
363c5923f0 | ||
|
|
8173b6e694 | ||
|
|
e2d64f146c | ||
|
|
9392783738 | ||
|
|
810b7916c2 | ||
|
|
eb0e999987 | ||
|
|
5c728ea609 | ||
|
|
b8f9ebf638 | ||
|
|
55ca90b3fc | ||
|
|
1a0fe993f5 | ||
|
|
02760d0f70 | ||
|
|
adca165ee9 | ||
|
|
fa86b2ddf0 | ||
|
|
5eb193c61f | ||
|
|
ec69b4bb12 | ||
|
|
5fdcd29ef9 | ||
|
|
8ee24fdfc0 | ||
|
|
db2a9fc96e | ||
|
|
75767e9273 | ||
|
|
4346a95b88 | ||
|
|
26cbbb569f | ||
|
|
a811cf78e1 | ||
|
|
c70a32ab9d | ||
|
|
6f3a800677 | ||
|
|
d781e207c8 | ||
|
|
39e7ee6e65 | ||
|
|
094ef31c01 | ||
|
|
afd0638b74 | ||
|
|
6e41edb90f | ||
|
|
8b10a44fe1 | ||
|
|
adae1501ac | ||
|
|
c8038f69fe | ||
|
|
30ea328e97 | ||
|
|
16b1f8c427 | ||
|
|
a582cc5bd8 | ||
|
|
7931f4c241 | ||
|
|
b847d40842 | ||
|
|
e91a02cc49 | ||
|
|
cc526940ee | ||
|
|
7188820151 | ||
|
|
00845709ce | ||
|
|
b50fdc191e | ||
|
|
ef0f723fc5 | ||
|
|
fbf62b4830 | ||
|
|
0e8830f3a8 | ||
|
|
4cdfee768b | ||
|
|
adbf2a15f9 | ||
|
|
ca65781132 |
@@ -34,7 +34,7 @@ jobs:
|
||||
build:
|
||||
working_directory: ~/babel
|
||||
docker:
|
||||
- image: circleci/node:10
|
||||
- image: circleci/node:11
|
||||
steps:
|
||||
- checkout
|
||||
- restore-cache: *restore-yarn-cache
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
package.json
|
||||
lerna.json
|
||||
packages/babel-runtime
|
||||
!packages/babel-runtime/scripts
|
||||
!packages/babel-runtime/core-js.js
|
||||
!packages/babel-plugin-transform-runtime/scripts
|
||||
!packages/babel-runtime-corejs2/core-js.js
|
||||
packages/babel-runtime-corejs2
|
||||
packages/*/node_modules
|
||||
packages/*/lib
|
||||
packages/*/dist
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "babel",
|
||||
"plugins": ["prettier"],
|
||||
"plugins": ["local-rules", "prettier"],
|
||||
"rules": {
|
||||
"curly": ["error", "multi-line"],
|
||||
"prettier/prettier": "error",
|
||||
"no-case-declarations": "error"
|
||||
"prettier/prettier": "error"
|
||||
},
|
||||
"env": {
|
||||
"node": true
|
||||
@@ -14,8 +12,8 @@
|
||||
{
|
||||
"files": ["packages/*/src/**/*.js", "codemods/*/src/**/*.js"],
|
||||
"rules": {
|
||||
"no-undefined-identifier": "error",
|
||||
"no-deprecated-clone": "error"
|
||||
"local-rules/no-undefined-identifier": "error",
|
||||
"local-rules/no-deprecated-clone": "error"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -28,6 +26,13 @@
|
||||
"env": {
|
||||
"jest": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"files": ["packages/babel-plugin-*/src/index.js"],
|
||||
"excludedFiles": ["packages/babel-plugin-transform-regenerator/**/*.js"],
|
||||
"rules": {
|
||||
"local-rules/plugin-name": "error"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
.*/codemods/.*/lib
|
||||
.*/codemods/.*/test
|
||||
.*/node_modules/conventional-changelog-core/
|
||||
.*/node_modules/module-deps/
|
||||
|
||||
[include]
|
||||
packages/*/src
|
||||
|
||||
34
.gitignore
vendored
34
.gitignore
vendored
@@ -1,6 +1,9 @@
|
||||
.DS_Store
|
||||
/node_modules
|
||||
/packages/*/node_modules
|
||||
/packages/*/LICENSE
|
||||
!/packages/babel-parser/LICENSE
|
||||
!/packages/babel-plugin-transform-object-assign/LICENSE
|
||||
*.log
|
||||
*.cache
|
||||
/build
|
||||
@@ -12,24 +15,27 @@ coverage
|
||||
dist
|
||||
/.package.json
|
||||
package-lock.json
|
||||
/packages/babel-runtime/core-js/**/*.js
|
||||
!/packages/babel-runtime/core-js/map.js
|
||||
|
||||
/packages/babel-runtime/helpers/*.js
|
||||
!/packages/babel-runtime/helpers/toArray.js
|
||||
!/packages/babel-runtime/helpers/iterableToArray.js
|
||||
!/packages/babel-runtime/helpers/temporalRef.js
|
||||
/packages/babel-runtime/helpers/builtin/*.js
|
||||
!/packages/babel-runtime/helpers/builtin/toArray.js
|
||||
!/packages/babel-runtime/helpers/builtin/iterableToArray.js
|
||||
!/packages/babel-runtime/helpers/builtin/temporalRef.js
|
||||
/packages/babel-runtime/helpers/builtin/es6/*.js
|
||||
!/packages/babel-runtime/helpers/builtin/es6/toArray.js
|
||||
!/packages/babel-runtime/helpers/builtin/es6/iterableToArray.js
|
||||
!/packages/babel-runtime/helpers/builtin/es6/temporalRef.js
|
||||
/packages/babel-runtime/helpers/es6/*.js
|
||||
!/packages/babel-runtime/helpers/es6/toArray.js
|
||||
!/packages/babel-runtime/helpers/es6/iterableToArray.js
|
||||
!/packages/babel-runtime/helpers/es6/temporalRef.js
|
||||
/packages/babel-runtime/helpers/esm/*.js
|
||||
!/packages/babel-runtime/helpers/esm/toArray.js
|
||||
!/packages/babel-runtime/helpers/esm/iterableToArray.js
|
||||
!/packages/babel-runtime/helpers/esm/temporalRef.js
|
||||
|
||||
/packages/babel-runtime-corejs2/helpers/*.js
|
||||
!/packages/babel-runtime-corejs2/helpers/toArray.js
|
||||
!/packages/babel-runtime-corejs2/helpers/iterableToArray.js
|
||||
!/packages/babel-runtime-corejs2/helpers/temporalRef.js
|
||||
/packages/babel-runtime-corejs2/helpers/esm/*.js
|
||||
!/packages/babel-runtime-corejs2/helpers/esm/toArray.js
|
||||
!/packages/babel-runtime-corejs2/helpers/esm/iterableToArray.js
|
||||
!/packages/babel-runtime-corejs2/helpers/esm/temporalRef.js
|
||||
/packages/babel-runtime-corejs2/core-js/**/*.js
|
||||
!/packages/babel-runtime-corejs2/core-js/map.js
|
||||
|
||||
/packages/babel-register/test/.babel
|
||||
/packages/babel-cli/test/tmp
|
||||
/packages/babel-node/test/tmp
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
"bracketSpacing": true,
|
||||
"jsxBracketSameLine": false,
|
||||
"tabWidth": 2,
|
||||
"parser": "babylon",
|
||||
"printWidth": 80,
|
||||
"overrides": [{
|
||||
"files": [
|
||||
@@ -16,6 +15,7 @@
|
||||
"**/packages/*/src/**/*.js",
|
||||
"**/packages/*/test/**/*.js"
|
||||
],
|
||||
"parser": "babylon",
|
||||
"options": {
|
||||
"trailingComma": "all"
|
||||
}
|
||||
|
||||
10
.travis.yml
10
.travis.yml
@@ -1,14 +1,12 @@
|
||||
git:
|
||||
depth: 10
|
||||
depth: 5
|
||||
sudo: false
|
||||
language: node_js
|
||||
cache:
|
||||
yarn: true
|
||||
directories:
|
||||
- node_modules
|
||||
node_js:
|
||||
# We test the latest version on circleci
|
||||
- '9'
|
||||
- '10'
|
||||
- '8'
|
||||
- '6'
|
||||
|
||||
@@ -20,7 +18,9 @@ env:
|
||||
before_install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash
|
||||
|
||||
install: yarn --ignore-engines
|
||||
install:
|
||||
# the `make test-ci` script runs this command already
|
||||
- if [ "$JOB" != "test" ]; then yarn install; fi
|
||||
|
||||
before_script:
|
||||
- 'if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi'
|
||||
|
||||
347
CHANGELOG.md
347
CHANGELOG.md
@@ -11,10 +11,353 @@
|
||||
|
||||
_Note: Gaps between patch versions are faulty, broken or test releases._
|
||||
|
||||
See [CHANGELOG - v4-v6](/.github/CHANGELOG-v4-v6.md) for the v4.x-v6.x changelog.
|
||||
See [CHANGELOG - v4](/.github/CHANGELOG-v4.md), [CHANGELOG - v5](/.github/CHANGELOG-v5.md), and [CHANGELOG - v6](/.github/CHANGELOG-v6.md) for v4.x-v6.x changes.
|
||||
See [CHANGELOG - 6to5](/.github/CHANGELOG-6to5.md) for the pre-4.0.0 version changelog.
|
||||
See [Babylon's CHANGELOG](packages/babylon/CHANGELOG.md) for the Babylon pre-7.0.0-beta.29 version changelog.
|
||||
|
||||
## 7.1.2 (2018-09-28)
|
||||
|
||||
Same as v7.1.1, except compiled against Node 6 instead of Node 8 by accident (e.g had `async functions`).
|
||||
|
||||
## v7.1.1 (2018-09-28)
|
||||
|
||||
> EDIT: had a publish issue here as well where it compiled against Node 8 instead of Node 6 so 7.1.2 will fix this.
|
||||
> Also force publish `@babel/runtime` and `@babel/runtime-corejs2`. We need to fix the publishing around that since Lerna doesn't pickup the `@babel/helpers` changes as there is no "dependency"
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-generator`, `babel-parser`, `babel-types`
|
||||
* [#8755](https://github.com/babel/babel/pull/8755) TypeScript: reserve `unknown` as TSUnknownKeyword. ([@g-plane](https://github.com/g-plane))
|
||||
* `babel-plugin-transform-destructuring`
|
||||
* [#8535](https://github.com/babel/babel/pull/8535) Do not unpack array patterns that update a referenced binding. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-plugin-proposal-decorators`
|
||||
* [#8742](https://github.com/babel/babel/pull/8742) [decorators] Support async and generator methods. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-helpers`, `babel-plugin-proposal-decorators`
|
||||
* [#8761](https://github.com/babel/babel/pull/8761) [decorators] Fields are enumerable. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-generator`
|
||||
* [#8751](https://github.com/babel/babel/pull/8751) Fix some missing parens cases with OptionalMemberExpression in generator. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8727](https://github.com/babel/babel/pull/8727) Handle throw expressions in generator. ([@existentialism](https://github.com/existentialism))
|
||||
|
||||
#### :house: Internal
|
||||
* Other
|
||||
* [#8780](https://github.com/babel/babel/pull/8780) Run test262 tests for exportNamespaceFrom. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-helper-transform-fixture-test-runner`
|
||||
* [#8768](https://github.com/babel/babel/pull/8768) Use babel-check-duplicated-nodes. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
## v7.1.0 (2018-09-17)
|
||||
|
||||
Check http://babeljs.io/blog/2018/09/17/7.1.0
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-cli`, `babel-core`
|
||||
* [#8660](https://github.com/babel/babel/pull/8660) Better support monorepos by allowing users to opt into automatically resolving 'root' with `rootMode: "upward"`.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helper-transform-fixture-test-runner`
|
||||
* [#7582](https://github.com/babel/babel/pull/7582) Allow regular plugins/presets resolution algorithm for packages outsi…. ([@Andarist](https://github.com/Andarist))
|
||||
* `babel-helpers`, `babel-plugin-proposal-decorators`, `babel-plugin-syntax-decorators`
|
||||
* [#7976](https://github.com/babel/babel/pull/7976) Add support for the new decorators proposal. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-helpers`, `babel-plugin-proposal-class-properties`
|
||||
* [#8205](https://github.com/babel/babel/pull/8205) Private Static Fields Features: Stage 3. ([@rricard](https://github.com/rricard))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#8698](https://github.com/babel/babel/pull/8698) Fix parsing of newline between 'async' and 'function'. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8677](https://github.com/babel/babel/pull/8677) Fix typescript parsing typed object shorthand methods. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-plugin-transform-typescript`
|
||||
* [#8682](https://github.com/babel/babel/pull/8682) Fix TSParameterProperty getting lost with transform-classes. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8695](https://github.com/babel/babel/pull/8695) Adjust TSParameterProperty handling to work with transform-parameters. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8666](https://github.com/babel/babel/pull/8666) Fix typescript import elision. ([@Retsam](https://github.com/Retsam))
|
||||
* `babel-preset-env`
|
||||
* [#8693](https://github.com/babel/babel/pull/8693) Fix es6.string.iterator mapping in babel-preset-env. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-core`, `babel-plugin-proposal-class-properties`, `babel-plugin-proposal-decorators`, `babel-plugin-transform-runtime`
|
||||
* [#8659](https://github.com/babel/babel/pull/8659) Fix version checks in .availableHelper and transform-runtime definitions.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* Other
|
||||
* [#8627](https://github.com/babel/babel/pull/8627) ts generator: allow reserved keywords in interfaces. ([@43081j](https://github.com/43081j))
|
||||
* `babel-plugin-transform-parameters`
|
||||
* [#8414](https://github.com/babel/babel/pull/8414) Allow patterns as argument of RestElement. ([@microbouji](https://github.com/microbouji))
|
||||
* `babel-core`, `babel-plugin-transform-runtime`
|
||||
* [#8624](https://github.com/babel/babel/pull/8624) Verify 'sourceMap' option with hasOwnProperty, and verify string-typed 'version'. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helpers`, `babel-plugin-proposal-class-properties`
|
||||
* [#8614](https://github.com/babel/babel/pull/8614) [static private] Unify loose handling of static and instance props. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8581](https://github.com/babel/babel/pull/8581) Fix grammar in error message at @babel/plugin-transform-runtime. ([@tricknotes](https://github.com/tricknotes))
|
||||
* `babel-parser`
|
||||
* [#8576](https://github.com/babel/babel/pull/8576) More helpful errorr message for missing decoratorsBeforeExport in parser. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :memo: Documentation
|
||||
* [#8561](https://github.com/babel/babel/pull/8561) Added pronounciation of babel. ([@siddhant1](https://github.com/siddhant1))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-core`
|
||||
* [#8714](https://github.com/babel/babel/pull/8714) Fix Flow error with new versionRange test.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* Other
|
||||
* [#8679](https://github.com/babel/babel/pull/8679) remove force publish, temp tag [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8661](https://github.com/babel/babel/pull/8661) Makefile: run fix json on fix. ([@xtuc](https://github.com/xtuc))
|
||||
* `babel-*`
|
||||
* [#8658](https://github.com/babel/babel/pull/8658) Format fixture options.json with Prettier.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-parser`
|
||||
* [#8630](https://github.com/babel/babel/pull/8630) Bump flow to 0.80 and fix sourceType error. ([@existentialism](https://github.com/existentialism))
|
||||
* [#8610](https://github.com/babel/babel/pull/8610) types: missing `unambiguous` sourceType. ([@xtuc](https://github.com/xtuc))
|
||||
* [#8170](https://github.com/babel/babel/pull/8170) @babel/parser: expose a TypeScript definition file from package. ([@AviVahl](https://github.com/AviVahl))
|
||||
* `babel-*`
|
||||
* [#8573](https://github.com/babel/babel/pull/8573) add access public to all packages [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
## v7.0.1 (2018-09-11)
|
||||
|
||||
Doing a quick patch regarding helpers versioning to prevent future issues: https://github.com/babel/babel/pull/8659
|
||||
|
||||
## v7.0.0 (2018-08-27)
|
||||
|
||||
No change from rc.4. Finally released as https://babeljs.io/blog/2018/08/27/7.0.0!
|
||||
|
||||
## v7.0.0-rc.4 (2018-08-27)
|
||||
|
||||
> Similar to removing proposals in `@babel/polyfill`, we are removing them in `transform-runtime`
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8547](https://github.com/babel/babel/pull/8547) Remove nonstandard functions and fake prototype methods from babel-runtime. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-parser`
|
||||
* [#8539](https://github.com/babel/babel/pull/8539) Update parser whitespace for clarity. ([@jridgewell](https://github.com/jridgewell))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-register`
|
||||
* [#8553](https://github.com/babel/babel/pull/8553) bump source-map-support. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-core`
|
||||
* [#8546](https://github.com/babel/babel/pull/8546) Default highlightCode:true for the parser highlighting.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :house: Internal
|
||||
* Other
|
||||
* [#8554](https://github.com/babel/babel/pull/8554) Lerna: remove exact [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-parser`
|
||||
* [#8540](https://github.com/babel/babel/pull/8540) Cleanup getLineInfo. ([@jridgewell](https://github.com/jridgewell))
|
||||
* [#8541](https://github.com/babel/babel/pull/8541) Update to ES6 String methods. ([@jridgewell](https://github.com/jridgewell))
|
||||
* [#8537](https://github.com/babel/babel/pull/8537) Flatten TokenType class hierarchy. ([@jridgewell](https://github.com/jridgewell))
|
||||
* [#8539](https://github.com/babel/babel/pull/8539) Update parser whitespace for clarity. ([@jridgewell](https://github.com/jridgewell))
|
||||
|
||||
## v7.0.0-rc.3 (2018-08-24)
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-preset-env`
|
||||
* [#8509](https://github.com/babel/babel/pull/8509) Add browserslist 4 support.. ([@yavorsky](https://github.com/yavorsky))
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8518](https://github.com/babel/babel/pull/8518) Make 'useESModules' only toggle CJS vs ESM helpers when importing file is ESM.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-plugin-transform-runtime`
|
||||
* [#8520](https://github.com/babel/babel/pull/8520) Expose opt-in useESModules:"auto" from transform-runtime to toggle based on 'supportsStaticESM'. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-helpers`, `babel-plugin-transform-classes`, `babel-preset-env`
|
||||
* [#8501](https://github.com/babel/babel/pull/8501) [_wrapNativeSuper] Don't wrap non-native constructors. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-generator`, `babel-traverse`, `babel-types`
|
||||
* [#8478](https://github.com/babel/babel/pull/8478) Fix path.scope.rename() to not change break clauses. ([@rafeca](https://github.com/rafeca))
|
||||
* `babel-plugin-proposal-object-rest-spread`
|
||||
* [#8514](https://github.com/babel/babel/pull/8514) fix: object rest with default values bug. ([@jquense](https://github.com/jquense))
|
||||
* `babel-traverse`
|
||||
* [#8505](https://github.com/babel/babel/pull/8505) Rename exported functions where name conflicts with param.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-plugin-transform-object-set-prototype-of-to-assign`
|
||||
* [#8409](https://github.com/babel/babel/pull/8409) Add LICENSE file to published npm packages [skip ci]. ([@opichals](https://github.com/opichals))
|
||||
* Other
|
||||
* [#8504](https://github.com/babel/babel/pull/8504) Update Babel to rc.2. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
## v7.0.0-rc.2 (2018-08-21)
|
||||
|
||||
A notable change is the addition of https://github.com/babel/babel/pull/8485 which enables https://github.com/babel/babel-loader/pull/660 (automatically doing `modules: false` for `@babel/preset-env` when using `babel-loader`.
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-core`
|
||||
* [#8470](https://github.com/babel/babel/pull/8470) Remove File#resolveModuleSource. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* [#8473](https://github.com/babel/babel/pull/8473) Allow babel-plugin/preset prefix to not be a prefix, when used in a scope.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`, `babel-parser`, `babel-plugin-syntax-decorators`
|
||||
* [#8465](https://github.com/babel/babel/pull/8465) Require decoratorsBeforeExport option for decorators. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-preset-env`
|
||||
* [#8500](https://github.com/babel/babel/pull/8500) Add missing es7.promise.finally polyfill when using useBuiltIns: usage. ([@jsnajdr](https://github.com/jsnajdr))
|
||||
* `babel-cli`, `babel-core`, `babel-node`, `babel-preset-env`, `babel-register`
|
||||
* [#8485](https://github.com/babel/babel/pull/8485) Allow preset-env to toggle module handling based on flags from the caller (like babel-loader). ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`
|
||||
* [#8474](https://github.com/babel/babel/pull/8474) Preserve 'false'-options for disabled plugins/presets.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* [#8473](https://github.com/babel/babel/pull/8473) Allow babel-plugin/preset prefix to not be a prefix, when used in a scope.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helper-transform-fixture-test-runner`, `babel-plugin-transform-runtime`
|
||||
* [#8435](https://github.com/babel/babel/pull/8435) Allow transform-runtime to insert runtime references with absolute paths.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`
|
||||
* [#8488](https://github.com/babel/babel/pull/8488) Fix trailingComments for FunctionExpression that is CallExpression arguments. ([@jiaxuan](https://github.com/jiaxuan))
|
||||
* `babel-core`
|
||||
* [#8493](https://github.com/babel/babel/pull/8493) Take top-level config source into consideration when processing nested env/overrides.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-helpers`, `babel-plugin-proposal-decorators`
|
||||
* [#7429](https://github.com/babel/babel/pull/7429) Fix default descriptor setting for class properties with decorators. ([@yhpark](https://github.com/yhpark))
|
||||
* `babel-plugin-transform-parameters`
|
||||
* [#8479](https://github.com/babel/babel/pull/8479) Fixes setter paratemer default value. ([@nikolayemrikh](https://github.com/nikolayemrikh))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-core`
|
||||
* [#8494](https://github.com/babel/babel/pull/8494) Cache individual programmatic descriptors along with the overall list.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* [#8493](https://github.com/babel/babel/pull/8493) Take top-level config source into consideration when processing nested env/overrides.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-core`
|
||||
* [#8493](https://github.com/babel/babel/pull/8493) Take top-level config source into consideration when processing nested env/overrides.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-plugin-transform-classes`
|
||||
* [#8472](https://github.com/babel/babel/pull/8472) Remove unused file. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
|
||||
## v7.0.0-rc.1 (2018-08-09)
|
||||
|
||||
Same as rc.0 but fixes the peerDep issue #8443. It's changed to just be ^7.0.0-0
|
||||
|
||||
## v7.0.0-rc.0 (2018-08-09)
|
||||
|
||||
> This had an issue with `peerDependencies` so please use `rc.1`.
|
||||
|
||||
Alright finally at the end 🙂. Shouldn't have anymore breaking changes and going to wait some time to fix bugs/regressions
|
||||
|
||||
> Summary: `@babel/polyfill` will not include proposal polyfills by default and fixed a regression.
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-polyfill`
|
||||
* [#8440](https://github.com/babel/babel/pull/8440) remove proposals polyfills from default import [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
> Will add this to the upgrade guide/polyfill docs. I guess we could include a `babel-upgrade` for this too, not sure.
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-cli`
|
||||
* [#8436](https://github.com/babel/babel/pull/8436) Require v1.1.0 so that correct filter params are passed.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
## v7.0.0-beta.56 (2018-08-03)
|
||||
|
||||
- Separate `@babel/runtime`: should work for helpers alone and opt-into core-js if necessary.
|
||||
- More details in http://babeljs.io/docs/en/next/babel-runtime, http://babeljs.io/docs/en/next/babel-plugin-transform-runtime (via https://github.com/babel/babel/pull/8266, https://github.com/babel/website/pull/1714)
|
||||
- `babel-upgrade` issue: https://github.com/babel/babel-upgrade/issues/70
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-plugin-transform-regenerator`, `babel-plugin-transform-runtime`, `babel-runtime-corejs2`, `babel-runtime`
|
||||
* [#8266](https://github.com/babel/babel/pull/8266) Split @babel/runtime into 2 modules via @babel/runtime-corejs2. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`, `babel-helper-module-imports`, `babel-helpers`, `babel-plugin-external-helpers`, `babel-plugin-transform-runtime`
|
||||
* [#8398](https://github.com/babel/babel/pull/8398) Only reference helpers from external/runtime helpers if they are known to be available.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-plugin-transform-regenerator`, `babel-plugin-transform-runtime`, `babel-runtime-corejs2`, `babel-runtime`
|
||||
* [#8266](https://github.com/babel/babel/pull/8266) Split @babel/runtime into 2 modules via @babel/runtime-corejs2. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-parser`, `babel-plugin-transform-typescript`
|
||||
* [#8408](https://github.com/babel/babel/pull/8408) Allow TSInterfaceDeclaration to be default export. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-preset-env`
|
||||
* [#8403](https://github.com/babel/babel/pull/8403) Ensure esmodule targets are parsed by browserslist. ([@existentialism](https://github.com/existentialism))
|
||||
* Other
|
||||
* [#8024](https://github.com/babel/babel/pull/8024) Run transform-runtime on the standalone bundle so it stays ES5-compatible.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :memo: Documentation
|
||||
* [#8412](https://github.com/babel/babel/pull/8412) Update Documentation[skip ci]. ([@leongjiameng](https://github.com/leongjiameng))
|
||||
|
||||
## v7.0.0-beta.55 (2018-07-28)
|
||||
|
||||
Breaking Change in beta:
|
||||
|
||||
> Throws an error on using Stage presets: https://babeljs.io/blog/2018/07/27/removing-babels-stage-presets
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-core`, `babel-plugin-proposal-class-properties`, `babel-plugin-proposal-decorators`, `babel-preset-stage-0`, `babel-preset-stage-1`, `babel-preset-stage-2`, `babel-preset-stage-3`, `babel-standalone`
|
||||
* [#8293](https://github.com/babel/babel/pull/8293) Remove Stage presets. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-generator`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-types`
|
||||
* [#7754](https://github.com/babel/babel/pull/7754) TypeScript: Support type arguments on tagged templates. ([@andy-ms](https://github.com/andy-ms))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-cli`, `babel-core`, `babel-generator`
|
||||
* [#8380](https://github.com/babel/babel/pull/8380) Ensure that Identifier source mappings explicitly start and stop on the generated range. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-preset-env`
|
||||
* [#8391](https://github.com/babel/babel/pull/8391) Ensure preset-env doesn't clobber browserslist defaults. ([@existentialism](https://github.com/existentialism))
|
||||
* `babel-core`
|
||||
* [#8376](https://github.com/babel/babel/pull/8376) Fix order of optional argument reordering. ([@Qix-](https://github.com/Qix-))
|
||||
* [#8381](https://github.com/babel/babel/pull/8381) Allow an Array for `babelrcRoots`.. ([@wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg))
|
||||
* [#8342](https://github.com/babel/babel/pull/8342) Do not mutate ast. ([@thiagoarrais](https://github.com/thiagoarrais))
|
||||
* `babel-parser`
|
||||
* [#8374](https://github.com/babel/babel/pull/8374) Correctly parse interface methods named 'static'. ([@bakkot](https://github.com/bakkot))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-parser`
|
||||
* [#8355](https://github.com/babel/babel/pull/8355) remove .then from `dynamic import` parser exception message. ([@dnalborczyk](https://github.com/dnalborczyk))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-core`, `babel-preset-stage-0`, `babel-preset-stage-1`, `babel-preset-stage-2`, `babel-preset-stage-3`, `babel-standalone`
|
||||
* [#8397](https://github.com/babel/babel/pull/8397) Remove our own use of stage presets. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-helpers`, `babel-plugin-proposal-class-properties`
|
||||
* [#8318](https://github.com/babel/babel/pull/8318) Save full descriptor instead of only value for private fields.. ([@nicolo-ribaudo](https://github.com/nicolo-ribaudo))
|
||||
* `babel-core`
|
||||
* [#8381](https://github.com/babel/babel/pull/8381) Allow an Array for `babelrcRoots`.. ([@wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg))
|
||||
* `babel-cli`, `babel-core`, `babel-generator`, `babel-helper-define-map`, `babel-helper-fixtures`, `babel-helper-module-imports`, `babel-helper-module-transforms`, `babel-helper-regex`, `babel-helper-simple-access`, `babel-helper-transform-fixture-test-runner`, `babel-node`, `babel-plugin-transform-block-scoping`, `babel-register`, `babel-template`, `babel-traverse`, `babel-types`
|
||||
* [#8377](https://github.com/babel/babel/pull/8377) Bumped lodash to 4.17.10. ([@Berkmann18](https://github.com/Berkmann18))
|
||||
|
||||
## v7.0.0-beta.54 (2018-07-16)
|
||||
|
||||
> Regarding https://github.com/babel/babel/issues/8184, we aren't using `micromatch` for paths, just basic `*/**` substitution now. For anything more complicated we will recommend using a regex/`.js` config.
|
||||
> Fixed a bug in the stage presets (https://github.com/babel/babel/issues/8307), so we just removed the requirements for setting options in the meantime for ease of use. We are removing the Stage presets next release. https://github.com/babel/babel/pull/8293
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-core`, `babel-register`, `babel-traverse`
|
||||
* [#8327](https://github.com/babel/babel/pull/8327) Treat string ignore/only/test/include/exclude values as paths with only basic pattern matching. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-core`, `babel-register`, `babel-traverse`
|
||||
* [#8327](https://github.com/babel/babel/pull/8327) Treat string ignore/only/test/include/exclude values as paths with only basic pattern matching. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-preset-stage-0`, `babel-preset-stage-1`
|
||||
* [#8317](https://github.com/babel/babel/pull/8317) Fix stage-0/1 import of pipeline proposals array. ([@mAAdhaTTah](https://github.com/mAAdhaTTah))
|
||||
* `babel-helper-module-transforms`, `babel-plugin-transform-modules-commonjs`
|
||||
* [#8316](https://github.com/babel/babel/pull/8316) Ensure that the wildcard interop is used with re-export + default.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
* `babel-core`
|
||||
* [#8315](https://github.com/babel/babel/pull/8315) Remove option-filtering options from the final options results.. ([@loganfsmyth](https://github.com/loganfsmyth))
|
||||
|
||||
#### :memo: Documentation
|
||||
* [#8320](https://github.com/babel/babel/pull/8320) Add link to audio version of song. ([@rugk](https://github.com/rugk))
|
||||
|
||||
## v7.0.0-beta.53 (2018-07-11)
|
||||
|
||||
- Fix for regression with paths on windows due to micromatch upgrade, remove yearly presets (not published)
|
||||
- (There was an issue with the Stage presets in this release, but it is also deprecated)
|
||||
|
||||
#### :boom: Breaking Change
|
||||
* `babel-*`
|
||||
* [#8274](https://github.com/babel/babel/pull/8274) Remove yearly presets from repo. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
#### :rocket: New Feature
|
||||
* `babel-generator`, `babel-parser`, `babel-plugin-transform-typescript`, `babel-types`
|
||||
* [#7799](https://github.com/babel/babel/pull/7799) TypeScript: Support type arguments on JSX opening and self-closing tags. ([@andy-ms](https://github.com/andy-ms))
|
||||
* `babel-parser`
|
||||
* [#8291](https://github.com/babel/babel/pull/8291) Support pipeline proposal flag in `@babel/parser`. ([@mAAdhaTTah](https://github.com/mAAdhaTTah))
|
||||
* `babel-plugin-proposal-object-rest-spread`
|
||||
* [#8264](https://github.com/babel/babel/pull/8264) Remove unused bindings when excluding keys with rest in loose mode. ([@Andarist](https://github.com/Andarist))
|
||||
* `babel-helpers`, `babel-plugin-proposal-object-rest-spread`, `babel-plugin-transform-destructuring`, `babel-preset-env`
|
||||
* [#8261](https://github.com/babel/babel/pull/8261) Introduce objectWithoutPropertiesLoose helper. ([@Andarist](https://github.com/Andarist))
|
||||
|
||||
#### :bug: Bug Fix
|
||||
* `babel-core`
|
||||
* [#8281](https://github.com/babel/babel/pull/8281) Revert micromatch upgrade (regression) [skip ci]. ([@hzoo](https://github.com/hzoo))
|
||||
* `babel-types`
|
||||
* [#8165](https://github.com/babel/babel/pull/8165) [babel-types] Fix isNodesEquivalent() behavior for TemplateElements. ([@timkendrick](https://github.com/timkendrick))
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-plugin-syntax-pipeline-operator`, `babel-preset-stage-0`, `babel-preset-stage-1`
|
||||
* [#8279](https://github.com/babel/babel/pull/8279) Improve error messages around pipeline option. ([@mAAdhaTTah](https://github.com/mAAdhaTTah))
|
||||
|
||||
#### :memo: Documentation
|
||||
* [#8286](https://github.com/babel/babel/pull/8286) Move v4-v6 changelog to another file and all prerelease 7.0 logs [ski…. ([@hzoo](https://github.com/hzoo))
|
||||
|
||||
#### :house: Internal
|
||||
* `babel-preset-env`
|
||||
* [#8299](https://github.com/babel/babel/pull/8299) Make env preset build-data scripts reproducible. ([@rtsao](https://github.com/rtsao))
|
||||
* `babel-plugin-proposal-object-rest-spread`
|
||||
* [#8287](https://github.com/babel/babel/pull/8287) Fixed fixture tests after merge. ([@Andarist](https://github.com/Andarist))
|
||||
* Other
|
||||
* [#8187](https://github.com/babel/babel/pull/8187) Invoke Jest main file directly. ([@ishitatsuyuki](https://github.com/ishitatsuyuki))
|
||||
|
||||
## v7.0.0-beta.52 (2018-07-06)
|
||||
|
||||
Deprecating the yearly/stage presets in v7 (will remove next beta). Ran `npm deprecate` on `@babel/preset-es2015`, `@babel/preset-es2016`, `@babel/preset-es2017`, `@babel/preset-stage-0`, `@babel/preset-stage-1`, `@babel/preset-stage-2`, `@babel/preset-stage-3` only for versions `>v7.0.0-beta.52`. This means this will only break your build if you are using `^` in Babel v7 beta (which we have recommended against each release). (It is unfortunate that the default behavior of npm is to use `^` when using `npm install` though; haven't made an RFC for it yet).
|
||||
@@ -2199,7 +2542,7 @@ Also started Babel to compile itself with Babel 7! (We'll be working on making i
|
||||
|
||||
#### :nail_care: Polish
|
||||
* `babel-register`
|
||||
* [#5411](https://github.com/babel/babel/pull/5411) Seperate version env cache files. ([@pwmckenna](https://github.com/pwmckenna))
|
||||
* [#5411](https://github.com/babel/babel/pull/5411) Separate version env cache files. ([@pwmckenna](https://github.com/pwmckenna))
|
||||
|
||||
#### :memo: Documentation
|
||||
* `babel-plugin-transform-runtime`
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
contributors and maintainers pledge to make participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting hzoo, thejameskyle, sebastian, or loganfsmyth on [Slack](https://slack.babeljs.io/). All
|
||||
reported by contacting Henry Zhu <hi@henryzoo.com>, Logan Smyth <loganfsmyth@gmail.com> or one of the other [Babel core team members](https://babeljs.io/team). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
|
||||
@@ -24,7 +24,7 @@ contributing, please read the
|
||||
## Not sure where to start?
|
||||
|
||||
- If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics.
|
||||
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://github.com/babel/babel/tree/master/packages/babel-parser#output).
|
||||
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://babeljs.io/docs/en/next/babel-parser.html#output).
|
||||
- Check out [`/doc`](https://github.com/babel/babel/tree/master/doc) for information about Babel's internals
|
||||
- Check out [the Babel Plugin Handbook](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-plugin-handbook) - core plugins are written the same way as any other plugin!
|
||||
- Check out [AST Explorer](http://astexplorer.net/#/scUfOmVOG5) to learn more about ASTs or make your own plugin in the browser
|
||||
@@ -186,7 +186,7 @@ For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https:/
|
||||
- If you need to expect an error, you can ignore creating the `output.js` file and pass a new `throws` key to the `options.json` that contains the error string that is created.
|
||||
- The second and preferred type is a test that actually evaluates the produced code and asserts that certain properties are true or false. We do this by creating an [`exec.js`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/comprehensive/exec.js) file.
|
||||
|
||||
In a fixture test, you simply write out the code you want transformed in `input.js`.
|
||||
In a fixture test, you simply write out the code you want to transform in `input.js`.
|
||||
|
||||
```js
|
||||
// input.js
|
||||
@@ -230,7 +230,7 @@ If the test requires a minimum Node version, you can add `minNodeVersion` (must
|
||||
|
||||
Writing tests for the babel parser is very
|
||||
similar to the other packages.
|
||||
Inside the `packages/babel-parser/tests/fixtures` folder are categories/groupings of test fixtures (es2015, flow,
|
||||
Inside the `packages/babel-parser/test/fixtures` folder are categories/groupings of test fixtures (es2015, flow,
|
||||
etc.). To add a test, create a folder under one of these groupings (or create a new one) with a
|
||||
descriptive name, and add the following:
|
||||
|
||||
@@ -310,7 +310,7 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe
|
||||
- Create a new issue that describes the proposal (ex: [#538](https://github.com/babel/babylon/issues/538)). Include any relevant information like proposal repo/author, examples, parsing approaches, meeting notes, presentation slides, and more.
|
||||
- The pull request should include:
|
||||
- [ ] An update to the [plugins](https://github.com/babel/babel/tree/master/packages/babel-parser#plugins) part of the readme. Add a new entry to that list for the new plugin flag (and link to the proposal)
|
||||
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/bloc/master/packages/babel-parser/ast/spec.md)
|
||||
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md)
|
||||
- [ ] Make sure you use the `this.hasPlugin("plugin-name-here")` check in the babel parser so that your new plugin code only runs when that flag is turned on (not default behavior)
|
||||
- [ ] Add failing/passing tests according to spec behavior
|
||||
- Start working about the Babel transform itself!
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
|
||||
Copyright (c) 2014-2018 Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
42
Makefile
42
Makefile
@@ -1,6 +1,6 @@
|
||||
MAKEFLAGS = -j1
|
||||
FLOW_COMMIT = 395e045c18d537fcbbc552a96ef2cdcd70b4ab52
|
||||
TEST262_COMMIT = f90a52b39609a620c0854e0bd0b3a906c930fd17
|
||||
FLOW_COMMIT = e192e1a4793dd8e43415fbfe8046d832cb513c8b
|
||||
TEST262_COMMIT = 238c88d4a084d9928372954e2fec54af2c951281
|
||||
|
||||
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
|
||||
export FORCE_COLOR = true
|
||||
@@ -31,7 +31,7 @@ build-preset-env-standalone:
|
||||
build-dist: build
|
||||
cd packages/babel-polyfill; \
|
||||
scripts/build-dist.sh
|
||||
cd packages/babel-runtime; \
|
||||
cd packages/babel-plugin-transform-runtime; \
|
||||
node scripts/build-dist.js
|
||||
|
||||
watch: clean clean-lib
|
||||
@@ -47,10 +47,13 @@ flow:
|
||||
./node_modules/.bin/flow check --strip-root
|
||||
|
||||
lint:
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --rulesdir="./scripts/eslint_rules"
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe
|
||||
|
||||
fix:
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix --rulesdir="./scripts/eslint_rules"
|
||||
fix: fix-json
|
||||
./node_modules/.bin/eslint scripts $(SOURCES) '*.js' --format=codeframe --fix
|
||||
|
||||
fix-json:
|
||||
./node_modules/.bin/prettier "{packages,codemod}/*/test/fixtures/**/options.json" --write --loglevel warn
|
||||
|
||||
clean: test-clean
|
||||
rm -rf packages/babel-polyfill/browser*
|
||||
@@ -79,7 +82,7 @@ test-ci-coverage:
|
||||
bootstrap-flow:
|
||||
rm -rf ./build/flow
|
||||
mkdir -p ./build
|
||||
git clone --branch=master --single-branch --shallow-since=2017-01-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)
|
||||
|
||||
test-flow:
|
||||
@@ -93,7 +96,7 @@ test-flow-update-whitelist:
|
||||
bootstrap-test262:
|
||||
rm -rf ./build/test262
|
||||
mkdir -p ./build
|
||||
git clone --branch=master --single-branch --shallow-since=2017-01-01 https://github.com/tc39/test262.git ./build/test262
|
||||
git clone --branch=master --single-branch --shallow-since=2018-11-01 https://github.com/tc39/test262.git ./build/test262
|
||||
cd build/test262 && git checkout $(TEST262_COMMIT)
|
||||
|
||||
test-test262:
|
||||
@@ -104,23 +107,32 @@ test-test262-ci: bootstrap test-test262
|
||||
test-test262-update-whitelist:
|
||||
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist
|
||||
|
||||
publish:
|
||||
git pull --rebase
|
||||
clone-license:
|
||||
./scripts/clone-license.sh
|
||||
|
||||
prepublish-build:
|
||||
make clean-lib
|
||||
rm -rf packages/babel-runtime/helpers
|
||||
rm -rf packages/babel-runtime/core-js
|
||||
BABEL_ENV=production make build-dist
|
||||
rm -rf packages/babel-runtime-corejs2/helpers
|
||||
rm -rf packages/babel-runtime-corejs2/core-js
|
||||
BABEL_ENV=production IS_PUBLISH=true make build-dist
|
||||
make clone-license
|
||||
|
||||
prepublish:
|
||||
git pull --rebase
|
||||
make prepublish-build
|
||||
make test
|
||||
# not using lerna independent mode atm, so only update packages that have changed since we use ^
|
||||
|
||||
publish: prepublish
|
||||
# --only-explicit-updates
|
||||
./node_modules/.bin/lerna publish --force-publish=* --exact --skip-temp-tag
|
||||
./node_modules/.bin/lerna publish --force-publish="@babel/runtime,@babel/runtime-corejs2" --dangerously-only-publish-explicit-updates-this-is-a-custom-flag-for-babel-and-you-should-not-be-using-it-just-deal-with-more-packages-being-published-it-is-not-a-big-deal
|
||||
make clean
|
||||
|
||||
bootstrap: clean-all
|
||||
yarn --ignore-engines
|
||||
./node_modules/.bin/lerna bootstrap -- --ignore-engines
|
||||
make build
|
||||
cd packages/babel-runtime; \
|
||||
cd packages/babel-plugin-transform-runtime; \
|
||||
node scripts/build-dist.js
|
||||
|
||||
clean-lib:
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<a href="https://medium.com/friendship-dot-js/i-peeked-into-my-node-modules-directory-and-you-wont-believe-what-happened-next-b89f63d21558"><img alt="Business Strategy Status" src="https://img.shields.io/badge/business%20model-flavortown-green.svg"></a>
|
||||
</p>
|
||||
|
||||
Babel is a community-driven project used by many companies and projects, and is maintained by a group of [volunteers](https://babeljs.io/team). If you'd like to help support the future of the project, please consider:
|
||||
Babel (pronounced ["babble"](https://soundcloud.com/sebmck/how-to-pronounce-babel)) is a community-driven project used by many companies and projects, and is maintained by a group of [volunteers](https://babeljs.io/team). If you'd like to help support the future of the project, please consider:
|
||||
|
||||
- Giving developer time on the project. (Message us on [Twitter](https://twitter.com/babeljs) or [Slack](https://slack.babeljs.io/) for guidance!)
|
||||
- Giving funds by becoming a sponsor (see below)!
|
||||
@@ -68,6 +68,10 @@ Become a sponsor and get your logo on our README on Github with a link to your s
|
||||
|
||||
Become a sponsor and get your logo on our README on Github with a link to your site. [[Become a sponsor](https://www.patreon.com/henryzhu)]
|
||||
|
||||
## Silver
|
||||
|
||||
<a href="https://issue.sh/?utm_medium=github&utm_campaign=babel" target="_blank"><img src="https://user-images.githubusercontent.com/5557143/43912065-c8cdff78-9c33-11e8-829a-0b4166ccc215.png"></a>
|
||||
|
||||
## Bronze
|
||||
|
||||
<a href="http://teamextension.io/" target="_blank"><img src="https://teamextension.io/dist/img/logo/te-logo-compact.png" height="64"></a>
|
||||
@@ -103,7 +107,7 @@ Mostly a handful of volunteers! Please check out our [team page](https://babeljs
|
||||
|
||||
### Looking for support?
|
||||
|
||||
For questions and support please visit join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
|
||||
For questions and support please join our [Slack Community](https://slack.babeljs.io/) (you can sign-up [here](https://slack.babeljs.io/) for an invite), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
|
||||
|
||||
### Is there a Babel song?
|
||||
|
||||
|
||||
@@ -13,13 +13,18 @@ module.exports = function(api) {
|
||||
|
||||
let convertESM = true;
|
||||
let ignoreLib = true;
|
||||
let includeRuntime = false;
|
||||
|
||||
switch (env) {
|
||||
// Configs used during bundling builds.
|
||||
case "babel-parser":
|
||||
convertESM = false;
|
||||
ignoreLib = false;
|
||||
break;
|
||||
case "standalone":
|
||||
convertESM = false;
|
||||
ignoreLib = false;
|
||||
includeRuntime = true;
|
||||
break;
|
||||
case "production":
|
||||
// Config during builds before publish.
|
||||
@@ -41,6 +46,10 @@ module.exports = function(api) {
|
||||
}
|
||||
|
||||
const config = {
|
||||
// Our dependencies are all standard CommonJS, along with all sorts of
|
||||
// other random files in Babel's codebase, so we use script as the default,
|
||||
// and then mark actual modules as modules farther down.
|
||||
sourceType: "script",
|
||||
comments: false,
|
||||
ignore: [
|
||||
// These may not be strictly necessary with the newly-limited scope of
|
||||
@@ -84,7 +93,29 @@ module.exports = function(api) {
|
||||
convertESM ? "@babel/transform-modules-commonjs" : null,
|
||||
].filter(Boolean),
|
||||
},
|
||||
],
|
||||
{
|
||||
// The vast majority of our src files are modules, but we use
|
||||
// unambiguous to keep things simple until we get around to renaming
|
||||
// the modules to be more easily distinguished from CommonJS
|
||||
test: [
|
||||
"packages/*/src",
|
||||
"packages/*/test",
|
||||
"codemods/*/src",
|
||||
"codemods/*/test",
|
||||
],
|
||||
sourceType: "unambiguous",
|
||||
},
|
||||
{
|
||||
// The runtime transform shouldn't process its own runtime or core-js.
|
||||
exclude: [
|
||||
"packages/babel-runtime",
|
||||
/[\\/]node_modules[\\/](?:@babel\/runtime|babel-runtime|core-js)[\\/]/,
|
||||
],
|
||||
plugins: [includeRuntime ? "@babel/transform-runtime" : null].filter(
|
||||
Boolean
|
||||
),
|
||||
},
|
||||
].filter(Boolean),
|
||||
};
|
||||
|
||||
// we need to do this as long as we do not test everything from source
|
||||
|
||||
@@ -36,7 +36,7 @@ npm install --save-dev @babel/plugin-codemod-object-assign-to-object-spread
|
||||
|
||||
**.babelrc**
|
||||
|
||||
```json
|
||||
```jsonc
|
||||
{
|
||||
"plugins": ["@babel/plugin-codemod-object-assign-to-object-spread"]
|
||||
}
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
{
|
||||
"name": "@babel/plugin-codemod-object-assign-to-object-spread",
|
||||
"version": "7.0.0-beta.54",
|
||||
"version": "7.0.0",
|
||||
"description": "Transforms Object.assign into object spread syntax",
|
||||
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-object-assign-to-object-spread",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"keywords": [
|
||||
"@babel/codemod",
|
||||
"@babel/plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.54"
|
||||
"@babel/plugin-syntax-object-rest-spread": "^7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.54",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.54"
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
||||
@@ -34,7 +34,7 @@ npm install --save-dev @babel/plugin-codemod-optional-catch-binding
|
||||
|
||||
**.babelrc**
|
||||
|
||||
```json
|
||||
```jsonc
|
||||
{
|
||||
"plugins": ["@babel/plugin-codemod-optional-catch-binding"]
|
||||
}
|
||||
|
||||
@@ -1,22 +1,25 @@
|
||||
{
|
||||
"name": "@babel/plugin-codemod-optional-catch-binding",
|
||||
"version": "7.0.0-beta.54",
|
||||
"version": "7.0.0",
|
||||
"description": "Remove unused catch bindings",
|
||||
"repository": "https://github.com/babel/babel/tree/master/codemods/babel-plugin-codemod-remove-unused-catch-binding",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"keywords": [
|
||||
"@babel/codemod",
|
||||
"@babel/plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.54"
|
||||
"@babel/plugin-syntax-optional-catch-binding": "^7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.54",
|
||||
"@babel/helper-plugin-test-runner": "7.0.0-beta.54"
|
||||
"@babel/core": "^7.0.0",
|
||||
"@babel/helper-plugin-test-runner": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
11
eslint-local-rules.js
Normal file
11
eslint-local-rules.js
Normal file
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
|
||||
const noDeprecatedClone = require("./scripts/eslint_rules/no-deprecated-clone");
|
||||
const noUndefinedIdentifier = require("./scripts/eslint_rules/no-undefined-identifier");
|
||||
const pluginName = require("./scripts/eslint_rules/plugin-name");
|
||||
|
||||
module.exports = {
|
||||
"no-deprecated-clone": noDeprecatedClone,
|
||||
"no-undefined-identifier": noUndefinedIdentifier,
|
||||
"plugin-name": pluginName,
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.0.0-beta.54",
|
||||
"version": "7.2.0",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
@@ -18,8 +18,11 @@
|
||||
"publish": {
|
||||
"ignore": [
|
||||
"*.md",
|
||||
"*.json",
|
||||
"*.txt",
|
||||
"test/**",
|
||||
"codemods/**"
|
||||
"codemods/**",
|
||||
"package.json"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2,12 +2,6 @@
|
||||
* Basic declarations for the npm modules we use.
|
||||
*/
|
||||
|
||||
declare module "micromatch" {
|
||||
declare module.exports: {
|
||||
(Array<string>, Array<string>, ?{ nocase: boolean }): Array<string>,
|
||||
};
|
||||
}
|
||||
|
||||
declare module "resolve" {
|
||||
declare export default {
|
||||
sync: (string, {| basedir: string |}) => string;
|
||||
@@ -32,6 +26,20 @@ declare module "lodash/merge" {
|
||||
declare export default <T: Object>(T, Object) => T;
|
||||
}
|
||||
|
||||
declare module "semver" {
|
||||
declare module.exports: {
|
||||
valid(v: string): boolean;
|
||||
gt(v1: string, v2: string): boolean;
|
||||
lt(v1: string, v2: string): boolean;
|
||||
major(v: string): number;
|
||||
minor(v: string): number;
|
||||
patch(v: string): number;
|
||||
satisfies(v1: string, r1: string): boolean;
|
||||
|
||||
intersects(r1: string, r2: string): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "source-map" {
|
||||
declare export type SourceMap = {
|
||||
version: 3,
|
||||
|
||||
72
package.json
72
package.json
@@ -6,60 +6,63 @@
|
||||
"build": "make build",
|
||||
"fix": "make fix",
|
||||
"lint": "make lint",
|
||||
"precommit": "lint-staged",
|
||||
"test": "make test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.0.0-beta.52",
|
||||
"@babel/core": "7.0.0-beta.52",
|
||||
"@babel/plugin-transform-modules-commonjs": "7.0.0-beta.52",
|
||||
"@babel/preset-env": "7.0.0-beta.52",
|
||||
"@babel/preset-flow": "7.0.0-beta.52",
|
||||
"@babel/preset-stage-0": "7.0.0-beta.52",
|
||||
"@babel/register": "7.0.0-beta.52",
|
||||
"@babel/cli": "^7.1.5",
|
||||
"@babel/core": "^7.1.6",
|
||||
"@babel/plugin-proposal-class-properties": "^7.1.0",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
|
||||
"@babel/plugin-transform-runtime": "^7.1.0",
|
||||
"@babel/preset-env": "^7.1.6",
|
||||
"@babel/preset-flow": "^7.0.0",
|
||||
"@babel/register": "^7.0.0",
|
||||
"@babel/runtime": "^7.1.5",
|
||||
"babel-core": "^7.0.0-0",
|
||||
"babel-eslint": "^8.2.5",
|
||||
"babel-jest": "^22.4.1",
|
||||
"babel-loader": "8.0.0-beta.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-jest": "^23.6.0",
|
||||
"babel-loader": "^8.0.4",
|
||||
"babel-plugin-transform-charcodes": "^0.1.0",
|
||||
"browserify": "^13.1.1",
|
||||
"browserify": "^16.2.2",
|
||||
"bundle-collapser": "^1.2.1",
|
||||
"chalk": "^2.3.2",
|
||||
"charcodes": "^0.1.0",
|
||||
"derequire": "^2.0.2",
|
||||
"enhanced-resolve": "^3.0.0",
|
||||
"eslint": "^5.0.1",
|
||||
"eslint-config-babel": "^7.0.2",
|
||||
"eslint-plugin-flowtype": "^2.49.3",
|
||||
"eslint-plugin-prettier": "^2.6.1",
|
||||
"flow-bin": "^0.75.0",
|
||||
"eslint": "^5.9.0",
|
||||
"eslint-config-babel": "^8.0.2",
|
||||
"eslint-plugin-flowtype": "^3.2.0",
|
||||
"eslint-plugin-local-rules": "0.1.0",
|
||||
"eslint-plugin-prettier": "^3.0.0",
|
||||
"flow-bin": "^0.82.0",
|
||||
"graceful-fs": "^4.1.11",
|
||||
"gulp": "^4.0.0",
|
||||
"gulp-babel": "^8.0.0-beta.2",
|
||||
"gulp-babel": "^8.0.0",
|
||||
"gulp-filter": "^5.1.0",
|
||||
"gulp-newer": "^1.0.0",
|
||||
"gulp-plumber": "^1.0.1",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"gulp-plumber": "^1.2.0",
|
||||
"gulp-rename": "^1.4.0",
|
||||
"gulp-uglify": "^3.0.1",
|
||||
"gulp-util": "^3.0.7",
|
||||
"gulp-watch": "^5.0.0",
|
||||
"husky": "^0.14.3",
|
||||
"jest": "^22.4.2",
|
||||
"gulp-watch": "^5.0.1",
|
||||
"husky": "^1.2.0",
|
||||
"jest": "^23.6.0",
|
||||
"lerna": "^2.11.0",
|
||||
"lerna-changelog": "^0.5.0",
|
||||
"lint-staged": "^6.0.1",
|
||||
"lodash": "^4.17.5",
|
||||
"lint-staged": "^8.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
"merge-stream": "^1.0.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"prettier": "1.13.2",
|
||||
"pump": "^1.0.2",
|
||||
"prettier": "^1.15.2",
|
||||
"pump": "^3.0.0",
|
||||
"rimraf": "^2.4.3",
|
||||
"rollup-plugin-babel": "^4.0.0-beta.0",
|
||||
"rollup-plugin-node-resolve": "^3.0.2",
|
||||
"rollup-stream": "^1.24.1",
|
||||
"test262-stream": "^1.2.0",
|
||||
"through2": "^2.0.0",
|
||||
"uglify-js": "^2.4.16",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-source-stream": "^2.0.0",
|
||||
"webpack": "^3.4.1",
|
||||
@@ -67,15 +70,20 @@
|
||||
"webpack-stream": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6.9.0 <= 11.0.0-0",
|
||||
"npm": ">= 2.x <= 5.x",
|
||||
"node": ">= 6.9.0 < 12.0.0",
|
||||
"npm": ">= 3.x <= 6.x",
|
||||
"yarn": ">=0.27.5 || >=1.0.0-20170811"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.js": [
|
||||
"eslint --format=codeframe --rulesdir='./scripts/eslint_rules'"
|
||||
"eslint --format=codeframe"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"jest": {
|
||||
"collectCoverageFrom": [
|
||||
"packages/*/src/**/*.mjs",
|
||||
|
||||
@@ -13,10 +13,10 @@ A monorepo, muhahahahahaha. See the [monorepo design doc](/doc/design/monorepo.m
|
||||
|
||||
| Package | Version | Dependencies |
|
||||
|--------|-------|------------|
|
||||
| [`@babel/core`](/packages/babel-core) | [](https://www.npmjs.com/package/@babel/core) | [](https://david-dm.org/babel/babel?path=packages/babel-core) |
|
||||
| [`@babel/parser`](/packages/@babel/parser) | [](https://www.npmjs.com/package/@babel/parser) | [](https://david-dm.org/babel/babel?path=packages/babel-parser) |
|
||||
| [`@babel/traverse`](/packages/babel-traverse) | [](https://www.npmjs.com/package/@babel/traverse) | [](https://david-dm.org/babel/babel?path=packages/babel-traverse) |
|
||||
| [`@babel/generator`](/packages/babel-generator) | [](https://www.npmjs.com/package/@babel/generator) | [](https://david-dm.org/babel/babel?path=packages/babel-generator) |
|
||||
| [`@babel/core`](/packages/babel-core) | [](https://www.npmjs.com/package/@babel/core) | [](https://david-dm.org/babel/babel?path=packages/babel-core) |
|
||||
| [`@babel/parser`](/packages/babel-parser) | [](https://www.npmjs.com/package/@babel/parser) | [](https://david-dm.org/babel/babel?path=packages/babel-parser) |
|
||||
| [`@babel/traverse`](/packages/babel-traverse) | [](https://www.npmjs.com/package/@babel/traverse) | [](https://david-dm.org/babel/babel?path=packages/babel-traverse) |
|
||||
| [`@babel/generator`](/packages/babel-generator) | [](https://www.npmjs.com/package/@babel/generator) | [](https://david-dm.org/babel/babel?path=packages/babel-generator) |
|
||||
|
||||
[`@babel/core`](/packages/babel-core) is the Babel compiler itself; it exposes the `babel.transform` method, where `transformedCode = transform(src).code`.
|
||||
|
||||
@@ -36,14 +36,14 @@ Check out the [`babel-handbook`](https://github.com/thejameskyle/babel-handbook/
|
||||
|
||||
| Package | Version | Dependencies |
|
||||
|--------|-------|------------|
|
||||
| [`@babel/cli`](/packages/babel-cli) | [](https://www.npmjs.com/package/@babel/cli) | [](https://david-dm.org/babel/babel?path=packages/babel-cli) |
|
||||
| [`@babel/types`](/packages/babel-types) | [](https://www.npmjs.com/package/@babel/types) | [](https://david-dm.org/babel/babel?path=packages/babel-types) |
|
||||
| [`@babel/polyfill`](/packages/babel-polyfill) | [](https://www.npmjs.com/package/@babel/polyfill) | [](https://david-dm.org/babel/babel?path=packages/babel-polyfill) |
|
||||
| [`@babel/runtime`](/packages/babel-runtime) | [](https://www.npmjs.com/package/@babel/runtime) | [](https://david-dm.org/babel/babel?path=packages/babel-runtime) |
|
||||
| [`@babel/register`](/packages/babel-register) | [](https://www.npmjs.com/package/@babel/register) | [](https://david-dm.org/babel/babel?path=packages/babel-register) |
|
||||
| [`@babel/template`](/packages/babel-template) | [](https://www.npmjs.com/package/@babel/template) | [](https://david-dm.org/babel/babel?path=packages/babel-template) |
|
||||
| [`@babel/helpers`](/packages/babel-helpers) | [](https://www.npmjs.com/package/@babel/helpers) | [](https://david-dm.org/babel/babel?path=packages/babel-helpers) |
|
||||
| [`@babel/code-frame`](/packages/babel-code-frame) | [](https://www.npmjs.com/package/@babel/code-frame) | [](https://david-dm.org/babel/babel?path=packages/babel-code-frame) |
|
||||
| [`@babel/cli`](/packages/babel-cli) | [](https://www.npmjs.com/package/@babel/cli) | [](https://david-dm.org/babel/babel?path=packages/babel-cli) |
|
||||
| [`@babel/types`](/packages/babel-types) | [](https://www.npmjs.com/package/@babel/types) | [](https://david-dm.org/babel/babel?path=packages/babel-types) |
|
||||
| [`@babel/polyfill`](/packages/babel-polyfill) | [](https://www.npmjs.com/package/@babel/polyfill) | [](https://david-dm.org/babel/babel?path=packages/babel-polyfill) |
|
||||
| [`@babel/runtime`](/packages/babel-runtime) | [](https://www.npmjs.com/package/@babel/runtime) | [](https://david-dm.org/babel/babel?path=packages/babel-runtime) |
|
||||
| [`@babel/register`](/packages/babel-register) | [](https://www.npmjs.com/package/@babel/register) | [](https://david-dm.org/babel/babel?path=packages/babel-register) |
|
||||
| [`@babel/template`](/packages/babel-template) | [](https://www.npmjs.com/package/@babel/template) | [](https://david-dm.org/babel/babel?path=packages/babel-template) |
|
||||
| [`@babel/helpers`](/packages/babel-helpers) | [](https://www.npmjs.com/package/@babel/helpers) | [](https://david-dm.org/babel/babel?path=packages/babel-helpers) |
|
||||
| [`@babel/code-frame`](/packages/babel-code-frame) | [](https://www.npmjs.com/package/@babel/code-frame) | [](https://david-dm.org/babel/babel?path=packages/babel-code-frame) |
|
||||
|
||||
- [`@babel/cli`](/packages/babel-cli) is the CLI tool that runs `@babel/core` and helps with outputting to a directory, a file, stdout and more (also includes `@babel/node` cli). Check out the [docs](https://babeljs.io/docs/usage/cli/).
|
||||
- [`@babel/types`](/packages/babel-types) is used to validate, build and change AST nodes.
|
||||
@@ -62,7 +62,7 @@ The transformer[s] used in Babel are the independent pieces of code that transfo
|
||||
|
||||
| Package | Version | Dependencies | Description |
|
||||
|--------|-------|------------|---|
|
||||
| [`@babel/preset-env`](/packages/babel-preset-env) | [](https://www.npmjs.com/package/@babel/preset-env) | [](https://david-dm.org/babel/babel?path=packages/babel-preset-env) | automatically determines plugins and polyfills you need based on your supported environments |
|
||||
| [`@babel/preset-env`](/packages/babel-preset-env) | [](https://www.npmjs.com/package/@babel/preset-env) | [](https://david-dm.org/babel/babel?path=packages/babel-preset-env) | automatically determines plugins and polyfills you need based on your supported environments |
|
||||
|
||||
> You can find community maintained presets on [npm](https://www.npmjs.com/search?q=babel-preset)
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"name": "@babel/cli",
|
||||
"version": "7.0.0-beta.54",
|
||||
"version": "7.2.0",
|
||||
"description": "Babel command line.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-cli",
|
||||
"keywords": [
|
||||
"6to5",
|
||||
@@ -18,23 +21,23 @@
|
||||
"dependencies": {
|
||||
"commander": "^2.8.1",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"fs-readdir-recursive": "^1.0.0",
|
||||
"fs-readdir-recursive": "^1.1.0",
|
||||
"glob": "^7.0.0",
|
||||
"lodash": "^4.17.5",
|
||||
"lodash": "^4.17.10",
|
||||
"mkdirp": "^0.5.1",
|
||||
"output-file-sync": "^2.0.0",
|
||||
"slash": "^1.0.0",
|
||||
"slash": "^2.0.0",
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"chokidar": "^2.0.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.50 <7.0.0-rc.0"
|
||||
"@babel/core": "^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.0.0-beta.54",
|
||||
"@babel/helper-fixtures": "7.0.0-beta.54"
|
||||
"@babel/core": "^7.2.0",
|
||||
"@babel/helper-fixtures": "^7.2.0"
|
||||
},
|
||||
"bin": {
|
||||
"babel": "./bin/babel.js",
|
||||
|
||||
@@ -89,7 +89,7 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
|
||||
const stat = fs.statSync(filenameOrDir);
|
||||
|
||||
if (stat.isDirectory(filenameOrDir)) {
|
||||
if (stat.isDirectory()) {
|
||||
const dirname = filenameOrDir;
|
||||
|
||||
let count = 0;
|
||||
|
||||
@@ -137,7 +137,11 @@ export default async function({ cliOptions, babelOptions }) {
|
||||
const dirname = filename;
|
||||
|
||||
util
|
||||
.readdirForCompilable(filename, cliOptions.includeDotfiles)
|
||||
.readdirForCompilable(
|
||||
filename,
|
||||
cliOptions.includeDotfiles,
|
||||
cliOptions.extensions,
|
||||
)
|
||||
.forEach(function(filename) {
|
||||
_filenames.push(path.join(dirname, filename));
|
||||
});
|
||||
|
||||
@@ -28,6 +28,11 @@ commander.option(
|
||||
"The name of the 'env' to use when loading configs and plugins. " +
|
||||
"Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.",
|
||||
);
|
||||
commander.option(
|
||||
"--root-mode [mode]",
|
||||
"The project-root resolution mode. " +
|
||||
"One of 'root' (the default), 'upward', or 'upward-optional'.",
|
||||
);
|
||||
|
||||
// Basic file input configuration.
|
||||
commander.option("--source-type [script|module]", "");
|
||||
@@ -76,7 +81,7 @@ commander.option(
|
||||
"print a comment after any injected non-user code",
|
||||
);
|
||||
|
||||
// General soucemap formatting.
|
||||
// General source map formatting.
|
||||
commander.option("-s, --source-maps [true|false|inline|both]", "", booleanify);
|
||||
commander.option(
|
||||
"--source-map-target [string]",
|
||||
@@ -162,20 +167,20 @@ export default function parseArgv(args: Array<string>) {
|
||||
|
||||
filenames.forEach(function(filename) {
|
||||
if (!fs.existsSync(filename)) {
|
||||
errors.push(filename + " doesn't exist");
|
||||
errors.push(filename + " does not exist");
|
||||
}
|
||||
});
|
||||
|
||||
if (commander.outDir && !filenames.length) {
|
||||
errors.push("filenames required for --out-dir");
|
||||
errors.push("--out-dir requires filenames");
|
||||
}
|
||||
|
||||
if (commander.outFile && commander.outDir) {
|
||||
errors.push("cannot have --out-file and --out-dir");
|
||||
errors.push("--out-file and --out-dir cannot be used together");
|
||||
}
|
||||
|
||||
if (commander.relative && !commander.outDir) {
|
||||
errors.push("output directory required for --relative");
|
||||
errors.push("--relative requires --out-dir usage");
|
||||
}
|
||||
|
||||
if (commander.watch) {
|
||||
@@ -207,41 +212,56 @@ export default function parseArgv(args: Array<string>) {
|
||||
}
|
||||
|
||||
if (errors.length) {
|
||||
console.error(errors.join(". "));
|
||||
console.error("babel:");
|
||||
errors.forEach(function(e) {
|
||||
console.error(" " + e);
|
||||
});
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const opts = commander.opts();
|
||||
|
||||
return {
|
||||
babelOptions: {
|
||||
presets: opts.presets,
|
||||
plugins: opts.plugins,
|
||||
configFile: opts.configFile,
|
||||
envName: opts.envName,
|
||||
sourceType: opts.sourceType,
|
||||
ignore: opts.ignore,
|
||||
only: opts.only,
|
||||
retainLines: opts.retainLines,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
sourceMaps: opts.sourceMaps,
|
||||
sourceFileName: opts.sourceFileName,
|
||||
sourceRoot: opts.sourceRoot,
|
||||
moduleRoot: opts.moduleRoot,
|
||||
moduleIds: opts.moduleIds,
|
||||
moduleId: opts.moduleId,
|
||||
const babelOptions = {
|
||||
presets: opts.presets,
|
||||
plugins: opts.plugins,
|
||||
rootMode: opts.rootMode,
|
||||
configFile: opts.configFile,
|
||||
envName: opts.envName,
|
||||
sourceType: opts.sourceType,
|
||||
ignore: opts.ignore,
|
||||
only: opts.only,
|
||||
retainLines: opts.retainLines,
|
||||
compact: opts.compact,
|
||||
minified: opts.minified,
|
||||
auxiliaryCommentBefore: opts.auxiliaryCommentBefore,
|
||||
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
|
||||
sourceMaps: opts.sourceMaps,
|
||||
sourceFileName: opts.sourceFileName,
|
||||
sourceRoot: opts.sourceRoot,
|
||||
moduleRoot: opts.moduleRoot,
|
||||
moduleIds: opts.moduleIds,
|
||||
moduleId: opts.moduleId,
|
||||
|
||||
// Commander will default the "--no-" arguments to true, but we want to
|
||||
// leave them undefined so that @babel/core can handle the
|
||||
// default-assignment logic on its own.
|
||||
babelrc: opts.babelrc === true ? undefined : opts.babelrc,
|
||||
highlightCode:
|
||||
opts.highlightCode === true ? undefined : opts.highlightCode,
|
||||
comments: opts.comments === true ? undefined : opts.comments,
|
||||
},
|
||||
// Commander will default the "--no-" arguments to true, but we want to
|
||||
// leave them undefined so that @babel/core can handle the
|
||||
// default-assignment logic on its own.
|
||||
babelrc: opts.babelrc === true ? undefined : opts.babelrc,
|
||||
highlightCode: opts.highlightCode === true ? undefined : opts.highlightCode,
|
||||
comments: opts.comments === true ? undefined : opts.comments,
|
||||
};
|
||||
|
||||
// If the @babel/cli version is newer than the @babel/core version, and we have added
|
||||
// new options for @babel/core, we'll potentially get option validation errors from
|
||||
// @babel/core. To avoid that, we delete undefined options, so @babel/core will only
|
||||
// give the error if users actually pass an unsupported CLI option.
|
||||
for (const key of Object.keys(babelOptions)) {
|
||||
if (babelOptions[key] === undefined) {
|
||||
delete babelOptions[key];
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
babelOptions,
|
||||
cliOptions: {
|
||||
filename: opts.filename,
|
||||
filenames,
|
||||
|
||||
@@ -15,18 +15,25 @@ export function readdir(
|
||||
includeDotfiles: boolean,
|
||||
filter: ReaddirFilter,
|
||||
) {
|
||||
return readdirRecursive(
|
||||
dirname,
|
||||
filename =>
|
||||
(includeDotfiles || filename[0] !== ".") && (!filter || filter(filename)),
|
||||
);
|
||||
return readdirRecursive(dirname, (filename, _index, currentDirectory) => {
|
||||
const stat = fs.statSync(path.join(currentDirectory, filename));
|
||||
|
||||
if (stat.isDirectory()) return true;
|
||||
|
||||
return (
|
||||
(includeDotfiles || filename[0] !== ".") && (!filter || filter(filename))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
export function readdirForCompilable(
|
||||
dirname: string,
|
||||
includeDotfiles: boolean,
|
||||
altExts?: Array<string>,
|
||||
) {
|
||||
return readdir(dirname, includeDotfiles, isCompilableExtension);
|
||||
return readdir(dirname, includeDotfiles, function(filename) {
|
||||
return isCompilableExtension(filename, altExts);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,9 +52,14 @@ export function addSourceMappingUrl(code, loc) {
|
||||
return code + "\n//# sourceMappingURL=" + path.basename(loc);
|
||||
}
|
||||
|
||||
const CALLER = {
|
||||
name: "@babel/cli",
|
||||
};
|
||||
|
||||
export function transform(filename, code, opts) {
|
||||
opts = {
|
||||
...opts,
|
||||
caller: CALLER,
|
||||
filename,
|
||||
};
|
||||
|
||||
@@ -60,6 +72,11 @@ export function transform(filename, code, opts) {
|
||||
}
|
||||
|
||||
export function compile(filename, opts) {
|
||||
opts = {
|
||||
...opts,
|
||||
caller: CALLER,
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
babel.transformFile(filename, opts, (err, result) => {
|
||||
if (err) reject(err);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir", "lib",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--include-dotfiles",
|
||||
"--ignore", "src/foo",
|
||||
"--ignore",
|
||||
"src/foo",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir", "lib",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--include-dotfiles",
|
||||
"--only", "src/foo",
|
||||
"--only",
|
||||
"src/foo",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--copy-files", "--include-dotfiles", "--verbose"]
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--include-dotfiles",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir", "lib",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--ignore", "src/foo/*",
|
||||
"--ignore",
|
||||
"src/foo/*",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
{
|
||||
"args": [
|
||||
"src",
|
||||
"--out-dir", "lib",
|
||||
"--out-dir",
|
||||
"lib",
|
||||
"--copy-files",
|
||||
"--only", "src/foo/*",
|
||||
"--only",
|
||||
"src/foo/*",
|
||||
"--verbose"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"args": ["--source-maps", "--out-file", "test.js"]
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"args": ["--source-maps", "inline"]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
return x * x;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsR0FBRyxDQUFDLEdBQUcsQ0FBQyxVQUFBLENBQUM7U0FBSSxDQUFDLEdBQUcsQ0FBQztDQUFBLENBQUMsQ0FBQyIsImZpbGUiOiJzdGRvdXQiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIHgpOyJdfQ==
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/bar/bar.js
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/bar/bar.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
|
||||
}
|
||||
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/foo.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/in-files/src/foo.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-dir", "lib", "--out-file", "compiled.js"]
|
||||
}
|
||||
2
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --out-dir --out-file/stderr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
babel:
|
||||
--out-file and --out-dir cannot be used together
|
||||
@@ -3,4 +3,4 @@
|
||||
arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9mb28uanMiXSwibmFtZXMiOlsiYXJyIiwibWFwIiwieCIsIk1VTFRJUExJRVIiXSwibWFwcGluZ3MiOiI7O0FBQUFBLElBQUlDLEdBQUosQ0FBUTtBQUFBLFNBQUtDLElBQUlDLFVBQVQ7QUFBQSxDQUFSIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9mb28uanMiXSwibmFtZXMiOlsiYXJyIiwibWFwIiwieCIsIk1VTFRJUExJRVIiXSwibWFwcGluZ3MiOiI7O0FBQUFBLEdBQUcsQ0FBQ0MsR0FBSixDQUFRLFVBQUFDLENBQUM7QUFBQSxTQUFJQSxDQUFDLEdBQUdDLFVBQVI7QUFBQSxDQUFUIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiBNVUxUSVBMSUVSKTsiXX0=
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../src/foo.js"],"names":["arr","map","x","MULTIPLIER"],"mappings":";;AAAAA,IAAIC,GAAJ,CAAQ;AAAA,SAAKC,IAAIC,UAAT;AAAA,CAAR","sourcesContent":["arr.map(x => x * MULTIPLIER);"],"file":"foo.js"}
|
||||
{"version":3,"sources":["../src/foo.js"],"names":["arr","map","x","MULTIPLIER"],"mappings":";;AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;AAAA,SAAIA,CAAC,GAAGC,UAAR;AAAA,CAAT","sourcesContent":["arr.map(x => x * MULTIPLIER);"],"file":"foo.js"}
|
||||
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["--out-dir", "lib"]
|
||||
}
|
||||
2
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --out-dir no filenames/stderr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
babel:
|
||||
--out-dir requires filenames
|
||||
1
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/in-files/src/bar/bar.es
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/in-files/src/bar/bar.es
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(() => 42)
|
||||
1
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/in-files/src/foo.es
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/in-files/src/foo.es
vendored
Normal file
@@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-file", "test.js", "--extensions", ".es"]
|
||||
}
|
||||
10
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/out-files/test.js
vendored
Normal file
10
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/out-files/test.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
(function () {
|
||||
return 42;
|
||||
});
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
0
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/stdout.txt
vendored
Normal file
0
packages/babel-cli/test/fixtures/babel/dir --out-file --extensions/stdout.txt
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-file/in-files/src/bar/bar.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-file/in-files/src/bar/bar.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
(() => 42)
|
||||
1
packages/babel-cli/test/fixtures/babel/dir --out-file/in-files/src/foo.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/dir --out-file/in-files/src/foo.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --out-file/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --out-file/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--out-file", "test.js"]
|
||||
}
|
||||
10
packages/babel-cli/test/fixtures/babel/dir --out-file/out-files/test.js
vendored
Normal file
10
packages/babel-cli/test/fixtures/babel/dir --out-file/out-files/test.js
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
"use strict";
|
||||
|
||||
(function () {
|
||||
return 42;
|
||||
});
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
0
packages/babel-cli/test/fixtures/babel/dir --out-file/stdout.txt
vendored
Normal file
0
packages/babel-cli/test/fixtures/babel/dir --out-file/stdout.txt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--skip-initial-build", "--out-dir", "lib"]
|
||||
}
|
||||
2
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --skip-initial-build no --watch/stderr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
babel:
|
||||
--skip-initial-build requires --watch
|
||||
@@ -0,0 +1,3 @@
|
||||
class Test {
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["src", "--watch"]
|
||||
}
|
||||
2
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/dir --watch no --out-dir no --out-file/stderr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
babel:
|
||||
--watch requires --out-file or --out-dir
|
||||
@@ -1 +1 @@
|
||||
filenames required for --out-dir
|
||||
--out-dir requires filenames
|
||||
|
||||
@@ -1 +1 @@
|
||||
cannot have --out-file and --out-dir
|
||||
--out-file and --out-dir cannot be used together
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"args": ["--relative"],
|
||||
"args": ["--relative", "--no-babelrc"],
|
||||
"stderrContains": true
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
output directory required for --relative
|
||||
--relative requires --out-dir usage
|
||||
|
||||
@@ -1 +1 @@
|
||||
foo.json doesn't exist
|
||||
foo.json does not exist
|
||||
|
||||
@@ -4,4 +4,4 @@ arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLElBQUksR0FBSixDQUFRO0FBQUEsU0FBSyxJQUFJLFVBQVQ7QUFBQSxDQUFSIiwiZmlsZSI6InNjcmlwdDIuanMiLCJzb3VyY2VzQ29udGVudCI6WyJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLEdBQUcsQ0FBQyxHQUFKLENBQVEsVUFBQSxDQUFDO0FBQUEsU0FBSSxDQUFDLEdBQUcsVUFBUjtBQUFBLENBQVQiLCJmaWxlIjoic2NyaXB0Mi5qcyIsInNvdXJjZXNDb250ZW50IjpbImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19
|
||||
|
||||
1
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/in-files/script.js
vendored
Normal file
1
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/in-files/script.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
arr.map(x => x * MULTIPLIER);
|
||||
3
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["--watch", "--out-file", "out.js", "--no-babelrc"]
|
||||
}
|
||||
2
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/filename --watch no filenames/stderr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
babel:
|
||||
--watch requires filenames
|
||||
3
packages/babel-cli/test/fixtures/babel/filename does not exist/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/filename does not exist/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["index.js"]
|
||||
}
|
||||
2
packages/babel-cli/test/fixtures/babel/filename does not exist/stderr.txt
vendored
Normal file
2
packages/babel-cli/test/fixtures/babel/filename does not exist/stderr.txt
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
babel:
|
||||
index.js does not exist
|
||||
@@ -4,4 +4,4 @@ arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9yaWdpbmFsLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsSUFBQSxHQUFBLENBQUE7QUFBQSxTQUFVLElBQUEsVUFBVjtBQUFBLENBQUEiLCJmaWxlIjoic2NyaXB0Mi5qcyIsInNvdXJjZXNDb250ZW50IjpbInZhciBmb28gPSAoKSA9PiA0OyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9yaWdpbmFsLmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsR0FBQSxDQUFBLEdBQUEsQ0FBQSxVQUFBLENBQUE7QUFBQSxTQUFVLENBQUEsR0FBQSxVQUFWO0FBQUEsQ0FBQSIsImZpbGUiOiJzY3JpcHQyLmpzIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGZvbyA9ICgpID0+IDQ7Il19
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
{
|
||||
"args": ["script.js", "script2.js", "--source-maps", "inline", "--out-file", "script3.js"]
|
||||
"args": [
|
||||
"script.js",
|
||||
"script2.js",
|
||||
"--source-maps",
|
||||
"inline",
|
||||
"--out-file",
|
||||
"script3.js"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@ arr.map(function (x) {
|
||||
return x * MULTIPLIER;
|
||||
});
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUFDO0FBQUEsU0FBTSxFQUFOO0FBQUEsQ0FBRDs7O0FDQUEsSUFBSSxHQUFKLENBQVE7QUFBQSxTQUFLLElBQUksVUFBVDtBQUFBLENBQVIiLCJmaWxlIjoic2NyaXB0My5qcyIsInNvdXJjZXNDb250ZW50IjpbIigoKSA9PiA0MikiLCJhcnIubWFwKHggPT4geCAqIE1VTFRJUExJRVIpOyJdfQ==
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNjcmlwdC5qcyIsInNjcmlwdDIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxDQUFDO0FBQUEsU0FBTSxFQUFOO0FBQUEsQ0FBRDs7O0FDQUEsR0FBRyxDQUFDLEdBQUosQ0FBUSxVQUFBLENBQUM7QUFBQSxTQUFJLENBQUMsR0FBRyxVQUFSO0FBQUEsQ0FBVCIsImZpbGUiOiJzY3JpcHQzLmpzIiwic291cmNlc0NvbnRlbnQiOlsiKCgpID0+IDQyKSIsImFyci5tYXAoeCA9PiB4ICogTVVMVElQTElFUik7Il19
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
{
|
||||
"args": ["script.js", "script2.js", "--source-maps", "--out-file", "script3.js"]
|
||||
"args": [
|
||||
"script.js",
|
||||
"script2.js",
|
||||
"--source-maps",
|
||||
"--out-file",
|
||||
"script3.js"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;AAAA,CAAC;AAAA,SAAM,EAAN;AAAA,CAAD;;;ACAA,IAAI,GAAJ,CAAQ;AAAA,SAAK,IAAI,UAAT;AAAA,CAAR","file":"script3.js","sourcesContent":["(() => 42)","arr.map(x => x * MULTIPLIER);"]}
|
||||
{"version":3,"sources":["script.js","script2.js"],"names":[],"mappings":";;AAAA,CAAC;AAAA,SAAM,EAAN;AAAA,CAAD;;;ACAA,GAAG,CAAC,GAAJ,CAAQ,UAAA,CAAC;AAAA,SAAI,CAAC,GAAG,UAAR;AAAA,CAAT","file":"script3.js","sourcesContent":["(() => 42)","arr.map(x => x * MULTIPLIER);"]}
|
||||
|
||||
3
packages/babel-cli/test/fixtures/babel/stdin --out-file --source-maps/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin --out-file --source-maps/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["--source-maps", "--out-file", "test.js", "--no-babelrc"]
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAG,CAAC,UAAA,CAAC;SAAI,CAAC,GAAG,CAAC;CAAA,CAAC,CAAC","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}
|
||||
{"version":3,"sources":["stdin"],"names":[],"mappings":";;AAAA,GAAG,CAAC,GAAJ,CAAQ,UAAA,CAAC;AAAA,SAAI,CAAC,GAAG,CAAR;AAAA,CAAT","file":"test.js","sourcesContent":["arr.map(x => x * x);"]}
|
||||
3
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/options.json
vendored
Normal file
3
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"args": ["--source-maps", "inline", "--no-babelrc"]
|
||||
}
|
||||
8
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/stdout.txt
vendored
Normal file
8
packages/babel-cli/test/fixtures/babel/stdin --source-maps inline/stdout.txt
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
arr.map(function (x) {
|
||||
return x * x;
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZGluIl0sIm5hbWVzIjpbImFyciIsIm1hcCIsIngiXSwibWFwcGluZ3MiOiI7O0FBQUFBLEdBQUcsQ0FBQ0MsR0FBSixDQUFRLFVBQUFDLENBQUM7QUFBQSxTQUFJQSxDQUFDLEdBQUdBLENBQVI7QUFBQSxDQUFUIiwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiB4KTsiXX0=
|
||||
|
||||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsImZpbGUiOiJzdGRvdXQifQ==
|
||||
@@ -1,14 +1,17 @@
|
||||
{
|
||||
"name": "@babel/code-frame",
|
||||
"version": "7.0.0-beta.54",
|
||||
"version": "7.0.0",
|
||||
"description": "Generate errors that contain a code frame that point to source locations.",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-code-frame",
|
||||
"main": "lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/highlight": "7.0.0-beta.54"
|
||||
"@babel/highlight": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chalk": "^2.0.0",
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"name": "@babel/core",
|
||||
"version": "7.0.0-beta.54",
|
||||
"version": "7.2.0",
|
||||
"description": "Babel compiler core.",
|
||||
"main": "lib/index.js",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://babeljs.io/",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-core",
|
||||
"keywords": [
|
||||
"6to5",
|
||||
@@ -30,23 +33,23 @@
|
||||
"./lib/transform-file.js": "./lib/transform-file-browser.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "7.0.0-beta.54",
|
||||
"@babel/generator": "7.0.0-beta.54",
|
||||
"@babel/helpers": "7.0.0-beta.54",
|
||||
"@babel/parser": "7.0.0-beta.54",
|
||||
"@babel/template": "7.0.0-beta.54",
|
||||
"@babel/traverse": "7.0.0-beta.54",
|
||||
"@babel/types": "7.0.0-beta.54",
|
||||
"@babel/code-frame": "^7.0.0",
|
||||
"@babel/generator": "^7.2.0",
|
||||
"@babel/helpers": "^7.2.0",
|
||||
"@babel/parser": "^7.2.0",
|
||||
"@babel/template": "^7.1.2",
|
||||
"@babel/traverse": "^7.1.6",
|
||||
"@babel/types": "^7.2.0",
|
||||
"convert-source-map": "^1.1.0",
|
||||
"debug": "^3.1.0",
|
||||
"json5": "^0.5.0",
|
||||
"lodash": "^4.17.5",
|
||||
"debug": "^4.1.0",
|
||||
"json5": "^2.1.0",
|
||||
"lodash": "^4.17.10",
|
||||
"resolve": "^1.3.2",
|
||||
"semver": "^5.4.1",
|
||||
"source-map": "^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.54",
|
||||
"@babel/register": "7.0.0-beta.54"
|
||||
"@babel/helper-transform-fixture-test-runner": "^7.0.0",
|
||||
"@babel/register": "^7.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,12 +206,29 @@ function makeSimpleConfigurator(
|
||||
return;
|
||||
}
|
||||
|
||||
return cache.using(val);
|
||||
return cache.using(() => assertSimpleType(val()));
|
||||
}
|
||||
cacheFn.forever = () => cache.forever();
|
||||
cacheFn.never = () => cache.never();
|
||||
cacheFn.using = cb => cache.using(() => cb());
|
||||
cacheFn.invalidate = cb => cache.invalidate(() => cb());
|
||||
cacheFn.using = cb => cache.using(() => assertSimpleType(cb()));
|
||||
cacheFn.invalidate = cb => cache.invalidate(() => assertSimpleType(cb()));
|
||||
|
||||
return (cacheFn: any);
|
||||
}
|
||||
|
||||
// Types are limited here so that in the future these values can be used
|
||||
// as part of Babel's caching logic.
|
||||
type SimpleType = string | boolean | number | null | void;
|
||||
export function assertSimpleType(value: mixed): SimpleType {
|
||||
if (
|
||||
value != null &&
|
||||
typeof value !== "string" &&
|
||||
typeof value !== "boolean" &&
|
||||
typeof value !== "number"
|
||||
) {
|
||||
throw new Error(
|
||||
"Cache keys must be either string, boolean, number, null, or undefined.",
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
type IgnoreList,
|
||||
type ConfigApplicableTest,
|
||||
type BabelrcSearch,
|
||||
type CallerMetadata,
|
||||
} from "./validation/options";
|
||||
import pathPatternToRegex from "./pattern-to-regex";
|
||||
|
||||
@@ -50,12 +51,27 @@ export type ConfigContext = {
|
||||
cwd: string,
|
||||
root: string,
|
||||
envName: string,
|
||||
caller: CallerMetadata | void,
|
||||
};
|
||||
|
||||
/**
|
||||
* Build a config chain for a given preset.
|
||||
*/
|
||||
export const buildPresetChain: (
|
||||
export function buildPresetChain(
|
||||
arg: PresetInstance,
|
||||
context: *,
|
||||
): ConfigChain | null {
|
||||
const chain = buildPresetChainWalker(arg, context);
|
||||
if (!chain) return null;
|
||||
|
||||
return {
|
||||
plugins: dedupDescriptors(chain.plugins),
|
||||
presets: dedupDescriptors(chain.presets),
|
||||
options: chain.options.map(o => normalizeOptions(o)),
|
||||
};
|
||||
}
|
||||
|
||||
export const buildPresetChainWalker: (
|
||||
arg: PresetInstance,
|
||||
context: *,
|
||||
) => * = makeChainWalker({
|
||||
@@ -128,12 +144,18 @@ export function buildRootChain(
|
||||
|
||||
let configFile;
|
||||
if (typeof opts.configFile === "string") {
|
||||
configFile = loadConfig(opts.configFile, context.cwd, context.envName);
|
||||
configFile = loadConfig(
|
||||
opts.configFile,
|
||||
context.cwd,
|
||||
context.envName,
|
||||
context.caller,
|
||||
);
|
||||
} else if (opts.configFile !== false) {
|
||||
configFile = findRootConfig(context.root, context.envName);
|
||||
configFile = findRootConfig(context.root, context.envName, context.caller);
|
||||
}
|
||||
|
||||
let { babelrc, babelrcRoots } = opts;
|
||||
let babelrcRootsDirectory = context.cwd;
|
||||
|
||||
const configFileChain = emptyChain();
|
||||
if (configFile) {
|
||||
@@ -147,6 +169,7 @@ export function buildRootChain(
|
||||
babelrc = validatedFile.options.babelrc;
|
||||
}
|
||||
if (babelrcRoots === undefined) {
|
||||
babelrcRootsDirectory = validatedFile.dirname;
|
||||
babelrcRoots = validatedFile.options.babelrcRoots;
|
||||
}
|
||||
|
||||
@@ -164,11 +187,12 @@ export function buildRootChain(
|
||||
if (
|
||||
(babelrc === true || babelrc === undefined) &&
|
||||
pkgData &&
|
||||
babelrcLoadEnabled(context, pkgData, babelrcRoots)
|
||||
babelrcLoadEnabled(context, pkgData, babelrcRoots, babelrcRootsDirectory)
|
||||
) {
|
||||
({ ignore: ignoreFile, config: babelrcFile } = findRelativeConfig(
|
||||
pkgData,
|
||||
context.envName,
|
||||
context.caller,
|
||||
));
|
||||
|
||||
if (
|
||||
@@ -207,6 +231,7 @@ function babelrcLoadEnabled(
|
||||
context: ConfigContext,
|
||||
pkgData: FilePackageData,
|
||||
babelrcRoots: BabelrcSearch | void,
|
||||
babelrcRootsDirectory: string,
|
||||
): boolean {
|
||||
if (typeof babelrcRoots === "boolean") return babelrcRoots;
|
||||
|
||||
@@ -221,7 +246,9 @@ function babelrcLoadEnabled(
|
||||
let babelrcPatterns = babelrcRoots;
|
||||
if (!Array.isArray(babelrcPatterns)) babelrcPatterns = [babelrcPatterns];
|
||||
babelrcPatterns = babelrcPatterns.map(pat => {
|
||||
return typeof pat === "string" ? path.resolve(context.cwd, pat) : pat;
|
||||
return typeof pat === "string"
|
||||
? path.resolve(babelrcRootsDirectory, pat)
|
||||
: pat;
|
||||
});
|
||||
|
||||
// Fast path to avoid having to match patterns if the babelrc is just
|
||||
@@ -231,10 +258,12 @@ function babelrcLoadEnabled(
|
||||
}
|
||||
|
||||
return babelrcPatterns.some(pat => {
|
||||
if (typeof pat === "string") pat = pathPatternToRegex(pat, context.cwd);
|
||||
if (typeof pat === "string") {
|
||||
pat = pathPatternToRegex(pat, babelrcRootsDirectory);
|
||||
}
|
||||
|
||||
return pkgData.directories.some(directory => {
|
||||
return matchPattern(pat, context.cwd, directory);
|
||||
return matchPattern(pat, babelrcRootsDirectory, directory, context);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -449,7 +478,12 @@ function mergeExtendsChain(
|
||||
): boolean {
|
||||
if (opts.extends === undefined) return true;
|
||||
|
||||
const file = loadConfig(opts.extends, dirname, context.envName);
|
||||
const file = loadConfig(
|
||||
opts.extends,
|
||||
dirname,
|
||||
context.envName,
|
||||
context.caller,
|
||||
);
|
||||
|
||||
if (files.has(file)) {
|
||||
throw new Error(
|
||||
@@ -515,7 +549,7 @@ function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
|
||||
|
||||
// "sourceMap" is just aliased to sourceMap, so copy it over as
|
||||
// we merge the options together.
|
||||
if (options.sourceMap) {
|
||||
if (options.hasOwnProperty("sourceMap")) {
|
||||
options.sourceMaps = options.sourceMap;
|
||||
delete options.sourceMap;
|
||||
}
|
||||
@@ -527,7 +561,7 @@ function dedupDescriptors(
|
||||
): Array<UnloadedDescriptor> {
|
||||
const map: Map<
|
||||
Function,
|
||||
Map<string | void, { value: UnloadedDescriptor | null }>,
|
||||
Map<string | void, { value: UnloadedDescriptor }>,
|
||||
> = new Map();
|
||||
|
||||
const descriptors = [];
|
||||
@@ -542,16 +576,12 @@ function dedupDescriptors(
|
||||
}
|
||||
let desc = nameMap.get(item.name);
|
||||
if (!desc) {
|
||||
desc = { value: null };
|
||||
desc = { value: item };
|
||||
descriptors.push(desc);
|
||||
|
||||
// Treat passPerPreset presets as unique, skipping them
|
||||
// in the merge processing steps.
|
||||
if (!item.ownPass) nameMap.set(item.name, desc);
|
||||
}
|
||||
|
||||
if (item.options === false) {
|
||||
desc.value = null;
|
||||
} else {
|
||||
desc.value = item;
|
||||
}
|
||||
@@ -561,7 +591,7 @@ function dedupDescriptors(
|
||||
}
|
||||
|
||||
return descriptors.reduce((acc, desc) => {
|
||||
if (desc.value) acc.push(desc.value);
|
||||
acc.push(desc.value);
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
@@ -633,12 +663,23 @@ function matchesPatterns(
|
||||
dirname: string,
|
||||
): boolean {
|
||||
return patterns.some(pattern =>
|
||||
matchPattern(pattern, dirname, context.filename),
|
||||
matchPattern(pattern, dirname, context.filename, context),
|
||||
);
|
||||
}
|
||||
|
||||
function matchPattern(pattern, dirname, pathToTest): boolean {
|
||||
if (typeof pattern === "function") return !!pattern(pathToTest);
|
||||
function matchPattern(
|
||||
pattern,
|
||||
dirname,
|
||||
pathToTest,
|
||||
context: ConfigContext,
|
||||
): boolean {
|
||||
if (typeof pattern === "function") {
|
||||
return !!pattern(pathToTest, {
|
||||
dirname,
|
||||
envName: context.envName,
|
||||
caller: context.caller,
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof pathToTest !== "string") {
|
||||
throw new Error(
|
||||
|
||||
@@ -41,6 +41,22 @@ export type UnloadedDescriptor = {
|
||||
} | void,
|
||||
};
|
||||
|
||||
function isEqualDescriptor(
|
||||
a: UnloadedDescriptor,
|
||||
b: UnloadedDescriptor,
|
||||
): boolean {
|
||||
return (
|
||||
a.name === b.name &&
|
||||
a.value === b.value &&
|
||||
a.options === b.options &&
|
||||
a.dirname === b.dirname &&
|
||||
a.alias === b.alias &&
|
||||
a.ownPass === b.ownPass &&
|
||||
(a.file && a.file.request) === (b.file && b.file.request) &&
|
||||
(a.file && a.file.resolved) === (b.file && b.file.resolved)
|
||||
);
|
||||
}
|
||||
|
||||
export type ValidatedFile = {
|
||||
filepath: string,
|
||||
dirname: string,
|
||||
@@ -50,7 +66,7 @@ export type ValidatedFile = {
|
||||
/**
|
||||
* Create a set of descriptors from a given options object, preserving
|
||||
* descriptor identity based on the identity of the plugin/preset arrays
|
||||
* themselves.
|
||||
* themselves, and potentially on the identity of the plugins/presets + options.
|
||||
*/
|
||||
export function createCachedDescriptors(
|
||||
dirname: string,
|
||||
@@ -113,26 +129,82 @@ export function createUncachedDescriptors(
|
||||
};
|
||||
}
|
||||
|
||||
const PRESET_DESCRIPTOR_CACHE = new WeakMap();
|
||||
const createCachedPresetDescriptors = makeWeakCache(
|
||||
(items: PluginList, cache: CacheConfigurator<string>) => {
|
||||
const dirname = cache.using(dir => dir);
|
||||
return makeStrongCache((alias: string) =>
|
||||
makeStrongCache((passPerPreset: boolean) =>
|
||||
createPresetDescriptors(items, dirname, alias, passPerPreset),
|
||||
createPresetDescriptors(items, dirname, alias, passPerPreset).map(
|
||||
// Items are cached using the overall preset array identity when
|
||||
// possibly, but individual descriptors are also cached if a match
|
||||
// can be found in the previously-used descriptor lists.
|
||||
desc => loadCachedDescriptor(PRESET_DESCRIPTOR_CACHE, desc),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
const PLUGIN_DESCRIPTOR_CACHE = new WeakMap();
|
||||
const createCachedPluginDescriptors = makeWeakCache(
|
||||
(items: PluginList, cache: CacheConfigurator<string>) => {
|
||||
const dirname = cache.using(dir => dir);
|
||||
return makeStrongCache((alias: string) =>
|
||||
createPluginDescriptors(items, dirname, alias),
|
||||
createPluginDescriptors(items, dirname, alias).map(
|
||||
// Items are cached using the overall plugin array identity when
|
||||
// possibly, but individual descriptors are also cached if a match
|
||||
// can be found in the previously-used descriptor lists.
|
||||
desc => loadCachedDescriptor(PLUGIN_DESCRIPTOR_CACHE, desc),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* When no options object is given in a descriptor, this object is used
|
||||
* as a WeakMap key in order to have consistent identity.
|
||||
*/
|
||||
const DEFAULT_OPTIONS = {};
|
||||
|
||||
/**
|
||||
* Given the cache and a descriptor, returns a matching descriptor from the
|
||||
* cache, or else returns the input descriptor and adds it to the cache for
|
||||
* next time.
|
||||
*/
|
||||
function loadCachedDescriptor(
|
||||
cache: WeakMap<{} | Function, WeakMap<{}, Array<UnloadedDescriptor>>>,
|
||||
desc: UnloadedDescriptor,
|
||||
) {
|
||||
const { value, options = DEFAULT_OPTIONS } = desc;
|
||||
if (options === false) return desc;
|
||||
|
||||
let cacheByOptions = cache.get(value);
|
||||
if (!cacheByOptions) {
|
||||
cacheByOptions = new WeakMap();
|
||||
cache.set(value, cacheByOptions);
|
||||
}
|
||||
|
||||
let possibilities = cacheByOptions.get(options);
|
||||
if (!possibilities) {
|
||||
possibilities = [];
|
||||
cacheByOptions.set(options, possibilities);
|
||||
}
|
||||
|
||||
if (possibilities.indexOf(desc) === -1) {
|
||||
const matches = possibilities.filter(possibility =>
|
||||
isEqualDescriptor(possibility, desc),
|
||||
);
|
||||
if (matches.length > 0) {
|
||||
return matches[0];
|
||||
}
|
||||
|
||||
possibilities.push(desc);
|
||||
}
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
function createPresetDescriptors(
|
||||
items: PluginList,
|
||||
dirname: string,
|
||||
|
||||
@@ -14,6 +14,7 @@ import makeAPI from "../helpers/config-api";
|
||||
import { makeStaticFileCache } from "./utils";
|
||||
import pathPatternToRegex from "../pattern-to-regex";
|
||||
import type { FilePackageData, RelativeConfig, ConfigFile } from "./types";
|
||||
import type { CallerMetadata } from "../validation/options";
|
||||
|
||||
const debug = buildDebug("babel:config:loading:files:configuration");
|
||||
|
||||
@@ -23,9 +24,25 @@ const BABELRC_FILENAME = ".babelrc";
|
||||
const BABELRC_JS_FILENAME = ".babelrc.js";
|
||||
const BABELIGNORE_FILENAME = ".babelignore";
|
||||
|
||||
export function findConfigUpwards(rootDir: string): string | null {
|
||||
let dirname = rootDir;
|
||||
while (true) {
|
||||
if (fs.existsSync(path.join(dirname, BABEL_CONFIG_JS_FILENAME))) {
|
||||
return dirname;
|
||||
}
|
||||
|
||||
const nextDir = path.dirname(dirname);
|
||||
if (dirname === nextDir) break;
|
||||
dirname = nextDir;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export function findRelativeConfig(
|
||||
packageData: FilePackageData,
|
||||
envName: string,
|
||||
caller: CallerMetadata | void,
|
||||
): RelativeConfig {
|
||||
let config = null;
|
||||
let ignore = null;
|
||||
@@ -37,7 +54,7 @@ export function findRelativeConfig(
|
||||
config = [BABELRC_FILENAME, BABELRC_JS_FILENAME].reduce(
|
||||
(previousConfig: ConfigFile | null, name) => {
|
||||
const filepath = path.join(loc, name);
|
||||
const config = readConfig(filepath, envName);
|
||||
const config = readConfig(filepath, envName, caller);
|
||||
|
||||
if (config && previousConfig) {
|
||||
throw new Error(
|
||||
@@ -91,10 +108,11 @@ export function findRelativeConfig(
|
||||
export function findRootConfig(
|
||||
dirname: string,
|
||||
envName: string,
|
||||
caller: CallerMetadata | void,
|
||||
): ConfigFile | null {
|
||||
const filepath = path.resolve(dirname, BABEL_CONFIG_JS_FILENAME);
|
||||
|
||||
const conf = readConfig(filepath, envName);
|
||||
const conf = readConfig(filepath, envName, caller);
|
||||
if (conf) {
|
||||
debug("Found root config %o in $o.", BABEL_CONFIG_JS_FILENAME, dirname);
|
||||
}
|
||||
@@ -105,10 +123,11 @@ export function loadConfig(
|
||||
name: string,
|
||||
dirname: string,
|
||||
envName: string,
|
||||
caller: CallerMetadata | void,
|
||||
): ConfigFile {
|
||||
const filepath = resolve.sync(name, { basedir: dirname });
|
||||
|
||||
const conf = readConfig(filepath, envName);
|
||||
const conf = readConfig(filepath, envName, caller);
|
||||
if (!conf) {
|
||||
throw new Error(`Config file ${filepath} contains no configuration data`);
|
||||
}
|
||||
@@ -121,16 +140,22 @@ export function loadConfig(
|
||||
* Read the given config file, returning the result. Returns null if no config was found, but will
|
||||
* throw if there are parsing errors while loading a config.
|
||||
*/
|
||||
function readConfig(filepath, envName): ConfigFile | null {
|
||||
function readConfig(filepath, envName, caller): ConfigFile | null {
|
||||
return path.extname(filepath) === ".js"
|
||||
? readConfigJS(filepath, { envName })
|
||||
? readConfigJS(filepath, { envName, caller })
|
||||
: readConfigJSON5(filepath);
|
||||
}
|
||||
|
||||
const LOADING_CONFIGS = new Set();
|
||||
|
||||
const readConfigJS = makeStrongCache(
|
||||
(filepath, cache: CacheConfigurator<{ envName: string }>) => {
|
||||
(
|
||||
filepath,
|
||||
cache: CacheConfigurator<{
|
||||
envName: string,
|
||||
caller: CallerMetadata | void,
|
||||
}>,
|
||||
) => {
|
||||
if (!fs.existsSync(filepath)) {
|
||||
cache.forever();
|
||||
return null;
|
||||
|
||||
@@ -7,8 +7,16 @@ import type {
|
||||
FilePackageData,
|
||||
} from "./types";
|
||||
|
||||
import type { CallerMetadata } from "../validation/options";
|
||||
|
||||
export type { ConfigFile, IgnoreFile, RelativeConfig, FilePackageData };
|
||||
|
||||
export function findConfigUpwards(
|
||||
rootDir: string, // eslint-disable-line no-unused-vars
|
||||
): string | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function findPackageData(filepath: string): FilePackageData {
|
||||
return {
|
||||
filepath,
|
||||
@@ -21,6 +29,7 @@ export function findPackageData(filepath: string): FilePackageData {
|
||||
export function findRelativeConfig(
|
||||
pkgData: FilePackageData, // eslint-disable-line no-unused-vars
|
||||
envName: string, // eslint-disable-line no-unused-vars
|
||||
caller: CallerMetadata | void, // eslint-disable-line no-unused-vars
|
||||
): RelativeConfig {
|
||||
return { pkg: null, config: null, ignore: null };
|
||||
}
|
||||
@@ -28,6 +37,7 @@ export function findRelativeConfig(
|
||||
export function findRootConfig(
|
||||
dirname: string, // eslint-disable-line no-unused-vars
|
||||
envName: string, // eslint-disable-line no-unused-vars
|
||||
caller: CallerMetadata | void, // eslint-disable-line no-unused-vars
|
||||
): ConfigFile | null {
|
||||
return null;
|
||||
}
|
||||
@@ -36,6 +46,7 @@ export function loadConfig(
|
||||
name: string,
|
||||
dirname: string,
|
||||
envName: string, // eslint-disable-line no-unused-vars
|
||||
caller: CallerMetadata | void, // eslint-disable-line no-unused-vars
|
||||
): ConfigFile {
|
||||
throw new Error(`Cannot load ${name} relative to ${dirname} in a browser`);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import typeof * as indexType from "./index";
|
||||
export { findPackageData } from "./package";
|
||||
|
||||
export {
|
||||
findConfigUpwards,
|
||||
findRelativeConfig,
|
||||
findRootConfig,
|
||||
loadConfig,
|
||||
|
||||
@@ -15,8 +15,8 @@ const BABEL_PLUGIN_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-plugin-)/;
|
||||
const BABEL_PRESET_PREFIX_RE = /^(?!@|module:|[^/]+\/|babel-preset-)/;
|
||||
const BABEL_PLUGIN_ORG_RE = /^(@babel\/)(?!plugin-|[^/]+\/)/;
|
||||
const BABEL_PRESET_ORG_RE = /^(@babel\/)(?!preset-|[^/]+\/)/;
|
||||
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?!babel-preset(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_PLUGIN_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-plugin(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_PRESET_ORG_RE = /^(@(?!babel\/)[^/]+\/)(?![^/]*babel-preset(?:-|\/|$)|[^/]+\/)/;
|
||||
const OTHER_ORG_DEFAULT_RE = /^(@(?!babel$)[^/]+)$/;
|
||||
|
||||
export function resolvePlugin(name: string, dirname: string): string | null {
|
||||
@@ -132,7 +132,7 @@ function resolveStandardizedName(
|
||||
} catch (e2) {}
|
||||
|
||||
if (resolvedOppositeType) {
|
||||
e.message += `\n- Did you accidentally pass a ${type} as a ${oppositeType}?`;
|
||||
e.message += `\n- Did you accidentally pass a ${oppositeType} as a ${type}?`;
|
||||
}
|
||||
|
||||
throw e;
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
import type { UnloadedDescriptor } from "./config-descriptors";
|
||||
import traverse from "@babel/traverse";
|
||||
import { makeWeakCache, type CacheConfigurator } from "./caching";
|
||||
import { validate } from "./validation/options";
|
||||
import { validate, type CallerMetadata } from "./validation/options";
|
||||
import { validatePluginObject } from "./validation/plugins";
|
||||
import makeAPI from "./helpers/config-api";
|
||||
|
||||
@@ -41,6 +41,7 @@ export type PluginPasses = Array<PluginPassList>;
|
||||
// process 'ignore'/'only' and other filename-based logic.
|
||||
type SimpleContext = {
|
||||
envName: string,
|
||||
caller: CallerMetadata | void,
|
||||
};
|
||||
|
||||
export default function loadFullConfig(
|
||||
@@ -68,15 +69,21 @@ export default function loadFullConfig(
|
||||
},
|
||||
pass: Array<Plugin>,
|
||||
) {
|
||||
const plugins = config.plugins.map(descriptor => {
|
||||
return loadPluginDescriptor(descriptor, context);
|
||||
});
|
||||
const presets = config.presets.map(descriptor => {
|
||||
return {
|
||||
preset: loadPresetDescriptor(descriptor, context),
|
||||
pass: descriptor.ownPass ? [] : pass,
|
||||
};
|
||||
});
|
||||
const plugins = config.plugins.reduce((acc, descriptor) => {
|
||||
if (descriptor.options !== false) {
|
||||
acc.push(loadPluginDescriptor(descriptor, context));
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
const presets = config.presets.reduce((acc, descriptor) => {
|
||||
if (descriptor.options !== false) {
|
||||
acc.push({
|
||||
preset: loadPresetDescriptor(descriptor, context),
|
||||
pass: descriptor.ownPass ? [] : pass,
|
||||
});
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
// resolve presets
|
||||
if (presets.length > 0) {
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
import semver from "semver";
|
||||
import { version as coreVersion } from "../../";
|
||||
import type { CacheConfigurator, SimpleCacheConfigurator } from "../caching";
|
||||
import {
|
||||
assertSimpleType,
|
||||
type CacheConfigurator,
|
||||
type SimpleCacheConfigurator,
|
||||
} from "../caching";
|
||||
|
||||
import type { CallerMetadata } from "../validation/options";
|
||||
|
||||
type EnvFunction = {
|
||||
(): string,
|
||||
@@ -20,12 +26,14 @@ export type PluginAPI = {
|
||||
};
|
||||
|
||||
export default function makeAPI(
|
||||
cache: CacheConfigurator<{ envName: string }>,
|
||||
cache: CacheConfigurator<{ envName: string, caller: CallerMetadata | void }>,
|
||||
): PluginAPI {
|
||||
const env: any = value =>
|
||||
cache.using(data => {
|
||||
if (typeof value === "undefined") return data.envName;
|
||||
if (typeof value === "function") return value(data.envName);
|
||||
if (typeof value === "function") {
|
||||
return assertSimpleType(value(data.envName));
|
||||
}
|
||||
if (!Array.isArray(value)) value = [value];
|
||||
|
||||
return value.some(entry => {
|
||||
@@ -36,13 +44,18 @@ export default function makeAPI(
|
||||
});
|
||||
});
|
||||
|
||||
const caller: any = cb =>
|
||||
cache.using(data => assertSimpleType(cb(data.caller)));
|
||||
|
||||
return {
|
||||
version: coreVersion,
|
||||
cache: cache.simple(),
|
||||
// Expose ".env()" so people can easily get the same env that we expose using the "env" key.
|
||||
env,
|
||||
async: () => false,
|
||||
caller,
|
||||
assertVersion,
|
||||
tokTypes: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -71,9 +71,11 @@ class ConfigItem {
|
||||
|
||||
/**
|
||||
* The options, if any, that were passed to the item.
|
||||
* Mutating this will lead to undefined behavior. If you need
|
||||
* Mutating this will lead to undefined behavior.
|
||||
*
|
||||
* "false" means that this item has been disabled.
|
||||
*/
|
||||
options: {} | void;
|
||||
options: {} | void | false;
|
||||
|
||||
/**
|
||||
* The directory that the options for this item are relative to.
|
||||
@@ -103,10 +105,6 @@ class ConfigItem {
|
||||
this._descriptor = descriptor;
|
||||
Object.defineProperty(this, "_descriptor", ({ enumerable: false }: any));
|
||||
|
||||
if (this._descriptor.options === false) {
|
||||
throw new Error("Assertion failure - unexpected false options");
|
||||
}
|
||||
|
||||
this.value = this._descriptor.value;
|
||||
this.options = this._descriptor.options;
|
||||
this.dirname = this._descriptor.dirname;
|
||||
|
||||
@@ -6,9 +6,43 @@ import { mergeOptions } from "./util";
|
||||
import { createItemFromDescriptor } from "./item";
|
||||
import { buildRootChain, type ConfigContext } from "./config-chain";
|
||||
import { getEnv } from "./helpers/environment";
|
||||
import { validate, type ValidatedOptions } from "./validation/options";
|
||||
import {
|
||||
validate,
|
||||
type ValidatedOptions,
|
||||
type RootMode,
|
||||
} from "./validation/options";
|
||||
|
||||
import type { ConfigFile, IgnoreFile } from "./files";
|
||||
import { findConfigUpwards, type ConfigFile, type IgnoreFile } from "./files";
|
||||
|
||||
function resolveRootMode(rootDir: string, rootMode: RootMode): string {
|
||||
switch (rootMode) {
|
||||
case "root":
|
||||
return rootDir;
|
||||
|
||||
case "upward-optional": {
|
||||
const upwardRootDir = findConfigUpwards(rootDir);
|
||||
return upwardRootDir === null ? rootDir : upwardRootDir;
|
||||
}
|
||||
|
||||
case "upward": {
|
||||
const upwardRootDir = findConfigUpwards(rootDir);
|
||||
if (upwardRootDir !== null) return upwardRootDir;
|
||||
|
||||
throw Object.assign(
|
||||
(new Error(
|
||||
`Babel was run with rootMode:"upward" but a root could not ` +
|
||||
`be found when searching upward from "${rootDir}"`,
|
||||
): any),
|
||||
{
|
||||
code: "BABEL_ROOT_NOT_FOUND",
|
||||
dirname: rootDir,
|
||||
},
|
||||
);
|
||||
}
|
||||
default:
|
||||
throw new Error(`Assertion failure - unknown rootMode value`);
|
||||
}
|
||||
}
|
||||
|
||||
export default function loadPrivatePartialConfig(
|
||||
inputOpts: mixed,
|
||||
@@ -28,9 +62,18 @@ export default function loadPrivatePartialConfig(
|
||||
|
||||
const args = inputOpts ? validate("arguments", inputOpts) : {};
|
||||
|
||||
const { envName = getEnv(), cwd = ".", root: rootDir = "." } = args;
|
||||
const {
|
||||
envName = getEnv(),
|
||||
cwd = ".",
|
||||
root: rootDir = ".",
|
||||
rootMode = "root",
|
||||
caller,
|
||||
} = args;
|
||||
const absoluteCwd = path.resolve(cwd);
|
||||
const absoluteRootDir = path.resolve(absoluteCwd, rootDir);
|
||||
const absoluteRootDir = resolveRootMode(
|
||||
path.resolve(absoluteCwd, rootDir),
|
||||
rootMode,
|
||||
);
|
||||
|
||||
const context: ConfigContext = {
|
||||
filename:
|
||||
@@ -40,6 +83,7 @@ export default function loadPrivatePartialConfig(
|
||||
cwd: absoluteCwd,
|
||||
root: absoluteRootDir,
|
||||
envName,
|
||||
caller,
|
||||
};
|
||||
|
||||
const configChain = buildRootChain(args, context);
|
||||
|
||||
@@ -13,16 +13,70 @@ import type {
|
||||
SourceTypeOption,
|
||||
CompactOption,
|
||||
RootInputSourceMapOption,
|
||||
NestingPath,
|
||||
CallerMetadata,
|
||||
RootMode,
|
||||
} from "./options";
|
||||
|
||||
export type ValidatorSet = {
|
||||
[string]: Validator<any>,
|
||||
};
|
||||
|
||||
export type Validator<T> = (string, mixed) => T;
|
||||
export type Validator<T> = (OptionPath, mixed) => T;
|
||||
|
||||
export function msg(loc: NestingPath | GeneralPath) {
|
||||
switch (loc.type) {
|
||||
case "root":
|
||||
return ``;
|
||||
case "env":
|
||||
return `${msg(loc.parent)}.env["${loc.name}"]`;
|
||||
case "overrides":
|
||||
return `${msg(loc.parent)}.overrides[${loc.index}]`;
|
||||
case "option":
|
||||
return `${msg(loc.parent)}.${loc.name}`;
|
||||
case "access":
|
||||
return `${msg(loc.parent)}[${JSON.stringify(loc.name)}]`;
|
||||
default:
|
||||
throw new Error(`Assertion failure: Unknown type ${loc.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function access(loc: GeneralPath, name: string | number): AccessPath {
|
||||
return {
|
||||
type: "access",
|
||||
name,
|
||||
parent: loc,
|
||||
};
|
||||
}
|
||||
|
||||
export type OptionPath = $ReadOnly<{
|
||||
type: "option",
|
||||
name: string,
|
||||
parent: NestingPath,
|
||||
}>;
|
||||
type AccessPath = $ReadOnly<{
|
||||
type: "access",
|
||||
name: string | number,
|
||||
parent: GeneralPath,
|
||||
}>;
|
||||
type GeneralPath = OptionPath | AccessPath;
|
||||
|
||||
export function assertRootMode(loc: OptionPath, value: mixed): RootMode | void {
|
||||
if (
|
||||
value !== undefined &&
|
||||
value !== "root" &&
|
||||
value !== "upward" &&
|
||||
value !== "upward-optional"
|
||||
) {
|
||||
throw new Error(
|
||||
`${msg(loc)} must be a "root", "upward", "upward-optional" or undefined`,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertSourceMaps(
|
||||
key: string,
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): SourceMapsOption | void {
|
||||
if (
|
||||
@@ -32,21 +86,24 @@ export function assertSourceMaps(
|
||||
value !== "both"
|
||||
) {
|
||||
throw new Error(
|
||||
`.${key} must be a boolean, "inline", "both", or undefined`,
|
||||
`${msg(loc)} must be a boolean, "inline", "both", or undefined`,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertCompact(key: string, value: mixed): CompactOption | void {
|
||||
export function assertCompact(
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): CompactOption | void {
|
||||
if (value !== undefined && typeof value !== "boolean" && value !== "auto") {
|
||||
throw new Error(`.${key} must be a boolean, "auto", or undefined`);
|
||||
throw new Error(`${msg(loc)} must be a boolean, "auto", or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertSourceType(
|
||||
key: string,
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): SourceTypeOption | void {
|
||||
if (
|
||||
@@ -56,14 +113,49 @@ export function assertSourceType(
|
||||
value !== "unambiguous"
|
||||
) {
|
||||
throw new Error(
|
||||
`.${key} must be "module", "script", "unambiguous", or undefined`,
|
||||
`${msg(loc)} must be "module", "script", "unambiguous", or undefined`,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertCallerMetadata(
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): CallerMetadata | void {
|
||||
const obj = assertObject(loc, value);
|
||||
if (obj) {
|
||||
if (typeof obj[("name": string)] !== "string") {
|
||||
throw new Error(
|
||||
`${msg(loc)} set but does not contain "name" property string`,
|
||||
);
|
||||
}
|
||||
|
||||
for (const prop of Object.keys(obj)) {
|
||||
const propLoc = access(loc, prop);
|
||||
const value = obj[prop];
|
||||
if (
|
||||
value != null &&
|
||||
typeof value !== "boolean" &&
|
||||
typeof value !== "string" &&
|
||||
typeof value !== "number"
|
||||
) {
|
||||
// NOTE(logan): I'm limiting the type here so that we can guarantee that
|
||||
// the "caller" value will serialize to JSON nicely. We can always
|
||||
// allow more complex structures later though.
|
||||
throw new Error(
|
||||
`${msg(
|
||||
propLoc,
|
||||
)} must be null, undefined, a boolean, a string, or a number.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (value: any);
|
||||
}
|
||||
|
||||
export function assertInputSourceMap(
|
||||
key: string,
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): RootInputSourceMapOption | void {
|
||||
if (
|
||||
@@ -71,75 +163,82 @@ export function assertInputSourceMap(
|
||||
typeof value !== "boolean" &&
|
||||
(typeof value !== "object" || !value)
|
||||
) {
|
||||
throw new Error(".inputSourceMap must be a boolean, object, or undefined");
|
||||
throw new Error(`${msg(loc)} must be a boolean, object, or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertString(key: string, value: mixed): string | void {
|
||||
export function assertString(loc: GeneralPath, value: mixed): string | void {
|
||||
if (value !== undefined && typeof value !== "string") {
|
||||
throw new Error(`.${key} must be a string, or undefined`);
|
||||
throw new Error(`${msg(loc)} must be a string, or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertFunction(key: string, value: mixed): Function | void {
|
||||
export function assertFunction(
|
||||
loc: GeneralPath,
|
||||
value: mixed,
|
||||
): Function | void {
|
||||
if (value !== undefined && typeof value !== "function") {
|
||||
throw new Error(`.${key} must be a function, or undefined`);
|
||||
throw new Error(`${msg(loc)} must be a function, or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertBoolean(key: string, value: mixed): boolean | void {
|
||||
export function assertBoolean(loc: GeneralPath, value: mixed): boolean | void {
|
||||
if (value !== undefined && typeof value !== "boolean") {
|
||||
throw new Error(`.${key} must be a boolean, or undefined`);
|
||||
throw new Error(`${msg(loc)} must be a boolean, or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertObject(key: string, value: mixed): {} | void {
|
||||
export function assertObject(loc: GeneralPath, value: mixed): {} | void {
|
||||
if (
|
||||
value !== undefined &&
|
||||
(typeof value !== "object" || Array.isArray(value) || !value)
|
||||
) {
|
||||
throw new Error(`.${key} must be an object, or undefined`);
|
||||
throw new Error(`${msg(loc)} must be an object, or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertArray(key: string, value: mixed): ?$ReadOnlyArray<mixed> {
|
||||
export function assertArray(
|
||||
loc: GeneralPath,
|
||||
value: mixed,
|
||||
): ?$ReadOnlyArray<mixed> {
|
||||
if (value != null && !Array.isArray(value)) {
|
||||
throw new Error(`.${key} must be an array, or undefined`);
|
||||
throw new Error(`${msg(loc)} must be an array, or undefined`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertIgnoreList(key: string, value: mixed): IgnoreList | void {
|
||||
const arr = assertArray(key, value);
|
||||
export function assertIgnoreList(
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): IgnoreList | void {
|
||||
const arr = assertArray(loc, value);
|
||||
if (arr) {
|
||||
arr.forEach((item, i) => assertIgnoreItem(key, i, item));
|
||||
arr.forEach((item, i) => assertIgnoreItem(access(loc, i), item));
|
||||
}
|
||||
return (arr: any);
|
||||
}
|
||||
function assertIgnoreItem(
|
||||
key: string,
|
||||
index: number,
|
||||
value: mixed,
|
||||
): IgnoreItem {
|
||||
function assertIgnoreItem(loc: GeneralPath, value: mixed): IgnoreItem {
|
||||
if (
|
||||
typeof value !== "string" &&
|
||||
typeof value !== "function" &&
|
||||
!(value instanceof RegExp)
|
||||
) {
|
||||
throw new Error(
|
||||
`.${key}[${index}] must be an array of string/Funtion/RegExp values, or undefined`,
|
||||
`${msg(
|
||||
loc,
|
||||
)} must be an array of string/Funtion/RegExp values, or undefined`,
|
||||
);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export function assertConfigApplicableTest(
|
||||
key: string,
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): ConfigApplicableTest | void {
|
||||
if (value === undefined) return value;
|
||||
@@ -147,12 +246,14 @@ export function assertConfigApplicableTest(
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((item, i) => {
|
||||
if (!checkValidTest(item)) {
|
||||
throw new Error(`.${key}[${i}] must be a string/Function/RegExp.`);
|
||||
throw new Error(
|
||||
`${msg(access(loc, i))} must be a string/Function/RegExp.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error(
|
||||
`.${key} must be a string/Function/RegExp, or an array of those`,
|
||||
`${msg(loc)} must be a string/Function/RegExp, or an array of those`,
|
||||
);
|
||||
}
|
||||
return (value: any);
|
||||
@@ -167,7 +268,7 @@ function checkValidTest(value: mixed): boolean {
|
||||
}
|
||||
|
||||
export function assertConfigFileSearch(
|
||||
key: string,
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): ConfigFileSearch | void {
|
||||
if (
|
||||
@@ -176,7 +277,7 @@ export function assertConfigFileSearch(
|
||||
typeof value !== "string"
|
||||
) {
|
||||
throw new Error(
|
||||
`.${key} must be a undefined, a boolean, a string, ` +
|
||||
`${msg(loc)} must be a undefined, a boolean, a string, ` +
|
||||
`got ${JSON.stringify(value)}`,
|
||||
);
|
||||
}
|
||||
@@ -185,52 +286,51 @@ export function assertConfigFileSearch(
|
||||
}
|
||||
|
||||
export function assertBabelrcSearch(
|
||||
key: string,
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): BabelrcSearch | void {
|
||||
if (value === undefined || typeof value === "boolean") return value;
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((item, i) => {
|
||||
if (!checkValidTest(value)) {
|
||||
throw new Error(`.${key}[${i}] must be a string/Function/RegExp.`);
|
||||
if (!checkValidTest(item)) {
|
||||
throw new Error(
|
||||
`${msg(access(loc, i))} must be a string/Function/RegExp.`,
|
||||
);
|
||||
}
|
||||
});
|
||||
} else if (!checkValidTest(value)) {
|
||||
throw new Error(
|
||||
`.${key} must be a undefined, a boolean, a string/Function/RegExp ` +
|
||||
`${msg(loc)} must be a undefined, a boolean, a string/Function/RegExp ` +
|
||||
`or an array of those, got ${JSON.stringify(value)}`,
|
||||
);
|
||||
}
|
||||
return (value: any);
|
||||
}
|
||||
|
||||
export function assertPluginList(key: string, value: mixed): PluginList | void {
|
||||
const arr = assertArray(key, value);
|
||||
export function assertPluginList(
|
||||
loc: OptionPath,
|
||||
value: mixed,
|
||||
): PluginList | void {
|
||||
const arr = assertArray(loc, value);
|
||||
if (arr) {
|
||||
// Loop instead of using `.map` in order to preserve object identity
|
||||
// for plugin array for use during config chain processing.
|
||||
arr.forEach((item, i) => assertPluginItem(key, i, item));
|
||||
arr.forEach((item, i) => assertPluginItem(access(loc, i), item));
|
||||
}
|
||||
return (arr: any);
|
||||
}
|
||||
function assertPluginItem(
|
||||
key: string,
|
||||
index: number,
|
||||
value: mixed,
|
||||
): PluginItem {
|
||||
function assertPluginItem(loc: GeneralPath, value: mixed): PluginItem {
|
||||
if (Array.isArray(value)) {
|
||||
if (value.length === 0) {
|
||||
throw new Error(`.${key}[${index}] must include an object`);
|
||||
throw new Error(`${msg(loc)} must include an object`);
|
||||
}
|
||||
|
||||
if (value.length > 3) {
|
||||
throw new Error(
|
||||
`.${key}[${index}] may only be a two-tuple or three-tuple`,
|
||||
);
|
||||
throw new Error(`${msg(loc)} may only be a two-tuple or three-tuple`);
|
||||
}
|
||||
|
||||
assertPluginTarget(key, index, true, value[0]);
|
||||
assertPluginTarget(access(loc, 0), value[0]);
|
||||
|
||||
if (value.length > 1) {
|
||||
const opts = value[1];
|
||||
@@ -240,38 +340,31 @@ function assertPluginItem(
|
||||
(typeof opts !== "object" || Array.isArray(opts))
|
||||
) {
|
||||
throw new Error(
|
||||
`.${key}[${index}][1] must be an object, false, or undefined`,
|
||||
`${msg(access(loc, 1))} must be an object, false, or undefined`,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (value.length === 3) {
|
||||
const name = value[2];
|
||||
if (name !== undefined && typeof name !== "string") {
|
||||
throw new Error(`.${key}[${index}][2] must be a string, or undefined`);
|
||||
throw new Error(
|
||||
`${msg(access(loc, 2))} must be a string, or undefined`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertPluginTarget(key, index, false, value);
|
||||
assertPluginTarget(loc, value);
|
||||
}
|
||||
|
||||
return (value: any);
|
||||
}
|
||||
function assertPluginTarget(
|
||||
key: string,
|
||||
index: number,
|
||||
inArray: boolean,
|
||||
value: mixed,
|
||||
): PluginTarget {
|
||||
function assertPluginTarget(loc: GeneralPath, value: mixed): PluginTarget {
|
||||
if (
|
||||
(typeof value !== "object" || !value) &&
|
||||
typeof value !== "string" &&
|
||||
typeof value !== "function"
|
||||
) {
|
||||
throw new Error(
|
||||
`.${key}[${index}]${
|
||||
inArray ? `[0]` : ""
|
||||
} must be a string, object, function`,
|
||||
);
|
||||
throw new Error(`${msg(loc)} must be a string, object, function`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,13 @@ import Plugin from "../plugin";
|
||||
|
||||
import removed from "./removed";
|
||||
import {
|
||||
msg,
|
||||
access,
|
||||
assertString,
|
||||
assertBoolean,
|
||||
assertObject,
|
||||
assertArray,
|
||||
assertCallerMetadata,
|
||||
assertInputSourceMap,
|
||||
assertIgnoreList,
|
||||
assertPluginList,
|
||||
@@ -16,20 +19,28 @@ import {
|
||||
assertConfigFileSearch,
|
||||
assertBabelrcSearch,
|
||||
assertFunction,
|
||||
assertRootMode,
|
||||
assertSourceMaps,
|
||||
assertCompact,
|
||||
assertSourceType,
|
||||
type ValidatorSet,
|
||||
type Validator,
|
||||
type OptionPath,
|
||||
} from "./option-assertions";
|
||||
|
||||
const ROOT_VALIDATORS: ValidatorSet = {
|
||||
cwd: (assertString: Validator<$PropertyType<ValidatedOptions, "cwd">>),
|
||||
root: (assertString: Validator<$PropertyType<ValidatedOptions, "root">>),
|
||||
rootMode: (assertRootMode: Validator<
|
||||
$PropertyType<ValidatedOptions, "rootMode">,
|
||||
>),
|
||||
configFile: (assertConfigFileSearch: Validator<
|
||||
$PropertyType<ValidatedOptions, "configFile">,
|
||||
>),
|
||||
|
||||
caller: (assertCallerMetadata: Validator<
|
||||
$PropertyType<ValidatedOptions, "caller">,
|
||||
>),
|
||||
filename: (assertString: Validator<
|
||||
$PropertyType<ValidatedOptions, "filename">,
|
||||
>),
|
||||
@@ -169,10 +180,12 @@ export type ValidatedOptions = {
|
||||
babelrcRoots?: BabelrcSearch,
|
||||
configFile?: ConfigFileSearch,
|
||||
root?: string,
|
||||
rootMode?: RootMode,
|
||||
code?: boolean,
|
||||
ast?: boolean,
|
||||
inputSourceMap?: RootInputSourceMapOption,
|
||||
envName?: string,
|
||||
caller?: CallerMetadata,
|
||||
|
||||
extends?: string,
|
||||
env?: EnvSet<ValidatedOptions>,
|
||||
@@ -222,6 +235,11 @@ export type ValidatedOptions = {
|
||||
generatorOpts?: {},
|
||||
};
|
||||
|
||||
export type CallerMetadata = {
|
||||
// If 'caller' is specified, require that the name is given for debugging
|
||||
// messages.
|
||||
name: string,
|
||||
};
|
||||
export type EnvSet<T> = {
|
||||
[string]: ?T,
|
||||
};
|
||||
@@ -247,25 +265,64 @@ export type SourceMapsOption = boolean | "inline" | "both";
|
||||
export type SourceTypeOption = "module" | "script" | "unambiguous";
|
||||
export type CompactOption = boolean | "auto";
|
||||
export type RootInputSourceMapOption = {} | boolean;
|
||||
export type RootMode = "root" | "upward" | "upward-optional";
|
||||
|
||||
export type OptionsType =
|
||||
export type OptionsSource =
|
||||
| "arguments"
|
||||
| "env"
|
||||
| "preset"
|
||||
| "override"
|
||||
| "configfile"
|
||||
| "babelrcfile"
|
||||
| "extendsfile";
|
||||
| "extendsfile"
|
||||
| "preset";
|
||||
|
||||
type RootPath = $ReadOnly<{
|
||||
type: "root",
|
||||
source: OptionsSource,
|
||||
}>;
|
||||
type OverridesPath = $ReadOnly<{
|
||||
type: "overrides",
|
||||
index: number,
|
||||
parent: RootPath,
|
||||
}>;
|
||||
type EnvPath = $ReadOnly<{
|
||||
type: "env",
|
||||
name: string,
|
||||
parent: RootPath | OverridesPath,
|
||||
}>;
|
||||
export type NestingPath = RootPath | OverridesPath | EnvPath;
|
||||
|
||||
function getSource(loc: NestingPath): OptionsSource {
|
||||
return loc.type === "root" ? loc.source : getSource(loc.parent);
|
||||
}
|
||||
|
||||
export function validate(type: OptionsSource, opts: {}): ValidatedOptions {
|
||||
return validateNested(
|
||||
{
|
||||
type: "root",
|
||||
source: type,
|
||||
},
|
||||
opts,
|
||||
);
|
||||
}
|
||||
|
||||
function validateNested(loc: NestingPath, opts: {}) {
|
||||
const type = getSource(loc);
|
||||
|
||||
export function validate(type: OptionsType, opts: {}): ValidatedOptions {
|
||||
assertNoDuplicateSourcemap(opts);
|
||||
|
||||
Object.keys(opts).forEach(key => {
|
||||
const optLoc = {
|
||||
type: "option",
|
||||
name: key,
|
||||
parent: loc,
|
||||
};
|
||||
|
||||
if (type === "preset" && NONPRESET_VALIDATORS[key]) {
|
||||
throw new Error(`.${key} is not allowed in preset options`);
|
||||
throw new Error(`${msg(optLoc)} is not allowed in preset options`);
|
||||
}
|
||||
if (type !== "arguments" && ROOT_VALIDATORS[key]) {
|
||||
throw new Error(`.${key} is only allowed in root programmatic options`);
|
||||
throw new Error(
|
||||
`${msg(optLoc)} is only allowed in root programmatic options`,
|
||||
);
|
||||
}
|
||||
if (
|
||||
type !== "arguments" &&
|
||||
@@ -274,48 +331,47 @@ export function validate(type: OptionsType, opts: {}): ValidatedOptions {
|
||||
) {
|
||||
if (type === "babelrcfile" || type === "extendsfile") {
|
||||
throw new Error(
|
||||
`.${key} is not allowed in .babelrc or "extend"ed files, only in root programmatic options, ` +
|
||||
`${msg(
|
||||
optLoc,
|
||||
)} is not allowed in .babelrc or "extends"ed files, only in root programmatic options, ` +
|
||||
`or babel.config.js/config file options`,
|
||||
);
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`.${key} is only allowed in root programmatic options, or babel.config.js/config file options`,
|
||||
`${msg(
|
||||
optLoc,
|
||||
)} is only allowed in root programmatic options, or babel.config.js/config file options`,
|
||||
);
|
||||
}
|
||||
if (type === "env" && key === "env") {
|
||||
throw new Error(`.${key} is not allowed inside another env block`);
|
||||
}
|
||||
if (type === "env" && key === "overrides") {
|
||||
throw new Error(`.${key} is not allowed inside an env block`);
|
||||
}
|
||||
if (type === "override" && key === "overrides") {
|
||||
throw new Error(`.${key} is not allowed inside an overrides block`);
|
||||
}
|
||||
|
||||
const validator =
|
||||
COMMON_VALIDATORS[key] ||
|
||||
NONPRESET_VALIDATORS[key] ||
|
||||
BABELRC_VALIDATORS[key] ||
|
||||
ROOT_VALIDATORS[key];
|
||||
ROOT_VALIDATORS[key] ||
|
||||
throwUnknownError;
|
||||
|
||||
if (validator) validator(key, opts[key]);
|
||||
else throw buildUnknownError(key);
|
||||
validator(optLoc, opts[key]);
|
||||
});
|
||||
|
||||
return (opts: any);
|
||||
}
|
||||
|
||||
function buildUnknownError(key: string) {
|
||||
function throwUnknownError(loc: OptionPath) {
|
||||
const key = loc.name;
|
||||
|
||||
if (removed[key]) {
|
||||
const { message, version = 5 } = removed[key];
|
||||
|
||||
throw new ReferenceError(
|
||||
`Using removed Babel ${version} option: .${key} - ${message}`,
|
||||
`Using removed Babel ${version} option: ${msg(loc)} - ${message}`,
|
||||
);
|
||||
} else {
|
||||
// eslint-disable-next-line max-len
|
||||
const unknownOptErr = `Unknown option: .${key}. Check out http://babeljs.io/docs/usage/options/ for more information about options.`;
|
||||
const unknownOptErr = `Unknown option: ${msg(
|
||||
loc,
|
||||
)}. Check out https://babeljs.io/docs/en/babel-core/#options for more information about options.`;
|
||||
|
||||
throw new ReferenceError(unknownOptErr);
|
||||
}
|
||||
@@ -331,27 +387,53 @@ function assertNoDuplicateSourcemap(opts: {}): void {
|
||||
}
|
||||
}
|
||||
|
||||
function assertEnvSet(key: string, value: mixed): EnvSet<ValidatedOptions> {
|
||||
const obj = assertObject(key, value);
|
||||
function assertEnvSet(loc: OptionPath, value: mixed): EnvSet<ValidatedOptions> {
|
||||
if (loc.parent.type === "env") {
|
||||
throw new Error(`${msg(loc)} is not allowed inside of another .env block`);
|
||||
}
|
||||
const parent: RootPath | OverridesPath = loc.parent;
|
||||
|
||||
const obj = assertObject(loc, value);
|
||||
if (obj) {
|
||||
// Validate but don't copy the .env object in order to preserve
|
||||
// object identity for use during config chain processing.
|
||||
for (const key of Object.keys(obj)) {
|
||||
const env = assertObject(key, obj[key]);
|
||||
if (env) validate("env", env);
|
||||
for (const envName of Object.keys(obj)) {
|
||||
const env = assertObject(access(loc, envName), obj[envName]);
|
||||
if (!env) continue;
|
||||
|
||||
const envLoc = {
|
||||
type: "env",
|
||||
name: envName,
|
||||
parent,
|
||||
};
|
||||
validateNested(envLoc, env);
|
||||
}
|
||||
}
|
||||
return (obj: any);
|
||||
}
|
||||
|
||||
function assertOverridesList(key: string, value: mixed): OverridesList {
|
||||
const arr = assertArray(key, value);
|
||||
function assertOverridesList(loc: OptionPath, value: mixed): OverridesList {
|
||||
if (loc.parent.type === "env") {
|
||||
throw new Error(`${msg(loc)} is not allowed inside an .env block`);
|
||||
}
|
||||
if (loc.parent.type === "overrides") {
|
||||
throw new Error(`${msg(loc)} is not allowed inside an .overrides block`);
|
||||
}
|
||||
const parent: RootPath = loc.parent;
|
||||
|
||||
const arr = assertArray(loc, value);
|
||||
if (arr) {
|
||||
for (const [index, item] of arr.entries()) {
|
||||
const env = assertObject(`${index}`, item);
|
||||
if (!env) throw new Error(`.${key}[${index}] must be an object`);
|
||||
const objLoc = access(loc, index);
|
||||
const env = assertObject(objLoc, item);
|
||||
if (!env) throw new Error(`${msg(objLoc)} must be an object`);
|
||||
|
||||
validate("override", env);
|
||||
const overridesLoc = {
|
||||
type: "overrides",
|
||||
index,
|
||||
parent,
|
||||
};
|
||||
validateNested(overridesLoc, env);
|
||||
}
|
||||
}
|
||||
return (arr: any);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user