Skip to content

Commit

Permalink
docs(en): merging all conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
docschina-bot committed Sep 18, 2024
2 parents a90f03b + ec30c0a commit 37038ac
Show file tree
Hide file tree
Showing 108 changed files with 3,894 additions and 1,866 deletions.
38 changes: 22 additions & 16 deletions _redirects
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,23 @@ https://babel.netlify.com/* https://babeljs.io/:splat 301!
/docs/plugins/external-helpers/ /docs/babel-plugin-external-helpers

# Plugins renamed from -proposal- to -transform-
/docs/babel-plugin-proposal-class-static-block /docs/babel-plugin-transform-class-static-block
/docs/babel-plugin-proposal-private-property-in-object /docs/babel-plugin-transform-private-property-in-object
/docs/babel-plugin-proposal-class-properties /docs/babel-plugin-transform-class-properties
/docs/babel-plugin-proposal-private-methods /docs/babel-plugin-transform-private-methods
/docs/babel-plugin-proposal-numeric-separator /docs/babel-plugin-transform-numeric-separator
/docs/babel-plugin-proposal-logical-assignment-operators /docs/babel-plugin-transform-logical-assignment-operators
/docs/babel-plugin-proposal-nullish-coalescing-operator /docs/babel-plugin-transform-nullish-coalescing-operator
/docs/babel-plugin-proposal-optional-chaining /docs/babel-plugin-transform-optional-chaining
/docs/babel-plugin-proposal-json-strings /docs/babel-plugin-transform-json-strings
/docs/babel-plugin-proposal-optional-catch-binding /docs/babel-plugin-transform-optional-catch-binding
/docs/babel-plugin-proposal-async-generator-functions /docs/babel-plugin-transform-async-generator-functions
/docs/babel-plugin-proposal-object-rest-spread /docs/babel-plugin-transform-object-rest-spread
/docs/babel-plugin-proposal-unicode-property-regex /docs/babel-plugin-transform-unicode-property-regex
/docs/babel-plugin-proposal-unicode-sets-regex /docs/babel-plugin-transform-unicode-sets-regex
/docs/babel-plugin-proposal-export-namespace-from /docs/babel-plugin-transform-export-namespace-from
/docs/babel-plugin-proposal-class-static-block /docs/babel-plugin-transform-class-static-block
/docs/babel-plugin-proposal-private-property-in-object /docs/babel-plugin-transform-private-property-in-object
/docs/babel-plugin-proposal-class-properties /docs/babel-plugin-transform-class-properties
/docs/babel-plugin-proposal-private-methods /docs/babel-plugin-transform-private-methods
/docs/babel-plugin-proposal-numeric-separator /docs/babel-plugin-transform-numeric-separator
/docs/babel-plugin-proposal-dynamic-import /docs/babel-plugin-transform-dynamic-import
/docs/babel-plugin-proposal-logical-assignment-operators /docs/babel-plugin-transform-logical-assignment-operators
/docs/babel-plugin-proposal-nullish-coalescing-operator /docs/babel-plugin-transform-nullish-coalescing-operator
/docs/babel-plugin-proposal-optional-chaining /docs/babel-plugin-transform-optional-chaining
/docs/babel-plugin-proposal-json-strings /docs/babel-plugin-transform-json-strings
/docs/babel-plugin-proposal-optional-catch-binding /docs/babel-plugin-transform-optional-catch-binding
/docs/babel-plugin-proposal-async-generator-functions /docs/babel-plugin-transform-async-generator-functions
/docs/babel-plugin-proposal-object-rest-spread /docs/babel-plugin-transform-object-rest-spread
/docs/babel-plugin-proposal-unicode-property-regex /docs/babel-plugin-transform-unicode-property-regex
/docs/babel-plugin-proposal-unicode-sets-regex /docs/babel-plugin-transform-unicode-sets-regex
/docs/babel-plugin-proposal-export-namespace-from /docs/babel-plugin-transform-export-namespace-from
/docs/babel-plugin-proposal-duplicate-named-capturing-groups-regex /docs/babel-plugin-transform-duplicate-named-capturing-groups-regex

# Legacy redirects
/docs/en/babel-plugin-transform-decorators /docs/babel-plugin-proposal-decorators
Expand All @@ -92,8 +94,9 @@ https://babel.netlify.com/* https://babeljs.io/:splat 301!
/docs/en/next/tools/* /setup

# Blog rewrites
/7.25.0 /blog/2024/07/26/7.25.0
/7.24.0 /blog/2024/02/28/7.24.0
/7.23.0 /blog/2023/09/25/7.22.0
/7.23.0 /blog/2023/09/25/7.23.0
/7.22.0 /blog/2023/05/26/7.22.0
/7.21.0 /blog/2023/02/20/7.21.0
/7.20.0 /blog/2022/10/27/7.20.0
Expand Down Expand Up @@ -139,3 +142,6 @@ https://babel.netlify.com/* https://babeljs.io/:splat 301!
# Docusaurus v1 compat

/docs/en/* /docs/:splat

# CircleCI CORS
/circleci/api/* https://circleci.com/api/v1.1/project/github/babel/babel/:splat 200
2 changes: 0 additions & 2 deletions docs/assumptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,6 @@ class Child extends Parent {
"mutableTemplateObject": true,
"noClassCalls": true,
"noDocumentAll": true,
"noObjectSuper": true,
"noUndeclaredVariablesCheck": true,
"objectRestNoSymbols": true,
"privateFieldsAsProperties": true,
"pureGetters": true,
Expand Down
21 changes: 20 additions & 1 deletion docs/generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: babel-generator
title: "@babel/generator"
---

> Turns an AST into code.
> Turns Babel AST into code.
## Install

Expand Down Expand Up @@ -33,6 +33,25 @@ const output = generate(
The symbols like white spaces or new line characters are not preserved in the AST. When Babel generator prints code from the AST, the output format is not guaranteed.
:::

### Parser plugins support
Babel generator supports all the listed [Babel parser plugins](./parser.md#plugins) except `estree`. Note that parser plugins do not transform the code. For example,
if you pass JSX `<div></div>` to babel generator, the result will still contain the `div` JSX element.

```js title="JavaScript"
import { parse } from "@babel/parser";
import generate from "@babel/generator";

const code = "const Example = () => <div>example</div>";
const ast = parse(code, { plugins: ["jsx" ] });

const output = generate(
ast,
);

// true
output.includes("<div>");
```

## Options

<details>
Expand Down
2 changes: 1 addition & 1 deletion docs/helper-environment-visitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if (path.isMethod()) {

Suppose we are migrating from vanilla JavaScript to ES Modules. Now that the `this` keyword is equivalent to `undefined` at the top level of an ESModule ([spec](https://tc39.es/ecma262/#sec-module-environment-records-getthisbinding)), we want to replace all top-level `this` to [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis):

```js title=input.js
```js title="input.js"
// replace this expression to `globalThis.foo = "top"`
this.foo = "top";

Expand Down
16 changes: 15 additions & 1 deletion docs/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,29 @@ NODE_NO_READLINE=1 rlwrap --always-readline npx babel-node
### Usage

```sh title="Shell"
babel-node [options] [ -e script | script.js ] [arguments]
babel-node [options] [ -e script | [--] script.js ] [arguments]
```

:::babel7

When arguments for user script have names conflicting with node options, double dash placed before script name can be used to resolve ambiguities

```sh title="Shell"
npx babel-node --inspect --presets @babel/preset-env -- script.js --inspect
```

:::

:::babel8

Options for Node.js and Babel must be placed before the file name, while arguments for the script (that will be available as `process.argv`) must be placed after.

```sh title="Shell"
npx babel-node --arg-for-babel script.js --arg-for-script.js
```

:::

### Options

| Option | Default | Description |
Expand Down
11 changes: 6 additions & 5 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ babelrcRoots: [

### `plugins`

Type: `Array<PluginEntry | Plugin>` ([`PluginEntry`](#plugin-preset-entries))<br />
Type: `Array<PluginEntry | Plugin>` ([`PluginEntry`](#pluginpreset-entries))<br />
Default: `[]`<br />

An array of plugins to activate when processing this file. For more information on how
Expand All @@ -295,7 +295,7 @@ representation of a plugin or preset, you should use [`babel.createConfigItem()`

### `presets`

Type: `Array<PresetEntry>` ([`PresetEntry`](#plugin-preset-entries))<br />
Type: `Array<PresetEntry>` ([`PresetEntry`](#pluginpreset-entries))<br />
Default: `[]`<br />

An array of presets to activate when processing this file. For more information on how
Expand Down Expand Up @@ -365,7 +365,7 @@ If a minor version is not specified, Babel will interpret it as `MAJOR.0`. For e

#### No targets

:::babel7
::::babel7

When no targets are specified: Babel will assume you are targeting the oldest browsers possible. For example, `@babel/preset-env` will transform all ES2015-ES2020 code to be ES5 compatible.

Expand All @@ -389,7 +389,7 @@ Because of this, Babel's behavior is different than [browserslist](https://githu

We recognize this isn’t ideal and will be revisiting this in Babel v8.

:::
::::

:::babel8

Expand Down Expand Up @@ -612,7 +612,8 @@ Default: `false`<br />
- `"inline"` to generate a sourcemap and append it as a data URL to the end of the code, but not include it in the result object.
- `"both"` is the same as inline, but will include the map in the result object.

`@babel/cli` overloads some of these to also affect how maps are written to disk:
Options in configuration files have no effect on whether `@babel/cli` writes files separate `.map` files to disk.
When the `--source-maps` CLI option is passed to `@babel/cli` it will also control whether `.map` files are written:

- `true` will write the map to a `.map` file on disk
- `"inline"` will write the file directly, so it will have a `data:` containing the map
Expand Down
Loading

0 comments on commit 37038ac

Please sign in to comment.