Repository navigation
Conversation
Deploying rstack-cli with
|
| Latest commit: |
fc75027
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://56665ce6.rstack-cli.pages.dev |
| Branch Preview URL: | https://refactor-official-swc-next-p.rstack-cli.pages.dev |
Follow-up: SWC Next #1559 (2026-11-17)Tested swc-project/swc-next#1559 at
All 17 original standalone files still differ from the reference. Follow-up validation detailsBuilt the Rust formatter from the exact #1559 head and merge base in separate clean checkouts. All seven reduced inputs reproduce the original differing output at the merge base; only Case 6 changes to the reference output at the head. The head now looks through Rechecked the 17 complete standalone files, all 108 JS/TS code fences extracted from the 8 original MDX files, and the 7 reduced inputs. For all 132 inputs, native output matched the matching document decoder + Prettier printer, a second formatting pass was unchanged, and independently parsed Babel ASTs/comments matched after removing location/parenthesis metadata (template raw values retained). The seven reduced results were also unchanged when switching the printer from Prettier 3.9.9 to 3.10.1. MDX host formatting and the Rsbuild runtime suite were not rerun in this follow-up. This verifies #1559's formatter behavior; rstack-cli #648 still needs an updated formatter dependency before it receives this fix. Rechecked the Rsbuild output differences against the current PR head. The 17 files are the standalone JS/TS subset; there are also 8 Markdown/MDX files, for 25 changed files in the 3,439-file input. They fall into the 7 cases below. All 25 files are linked;
Here “expected output” means the actual Before output used as the formatting-compatibility reference, not a claim that every different layout is a correctness bug. “Actual output” is the current PR's After output. The reduced inputs below were each run through both CLIs with All 3,439 files were rechecked: Before passes the format check; After changes 25 files and passes a second format check. Separately, Babel ( Case 1: Method chains break before calls with multiline argumentsSWCFMT puts the receiver and chained calls on separate lines when the final call has a multiline object or array argument. This accounts for eight standalone JS/TS files and six MDX documents. Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( chain.plugin('extra-define').use(rspack.DefinePlugin, [
{
ENABLE_TEST: JSON.stringify(true),
},
]);Expected output (Before, PR base) chain.plugin('extra-define').use(rspack.DefinePlugin, [
{
ENABLE_TEST: JSON.stringify(true),
},
]);Actual output (After, PR head) chain
.plugin('extra-define')
.use(rspack.DefinePlugin, [
{
ENABLE_TEST: JSON.stringify(true),
},
]);AST / behavior comparison Layout difference. Call order, arguments, AST and comments are unchanged. Affected files
Case 2: Type assertions in ternary branches lose optional parenthesesUpstream tracking: swc-next-issues#486; still reproduces at #1559 head SWCFMT removes the extra parentheses around Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( const esQuery = isDefaultBrowserslist
? 'es2017'
: (`browserslist:${browserslist.join(',')}` as const);Expected output (Before, PR base) const esQuery = isDefaultBrowserslist
? 'es2017'
: (`browserslist:${browserslist.join(',')}` as const);Actual output (After, PR head) const esQuery = isDefaultBrowserslist
? 'es2017'
: `browserslist:${browserslist.join(',')}` as const;AST / behavior comparison Parenthesis difference. Babel parses both outputs to the same normalized AST; the assertion still applies to the same branch expression. Affected files Case 3: Curried arrow functions move onto the property lineFor an object property whose value is an arrow returning another arrow, the first arrow moves onto the property line. Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( const config = {
setup:
({ server }) =>
() => {
server.middlewares.use(handler);
},
};Expected output (Before, PR base) const config = {
setup:
({ server }) =>
() => {
server.middlewares.use(handler);
},
};Actual output (After, PR head) const config = {
setup: ({ server }) =>
() => {
server.middlewares.use(handler);
},
};AST / behavior comparison Layout difference. Both outputs retain the same nested arrow functions and body. Affected files Case 4: A long template receiver breaks before the method callFor a long template literal followed by Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( function createContentRange(type: string, size: number, range?: Range): string {
return `${type} ${range ? `${range.start}-${range.end}` : '*'}:${size}`.replace(
':',
'/',
);
}Expected output (Before, PR base) function createContentRange(type: string, size: number, range?: Range): string {
return `${type} ${range ? `${range.start}-${range.end}` : '*'}:${size}`.replace(
':',
'/',
);
}Actual output (After, PR head) function createContentRange(type: string, size: number, range?: Range): string {
return `${type} ${range ? `${range.start}-${range.end}` : '*'}:${size}`
.replace(':', '/');
}AST / behavior comparison Layout difference. The template raw/cooked values, interpolation AST and Affected files Case 5: An array receiver stays compact while its map call breaksAt this indentation level, SWCFMT keeps the array on one line and breaks before Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( describe('plugins', () => {
test('sorts dependencies', () => {
expect(result).toEqual(
[
{ name: '1' },
{ name: '3' },
{ name: '2', pre: ['3'] },
{ name: '4' },
].map((p) => ({
environment: '',
instance: p,
})),
);
});
});Expected output (Before, PR base) describe('plugins', () => {
test('sorts dependencies', () => {
expect(result).toEqual(
[
{ name: '1' },
{ name: '3' },
{ name: '2', pre: ['3'] },
{ name: '4' },
].map((p) => ({
environment: '',
instance: p,
})),
);
});
});Actual output (After, PR head) describe('plugins', () => {
test('sorts dependencies', () => {
expect(result).toEqual(
[{ name: '1' }, { name: '3' }, { name: '2', pre: ['3'] }, { name: '4' }]
.map((p) => ({
environment: '',
instance: p,
})),
);
});
});AST / behavior comparison Layout difference. Array elements and the mapping callback are unchanged. Affected files Case 6: A type-asserted object argument expands the outer callVerified fixed by swc-project/swc-next#1559 at An object literal with an Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( const result = await nativeTransformAsync(String(source), {
...solid,
filename,
sourceMap: true,
} as NativeTransformOptions);Expected output (Before, PR base) const result = await nativeTransformAsync(String(source), {
...solid,
filename,
sourceMap: true,
} as NativeTransformOptions);Actual output (After, PR head) const result = await nativeTransformAsync(
String(source),
{
...solid,
filename,
sourceMap: true,
} as NativeTransformOptions,
);AST / behavior comparison Layout difference. The object, assertion and argument order are unchanged. This file also appears in Case 2 for a separate hunk. Affected files Case 7: A template interpolation wraps inside a Markdown code fenceInside a TypeScript code fence, SWCFMT splits the arithmetic expression within a long template interpolation. Before keeps the interpolation on one line. Both English and Chinese documents contain this example. Found in Rsbuild — Input / expected output / actual output / AST comparison / affected filesInput ( ```ts title="rsbuild.config.ts"
export default {
performance: {
printFileSize: {
total: ({ distPath, assets, totalSize }) => {
return `Generated ${assets.length} files in ${distPath}, the total size is ${(totalSize / 1000).toFixed(1)} kB.`;
},
},
},
};
```Expected output (Before, PR base) ```ts title="rsbuild.config.ts"
export default {
performance: {
printFileSize: {
total: ({ distPath, assets, totalSize }) => {
return `Generated ${assets.length} files in ${distPath}, the total size is ${(totalSize / 1000).toFixed(1)} kB.`;
},
},
},
};
```Actual output (After, PR head) ```ts title="rsbuild.config.ts"
export default {
performance: {
printFileSize: {
total: ({ distPath, assets, totalSize }) => {
return `Generated ${assets.length} files in ${distPath}, the total size is ${(
totalSize / 1000
).toFixed(1)} kB.`;
},
},
},
};
```AST / behavior comparison Layout difference inside the code fence. The template raw/cooked values and interpolation AST are unchanged; the surrounding MDX document structure is unchanged. Affected files |
Use
@swc-next/formatter-prettier-pluginfor default JS/TS formatting and JavaScript, JSX, TypeScript and TSX code fences in Markdown/MDX.SWC Next Prettier plugin vs. SWCFMT Prettier plugin
Both use the SWC Next parser. The difference is who builds the formatting document:
Before uses local
swcNextPlugin.ts+@swc-next/parser; after uses the official@swc-next/formatter-prettier-plugin.Doc IR is a layout description—text, groups, indentation and possible line breaks. SWCFMT moves AST-to-Doc work into Rust; Prettier still chooses the final line breaks and renders the text.
For Markdown/MDX, Prettier formats the document and delegates supported code fences to SWCFMT. The wrapper supplies missing language aliases (
js,ts, etc.) and a JSX language entry so fence language inference selects SWCFMT. MDX top-level import/export and JSX nodes still use Prettier's specialized processing.Behavior also changes:
import sourceRsbuild formatting CLI, median elapsed time:
oxfmt is an external CLI reference on the same files. These runs use each CLI's default concurrency: 8 workers for
rs fmt, 18 threads for oxfmt. Configuration, plugin and output differences are documented below. Each scope runs independently; the rows cannot be added or subtracted to derive other language timings.Behavior before / after
These comparisons use the PR base (
d1efeb3) and final implementation (fc75027), with default formatting unless stated otherwise.embeddedLanguageFormatting: 'off'leaves code fences untouched. Project JS/TS parser plugins retain precedence. MDX top-level import/export requires AST validation and JSX uses Prettier's expression/root-marker handling; these nodes remain on Prettier's built-in path.declare module "*" with { type: "text" } { ... }errors before; after it formats and preserves the attributes.embeddedLanguageFormattingenabled. This also applies inside JS/TS code fences. For example, the GraphQL body inconst query = /* GraphQL */ `query{user{id name}}`stays compact.rangeStartor any finiterangeEndproduces an error.requirePragma,insertPragmaandcheckIgnorePragmaproduce errors on standalone SWC files, including empty files and files without a pragma.objectWrap: 'collapse',experimentalTernaries: trueandexperimentalOperatorPosition: 'start'produce errors on standalone SWC files.import source mod from './module.wasm'formats before and produces an unsupported import-phase error after on the standalone SWC path. The Rsbuild fixture exits with code 2 rather than code 0. Inside Markdown, rejected embedded snippets are preserved by the host.swc/swc-ts/swc-tsxparsers. Explicitbabel/typescriptselection uses Prettier, and project JS/TS parser plugins retain precedence. Existingswc-next/swc-next-tsnames remain available.The SWC Next formatter remains experimental. Projects needing Prettier's JS/TS template-language formatting or the standalone options listed above can explicitly select
parser: 'babel'orparser: 'typescript'indefine.fmt()or a file override.Prettier stays at 3.10.1, matching the PR base. Upstream SWC Next #754 declares the plugin's Prettier peer as
catalog:, which expands to the workspace's pinned3.9.9when published. Its description, discussion, reviews and commit messages do not identify a specific incompatibility with 3.10.1. Rstack allows exactly3.10.1for this peer on@swc-next/formatter-prettier-plugin@0.7.0; no plugin runtime patch is needed.With the same published plugin, all 12,219 upstream formatter fixture/option combinations produce identical output under Prettier 3.9.9 and 3.10.1, with no errors. All 3,439 Rsbuild files, including 477 Markdown/MDX documents, also produce identical output between those two versions and pass a second format check. These checks establish compatibility for the tested corpus, not every possible input. The overall PR still changes 25 files relative to the previous SWC parser integration.
Performance methodology and oxfmt reference
d1efeb3, final implementationfc75027and npmoxfmt@0.79.0, using isolated copies of Rsbuild atad8388c. All implementations use exactly the same file lists and original contents. The Rstack versions use the same Rsbuild configuration, ignores andheading-caseplugin.node <checkout>/packages/rstack/bin/rs.js fmt <file-list> --check --no-cache; oxfmt:node <oxfmt>/bin/oxfmt --check <file-list>.singleQuote: true,printWidth: 80,sortPackageJson: true,sortImports: false,jsdoc: falseandembeddedLanguageFormatting: 'auto'. The file lists already apply Rsbuild exclusions. oxfmt does not loadheading-case. The reference does not hold features, outputs or CPU parallelism constant.e2e/cases/wasm/wasm-source-import/src/index.js. The table therefore does not claim successful formatting of every repository file.Validation
pnpm checkalso pass.git diff --checkpass on the final revision. The website build and changed-file spelling passed before this dependency-only update. Full spelling previously reported absolute-path words in two ignored test-generated config files; changed files were clean.