Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/plugin-react-swc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"type": "module",
"private": true,
"scripts": {
"dev": "tsx scripts/bundle.ts --dev",
"build": "tsx scripts/bundle.ts",
"dev": "tsdown --watch",
"build": "tsdown",
"test": "playwright test"
},
"repository": {
Expand All @@ -40,10 +40,9 @@
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.16.0",
"@vitejs/react-common": "workspace:*",
"esbuild": "^0.25.5",
"fs-extra": "^11.3.0",
"picocolors": "^1.1.1",
"prettier": "^3.0.3",
"tsdown": "^0.12.9",
"typescript": "^5.8.3"
}
}
91 changes: 0 additions & 91 deletions packages/plugin-react-swc/scripts/bundle.ts

This file was deleted.

34 changes: 5 additions & 29 deletions packages/plugin-react-swc/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
{
"include": [
"src",
"scripts",
"playwright.config.ts",
"playground/utils.ts",
"playground/*/__tests__"
],
"compilerOptions": {
/* Target node 22 */
"module": "ESNext",
"lib": ["ES2023", "DOM"],
"target": "ES2023",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true,
"noUncheckedSideEffectImports": true,
"noPropertyAccessFromIndexSignature": true
}
"include": [],
"references": [
{ "path": "./tsconfig.src.json" },
{ "path": "./tsconfig.test.json" }
]
}
27 changes: 27 additions & 0 deletions packages/plugin-react-swc/tsconfig.src.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"include": ["src"],
"compilerOptions": {
/* Target node 22 */
"module": "ESNext",
"lib": ["ES2023", "DOM"],
"target": "ES2023",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
"declaration": true,
"isolatedDeclarations": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true,
"noUncheckedSideEffectImports": true,
"noPropertyAccessFromIndexSignature": true
}
}
25 changes: 25 additions & 0 deletions packages/plugin-react-swc/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"include": ["playwright.config.ts", "playground"],
"compilerOptions": {
/* Target node 22 */
"module": "ESNext",
"lib": ["ES2023", "DOM"],
"target": "ES2023",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true,
"noUncheckedSideEffectImports": true,
"noPropertyAccessFromIndexSignature": true
}
}
64 changes: 64 additions & 0 deletions packages/plugin-react-swc/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { writeFileSync } from 'node:fs'
import { defineConfig } from 'tsdown'
import packageJSON from './package.json' with { type: 'json' }

export default defineConfig({
entry: 'src/index.ts',
format: ['esm', 'cjs'],
dts: true,
tsconfig: './tsconfig.src.json', // https://github.com/sxzz/rolldown-plugin-dts/issues/55
copy: [
{
from: 'node_modules/@vitejs/react-common/refresh-runtime.js',
to: 'dist/refresh-runtime.js',
},
{
from: 'LICENSE',
to: 'dist/LICENSE',
},
{
from: 'README.md',
to: 'dist/README.md',
},
],
outputOptions(outputOpts, format) {
if (format === 'cjs') {
outputOpts.footer = (chunk) => {
// don't append to dts files
if (chunk.fileName.endsWith('.cjs')) {
return 'module.exports.default = module.exports'
}
return ''
}
}
return outputOpts
},
onSuccess() {
writeFileSync(
'dist/package.json',
JSON.stringify(
{
...Object.fromEntries(
Object.entries(packageJSON).filter(
([key, _val]) =>
key !== 'devDependencies' &&
key !== 'scripts' &&
key !== 'private',
),
),
main: 'index.cjs',
types: 'index.d.ts',
module: 'index.js',
exports: {
'.': {
require: './index.cjs',
import: './index.js',
},
},
},
null,
2,
),
)
},
})
9 changes: 3 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading