Skip to content

Commit ddf3ec6

Browse files
committed
build: use tsdown for plugin-react-swc
1 parent 822e7dd commit ddf3ec6

File tree

7 files changed

+125
-147
lines changed

7 files changed

+125
-147
lines changed

packages/plugin-react-swc/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"type": "module",
1616
"private": true,
1717
"scripts": {
18-
"dev": "tsx scripts/bundle.ts --dev",
19-
"build": "tsx scripts/bundle.ts",
18+
"dev": "tsdown --watch",
19+
"build": "tsdown",
2020
"test": "playwright test"
2121
},
2222
"repository": {
@@ -40,10 +40,9 @@
4040
"@types/fs-extra": "^11.0.4",
4141
"@types/node": "^22.16.0",
4242
"@vitejs/react-common": "workspace:*",
43-
"esbuild": "^0.25.5",
4443
"fs-extra": "^11.3.0",
45-
"picocolors": "^1.1.1",
4644
"prettier": "^3.0.3",
45+
"tsdown": "^0.12.9",
4746
"typescript": "^5.8.3"
4847
}
4948
}

packages/plugin-react-swc/scripts/bundle.ts

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
{
2-
"include": [
3-
"src",
4-
"scripts",
5-
"playwright.config.ts",
6-
"playground/utils.ts",
7-
"playground/*/__tests__"
8-
],
9-
"compilerOptions": {
10-
/* Target node 22 */
11-
"module": "ESNext",
12-
"lib": ["ES2023", "DOM"],
13-
"target": "ES2023",
14-
"skipLibCheck": true,
15-
16-
/* Bundler mode */
17-
"moduleResolution": "bundler",
18-
"allowImportingTsExtensions": true,
19-
"verbatimModuleSyntax": true,
20-
"noEmit": true,
21-
22-
/* Linting */
23-
"strict": true,
24-
"noUnusedLocals": true,
25-
"noUnusedParameters": true,
26-
"noFallthroughCasesInSwitch": true,
27-
"useUnknownInCatchVariables": true,
28-
"noUncheckedSideEffectImports": true,
29-
"noPropertyAccessFromIndexSignature": true
30-
}
2+
"include": [],
3+
"references": [
4+
{ "path": "./tsconfig.src.json" },
5+
{ "path": "./tsconfig.test.json" }
6+
]
317
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"include": ["src"],
3+
"compilerOptions": {
4+
/* Target node 22 */
5+
"module": "ESNext",
6+
"lib": ["ES2023", "DOM"],
7+
"target": "ES2023",
8+
"skipLibCheck": true,
9+
10+
/* Bundler mode */
11+
"moduleResolution": "bundler",
12+
"allowImportingTsExtensions": true,
13+
"verbatimModuleSyntax": true,
14+
"noEmit": true,
15+
"declaration": true,
16+
"isolatedDeclarations": true,
17+
18+
/* Linting */
19+
"strict": true,
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
"noFallthroughCasesInSwitch": true,
23+
"useUnknownInCatchVariables": true,
24+
"noUncheckedSideEffectImports": true,
25+
"noPropertyAccessFromIndexSignature": true
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"include": ["playwright.config.ts", "playground"],
3+
"compilerOptions": {
4+
/* Target node 22 */
5+
"module": "ESNext",
6+
"lib": ["ES2023", "DOM"],
7+
"target": "ES2023",
8+
"skipLibCheck": true,
9+
10+
/* Bundler mode */
11+
"moduleResolution": "bundler",
12+
"allowImportingTsExtensions": true,
13+
"verbatimModuleSyntax": true,
14+
"noEmit": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"useUnknownInCatchVariables": true,
22+
"noUncheckedSideEffectImports": true,
23+
"noPropertyAccessFromIndexSignature": true
24+
}
25+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { writeFileSync } from 'node:fs'
2+
import { defineConfig } from 'tsdown'
3+
import packageJSON from './package.json'
4+
5+
export default defineConfig({
6+
entry: 'src/index.ts',
7+
format: ['esm', 'cjs'],
8+
dts: true,
9+
copy: [
10+
{
11+
from: 'node_modules/@vitejs/react-common/refresh-runtime.js',
12+
to: 'dist/refresh-runtime.js',
13+
},
14+
{
15+
from: 'LICENSE',
16+
to: 'dist/LICENSE',
17+
},
18+
{
19+
from: 'README.md',
20+
to: 'dist/README.md',
21+
},
22+
],
23+
outputOptions(outputOpts, format) {
24+
if (format === 'cjs') {
25+
outputOpts.footer = 'module.exports.default = module.exports'
26+
}
27+
return outputOpts
28+
},
29+
onSuccess() {
30+
writeFileSync(
31+
'dist/package.json',
32+
JSON.stringify(
33+
{
34+
...Object.fromEntries(
35+
Object.entries(packageJSON).filter(
36+
([key, _val]) =>
37+
key !== 'devDependencies' &&
38+
key !== 'scripts' &&
39+
key !== 'private',
40+
),
41+
),
42+
main: 'index.cjs',
43+
types: 'index.d.ts',
44+
module: 'index.js',
45+
exports: {
46+
'.': {
47+
require: './index.cjs',
48+
import: './index.js',
49+
},
50+
},
51+
},
52+
null,
53+
2,
54+
),
55+
)
56+
},
57+
})

pnpm-lock.yaml

Lines changed: 8 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)