Skip to content

Commit

Permalink
Rename "babylon" to "@babel/parser" (babel#7937) 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
kamthamc authored and hzoo committed May 19, 2018
1 parent 0200a3e commit daf0ca8
Show file tree
Hide file tree
Showing 7,587 changed files with 146 additions and 129 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ 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/test/expressions
packages/babel-parser/test/expressions
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ 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
/packages/babel-parser/build
.idea/
/.changelog
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@ before_install:
install: yarn --ignore-engines

before_script:
- 'if [ "$JOB" = "babylon-flow-tests" ]; then make bootstrap-flow; fi'
- 'if [ "$JOB" = "babylon-test262-tests" ]; then make bootstrap-test262; fi'
- 'if [ "$JOB" = "babel-parser-flow-tests" ]; then make bootstrap-flow; fi'
- 'if [ "$JOB" = "babel-parser-test262-tests" ]; then make bootstrap-test262; fi'

script:
- 'if [ "$JOB" = "test" ]; then make test-ci; fi'
- 'if [ "$JOB" = "lint" ]; then make lint && make flow; fi'
- 'if [ "$JOB" = "babylon-flow-tests" ]; then make test-flow-ci; fi'
- 'if [ "$JOB" = "babylon-test262-tests" ]; then make test-test262-ci; fi'
- 'if [ "$JOB" = "babel-parser-flow-tests" ]; then make test-flow-ci; fi'
- 'if [ "$JOB" = "babel-parser-test262-tests" ]; then make test-test262-ci; fi'

matrix:
fast_finish: true
include:
- node_js: "node"
env: JOB=lint
- node_js: "node"
env: JOB=babylon-flow-tests
env: JOB=babel-parser-flow-tests
- node_js: "node"
env: JOB=babylon-test262-tests
env: JOB=babel-parser-test262-tests

notifications:
slack:
Expand Down
26 changes: 13 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contributing, please read the
## Not sure where to start?

- If you aren't just making a documentation change, you'll probably want to learn a bit about a few topics.
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/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).
- [ASTs](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Abstract Syntax Tree): The Babel AST [spec](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) is a bit different from [ESTree](https://github.com/estree/estree). The differences are listed [here](https://github.com/babel/babel/tree/master/packages/babel-parser#output).
- 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
Expand Down Expand Up @@ -226,19 +226,19 @@ If the test requires a minimum Node version, you can add `minNodeVersion` (must
}
```

#### `babylon`
#### `@babel/parser`

Writing tests for Babylon is very
Writing tests for the babel parser is very
similar to the other packages.
Inside the `packages/babylon/tests/fixtures` folder are categories/groupings of test fixtures (es2015, flow,
Inside the `packages/babel-parser/tests/fixtures` folder are categories/groupings of test fixtures (es2015, flow,
etc.). To add a test, create a folder under one of these groupings (or create a new one) with a
descriptive name, and add the following:

* Create an `input.js` file that contains the code you want Babylon to parse.
* Create an `input.js` file that contains the code you want the babel parser to parse.

* Add an `output.json` file with the expected parser output. For added convenience, if there is no `output.json` present, the test runner will generate one for you.

After writing tests for babylon, just build it by running:
After writing tests for @babel/parser, just build it by running:

```sh
$ make build
Expand All @@ -247,17 +247,17 @@ $ make build
Then, to run the tests, use:

```sh
$ TEST_ONLY=babylon make test-only
$ TEST_ONLY=babel-parser make test-only
```

#### Bootstrapping expected output

For both `@babel/plugin-x` and `babylon`, you can easily generate an `output.js`/`output.json` automatically by just providing `input.js` and running the tests as you usually would.
For both `@babel/plugin-x` and `@babel/parser`, you can easily generate an `output.js`/`output.json` automatically by just providing `input.js` and running the tests as you usually would.

```
// Example
- packages
- babylon
- babel-parser
- test
- fixtures
- comments
Expand Down Expand Up @@ -309,14 +309,14 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe
- Create a new issue that describes the proposal (ex: [#538](https://github.com/babel/babylon/issues/538)). Include any relevant information like proposal repo/author, examples, parsing approaches, meeting notes, presentation slides, and more.
- The pull request should include:
- [ ] An update to the [plugins](https://github.com/babel/babel/tree/master/packages/babylon#plugins) part of the readme. Add a new entry to that list for the new plugin flag (and link to the proposal)
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/bloc/master/packages/babylon/ast/spec.md)
- [ ] Make sure you use the `this.hasPlugin("plugin-name-here")` check in Babylon so that your new plugin code only runs when that flag is turned on (not default behavior)
- [ ] An update to the [plugins](https://github.com/babel/babel/tree/master/packages/babel-parser#plugins) part of the readme. Add a new entry to that list for the new plugin flag (and link to the proposal)
- [ ] If any new nodes or modifications need to be added to the AST, update [ast/spec.md](https://github.com/babel/babel/bloc/master/packages/babel-parser/ast/spec.md)
- [ ] Make sure you use the `this.hasPlugin("plugin-name-here")` check in the babel parser so that your new plugin code only runs when that flag is turned on (not default behavior)
- [ ] Add failing/passing tests according to spec behavior
- Start working about the Babel transform itself!

## Internals
- AST spec ([babylon/ast/spec.md](https://github.com/babel/babel/blob/master/packages/babylon/ast/spec.md))
- AST spec ([babel-parser/ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.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))
Expand Down
4 changes: 2 additions & 2 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function buildRollup(packages) {
format: "cjs",
plugins: [
rollupBabel({
envName: "babylon",
envName: "babel-parser",
}),
rollupNodeResolve(),
],
Expand All @@ -113,7 +113,7 @@ function buildRollup(packages) {
}

gulp.task("build", function() {
const bundles = ["packages/babylon"];
const bundles = ["packages/babel-parser"];

return merge([buildBabel(/* exclude */ bundles), buildRollup(bundles)]);
});
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ bootstrap-flow:
cd build/flow && git checkout $(FLOW_COMMIT)

test-flow:
node scripts/tests/flow/run_babylon_flow_tests.js
node scripts/tests/flow/run_babel_parser_flow_tests.js

test-flow-ci: bootstrap test-flow

test-flow-update-whitelist:
node scripts/tests/flow/run_babylon_flow_tests.js --update-whitelist
node scripts/tests/flow/run_babel_parser_flow_tests.js --update-whitelist

bootstrap-test262:
rm -rf ./build/test262
Expand All @@ -101,12 +101,12 @@ bootstrap-test262:
cd build/test262 && git checkout $(TEST262_COMMIT)

test-test262:
node scripts/tests/test262/run_babylon_test262.js
node scripts/tests/test262/run_babel_parser_test262.js

test-test262-ci: bootstrap test-test262

test-test262-update-whitelist:
node scripts/tests/test262/run_babylon_test262.js --update-whitelist
node scripts/tests/test262/run_babel_parser_test262.js --update-whitelist

publish:
git pull --rebase
Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(api) {

switch (env) {
// Configs used during bundling builds.
case "babylon":
case "babel-parser":
case "standalone":
convertESM = false;
ignoreLib = false;
Expand Down Expand Up @@ -69,7 +69,7 @@ module.exports = function(api) {
].filter(Boolean),
overrides: [
{
test: "packages/babylon",
test: "packages/babel-parser",
plugins: [
"babel-plugin-transform-charcodes",
["@babel/transform-for-of", { assumeArray: true }],
Expand Down
2 changes: 1 addition & 1 deletion doc/ast/spec.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
The [AST specification](https://github.com/babel/babel/blob/master/packages/babylon/ast/spec.md) has been moved to the Babylon package, `packages/babylon`.
The [AST specification](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) has been moved to the babel parser package, `packages/babel-parser`.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"/node_modules/",
"/test/fixtures/",
"/test/debug-fixtures/",
"/babylon/test/expressions/",
"/babel-parser/test/expressions/",
"/test/tmp/",
"/test/__data__/",
"/test/helpers/",
Expand Down
6 changes: 3 additions & 3 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ A monorepo, muhahahahahaha. See the [monorepo design doc](/doc/design/monorepo.m
| Package | Version | Dependencies |
|--------|-------|------------|
| [`@babel/core`](/packages/babel-core) | [![npm](https://img.shields.io/npm/v/@babel/core.svg?maxAge=2592000)](https://www.npmjs.com/package/@babel/core) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-core)](https://david-dm.org/babel/babel?path=packages/babel-core) |
| [`babylon`](/packages/babylon) | [![npm](https://img.shields.io/npm/v/babylon.svg?maxAge=2592000)](https://www.npmjs.com/package/babylon) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babylon)](https://david-dm.org/babel/babel?path=packages/babylon) |
| [`@babel/parser`](/packages/@babel/parser) | [![npm](https://img.shields.io/npm/v/@babel/parser.svg?maxAge=2592000)](https://www.npmjs.com/package/@babel/parser) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-parser)](https://david-dm.org/babel/babel?path=packages/babel-parser) |
| [`@babel/traverse`](/packages/babel-traverse) | [![npm](https://img.shields.io/npm/v/@babel/traverse.svg?maxAge=2592000)](https://www.npmjs.com/package/@babel/traverse) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-traverse)](https://david-dm.org/babel/babel?path=packages/babel-traverse) |
| [`@babel/generator`](/packages/babel-generator) | [![npm](https://img.shields.io/npm/v/@babel/generator.svg?maxAge=2592000)](https://www.npmjs.com/package/@babel/generator) | [![Dependency Status](https://david-dm.org/babel/babel.svg?path=packages/babel-generator)](https://david-dm.org/babel/babel?path=packages/babel-generator) |

[`@babel/core`](/packages/babel-core) is the Babel compiler itself; it exposes the `babel.transform` method, where `transformedCode = transform(src).code`.

The compiler can be broken down into 3 parts:
- The parser: [`babylon`](/packages/babylon)
- The parser: [`@babel/parser`](/packages/babel-parser)
- The transformer[s]: All the plugins/presets
- These all use [`@babel/traverse`](/packages/babel-traverse) to traverse through the AST
- The generator: [`@babel/generator`](/packages/babel-generator)

The flow goes like this:

input string -> `babylon` parser -> `AST` -> transformer[s] -> `AST` -> `@babel/generator` -> output string
input string -> `@babel/parser` parser -> `AST` -> transformer[s] -> `AST` -> `@babel/generator` -> output string

Check out the [`babel-handbook`](https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#introduction) for more information on this.

Expand Down
6 changes: 3 additions & 3 deletions packages/babel-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Given an [AST](https://astexplorer.net/), transform it.

```js
const sourceCode = "if (true) return;";
const parsedAst = babylon.parse(sourceCode, { allowReturnOutsideFunction: true });
const parsedAst = babel.parse(sourceCode, { allowReturnOutsideFunction: true });
babel.transformFromAst(parsedAst, sourceCode, options, function(err, result) {
const { code, map, ast } = result;
});
Expand All @@ -119,7 +119,7 @@ Given an [AST](https://astexplorer.net/), transform it.

```js
const sourceCode = "if (true) return;";
const parsedAst = babylon.parse(sourceCode, { allowReturnOutsideFunction: true });
const parsedAst = babel.parse(sourceCode, { allowReturnOutsideFunction: true });
const { code, map, ast } = babel.transformFromAstSync(parsedAst, sourceCode, options);
```

Expand Down Expand Up @@ -238,7 +238,7 @@ Following is a table of the options you can use:
| `moduleIds` | `false` | If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for `common` modules) |
| `moduleRoot` | `(sourceRoot)` | Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions |
| `only` | `null` | A [glob](https://github.com/isaacs/minimatch), regex, or mixed array of both, matching paths to **only** compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim |
| `parserOpts` | `{}` | An object containing the options to be passed down to the babel parser, babylon |
| `parserOpts` | `{}` | An object containing the options to be passed down to the babel parser, @babel/parser |
| `plugins` | `[]` | List of [plugins](https://babeljs.io/docs/plugins/) to load and use |
| `presets` | `[]` | List of [presets](https://babeljs.io/docs/plugins/#presets) (a set of plugins) to load and use |
| `retainLines` | `false` | Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. (**NOTE:** This will not retain the columns) |
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@babel/template": "7.0.0-beta.47",
"@babel/traverse": "7.0.0-beta.47",
"@babel/types": "7.0.0-beta.47",
"babylon": "7.0.0-beta.47",
"@babel/parser": "7.0.0-beta.47",
"convert-source-map": "^1.1.0",
"debug": "^3.1.0",
"json5": "^0.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/src/transformation/normalize-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as t from "@babel/types";
import type { PluginPasses } from "../config";
import convertSourceMap, { typeof Converter } from "convert-source-map";
import { parse } from "babylon";
import { parse } from "@babel/parser";
import { codeFrameColumns } from "@babel/code-frame";
import File from "./file/file";
import generateMissingPluginMessage from "./util/missing-plugin-helper";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ const getNameURLCombination = ({ name, url }) => `${name} (${url})`;

/*
Returns a string of the format:
Support for the experimental syntax [babylon plugin name] isn't currently enabled ([loc]):
Support for the experimental syntax [@babel/parser plugin name] isn't currently enabled ([loc]):
[code frame]
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/test/evaluation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import traverse from "@babel/traverse";
import { parse } from "babylon";
import { parse } from "@babel/parser";

describe("evaluation", function() {
function addTest(code, type, value, notConfident) {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-generator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @babel/generator

> Turns a [Babylon AST](https://github.com/babel/babel/blob/master/packages/babylon/ast/spec.md) into code.
> Turns a [The Babel Parser AST](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md) into code.
## Install

Expand Down
2 changes: 1 addition & 1 deletion packages/babel-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
},
"devDependencies": {
"@babel/helper-fixtures": "7.0.0-beta.47",
"babylon": "7.0.0-beta.47"
"@babel/parser": "7.0.0-beta.47"
}
}
7 changes: 5 additions & 2 deletions packages/babel-generator/scripts/generate-typescript-tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copies tests from babylon's TypeScript test suite to @babel/generator.
Copies tests from the @babel/parser's TypeScript test suite to @babel/generator.
*/
const {
copySync,
Expand All @@ -10,7 +10,10 @@ const {
} = require("fs-extra");
const { join } = require("path");

const testsFrom = join(__dirname, "../../babylon/test/fixtures/typescript");
const testsFrom = join(
__dirname,
"../../babel-parser/test/fixtures/typescript"
);
const testsTo = join(__dirname, "../test/fixtures/typescript");

emptyDirSync(testsTo);
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-generator/test/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Printer from "../lib/printer";
import generate, { CodeGenerator } from "../lib";
import { parse } from "babylon";
import { parse } from "@babel/parser";
import * as t from "@babel/types";
import fs from "fs";
import path from "path";
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
> - :house: [Internal]
> - :nail_care: [Polish]
> Semver Policy: https://github.com/babel/babylon#semver
> Semver Policy: https://github.com/babel/babel/tree/master/packages/babel-parser#semver
_Note: Gaps between patch versions are faulty, broken or test releases._

Expand Down
File renamed without changes.
Loading

0 comments on commit daf0ca8

Please sign in to comment.