Repository navigation
feat(playground): support explicit source types - #29638
Merged
Merged
Conversation
Expose the parser's script, module, commonjs, and unambiguous modes in the playground binding using the shared get_source_type resolver. Preserve extension-based inference when sourceType is omitted. Copy generated WASI declarations to the public index.d.ts during patching so playground consumers can type-check the new option.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The playground binding cannot override source type, so TSX without import/export syntax emits
require()helpers. Its public declarations also lacksourceType, blocking type-checking in oxc-project/playground#488.Expose the parser's
script,module,commonjs, andunambiguousmodes throughoxc_napi::get_source_type. Preserve extension-based language selection and inference when the option is omitted. Copy the generated WASI declarations to the publicindex.d.tsduring binding patching.Example
Input (playground for this input and configuration):
Both binding builds use
extension: "tsx",sourceType: "module", and transformer targetes2015, with npm runtime helpers. The playground link contains the same run, parser, and transformer options; the deployed binding cannot demonstrate the newsourceTypeoption until updated.Before output (parent
e4703b1848):After output:
The explicit Module mode now emits an ESM helper import. Both runs have no diagnostics and produce identical serialized source maps.
Verified the WASM development build on Rust 1.100.0; temporary Node/WASI assertions for all four modes, omitted-option inference, CommonJS top-level return, JavaScript strictness, TSX parsing, and source-map content;
just lint -p oxc_playground_napi; Rust/script formatting and script lint. Playgroundvue-tscreproduces exactly foursourceTypeerrors with the parent's declarations and passes with the newly generated declarations. No persistent playground tests added.AI assistance: implementation and verification were prepared with an AI coding assistant.