Skip to content

feat(fmt): prototype SWC Next 0.2.0 via npm - #464

Draft
SoonIter wants to merge 1 commit into
mainfrom
codex/poc-fmt-swc-next-npm
Draft

feat(fmt): prototype SWC Next 0.2.0 via npm#464
SoonIter wants to merge 1 commit into
mainfrom
codex/poc-fmt-swc-next-npm

Conversation

@SoonIter

@SoonIter SoonIter commented Sep 7, 2026

Copy link
Copy Markdown
Member

Summary

This draft evaluates replacing Yuku in rs fmt with @swc-next/parser@0.2.0, using its published native binding and the existing Prettier ESTree adapter. Inferred parsers use SWC Next; explicit Prettier parsers and project plugin precedence remain available, while the experimental aliases become swc-next and swc-next-ts.

The cache namespace isolates this PoC from Yuku and the crate alternative. SWC Next 0.2.0 accepts function implementations in declaration files that Yuku rejected; the tests explicitly record that upstream diagnostic gap rather than adding a fallback.

On macOS arm64, builds, pnpm check, spelling, and the complete test suite pass (378 passed, one existing skipped test). See packages/rstack/SWC_NEXT_POC.md for reproduction and limits; no performance or cross-platform parity is claimed.

Related Links

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying rstack-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0016242
Status: ✅  Deploy successful!
Preview URL: https://49182fbd.rstack-cli.pages.dev
Branch Preview URL: https://codex-poc-fmt-swc-next-npm.rstack-cli.pages.dev

View logs

SoonIter commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

Known compatibility difference in swc-next 0.2.0, found by the existing rs fmt tests for .d.ts, .d.mts, and .d.cts:

export function value() { return 1; }

This is valid in a normal .ts file, but declaration files should contain a signature such as export function value(): number;. swc-next 0.2.0 currently returns no diagnostics for the implementation even with lang: "dts" explicitly selected, so this is not a filename-to-language mapping issue.

The previous Yuku adapter reported this with semanticErrors: false, and Babel reports it with its TypeScript dts: true option. TypeScript reports TS1183 during semantic checking when declaration checking is enabled (skipLibCheck: false); its syntactic diagnostics alone do not report it.

Upstream draft fix: https://github.com/swc-project/swc-next/pull/631. It proposes extending the existing ambient-implementation diagnostic to inherited ambient contexts, with regression tests and four additional passing conformance cases.

This PoC remains pinned to 0.2.0, and its tests explicitly record the current acceptance difference. The draft fix is not included in that published version; the rejection expectation can be restored after upgrading to a release containing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant