-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(bindings): Introduce AST Viewer to improve debugging experience #10963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 09f1dd1 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #10963 will not alter performanceComparing Summary
Footnotes |
7df43cf
to
dd2a76b
Compare
5062fec
to
a9d5f6a
Compare
a9d5f6a
to
4a03c7e
Compare
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new AST Viewer binding to improve the debugging experience by providing a way to parse JavaScript/TypeScript code and return both the AST and token information in a formatted debug output.
- Adds a new WebAssembly binding
binding_es_ast_viewer
with parsing functionality - Integrates the new binding into the project's build and publish workflows
- Enhances token debug output with more descriptive template literal token representations
Reviewed Changes
Copilot reviewed 16 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
scripts/publish.sh | Adds the new binding package to version management |
crates/swc_ecma_parser/src/lib.rs | Exposes additional parser utilities for unstable API |
crates/swc_ecma_parser/src/lexer/token.rs | Improves debug output for template literal tokens |
bindings/binding_es_ast_viewer/src/lib.rs | Main library implementing parse function for AST/token extraction |
bindings/binding_es_ast_viewer/src/es_ast_viewer_node.js | Node.js wrapper for the WASM module |
bindings/binding_es_ast_viewer/scripts/* | Build and packaging scripts |
bindings/binding_es_ast_viewer/package.json | Package configuration |
bindings/binding_es_ast_viewer/jest.config.json | Jest test configuration |
bindings/binding_es_ast_viewer/examples/cli.rs | CLI example for testing the parser |
bindings/binding_es_ast_viewer/tests/parse.js | Comprehensive test suite |
bindings/binding_es_ast_viewer/Cargo.toml | Rust package configuration |
bindings/Cargo.toml | Workspace member addition |
.github/workflows/* | CI and publish workflow updates |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
.unwrap_or_default(); | ||
|
||
let is_d_ts = | ||
is_ts && matches!(iter.next(), Some("d" | "D")) || matches!(iter.next(), Some("d" | "D")); |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for detecting .d.ts files is incorrect. The second matches!(iter.next(), Some("d" | "D"))
will always consume another element from the iterator regardless of the first condition's result, potentially leading to false positives. This should be: is_ts && matches!(iter.next(), Some("d" | "D"))
is_ts && matches!(iter.next(), Some("d" | "D")) || matches!(iter.next(), Some("d" | "D")); | |
is_ts && matches!(iter.next(), Some("d" | "D")); |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the case of foo.d.css.ts
.
See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#allowarbitraryextensions
Note that historically, a similar effect has often been achievable by adding a declaration file named app.css.d.ts instead of app.d.css.ts - however, this just worked through Node’s require resolution rules for CommonJS. Strictly speaking, the former is interpreted as a declaration file for a JavaScript file named app.css.js. Because relative files imports need to include extensions in Node’s ESM support, TypeScript would error on our example in an ESM file under --moduleResolution node16 or nodenext.
Added support for swc_core and swc_ecma_parser in the changeset.
Description:
BREAKING CHANGE:
Related issue (if exists):