feat(es_parser): complete internal parser wiring without ecma runtime dep#11622
feat(es_parser): complete internal parser wiring without ecma runtime dep#11622
Conversation
|
Binary Sizes
Commit: 0a5c1bb |
Merging this PR will not alter performance
Comparing |
PR Review: feat(es_parser): complete internal parser wiring without ecma runtime depOverall this is a solid PR that systematically wires syntax options ( Code QualityGood:
Nits:
Potential Issues
Performance
Test Coverage
Minor Suggestions
LGTM with the minor suggestions above. The behavioral changes around |
There was a problem hiding this comment.
Pull request overview
This PR finishes wiring several swc_es_parser syntax options end-to-end (including diagnostics/snapshots) while reinforcing the “fixture reuse is test-only” contract to avoid any runtime dependency on swc_ecma_parser.
Changes:
- Add
Syntaxaccessors and connect parser behavior fordecorators_before_export,export_default_from,allow_super_outside_method,dts, anddisallow_ambiguous_jsx_like. - Tighten
superhandling and refresh parity harness expectations/snapshots for fixtures that intentionally exercise invalidsuperusage. - Strengthen and document the no-runtime-
swc_ecma_parserdependency policy (tests + docs), and prune stale skip/ignore entries.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/swc_es_parser/src/parser.rs | Wires new syntax options into parsing behavior, adds super context enforcement, and adds targeted unit tests. |
| crates/swc_es_parser/src/syntax.rs | Adds new Syntax accessors (decorators_before_export, export_default_from, dts, disallow_ambiguous_jsx_like). |
| crates/swc_es_parser/src/context.rs | Introduces new context flags used by the parser (IN_DECLARE, ALLOW_DIRECT_SUPER). |
| crates/swc_es_parser/tests/no_ecma_dependency.rs | Refactors/extends test-only checks intended to prevent swc_ecma_parser dependency usage. |
| crates/swc_es_parser/tests/parity_suite.rs | Marks known-invalid super span fixtures as expected failures to normalize parity expectations. |
| crates/swc_es_parser/tests/typescript.rs | Improves TS fixture option inference using file extensions (tsx, cts/mts). |
| crates/swc_es_parser/tests/test262.rs | Updates ignore-list comments and removes stale ignored entries. |
| crates/swc_es_parser/tests/common/ecma_reuse.rs | Removes stale tsc skip/ignore patterns. |
| crates/swc_es_parser/tests/snapshots/** | Updates stderr snapshots for new diagnostics / adjusted failure classification. |
| crates/swc_es_parser/README.md | Documents runtime non-dependency and enumerates wired syntax options. |
| crates/swc_es_parser/AGENTS.md | Updates contributor-facing notes for the non-dependency and option coverage contracts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| TokenKind::Dot => { | ||
| self.ensure_super_property_or_call_allowed(expr)?; | ||
| let start = self.cur.span.lo; | ||
| self.bump(); | ||
| let is_private = self.cur.kind == TokenKind::Hash; |
There was a problem hiding this comment.
ensure_super_property_or_call_allowed is only invoked for member access/calls (., ?., [], ()). Other postfix forms like tagged templates (super as a tag) and update expressions (super++ / super--) can still be parsed without triggering the super-context restriction. Consider invoking the same check for TokenKind::Template and the PlusPlus/MinusMinus branches (or representing super as a distinct AST node and validating all non-SuperProperty/SuperCall uses).
| fn contains_swc_ecma_parser_import(source: &str) -> bool { | ||
| source.contains("use swc_ecma_parser") | ||
| || source.contains("extern crate swc_ecma_parser") | ||
| || source.contains("::swc_ecma_parser::") |
There was a problem hiding this comment.
contains_swc_ecma_parser_import does not currently match direct crate-path references like swc_ecma_parser::Parser (without a leading ::). If the goal is to forbid any test-time dependency usage, consider also checking for "swc_ecma_parser::" to avoid false negatives.
| || source.contains("::swc_ecma_parser::") | |
| || source.contains("::swc_ecma_parser::") | |
| || source.contains("swc_ecma_parser::") |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 88f10aa93b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let old_ctx = self.ctx; | ||
| self.ctx.insert(Context::IN_FUNCTION); | ||
| self.ctx.insert(Context::ALLOW_DIRECT_SUPER); | ||
| if is_async { |
There was a problem hiding this comment.
Restore method parsing context before propagating errors
parse_class_method_function now mutates self.ctx before any of the fallible header parsing (expect('('), parameter parsing, return type parsing), but the old context is only restored after successfully parsing the body. If a malformed method signature returns early via ?, the parser keeps IN_FUNCTION/ALLOW_DIRECT_SUPER set, so subsequent statements are parsed under the wrong context (for example in TypeScript no_early_errors mode where parsing continues after fatal errors), which can suppress or misclassify later diagnostics.
Useful? React with 👍 / 👎.
Summary
swc_es_parseroption wiring without introducing runtime dependency onswc_ecma_parserSyntaxaccessors and connect parser behavior fordecorators_before_export,export_default_from,allow_super_outside_method,dts, anddisallow_ambiguous_jsx_likesupercontext handling and fixexport default frombranch regression (export default from;remains expression export)superspan fixtures, and refresh impacted snapshotssrc/tests/examples/benches,Cargo.toml, andcargo treegraph)README.md,AGENTS.md) with runtime non-dependency and fixture-reuse policyVerification
git submodule update --init --recursivecargo fmt --allcargo clippy --all --all-targets -- -D warningscargo test -p swc_es_parser