build: migrate to tsdown (#595)

This commit is contained in:
pengzhanbo 2025-05-12 17:28:55 +08:00 committed by GitHub
parent aaa473572c
commit b4c139bc72
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 343 additions and 389 deletions

View File

@ -79,6 +79,7 @@
"taze",
"Tongji",
"tsbuildinfo",
"tsdown",
"twoslash",
"vite",
"vuepress",

View File

@ -27,7 +27,7 @@
"templates"
],
"scripts": {
"build": "tsup"
"build": "tsdown"
},
"dependencies": {
"@clack/prompts": "catalog:prod",

View File

@ -1,4 +1,5 @@
import { defineConfig } from 'tsup'
import type { Options } from 'tsdown'
import { defineConfig } from 'tsdown'
import { version } from './package.json'
export default defineConfig({
@ -7,9 +8,8 @@ export default defineConfig({
dts: true,
format: 'esm',
sourcemap: false,
splitting: false,
clean: true,
define: {
__CLI_VERSION__: JSON.stringify(version),
},
})
}) as Options

View File

@ -69,7 +69,7 @@
"stylelint": "catalog:dev",
"stylus": "catalog:dev",
"tsconfig-vuepress": "catalog:dev",
"tsup": "catalog:dev",
"tsdown": "catalog:dev",
"typescript": "catalog:dev",
"vitest": "catalog:dev",
"wait-on": "catalog:dev"

View File

@ -27,10 +27,10 @@
"lib"
],
"scripts": {
"build": "pnpm run copy && pnpm run tsup",
"build": "pnpm run tsdown && pnpm run copy",
"clean": "rimraf --glob ./lib",
"copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png,woff2}\" lib",
"tsup": "tsup --config tsup.config.ts"
"tsdown": "tsdown"
},
"peerDependencies": {
"vuepress": "catalog:vuepress"

View File

@ -1,5 +1,5 @@
import type { Options } from 'tsup'
import { defineConfig } from 'tsup'
import type { Options } from 'tsdown'
import { defineConfig } from 'tsdown'
import { argv } from '../../scripts/tsup-args.js'
const clientExternal: (string | RegExp)[] = [
@ -11,7 +11,6 @@ export default defineConfig(() => {
const DEFAULT_OPTIONS: Options = {
dts: true,
sourcemap: false,
splitting: false,
format: 'esm',
}
const options: Options[] = []

View File

@ -31,13 +31,13 @@
"lib"
],
"scripts": {
"dev": "pnpm '/(copy|tsup):watch/'",
"build": "pnpm copy && pnpm tsup",
"dev": "pnpm '/(copy|tsdown):watch/'",
"build": "pnpm tsdown && pnpm copy",
"clean": "rimraf --glob ./lib",
"copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib",
"copy:watch": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib -w",
"tsup": "tsup --config tsup.config.ts",
"tsup:watch": "tsup --config tsup.config.ts --watch -- -c"
"tsdown": "tsdown",
"tsdown:watch": "tsdown --watch -- -c"
},
"peerDependencies": {
"artplayer": "catalog:peer",

View File

@ -1,5 +1,5 @@
import type { Options } from 'tsup'
import { defineConfig } from 'tsup'
import type { Options } from 'tsdown'
import { defineConfig } from 'tsdown'
import { argv } from '../../scripts/tsup-args.js'
const config = [
@ -16,12 +16,12 @@ const clientExternal = [
/shared\/index\.js$/,
]
export default defineConfig(() => {
export default defineConfig((cli) => {
const DEFAULT_OPTIONS: Options = {
dts: true,
sourcemap: false,
splitting: false,
format: 'esm',
clean: !cli.watch,
}
const options: Options[] = []

View File

@ -27,8 +27,8 @@
"lib"
],
"scripts": {
"build": "pnpm run tsup",
"tsup": "tsup --config tsup.config.ts"
"build": "pnpm run tsdown",
"tsdown": "tsdown"
},
"peerDependencies": {
"vuepress": "catalog:vuepress"

View File

@ -1,12 +1,11 @@
import type { Options } from 'tsup'
import { defineConfig } from 'tsup'
import type { Options } from 'tsdown'
import { defineConfig } from 'tsdown'
import { argv } from '../../scripts/tsup-args.js'
export default defineConfig(() => {
const DEFAULT_OPTIONS: Options = {
dts: true,
sourcemap: false,
splitting: false,
format: 'esm',
}
const options: Options[] = []

View File

@ -31,10 +31,10 @@
"lib"
],
"scripts": {
"build": "pnpm run copy && pnpm run tsup",
"build": "pnpm run tsdown && pnpm run copy",
"clean": "rimraf --glob ./lib",
"copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png}\" lib",
"tsup": "tsup --config tsup.config.ts"
"tsdown": "tsdown"
},
"peerDependencies": {
"vuepress": "catalog:vuepress"

View File

@ -1,5 +1,5 @@
import type { Options } from 'tsup'
import { defineConfig } from 'tsup'
import type { Options } from 'tsdown'
import { defineConfig } from 'tsdown'
import { argv } from '../../scripts/tsup-args.js'
const sharedExternal: (string | RegExp)[] = [
@ -17,7 +17,6 @@ export default defineConfig(() => {
const DEFAULT_OPTIONS: Options = {
dts: true,
sourcemap: false,
splitting: false,
format: 'esm',
}

651
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -47,7 +47,7 @@ catalogs:
stylelint: ^16.19.1
stylus: ^0.64.0
tsconfig-vuepress: ^7.0.0
tsup: ^8.4.0
tsdown: ^0.11.5
typescript: ^5.8.3
vitest: ^3.1.3
vue-router: ^4.5.1

View File

@ -56,13 +56,13 @@
"node": "^20.6.0 || >=22.0.0"
},
"scripts": {
"dev": "pnpm '/(copy|tsup):watch/'",
"build": "pnpm run copy && pnpm run tsup",
"dev": "pnpm '/(copy|tsdown):watch/'",
"build": "pnpm run tsdown && pnpm run copy",
"clean": "rimraf --glob ./lib",
"copy": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png,woff2}\" lib",
"copy:watch": "cpx \"src/**/*.{d.ts,vue,css,scss,jpg,png,woff2}\" lib -w",
"tsup": "tsup --config tsup.config.ts",
"tsup:watch": "tsup --config tsup.config.ts --watch -- -c"
"tsdown": "tsdown",
"tsdown:watch": "tsdown --watch -- -c"
},
"peerDependencies": {
"@iconify/json": "catalog:peer",

View File

@ -13,3 +13,5 @@ export type {
GitChangelogInfo as GitChangelog,
GitContributorInfo as GitContributor,
} from '@vuepress/plugin-git'
export {}

View File

@ -1,8 +1,8 @@
import type { Options } from 'tsup'
import type { Options } from 'tsdown'
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import { defineConfig } from 'tsup'
import { defineConfig } from 'tsdown'
import { argv } from '../scripts/tsup-args.js'
const sharedExternal: (string | RegExp)[] = [
@ -26,10 +26,10 @@ export default defineConfig((cli) => {
const DEFAULT_OPTIONS: Options = {
dts: true,
sourcemap: false,
splitting: false,
watch: cli.watch,
format: 'esm',
silent: !!cli.watch,
clean: !cli.watch,
}
const options: Options[] = []
@ -38,7 +38,7 @@ export default defineConfig((cli) => {
...DEFAULT_OPTIONS,
entry: ['./src/shared/index.ts'],
outDir: './lib/shared',
dts: true,
external: ['sax'],
})
if (argv.node) {
@ -58,6 +58,7 @@ export default defineConfig((cli) => {
...DEFAULT_OPTIONS,
entry: ['./src/client/utils/index.ts'],
outDir: './lib/client/utils',
platform: 'browser',
external: clientExternal,
},
// client/composables/index.js
@ -65,6 +66,7 @@ export default defineConfig((cli) => {
...DEFAULT_OPTIONS,
entry: ['./src/client/composables/index.ts'],
outDir: './lib/client/composables',
platform: 'browser',
external: [
...clientExternal,
'../utils/index.js',
@ -76,6 +78,7 @@ export default defineConfig((cli) => {
entry: ['./src/client/config.ts'],
outDir: './lib/client',
dts: false,
platform: 'browser',
external: [
...clientExternal,
'./composables/index.js',
@ -87,6 +90,7 @@ export default defineConfig((cli) => {
...DEFAULT_OPTIONS,
entry: ['./src/client/index.ts'],
outDir: './lib/client',
platform: 'browser',
external: [
...clientExternal,
'./composables/index.js',
@ -98,6 +102,7 @@ export default defineConfig((cli) => {
...DEFAULT_OPTIONS,
entry: [`./src/client/features/composables/${file}`],
outDir: `./lib/client/features/composables/`,
platform: 'browser',
external: [
...clientExternal,
'../../composables/index.js',
@ -105,7 +110,7 @@ export default defineConfig((cli) => {
...featuresComposables.map(file => `./${file.replace('.ts', '.js')}`),
],
})),
])
] as Options[])
}
return options
}) as Options[]