feat(fmt): prototype SWC Next 0.2.0 via crate and decoder - #465
Conversation
Deploying rstack-cli with
|
| Latest commit: |
61def22
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0f1cd851.rstack-cli.pages.dev |
| Branch Preview URL: | https://codex-poc-fmt-swc-next-nativ.rstack-cli.pages.dev |
|
Known compatibility difference in swc-next 0.2.0, found by the existing export function value() { return 1; }This is valid in a normal The previous Yuku adapter reported this with 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. |
Summary
This draft evaluates replacing Yuku in
rs fmtby compilingswc_next_bridge = "=0.2.0"into rstack's existing native binding and decoding its Buffer with@swc-next/decoder@0.2.0. The thin NAPI adapter delegates parsing and serialization to the upstream crate, uses the lazy generated loader, and requires no parser npm package or separate SWC Next native binary.It shares the Prettier adapter and compatibility tests with #464, retains explicit Prettier parsers and project plugin precedence, and isolates its formatting cache. Both routes record the same upstream gap: function implementations in declaration files are accepted rather than diagnosed; explicit experimental aliases become
swc-nextandswc-next-ts.On macOS arm64, debug/release native builds, Rust formatting/Clippy/tests,
pnpm check, spelling, and the complete JS suite pass (380 passed, one existing skipped test).packages/rstack/SWC_NEXT_POC.mdincludes reproduction and limits; serializer and decoder upgrades must stay synchronized, and cross-platform parity and throughput are not established.Related Links