Skip to content

Apply preset defaults without a Babel API - #58254

Open
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/default-preset-without-babel-api
Open

Apply preset defaults without a Babel API#58254
OskarEichler wants to merge 1 commit into
react:mainfrom
OskarEichler:codex/default-preset-without-babel-api

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Summary:

The preset's Babel-API accesses are optional, but invoking it without the Babel API still has two incomplete fallback paths: preset() can read properties from an undefined options object, and getPreset(code, {dev: false}) receives no transform profile and silently falls back to legacy class transforms instead of the normal hermes-stable default.

Default options to an empty object, consistently rely on that non-null invariant throughout the configuration builder, and apply hermes-stable when neither explicit options nor babel.caller provides a profile. Explicit options and caller-provided profiles retain precedence.

Changelog:

[GENERAL] [FIXED] - Apply normal preset defaults when invoked without a Babel API or options object.

Test Plan:

  • Added a regression proving preset() builds without options or a Babel API.
  • Added a transform regression proving no-API invocation preserves classes under the default hermes-stable profile; exact baseline lowers the class to helpers.
  • Full preset Jest passes: 4/4 suites, 112/112 tests, 16 snapshots.
  • Fresh Flow check reports 0 errors.
  • Targeted no-ignore ESLint, Prettier, and git diff --check pass.

No breaking change: explicit profiles/caller behavior are unchanged, while standalone invocation now matches the preset's documented default path.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 30, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant