Skip to content

feat(transformer): expose whether env options lower any JavaScript syntax - #30251

Merged
Dunqing merged 1 commit into
mainfrom
transformer-needs-js-transform
Nov 26, 2026
Merged

Dunqing merged 1 commit into
mainfrom
transformer-needs-js-transform

Conversation

@Dunqing

@Dunqing Dunqing commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Rolldown skips the transformer for plain JavaScript when the target lowers nothing. To decide that, it keeps a hand-copied list of the ESFeatures that EnvOptions::from(EngineTargets) turns into transform flags, with a canary test. A missing entry once let using declarations through at es2024.

This adds EnvOptions::lowers_syntax() so callers can ask Oxc instead: whether the env options lower, or reject, any JavaScript syntax. It destructures every flag, so a new flag doesn't compile until it's counted. It depends only on the options, so callers can cache it.

When it is false, the transformer leaves a JavaScript program's syntax unchanged, apart from transforms that don't depend on the target: decorators (decorator.legacy), TypeScript, JSX options (display_name is on by default and names React.createClass calls in any source type), plugins (styled-components, the </script tagged-template transform) and EnvOptions::module. Whether a program needs decorator lowering comes with the standard decorators stack: #28882 adds DecoratorOptions::transforms_decorators next to this.

The new integration test checks the method against the transformer itself: for every ES target and a program for each lowered feature, a program the method says to skip must come out of the transformer unchanged. Transformer tests, clippy and transform conformance pass with no snapshot changes.

AI disclosure: written with Claude Code (Claude Opus 5.5, model ID claude-opus-5-5); reasoning effort level not exposed to the session.

@github-actions github-actions Bot added the A-transformer Area - JS/TS transforms and downleveling, oxc_transformer label Nov 25, 2026
@Dunqing
Dunqing added this pull request to stack #30053 November 25, 2026 12:58
@codspeed

codspeed Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

Warning

oxc-project has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

✅ 91 untouched benchmarks
⏩ 19 skipped benchmarks1


Comparing transformer-needs-js-transform (5bb4f53) with main (d7f9336)

Open in CodSpeed

Footnotes

  1. 19 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@Dunqing
Dunqing force-pushed the transformer-needs-js-transform branch from 056f9f9 to cbefbea Compare November 25, 2026 14:55
@Dunqing
Dunqing force-pushed the decorators-lowering branch 2 times, most recently from b6aeade to 1f5fcf7 Compare November 25, 2026 16:37
@Dunqing
Dunqing force-pushed the transformer-needs-js-transform branch from cbefbea to 18e8bed Compare November 25, 2026 16:37
@Dunqing
Dunqing force-pushed the decorators-lowering branch from 1f5fcf7 to da26dfd Compare November 25, 2026 17:04
@Dunqing
Dunqing force-pushed the transformer-needs-js-transform branch 2 times, most recently from 9cad94a to e66ccf8 Compare November 25, 2026 17:23
@Dunqing
Dunqing force-pushed the decorators-lowering branch from da26dfd to 2e5018e Compare November 25, 2026 17:23
…ntax

Add `EnvOptions::lowers_syntax` so callers such as Rolldown can skip the
transformer for plain JavaScript without keeping their own copy of the
target feature list.

It destructures every env flag, so a new flag fails to compile until it is
counted. It does not cover transforms that do not depend on the target:
decorators, TypeScript, JSX options, plugins and the module format.
@Dunqing
Dunqing force-pushed the decorators-lowering branch from 2e5018e to 90f41a1 Compare November 25, 2026 17:32
@Dunqing
Dunqing force-pushed the transformer-needs-js-transform branch from e66ccf8 to 5bb4f53 Compare November 25, 2026 17:32
@Dunqing Dunqing changed the title feat(transformer): expose whether a JavaScript program needs syntax lowering feat(transformer): expose whether env options lower any JavaScript syntax Nov 25, 2026
@Dunqing
Dunqing removed this pull request from stack #30053 November 25, 2026 17:38
@Dunqing
Dunqing changed the base branch from decorators-lowering to main November 25, 2026 17:38
@Dunqing
Dunqing added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 697a09b Nov 26, 2026
53 of 82 checks passed
@Dunqing
Dunqing deleted the transformer-needs-js-transform branch November 26, 2026 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - JS/TS transforms and downleveling, oxc_transformer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants