Compare commits

...

112 Commits

Author SHA1 Message Date
Henry Zhu
a7c9264c79 v7.0.0-beta.34 2017-12-02 09:38:52 -05:00
Raja Sekar
c41eb0d052 Do Expression from Stage 0 to Stage 1 (#6943) 2017-12-02 09:02:31 -05:00
Daniel Tschinder
de5ab72c49 Update flow to 0.59 and fix some flow issues (#6957) 2017-12-02 08:59:46 -05:00
Henry Zhu
607916880d update to beta.33 (#6948)
* update to beta.33

* typeof is excluded by default in loose mode
2017-12-02 08:59:08 -05:00
Daniel Tschinder
8270903ba2 Refactor @babel/types to be 100% ES-module (#6741)
This generates the dynamic functions at buildtime and also
splits the package into smaller files to avoid dependency circles.
2017-12-02 12:20:10 +01:00
Brian Ng
95fe785354 Fix stage refs to exportNamespaceFrom and exportDefaultFrom (#6949) 2017-12-01 12:29:51 -05:00
Henry Zhu
413aa79711 v7.0.0-beta.33 2017-12-01 09:27:57 -05:00
Henry Zhu
1a3a502f97 Remove some built files before publish [skip ci] (#6946) 2017-12-01 09:25:27 -05:00
Henry Zhu
5761eb0bb4 add readme entry for for-of assumeArray, use it (#6942) 2017-11-30 17:40:23 -06:00
Raja Sekar
a992d06c41 Porting babel-plugin-transform-for-of-as-array into transform-for-of as an option (#6914) 2017-11-30 17:48:56 -05:00
Brian Ng
d8bbaaae0a Split exportExtensions into exportDefault and exportNamespace plugins… (#6920)
* Split exportExtensions into two plugins in babylon
* rename proposal-export-default to proposal-export-default-from
* rename proposal-export-namespace to proposal-export-namespace-from
2017-11-30 17:46:36 -05:00
Daniel Tschinder
9d9710c765 Copy getters and setters correctly in interopWildcard (#6850) 2017-11-30 15:50:10 -06:00
Sam Gluck
18b91a8388 [plugin-proposal-class-properties] Fix small loose docs typo (#6941) 2017-11-30 15:09:36 -06:00
Artem Yavorsky
0a2a37c31f Fix export from assignment order for loose mode. (#6863)
* Consider reexports for bindingKindLookup.

* Update test cases according to reexports change

* Fix order for assign reexports.

* void 0 assignation to module keys only for loose mode.

* Create buildReexportsFromMeta helper.

* Update umd/amd fixtures.

* Refactor reexports build.

* Hoist template for reexports.

* Use map as a second argument of Array.from.

* Remove unnecessary export.
2017-11-29 11:58:29 -08:00
Boda
d731acc351 updated Unpkg link (#6929)
...to be the same as the link in the Installation section
2017-11-29 11:41:13 -05:00
Logan Smyth
fba19295b4 Merge pull request #6905 from loganfsmyth/config-options-merge
Merge all config & programmatic plugins/preset rather than duplicating
2017-11-28 13:46:36 -08:00
Logan Smyth
8fc8a1f2ee Use public options API for tests. 2017-11-28 13:25:10 -08:00
Nicolò Ribaudo
18c8d97c3d UpdateExpressions as callees must be parenthesized (#6922) 2017-11-27 23:31:24 +01:00
Henry Zhu
58962c35b5 update regenerator (removed explicit babel-types dep) (#6917) 2017-11-27 23:16:41 +01:00
Brian Ng
881fc14329 Add handling parens for extends clause in generator (#6897) 2017-11-27 12:08:35 -06:00
Daniel Lo Nigro
7d8932b6be Add comment to babel-standalone to dissuade removal of whitelist (#6910)
There was a good discussion on https://github.com/babel/babel/pull/6177. Linking to it in the code to preserve the comments.
2017-11-27 10:08:28 -08:00
Mauro Bringolf
6330a152ce Implement TDZ for ClassFieldDefinitionEvaluation (#6855)
* First implementation sketch and testcase

* Use helper instead of inline IIFE's

* minNodeVersion 6.0.0

* Hoisted visitor for subtraversal and fixed edgest case

* Resolve merge conflicts in helpers

* Remove duplicated helper from messing up Git
2017-11-26 16:56:04 +01:00
Logan Smyth
189c56628a Replace repeated plugins/preset in top-level config instead of running both. 2017-11-25 18:47:13 -08:00
Logan Smyth
8be488652f Allow plugins and presets to have explicit names. 2017-11-25 18:46:00 -08:00
Logan Smyth
cdf420d4d8 Rewrite config chain tests to use public loadOptions API. (#6909) 2017-11-25 18:25:20 -08:00
Nicolas Marien
cf62908bbd Keep user options intact in transformFile (#6890)
* Preserve user options in transformFile

* Improve tests for transformFile user opts handling
2017-11-25 10:13:56 -08:00
Logan Smyth
66ee192a7f Merge pull request #6904 from loganfsmyth/config-merge-prep
Add a 'cwd' option, and misc refactoring and tweaks before simple config merging
2017-11-24 22:54:40 -08:00
Logan Smyth
c635ff9c32 Remove duplicate from plugin list. 2017-11-24 19:45:15 -08:00
Logan Smyth
6cb9d20a0a Tie presets pass metadata to descriptors. 2017-11-24 19:45:15 -08:00
Logan Smyth
b5cb78d33a Move plugin pass initialization logic a bit. 2017-11-24 19:45:15 -08:00
Logan Smyth
1d0a3d6772 Remove duplicated assertion. Covered by validate() 2017-11-24 19:45:14 -08:00
Logan Smyth
18ea5aca51 Expose a 'cwd' option for Babel's root options. 2017-11-24 19:43:25 -08:00
Logan Smyth
db28c18458 Disallow nested '.env' blocks since they are useless. 2017-11-24 17:45:27 -08:00
Logan Smyth
a89171910f Merge pull request #6834 from loganfsmyth/caching-refactor
Expose `envName` as a top-level Babel option to avoid using environmental variables
2017-11-24 17:42:16 -08:00
Mark Shulhin
0056fb1cfb Fixed ignore in readme for babel-register [skip ci] (#6899) 2017-11-24 17:45:49 -05:00
Sven SAULEAU
041dd4a536 Merge pull request #6893 from Arfey/features/updated-gitignore-file
feat: updated .gitignore file
2017-11-24 20:13:37 +01:00
misha.gavela
428e294ded Merge branch 'master' of https://github.com/babel/babel into features/updated-gitignore-file 2017-11-24 19:21:30 +02:00
Brian Ng
0a3c2a0c4c Fix babylon test 2017-11-24 09:15:17 -06:00
misha.gavela
917e3ede31 feat: updated .gitignore file 2017-11-24 15:18:13 +02:00
Martin McKeaveney
6d820a2757 removing expression field from ArrowFunctionExpression (#6836) 2017-11-23 22:12:13 +01:00
Mateusz Burzyński
1ef7e0f48e Allowed hintedNames for namespaced imports, changed some other defaults for more readable ones (#6744) 2017-11-23 21:01:47 +01:00
Daniel Tschinder
9206df964d Use only imports in babel-traverse and remove double exports (#6881) 2017-11-23 20:59:54 +01:00
Brian Ng
c583a04a55 Fix setting deopt properly after evaluating multiple expressions (#6882) 2017-11-22 20:06:57 -05:00
Gidi Meir Morris
edbf5d33dc Fix "Better error messaging for unexpected tokens #6715" (#6875) 2017-11-22 15:31:03 -06:00
Brian Ng
8393a6d089 Add firefox 58 mappings to preset-env data (#6874) 2017-11-22 15:30:07 -06:00
Nicolò Ribaudo
464df13c69 Allow yielding an arrow function withour parens around the param (#6877) 2017-11-22 15:28:37 -06:00
Logan Smyth
80b4b7120b Quick fix for typescript import crash. (#6879) 2017-11-22 13:27:31 -08:00
Brian Ng
ccd7c25174 Regen babel-types docsdocs and interfaces [skip ci] 2017-11-22 08:53:16 -06:00
Sven SAULEAU
4384d38b90 Merge pull request #6862 from maurobringolf/const-violation-helper
Define readOnlyError helper and use in check-constants plugin
2017-11-22 12:18:52 +01:00
Yifeng Wang
3fae022320 Update CONTRIBUTING.md (#6868) 2017-11-22 10:47:06 +01:00
Henry Zhu
70361f1200 Remove the experimental folder 2017-11-21 20:03:16 -05:00
Artem Yavorsky
d72d567d43 Merge pull request #6866 from aaharu/reduce-preset-env-pkg-size
Add `.github` and `.idea` to `.npmignore` for babel-preset-env.
2017-11-21 21:06:52 +02:00
aaharu
4a455639e7 Add .github and .idea to .npmignore 2017-11-22 02:22:55 +09:00
Mauro Bringolf
ba441c5ce4 Define readOnlyError helper and use in check-constants plugin 2017-11-20 16:41:15 +01:00
Daniel Tschinder
7064b298d7 Make SpreadProperty and RestProperty a deprecatedAlias (#6853)
instead of hardcoding backwards compatiblity.
This way we get deprecation warnings and also builders will work.
2017-11-18 21:54:24 +01:00
Daniel Tschinder
f3004d0d4d Fix validation of WithStatement and enable flow in definitions (#6852)
Fixes also flow errors after activating flow
2017-11-18 18:17:31 +01:00
Vincent Chan
037b2025a6 description about building and testing babylon in CONTRIBUTING.md (#6756)
developers maybe confuse about the steps of building and testings in the mono project
2017-11-18 12:57:58 +01:00
Darío Hereñú
7d534dc32c Minor fix (styling) (#6849) [skip ci] 2017-11-18 06:51:44 +01:00
Anatoli Papirovski
2b710d0387 Do not access out of bounds arguments (#6792)
Potentially out of bounds arguments should not just be directly
accessed, instead use a ternary operator to check length.
2017-11-17 21:39:08 +01:00
Kevin Ji
e67cfc5b31 README: Use HTTPS and relative links when possible [skip ci] (#6843) 2017-11-17 10:34:44 -05:00
Sven SAULEAU
4552ee9962 Merge pull request #6844 from nicolo-ribaudo/babyon-watch
Add "make watch-babylon" [skip ci]
2017-11-17 14:16:32 +01:00
Nicolò Ribaudo
3c64554716 Add "make watch-babylon" [skip ci] 2017-11-17 09:50:46 +01:00
Steven Hargrove
cee9ae48e0 [skip ci] removed shorthand usage of official babel scoped presets & plugins from README.md's (#6820) 2017-11-16 22:51:23 -05:00
Logan Smyth
39dae28d5c Add missing argument and remove nonexistent one. (#6842) 2017-11-16 16:32:47 -08:00
Valerii Iatsko
16e898c692 @babel/cli: removed babel-node mention in README.md [skip ci] (#6829)
Follow up to 2374062bbd
2017-11-16 18:04:10 +01:00
Sven SAULEAU
bb89364813 Merge pull request #6727 from babel/feat-use-charcode-constants
[Babylon] Use char codes contants
2017-11-16 10:35:42 +01:00
Sven SAULEAU
57e2c45cbe chore: upgrade charcode 2017-11-16 09:57:20 +01:00
Raja Sekar
63397d0aad Better error message for super when not using an object method (#6754) 2017-11-15 21:29:46 -06:00
Artem Yavorsky
48906604f2 Add safari technology preview for babel-preset-env. (#6791) 2017-11-15 17:14:54 -06:00
Brian Ng
0f2ab2fe20 Fix some reserved type handling and declare class with multiple extends (#6725) 2017-11-15 16:16:15 -06:00
Artem Yavorsky
de3597983a [preset-env] Exclude transform-typeof-symbol with loose option. (#6831) 2017-11-15 14:13:59 -06:00
Logan Smyth
aa2d415507 Expose the envName as a programmatic and CLI option. 2017-11-15 11:24:39 -08:00
Sven SAULEAU
4c584ae341 chore: upgrade and fix charcodes 2017-11-15 19:53:30 +01:00
Logan Smyth
74439889d8 Centralize envName lookup using caching sidechannel. 2017-11-15 10:05:48 -08:00
Logan Smyth
74ea70718e Allow passing an cachable 'sidechannel' object into cache handlers. 2017-11-15 10:05:47 -08:00
Logan Smyth
bbff566024 Use expanded caching API to simplify usage. 2017-11-15 09:51:13 -08:00
Logan Smyth
3942862a2a Expose more caching flexibility for Babel's internal use. 2017-11-15 09:51:12 -08:00
Brian Ng
f3fd2ee3b2 Maintain plugin order with items in the include option (#6663) 2017-11-15 10:45:16 -06:00
Marcio Junior
6a19c2299a docs: [skip-ci] Remove @babel scope from babel-preset-env include/exc… (#6825) 2017-11-15 10:25:21 -06:00
Brian Ng
6371200215 Fix preset-env test 2017-11-15 10:07:04 -06:00
Brian Ng
47d5f0c20c Update dep versions inside preset-env-standalone 2017-11-15 09:54:03 -06:00
Artem Yavorsky
262d7518bd Move babel-preset-env-standalone to the monorepo. (#6438) 2017-11-15 09:50:36 -06:00
Brian Ng
287b485d0e Fix bug in preset-env usage plugin with destructure in for-of (#6662) 2017-11-15 09:45:54 -06:00
Nicolò Ribaudo
9ae23639ad Parse async arrows with flow type parameters (#6802)
Fixes #6712
2017-11-14 16:24:14 +01:00
Brian Ng
3c359698a7 Remove unneeded .eslintrc files (#6815) [skip ci] 2017-11-13 18:12:26 -05:00
Artem Yavorsky
056a995dd8 Fix shadow variables reassignment for block scoping in loops. (#6814) 2017-11-14 00:06:32 +01:00
Henry Zhu
84fe8e4181 use pr instead of tag for changelog/prs [skip ci] (#6819) 2017-11-13 16:08:08 -05:00
Logan Smyth
e44cef3473 Merge pull request #6818 from loganfsmyth/async-warnings
Add some nice warnings if plugins happen to return promises instead of sync values.
2017-11-13 12:42:58 -08:00
Logan Smyth
44c2791849 Expose a function for plugins to check if async plugins are supported by the current compilation. 2017-11-13 11:58:31 -08:00
Logan Smyth
0e88156d0c Add warnings to places where we might allow promises to be returned in later minors. 2017-11-13 11:58:30 -08:00
Henry Zhu
394ad93d22 Update to v7-beta.31 (#6804) 2017-11-13 10:50:29 -05:00
Sven SAULEAU
82a4919c11 Merge pull request #6803 from satya164/async-to-generator-pure
Add /*#__PURE__*/ annotatiotion for babel-plugin-async-to-generator
2017-11-13 16:31:37 +01:00
Sven SAULEAU
186f04a3e9 feat: use charcodes in JSX plugin 2017-11-13 13:15:32 +01:00
Sven SAULEAU
42c740ca0a Merge branch 'master' into async-to-generator-pure 2017-11-13 11:49:16 +01:00
Satyajit Sahoo
7ae6e1e5a0 Add /*#__PURE__*/ annotatiotion for babel-plugin-async-to-generator. Fixes #6572 2017-11-12 18:31:48 +05:30
Sven SAULEAU
097ff40001 feat: more charCodes 2017-11-11 18:08:43 +01:00
Sven SAULEAU
b79e3c0e99 fix: minor changes 2017-11-09 18:07:10 +01:00
Sven SAULEAU
88c1b4ef1c feat: more charcodes 2017-11-09 17:13:36 +01:00
Sven SAULEAU
6b417a8ecb chore: bump charcode plugin 2017-11-08 16:56:25 +01:00
Sven SAULEAU
cd8a869a18 fix: remove unwanted change 2017-11-08 13:20:11 +01:00
Sven SAULEAU
f3f005c67e feat: use charcode AOT transform 2017-11-07 19:16:04 +01:00
Sven SAULEAU
7dfa79f4c8 Merge branch 'master' into feat-use-charcode-constants 2017-11-07 18:09:52 +01:00
Sven SAULEAU
3e34162092 chore: bump charcode 2017-11-07 18:07:38 +01:00
Sven SAULEAU
b93800d3cb fix: use charcode package 2017-11-03 09:52:45 +01:00
Sven SAULEAU
233e60c765 Merge branch 'master' into feat-use-charcode-constants 2017-11-03 08:52:54 +01:00
Sven SAULEAU
72a90cb63d feat: more charcodes 2017-11-03 08:51:48 +01:00
Sven SAULEAU
b51ac5e60a feat: sort by value
Vim 🖤
2017-11-03 08:27:03 +01:00
Sven SAULEAU
8b206b2c3b feat: generate charCodes
Vim 🖤
2017-11-02 20:13:44 +01:00
Sven SAULEAU
a2ed843636 feat: add more charCodes 2017-11-02 18:14:29 +01:00
Sven SAULEAU
b95810f4b4 refactor: switch to individual exports 2017-11-02 17:57:58 +01:00
Sven SAULEAU
abb4850709 refactor: use charCodes 2017-11-02 16:40:08 +01:00
Sven SAULEAU
459e289d63 feat: setup constants 2017-11-02 09:10:26 +01:00
1872 changed files with 12184 additions and 7349 deletions

View File

@@ -2,3 +2,4 @@
packages/*/test/fixtures
packages/*/lib
packages/babel-standalone/babel.js
packages/babel-preset-env-standalone/babel-preset-env.js

View File

@@ -32,7 +32,6 @@ function istanbulHacks() {
let envOpts = {
loose: true,
exclude: ["transform-typeof-symbol"],
};
const config = {
@@ -43,9 +42,9 @@ const config = {
],
plugins: [
["@babel/proposal-class-properties", { loose: true }],
"@babel/proposal-export-namespace",
"@babel/proposal-export-namespace-from",
"@babel/proposal-numeric-separator",
["@babel/proposal-object-rest-spread", { useBuiltIns: true}],
["@babel/proposal-object-rest-spread", { useBuiltIns: true }],
]
};

View File

@@ -12,12 +12,10 @@ codemods/*/lib
codemods/*/dist
codemods/*/test/fixtures
codemods/*/test/tmp
experimental/*/lib
experimental/*/node_modules
experimental/*/test/fixtures
experimental/*/test/tmp
experimental/babel-preset-env/data
experimental/babel-preset-env/test/debug-fixtures
packages/babel-preset-env/data
packages/babel-preset-env/test/debug-fixtures
packages/babel-preset-env-standalone/babel-preset-env.js
packages/babel-preset-env-standalone/babel-preset-env.min.js
packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js
packages/babylon/build

View File

@@ -15,7 +15,6 @@
{
"files": [
"packages/*/src/**/*.js",
"experimental/*/src/**/*.js",
"codemods/*/src/**/*.js"
],
"rules": {
@@ -23,7 +22,11 @@
}
},
{
"files": [ "packages/*/test/**/*.js", "test/**/*.js" ],
"files": [
"packages/*/test/**/*.js",
"codemods/*/test/**/*.js",
"test/**/*.js"
],
"env": {
"mocha": true
}

View File

@@ -4,14 +4,11 @@
.*/packages/.*/test
.*/codemods/.*/lib
.*/codemods/.*/test
.*/experimental/.*/lib
.*/experimental/.*/test
.*/node_modules/conventional-changelog-core/
[include]
packages/*/src
codemods/*/src
experimental/*/src
[libs]
lib/file.js
@@ -20,6 +17,7 @@ lib/types.js
lib/third-party-libs.js.flow
[options]
include_warnings=true
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
suppress_comment= \\(.\\|\n\\)*\\$FlowIssue
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore

3
.gitignore vendored
View File

@@ -34,6 +34,9 @@ package-lock.json
/babel.sublime-workspace
packages/babel-standalone/babel.js
packages/babel-standalone/babel.min.js
packages/babel-preset-env-standalone/babel-preset-env.js
packages/babel-preset-env-standalone/babel-preset-env.min.js
/codemods/*/lib
/codemods/*/node_modules
/packages/babylon/build
.idea/

View File

@@ -2,8 +2,6 @@
"trailingComma": "es5",
"overrides": [{
"files": [
"**/experimental/*/src/**/*.js",
"**/experimental/*/test/**/*.js",
"**/codemods/*/src/**/*.js",
"**/codemods/*/test/**/*.js",
"**/packages/*/src/**/*.js",

View File

@@ -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/tree/master/packages/babylon/blob/master/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/babylon#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/babylon/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/babylon#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
@@ -115,7 +115,7 @@ $ TEST_ONLY=babel-cli make test
`TEST_ONLY` will also match substrings of the package name:
```sh
# Run tests for the babel-plugin-transform-classes package.
# Run tests for the @babel/plugin-transform-classes package.
$ TEST_ONLY=es2015-class make test
```
@@ -161,16 +161,16 @@ In case you're locally getting errors which are not on the CI, it may be due to
Most packages in [`/packages`](https://github.com/babel/babel/tree/master/packages) have a `test` folder, however some tests might be in other packages or in [`/packages/babel-core`](https://github.com/babel/babel/tree/master/packages/babel-core/test/fixtures).
#### `babel-plugin-x`
#### `@babel/plugin-x`
All the Babel plugins (and other packages) that have a `/test/fixtures` are written in a similar way.
For example, in [`babel-plugin-transform-exponentiation-operator/test`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test):
For example, in [`@babel/plugin-transform-exponentiation-operator/test`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test):
- There is an `index.js` file. It imports our [test helper](https://github.com/babel/babel/tree/master/packages/babel-helper-plugin-test-runner). (You don't have to worry about this).
- There can be multiple folders under [`/fixtures`](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures)
- There is an [`options.json`](https://github.com/babel/babel/blob/master/packages/babel-plugin-transform-exponentiation-operator/test/fixtures/exponentian-operator/options.json) file whose function is similar to a `.babelrc` file, allowing you to pass in the plugins and settings you need for your tests.
- For this test, we only need the relevant plugin, so it's just `{ "plugins": ["@babel/transform-exponentiation-operator"] }`.
- For this test, we only need the relevant plugin, so it's just `{ "plugins": ["@babel/plugin-transform-exponentiation-operator"] }`.
- If necessary, you can have an `options.json` with different options in each subfolder.
- In each subfolder, you can organize your directory structure by categories of tests. (Example: these folders can be named after the feature you are testing or can reference the issue number they fix)
@@ -205,8 +205,8 @@ If you need to check for an error that is thrown you can add to the `options.jso
```js
// options.json example
{
"plugins": [["@babel/proposal-object-rest-spread", { "useBuiltIns": "invalidOption" }]],
"throws": "@babel/proposal-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)"
"plugins": [["@babel/plugin-proposal-object-rest-spread", { "useBuiltIns": "invalidOption" }]],
"throws": "@babel/plugin-proposal-object-rest-spread currently only accepts a boolean option for useBuiltIns (defaults to false)"
}
```
@@ -231,9 +231,21 @@ descriptive name, and add the following:
* Add an `expected.json` file with the expected parser output. For added convenience, if there is no `expected.json` present, the test runner will generate one for you.
After writing tests for babylon, just build it by running:
```sh
$ make build-babylon
```
Then, to run the tests, use:
```sh
$ TEST_ONLY=babylon make test-only
```
#### Bootstrapping expected output
For both `babel-plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
For both `@babel/plugin-x` and `babylon`, you can easily generate an `expected.js`/`expected.json` automatically by just providing `actual.js` and running the tests as you usually would.
```
// Example
@@ -267,7 +279,7 @@ To include the changes, we have to make sure to build Babel:
$ make build
```
Next, we need to execute `Generator.generate()`, which can be achieved by running a test case in the `babel-generator` package.
Next, we need to execute `Generator.generate()`, which can be achieved by running a test case in the `@babel/generator` package.
For example, we can run the test case that tests the generation of class declarations:
```bash
@@ -275,7 +287,6 @@ $ TEST_DEBUG=true TEST_GREP=ClassDeclaration make test-only
./scripts/test.sh
Debugger listening on port 9229.
Warning: This is an experimental feature and could change at any time.
To start debugging, open the following URL in Chrome:
chrome-devtools://devtools/remote/serve_file/@60cd6e859b9f557d2312f5bf532f6aec5f284980/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/3cdaebd2-be88-4e7b-a94b-432950ab72d0
```
@@ -299,7 +310,7 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe
## Internals
- AST spec ([babylon/ast/spec.md](https://github.com/babel/babel/tree/master/packages/babylon/blob/master/ast/spec.md))
- Versioning ([doc/design/versioning.md](https://github.com/babel/babel/blob/master/doc/design/versioning.md)
- Versioning ([doc/design/versioning.md](https://github.com/babel/babel/blob/master/doc/design/versioning.md))
- Monorepo ([doc/design/monorepo.md](https://github.com/babel/babel/blob/master/doc/design/monorepo.md))
- Compiler environment support ([doc/design/compiler-environment-support.md](https://github.com/babel/babel/blob/master/doc/design/compiler-environment-support.md))
- Compiler assumptions ([doc/design/compiler-assumptions.md](https://github.com/babel/babel/blob/master/doc/design/compiler-assumptions.md))

View File

@@ -3,9 +3,6 @@
const plumber = require("gulp-plumber");
const through = require("through2");
const chalk = require("chalk");
const pump = require("pump");
const uglify = require("gulp-uglify");
const rename = require("gulp-rename");
const newer = require("gulp-newer");
const babel = require("gulp-babel");
const watch = require("gulp-watch");
@@ -13,13 +10,12 @@ const gutil = require("gulp-util");
const filter = require("gulp-filter");
const gulp = require("gulp");
const path = require("path");
const merge = require("merge-stream");
const RootMostResolvePlugin = require("webpack-dependency-suite")
.RootMostResolvePlugin;
const webpack = require("webpack");
const webpackStream = require("webpack-stream");
const merge = require("merge-stream");
const registerStandalonePackageTask = require("./scripts/gulp-tasks")
.registerStandalonePackageTask;
const sources = ["codemods", "packages", "experimental"];
const sources = ["codemods", "packages"];
function swapSrcWithLib(srcPath) {
const parts = srcPath.split(path.sep);
@@ -81,114 +77,40 @@ gulp.task("watch", ["build"], function() {
});
});
gulp.task("build-babel-standalone", cb => {
pump(
[
gulp.src(__dirname + "/packages/babel-standalone/src/index.js"),
webpackBuild(),
gulp.dest(__dirname + "/packages/babel-standalone"),
uglify(),
rename({ extname: ".min.js" }),
gulp.dest(__dirname + "/packages/babel-standalone"),
],
cb
);
});
registerStandalonePackageTask(
gulp,
"babel",
"Babel",
path.join(__dirname, "packages"),
require("./packages/babel-core/package.json").version
);
function webpackBuild() {
let version = require("./packages/babel-core/package.json").version;
const presetEnvWebpackPlugins = [
new webpack.NormalModuleReplacementPlugin(
/\.\/available-plugins/,
require.resolve(
path.join(
__dirname,
"./packages/babel-preset-env-standalone/src/available-plugins"
)
)
),
new webpack.NormalModuleReplacementPlugin(
/caniuse-lite\/data\/regions\/.+/,
require.resolve(
path.join(
__dirname,
"./packages/babel-preset-env-standalone/src/caniuse-lite-regions"
)
)
),
];
// If this build is part of a pull request, include the pull request number in
// the version number.
if (process.env.CIRCLE_PR_NUMBER) {
version += "+pr." + process.env.CIRCLE_PR_NUMBER;
}
const config = {
module: {
rules: [
{
test: /\.js$/,
include: /node_modules/,
loader: "babel-loader",
options: {
// Some of the node_modules may have their own "babel" section in
// their project.json (or a ".babelrc" file). We need to ignore
// those as we're using our own Babel options.
babelrc: false,
presets: [
[
"@babel/env",
{
loose: true,
exclude: ["transform-typeof-symbol"],
},
],
],
},
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
options: {
// Some of the node_modules may have their own "babel" section in
// their project.json (or a ".babelrc" file). We need to ignore
// those as we're using our own Babel options.
babelrc: false,
presets: [
[
"@babel/env",
{
loose: true,
exclude: ["transform-typeof-symbol"],
},
],
["@babel/stage-0", { loose: true }],
],
},
},
],
// babylon is already bundled and does not require parsing
noParse: [/babylon\/lib/],
},
node: {
// Mock Node.js modules that Babel require()s but that we don't
// particularly care about.
fs: "empty",
module: "empty",
net: "empty",
},
output: {
filename: "babel.js",
library: "Babel",
libraryTarget: "umd",
},
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": '"production"',
BABEL_VERSION: JSON.stringify(version),
VERSION: JSON.stringify(version),
}),
/*new webpack.NormalModuleReplacementPlugin(
/..\/..\/package/,
"../../../../src/babel-package-shim"
),*/
new webpack.optimize.ModuleConcatenationPlugin(),
],
resolve: {
plugins: [
// Dedupe packages that are used across multiple plugins.
// This replaces DedupePlugin from Webpack 1.x
new RootMostResolvePlugin(__dirname, true),
],
},
};
return webpackStream(config, webpack);
// To write JSON for debugging:
/*return webpackStream(config, webpack, (err, stats) => {
require('gulp-util').log(stats.toString({colors: true}));
require('fs').writeFileSync('webpack-debug.json', JSON.stringify(stats.toJson()));
});*/
}
registerStandalonePackageTask(
gulp,
"babel-preset-env",
"babelPresetEnv",
path.join(__dirname, "packages"),
require("./packages/babel-preset-env/package.json").version,
presetEnvWebpackPlugins
);

View File

@@ -1,5 +1,5 @@
MAKEFLAGS = -j1
FLOW_COMMIT = 4cc2b9f7fadf2e9e445ee9b7b980c65d69d3fbc0
FLOW_COMMIT = 0dfdb8bf984205f03e95b71680e39bae6b8f7066
TEST262_COMMIT = 1282e842febf418ca27df13fa4b32f7e5021b470
export NODE_ENV = test
@@ -7,7 +7,7 @@ export NODE_ENV = test
# Fix color output until TravisCI fixes https://github.com/travis-ci/travis-ci/issues/7967
export FORCE_COLOR = true
SOURCES = packages codemods experimental
SOURCES = packages codemods
.PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap
@@ -16,8 +16,12 @@ build: clean
# Build babylon before building all other projects
make build-babylon
./node_modules/.bin/gulp build
node ./packages/babel-types/scripts/generateTypeHelpers.js
# call build again as the generated files might need to be compiled again.
./node_modules/.bin/gulp build
ifneq ("$(BABEL_ENV)", "cov")
make build-standalone
make build-preset-env-standalone
endif
build-babylon:
@@ -27,6 +31,9 @@ build-babylon:
build-standalone:
./node_modules/.bin/gulp build-babel-standalone
build-preset-env-standalone:
./node_modules/.bin/gulp build-babel-preset-env-standalone
build-dist: build
cd packages/babel-polyfill; \
scripts/build-dist.sh
@@ -38,6 +45,10 @@ watch: clean
make clean-lib
BABEL_ENV=development ./node_modules/.bin/gulp watch
watch-babylon:
cd packages/babylon; \
./node_modules/.bin/rollup -c -w
flow:
./node_modules/.bin/flow check --strip-root
@@ -50,8 +61,6 @@ fix:
clean: test-clean
rm -rf packages/babel-polyfill/browser*
rm -rf packages/babel-polyfill/dist
# rm -rf packages/babel-runtime/helpers
# rm -rf packages/babel-runtime/core-js
rm -rf coverage
rm -rf packages/*/npm-debug*
@@ -110,6 +119,8 @@ test-test262-update-whitelist:
publish:
git pull --rebase
make clean-lib
rm -rf packages/babel-runtime/helpers
rm -rf packages/babel-runtime/core-js
BABEL_ENV=production make build-dist
make test
# not using lerna independent mode atm, so only update packages that have changed since we use ^

View File

@@ -24,9 +24,9 @@
<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 community-driven and thus mostly maintained by a group of [volunteers](https://babeljs.io/team). It has a lot of [companies and projects](http://babeljs.io/users) using it but almost no sponsors/people funded to work on it. If you'd like to help maintain the future of the project, please consider:
Babel is community-driven and thus mostly maintained by a group of [volunteers](https://babeljs.io/team). It has a lot of [companies and projects](https://babeljs.io/users) using it but almost no sponsors/people funded to work on it. If you'd like to help maintain the future of the project, please consider:
- Giving developer time on the project. (Message us on [Twitter](https://twitter.com/babeljs) or [Slack](slack.babeljs.io))
- Giving developer time on the project. (Message us on [Twitter](https://twitter.com/babeljs) or [Slack](https://slack.babeljs.io/))
- [Giving funds by becoming a backer/sponsor on OpenCollective](https://opencollective.com/babel)
## Intro
@@ -63,19 +63,19 @@ 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/), ask a question on [Stack Overflow](http://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs/).
For questions and support please visit join our [Slack Community](https://slack.babeljs.io/), ask a question on [Stack Overflow](https://stackoverflow.com/questions/tagged/babeljs), or ping us on [Twitter](https://twitter.com/babeljs).
### Where are the docs?
Check out our website: [babeljs.io](http://babeljs.io/), and report issues/features at [babel/website](https://github.com/babel/website/issues).
Check out our website: [babeljs.io](https://babeljs.io/), and report issues/features at [babel/website](https://github.com/babel/website/issues).
### Want to report a bug or request a feature?
Please read through our [CONTRIBUTING.md](https://github.com/babel/babel/blob/master/CONTRIBUTING.md) and fill out the issue template at [babel/issues](https://github.com/babel/babel/issues)!
Please read through our [CONTRIBUTING.md](CONTRIBUTING.md) and fill out the issue template at [babel/issues](https://github.com/babel/babel/issues)!
### Want to contribute to Babel?
Check out our [CONTRIBUTING.md](https://github.com/babel/babel/blob/master/CONTRIBUTING.md) to get started with setting up the repo.
Check out our [CONTRIBUTING.md](CONTRIBUTING.md) to get started with setting up the repo.
- If you have already joined Slack, join our [#development](https://babeljs.slack.com/messages/development) channel and say hi!
- Check out the issues with the [good first issue](https://github.com/babel/babel/labels/good%20first%20issue) and [help wanted](https://github.com/babel/babel/labels/help%20wanted) label. We suggest also looking at the closed ones to get a sense of the kinds of issues you can tackle.
@@ -84,7 +84,7 @@ Check out our [CONTRIBUTING.md](https://github.com/babel/babel/blob/master/CONTR
### How is the repo structured?
The Babel repo is managed as a [monorepo](https://github.com/babel/babel/blob/master/doc/design/monorepo.md) that is composed of many [npm packages](/packages#readme).
The Babel repo is managed as a [monorepo](doc/design/monorepo.md) that is composed of many [npm packages](packages/README.md).
## Backers
@@ -158,4 +158,4 @@ Become a sponsor and get your logo on our README on Github with a link to your s
## License
[MIT](https://github.com/babel/babel/blob/master/LICENSE)
[MIT](LICENSE)

View File

@@ -2,6 +2,8 @@ general:
artifacts:
- "packages/babel-standalone/babel.js"
- "packages/babel-standalone/babel.min.js"
- "packages/babel-preset-env-standalone/babel-preset-env.js"
- "packages/babel-preset-env-standalone/babel-preset-env.min.js"
machine:
node:
@@ -25,3 +27,4 @@ test:
# data for a JS file that's several megabytes large is bound to fail. Here,
# we just run the babel-standalone test separately.
- ./node_modules/mocha/bin/_mocha packages/babel-standalone/test/ --opts test/mocha.opts
- ./node_modules/mocha/bin/_mocha packages/babel-preset-env-standalone/test/ --opts test/mocha.opts

View File

@@ -1,6 +0,0 @@
{
"rules": {
"prettier/prettier": ["error", { "trailingComma": "all" }],
"no-undefined-identifier": 2
}
}

View File

@@ -36,21 +36,21 @@ npm install --save-dev @babel/plugin-codemod-optional-catch-binding
```json
{
"plugins": ["@babel/codemod-optional-catch-binding"]
"plugins": ["@babel/plugin-codemod-optional-catch-binding"]
}
```
### Via CLI
```sh
babel --plugins @babel/codemod-optional-catch-binding script.js
babel --plugins @babel/plugin-codemod-optional-catch-binding script.js
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/codemod-optional-catch-binding"]
plugins: ["@babel/plugin-codemod-optional-catch-binding"]
});
```

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/plugin-codemod-optional-catch-binding",
"version": "7.0.0-beta.32",
"version": "7.0.0-beta.34",
"description": "Remove unused catch bindings",
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-remove-unused-catch-binding",
"license": "MIT",
@@ -9,13 +9,13 @@
"@babel/plugin"
],
"dependencies": {
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.32"
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.34"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.32"
"@babel/core": "7.0.0-beta.34"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.32",
"@babel/helper-plugin-test-runner": "7.0.0-beta.32"
"@babel/core": "7.0.0-beta.34",
"@babel/helper-plugin-test-runner": "7.0.0-beta.34"
}
}

View File

@@ -1,6 +0,0 @@
{
"rules": {
"prettier/prettier": ["error", { "trailingComma": "all" }],
"no-undefined-identifier": 2
}
}

View File

@@ -1,6 +0,0 @@
/lib
debug-fixtures
fixtures
/data
/flow-typed
test/tmp

View File

@@ -1,63 +0,0 @@
{
"name": "@babel/preset-env",
"version": "7.0.0-beta.32",
"description": "A Babel preset for each environment.",
"author": "Henry Zhu <hi@henryzoo.com>",
"homepage": "https://babeljs.io/",
"license": "MIT",
"repository": "https://github.com/babel/babel/tree/master/experimental/babel-preset-env",
"main": "lib/index.js",
"scripts": {
"build-data": "node ./scripts/build-data.js"
},
"dependencies": {
"@babel/plugin-check-constants": "7.0.0-beta.32",
"@babel/plugin-proposal-async-generator-functions": "7.0.0-beta.32",
"@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.32",
"@babel/plugin-proposal-optional-catch-binding": "7.0.0-beta.32",
"@babel/plugin-proposal-unicode-property-regex": "7.0.0-beta.32",
"@babel/plugin-syntax-async-generators": "7.0.0-beta.32",
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.32",
"@babel/plugin-syntax-optional-catch-binding": "7.0.0-beta.32",
"@babel/plugin-transform-arrow-functions": "7.0.0-beta.32",
"@babel/plugin-transform-async-to-generator": "7.0.0-beta.32",
"@babel/plugin-transform-block-scoped-functions": "7.0.0-beta.32",
"@babel/plugin-transform-block-scoping": "7.0.0-beta.32",
"@babel/plugin-transform-classes": "7.0.0-beta.32",
"@babel/plugin-transform-computed-properties": "7.0.0-beta.32",
"@babel/plugin-transform-destructuring": "7.0.0-beta.32",
"@babel/plugin-transform-duplicate-keys": "7.0.0-beta.32",
"@babel/plugin-transform-exponentiation-operator": "7.0.0-beta.32",
"@babel/plugin-transform-for-of": "7.0.0-beta.32",
"@babel/plugin-transform-function-name": "7.0.0-beta.32",
"@babel/plugin-transform-literals": "7.0.0-beta.32",
"@babel/plugin-transform-modules-amd": "7.0.0-beta.32",
"@babel/plugin-transform-modules-commonjs": "7.0.0-beta.32",
"@babel/plugin-transform-modules-systemjs": "7.0.0-beta.32",
"@babel/plugin-transform-modules-umd": "7.0.0-beta.32",
"@babel/plugin-transform-new-target": "7.0.0-beta.32",
"@babel/plugin-transform-object-super": "7.0.0-beta.32",
"@babel/plugin-transform-parameters": "7.0.0-beta.32",
"@babel/plugin-transform-regenerator": "7.0.0-beta.32",
"@babel/plugin-transform-shorthand-properties": "7.0.0-beta.32",
"@babel/plugin-transform-spread": "7.0.0-beta.32",
"@babel/plugin-transform-sticky-regex": "7.0.0-beta.32",
"@babel/plugin-transform-template-literals": "7.0.0-beta.32",
"@babel/plugin-transform-typeof-symbol": "7.0.0-beta.32",
"@babel/plugin-transform-unicode-regex": "7.0.0-beta.32",
"browserslist": "^2.4.0",
"invariant": "^2.2.2",
"semver": "^5.3.0"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.32"
},
"devDependencies": {
"@babel/cli": "7.0.0-beta.32",
"@babel/core": "7.0.0-beta.32",
"@babel/helper-fixtures": "7.0.0-beta.32",
"@babel/helper-plugin-test-runner": "7.0.0-beta.32",
"compat-table": "kangax/compat-table#957f1ff15972e8fb2892a172f985e9af27bf1c75",
"electron-to-chromium": "^1.3.27"
}
}

View File

@@ -1,5 +0,0 @@
{
"rules": {
"prettier/prettier": ["error", { "trailingComma": "es5" }]
}
}

View File

@@ -1,8 +0,0 @@
{
"env": {
"mocha": true
},
"rules": {
"max-len": 0
}
}

View File

@@ -1,5 +0,0 @@
"use strict";
var _a = _interopRequireDefault(require("a"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

View File

@@ -1 +0,0 @@
import a from "a";

View File

@@ -1,16 +1,16 @@
{
"lerna": "2.0.0-rc.4",
"version": "7.0.0-beta.32",
"version": "7.0.0-beta.34",
"changelog": {
"repo": "babel/babel",
"labels": {
"Tag: Spec Compliancy": ":eyeglasses: Spec Compliancy",
"Tag: Breaking Change": ":boom: Breaking Change",
"Tag: New Feature": ":rocket: New Feature",
"Tag: Bug Fix": ":bug: Bug Fix",
"Tag: Polish": ":nail_care: Polish",
"Tag: Docs": ":memo: Documentation",
"Tag: Internal": ":house: Internal"
"PR: Spec Compliancy": ":eyeglasses: Spec Compliancy",
"PR: Breaking Change": ":boom: Breaking Change",
"PR: New Feature": ":rocket: New Feature",
"PR: Bug Fix": ":bug: Bug Fix",
"PR: Polish": ":nail_care: Polish",
"PR: Docs": ":memo: Documentation",
"PR: Internal": ":house: Internal"
}
},
"cacheDir": ".changelog",
@@ -19,15 +19,13 @@
"ignore": [
"*.md",
"test/**",
"codemods/**",
"experimental/**"
"codemods/**"
]
}
},
"packages": [
"packages/*",
"codemods/*",
"experimental/*"
"codemods/*"
],
"npmClient": "yarn",
"npmClientArgs": [

View File

@@ -352,7 +352,7 @@ declare class BabelNodeWhileStatement extends BabelNode {
declare class BabelNodeWithStatement extends BabelNode {
type: "WithStatement";
object: any;
object: BabelNodeExpression;
body: BabelNodeBlockStatement | BabelNodeStatement;
}
@@ -800,7 +800,7 @@ declare class BabelNodeVoidTypeAnnotation extends BabelNode {
declare class BabelNodeJSXAttribute extends BabelNode {
type: "JSXAttribute";
name: BabelNodeJSXIdentifier | BabelNodeJSXNamespacedName;
value?: ?BabelNodeJSXElement | BabelNodeStringLiteral | BabelNodeJSXExpressionContainer;
value?: ?BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeStringLiteral | BabelNodeJSXExpressionContainer;
}
declare class BabelNodeJSXClosingElement extends BabelNode {
@@ -864,6 +864,21 @@ declare class BabelNodeJSXText extends BabelNode {
value: string;
}
declare class BabelNodeJSXFragment extends BabelNode {
type: "JSXFragment";
openingFragment: BabelNodeJSXOpeningFragment;
closingFragment: BabelNodeJSXClosingFragment;
children: any;
}
declare class BabelNodeJSXOpeningFragment extends BabelNode {
type: "JSXOpeningFragment";
}
declare class BabelNodeJSXClosingFragment extends BabelNode {
type: "JSXClosingFragment";
}
declare class BabelNodeNoop extends BabelNode {
type: "Noop";
}
@@ -1247,7 +1262,7 @@ declare class BabelNodeTSTypeParameter extends BabelNode {
name?: string;
}
type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeParenthesizedExpression | BabelNodeAwaitExpression | BabelNodeBindExpression | BabelNodeImport | BabelNodeDoExpression | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
type BabelNodeExpression = BabelNodeArrayExpression | BabelNodeAssignmentExpression | BabelNodeBinaryExpression | BabelNodeCallExpression | BabelNodeConditionalExpression | BabelNodeFunctionExpression | BabelNodeIdentifier | BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeLogicalExpression | BabelNodeMemberExpression | BabelNodeNewExpression | BabelNodeObjectExpression | BabelNodeSequenceExpression | BabelNodeThisExpression | BabelNodeUnaryExpression | BabelNodeUpdateExpression | BabelNodeArrowFunctionExpression | BabelNodeClassExpression | BabelNodeMetaProperty | BabelNodeSuper | BabelNodeTaggedTemplateExpression | BabelNodeTemplateLiteral | BabelNodeYieldExpression | BabelNodeTypeCastExpression | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXFragment | BabelNodeParenthesizedExpression | BabelNodeAwaitExpression | BabelNodeBindExpression | BabelNodeImport | BabelNodeDoExpression | BabelNodeTSAsExpression | BabelNodeTSTypeAssertion | BabelNodeTSNonNullExpression;
type BabelNodeBinary = BabelNodeBinaryExpression | BabelNodeLogicalExpression;
type BabelNodeScopable = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeClassDeclaration | BabelNodeClassExpression | BabelNodeForOfStatement | BabelNodeClassMethod;
type BabelNodeBlockParent = BabelNodeBlockStatement | BabelNodeCatchClause | BabelNodeDoWhileStatement | BabelNodeForInStatement | BabelNodeForStatement | BabelNodeFunctionDeclaration | BabelNodeFunctionExpression | BabelNodeProgram | BabelNodeObjectMethod | BabelNodeSwitchStatement | BabelNodeWhileStatement | BabelNodeArrowFunctionExpression | BabelNodeForOfStatement | BabelNodeClassMethod;
@@ -1269,7 +1284,7 @@ type BabelNodePatternLike = BabelNodeIdentifier | BabelNodeRestElement | BabelNo
type BabelNodeLVal = BabelNodeIdentifier | BabelNodeMemberExpression | BabelNodeRestElement | BabelNodeAssignmentPattern | BabelNodeArrayPattern | BabelNodeObjectPattern | BabelNodeTSParameterProperty;
type BabelNodeTSEntityName = BabelNodeIdentifier | BabelNodeTSQualifiedName;
type BabelNodeLiteral = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeRegExpLiteral | BabelNodeTemplateLiteral;
type BabelNodeImmutable = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXOpeningElement | BabelNodeJSXText;
type BabelNodeImmutable = BabelNodeStringLiteral | BabelNodeNumericLiteral | BabelNodeNullLiteral | BabelNodeBooleanLiteral | BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXOpeningElement | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment;
type BabelNodeUserWhitespacable = BabelNodeObjectMethod | BabelNodeObjectProperty | BabelNodeObjectTypeCallProperty | BabelNodeObjectTypeIndexer | BabelNodeObjectTypeProperty | BabelNodeObjectTypeSpreadProperty;
type BabelNodeMethod = BabelNodeObjectMethod | BabelNodeClassMethod;
type BabelNodeObjectMember = BabelNodeObjectMethod | BabelNodeObjectProperty;
@@ -1284,7 +1299,7 @@ type BabelNodeFlow = BabelNodeAnyTypeAnnotation | BabelNodeArrayTypeAnnotation |
type BabelNodeFlowBaseAnnotation = BabelNodeAnyTypeAnnotation | BabelNodeBooleanTypeAnnotation | BabelNodeNullLiteralTypeAnnotation | BabelNodeMixedTypeAnnotation | BabelNodeEmptyTypeAnnotation | BabelNodeNumberTypeAnnotation | BabelNodeStringTypeAnnotation | BabelNodeThisTypeAnnotation | BabelNodeVoidTypeAnnotation;
type BabelNodeFlowDeclaration = BabelNodeDeclareClass | BabelNodeDeclareFunction | BabelNodeDeclareInterface | BabelNodeDeclareModule | BabelNodeDeclareModuleExports | BabelNodeDeclareTypeAlias | BabelNodeDeclareOpaqueType | BabelNodeDeclareVariable | BabelNodeDeclareExportDeclaration | BabelNodeDeclareExportAllDeclaration | BabelNodeInterfaceDeclaration | BabelNodeOpaqueType | BabelNodeTypeAlias;
type BabelNodeFlowPredicate = BabelNodeDeclaredPredicate | BabelNodeInferredPredicate;
type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText;
type BabelNodeJSX = BabelNodeJSXAttribute | BabelNodeJSXClosingElement | BabelNodeJSXElement | BabelNodeJSXEmptyExpression | BabelNodeJSXExpressionContainer | BabelNodeJSXSpreadChild | BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression | BabelNodeJSXNamespacedName | BabelNodeJSXOpeningElement | BabelNodeJSXSpreadAttribute | BabelNodeJSXText | BabelNodeJSXFragment | BabelNodeJSXOpeningFragment | BabelNodeJSXClosingFragment;
type BabelNodeTSTypeElement = BabelNodeTSCallSignatureDeclaration | BabelNodeTSConstructSignatureDeclaration | BabelNodeTSPropertySignature | BabelNodeTSMethodSignature | BabelNodeTSIndexSignature;
type BabelNodeTSType = BabelNodeTSAnyKeyword | BabelNodeTSNumberKeyword | BabelNodeTSObjectKeyword | BabelNodeTSBooleanKeyword | BabelNodeTSStringKeyword | BabelNodeTSSymbolKeyword | BabelNodeTSVoidKeyword | BabelNodeTSUndefinedKeyword | BabelNodeTSNullKeyword | BabelNodeTSNeverKeyword | BabelNodeTSThisType | BabelNodeTSFunctionType | BabelNodeTSConstructorType | BabelNodeTSTypeReference | BabelNodeTSTypePredicate | BabelNodeTSTypeQuery | BabelNodeTSTypeLiteral | BabelNodeTSArrayType | BabelNodeTSTupleType | BabelNodeTSUnionType | BabelNodeTSIntersectionType | BabelNodeTSParenthesizedType | BabelNodeTSTypeOperator | BabelNodeTSIndexedAccessType | BabelNodeTSMappedType | BabelNodeTSLiteralType | BabelNodeTSExpressionWithTypeArguments;
@@ -1337,7 +1352,7 @@ declare module "@babel/types" {
declare function variableDeclaration(kind: any, declarations: any, declare?: boolean): BabelNodeVariableDeclaration;
declare function variableDeclarator(id: BabelNodeLVal, init?: ?BabelNodeExpression): BabelNodeVariableDeclarator;
declare function whileStatement(test: BabelNodeExpression, body: BabelNodeBlockStatement | BabelNodeStatement): BabelNodeWhileStatement;
declare function withStatement(object: any, body: BabelNodeBlockStatement | BabelNodeStatement): BabelNodeWithStatement;
declare function withStatement(object: BabelNodeExpression, body: BabelNodeBlockStatement | BabelNodeStatement): BabelNodeWithStatement;
declare function assignmentPattern(left: BabelNodeIdentifier | BabelNodeObjectPattern | BabelNodeArrayPattern, right: BabelNodeExpression, decorators?: any, typeAnnotation?: ?BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop): BabelNodeAssignmentPattern;
declare function arrayPattern(elements: any, decorators?: any, typeAnnotation?: ?BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop): BabelNodeArrayPattern;
declare function arrowFunctionExpression(params: any, body: BabelNodeBlockStatement | BabelNodeExpression, async?: boolean, expression?: boolean, generator?: boolean, returnType?: ?BabelNodeTypeAnnotation | BabelNodeTSTypeAnnotation | BabelNodeNoop, typeParameters?: ?BabelNodeTypeParameterDeclaration | BabelNodeNoop): BabelNodeArrowFunctionExpression;
@@ -1411,7 +1426,7 @@ declare module "@babel/types" {
declare function typeParameterInstantiation(params: any): BabelNodeTypeParameterInstantiation;
declare function unionTypeAnnotation(types: any): BabelNodeUnionTypeAnnotation;
declare function voidTypeAnnotation(): BabelNodeVoidTypeAnnotation;
declare function jSXAttribute(name: BabelNodeJSXIdentifier | BabelNodeJSXNamespacedName, value?: ?BabelNodeJSXElement | BabelNodeStringLiteral | BabelNodeJSXExpressionContainer): BabelNodeJSXAttribute;
declare function jSXAttribute(name: BabelNodeJSXIdentifier | BabelNodeJSXNamespacedName, value?: ?BabelNodeJSXElement | BabelNodeJSXFragment | BabelNodeStringLiteral | BabelNodeJSXExpressionContainer): BabelNodeJSXAttribute;
declare function jSXClosingElement(name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression): BabelNodeJSXClosingElement;
declare function jSXElement(openingElement: BabelNodeJSXOpeningElement, closingElement?: ?BabelNodeJSXClosingElement, children: any, selfClosing: any): BabelNodeJSXElement;
declare function jSXEmptyExpression(): BabelNodeJSXEmptyExpression;
@@ -1423,6 +1438,9 @@ declare module "@babel/types" {
declare function jSXOpeningElement(name: BabelNodeJSXIdentifier | BabelNodeJSXMemberExpression, attributes: any, selfClosing?: boolean): BabelNodeJSXOpeningElement;
declare function jSXSpreadAttribute(argument: BabelNodeExpression): BabelNodeJSXSpreadAttribute;
declare function jSXText(value: string): BabelNodeJSXText;
declare function jSXFragment(openingFragment: BabelNodeJSXOpeningFragment, closingFragment: BabelNodeJSXClosingFragment, children: any): BabelNodeJSXFragment;
declare function jSXOpeningFragment(): BabelNodeJSXOpeningFragment;
declare function jSXClosingFragment(): BabelNodeJSXClosingFragment;
declare function noop(): BabelNodeNoop;
declare function parenthesizedExpression(expression: BabelNodeExpression): BabelNodeParenthesizedExpression;
declare function awaitExpression(argument: BabelNodeExpression): BabelNodeAwaitExpression;
@@ -1621,6 +1639,9 @@ declare module "@babel/types" {
declare function isJSXOpeningElement(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXOpeningElement)
declare function isJSXSpreadAttribute(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXSpreadAttribute)
declare function isJSXText(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXText)
declare function isJSXFragment(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXFragment)
declare function isJSXOpeningFragment(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXOpeningFragment)
declare function isJSXClosingFragment(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeJSXClosingFragment)
declare function isNoop(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeNoop)
declare function isParenthesizedExpression(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeParenthesizedExpression)
declare function isAwaitExpression(node: Object, opts?: ?Object): boolean %checks (node instanceof BabelNodeAwaitExpression)
@@ -1727,6 +1748,8 @@ declare module "@babel/types" {
declare function isTSType(node: Object, opts?: ?Object): boolean
declare function isNumberLiteral(node: Object, opts?: ?Object): boolean
declare function isRegexLiteral(node: Object, opts?: ?Object): boolean
declare function isRestProperty(node: Object, opts?: ?Object): boolean
declare function isSpreadProperty(node: Object, opts?: ?Object): boolean
declare function validate(n: BabelNode, key: string, value: mixed): void;
declare function clone<T>(n: T): T;
declare function cloneDeep<T>(n: T): T;

View File

@@ -10,17 +10,18 @@
"test": "make test"
},
"devDependencies": {
"@babel/cli": "7.0.0-beta.5",
"@babel/core": "7.0.0-beta.5",
"@babel/preset-env": "7.0.0-beta.5",
"@babel/preset-flow": "7.0.0-beta.5",
"@babel/preset-stage-0": "7.0.0-beta.5",
"@babel/register": "7.0.0-beta.5",
"@babel/cli": "7.0.0-beta.33",
"@babel/core": "7.0.0-beta.33",
"@babel/plugin-proposal-export-namespace-from": "7.0.0-beta.33",
"@babel/preset-env": "7.0.0-beta.33",
"@babel/preset-flow": "7.0.0-beta.33",
"@babel/preset-stage-0": "7.0.0-beta.33",
"@babel/register": "7.0.0-beta.33",
"async": "^1.5.0",
"babel-eslint": "^8.0.1",
"babel-loader": "8.0.0-beta.0",
"babel-plugin-istanbul": "^4.1.4",
"babylon": "7.0.0-beta.30",
"babylon": "7.0.0-beta.33",
"browserify": "^13.1.1",
"bundle-collapser": "^1.2.1",
"chai": "^4.1.0",
@@ -30,7 +31,7 @@
"eslint-config-babel": "^7.0.2",
"eslint-plugin-flowtype": "^2.20.0",
"eslint-plugin-prettier": "^2.2.0",
"flow-bin": "^0.57.3",
"flow-bin": "^0.59.0",
"graceful-fs": "^4.1.11",
"gulp": "^3.9.0",
"gulp-babel": "^8.0.0-beta.0",
@@ -72,8 +73,7 @@
"scripts/*.js",
"packages/*/test/**",
"packages/babel-standalone/**",
"codemods/*/test/**",
"experimental/*/test/**"
"codemods/*/test/**"
],
"sourceMap": false,
"instrument": false

View File

@@ -45,7 +45,7 @@ Check out the [`babel-handbook`](https://github.com/thejameskyle/babel-handbook/
| [`@babel/helpers`](/packages/babel-helpers) | [![npm](https://img.shields.io/npm/v/babel-helpers.svg?maxAge=2592000)](https://www.npmjs.com/package/babel-helpers) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-helpers)](https://david-dm.org/babel/babel?path=packages/babel-helpers) |
| [`@babel/code-frame`](/packages/babel-code-frame) | [![npm](https://img.shields.io/npm/v/babel-code-frame.svg?maxAge=2592000)](https://www.npmjs.com/package/babel-code-frame) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/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`). Check out the [docs](https://babeljs.io/docs/usage/cli/).
- [`@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.
- [`@babel/polyfill`](/packages/babel-polyfill) is [literally a wrapper](https://github.com/babel/babel/blob/master/packages/babel-polyfill/src/index.js) around [`core-js`](https://github.com/zloirock/core-js) and [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime). Check out the [docs](https://babeljs.io/docs/usage/polyfill/).
- [`@babel/runtime`](/packages/babel-runtime) is similar to the polyfill except that it doesn't modify the global scope and is to be used with [`@babel/plugin-transform-runtime`](/packages/babel-plugin-transform-runtime) (usually in library/plugin code). Check out the [docs](https://babeljs.io/docs/plugins/transform-runtime/).

View File

@@ -4,7 +4,7 @@
In addition, various entry point scripts live in the top-level package at `@babel/cli/bin`.
There are some shell-executable utility scripts, `babel-external-helpers.js` and `babel-node.js`, and the main Babel cli script, `babel.js`.
There is a shell-executable utility script, `babel-external-helpers.js`, and the main Babel cli script, `babel.js`.
## Install

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/cli",
"version": "7.0.0-beta.32",
"version": "7.0.0-beta.34",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",
@@ -29,11 +29,11 @@
"chokidar": "^1.6.1"
},
"peerDependencies": {
"@babel/core": "7.0.0-beta.32"
"@babel/core": "7.0.0-beta.34"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.32",
"@babel/helper-fixtures": "7.0.0-beta.32"
"@babel/core": "7.0.0-beta.34",
"@babel/helper-fixtures": "7.0.0-beta.34"
},
"bin": {
"babel": "./bin/babel.js",

View File

@@ -49,6 +49,11 @@ commander.option(
collect,
);
commander.option("--config-file [path]", "Path a to .babelrc file to use");
commander.option(
"--env-name [name]",
"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'.",
);
// Basic file input configuration.
commander.option("--source-type [script|module]", "");

View File

@@ -1 +1 @@
SyntaxError: test.js: Unexpected token, expected ; (2:10)
SyntaxError: test.js: Unexpected token, expected ";" (2:10)

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/code-frame",
"version": "7.0.0-beta.32",
"version": "7.0.0-beta.34",
"description": "Generate errors that contain a code frame that point to source locations.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://babeljs.io/",

View File

@@ -144,10 +144,11 @@ Following is a table of the options you can use:
| `auxiliaryCommentAfter` | `null` | Attach a comment after all non-user injected code |
| `auxiliaryCommentBefore` | `null` | Attach a comment before all non-user injected code |
| `babelrc` | `true` | Specify whether or not to use .babelrc and .babelignore files. Not available when using the CLI, [use `--no-babelrc` instead](https://babeljs.io/docs/usage/cli/#babel-ignoring-babelrc) |
| `envName` | env vars | Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it defaults to `"development"` |
| `code` | `true` | Enable code generation |
| `comments` | `true` | Output comments in generated output |
| `compact` | `"auto"` | Do not include superfluous whitespace characters and line terminators. When set to `"auto"` compact is set to `true` on input sizes of >500KB |
| `env` | `{}` | This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { /* specific options */ } } }` which will use those options when the environment variable `BABEL_ENV` is set to `"production"`. If `BABEL_ENV` isn't set then `NODE_ENV` will be used, if it's not set then it defaults to `"development"` |
| `env` | `{}` | This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { /* specific options */ } } }` which will use those options when the `envName` is `production` |
| `extends` | `null` | A path to a `.babelrc` file to extend |
| `filename` | `"unknown"` | Filename for use in errors etc |
| `filenameRelative` | `(filename)` | Filename relative to `sourceRoot` |

View File

@@ -1,6 +1,6 @@
{
"name": "@babel/core",
"version": "7.0.0-beta.32",
"version": "7.0.0-beta.34",
"description": "Babel compiler core.",
"main": "./lib/index.js",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
@@ -28,13 +28,13 @@
"./lib/transform-file-sync.js": "./lib/transform-file-sync-browser.js"
},
"dependencies": {
"@babel/code-frame": "7.0.0-beta.32",
"@babel/generator": "7.0.0-beta.32",
"@babel/helpers": "7.0.0-beta.32",
"@babel/template": "7.0.0-beta.32",
"@babel/traverse": "7.0.0-beta.32",
"@babel/types": "7.0.0-beta.32",
"babylon": "7.0.0-beta.32",
"@babel/code-frame": "7.0.0-beta.34",
"@babel/generator": "7.0.0-beta.34",
"@babel/helpers": "7.0.0-beta.34",
"@babel/template": "7.0.0-beta.34",
"@babel/traverse": "7.0.0-beta.34",
"@babel/types": "7.0.0-beta.34",
"babylon": "7.0.0-beta.34",
"convert-source-map": "^1.1.0",
"debug": "^3.0.1",
"json5": "^0.5.0",
@@ -44,7 +44,7 @@
"source-map": "^0.5.0"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.32",
"@babel/register": "7.0.0-beta.32"
"@babel/helper-transform-fixture-test-runner": "7.0.0-beta.34",
"@babel/register": "7.0.0-beta.34"
}
}

View File

@@ -1,6 +1,5 @@
// @flow
import { getEnv } from "./helpers/environment";
import path from "path";
import micromatch from "micromatch";
import buildDebug from "debug";
@@ -40,21 +39,22 @@ type ConfigPart =
};
export default function buildConfigChain(
cwd: string,
opts: ValidatedOptions,
envName: string,
): Array<ConfigItem> | null {
const filename = opts.filename ? path.resolve(opts.filename) : null;
const filename = opts.filename ? path.resolve(cwd, opts.filename) : null;
const builder = new ConfigChainBuilder(
filename ? new LoadedFile(filename) : null,
);
const envKey = getEnv();
try {
builder.mergeConfigArguments(opts, process.cwd(), envKey);
builder.mergeConfigArguments(opts, cwd, envName);
// resolve all .babelrc files
if (opts.babelrc !== false && filename) {
findConfigs(path.dirname(filename)).forEach(configFile =>
builder.mergeConfigFile(configFile, envKey),
findConfigs(path.dirname(filename), envName).forEach(configFile =>
builder.mergeConfigFile(configFile, envName),
);
}
} catch (e) {
@@ -85,21 +85,21 @@ class ConfigChainBuilder {
);
}
mergeConfigFile(file: ConfigFile, envKey: string) {
mergeConfigFile(file: ConfigFile, envName: string) {
if (this.seenFiles.has(file)) {
throw new Error(
`Cycle detected in Babel configuration file through "${file.filepath}".`,
);
}
const parts = flattenFileOptionsParts(file)(envKey);
const parts = flattenFileOptionsParts(file)(envName);
this.seenFiles.add(file);
parts.forEach(part => this._processConfigPart(part, envKey));
parts.forEach(part => this._processConfigPart(part, envName));
this.seenFiles.delete(file);
}
_processConfigPart(part: ConfigPart, envKey: string) {
_processConfigPart(part: ConfigPart, envName: string) {
if (part.part === "config") {
const { ignore, only } = part;
@@ -116,7 +116,10 @@ class ConfigChainBuilder {
this.configs.push(part.config);
} else {
this.mergeConfigFile(loadConfig(part.path, part.dirname), envKey);
this.mergeConfigFile(
loadConfig(part.path, part.dirname, envName),
envName,
);
}
}
}
@@ -129,7 +132,7 @@ class ConfigChainBuilder {
function flattenArgumentsOptionsParts(
opts: ValidatedOptions,
dirname: string,
envKey: string,
envName: string,
): Array<ConfigPart> {
const {
env,
@@ -142,7 +145,7 @@ function flattenArgumentsOptionsParts(
const raw = [];
if (env) {
raw.push(...flattenArgumentsEnvOptionsParts(env)(dirname)(envKey));
raw.push(...flattenArgumentsEnvOptionsParts(env)(dirname)(envName));
}
if (Object.keys(options).length > 0) {
@@ -263,7 +266,7 @@ function flattenOptionsPartsLookup(
});
}
return envKey => lookup.get(envKey) || def;
return envName => lookup.get(envName) || def;
}
/**

View File

@@ -1,29 +1,33 @@
// @flow
type CacheConfigurator = CacheConfiguratorFn & CacheConfiguratorObj;
type SimpleCacheConfigurator = SimpleCacheConfiguratorFn &
SimpleCacheConfiguratorObj;
type CacheConfiguratorFn = {
type SimpleCacheConfiguratorFn = {
(boolean): void,
<T>(handler: () => T): T,
};
type CacheConfiguratorObj = {
type SimpleCacheConfiguratorObj = {
forever: () => void,
never: () => void,
using: <T>(handler: () => T) => T,
invalidate: <T>(handler: () => T) => T,
};
type CacheEntry<ResultT> = Array<[ResultT, () => boolean]>;
type CacheEntry<ResultT, SideChannel> = Array<
[ResultT, (SideChannel) => boolean],
>;
export type { CacheConfigurator };
/**
* Given a function with a single argument, cache its results based on its argument and how it
* configures its caching behavior. Cached values are stored strongly.
*/
export function makeStrongCache<ArgT, ResultT>(
handler: (ArgT, CacheConfigurator) => ResultT,
autoPermacache?: boolean,
): ArgT => ResultT {
return makeCachedFunction(new Map(), handler, autoPermacache);
export function makeStrongCache<ArgT, ResultT, SideChannel>(
handler: (ArgT, CacheConfigurator<SideChannel>) => ResultT,
): (ArgT, SideChannel) => ResultT {
return makeCachedFunction(new Map(), handler);
}
/**
@@ -31,190 +35,182 @@ export function makeStrongCache<ArgT, ResultT>(
* configures its caching behavior. Cached values are stored weakly and the function argument must be
* an object type.
*/
export function makeWeakCache<ArgT: {} | Array<*> | $ReadOnlyArray<*>, ResultT>(
handler: (ArgT, CacheConfigurator) => ResultT,
autoPermacache?: boolean,
): ArgT => ResultT {
return makeCachedFunction(new WeakMap(), handler, autoPermacache);
export function makeWeakCache<
ArgT: {} | Array<*> | $ReadOnlyArray<*>,
ResultT,
SideChannel,
>(
handler: (ArgT, CacheConfigurator<SideChannel>) => ResultT,
): (ArgT, SideChannel) => ResultT {
return makeCachedFunction(new WeakMap(), handler);
}
type CacheMap<ArgT, ResultT> =
| Map<ArgT, CacheEntry<ResultT>>
| WeakMap<ArgT, CacheEntry<ResultT>>;
type CacheMap<ArgT, ResultT, SideChannel> =
| Map<ArgT, CacheEntry<ResultT, SideChannel>>
| WeakMap<ArgT, CacheEntry<ResultT, SideChannel>>;
function makeCachedFunction<ArgT, ResultT, Cache: CacheMap<ArgT, ResultT>>(
function makeCachedFunction<
ArgT,
ResultT,
SideChannel,
Cache: CacheMap<ArgT, ResultT, SideChannel>,
>(
callCache: Cache,
handler: (ArgT, CacheConfigurator) => ResultT,
autoPermacache: boolean = true,
): ArgT => ResultT {
return function cachedFunction(arg) {
let cachedValue: CacheEntry<ResultT> | void = callCache.get(arg);
handler: (ArgT, CacheConfigurator<SideChannel>) => ResultT,
): (ArgT, SideChannel) => ResultT {
return function cachedFunction(arg, data) {
let cachedValue: CacheEntry<ResultT, SideChannel> | void = callCache.get(
arg,
);
if (cachedValue) {
for (const [value, valid] of cachedValue) {
if (valid()) return value;
if (valid(data)) return value;
}
}
const { cache, result, deactivate } = makeCacheConfig();
const cache = new CacheConfigurator(data);
const value = handler(arg, cache);
if (autoPermacache && !result.configured) cache.forever();
if (!cache.configured()) cache.forever();
deactivate();
cache.deactivate();
if (!result.configured) {
// eslint-disable-next-line max-len
throw new Error(
[
"Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured",
"for various types of caching, using the first param of their handler functions:",
"",
"module.exports = function(api) {",
" // The API exposes the following:",
"",
" // Cache the returned value forever and don't call this function again.",
" api.cache(true);",
"",
" // Don't cache at all. Not recommended because it will be very slow.",
" api.cache(false);",
"",
" // Cached based on the value of some function. If this function returns a value different from",
" // a previously-encountered value, the plugins will re-evaluate.",
" var env = api.cache(() => process.env.NODE_ENV);",
"",
" // If testing for a specific env, we recommend specifics to avoid instantiating a plugin for",
" // any possible NODE_ENV value that might come up during plugin execution.",
' var isProd = api.cache(() => process.env.NODE_ENV === "production");',
"",
" // .cache(fn) will perform a linear search though instances to find the matching plugin based",
" // based on previous instantiated plugins. If you want to recreate the plugin and discard the",
" // previous instance whenever something changes, you may use:",
' var isProd = api.cache.invalidate(() => process.env.NODE_ENV === "production");',
"",
" // Note, we also expose the following more-verbose versions of the above examples:",
" api.cache.forever(); // api.cache(true)",
" api.cache.never(); // api.cache(false)",
" api.cache.using(fn); // api.cache(fn)",
"",
" // Return the value that will be cached.",
" return { };",
"};",
].join("\n"),
);
}
if (!result.never) {
if (result.forever) {
switch (cache.mode()) {
case "forever":
cachedValue = [[value, () => true]];
} else if (result.invalidate) {
cachedValue = [[value, result.valid]];
} else {
cachedValue = cachedValue || [];
cachedValue.push([value, result.valid]);
}
callCache.set(arg, cachedValue);
callCache.set(arg, cachedValue);
break;
case "invalidate":
cachedValue = [[value, cache.validator()]];
callCache.set(arg, cachedValue);
break;
case "valid":
if (cachedValue) {
cachedValue.push([value, cache.validator()]);
} else {
cachedValue = [[value, cache.validator()]];
callCache.set(arg, cachedValue);
}
}
return value;
};
}
function makeCacheConfig(): {
cache: CacheConfigurator,
result: *,
deactivate: () => void,
} {
const pairs = [];
class CacheConfigurator<SideChannel = void> {
_active: boolean = true;
_never: boolean = false;
_forever: boolean = false;
_invalidate: boolean = false;
const result = {
configured: false,
never: false,
forever: false,
invalidate: false,
valid: () => pairs.every(([key, fn]) => key === fn()),
};
_configured: boolean = false;
let active = true;
const deactivate = () => {
active = false;
};
_pairs: Array<[mixed, (SideChannel) => mixed]> = [];
const cache: CacheConfigurator = Object.assign(
(function cacheFn(val) {
if (typeof val === "boolean") {
if (val) cache.forever();
else cache.never();
return;
}
_data: SideChannel;
return cache.using(val);
}: any),
({
forever() {
if (!active) {
throw new Error(
"Cannot change caching after evaluation has completed.",
);
}
if (result.never) {
throw new Error("Caching has already been configured with .never()");
}
result.forever = true;
result.configured = true;
},
never() {
if (!active) {
throw new Error(
"Cannot change caching after evaluation has completed.",
);
}
if (result.forever) {
throw new Error(
"Caching has already been configured with .forever()",
);
}
result.never = true;
result.configured = true;
},
using<T>(handler: () => T): T {
if (!active) {
throw new Error(
"Cannot change caching after evaluation has completed.",
);
}
if (result.never || result.forever) {
throw new Error(
"Caching has already been configured with .never or .forever()",
);
}
result.configured = true;
constructor(data: SideChannel) {
this._data = data;
}
const key = handler();
pairs.push([key, handler]);
return key;
},
invalidate<T>(handler: () => T): T {
if (!active) {
throw new Error(
"Cannot change caching after evaluation has completed.",
);
}
if (result.never || result.forever) {
throw new Error(
"Caching has already been configured with .never or .forever()",
);
}
result.invalidate = true;
result.configured = true;
simple() {
return makeSimpleConfigurator(this);
}
const key = handler();
pairs.push([key, handler]);
return key;
},
}: CacheConfiguratorObj),
);
mode() {
if (this._never) return "never";
if (this._forever) return "forever";
if (this._invalidate) return "invalidate";
return "valid";
}
return { cache, result, deactivate };
forever() {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._never) {
throw new Error("Caching has already been configured with .never()");
}
this._forever = true;
this._configured = true;
}
never() {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._forever) {
throw new Error("Caching has already been configured with .forever()");
}
this._never = true;
this._configured = true;
}
using<T>(handler: SideChannel => T): T {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._never || this._forever) {
throw new Error(
"Caching has already been configured with .never or .forever()",
);
}
this._configured = true;
const key = handler(this._data);
this._pairs.push([key, handler]);
return key;
}
invalidate<T>(handler: SideChannel => T): T {
if (!this._active) {
throw new Error("Cannot change caching after evaluation has completed.");
}
if (this._never || this._forever) {
throw new Error(
"Caching has already been configured with .never or .forever()",
);
}
this._invalidate = true;
this._configured = true;
const key = handler(this._data);
this._pairs.push([key, handler]);
return key;
}
validator(): SideChannel => boolean {
const pairs = this._pairs;
return (data: SideChannel) => pairs.every(([key, fn]) => key === fn(data));
}
deactivate() {
this._active = false;
}
configured() {
return this._configured;
}
}
function makeSimpleConfigurator(
cache: CacheConfigurator<any>,
): SimpleCacheConfigurator {
function cacheFn(val) {
if (typeof val === "boolean") {
if (val) cache.forever();
else cache.never();
return;
}
return cache.using(val);
}
cacheFn.forever = () => cache.forever();
cacheFn.never = () => cache.never();
cacheFn.using = cb => cache.using(() => cb());
cacheFn.invalidate = cb => cache.invalidate(() => cb());
return (cacheFn: any);
}

View File

@@ -5,8 +5,7 @@ import path from "path";
import fs from "fs";
import json5 from "json5";
import resolve from "resolve";
import { getEnv } from "../../helpers/environment";
import { makeStrongCache } from "../../caching";
import { makeStrongCache, type CacheConfigurator } from "../../caching";
const debug = buildDebug("babel:config:loading:files:configuration");
@@ -21,7 +20,10 @@ const BABELRC_JS_FILENAME = ".babelrc.js";
const PACKAGE_FILENAME = "package.json";
const BABELIGNORE_FILENAME = ".babelignore";
export function findConfigs(dirname: string): Array<ConfigFile> {
export function findConfigs(
dirname: string,
envName: string,
): Array<ConfigFile> {
let foundConfig = false;
let foundIgnore = false;
@@ -47,7 +49,7 @@ export function findConfigs(dirname: string): Array<ConfigFile> {
PACKAGE_FILENAME,
].reduce((previousConfig: ConfigFile | null, name) => {
const filepath = path.join(loc, name);
const config = readConfig(filepath);
const config = readConfig(filepath, envName);
if (config && previousConfig) {
throw new Error(
@@ -77,10 +79,14 @@ export function findConfigs(dirname: string): Array<ConfigFile> {
return confs;
}
export function loadConfig(name: string, dirname: string): ConfigFile {
export function loadConfig(
name: string,
dirname: string,
envName: string,
): ConfigFile {
const filepath = resolve.sync(name, { basedir: dirname });
const conf = readConfig(filepath);
const conf = readConfig(filepath, envName);
if (!conf) {
throw new Error(`Config file ${filepath} contains no configuration data`);
}
@@ -93,72 +99,86 @@ export function loadConfig(name: string, dirname: string): ConfigFile {
* 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) {
function readConfig(filepath, envName) {
return path.extname(filepath) === ".js"
? readConfigJS(filepath)
? readConfigJS(filepath, { envName })
: readConfigFile(filepath);
}
const LOADING_CONFIGS = new Set();
const readConfigJS = makeStrongCache((filepath, cache) => {
if (!fs.existsSync(filepath)) {
cache.forever();
return null;
}
// The `require()` call below can make this code reentrant if a require hook like @babel/register has been
// loaded into the system. That would cause Babel to attempt to compile the `.babelrc.js` file as it loads
// below. To cover this case, we auto-ignore re-entrant config processing.
if (LOADING_CONFIGS.has(filepath)) {
cache.never();
const readConfigJS = makeStrongCache(
(filepath, cache: CacheConfigurator<{ envName: string }>) => {
if (!fs.existsSync(filepath)) {
cache.forever();
return null;
}
// The `require()` call below can make this code reentrant if a require hook like @babel/register has been
// loaded into the system. That would cause Babel to attempt to compile the `.babelrc.js` file as it loads
// below. To cover this case, we auto-ignore re-entrant config processing.
if (LOADING_CONFIGS.has(filepath)) {
cache.never();
debug("Auto-ignoring usage of config %o.", filepath);
return {
filepath,
dirname: path.dirname(filepath),
options: {},
};
}
let options;
try {
LOADING_CONFIGS.add(filepath);
// $FlowIssue
const configModule = (require(filepath): mixed);
options =
configModule && configModule.__esModule
? configModule.default || undefined
: configModule;
} catch (err) {
err.message = `${filepath}: Error while loading config - ${err.message}`;
throw err;
} finally {
LOADING_CONFIGS.delete(filepath);
}
if (typeof options === "function") {
options = options({
cache: cache.simple(),
// Expose ".env()" so people can easily get the same env that we expose using the "env" key.
env: () => cache.using(data => data.envName),
async: () => false,
});
if (!cache.configured()) throwConfigError();
}
if (!options || typeof options !== "object" || Array.isArray(options)) {
throw new Error(
`${filepath}: Configuration should be an exported JavaScript object.`,
);
}
if (typeof options.then === "function") {
throw new Error(
`You appear to be using an async configuration, ` +
`which your current version of Babel does not support. ` +
`We may add support for this in the future, ` +
`but if you're on the most recent version of @babel/core and still ` +
`seeing this error, then you'll need to synchronously return your config.`,
);
}
debug("Auto-ignoring usage of config %o.", filepath);
return {
filepath,
dirname: path.dirname(filepath),
options: {},
options,
};
}
let options;
try {
LOADING_CONFIGS.add(filepath);
// $FlowIssue
const configModule = (require(filepath): mixed);
options =
configModule && configModule.__esModule
? configModule.default || undefined
: configModule;
} catch (err) {
err.message = `${filepath}: Error while loading config - ${err.message}`;
throw err;
} finally {
LOADING_CONFIGS.delete(filepath);
}
if (typeof options === "function") {
options = options({
cache,
// Expose ".env()" so people can easily get the same env that we expose using the "env" key.
env: () => cache.using(() => getEnv()),
});
} else {
cache.forever();
}
if (!options || typeof options !== "object" || Array.isArray(options)) {
throw new Error(
`${filepath}: Configuration should be an exported JavaScript object.`,
);
}
return {
filepath,
dirname: path.dirname(filepath),
options,
};
}, false /* autoPermacache */);
},
);
const readConfigFile = makeStaticFileCache((filepath, content) => {
let options;
@@ -228,3 +248,40 @@ function fileMtime(filepath: string): number | null {
return null;
}
function throwConfigError() {
throw new Error(`\
Caching was left unconfigured. Babel's plugins, presets, and .babelrc.js files can be configured
for various types of caching, using the first param of their handler functions:
module.exports = function(api) {
// The API exposes the following:
// Cache the returned value forever and don't call this function again.
api.cache(true);
// Don't cache at all. Not recommended because it will be very slow.
api.cache(false);
// Cached based on the value of some function. If this function returns a value different from
// a previously-encountered value, the plugins will re-evaluate.
var env = api.cache(() => process.env.NODE_ENV);
// If testing for a specific env, we recommend specifics to avoid instantiating a plugin for
// any possible NODE_ENV value that might come up during plugin execution.
var isProd = api.cache(() => process.env.NODE_ENV === "production");
// .cache(fn) will perform a linear search though instances to find the matching plugin based
// based on previous instantiated plugins. If you want to recreate the plugin and discard the
// previous instance whenever something changes, you may use:
var isProd = api.cache.invalidate(() => process.env.NODE_ENV === "production");
// Note, we also expose the following more-verbose versions of the above examples:
api.cache.forever(); // api.cache(true)
api.cache.never(); // api.cache(false)
api.cache.using(fn); // api.cache(fn)
// Return the value that will be cached.
return { };
};`);
}

View File

@@ -146,16 +146,31 @@ function assertPluginItem(
if (value.length === 0) {
throw new Error(`.${key}[${index}] must include an object`);
}
if (value.length > 2) {
throw new Error(`.${key}[${index}] may only be a two-tuple`);
if (value.length > 3) {
throw new Error(
`.${key}[${index}] may only be a two-tuple or three-tuple`,
);
}
assertPluginTarget(key, index, true, value[0]);
if (value.length === 2) {
if (value.length > 1) {
const opts = value[1];
if (opts != null && (typeof opts !== "object" || Array.isArray(opts))) {
throw new Error(`.${key}[${index}][1] must be an object, or undefined`);
if (
opts !== undefined &&
opts !== false &&
(typeof opts !== "object" || Array.isArray(opts))
) {
throw new Error(
`.${key}[${index}][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`);
}
}
} else {

View File

@@ -1,12 +1,13 @@
// @flow
import path from "path";
import * as context from "../index";
import Plugin, { validatePluginObject } from "./plugin";
import merge from "lodash/merge";
import buildConfigChain, { type ConfigItem } from "./build-config-chain";
import traverse from "@babel/traverse";
import clone from "lodash/clone";
import { makeWeakCache } from "./caching";
import { makeWeakCache, type CacheConfigurator } from "./caching";
import { getEnv } from "./helpers/environment";
import { validate, type ValidatedOptions, type PluginItem } from "./options";
@@ -29,13 +30,9 @@ export default function manageOptions(opts: {}): {
}
class OptionManager {
constructor() {
this.options = {};
this.passes = [[]];
}
options: ValidatedOptions;
passes: Array<Array<Plugin>>;
optionDefaults: ValidatedOptions = {};
options: ValidatedOptions = {};
passes: Array<Array<Plugin>> = [[]];
/**
* This is called when we want to merge the input `opts` into the
@@ -45,32 +42,47 @@ class OptionManager {
* - `loc` is used to point to the original config.
* - `dirname` is used to resolve plugins relative to it.
*/
mergeOptions(config: MergeOptions, pass?: Array<Plugin>) {
const result = loadConfig(config);
const plugins = result.plugins.map(descriptor =>
loadPluginDescriptor(descriptor),
mergeOptions(
config: {
plugins: Array<BasicDescriptor>,
presets: Array<BasicDescriptor>,
},
pass: Array<Plugin>,
envName: string,
) {
const plugins = config.plugins.map(descriptor =>
loadPluginDescriptor(descriptor, envName),
);
const presets = result.presets.map(descriptor =>
loadPresetDescriptor(descriptor),
);
const passPerPreset = config.options.passPerPreset;
pass = pass || this.passes[0];
const presets = config.presets.map(descriptor => {
return {
preset: loadPresetDescriptor(descriptor, envName),
pass: descriptor.ownPass ? [] : pass,
};
});
// resolve presets
if (presets.length > 0) {
let presetPasses = null;
if (passPerPreset) {
presetPasses = presets.map(() => []);
// The passes are created in the same order as the preset list, but are inserted before any
// existing additional passes.
this.passes.splice(1, 0, ...presetPasses);
}
// The passes are created in the same order as the preset list, but are inserted before any
// existing additional passes.
this.passes.splice(
1,
0,
...presets.map(o => o.pass).filter(p => p !== pass),
);
presets.forEach((presetConfig, i) => {
this.mergeOptions(presetConfig, presetPasses ? presetPasses[i] : pass);
presets.forEach(({ preset, pass }) => {
const loadedConfig = loadConfig(preset);
this.mergeOptions(
{
// Call dedupDescriptors() to remove 'false' descriptors.
plugins: dedupDescriptors(loadedConfig.plugins),
presets: dedupDescriptors(loadedConfig.presets),
},
pass,
envName,
);
merge(this.optionDefaults, normalizeOptions(loadedConfig.options));
});
}
@@ -78,34 +90,36 @@ class OptionManager {
if (plugins.length > 0) {
pass.unshift(...plugins);
}
}
const options = Object.assign({}, result.options);
delete options.extends;
delete options.env;
delete options.plugins;
delete options.presets;
delete options.passPerPreset;
mergeConfigChain(chain: $ReadOnlyArray<MergeOptions>, envName: string) {
const config = dedupLoadedConfigs(chain.map(config => loadConfig(config)));
// "sourceMap" is just aliased to sourceMap, so copy it over as
// we merge the options together.
if (options.sourceMap) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}
this.mergeOptions(
{
plugins: config.plugins,
presets: config.presets,
},
this.passes[0],
envName,
);
merge(this.options, options);
config.options.forEach(opts => {
merge(this.options, normalizeOptions(opts));
});
}
init(inputOpts: {}) {
const args = validate("arguments", inputOpts);
const configChain = buildConfigChain(args);
const { envName = getEnv(), cwd = "." } = args;
const absoluteCwd = path.resolve(cwd);
const configChain = buildConfigChain(absoluteCwd, args, envName);
if (!configChain) return null;
try {
for (const config of configChain) {
this.mergeOptions(config);
}
this.mergeConfigChain(configChain, envName);
} catch (e) {
// There are a few case where thrown errors will try to annotate themselves multiple times, so
// to keep things simple we just bail out if re-wrapping the message.
@@ -116,7 +130,7 @@ class OptionManager {
throw e;
}
const opts: Object = this.options;
const opts: Object = merge(this.optionDefaults, this.options);
// Tack the passes onto the object itself so that, if this object is passed back to Babel a second time,
// it will be in the right structure to not change behavior.
@@ -127,6 +141,8 @@ class OptionManager {
.filter(plugins => plugins.length > 0)
.map(plugins => ({ plugins }));
opts.passPerPreset = opts.presets.length > 0;
opts.envName = envName;
opts.cwd = absoluteCwd;
return {
options: opts,
@@ -135,11 +151,32 @@ class OptionManager {
}
}
function normalizeOptions(opts: ValidatedOptions): ValidatedOptions {
const options = Object.assign({}, opts);
delete options.extends;
delete options.env;
delete options.plugins;
delete options.presets;
delete options.passPerPreset;
delete options.ignore;
delete options.only;
// "sourceMap" is just aliased to sourceMap, so copy it over as
// we merge the options together.
if (options.sourceMap) {
options.sourceMaps = options.sourceMap;
delete options.sourceMap;
}
return options;
}
type BasicDescriptor = {
name: string | void,
value: {} | Function,
options: {} | void,
options: {} | void | false,
dirname: string,
alias: string,
ownPass?: boolean,
};
type LoadedDescriptor = {
@@ -149,14 +186,16 @@ type LoadedDescriptor = {
alias: string,
};
type LoadedConfig = {
options: ValidatedOptions,
plugins: Array<BasicDescriptor>,
presets: Array<BasicDescriptor>,
};
/**
* Load and validate the given config into a set of options, plugins, and presets.
*/
const loadConfig = makeWeakCache((config: MergeOptions): {
options: {},
plugins: Array<BasicDescriptor>,
presets: Array<BasicDescriptor>,
} => {
const loadConfig = makeWeakCache((config: MergeOptions): LoadedConfig => {
const options = config.options;
const plugins = (config.options.plugins || []).map((plugin, index) =>
@@ -166,29 +205,139 @@ const loadConfig = makeWeakCache((config: MergeOptions): {
}),
);
assertNoDuplicates(plugins);
const presets = (config.options.presets || []).map((preset, index) =>
createDescriptor(preset, loadPreset, config.dirname, {
index,
alias: config.alias,
ownPass: options.passPerPreset,
}),
);
assertNoDuplicates(presets);
return { options, plugins, presets };
});
function assertNoDuplicates(items: Array<BasicDescriptor>): void {
const map = new Map();
for (const item of items) {
if (typeof item.value !== "function") continue;
let nameMap = map.get(item.value);
if (!nameMap) {
nameMap = new Set();
map.set(item.value, nameMap);
}
if (nameMap.has(item.name)) {
throw new Error(
[
`Duplicate plugin/preset detected.`,
`If you'd like to use two separate instances of a plugin,`,
`they neen separate names, e.g.`,
``,
` plugins: [`,
` ['some-plugin', {}],`,
` ['some-plugin', {}, 'some unique name'],`,
` ]`,
].join("\n"),
);
}
nameMap.add(item.name);
}
}
function dedupLoadedConfigs(
items: Array<LoadedConfig>,
): {
plugins: Array<BasicDescriptor>,
presets: Array<BasicDescriptor>,
options: Array<ValidatedOptions>,
} {
const options = [];
const plugins = [];
const presets = [];
for (const item of items) {
plugins.push(...item.plugins);
presets.push(...item.presets);
options.push(item.options);
}
return {
options,
plugins: dedupDescriptors(plugins),
presets: dedupDescriptors(presets),
};
}
function dedupDescriptors(
items: Array<BasicDescriptor>,
): Array<BasicDescriptor> {
const map: Map<
Function,
Map<string | void, { value: BasicDescriptor | null }>,
> = new Map();
const descriptors = [];
for (const item of items) {
if (typeof item.value === "function") {
const fnKey = item.value;
let nameMap = map.get(fnKey);
if (!nameMap) {
nameMap = new Map();
map.set(fnKey, nameMap);
}
let desc = nameMap.get(item.name);
if (!desc) {
desc = { value: null };
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;
}
} else {
descriptors.push({ value: item });
}
}
return descriptors.reduce((acc, desc) => {
if (desc.value) acc.push(desc.value);
return acc;
}, []);
}
/**
* Load a generic plugin/preset from the given descriptor loaded from the config object.
*/
const loadDescriptor = makeWeakCache(
(
{ value, options = {}, dirname, alias }: BasicDescriptor,
cache,
{ value, options, dirname, alias }: BasicDescriptor,
cache: CacheConfigurator<{ envName: string }>,
): LoadedDescriptor => {
// Disabled presets should already have been filtered out
if (options === false) throw new Error("Assertion failure");
options = options || {};
let item = value;
if (typeof value === "function") {
const api = Object.assign(Object.create(context), {
cache,
env: () => cache.using(() => getEnv()),
cache: cache.simple(),
env: () => cache.using(data => data.envName),
async: () => false,
});
try {
@@ -205,6 +354,15 @@ const loadDescriptor = makeWeakCache(
throw new Error("Plugin/Preset did not return an object.");
}
if (typeof item.then === "function") {
throw new Error(
`You appear to be using an async plugin, ` +
`which your current version of Babel does not support.` +
`If you're using a published plugin, ` +
`you may need to upgrade your @babel/core version.`,
);
}
return { value: item, options, dirname, alias };
},
);
@@ -212,7 +370,10 @@ const loadDescriptor = makeWeakCache(
/**
* Instantiate a plugin for the given descriptor, returning the plugin/options pair.
*/
function loadPluginDescriptor(descriptor: BasicDescriptor): Plugin {
function loadPluginDescriptor(
descriptor: BasicDescriptor,
envName: string,
): Plugin {
if (descriptor.value instanceof Plugin) {
if (descriptor.options) {
throw new Error(
@@ -223,11 +384,16 @@ function loadPluginDescriptor(descriptor: BasicDescriptor): Plugin {
return descriptor.value;
}
return instantiatePlugin(loadDescriptor(descriptor));
return instantiatePlugin(loadDescriptor(descriptor, { envName }), {
envName,
});
}
const instantiatePlugin = makeWeakCache(
({ value, options, dirname, alias }: LoadedDescriptor, cache): Plugin => {
(
{ value, options, dirname, alias }: LoadedDescriptor,
cache: CacheConfigurator<{ envName: string }>,
): Plugin => {
const pluginObj = validatePluginObject(value);
const plugin = Object.assign({}, pluginObj);
@@ -237,6 +403,7 @@ const instantiatePlugin = makeWeakCache(
if (plugin.inherits) {
const inheritsDescriptor = {
name: undefined,
alias: `${alias}$inherits`,
value: plugin.inherits,
options,
@@ -244,8 +411,8 @@ const instantiatePlugin = makeWeakCache(
};
// If the inherited plugin changes, reinstantiate this plugin.
const inherits = cache.invalidate(() =>
loadPluginDescriptor(inheritsDescriptor),
const inherits = cache.invalidate(data =>
loadPluginDescriptor(inheritsDescriptor, data.envName),
);
plugin.pre = chain(inherits.pre, plugin.pre);
@@ -267,8 +434,11 @@ const instantiatePlugin = makeWeakCache(
/**
* Generate a config object that will act as the root of a new nested config.
*/
const loadPresetDescriptor = (descriptor: BasicDescriptor): MergeOptions => {
return instantiatePreset(loadDescriptor(descriptor));
const loadPresetDescriptor = (
descriptor: BasicDescriptor,
envName: string,
): MergeOptions => {
return instantiatePreset(loadDescriptor(descriptor, { envName }));
};
const instantiatePreset = makeWeakCache(
@@ -292,15 +462,23 @@ function createDescriptor(
{
index,
alias,
ownPass,
}: {
index: number,
alias: string,
ownPass?: boolean,
},
): BasicDescriptor {
let name;
let options;
let value = pair;
if (Array.isArray(value)) {
[value, options] = value;
if (value.length === 3) {
// $FlowIgnore - Flow doesn't like the multiple tuple types.
[value, options, name] = value;
} else {
[value, options] = value;
}
}
let filepath = null;
@@ -335,18 +513,13 @@ function createDescriptor(
);
}
if (options != null && typeof options !== "object") {
throw new Error(
"Plugin/Preset options must be an object, null, or undefined",
);
}
options = options || undefined;
return {
name,
alias: filepath || `${alias}$${index}`,
value,
options,
dirname,
ownPass,
};
}

View File

@@ -17,6 +17,7 @@ import {
} from "./option-assertions";
const ROOT_VALIDATORS: ValidatorSet = {
cwd: (assertString: Validator<$PropertyType<ValidatedOptions, "cwd">>),
filename: (assertString: Validator<
$PropertyType<ValidatedOptions, "filename">,
>),
@@ -28,6 +29,10 @@ const ROOT_VALIDATORS: ValidatorSet = {
>),
code: (assertBoolean: Validator<$PropertyType<ValidatedOptions, "code">>),
ast: (assertBoolean: Validator<$PropertyType<ValidatedOptions, "ast">>),
envName: (assertString: Validator<
$PropertyType<ValidatedOptions, "envName">,
>),
};
const NONPRESET_VALIDATORS: ValidatorSet = {
@@ -124,12 +129,14 @@ const COMMON_VALIDATORS: ValidatorSet = {
export type InputOptions = ValidatedOptions;
export type ValidatedOptions = {
cwd?: string,
filename?: string,
filenameRelative?: string,
babelrc?: boolean,
code?: boolean,
ast?: boolean,
inputSourceMap?: RootInputSourceMapOption,
envName?: string,
extends?: string,
env?: EnvSet<ValidatedOptions>,
@@ -180,8 +187,13 @@ export type EnvSet<T> = {
export type IgnoreItem = string | Function | RegExp;
export type IgnoreList = $ReadOnlyArray<IgnoreItem>;
export type PluginOptions = {} | void | false;
export type PluginTarget = string | {} | Function;
export type PluginItem = PluginTarget | [PluginTarget, {} | void];
export type PluginItem =
| Plugin
| PluginTarget
| [PluginTarget, PluginOptions]
| [PluginTarget, PluginOptions, string];
export type PluginList = $ReadOnlyArray<PluginItem>;
export type SourceMapsOption = boolean | "inline" | "both";
@@ -201,6 +213,9 @@ export function validate(type: OptionsType, opts: {}): ValidatedOptions {
if (type !== "arguments" && ROOT_VALIDATORS[key]) {
throw new Error(`.${key} is only allowed in root programmatic options`);
}
if (type === "env" && key === "env") {
throw new Error(`.${key} is not allowed inside another env block`);
}
const validator =
COMMON_VALIDATORS[key] ||

View File

@@ -8,13 +8,14 @@ export default function transformFileSync(
filename: string,
opts: ?InputOptions,
): FileResult | null {
let options;
if (opts == null) {
opts = { filename };
options = { filename };
} else if (opts && typeof opts === "object") {
opts = Object.assign(opts, { filename });
options = Object.assign({}, opts, { filename });
}
const config = loadConfig(opts);
const config = loadConfig(options);
if (config === null) return null;
return runSync(config, fs.readFileSync(filename, "utf8"));

View File

@@ -10,21 +10,22 @@ type TransformFile = {
};
export default ((function transformFile(filename, opts, callback) {
let options;
if (typeof opts === "function") {
callback = opts;
opts = undefined;
}
if (opts == null) {
opts = { filename };
options = { filename };
} else if (opts && typeof opts === "object") {
opts = Object.assign(opts, { filename });
options = Object.assign({}, opts, { filename });
}
process.nextTick(() => {
let cfg;
try {
cfg = loadConfig(opts);
cfg = loadConfig(options);
if (cfg === null) return callback(null, null);
} catch (err) {
return callback(err);

View File

@@ -38,6 +38,15 @@ export default function generateCode(
result = generate(ast, opts.generatorOpts, code);
} else if (results.length === 1) {
result = results[0];
if (typeof result.then === "function") {
throw new Error(
`You appear to be using an async parser plugin, ` +
`which your current version of Babel does not support. ` +
`If you're using a published plugin, ` +
`you may need to upgrade your @babel/core version.`,
);
}
} else {
throw new Error("More than one plugin attempted to override codegen.");
}

View File

@@ -86,7 +86,18 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
for (const [plugin, pass] of passPairs) {
const fn = plugin.pre;
if (fn) fn.call(pass, file);
if (fn) {
const result = fn.call(pass, file);
if (isThenable(result)) {
throw new Error(
`You appear to be using an plugin with an async .pre, ` +
`which your current version of Babel does not support.` +
`If you're using a published plugin, you may need to upgrade ` +
`your @babel/core version.`,
);
}
}
}
// merge all plugin visitors into a single visitor
@@ -99,7 +110,26 @@ function transformFile(file: File, pluginPasses: PluginPasses): void {
for (const [plugin, pass] of passPairs) {
const fn = plugin.post;
if (fn) fn.call(pass, file);
if (fn) {
const result = fn.call(pass, file);
if (isThenable(result)) {
throw new Error(
`You appear to be using an plugin with an async .post, ` +
`which your current version of Babel does not support.` +
`If you're using a published plugin, you may need to upgrade ` +
`your @babel/core version.`,
);
}
}
}
}
}
function isThenable(val: mixed): boolean {
return (
!!val &&
(typeof val === "object" || typeof val === "function") &&
typeof val.then === "function"
);
}

View File

@@ -76,6 +76,14 @@ function parser(pluginPasses, options, code) {
if (results.length === 0) {
return parse(code, options.parserOpts);
} else if (results.length === 1) {
if (typeof results[0].then === "function") {
throw new Error(
`You appear to be using an async codegen plugin, ` +
`which your current version of Babel does not support. ` +
`If you're using a published plugin, you may need to upgrade ` +
`your @babel/core version.`,
);
}
return results[0];
}
throw new Error("More than one plugin attempted to override parsing.");

View File

@@ -41,9 +41,9 @@ export default function normalizeOptions(config: ResolvedConfig): {} {
auxiliaryCommentAfter: opts.auxiliaryCommentAfter,
retainLines: opts.retainLines,
comments,
shouldPrintComment: opts.shouldPrintComment,
compact,
minified: opts.minified,
concise: opts.concise,
// Source-map generation flags.
sourceMaps,

View File

@@ -118,26 +118,33 @@ describe("api", function() {
});
it("transformFile", function(done) {
babel.transformFile(
__dirname + "/fixtures/api/file.js",
{
babelrc: false,
},
function(err, res) {
if (err) return done(err);
assert.equal(res.code, "foo();");
done();
},
);
const options = {
babelrc: false,
};
Object.freeze(options);
babel.transformFile(__dirname + "/fixtures/api/file.js", options, function(
err,
res,
) {
if (err) return done(err);
assert.equal(res.code, "foo();");
// keep user options untouched
assert.deepEqual(options, { babelrc: false });
done();
});
});
it("transformFileSync", function() {
const options = {
babelrc: false,
};
Object.freeze(options);
assert.equal(
babel.transformFileSync(__dirname + "/fixtures/api/file.js", {
babelrc: false,
}).code,
babel.transformFileSync(__dirname + "/fixtures/api/file.js", options)
.code,
"foo();",
);
assert.deepEqual(options, { babelrc: false });
});
it("options throw on falsy true", function() {
@@ -296,12 +303,6 @@ describe("api", function() {
development: {
passPerPreset: true,
presets: [pushPreset("argthree"), pushPreset("argfour")],
env: {
development: {
passPerPreset: true,
presets: [pushPreset("argfive"), pushPreset("argsix")],
},
},
},
},
});
@@ -309,32 +310,30 @@ describe("api", function() {
assert.equal(
result.code,
[
"argtwo;",
"argone;",
"eleven;",
"twelve;",
"thirteen;",
"fourteen;",
"seventeen;",
"eighteen;",
"one;",
"two;",
"eleven;",
"twelve;",
"argtwo;",
"argone;",
"five;",
"six;",
"three;",
"four;",
"seventeen;",
"eighteen;",
"nineteen;",
"twenty;",
"thirteen;",
"fourteen;",
"fifteen;",
"sixteen;",
"argfive;",
"argsix;",
"argthree;",
"argfour;",
"seven;",
"eight;",
"nine;",
"ten;",
"argthree;",
"argfour;",
].join("\n"),
);
});

View File

@@ -19,23 +19,6 @@ describe("caching API", () => {
assert.notEqual(fn("one"), fn("two"));
});
it("should allow permacaching with cache(true)", () => {
let count = 0;
const fn = makeStrongCache((arg, cache) => {
cache(true);
return { arg, count: count++ };
});
assert.deepEqual(fn("one"), { arg: "one", count: 0 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", count: 1 });
assert.equal(fn("two"), fn("two"));
assert.notEqual(fn("one"), fn("two"));
});
it("should allow disabling caching with .never()", () => {
let count = 0;
@@ -55,25 +38,6 @@ describe("caching API", () => {
assert.notEqual(fn("one"), fn("two"));
});
it("should allow disabling caching with cache(false)", () => {
let count = 0;
const fn = makeStrongCache((arg, cache) => {
cache(false);
return { arg, count: count++ };
});
assert.deepEqual(fn("one"), { arg: "one", count: 0 });
assert.deepEqual(fn("one"), { arg: "one", count: 1 });
assert.notEqual(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", count: 4 });
assert.deepEqual(fn("two"), { arg: "two", count: 5 });
assert.notEqual(fn("two"), fn("two"));
assert.notEqual(fn("one"), fn("two"));
});
it("should allow caching based on a value with .using(fn)", () => {
let count = 0;
let other = "default";
@@ -115,47 +79,6 @@ describe("caching API", () => {
assert.equal(fn("two"), fn("two"));
});
it("should allow caching based on a value with cache(fn)", () => {
let count = 0;
let other = "default";
const fn = makeStrongCache((arg, cache) => {
const val = cache(() => other);
return { arg, val, count: count++ };
});
assert.deepEqual(fn("one"), { arg: "one", val: "default", count: 0 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "default", count: 1 });
assert.equal(fn("two"), fn("two"));
other = "new";
assert.deepEqual(fn("one"), { arg: "one", val: "new", count: 2 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "new", count: 3 });
assert.equal(fn("two"), fn("two"));
other = "default";
assert.deepEqual(fn("one"), { arg: "one", val: "default", count: 0 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "default", count: 1 });
assert.equal(fn("two"), fn("two"));
other = "new";
assert.deepEqual(fn("one"), { arg: "one", val: "new", count: 2 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "new", count: 3 });
assert.equal(fn("two"), fn("two"));
});
it("should allow invalidation based on a value with .invalidate(fn)", () => {
let count = 0;
let other = "default";
@@ -298,12 +221,6 @@ describe("caching API", () => {
assert.equal(fn("two"), fn("two"));
});
it("should throw if caching is never configured and not defaulting", () => {
const fn = makeStrongCache(() => {}, false /* autoPermacache */);
assert.throws(() => fn(), /Error: Caching was left unconfigured./);
});
it("should auto-permacache by default", () => {
let count = 0;
@@ -410,4 +327,89 @@ describe("caching API", () => {
/Cannot change caching after evaluation/,
);
});
describe("simple", () => {
it("should allow permacaching with cache(true)", () => {
let count = 0;
const fn = makeStrongCache((arg, cache) => {
cache = cache.simple();
cache(true);
return { arg, count: count++ };
});
assert.deepEqual(fn("one"), { arg: "one", count: 0 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", count: 1 });
assert.equal(fn("two"), fn("two"));
assert.notEqual(fn("one"), fn("two"));
});
it("should allow disabling caching with cache(false)", () => {
let count = 0;
const fn = makeStrongCache((arg, cache) => {
cache = cache.simple();
cache(false);
return { arg, count: count++ };
});
assert.deepEqual(fn("one"), { arg: "one", count: 0 });
assert.deepEqual(fn("one"), { arg: "one", count: 1 });
assert.notEqual(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", count: 4 });
assert.deepEqual(fn("two"), { arg: "two", count: 5 });
assert.notEqual(fn("two"), fn("two"));
assert.notEqual(fn("one"), fn("two"));
});
it("should allow caching based on a value with cache(fn)", () => {
let count = 0;
let other = "default";
const fn = makeStrongCache((arg, cache) => {
cache = cache.simple();
const val = cache(() => other);
return { arg, val, count: count++ };
});
assert.deepEqual(fn("one"), { arg: "one", val: "default", count: 0 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "default", count: 1 });
assert.equal(fn("two"), fn("two"));
other = "new";
assert.deepEqual(fn("one"), { arg: "one", val: "new", count: 2 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "new", count: 3 });
assert.equal(fn("two"), fn("two"));
other = "default";
assert.deepEqual(fn("one"), { arg: "one", val: "default", count: 0 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "default", count: 1 });
assert.equal(fn("two"), fn("two"));
other = "new";
assert.deepEqual(fn("one"), { arg: "one", val: "new", count: 2 });
assert.equal(fn("one"), fn("one"));
assert.deepEqual(fn("two"), { arg: "two", val: "new", count: 3 });
assert.equal(fn("two"), fn("two"));
});
});
});

File diff suppressed because it is too large Load Diff

View File

@@ -42,10 +42,10 @@ describe("@babel/core config loading", () => {
const options1 = loadConfig(opts).options;
expect(options1.plugins.map(p => p.key)).to.eql([
"plugin6",
"plugin5",
"plugin1",
"plugin2",
"plugin6",
"plugin5",
"plugin4",
"plugin3",
]);
@@ -86,7 +86,7 @@ describe("@babel/core config loading", () => {
expect(options2.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options1.plugins.length; i++) {
if (i === 2) {
if (i === 0) {
expect(options2.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options2.plugins[i]).to.equal(options1.plugins[i]);
@@ -99,7 +99,7 @@ describe("@babel/core config loading", () => {
expect(options3.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options1.plugins.length; i++) {
if (i === 2 || i === 5) {
if (i === 0 || i === 5) {
expect(options3.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options3.plugins[i]).to.equal(options1.plugins[i]);
@@ -150,7 +150,7 @@ describe("@babel/core config loading", () => {
expect(options2.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options1.plugins.length; i++) {
if (i === 2 || i === 3 || i === 4 || i === 5 || i === 6) {
if (i === 0 || i === 1 || i === 4 || i === 5 || i === 6) {
expect(options2.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options2.plugins[i]).to.equal(options1.plugins[i]);
@@ -185,7 +185,7 @@ describe("@babel/core config loading", () => {
expect(options2.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options2.plugins.length; i++) {
if (i === 0) {
if (i === 2) {
expect(options2.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options2.plugins[i]).to.equal(options1.plugins[i]);
@@ -205,7 +205,7 @@ describe("@babel/core config loading", () => {
expect(options2.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options2.plugins.length; i++) {
if (i === 1) {
if (i === 3) {
expect(options2.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options2.plugins[i]).to.equal(options1.plugins[i]);
@@ -224,7 +224,7 @@ describe("@babel/core config loading", () => {
expect(options2.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options1.plugins.length; i++) {
if (i === 0) {
if (i === 2) {
expect(options2.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options2.plugins[i]).to.equal(options1.plugins[i]);
@@ -243,7 +243,7 @@ describe("@babel/core config loading", () => {
expect(options2.plugins.length).to.equal(options1.plugins.length);
for (let i = 0; i < options1.plugins.length; i++) {
if (i === 1) {
if (i === 3) {
expect(options2.plugins[i]).not.to.equal(options1.plugins[i]);
} else {
expect(options2.plugins[i]).to.equal(options1.plugins[i]);

View File

@@ -1 +0,0 @@
root-ignore

View File

@@ -1,4 +0,0 @@
{
"plugins": ["root"],
"extends": "./extended.babelrc.json"
}

View File

@@ -18,4 +18,5 @@ seventeen.js
eighteen.js
nineteen.js
twenty.js
plugin.js
**/plugin.js

View File

@@ -2,6 +2,8 @@ module.exports = function(api) {
api.env();
return {
comments: false,
plugins: [
require("./plugin"),
],
};
}

View File

@@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@@ -1,3 +1,3 @@
{
comments: false,
plugins: ["./plugin"],
}

View File

@@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@@ -1,5 +1,5 @@
{
"babel": {
"comments": false
"plugins": ["./plugin"]
}
}

View File

@@ -0,0 +1,3 @@
module.exports = function() {
return {};
};

View File

@@ -0,0 +1 @@
# Placeholder so the monorepo ignore isn't accessed

View File

@@ -0,0 +1 @@
src.js

View File

@@ -0,0 +1 @@
{45

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
{}

View File

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

View File

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

View File

@@ -0,0 +1 @@
{}

View File

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

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,5 +0,0 @@
{
"plugins": [
"dir2"
]
}

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,5 +0,0 @@
{
"name": "application-name",
"version": "0.0.1"
}

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,11 +0,0 @@
{
"plugins": ["env-base"],
"env": {
"foo": {
"plugins": ["env-foo"]
},
"bar": {
"plugins": ["env-bar"]
}
}
}

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,5 +0,0 @@
{
"plugins": [
"extended"
]
}

View File

@@ -1,6 +0,0 @@
{
ignore: [
"*",
"!folder",
],
}

View File

@@ -1,2 +0,0 @@
# Blank .gitignore to ensure this directory exists.
!.gitignore

View File

@@ -1,6 +0,0 @@
{
ignore: [
"*",
"!src.js",
],
}

View File

@@ -1,10 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var plugins = ["foo", "bar"];
exports.default = {
plugins: plugins
};

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,2 +0,0 @@
throw new Error("Something bad happened!");
module.exports = {}

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1 +0,0 @@
module.exports = '';

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1 +0,0 @@
module.exports = null;

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,6 +0,0 @@
var plugins = ["foo", "bar"];
module.exports = {
extends: "../extended.babelrc.json",
plugins: plugins
}

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,7 +0,0 @@
module.exports = function(api) {
api.cache(true);
return {
compact: true,
};
};

View File

@@ -1,5 +0,0 @@
var plugins = ["foo", "bar"];
module.exports = {
plugins: plugins
}

View File

@@ -1 +0,0 @@
// empty

View File

@@ -1,5 +0,0 @@
{
"plugins": [
"json"
]
}

View File

@@ -1,5 +0,0 @@
module.exports = {
plugins: [
"js"
]
}

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