Skip to content

Commit 90e2857

Browse files
committed
refactor(fmt): simplify SWC Next PoC setup and attribution
1 parent 3218678 commit 90e2857

4 files changed

Lines changed: 7 additions & 43 deletions

File tree

‎packages/rstack/SWC_NEXT_POC.md‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎packages/rstack/rslib.config.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import { readFileSync } from 'node:fs';
2-
import { findPackageJSON } from 'node:module';
31
import { defineConfig } from '@rslib/core';
42
import prettierPkgJson from 'prettier/package.json' with { type: 'json' };
5-
import pkgJson from './package.json' with { type: 'json' };
6-
73
// @swc-next/parser does not export its package.json.
8-
const swcNextPkgJson = JSON.parse(
9-
readFileSync(findPackageJSON('@swc-next/parser', import.meta.url)!, 'utf8'),
10-
) as { version: string };
4+
import swcNextPkgJson from './node_modules/@swc-next/parser/package.json' with { type: 'json' };
5+
import pkgJson from './package.json' with { type: 'json' };
116

127
const fullyMinifiedChunks =
138
/(?:fmt(?:Lsp|Plugins)?|sortPackageJsonPlugin|staged)\.js$/;

‎packages/rstack/src/fmt/swcNextPlugin.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Adapted from @prettier/plugin-yuku to use SWC Next:
2+
// https://github.com/prettier/prettier/tree/main/packages/plugin-yuku
3+
14
import * as prettierEstreePlugin from 'prettier/plugins/estree';
25
import type { Parser, ParserOptions, Plugin } from 'prettier';
36
import {

‎packages/rstack/tests/fmt/cacheIdentity.test.ts‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { readFileSync } from 'node:fs';
2-
import { findPackageJSON } from 'node:module';
31
import path from 'node:path';
42
import { pathToFileURL } from 'node:url';
53
import prettierPkgJson from 'prettier/package.json' with { type: 'json' };
64
import { expect, test } from 'rstack/test';
5+
// @swc-next/parser does not export its package.json.
6+
import swcNextPkgJson from '../../node_modules/@swc-next/parser/package.json' with { type: 'json' };
77
import pkgJson from '../../package.json' with { type: 'json' };
88
import {
99
cacheHashLength,
@@ -86,10 +86,6 @@ test('bypasses user plugins and unserializable options', () => {
8686
});
8787

8888
test('includes formatter implementation versions in the namespace', () => {
89-
const swcNextPkgJson = JSON.parse(
90-
readFileSync(findPackageJSON('@swc-next/parser', import.meta.url)!, 'utf8'),
91-
) as { version: string };
92-
9389
expect(JSON.parse(cacheNamespace)).toEqual([
9490
fmtCacheVersion,
9591
pkgJson.version,

0 commit comments

Comments
 (0)