Skip to content

Add types for @babel/standalone - #18095

Merged
nicolo-ribaudo merged 4 commits into
babel:mainfrom
liuxingbaoyu:standalone-types
Jul 16, 2026
Merged

nicolo-ribaudo merged 4 commits into
babel:mainfrom
liuxingbaoyu:standalone-types

Conversation

@liuxingbaoyu

Copy link
Copy Markdown
Member
Q 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@babel-bot

babel-bot commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61915

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88fd7422a5

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/babel-standalone/package.json Outdated
Comment on lines +1 to +9
import type {
buildExternalHelpers as buildExternalHelpers$1,
PluginObject,
PresetObject,
InputOptions,
transformFromAstSync,
transformFromAstAsync as transformFromAstAsync$1,
FileResult,
} from "@babel/core";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid unresolved type-only imports

In a TypeScript project that installs only @babel/standalone with the default skipLibCheck: false, this declaration file cannot be checked because the package does not publish any dependencies or peers for @babel/core, @babel/generator, @babel/parser, etc. The new types therefore produce Cannot find module '@babel/core' (and the other imports) before users can consume the package unless they separately install Babel internals or skip lib checking.

Useful? React with 馃憤聽/ 馃憥.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have to do this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that ship has sailed, now that we export types we need to add type-only deps as dependencies.

Comment thread packages/babel-standalone/types.d.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4c573c66bf

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"./babel.js": "./babel.js",
"./babel.min.js": "./babel.min.js",
".": {
"types": "./types.d.ts",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Expose declarations to classic TypeScript resolution

In projects that still use moduleResolution: node/node10, TypeScript does not use these conditional exports entries for declaration lookup; it follows main to babel.js and then looks for a top-level types/typings field or babel.d.ts. With only this exports.types condition, import Babel = require("@babel/standalone") reports that types.d.ts exists but cannot be resolved under the current module resolution, so the new declarations remain unusable unless users switch resolvers. Add a top-level "types": "./types.d.ts" as well.

Useful? React with 馃憤聽/ 馃憥.

function disableScriptTags(): void;
}

export = Babel;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Declare the browser global for script-tag users

For browser/CDN consumers that use the standalone bundle as a global, referencing these types still does not make Babel available because this external-module declaration only has export = Babel. A file with /// <reference types="@babel/standalone" /> and Babel.transform(...) still fails with Cannot find name 'Babel'; add the UMD-style export as namespace Babel so the published types cover the script-tag API.

Useful? React with 馃憤聽/ 馃憥.

@pkg-pr-new

pkg-pr-new Bot commented Jun 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

commit: 09c8a0a

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃挕 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 439d0ad00e

鈩癸笍 About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 馃憤.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/**
* Registers a named plugin for use with Babel.
*/
function registerPlugin(name: string, plugin: () => PluginObject): void;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Accept plugin factories with Babel parameters

When a TypeScript consumer registers a normal Babel plugin factory that declares api or options, this no-argument callback type is not assignable even though registerPlugin stores the value and transform passes it through to @babel/core, which invokes plugin factories with those parameters. This makes supported custom plugins fail type-checking; the public type should allow Babel's plugin target shape here and in registerPlugins.

Useful? React with 馃憤聽/ 馃憥.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 馃悰 A type of pull request used for our changelog categories label Jul 15, 2026
@nicolo-ribaudo
nicolo-ribaudo merged commit d957b38 into babel:main Jul 16, 2026
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 馃悰 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants