refactor(ast): migrate JavaScript string values to JSStr - #26548
Conversation
Decoded JavaScript strings need to preserve lone surrogates without exposing their encoding as ordinary UTF-8 text. Carry JSStr through the AST and its consumers so surrogate handling follows the value instead of a separate flag. Rust callers now explicitly handle values that cannot be borrowed as str. Keep raw source text and identifiers in their UTF-8 types. Part of #26242. Implemented with AI assistance.
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
Keep the existing escape-table structure while migrating string values to JSStr so reviewers can focus on representation changes. The remaining single-implementation abstraction can be removed in a follow-up. Implemented with AI assistance.
Keep CI's generated-output checks in sync with the migration. The transformer tests intentionally execute trusted fixture output to check runtime string values, so allow that evaluation at those call sites. Implemented with AI assistance.

Decoded JavaScript strings currently use UTF-8 text plus separate lone-surrogate flags. Consumers can lose those flags or treat the internal escape encoding as literal text when constructing a new value.
Carry
JSStrthrough decoded AST values, module requests, and their consumers, building on #26435. This is a Rust API change: callers that need UTF-8 must handleJSStr::as_str()returningNone. Raw source text and identifiers keep their UTF-8 types. The draft includes enum evaluation and the associated owned UTF-16 storage; it does not introduce a general ownedJSString.Suggested review order
oxc_strserialization, codegen, module-record conversion, and NAPI. Check JSON, raw-transfer, and lazy-transfer behavior, especially theOption<JSStr>niche and layout assertions.js-str.test.tsfiles in the parser, minifier, and transformer bindings cover string values, module requests, recovery, and runtime behavior.Deferred to a follow-up: simplify
EscapeTable/StandardEscapeTableinoxc_estreeinto direct helpers. The migration retains their existing structure and eight-byte escape scanner while removing the obsolete marker decoder.just readypassed after the latest commit, including workspace tests, Clippy, documentation, formatting, and generated-file checks; the working tree is clean. Additional validation covered parser conformance (no new failures), native parser/minifier/transformer tests, 3,723 runtime checks, and size/allocation tracking. Minifier size snapshots are unchanged. JavaScript lint and all 61 transformer binding tests also passed, and scalar lexer conformance regenerated only the expected fixture count. A direct Node/WASI smoke check covered module dependencies and enum string values. Browser execution has not been validated locally.Part of #26242.
Implemented with AI assistance; draft for human review.