From 629a534e8d5f22848f9d6b9440fd688d4d3afb5c Mon Sep 17 00:00:00 2001 From: Houtan <62800782+houtan-rocky@users.noreply.github.com> Date: Wed, 27 Mar 2024 23:37:32 +0330 Subject: [PATCH 01/47] [FIX] broken link (#2883) Co-authored-by: Brian Ng --- website/data/tools/node/usage.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/data/tools/node/usage.md b/website/data/tools/node/usage.md index a59b7b37d..b1d3e3948 100644 --- a/website/data/tools/node/usage.md +++ b/website/data/tools/node/usage.md @@ -6,6 +6,6 @@ require("@babel/core").transform("code", {

- For full documentation on the Babel API see the usage docs. + Explore the @babel/core documentation for the full API.

From 90125ef8248bcd02a4e55038272f380bdc718fe0 Mon Sep 17 00:00:00 2001 From: Tom Zajac Date: Fri, 29 Mar 2024 13:35:47 +0100 Subject: [PATCH 02/47] Update plugin-proposal-optional-chaining-assign.md (#2884) --- docs/plugin-proposal-optional-chaining-assign.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/plugin-proposal-optional-chaining-assign.md b/docs/plugin-proposal-optional-chaining-assign.md index e359b4b48..9a687e226 100644 --- a/docs/plugin-proposal-optional-chaining-assign.md +++ b/docs/plugin-proposal-optional-chaining-assign.md @@ -34,10 +34,12 @@ npm install --save-dev @babel/plugin-proposal-optional-chaining-assign ```json title="babel.config.json" { "plugins": [ - "@babel/plugin-proposal-optional-chaining-assign", - { - "version": "2023-07" - } + [ + "@babel/plugin-proposal-optional-chaining-assign", + { + "version": "2023-07" + } + ] ] } ``` From 6678bf7d8d8ba5bb107246179c2beee58b1c7b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 3 Apr 2024 18:14:20 +0200 Subject: [PATCH 03/47] Add docs for bugfix-firefox-class-in-computed-class-key (#2885) --- ...fix-firefox-class-in-computed-class-key.md | 45 +++++++++++++++++++ website/sidebars.js | 1 + 2 files changed, 46 insertions(+) create mode 100644 docs/plugin-bugfix-firefox-class-in-computed-class-key.md diff --git a/docs/plugin-bugfix-firefox-class-in-computed-class-key.md b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md new file mode 100644 index 000000000..84082a515 --- /dev/null +++ b/docs/plugin-bugfix-firefox-class-in-computed-class-key.md @@ -0,0 +1,45 @@ +--- +id: babel-plugin-bugfix-firefox-class-in-computed-class-key +title: "@babel/plugin-bugfix-firefox-class-in-computed-class-key" +sidebar_label: bugfix-firefox-class-in-computed-class-key +--- + +This bugfix plugin transforms classes inside computed keys of other classes to workaround a [SpiderMonkey bug](https://bugzilla.mozilla.org/show_bug.cgi?id=1887677) with private class elements. + +:::tip +This plugin is included in `@babel/preset-env`, and Babel will automatically enable this plugin for you when your `targets` are affected by the browser bug. +::: + +:::warning +Terser versions older than 5.30.2 will undo the transform done by this plugin. Make sure to use at least version 5.30.2, or set the Terser's [`compress.inline`](https://terser.org/docs/options/#compress-options) option to `false`. +::: + +## Installation + +```shell npm2yarn +npm install --save-dev @babel/plugin-bugfix-firefox-class-in-computed-class-key +``` + +## Usage + +### With a configuration file (Recommended) + +```json title="babel.config.json" +{ + "plugins": ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"] +} +``` + +### Via CLI + +```sh title="Shell" +babel --plugins @babel/plugin-bugfix-firefox-class-in-computed-class-key script.js +``` + +### Via Node API + +```js title="JavaScript" +require("@babel/core").transformSync("code", { + plugins: ["@babel/plugin-bugfix-firefox-class-in-computed-class-key"], +}); +``` diff --git a/website/sidebars.js b/website/sidebars.js index 13f4eec00..f4c6a258d 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -152,6 +152,7 @@ module.exports = { type: "category", label: "Bugfix", items: [ + "babel-plugin-bugfix-firefox-class-in-computed-class-key", "babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression", "babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining", ], From 85c50ccf2bb460f155f0e51140af3c726285a67a Mon Sep 17 00:00:00 2001 From: Adam Skoufis Date: Wed, 10 Apr 2024 17:46:04 +1000 Subject: [PATCH 04/47] Fix typo in preset-typescript.md (#2886) --- docs/preset-typescript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/preset-typescript.md b/docs/preset-typescript.md index b2ce2a5a2..93bb8901e 100644 --- a/docs/preset-typescript.md +++ b/docs/preset-typescript.md @@ -205,7 +205,7 @@ Added in: `v7.23.0` When set to `true`, Babel will rewrite `.ts`/`.mts`/`.cts` extensions in import declarations to `.js`/`.mjs`/`.cjs`. -This option, when used together with TypeScript's [`allowImportingTsExtension`](https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions) option, allows to write complete relative specifiers in import declaratoinss while using the same extension used by the source files. +This option, when used together with TypeScript's [`allowImportingTsExtension`](https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions) option, allows to write complete relative specifiers in import declarations while using the same extension used by the source files. As an example, given this project structure (where `src` contains the source files, and `dist` the compiled files): ``` From f151f34e090e5a9586fa73dbcc3db8bdd77e7cb9 Mon Sep 17 00:00:00 2001 From: Babel Bot Date: Mon, 29 Apr 2024 20:37:22 +0200 Subject: [PATCH 05/47] Update Babel types docs (#2887) --- docs/types.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/types.md b/docs/types.md index 118a30256..636f582a8 100644 --- a/docs/types.md +++ b/docs/types.md @@ -290,7 +290,7 @@ See also `t.isCallExpression(node, opts)` and `t.assertCallExpression(node, opts AST Node `CallExpression` shape: - `callee`: `Expression | Super | V8IntrinsicIdentifier` (required) -- `arguments`: `Array` (required) +- `arguments`: `Array` (required) - `optional`: `true | false` (default: `null`, excluded from builder function) - `typeArguments`: `TypeParameterInstantiation` (default: `null`, excluded from builder function) - `typeParameters`: `TSTypeParameterInstantiation` (default: `null`, excluded from builder function) @@ -1915,7 +1915,7 @@ See also `t.isNewExpression(node, opts)` and `t.assertNewExpression(node, opts)` AST Node `NewExpression` shape: - `callee`: `Expression | Super | V8IntrinsicIdentifier` (required) -- `arguments`: `Array` (required) +- `arguments`: `Array` (required) - `optional`: `true | false` (default: `null`, excluded from builder function) - `typeArguments`: `TypeParameterInstantiation` (default: `null`, excluded from builder function) - `typeParameters`: `TSTypeParameterInstantiation` (default: `null`, excluded from builder function) @@ -2232,7 +2232,7 @@ See also `t.isOptionalCallExpression(node, opts)` and `t.assertOptionalCallExpre AST Node `OptionalCallExpression` shape: - `callee`: `Expression` (required) -- `arguments`: `Array` (required) +- `arguments`: `Array` (required) - `optional`: `boolean` (required) - `typeArguments`: `TypeParameterInstantiation` (default: `null`, excluded from builder function) - `typeParameters`: `TSTypeParameterInstantiation` (default: `null`, excluded from builder function) From d75348f06bd30271e2fa6a57956f04e2e0198b75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 29 Apr 2024 20:38:54 +0200 Subject: [PATCH 06/47] Docs updates for `transform-runtime` cleanup (#2872) --- docs/plugin-transform-runtime.md | 131 +++++++++++++++++++++---------- docs/v8-migration.md | 10 +++ 2 files changed, 99 insertions(+), 42 deletions(-) diff --git a/docs/plugin-transform-runtime.md b/docs/plugin-transform-runtime.md index e71d55d0a..65c7296ea 100644 --- a/docs/plugin-transform-runtime.md +++ b/docs/plugin-transform-runtime.md @@ -5,10 +5,14 @@ title: "@babel/plugin-transform-runtime" A plugin that enables the re-use of Babel's injected helper code to save on codesize. +::::babel7 + :::note Instance methods such as `"foobar".includes("foo")` will only work with `core-js@3`. If you need to polyfill them, you can directly import `"core-js"` or use `@babel/preset-env`'s `useBuiltIns` option. ::: +:::: + ## Installation Install it as development dependency. @@ -35,10 +39,14 @@ Babel uses very small helpers for common functions such as `_extend`. By default This is where the `@babel/plugin-transform-runtime` plugin comes in: all of the helpers will reference the module `@babel/runtime` to avoid duplication across your compiled output. The runtime will be compiled into your build. +::::babel7 + Another purpose of this transformer is to create a sandboxed environment for your code. If you directly import [core-js](https://github.com/zloirock/core-js) or [@babel/polyfill](polyfill.md) and the built-ins it provides such as `Promise`, `Set` and `Map`, those will pollute the global scope. While this might be ok for an app or a command line tool, it becomes a problem if your code is a library which you intend to publish for others to use or if you can't exactly control the environment in which your code will run. The transformer will alias these built-ins to `core-js` so you can use them seamlessly without having to require the polyfill. +:::: + See the [technical details](#technical-details) section for more information on how this works and the types of transformations that occur. ## Usage @@ -90,6 +98,21 @@ require("@babel/core").transformSync("code", { ## Options + +### `absoluteRuntime` + +`boolean` or `string`, defaults to `false`. + +This allows users to run `transform-runtime` broadly across a whole project. By default, `transform-runtime` imports from `@babel/runtime/foo` directly, but that only works if `@babel/runtime` is in the `node_modules` of the file that is being compiled. This can be problematic for nested `node_modules`, npm-linked modules, or CLIs that reside outside the user's project, among other cases. To avoid worrying about how the runtime module's location is resolved, this allows users to resolve the runtime once up front, and then insert absolute paths to the runtime into the output code. + +Using absolute paths is not desirable if files are compiled for use at a later time, but in contexts where a file is compiled and then immediately consumed, they can be quite helpful. + +:::tip +You can read more about configuring plugin options [here](https://babeljs.io/docs/en/plugins#plugin-options) +::: + +::::babel7 + ### `corejs` `false`, `2`, `3` or `{ version: 2 | 3, proposals: boolean }`, defaults to `false`. @@ -118,6 +141,12 @@ This option requires changing the dependency used to provide the necessary runti | `2` | `npm install --save @babel/runtime-corejs2` | | `3` | `npm install --save @babel/runtime-corejs3` | +:::caution + +The `corejs` option will be removed in Babel 8. To inject polyfills, you can use [`babel-plugin-polyfill-corejs3`](https://github.com/babel/babel-polyfills/blob/main/packages/babel-plugin-polyfill-corejs3/README.md) or [`babel-plugin-polyfill-corejs2`](https://github.com/babel/babel-polyfills/blob/main/packages/babel-plugin-polyfill-corejs2/README.md) directly. + +::: + ### `helpers` `boolean`, defaults to `true`. @@ -126,6 +155,14 @@ Toggles whether or not inlined Babel helpers (`classCallCheck`, `extends`, etc.) For more information, see [Helper aliasing](#helper-aliasing). +:::caution + +The `helpers` option will be removed in Babel 8, as this plugin will only be used to inject helpers (including `regeneratorRuntime`, which will be handled as any other Babel helper). + +::: + +:::: + ### `moduleName`
@@ -147,42 +184,22 @@ This option controls which package of helpers `@babel/plugin-transform-runtime` Note that specifying the [`corejs`](#corejs) option will internally enable the corresponding `babel-plugin-polyfill-corejs*` plugin, thus it has an effect on the final module name. -### `polyfill` - -:::danger -This option was removed in v7. -::: +::::babel7 ### `regenerator` `boolean`, defaults to `true`. -Toggles whether or not generator functions are transformed to use a regenerator runtime that does not pollute the global scope. +In older Babel version, this option used to toggles whether or not generator functions were transformed to use a regenerator runtime that does not pollute the global scope. For more information, see [Regenerator aliasing](#regenerator-aliasing). -### `useBuiltIns` - -:::danger -This option was removed in v7. +:::caution +The `regenerator` option will be removed in Babel 8, as it will not be necessary anymore. ::: ### `useESModules` -::::babel8 - -:::danger -This option was removed in v8. -::: - -:::: - -::::babel7 - -:::caution -This option has been deprecated and will be removed in Babel 8: starting from version `7.13.0`, `@babel/runtime`'s `package.json` uses `"exports"` option to automatically choose between CJS and ESM helpers. -::: - `boolean`, defaults to `false`.
@@ -219,46 +236,59 @@ export default function(instance, Constructor) { } ``` +:::caution +The `useESModules` option has been deprecated and will be removed in Babel 8: starting from version `7.13.0`, `@babel/runtime`'s `package.json` uses `"exports"` option to automatically choose between CJS and ESM helpers. +::: + :::: -### `absoluteRuntime` +### `version` -`boolean` or `string`, defaults to `false`. +::::babel7 -This allows users to run `transform-runtime` broadly across a whole project. By default, `transform-runtime` imports from `@babel/runtime/foo` directly, but that only works if `@babel/runtime` is in the `node_modules` of the file that is being compiled. This can be problematic for nested `node_modules`, npm-linked modules, or CLIs that reside outside the user's project, among other cases. To avoid worrying about how the runtime module's location is resolved, this allows users to resolve the runtime once up front, and then insert absolute paths to the runtime into the output code. +By default transform-runtime assumes that `@babel/runtime@7.0.0` is installed. If you have later versions of +`@babel/runtime` (or their corejs counterparts e.g. `@babel/runtime-corejs3`) installed or listed as a dependency, transform-runtime can use more advanced features. -Using absolute paths is not desirable if files are compiled for use at a later time, but in contexts where a file is compiled and then immediately consumed, they can be quite helpful. +For example if you depend on `@babel/runtime@^7.24.0` you can transpile your code with -:::tip -You can read more about configuring plugin options [here](https://babeljs.io/docs/en/plugins#plugin-options) -::: +```json title="babel.config.json" +{ + "plugins": [ + ["@babel/plugin-transform-runtime", { + "version": "^7.24.0" + }] + ] +} +``` -### `version` +:::: -By default transform-runtime assumes that `@babel/runtime@7.0.0` is installed. If you have later versions of +::::babel8 + +By default transform-runtime assumes that `@babel/runtime@8.0.0` is installed. If you have later versions of `@babel/runtime` (or their corejs counterparts e.g. `@babel/runtime-corejs3`) installed or listed as a dependency, transform-runtime can use more advanced features. -For example if you depend on `@babel/runtime-corejs2@7.7.4` you can transpile your code with + +For example if you depend on `@babel/runtime@^8.1.0` you can transpile your code with ```json title="babel.config.json" { "plugins": [ - [ - "@babel/plugin-transform-runtime", - { - "absoluteRuntime": false, - "corejs": 2, - "version": "^7.7.4" - } - ] + ["@babel/plugin-transform-runtime", { + "version": "^8.1.0" + }] ] } ``` +:::: + which results in a smaller bundle size. ## Technical details +::::babel7 + The `transform-runtime` transformer plugin does three things: - Automatically requires `@babel/runtime/regenerator` when you use generators/async functions (toggleable with the `regenerator` option). @@ -381,6 +411,8 @@ without worrying about where they come from. ### Helper aliasing +:::: + Usually Babel will place helpers at the top of your file to do common tasks to avoid duplicating the code around in the current file. Sometimes these helpers can get a little bulky and add unnecessary duplication across files. The `runtime` @@ -425,3 +457,18 @@ var Person = function Person() { (0, _classCallCheck3.default)(this, Person); }; ``` + +## Removed options + +:::babel8 + +The following options where removed in Babel 8.0.0: +- `corejs` +- `helpers` +- `regenerator` + +::: + +The following options where removed in Babel 7.0.0: +- `useBuiltIns` +- `polyfill` diff --git a/docs/v8-migration.md b/docs/v8-migration.md index bc751c055..a2e58e990 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -403,12 +403,22 @@ The following syntax plugins are no longer needed, you can safely remove them fr ### `@babel/plugin-transform-runtime` +![medium](https://img.shields.io/badge/risk%20of%20breakage%3F-medium-yellow.svg) + +- The `corejs` option has been removed ([#16311](https://github.com/babel/babel/pull/16311)) + + **Migration**: To inject polyfills, you can use [`babel-plugin-polyfill-corejs3`](https://github.com/babel/babel-polyfills/blob/main/packages/babel-plugin-polyfill-corejs3/README.md) or [babel-plugin-polyfill-corejs2](https://github.com/babel/babel-polyfills/blob/main/packages/babel-plugin-polyfill-corejs2/README.md) directly. + ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) - The `useESModules` option has been removed ([#16141](https://github.com/babel/babel/pull/16141)) **Migration**: Delete it from your configuration. `@babel/runtime` will now automatically expose ES modules when needed, using `package.json#exports`. +- The `runtime` and `helpers` options have been removed ([#16311](https://github.com/babel/babel/pull/16311)) + + **Migration**: Delete them from your configuration: `@babel/runtime` will now always import helpers. If you don't want to inject imports to helpers, remove `@babel/plugin-transform-runtime` from your config. + ### `@babel/node` ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) From 014d07f6272ed766bb345863b0269c796b57de92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 30 Apr 2024 10:25:30 -0400 Subject: [PATCH 07/47] Bump Babel 8 node.js requirements (#2888) * Bump Babel 8 node.js requirements * Update docs/v8-migration.md --- docs/v8-migration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/v8-migration.md b/docs/v8-migration.md index a2e58e990..7d1327979 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -13,9 +13,9 @@ Refer users to this document when upgrading to Babel 8 from Babel 7. If you are ### Node.js support -All Babel 8 packages require Node.js `^16.20.0 || ^18.16.0 || >=20.0.0`. +All Babel 8 packages require Node.js `^18.20.0 || ^20.10.0 || >=21.0.0`. -We highly encourage you to use a newer version of Node.js (LTS v18) since the previous versions are not maintained. +We highly encourage you to use a newer version of Node.js (LTS v20) since the previous versions are not maintained. See [nodejs/Release](https://github.com/nodejs/Release) for more information. This just means Babel _itself_ won't run on older versions of Node. It can still _output_ code that runs on old Node versions. From c375585abc891f82fcdc233f175b971cf85f2487 Mon Sep 17 00:00:00 2001 From: Dunqing Date: Sat, 11 May 2024 17:39:15 +0800 Subject: [PATCH 08/47] Update plugin-transform-typescript.md (#2889) --- docs/plugin-transform-typescript.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugin-transform-typescript.md b/docs/plugin-transform-typescript.md index 6a8111118..35abf8095 100644 --- a/docs/plugin-transform-typescript.md +++ b/docs/plugin-transform-typescript.md @@ -116,7 +116,7 @@ Forcibly enables `jsx` parsing. Otherwise angle brackets will be treated as Type ### `jsxPragma` -`string`, defaults to `React` +`string`, defaults to `React.createElement` Replace the function used when compiling JSX expressions. This is so that we know that the import is not a type import, and should not be removed. From b013f246aad485b472d025de7d0eecc24bb47d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Deng=20=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sat, 1 Jun 2024 08:54:27 +0800 Subject: [PATCH 09/47] docs: update Babel/estree ast difference (#2892) --- docs/parser.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/parser.md b/docs/parser.md index 91cb21e6b..d80cd613b 100644 --- a/docs/parser.md +++ b/docs/parser.md @@ -118,7 +118,8 @@ It is based on [ESTree spec][] with the following deviations: - [Program][] and [BlockStatement][] contain additional `directives` field with [Directive][] and [DirectiveLiteral][] - [ClassMethod][], [ClassPrivateMethod][], [ObjectProperty][], and [ObjectMethod][] value property's properties in [FunctionExpression][] is coerced/brought into the main method node. - [ChainExpression][] is replaced with [OptionalMemberExpression][] and [OptionalCallExpression][] -- [ImportExpression][] is replaced with a [CallExpression][] whose `callee` is an [Import] node. +- [ImportExpression][] is replaced with a [CallExpression][] whose `callee` is an [Import] node. This change will be reversed in Babel 8. +- [ExportAllDeclaration][] with `exported` field is replaced with an [ExportNamedDeclaration][] containing an [ExportNamespaceSpecifier][] node. :::tip There is now an `estree` plugin which reverts these deviations @@ -134,6 +135,7 @@ AST for JSX code is based on [Facebook JSX AST][]. [propertydefinition]: https://github.com/estree/estree/blob/master/es2022.md#propertydefinition [chainexpression]: https://github.com/estree/estree/blob/master/es2020.md#chainexpression [importexpression]: https://github.com/estree/estree/blob/master/es2020.md#importexpression +[exportalldeclaration]: https://github.com/estree/estree/blob/master/es2020.md#exportalldeclaration [privateidentifier]: https://github.com/estree/estree/blob/master/es2022.md#privateidentifier [stringliteral]: https://github.com/babel/babel/tree/main/packages/babel-parser/ast/spec.md#stringliteral [numericliteral]: https://github.com/babel/babel/tree/main/packages/babel-parser/ast/spec.md#numericliteral @@ -157,6 +159,8 @@ AST for JSX code is based on [Facebook JSX AST][]. [optionalcallexpression]: https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md#optionalcallexpression [callexpression]: https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md#callexpression [import]: https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md#import +[exportnameddeclaration]: https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md#exportnameddeclaration +[exportnamespacespecifier]: https://github.com/babel/babel/blob/main/packages/babel-parser/ast/spec.md#exportnamespacespecifier [facebook jsx ast]: https://github.com/facebook/jsx/blob/master/AST.md ### Semver From 9018180f2aa287333e1cc0ec3262914f436eaa76 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Mon, 3 Jun 2024 21:35:15 +0800 Subject: [PATCH 10/47] [Babel 8] Migration guide for `extra.shorthand` (#2891) --- docs/v8-migration-api.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/v8-migration-api.md b/docs/v8-migration-api.md index 73845fb16..9544b48e4 100644 --- a/docs/v8-migration-api.md +++ b/docs/v8-migration-api.md @@ -284,6 +284,10 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes **Migration**: Adapt to the new token design. If you want to restore to the Babel 7 behaviour, manually transform them to the Babel 7 tokens ([example](https://github.com/babel/babel/blob/7e60a93897f9a134506251ea51269faf4d02a86c/packages/babel-parser/src/parser/statement.ts#L116-L188)). +- Remove `extra.shorthand` from `ObjectProperty` nodes ([#16521](https://github.com/babel/babel/pull/16521)) + + **Migration**: Use `node.shorthand` rather than `node.extra.shorthand`. + ### `@babel/traverse` ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) From 13c9277f3a4635f024975e673e46bbe9c851977e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 4 Jun 2024 03:55:55 -0400 Subject: [PATCH 11/47] fix transform-dynamic-import 404 (#2894) --- _redirects | 3 ++- ...mport.md => plugin-transform-dynamic-import.md} | 14 +++++++------- website/sidebars.js | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) rename docs/{plugin-proposal-dynamic-import.md => plugin-transform-dynamic-import.md} (85%) diff --git a/_redirects b/_redirects index 79bef5c1d..83a360c41 100644 --- a/_redirects +++ b/_redirects @@ -70,6 +70,7 @@ https://babel.netlify.com/* https://babeljs.io/:splat 301! /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 @@ -93,7 +94,7 @@ https://babel.netlify.com/* https://babeljs.io/:splat 301! # Blog rewrites /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 diff --git a/docs/plugin-proposal-dynamic-import.md b/docs/plugin-transform-dynamic-import.md similarity index 85% rename from docs/plugin-proposal-dynamic-import.md rename to docs/plugin-transform-dynamic-import.md index 439f68779..394fdb7a0 100644 --- a/docs/plugin-proposal-dynamic-import.md +++ b/docs/plugin-transform-dynamic-import.md @@ -1,6 +1,6 @@ --- -id: babel-plugin-proposal-dynamic-import -title: "@babel/plugin-proposal-dynamic-import" +id: babel-plugin-transform-dynamic-import +title: "@babel/plugin-transform-dynamic-import" sidebar_label: dynamic-import --- @@ -74,7 +74,7 @@ will be transformed to ## Installation ```shell npm2yarn -npm install --save-dev @babel/plugin-proposal-dynamic-import +npm install --save-dev @babel/plugin-transform-dynamic-import ``` ## Usage @@ -84,7 +84,7 @@ npm install --save-dev @babel/plugin-proposal-dynamic-import ```json title="babel.config.json" { "plugins": [ - "@babel/plugin-proposal-dynamic-import", + "@babel/plugin-transform-dynamic-import", "@babel/plugin-transform-modules-commonjs" ] } @@ -93,7 +93,7 @@ npm install --save-dev @babel/plugin-proposal-dynamic-import ### Via CLI ```sh title="Shell" -babel --plugins=@babel/plugin-proposal-dynamic-import,@babel/plugin-transform-modules-amd script.js +babel --plugins=@babel/plugin-transform-dynamic-import,@babel/plugin-transform-modules-amd script.js ``` ### Via Node API @@ -101,7 +101,7 @@ babel --plugins=@babel/plugin-proposal-dynamic-import,@babel/plugin-transform-mo ```js title="JavaScript" require("@babel/core").transformSync("code", { plugins: [ - "@babel/plugin-proposal-dynamic-import", + "@babel/plugin-transform-dynamic-import", "@babel/plugin-transform-modules-systemjs" ], }); @@ -109,4 +109,4 @@ require("@babel/core").transformSync("code", { ## References -- [Proposal: import()](https://github.com/tc39/proposal-dynamic-import) +- [Proposal: import()](https://github.com/tc39/transform-dynamic-import) diff --git a/website/sidebars.js b/website/sidebars.js index f4c6a258d..edfea9acd 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -70,7 +70,7 @@ module.exports = { type: "category", label: "ES2020", items: [ - "babel-plugin-proposal-dynamic-import", + "babel-plugin-transform-dynamic-import", "babel-plugin-transform-export-namespace-from", "babel-plugin-transform-nullish-coalescing-operator", "babel-plugin-transform-optional-chaining", From 873907a11bef7a1a1123a140953e858d8e13ff2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 4 Jun 2024 04:02:38 -0400 Subject: [PATCH 12/47] fix dynamic-import proposal link (#2896) --- docs/plugin-transform-dynamic-import.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugin-transform-dynamic-import.md b/docs/plugin-transform-dynamic-import.md index 394fdb7a0..89c0c478b 100644 --- a/docs/plugin-transform-dynamic-import.md +++ b/docs/plugin-transform-dynamic-import.md @@ -109,4 +109,4 @@ require("@babel/core").transformSync("code", { ## References -- [Proposal: import()](https://github.com/tc39/transform-dynamic-import) +- [Proposal: import()](https://github.com/tc39/proposal-dynamic-import) From 806e689059427195cf081e42583da76be2fb63ec Mon Sep 17 00:00:00 2001 From: fi3ework Date: Wed, 19 Jun 2024 15:38:09 +0800 Subject: [PATCH 13/47] docs: typo in plugin-proposal-decorators (#2900) --- docs/plugin-proposal-decorators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugin-proposal-decorators.md b/docs/plugin-proposal-decorators.md index 44e1056a1..1a1dc5741 100644 --- a/docs/plugin-proposal-decorators.md +++ b/docs/plugin-proposal-decorators.md @@ -110,7 +110,7 @@ Selects the decorators proposal to use: `"2023-11"`, `"2023-05"`, `"2023-01"`, `"2022-03"`, `"2021-12"`, `"2018-09"` or `"legacy"`. Selects the decorators proposal to use: -- `"2023-11"` is the proposal version after the updates that reached consensus in the November 2023 TC30 meetings, intergrating [this change](https://github.com/pzuraq/ecma262/pull/12) +- `"2023-11"` is the proposal version after the updates that reached consensus in the November 2023 TC39 meetings, intergrating [this change](https://github.com/pzuraq/ecma262/pull/12) - `"2023-05"` is the proposal version after the updates that reached consensus in the March and May 2023 TC39 meetings, integrating [these changes](https://github.com/pzuraq/ecma262/compare/e86128e13b63a3c2efc3728f76c8332756752b02...c4465e44d514c6c1dba810487ec2721ccd6b08f9). - `"2023-01"` is the proposal version after the updates that reached consensus in the January 2023 TC39 meeting, integrating [`pzuraq/ecma262#4`](https://github.com/pzuraq/ecma262/pull/4). - `"2022-03"` is the proposal version that reached consensus for Stage 3 in the March 2022 TC39 meeting. You can read more about it at [`tc39/proposal-decorators@8ca65c046d`](https://github.com/tc39/proposal-decorators/tree/8ca65c046dd5e9aa3846a1fe5df343a6f7efd9f8). From d8df2be1805fb2c4b3661edea0f88c91fbbdbb6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 20 Jun 2024 15:53:54 +0200 Subject: [PATCH 14/47] Document that regexp plugins only handle regexp literals (#2901) --- ...posal-duplicate-named-capturing-groups-regex.md | 2 ++ docs/plugin-transform-dotall-regex.md | 2 ++ ...lugin-transform-named-capturing-groups-regex.md | 2 ++ docs/plugin-transform-unicode-property-regex.md | 2 ++ docs/plugin-transform-unicode-regex.md | 2 ++ docs/plugin-transform-unicode-sets-regex.md | 14 ++++++++++---- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md b/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md index 2bfeb8052..5e9b17a08 100644 --- a/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md +++ b/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md @@ -4,6 +4,8 @@ title: "@babel/plugin-proposal-duplicate-named-capturing-groups-regex" sidebar_label: duplicate-named-capturing-groups-regex --- +This plugin transforms regular expression _literals_ to support duplicate named capturing groups. It does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. + ## Examples **In** diff --git a/docs/plugin-transform-dotall-regex.md b/docs/plugin-transform-dotall-regex.md index 7b5dcd09d..625e885ee 100644 --- a/docs/plugin-transform-dotall-regex.md +++ b/docs/plugin-transform-dotall-regex.md @@ -8,6 +8,8 @@ sidebar_label: dotall-regex This plugin is included in `@babel/preset-env`, in [ES2018](https://github.com/tc39/proposals/blob/master/finished-proposals.md) ::: +This plugin transforms regular expression _literals_ to support the `/s` flag. It does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. + ## Example **In** diff --git a/docs/plugin-transform-named-capturing-groups-regex.md b/docs/plugin-transform-named-capturing-groups-regex.md index 500b78389..bec9a6c0b 100644 --- a/docs/plugin-transform-named-capturing-groups-regex.md +++ b/docs/plugin-transform-named-capturing-groups-regex.md @@ -11,6 +11,8 @@ functionalities. If you need to support older browsers, use either the `runtime: false` option or import a proper polyfill (e.g. `core-js`). ::: +This plugin transforms regular expression _literals_ to support named capturing groups. It does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. + ## Examples **In** diff --git a/docs/plugin-transform-unicode-property-regex.md b/docs/plugin-transform-unicode-property-regex.md index 6ae8bf6c4..41322b416 100644 --- a/docs/plugin-transform-unicode-property-regex.md +++ b/docs/plugin-transform-unicode-property-regex.md @@ -8,6 +8,8 @@ sidebar_label: unicode-property-regex This plugin is included in `@babel/preset-env`, in [ES2018](https://github.com/tc39/proposals/blob/master/finished-proposals.md) ::: +This plugin transforms regular expression _literals_ to support the `\p{...}` escapes. It does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. + [Here’s an online demo.](https://mothereff.in/regexpu#input=var+regex+%3D+/%5Cp%7BScript_Extensions%3DGreek%7D/u%3B&unicodePropertyEscape=1) ## Installation diff --git a/docs/plugin-transform-unicode-regex.md b/docs/plugin-transform-unicode-regex.md index 949337ce2..a1a20f2cc 100644 --- a/docs/plugin-transform-unicode-regex.md +++ b/docs/plugin-transform-unicode-regex.md @@ -8,6 +8,8 @@ sidebar_label: unicode-regex This plugin is included in `@babel/preset-env` ::: +This plugin transforms regular expression _literals_ to support the `/u` flag. It does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. + ## Example **In** diff --git a/docs/plugin-transform-unicode-sets-regex.md b/docs/plugin-transform-unicode-sets-regex.md index f0c20856e..60257c035 100644 --- a/docs/plugin-transform-unicode-sets-regex.md +++ b/docs/plugin-transform-unicode-sets-regex.md @@ -10,23 +10,27 @@ This plugin is included in `@babel/preset-env`, in [ES2024](https://github.com/t This plugin transforms regular expressions using the `v` flag, introduced by the [RegExp set notation + properties of strings](https://github.com/tc39/proposal-regexp-set-notation) proposal, to regular expressions that use the `u` flag. +It only transforms `/.../v` syntax and it does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. + ## Example ### Intersection + ```js title="input.js" -/[\p{ASCII}&&\p{Decimal_Number}]/v +/[\p{ASCII}&&\p{Decimal_Number}]/v; ``` will be transformed to ```js title="output.js" -/[0-9]/u +/[0-9]/u; ``` ### Difference + ```js title="input.js" // Non-ASCII white spaces -/[\p{White_Space}--\p{ASCII}]/v +/[\p{White_Space}--\p{ASCII}]/v; ``` will be transformed to @@ -36,6 +40,7 @@ will be transformed to ``` ### Property of Strings + ```js title="input.js" /^\p{Emoji_Keycap_Sequence}$/v.test("*\uFE0F\u20E3"); // true @@ -49,9 +54,10 @@ will be transformed to ``` Here is [a list of supported properties](https://github.com/tc39/proposal-regexp-unicode-sequence-properties#proposed-solution). Note that using property of strings with `u`-flag will error. + ```js title="input.js" // highlight-error-next-line -/\p{Emoji_Keycap_Sequence}/u +/\p{Emoji_Keycap_Sequence}/u; // Error: Properties of strings are only supported when using the unicodeSets (v) flag. ``` From 449f038a14f8fbb37d1590f745ed3055bb4dd136 Mon Sep 17 00:00:00 2001 From: Denis Bendrikov Date: Sat, 6 Jul 2024 17:58:05 +0300 Subject: [PATCH 15/47] fix(docsearch): better text contrast for active hit (#2905) --- website/src/css/custom.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/src/css/custom.css b/website/src/css/custom.css index f73ac8c74..999714e99 100644 --- a/website/src/css/custom.css +++ b/website/src/css/custom.css @@ -109,6 +109,10 @@ article[itemprop="blogPost"] h4 { --docsearch-muted-color: #7f8497; } +.DocSearch-Hit-Container { + --docsearch-hit-active-color: var(--ifm-color-content-inverse); +} + .wrapper { margin: 0 auto; max-width: 1100px; From 4caa527eb8e844bc6855697e11b2e6a8336dd5f2 Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Tue, 9 Jul 2024 09:28:57 -0500 Subject: [PATCH 16/47] docs(options.md): clarify `--source-maps` CLI option (#2898) * docs(options.md): clarify `--source-maps` CLI option it's confusing. Honestly it would be less confusing and IMO better if having `sourceMaps: true` in config files would make `@babel/cli` write `.map` files to disk. * Update options.md --- docs/options.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/options.md b/docs/options.md index f9ec37b45..d234940ac 100644 --- a/docs/options.md +++ b/docs/options.md @@ -612,7 +612,8 @@ Default: `false`
- `"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 From 7242463c93827d8e45c4a018d90dc1a27bc3f291 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Tue, 9 Jul 2024 09:29:11 -0500 Subject: [PATCH 17/47] docs(assumptions): Remove references to `noObjectSuper` & `noUndeclaredVariablesCheck` (#2895) * docs(assumptions): Remove `noObjectSuper` reference * docs(assumptions): Remove `noUndeclaredVariablesCheck` reference --- docs/assumptions.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/assumptions.md b/docs/assumptions.md index d6b244cc6..5e9d66e8e 100644 --- a/docs/assumptions.md +++ b/docs/assumptions.md @@ -434,8 +434,6 @@ class Child extends Parent { "mutableTemplateObject": true, "noClassCalls": true, "noDocumentAll": true, - "noObjectSuper": true, - "noUndeclaredVariablesCheck": true, "objectRestNoSymbols": true, "privateFieldsAsProperties": true, "pureGetters": true, From cf9d7652f998ddb86176dd6e6def2bf7a8c53618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Tue, 9 Jul 2024 11:57:16 -0400 Subject: [PATCH 18/47] Update plugins-list.md (#2909) Added `transform-dynamic-import` plugin link. Removed syntax only plugins as there are already under the syntax plugins section. --- docs/plugins-list.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/plugins-list.md b/docs/plugins-list.md index 3ff6353c4..c7535510f 100644 --- a/docs/plugins-list.md +++ b/docs/plugins-list.md @@ -37,7 +37,6 @@ sidebar_label: Plugins List - [class-static-block](plugin-transform-class-static-block.md) - [private-property-in-object](plugin-transform-private-property-in-object.md) - [private-methods](plugin-transform-private-methods.md) -- [syntax-top-level-await](plugin-syntax-top-level-await.md) ### ES2021 @@ -46,12 +45,10 @@ sidebar_label: Plugins List ### ES2020 +- [dynamic-import](plugin-transform-dynamic-import.md) - [export-namespace-from](plugin-transform-export-namespace-from.md) - [nullish-coalescing-operator](plugin-transform-nullish-coalescing-operator.md) - [optional-chaining](plugin-transform-optional-chaining.md) -- [syntax-dynamic-import](plugin-syntax-dynamic-import.md) -- [syntax-import-meta](plugin-syntax-import-meta.md) -- [syntax-bigint](plugin-syntax-bigint.md) ### ES2019 From 2852ab60bf7e77ac7f0baf43865e5e369c9b00b1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:47:23 -0400 Subject: [PATCH 19/47] Bump ws from 7.5.9 to 7.5.10 (#2910) Bumps [ws](https://github.com/websockets/ws) from 7.5.9 to 7.5.10. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 0c32a6e50..70e2b28a7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16898,8 +16898,8 @@ __metadata: linkType: hard "ws@npm:^7.3.1": - version: 7.5.9 - resolution: "ws@npm:7.5.9" + version: 7.5.10 + resolution: "ws@npm:7.5.10" peerDependencies: bufferutil: ^4.0.1 utf-8-validate: ^5.0.2 @@ -16908,7 +16908,7 @@ __metadata: optional: true utf-8-validate: optional: true - checksum: 171e35012934bd8788150a7f46f963e50bac43a4dc524ee714c20f258693ac4d3ba2abadb00838fdac42a47af9e958c7ae7e6f4bc56db047ba897b8a2268cf7c + checksum: 9c796b84ba80ffc2c2adcdfc9c8e9a219ba99caa435c9a8d45f9ac593bba325563b3f83edc5eb067cc6d21b9a6bf2c930adf76dd40af5f58a5ca6859e81858f0 languageName: node linkType: hard From f172a9648e8f28d5f1c855768eb3d078a2156029 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:53:42 -0400 Subject: [PATCH 20/47] Bump webpack-dev-middleware from 5.3.3 to 5.3.4 (#2911) Bumps [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) from 5.3.3 to 5.3.4. - [Release notes](https://github.com/webpack/webpack-dev-middleware/releases) - [Changelog](https://github.com/webpack/webpack-dev-middleware/blob/v5.3.4/CHANGELOG.md) - [Commits](https://github.com/webpack/webpack-dev-middleware/compare/v5.3.3...v5.3.4) --- updated-dependencies: - dependency-name: webpack-dev-middleware dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 70e2b28a7..8f20d2db9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16587,8 +16587,8 @@ __metadata: linkType: hard "webpack-dev-middleware@npm:^5.3.1": - version: 5.3.3 - resolution: "webpack-dev-middleware@npm:5.3.3" + version: 5.3.4 + resolution: "webpack-dev-middleware@npm:5.3.4" dependencies: colorette: "npm:^2.0.10" memfs: "npm:^3.4.3" @@ -16597,7 +16597,7 @@ __metadata: schema-utils: "npm:^4.0.0" peerDependencies: webpack: ^4.0.0 || ^5.0.0 - checksum: 31a2f7a11e58a76bdcde1eb8da310b6643844d9b442f9916f48be5b46c103f23490c393c32a9af501ce68226fbb018b811f5a956635ed60a03f9481a4bcd6c76 + checksum: 3004374130f31c2910da39b80e24296009653bb11caa0b8449d962b67e003d7e73d01fbcfda9be1f1f04179f66a9c39f4caf7963df54303b430e39ba5a94f7c2 languageName: node linkType: hard From ba5ca186530b1156871826de2bf2d6b0bb2260c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:41:38 -0400 Subject: [PATCH 21/47] Bump braces from 3.0.2 to 3.0.3 (#2912) Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index 8f20d2db9..f72892fb9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5884,11 +5884,11 @@ __metadata: linkType: hard "braces@npm:^3.0.2, braces@npm:~3.0.2": - version: 3.0.2 - resolution: "braces@npm:3.0.2" + version: 3.0.3 + resolution: "braces@npm:3.0.3" dependencies: - fill-range: "npm:^7.0.1" - checksum: 966b1fb48d193b9d155f810e5efd1790962f2c4e0829f8440b8ad236ba009222c501f70185ef732fef17a4c490bb33a03b90dab0631feafbdf447da91e8165b1 + fill-range: "npm:^7.1.1" + checksum: fad11a0d4697a27162840b02b1fad249c1683cbc510cd5bf1a471f2f8085c046d41094308c577a50a03a579dd99d5a6b3724c4b5e8b14df2c4443844cfcda2c6 languageName: node linkType: hard @@ -8162,12 +8162,12 @@ __metadata: languageName: node linkType: hard -"fill-range@npm:^7.0.1": - version: 7.0.1 - resolution: "fill-range@npm:7.0.1" +"fill-range@npm:^7.1.1": + version: 7.1.1 + resolution: "fill-range@npm:7.1.1" dependencies: to-regex-range: "npm:^5.0.1" - checksum: e260f7592fd196b4421504d3597cc76f4a1ca7a9488260d533b611fc3cefd61e9a9be1417cb82d3b01ad9f9c0ff2dbf258e1026d2445e26b0cf5148ff4250429 + checksum: a7095cb39e5bc32fada2aa7c7249d3f6b01bd1ce461a61b0adabacccabd9198500c6fb1f68a7c851a657e273fce2233ba869638897f3d7ed2e87a2d89b4436ea languageName: node linkType: hard From 22b7ea1b5ea3a4e5344053d566821e9afa75e313 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:41:55 -0400 Subject: [PATCH 22/47] Bump ua-parser-js from 0.7.32 to 0.7.38 (#2913) Bumps [ua-parser-js](https://github.com/faisalman/ua-parser-js) from 0.7.32 to 0.7.38. - [Release notes](https://github.com/faisalman/ua-parser-js/releases) - [Changelog](https://github.com/faisalman/ua-parser-js/blob/master/CHANGELOG.md) - [Commits](https://github.com/faisalman/ua-parser-js/compare/0.7.32...0.7.38) --- updated-dependencies: - dependency-name: ua-parser-js dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f72892fb9..f34931b26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15825,9 +15825,9 @@ __metadata: linkType: hard "ua-parser-js@npm:^0.7.30": - version: 0.7.32 - resolution: "ua-parser-js@npm:0.7.32" - checksum: 0a8a3c482a4b615e7047a522c9a737c70d505f5a94a7e1b7d7675112ce366eb930efeca828f72a6c7fb67e57eafd2575bdfab565a430a51b38c50da312d80980 + version: 0.7.38 + resolution: "ua-parser-js@npm:0.7.38" + checksum: 011609d0176952abc60b7a20e0af266a899b34f4c49a6f5097d6af763da27eacaa3752b710ae4d930d7b99508bb8c0b34ebe8042e1d9fdc4056d051b209b0842 languageName: node linkType: hard From 4f109ed768a5614fa69f6aa2c9650d455b27ba9a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:53:37 -0400 Subject: [PATCH 23/47] Bump follow-redirects from 1.15.3 to 1.15.6 (#2914) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.3 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.15.3...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index f34931b26..608336106 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8281,12 +8281,12 @@ __metadata: linkType: hard "follow-redirects@npm:^1.0.0, follow-redirects@npm:^1.14.9": - version: 1.15.3 - resolution: "follow-redirects@npm:1.15.3" + version: 1.15.6 + resolution: "follow-redirects@npm:1.15.6" peerDependenciesMeta: debug: optional: true - checksum: 60d98693f4976892f8c654b16ef6d1803887a951898857ab0cdc009570b1c06314ad499505b7a040ac5b98144939f8597766e5e6a6859c0945d157b473aa6f5f + checksum: 70c7612c4cab18e546e36b991bbf8009a1a41cf85354afe04b113d1117569abf760269409cb3eb842d9f7b03d62826687086b081c566ea7b1e6613cf29030bf7 languageName: node linkType: hard From 3f0e414e0a47350fe06d403f5c3d36b874e652b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:56:06 -0400 Subject: [PATCH 24/47] Bump tar from 6.1.13 to 6.2.1 (#2917) Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.13 to 6.2.1. - [Release notes](https://github.com/isaacs/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](https://github.com/isaacs/node-tar/compare/v6.1.13...v6.2.1) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/yarn.lock b/yarn.lock index 608336106..d6c5966db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11889,12 +11889,10 @@ __metadata: languageName: node linkType: hard -"minipass@npm:^4.0.0": - version: 4.0.0 - resolution: "minipass@npm:4.0.0" - dependencies: - yallist: "npm:^4.0.0" - checksum: 6656c87ea19e06faa7c1ae3b3125af544d7f563688f9353c6474cc2f53af94eb1d2b8344dfc0cf9bc0a962b51573163c857a2dd67a9a62c4d16390657981e07a +"minipass@npm:^5.0.0": + version: 5.0.0 + resolution: "minipass@npm:5.0.0" + checksum: 61682162d29f45d3152b78b08bab7fb32ca10899bc5991ffe98afc18c9e9543bd1e3be94f8b8373ba6262497db63607079dc242ea62e43e7b2270837b7347c93 languageName: node linkType: hard @@ -15555,16 +15553,16 @@ __metadata: linkType: hard "tar@npm:^6.1.11, tar@npm:^6.1.2": - version: 6.1.13 - resolution: "tar@npm:6.1.13" + version: 6.2.1 + resolution: "tar@npm:6.2.1" dependencies: chownr: "npm:^2.0.0" fs-minipass: "npm:^2.0.0" - minipass: "npm:^4.0.0" + minipass: "npm:^5.0.0" minizlib: "npm:^2.1.1" mkdirp: "npm:^1.0.3" yallist: "npm:^4.0.0" - checksum: add2c3c6d0d71192186ec118d265b92d94be5cd57a0b8fdf0d29ee46dc846574925a5fc57170eefffd78201eda4c45d7604070b5a4b0648e4d6e1d65918b5a82 + checksum: bfbfbb2861888077fc1130b84029cdc2721efb93d1d1fb80f22a7ac3a98ec6f8972f29e564103bbebf5e97be67ebc356d37fa48dbc4960600a1eb7230fbd1ea0 languageName: node linkType: hard From c5d174123576efda4fa657078c313cae3d7e3cee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:56:15 -0400 Subject: [PATCH 25/47] Bump semver from 5.7.1 to 5.7.2 (#2916) Bumps [semver](https://github.com/npm/node-semver) from 5.7.1 to 5.7.2. - [Release notes](https://github.com/npm/node-semver/releases) - [Changelog](https://github.com/npm/node-semver/blob/v5.7.2/CHANGELOG.md) - [Commits](https://github.com/npm/node-semver/compare/v5.7.1...v5.7.2) --- updated-dependencies: - dependency-name: semver dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index d6c5966db..ec327c46d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14732,11 +14732,11 @@ __metadata: linkType: hard "semver@npm:2 || 3 || 4 || 5, semver@npm:^5.5.0": - version: 5.7.1 - resolution: "semver@npm:5.7.1" + version: 5.7.2 + resolution: "semver@npm:5.7.2" bin: - semver: ./bin/semver - checksum: fbc71cf00736480ca0dd67f2527cda6e0fde5447af00bd2ce06cb522d510216603a63ed0c6c87d8904507c1a4e8113e628a71424ebd9e0fd7d345ee8ed249690 + semver: bin/semver + checksum: fca14418a174d4b4ef1fecb32c5941e3412d52a4d3d85165924ce3a47fbc7073372c26faf7484ceb4bbc2bde25880c6b97e492473dc7e9708fdfb1c6a02d546e languageName: node linkType: hard From 8b91f98220049796716f2eaec59c214426f90ab4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:56:28 -0400 Subject: [PATCH 26/47] Bump express from 4.18.2 to 4.19.2 (#2915) Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/master/History.md) - [Commits](https://github.com/expressjs/express/compare/4.18.2...4.19.2) --- updated-dependencies: - dependency-name: express dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/yarn.lock b/yarn.lock index ec327c46d..33fbc81a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5784,12 +5784,12 @@ __metadata: languageName: node linkType: hard -"body-parser@npm:1.20.1": - version: 1.20.1 - resolution: "body-parser@npm:1.20.1" +"body-parser@npm:1.20.2": + version: 1.20.2 + resolution: "body-parser@npm:1.20.2" dependencies: bytes: "npm:3.1.2" - content-type: "npm:~1.0.4" + content-type: "npm:~1.0.5" debug: "npm:2.6.9" depd: "npm:2.0.0" destroy: "npm:1.2.0" @@ -5797,10 +5797,10 @@ __metadata: iconv-lite: "npm:0.4.24" on-finished: "npm:2.4.1" qs: "npm:6.11.0" - raw-body: "npm:2.5.1" + raw-body: "npm:2.5.2" type-is: "npm:~1.6.18" unpipe: "npm:1.0.0" - checksum: 5f8d128022a2fb8b6e7990d30878a0182f300b70e46b3f9d358a9433ad6275f0de46add6d63206da3637c01c3b38b6111a7480f7e7ac2e9f7b989f6133fe5510 + checksum: 3cf171b82190cf91495c262b073e425fc0d9e25cc2bf4540d43f7e7bbca27d6a9eae65ca367b6ef3993eea261159d9d2ab37ce444e8979323952e12eb3df319a languageName: node linkType: hard @@ -6570,6 +6570,13 @@ __metadata: languageName: node linkType: hard +"content-type@npm:~1.0.5": + version: 1.0.5 + resolution: "content-type@npm:1.0.5" + checksum: 585847d98dc7fb8035c02ae2cb76c7a9bd7b25f84c447e5ed55c45c2175e83617c8813871b4ee22f368126af6b2b167df655829007b21aa10302873ea9c62662 + languageName: node + linkType: hard + "convert-source-map@npm:^1.5.0, convert-source-map@npm:^1.7.0": version: 1.9.0 resolution: "convert-source-map@npm:1.9.0" @@ -6591,10 +6598,10 @@ __metadata: languageName: node linkType: hard -"cookie@npm:0.5.0": - version: 0.5.0 - resolution: "cookie@npm:0.5.0" - checksum: aae7911ddc5f444a9025fbd979ad1b5d60191011339bce48e555cb83343d0f98b865ff5c4d71fecdfb8555a5cafdc65632f6fce172f32aaf6936830a883a0380 +"cookie@npm:0.6.0": + version: 0.6.0 + resolution: "cookie@npm:0.6.0" + checksum: c1f8f2ea7d443b9331680598b0ae4e6af18a618c37606d1bbdc75bec8361cce09fe93e727059a673f2ba24467131a9fb5a4eec76bb1b149c1b3e1ccb268dc583 languageName: node linkType: hard @@ -7956,15 +7963,15 @@ __metadata: linkType: hard "express@npm:^4.17.3": - version: 4.18.2 - resolution: "express@npm:4.18.2" + version: 4.19.2 + resolution: "express@npm:4.19.2" dependencies: accepts: "npm:~1.3.8" array-flatten: "npm:1.1.1" - body-parser: "npm:1.20.1" + body-parser: "npm:1.20.2" content-disposition: "npm:0.5.4" content-type: "npm:~1.0.4" - cookie: "npm:0.5.0" + cookie: "npm:0.6.0" cookie-signature: "npm:1.0.6" debug: "npm:2.6.9" depd: "npm:2.0.0" @@ -7990,7 +7997,7 @@ __metadata: type-is: "npm:~1.6.18" utils-merge: "npm:1.0.1" vary: "npm:~1.1.2" - checksum: 869ae89ed6ff4bed7b373079dc58e5dddcf2915a2669b36037ff78c99d675ae930e5fe052b35c24f56557d28a023bb1cbe3e2f2fb87eaab96a1cedd7e597809d + checksum: 3fcd792536f802c059789ef48db3851b87e78fba103423e524144d79af37da7952a2b8d4e1a007f423329c7377d686d9476ac42e7d9ea413b80345d495e30a3a languageName: node linkType: hard @@ -13487,15 +13494,15 @@ __metadata: languageName: node linkType: hard -"raw-body@npm:2.5.1": - version: 2.5.1 - resolution: "raw-body@npm:2.5.1" +"raw-body@npm:2.5.2": + version: 2.5.2 + resolution: "raw-body@npm:2.5.2" dependencies: bytes: "npm:3.1.2" http-errors: "npm:2.0.0" iconv-lite: "npm:0.4.24" unpipe: "npm:1.0.0" - checksum: 280bedc12db3490ecd06f740bdcf66093a07535374b51331242382c0e130bb273ebb611b7bc4cba1b4b4e016cc7b1f4b05a6df885a6af39c2bc3b94c02291c84 + checksum: 863b5171e140546a4d99f349b720abac4410338e23df5e409cfcc3752538c9caf947ce382c89129ba976f71894bd38b5806c774edac35ebf168d02aa1ac11a95 languageName: node linkType: hard From 97be67f80270be066d5df494df18f123510cf1c9 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 10 Jul 2024 17:24:14 +0800 Subject: [PATCH 27/47] Add migration docs for removing methods starting with `_` (#2918) --- docs/v8-migration-api.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/v8-migration-api.md b/docs/v8-migration-api.md index 9544b48e4..ae7209966 100644 --- a/docs/v8-migration-api.md +++ b/docs/v8-migration-api.md @@ -307,6 +307,33 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes __Migration__: Adapt to the new behaviour. You can use `NodePath#shouldSkip` to check whether a NodePath has been skipped before calling `NodePath#requeue()`. +- Remove methods starting with `_` ([#16504](https://github.com/babel/babel/pull/16504)) + + ``` + _assertUnremoved + _call + _callRemovalHooks + _containerInsert + _containerInsertAfter + _containerInsertBefore + _getKey + _getPattern + _getQueueContexts + _getTypeAnnotation + _markRemoved + _remove + _removeFromScope + _replaceWith + _resolve + _resyncKey + _resyncList + _resyncParent + _resyncRemoved + _verifyNodeList + ``` + + __Migration__: These methods are meant to be private so there is no real migration approach. But if your plugin / build is broken by this change, feel free to open an issue and tell us how you use these methods and we can see what we can do after Babel 8 is released. + ### `@babel/compat-data` ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) From eab1cea134185476e4beaec03ce6cb76bdb19e65 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Mon, 15 Jul 2024 18:11:13 +0800 Subject: [PATCH 28/47] Fix REPL CORS error (#2920) --- _redirects | 3 +++ js/repl/CircleCI.ts | 17 ++++------------- js/repl/PluginConfig.ts | 1 - js/repl/Repl.tsx | 1 - js/repl/UriUtils.ts | 1 - js/repl/loadBundle.ts | 8 +------- js/repl/replUtils.ts | 1 - js/repl/types.ts | 3 --- 8 files changed, 8 insertions(+), 27 deletions(-) diff --git a/_redirects b/_redirects index 83a360c41..29c43f458 100644 --- a/_redirects +++ b/_redirects @@ -140,3 +140,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 diff --git a/js/repl/CircleCI.ts b/js/repl/CircleCI.ts index f542dcdb8..57e25c197 100644 --- a/js/repl/CircleCI.ts +++ b/js/repl/CircleCI.ts @@ -1,11 +1,7 @@ import fetch from "unfetch"; -async function sendRequest( - repo: string | undefined | null, - uri: string -): Promise { - const urlRepo = repo && repo.length ? repo : "babel/babel"; - const fullURL = `https://circleci.com/api/v1.1/project/github/${urlRepo}/${uri}`; +async function sendRequest(uri: string): Promise { + const fullURL = `/circleci/api/${uri}`; let response; try { response = await fetch(fullURL).then((res) => res.json()); @@ -21,14 +17,11 @@ async function sendRequest( } export async function loadBuildArtifacts( - repo: string | undefined | null, regExp: RegExp, - build: number | string, - // eslint-disable-line no-unused-vars - cb: (url: string, error?: string) => Promise + build: number | string ): Promise { try { - const response = await sendRequest(repo, `${build}/artifacts`); + const response = await sendRequest(`${build}/artifacts`); const artifacts = response.filter((x) => regExp.test(x.path)); if (!artifacts || artifacts.length === 0) { throw new Error( @@ -42,14 +35,12 @@ export async function loadBuildArtifacts( } export async function loadLatestBuildNumberForBranch( - repo: string | undefined | null, branch: string, jobName: string, limit: number = 30 ): Promise { try { const response = await sendRequest( - repo, `tree/${branch}?limit=${limit}&filter=successful` ); if (!response) throw new Error("No builds found"); diff --git a/js/repl/PluginConfig.ts b/js/repl/PluginConfig.ts index 5e4feac97..940951d04 100644 --- a/js/repl/PluginConfig.ts +++ b/js/repl/PluginConfig.ts @@ -93,7 +93,6 @@ const replDefaults: ReplState = { builtIns: false, spec: false, loose: false, - circleciRepo: "", code: "", debug: false, evaluate: false, diff --git a/js/repl/Repl.tsx b/js/repl/Repl.tsx index 6ec7e9079..ffdf20e83 100644 --- a/js/repl/Repl.tsx +++ b/js/repl/Repl.tsx @@ -653,7 +653,6 @@ class Repl extends React.Component { corejs: envConfig.corejs, spec: envConfig.isSpecEnabled, loose: envConfig.isLooseEnabled, - circleciRepo: state.babel.circleciRepo, code: state.code, debug: state.debugEnvPreset, modules: envConfig.modules, diff --git a/js/repl/UriUtils.ts b/js/repl/UriUtils.ts index b989985d4..37da34cb6 100644 --- a/js/repl/UriUtils.ts +++ b/js/repl/UriUtils.ts @@ -14,7 +14,6 @@ const URL_KEYS = [ "forceAllTransforms", "modules", "shippedProposals", - "circleciRepo", "evaluate", "fileSize", "timeTravel", diff --git a/js/repl/loadBundle.ts b/js/repl/loadBundle.ts index fe60f3983..a4f6092da 100644 --- a/js/repl/loadBundle.ts +++ b/js/repl/loadBundle.ts @@ -62,18 +62,12 @@ export default async function loadBundle( // to main, we map /build/7.0 and /build/master to // /build/main for backwards compatibility. build = await loadLatestBuildNumberForBranch( - state.circleciRepo, build === "7.0" || build === "master" ? "main" : build, "build-standalone" ); } const regExp = new RegExp(`${packageName}/${packageFile}$`); - const url = await loadBuildArtifacts( - state.circleciRepo, - regExp, - build, - doLoad - ); + const url = await loadBuildArtifacts(regExp, build); return doLoad(url); } catch (ex) { return doLoad(null, ex.message); diff --git a/js/repl/replUtils.ts b/js/repl/replUtils.ts index 420b70754..062a80a47 100644 --- a/js/repl/replUtils.ts +++ b/js/repl/replUtils.ts @@ -66,7 +66,6 @@ export const persistedStateToBabelState = ( ): BabelState => ({ availablePresets: [], build: persistedState.build, - circleciRepo: persistedState.circleciRepo, didError: false, isLoaded: false, isLoading: true, diff --git a/js/repl/types.ts b/js/repl/types.ts index 6796de14d..1f18be6ed 100644 --- a/js/repl/types.ts +++ b/js/repl/types.ts @@ -75,7 +75,6 @@ export type BabelState = LazyLoadedState & { availablePresets: Array; build: any; errorMessage?: string; - circleciRepo: string; config: PluginConfig; version: any; }; @@ -84,7 +83,6 @@ export type EnvState = LazyLoadedState & { availablePresets: Array; build: number; errorMessage?: string; - circleciRepo: string; config: PluginConfig; version: any; isEnabled: boolean; @@ -129,7 +127,6 @@ export type ReplState = { corejs?: string | false; spec: boolean; loose: boolean; - circleciRepo: string; code: string; debug: boolean; evaluate: boolean; From 90481ce58f85fb2644f04f04913e1e7ce878821e Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Fri, 26 Jul 2024 21:17:36 +0800 Subject: [PATCH 29/47] [Babel 8] Doc for removing some `NodePath` methods (#2924) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Huáng Jùnliàng --- docs/v8-migration-api.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docs/v8-migration-api.md b/docs/v8-migration-api.md index ae7209966..7b1944c8f 100644 --- a/docs/v8-migration-api.md +++ b/docs/v8-migration-api.md @@ -290,6 +290,31 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes ### `@babel/traverse` +![medium](https://img.shields.io/badge/risk%20of%20breakage%3F-medium-yellow.svg) + +- Remove some `NodePath` methods ([#16655](https://github.com/babel/babel/pull/16655)) + + __Migration__: + `hoist`, `updateSiblingKeys`, `call`, `setScope`, `resync`, `popContext`, `pushContext`, `setup`, `setKey` + These methods are meant to be private so there is no real migration approach. But if your plugin / build is broken by this change, feel free to open an issue and tell us how you use these methods and we can see what we can do after Babel 8 is released. + + `is`, `isnt`, `has`, `equals` + Access `path.node` instead. + ```diff + --- functionExpressionPath.equals("id", idNode) + +++ functionExpressionPath.node.id === idNode + + --- functionExpressionPath.is("id") + --- functionExpressionPath.has("id") + +++ functionExpressionPath.node.id + + --- functionExpressionPath.has("arguments") + +++ !!functionExpressionPath.node.arguments.length + + --- functionExpressionPath.isnt("async") + +++ !functionExpressionPath.node.async + ``` + ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) - Remove `block` argument from `Scope#rename` ([#15288](https://github.com/babel/babel/pull/15288)) From 6ea57043da0040c5ddaa8e1b905932201244a2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 26 Jul 2024 12:56:18 -0400 Subject: [PATCH 30/47] Add duplicate-named-capturing-groups to ES2025 (#2893) --- _redirects | 33 ++++++++++--------- ...-duplicate-named-capturing-groups-regex.md | 16 +++++---- docs/plugins-list.md | 5 ++- website/sidebars.js | 6 +++- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/_redirects b/_redirects index 29c43f458..eb887e41f 100644 --- a/_redirects +++ b/_redirects @@ -65,22 +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-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-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 diff --git a/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md b/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md index 5e9b17a08..608b7e36a 100644 --- a/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md +++ b/docs/plugin-proposal-duplicate-named-capturing-groups-regex.md @@ -1,9 +1,13 @@ --- -id: babel-plugin-proposal-duplicate-named-capturing-groups-regex -title: "@babel/plugin-proposal-duplicate-named-capturing-groups-regex" +id: babel-plugin-transform-duplicate-named-capturing-groups-regex +title: "@babel/plugin-transform-duplicate-named-capturing-groups-regex" sidebar_label: duplicate-named-capturing-groups-regex --- +:::info +This plugin is included in `@babel/preset-env`, in [ES2025](https://github.com/tc39/proposals/blob/master/finished-proposals.md). +::: + This plugin transforms regular expression _literals_ to support duplicate named capturing groups. It does not patch the `new RegExp` constructor, since its arguments cannot be pre-transformed statically: to handle runtime behavior of functions/classes, you will need to use a polyfill instead. ## Examples @@ -30,7 +34,7 @@ console.log(re.exec("02-1999").groups.year); ## Installation ```shell npm2yarn -npm install --save-dev @babel/plugin-proposal-duplicate-named-capturing-groups-regex +npm install --save-dev @babel/plugin-transform-duplicate-named-capturing-groups-regex ``` ## Usage @@ -39,21 +43,21 @@ npm install --save-dev @babel/plugin-proposal-duplicate-named-capturing-groups-r ```json title="babel.config.json" { - "plugins": ["@babel/plugin-proposal-duplicate-named-capturing-groups-regex"] + "plugins": ["@babel/plugin-transform-duplicate-named-capturing-groups-regex"] } ``` ### Via CLI ```sh title="Shell" -babel --plugins @babel/plugin-proposal-duplicate-named-capturing-groups-regex script.js +babel --plugins @babel/plugin-transform-duplicate-named-capturing-groups-regex script.js ``` ### Via Node API ```js title="JavaScript" require("@babel/core").transformSync("code", { - plugins: ["@babel/plugin-proposal-duplicate-named-capturing-groups-regex"], + plugins: ["@babel/plugin-transform-duplicate-named-capturing-groups-regex"], }); ``` diff --git a/docs/plugins-list.md b/docs/plugins-list.md index c7535510f..06e4d35f9 100644 --- a/docs/plugins-list.md +++ b/docs/plugins-list.md @@ -11,7 +11,6 @@ sidebar_label: Plugins List #### Stage 3 - [decorators](plugin-proposal-decorators.md) -- [duplicate-named-capturing-groups-regex](plugin-proposal-duplicate-named-capturing-groups-regex.md) - [json-modules](plugin-proposal-json-modules.md) - [import-wasm-source](plugin-proposal-import-wasm-source.md) - [regexp-modifiers](plugin-proposal-regexp-modifiers.md) @@ -27,6 +26,10 @@ sidebar_label: Plugins List - [throw-expressions](plugin-proposal-throw-expressions.md) - [record-and-tuple](plugin-proposal-record-and-tuple.md) +### ES2025 + +- [duplicate-named-capturing-groups-regex](plugin-proposal-duplicate-named-capturing-groups-regex.md) + ### ES2024 - [unicode-sets-regex](plugin-transform-unicode-sets-regex.md) diff --git a/website/sidebars.js b/website/sidebars.js index edfea9acd..c4592bc93 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -42,6 +42,11 @@ module.exports = { id: "babel-preset-env", }, items: [ + { + type: "category", + label: "ES2025", + items: ["babel-plugin-transform-duplicate-named-capturing-groups-regex"], + }, { type: "category", label: "ES2024", @@ -242,7 +247,6 @@ module.exports = { "TC39 Proposals": { "Stage 3": [ "babel-plugin-proposal-decorators", - "babel-plugin-proposal-duplicate-named-capturing-groups-regex", "babel-plugin-proposal-explicit-resource-management", "babel-plugin-proposal-import-wasm-source", "babel-plugin-proposal-json-modules", From 3dd26418ab19eadf9fa23f4639b661fc7932d62f Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 26 Jul 2024 17:56:30 +0100 Subject: [PATCH 31/47] Add docs for plugin-bugfix-safari-class-field-initializer-scope (#2921) --- ...ix-safari-class-field-initializer-scope.md | 41 +++++++++++++++++++ website/sidebars.js | 1 + 2 files changed, 42 insertions(+) create mode 100644 docs/plugin-bugfix-safari-class-field-initializer-scope.md diff --git a/docs/plugin-bugfix-safari-class-field-initializer-scope.md b/docs/plugin-bugfix-safari-class-field-initializer-scope.md new file mode 100644 index 000000000..d5f21096e --- /dev/null +++ b/docs/plugin-bugfix-safari-class-field-initializer-scope.md @@ -0,0 +1,41 @@ +--- +id: babel-plugin-bugfix-safari-class-field-initializer-scope +title: "@babel/plugin-bugfix-safari-class-field-initializer-scope" +sidebar_label: bugfix-safari-class-field-initializer-scope +--- + +This bugfix plugin wraps some class field initializers with an IIFE to workaround [a WebKit bug](https://webkit.org/b/236843) which affects Safari 15. + +:::tip +This plugin is included in `@babel/preset-env`, and Babel will automatically enable this plugin for you when your `targets` are affected by the browser bug. +::: + +## Installation + +```shell npm2yarn +npm install --save-dev @babel/plugin-bugfix-safari-class-field-initializer-scope +``` + +## Usage + +### With a configuration file (Recommended) + +```json title="babel.config.json" +{ + "plugins": ["@babel/plugin-bugfix-safari-class-field-initializer-scope"] +} +``` + +### Via CLI + +```sh title="Shell" +babel --plugins @babel/plugin-bugfix-safari-class-field-initializer-scope script.js +``` + +### Via Node API + +```js title="JavaScript" +require("@babel/core").transformSync("code", { + plugins: ["@babel/plugin-bugfix-safari-class-field-initializer-scope"], +}); +``` diff --git a/website/sidebars.js b/website/sidebars.js index c4592bc93..f2139a301 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -158,6 +158,7 @@ module.exports = { label: "Bugfix", items: [ "babel-plugin-bugfix-firefox-class-in-computed-class-key", + "babel-plugin-bugfix-safari-class-field-initializer-scope", "babel-plugin-bugfix-safari-id-destructuring-collision-in-function-expression", "babel-plugin-bugfix-v8-spread-parameters-in-optional-chaining", ], From 5c021854003fec55fd2a56fc9c93a961a3c73057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 26 Jul 2024 18:57:01 +0200 Subject: [PATCH 32/47] Add docs for `uncheckedRequire` option (#2928) --- docs/plugin-proposal-json-modules.md | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/docs/plugin-proposal-json-modules.md b/docs/plugin-proposal-json-modules.md index 795bac5fd..1f579ca49 100644 --- a/docs/plugin-proposal-json-modules.md +++ b/docs/plugin-proposal-json-modules.md @@ -72,9 +72,7 @@ npm install --save-dev @babel/plugin-proposal-json-modules ```json title="babel.config.json" { - "plugins": [ - "@babel/plugin-proposal-json-modules" - ] + "plugins": ["@babel/plugin-proposal-json-modules"] } ``` @@ -88,12 +86,38 @@ babel --plugins=@babel/plugin-proposal-json-modules script.js ```js title="JavaScript" require("@babel/core").transformSync("code", { - plugins: [ - "@babel/plugin-proposal-json-modules" - ], + plugins: ["@babel/plugin-proposal-json-modules"], }); ``` +## Options + +### `uncheckedRequire` + +Type: `boolean`
+Default: `false`
+Added in `v7.25.0` + +When set to `true`, the plugin will generate a simpler output by using `require` directly to import the JSON file. When targeting CommonJS, this option leads to output that is easier to analyze for bundlers but doesn't check that the module being imported is actually JSON: + +**In** + +```js +import data from "./data.json" with { type: "json" }; +``` + +**Out (without `uncheckedRequire: true`)** + +```js +const data = JSON.parse(require("fs").readFileSync(require.resolve("./data.json"))); +``` + +**Out (with `uncheckedRequire: true`)** + +```js +const data = require("./data.json"); +``` + ## References - [Proposal: JSON Modules](https://github.com/tc39/proposal-json-modules/) From 05b6483c695feaabcfe6e643732f6a9a33779175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 26 Jul 2024 19:05:32 +0200 Subject: [PATCH 33/47] Add release post for 7.25.0 (#2927) Co-authored-by: Brian Ng Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> --- website/blog/2024-07-26-7.25.0.md | 110 ++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 website/blog/2024-07-26-7.25.0.md diff --git a/website/blog/2024-07-26-7.25.0.md b/website/blog/2024-07-26-7.25.0.md new file mode 100644 index 000000000..75c3c98ce --- /dev/null +++ b/website/blog/2024-07-26-7.25.0.md @@ -0,0 +1,110 @@ +--- +layout: post +title: "7.25.0 Released: Safari bugfixes and duplicated named capturing groups" +author: Babel Team +authorURL: https://twitter.com/babeljs +date: 2024-07-26 0:00:00 +categories: announcements +share_text: "Babel 7.25.0 Released" +--- + +###### tags: `Babel blog article` + +Babel 7.25.0 is out! + +`@babel/preset-env` now supports the [duplicated named capturing groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups) proposal for Regular Expressions by default, as well as a bugfix for class fields when targeting Safari. This version also improves support for compiling [JSON module imports](https://babeljs.io/docs/babel-plugin-proposal-json-modules) to CommonJS, and adds support for config files to `@babel/node`'s `--eval` mode. + +You can read the whole changelog [on GitHub](https://github.com/babel/babel/releases/tag/v7.25.0). + + + +> If you or your company want to support Babel and the evolution of JavaScript, but aren't sure how, you can donate to us on our [Open Collective](https://github.com/babel/babel?sponsor=1) and, better yet, work with us on the implementation of [new ECMAScript proposals](https://github.com/babel/proposals) directly! As a volunteer-driven project, we rely on the community's support to fund our efforts in supporting the wide range of JavaScript users. Reach out at [team@babeljs.io](mailto:team@babeljs.io) if you'd like to discuss more! + +## Highlights + +### Duplicated named capturing groups ([#16445](https://github.com/babel/babel/pull/16445)) + +The [duplicated named capturing groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups) proposal allows re-using the same name for groups in alternative branches within a regular expression. For example, a RegExp that matches dates either in the `dd/mm/yyyy` or `yyyy-mm-dd` format could be written as + +```javascript +let re = + /(?\d\d)\/(?\d\d)\/(?\d\d\d\d)|(?\d\d\d\d)-(?\d\d)-(?\d\d)/; + +"21/12/2023".match(re).groups.day; // 21 +"2023-12-21".match(re).groups.day; // 21 +``` + +The proposal reached Stage 4 in the April 2024 TC39 meeting, and will be included in the next version of the JavaScript standard. It is thus now enabled by default in `@babel/preset-env` (when needed based on your [targets](https://babeljs.io/docs/options#targets)), and you can safely remove `@babel/plugin-proposal-duplicate-named-capturing-groups-regex` from your configuration. + +If for any reason you still need to explicitly list the plugin, it has now been renamed to `@babel/plugin-transform-duplicate-named-capturing-groups-regex` as the proposal became a standard language feature. + +### Simplify JSON modules imports in CommonJS ([#16579](https://github.com/babel/babel/pull/16579)) + +After introducing support for transforming [JSON modules](https://github.com/tc39/proposal-json-modules) imports in Babel 7.24.0, we realized that the generated output was not friendly to CommonJS bundlers. + +Given this code: + +```javascript +import myConfig from "./config.json" with { type: "json" }; +``` + +[`@babel/plugin-proposal-json-modules`](https://babeljs.io/docs/babel-plugin-proposal-json-modules) would compile it to the following, when targeting CommonJS on Node.js: + +```javascript +const myConfig = JSON.parse( + require("fs").readFileSync(require.resolve("./config.json")) +); +``` + +The `JSON.parse` + `readFileSync` combination is necessary to ensure that `config.json` is indeed a JSON file, and not a `config.json.js` file trying to sneakily execute some code while being loaded. + +`@babel/plugin-proposal-json-modules` has now an `uncheckedRequire` option to simplify the output, at the cost of less validation. You can enable it in your configuration: + +```json title="babel.config.json" +{ + "plugins": [ + ["@babel/plugin-proposal-json-modules", { "uncheckedRequire": true }] + ] +} +``` + +and Babel will generate the following code: + +```javascript +const myConfig = require("./config.json"); +``` + +### `@babel/plugin-bugfix-safari-class-field-initializer-scope` ([#16569](https://github.com/babel/babel/pull/16569)) + +Safari versions up to 16 (included) have [a bug](https://bugs.webkit.org/show_bug.cgi?id=236843) when using parentheses around expressions in class fields. For example, the following code would throw an error: + +```javascript +{ + let a = [3]; + new (class { + c = a[0]; + })(); +} +``` + +This is especially problematic when using Webpack or when compiling to CommonJS, as they add parentheses when transforming imports. For example, this input code: + +```javascript +import { hello } from "./dep"; + +class A { + prop = hello(); +} +``` + +would become + +```javascript +var _dep = /* ... */; + +class A { + prop = (0, _dep.hello)(); +} +``` + +[David Taylor](https://github.com/davidtaylorhq) implemented a fix (thanks!) in the new `@babel/plugin-bugfix-safari-class-field-initializer-scope` package, which is enabled by default in `@babel/preset-env` when your targets include Safari versions up to 16. From 7d5e62457f907a015529a7ba0f86e4bd46ad9f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 26 Jul 2024 19:08:44 +0200 Subject: [PATCH 34/47] Remove tag from 7.25.0 blog post --- website/blog/2024-07-26-7.25.0.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/website/blog/2024-07-26-7.25.0.md b/website/blog/2024-07-26-7.25.0.md index 75c3c98ce..b30c54c16 100644 --- a/website/blog/2024-07-26-7.25.0.md +++ b/website/blog/2024-07-26-7.25.0.md @@ -8,8 +8,6 @@ categories: announcements share_text: "Babel 7.25.0 Released" --- -###### tags: `Babel blog article` - Babel 7.25.0 is out! `@babel/preset-env` now supports the [duplicated named capturing groups](https://github.com/tc39/proposal-duplicate-named-capturing-groups) proposal for Regular Expressions by default, as well as a bugfix for class fields when targeting Safari. This version also improves support for compiling [JSON module imports](https://babeljs.io/docs/babel-plugin-proposal-json-modules) to CommonJS, and adds support for config files to `@babel/node`'s `--eval` mode. From 7ff59f9cf09957fa0eaf067f307a4e36032868bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 26 Jul 2024 19:15:48 +0200 Subject: [PATCH 35/47] The Safari bug is _before_ 16 --- website/blog/2024-07-26-7.25.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/blog/2024-07-26-7.25.0.md b/website/blog/2024-07-26-7.25.0.md index b30c54c16..466b897e5 100644 --- a/website/blog/2024-07-26-7.25.0.md +++ b/website/blog/2024-07-26-7.25.0.md @@ -74,7 +74,7 @@ const myConfig = require("./config.json"); ### `@babel/plugin-bugfix-safari-class-field-initializer-scope` ([#16569](https://github.com/babel/babel/pull/16569)) -Safari versions up to 16 (included) have [a bug](https://bugs.webkit.org/show_bug.cgi?id=236843) when using parentheses around expressions in class fields. For example, the following code would throw an error: +Safari versions older than 16 have [a bug](https://bugs.webkit.org/show_bug.cgi?id=236843) when using parentheses around expressions in class fields. For example, the following code would throw an error: ```javascript { @@ -105,4 +105,4 @@ class A { } ``` -[David Taylor](https://github.com/davidtaylorhq) implemented a fix (thanks!) in the new `@babel/plugin-bugfix-safari-class-field-initializer-scope` package, which is enabled by default in `@babel/preset-env` when your targets include Safari versions up to 16. +[David Taylor](https://github.com/davidtaylorhq) implemented a fix (thanks!) in the new `@babel/plugin-bugfix-safari-class-field-initializer-scope` package, which is enabled by default in `@babel/preset-env` when your targets include Safari versions older than 16. From 06d451b1a9ab9581902ce310567d05c9d51260bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Fri, 26 Jul 2024 17:45:19 -0400 Subject: [PATCH 36/47] add 7.25.0 to past versions (#2929) * add 7.25.0 to past versions * add repl past versions * update announcement * update link --- _redirects | 1 + js/repl/past-versions.json | 5 ++++- website/past-versions.json | 1 + website/src/pages/index.js | 6 +++--- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/_redirects b/_redirects index eb887e41f..8ca5e4688 100644 --- a/_redirects +++ b/_redirects @@ -94,6 +94,7 @@ 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.23.0 /7.22.0 /blog/2023/05/26/7.22.0 diff --git a/js/repl/past-versions.json b/js/repl/past-versions.json index 7352befe1..255288f09 100644 --- a/js/repl/past-versions.json +++ b/js/repl/past-versions.json @@ -1,5 +1,8 @@ [ - "8.0.0-alpha.2", + "8.0.0-alpha.12", + "7.24.10", + "7.23.10", + "7.22.20", "7.21.9", "7.20.15", "7.19.6", diff --git a/website/past-versions.json b/website/past-versions.json index 127b8a51f..ba48695b5 100644 --- a/website/past-versions.json +++ b/website/past-versions.json @@ -1,4 +1,5 @@ [ + "7.25.0", "7.24.0", "7.23.0", "7.22.0", diff --git a/website/src/pages/index.js b/website/src/pages/index.js index 2e2036c79..49e968494 100755 --- a/website/src/pages/index.js +++ b/website/src/pages/index.js @@ -219,9 +219,9 @@ const Hero = ({ language }) => (
- Babel 7.24 is released! Please read our{" "} - blog post for highlights and{" "} - + Babel 7.25 is released! Please read our{" "} + blog post for highlights and{" "} + changelog {" "} for more details! From 86dee747193f4ea8030fb556083756cb5ff386af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 27 Jul 2024 13:02:49 +0200 Subject: [PATCH 37/47] Update 2024-07-26-7.25.0.md --- website/blog/2024-07-26-7.25.0.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/website/blog/2024-07-26-7.25.0.md b/website/blog/2024-07-26-7.25.0.md index 466b897e5..4f23dcc0e 100644 --- a/website/blog/2024-07-26-7.25.0.md +++ b/website/blog/2024-07-26-7.25.0.md @@ -79,9 +79,9 @@ Safari versions older than 16 have [a bug](https://bugs.webkit.org/show_bug.cgi? ```javascript { let a = [3]; - new (class { - c = a[0]; - })(); + new class { + c = (a)[0]; + }; } ``` From 3d3732cc14cba99a96b291c5a36d3875bfe68095 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 29 Jul 2024 18:39:37 +0300 Subject: [PATCH 38/47] fix(options): fix nested directives usage (#2908) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(options): drop visual noise * fix nested directive * fix another nested babel 7 directive --------- Co-authored-by: Huáng Jùnliàng --- docs/options.md | 4 ++-- docs/plugin-transform-runtime.md | 4 ++-- docs/preset-react.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/options.md b/docs/options.md index d234940ac..b1a47563d 100644 --- a/docs/options.md +++ b/docs/options.md @@ -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. @@ -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 diff --git a/docs/plugin-transform-runtime.md b/docs/plugin-transform-runtime.md index 65c7296ea..b866e1a6a 100644 --- a/docs/plugin-transform-runtime.md +++ b/docs/plugin-transform-runtime.md @@ -462,13 +462,13 @@ var Person = function Person() { :::babel8 -The following options where removed in Babel 8.0.0: +The following options were removed in Babel 8.0.0: - `corejs` - `helpers` - `regenerator` ::: -The following options where removed in Babel 7.0.0: +The following options were removed in Babel 7.0.0: - `useBuiltIns` - `polyfill` diff --git a/docs/preset-react.md b/docs/preset-react.md index be70a26c3..050171b5b 100644 --- a/docs/preset-react.md +++ b/docs/preset-react.md @@ -176,7 +176,7 @@ Replace the function used when compiling JSX expressions. It should be a qualifi Replace the component used when compiling JSX fragments. It should be a valid JSX tag name. -:::babel7 +::::babel7 #### `useBuiltIns` @@ -200,7 +200,7 @@ This option will be removed in Babel 8. Set `useSpread` to `true` if you are tar When spreading props, use inline object with spread elements directly instead of Babel's extend helper or `Object.assign`. -::: +:::: ### babel.config.js From f9eeddda01074e5584e4209f09d6d63b7ef2dbc0 Mon Sep 17 00:00:00 2001 From: David LJ Date: Wed, 31 Jul 2024 18:35:55 +0200 Subject: [PATCH 39/47] fix(options): fix plugin / present entries anchors (#2930) --- docs/options.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/options.md b/docs/options.md index b1a47563d..a632e61d0 100644 --- a/docs/options.md +++ b/docs/options.md @@ -282,7 +282,7 @@ babelrcRoots: [ ### `plugins` -Type: `Array` ([`PluginEntry`](#plugin-preset-entries))
+Type: `Array` ([`PluginEntry`](#pluginpreset-entries))
Default: `[]`
An array of plugins to activate when processing this file. For more information on how @@ -295,7 +295,7 @@ representation of a plugin or preset, you should use [`babel.createConfigItem()` ### `presets` -Type: `Array` ([`PresetEntry`](#plugin-preset-entries))
+Type: `Array` ([`PresetEntry`](#pluginpreset-entries))
Default: `[]`
An array of presets to activate when processing this file. For more information on how From 287e0adc20a4ab2a241999972de97594b1e5395c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Thu, 1 Aug 2024 14:04:10 -0400 Subject: [PATCH 40/47] improve Babel generator docs (#2931) --- docs/generator.md | 21 ++++++++++++++++++++- docs/parser.md | 4 ++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/docs/generator.md b/docs/generator.md index 7fe578ec2..8a121bcdf 100644 --- a/docs/generator.md +++ b/docs/generator.md @@ -3,7 +3,7 @@ id: babel-generator title: "@babel/generator" --- -> Turns an AST into code. +> Turns Babel AST into code. ## Install @@ -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 `
` 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 = () =>
example
"; +const ast = parse(code, { plugins: ["jsx" ] }); + +const output = generate( + ast, +); + +// true +output.includes("
"); +``` + ## Options
diff --git a/docs/parser.md b/docs/parser.md index d80cd613b..dd7befb40 100644 --- a/docs/parser.md +++ b/docs/parser.md @@ -121,8 +121,8 @@ It is based on [ESTree spec][] with the following deviations: - [ImportExpression][] is replaced with a [CallExpression][] whose `callee` is an [Import] node. This change will be reversed in Babel 8. - [ExportAllDeclaration][] with `exported` field is replaced with an [ExportNamedDeclaration][] containing an [ExportNamespaceSpecifier][] node. -:::tip -There is now an `estree` plugin which reverts these deviations +:::note +The `estree` plugin can revert these deviations. Use it only if you are passing Babel AST to other ESTree-compliant tools. ::: AST for JSX code is based on [Facebook JSX AST][]. From b3f6ea3908ef1973519961e8fa723cfb9abce162 Mon Sep 17 00:00:00 2001 From: Dwij <96073160+Dwij1704@users.noreply.github.com> Date: Sun, 11 Aug 2024 07:32:03 -0400 Subject: [PATCH 41/47] Updated Broken Link Broken Link #2934 (#2936) --- docs/preset-react.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/preset-react.md b/docs/preset-react.md index 050171b5b..ea724bf61 100644 --- a/docs/preset-react.md +++ b/docs/preset-react.md @@ -22,7 +22,7 @@ Automatic runtime (since `v7.9.0`) adds the functionality for these plugins auto ## Installation -> You can also check out the React [Getting Started page](https://facebook.github.io/react/docs/hello-world.html) +> You can also check out the React [Getting Started page](https://react.dev/learn/installation) ```shell npm2yarn npm install --save-dev @babel/preset-react From eccff2f3bfce49f0a6e256e7be9a9f2161b80021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 19 Aug 2024 12:14:40 +0200 Subject: [PATCH 42/47] Add Route4Me sponsor logo (#2938) --- website/data/sponsors.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/data/sponsors.yml b/website/data/sponsors.yml index db876b998..a59d18f64 100644 --- a/website/data/sponsors.yml +++ b/website/data/sponsors.yml @@ -16,3 +16,9 @@ type: opencollective tier: gold-sponsors monthly: 1000 +- name: Route Planner + url: https://route4me.com/ + image: https://github.com/user-attachments/assets/002949fe-aa5e-4311-b77f-7f2c905e91f5 + type: opencollective + tier: silver-sponsors + monthly: 500 From 4cfea29424a948b12c9a0e5925ea4b002d9558e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 4 Sep 2024 15:52:29 +0200 Subject: [PATCH 43/47] Migration: min Node.js version for Babel 8 (#2947) --- docs/v8-migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/v8-migration.md b/docs/v8-migration.md index 7d1327979..1e4525c93 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -13,7 +13,7 @@ Refer users to this document when upgrading to Babel 8 from Babel 7. If you are ### Node.js support -All Babel 8 packages require Node.js `^18.20.0 || ^20.10.0 || >=21.0.0`. +All Babel 8 packages require Node.js `^18.20.0 || ^20.17.0 || >=22.8.0`. We highly encourage you to use a newer version of Node.js (LTS v20) since the previous versions are not maintained. See [nodejs/Release](https://github.com/nodejs/Release) for more information. From 9423c66d453f4ab2518300a86189da76911e8ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Wed, 4 Sep 2024 16:13:47 +0200 Subject: [PATCH 44/47] Add Igalia as a base support sponsor (#2946) --- website/data/sponsors.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/data/sponsors.yml b/website/data/sponsors.yml index a59d18f64..108db20f5 100644 --- a/website/data/sponsors.yml +++ b/website/data/sponsors.yml @@ -1,3 +1,9 @@ +- name: Igalia + url: https://www.igalia.com/ + image: https://images.opencollective.com/igalia/1c2e7cb/logo/256.png + type: opencollective + tier: base-support-sponsor + yearly: 30000 # There is not actual amount, but we need a large enough amount to fit in the tier - name: Coinbase url: https://github.com/coinbase image: https://avatars.githubusercontent.com/u/1885080?s=200&v=4 From 4bad02bca0bc31ee3b225efdd774c1a3cbd693df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Fri, 6 Sep 2024 15:55:46 +0200 Subject: [PATCH 45/47] [babel 8] Docs for babel/node args order (#2950) --- docs/node.md | 16 +++++++++++++++- docs/v8-migration.md | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/node.md b/docs/node.md index e37ec7d6f..04e170840 100644 --- a/docs/node.md +++ b/docs/node.md @@ -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 | diff --git a/docs/v8-migration.md b/docs/v8-migration.md index 1e4525c93..fbadc4cb1 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -426,6 +426,8 @@ The following syntax plugins are no longer needed, you can safely remove them fr - The `-gc` and `-d` command-line flags have been removed ([#15956](https://github.com/babel/babel/pull/15956)) **Migration**: Use the `--expose-gc` and `--inspect` Node.js flags respectively. Note that although `-d` was short for `--debug`, the latter has been [deprecated since Node.js 7.7.0](https://nodejs.org/en/docs/guides/debugging-getting-started#legacy-debugger). +- Command-line flags for Node.js and Babel must now be passed _before_ the filename, while flags for the script itself must be passed after. ([#16706](https://github.com/babel/babel/pull/16706)) + ## Compilation Changes ### Default target From b5d8f968134386ebc2e762c890e89c5ee4eccfff Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:56:12 +0800 Subject: [PATCH 46/47] [Babel 8] doc: Remove `decimal` from parser (#2945) --- docs/v8-migration.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/v8-migration.md b/docs/v8-migration.md index fbadc4cb1..238d4cf82 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -311,6 +311,17 @@ The following syntax plugins are no longer needed, you can safely remove them fr **Migration**: Remove the option from your config, since it's now enabled by default. Previously the `classFeatures` plugin enables `@babel/parser` to produce class properties AST compatible with ESLint 8, following the ESTree specification. In Babel 8 the `eslint-parser` only works with ESLint 8 and above. + - Remove `decimal` plugin option [#16741](https://github.com/babel/babel/pull/16741) + + **Migration**: Migrate your project to the latest proposal and remove the plugin from your config since the latest proposal doesn't have syntax anymore. + + ```diff title=example.js + - 1.03m + + new Decimal("1.03") + - decimal1 + decimal2 + + decimal1.add(decimal2) + ``` + ### `@babel/generator` {#configuration-change-generator} ![medium](https://img.shields.io/badge/risk%20of%20breakage%3F-medium-yellow.svg) From 1c62dd817e22e60a6931ef43c15e38415f5f915f Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:57:14 +0800 Subject: [PATCH 47/47] [Babel 8] doc: Split `typeParameter` of `TSMappedType` (#2939) --- docs/v8-migration-api.md | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/v8-migration-api.md b/docs/v8-migration-api.md index 7b1944c8f..7a2566cf2 100644 --- a/docs/v8-migration-api.md +++ b/docs/v8-migration-api.md @@ -33,7 +33,7 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes // AST in Babel 8 { type: "ImportExpression", - source: StringLitera("foo"), + source: StringLiteral("foo"), options: Identifier("options") } ``` @@ -77,6 +77,39 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes - For `node.parameters` in Babel 7, use `node.params` in Babel 8 - For `node.typeAnnotation` in Babel 7, use `node.returnType` in Babel 8 +![medium](https://img.shields.io/badge/risk%20of%20breakage%3F-medium-yellow.svg) + +- Split `typeParameter` of `TSMappedType` ([#16733](https://github.com/babel/babel/pull/16733)). + + For a `TSMappedType` node, the `typeParameter` attribute is split into `key` and `constraint` attributes. + This is to align the AST for TS nodes with `@typescript-eslint`. + + ```ts + // Example input + let map1: { [P in string]: number; }; + + // AST in Babel 7 + { + type: "TSMappedType", + typeParameter: { + type: "TypeParameter", + name: Identifier("P"), + constraint: TSStringKeyword() + }, + typeAnnotation: TSNumberKeyword(), + } + + // AST in Babel 8 + { + type: "TSMappedType", + key: Identifier("P"), + constraint: TSStringKeyword() + typeAnnotation: TSNumberKeyword(), + } + ``` + + __Migration__: If you have a customized plugin accessing `typeParameter` of a `TSMappedType` node, use `node.key` and `node.constraint` in Babel 8. + ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) - Don't generate `TSParenthesizedType` unless `createParenthesizedExpression` is enabled([#9546](https://github.com/babel/babel/issues/9546), [#12608](https://github.com/babel/babel/pull/12608)) @@ -307,7 +340,7 @@ Check out the [v8-migration guide](v8-migration.md) for other user-level changes --- functionExpressionPath.is("id") --- functionExpressionPath.has("id") +++ functionExpressionPath.node.id - + --- functionExpressionPath.has("arguments") +++ !!functionExpressionPath.node.arguments.length