build: fix tsdown build config
This commit is contained in:
parent
2059cf92ff
commit
96eb076496
@ -1,4 +1,3 @@
|
||||
import type { Options } from 'tsdown'
|
||||
import { defineConfig } from 'tsdown'
|
||||
|
||||
export default defineConfig({
|
||||
@ -7,4 +6,4 @@ export default defineConfig({
|
||||
dts: true,
|
||||
format: 'esm',
|
||||
sourcemap: false,
|
||||
}) as Options
|
||||
})
|
||||
@ -1,19 +1,22 @@
|
||||
import type { Options, UserConfigFn } from 'tsdown'
|
||||
import { defineConfig } from 'tsdown'
|
||||
import { argv } from '../../scripts/tsdown-args.js'
|
||||
import { argv } from '../../scripts/tsdown-args.mjs'
|
||||
|
||||
const clientExternal: (string | RegExp)[] = [
|
||||
/** @import {Options} from 'tsdown' */
|
||||
|
||||
const clientExternal = [
|
||||
/.*\.vue$/,
|
||||
/.*\.css$/,
|
||||
]
|
||||
|
||||
export default defineConfig(() => {
|
||||
const DEFAULT_OPTIONS: Options = {
|
||||
/** @type {Options} */
|
||||
const DEFAULT_OPTIONS = {
|
||||
dts: true,
|
||||
sourcemap: false,
|
||||
format: 'esm',
|
||||
}
|
||||
const options: Options[] = []
|
||||
/** @type {Options[]} */
|
||||
const options = []
|
||||
|
||||
if (argv.node) {
|
||||
options.push({
|
||||
@ -37,4 +40,4 @@ export default defineConfig(() => {
|
||||
])
|
||||
}
|
||||
return options
|
||||
}) as UserConfigFn
|
||||
})
|
||||
@ -1,6 +1,7 @@
|
||||
import type { Options, UserConfigFn } from 'tsdown'
|
||||
import { defineConfig } from 'tsdown'
|
||||
import { argv } from '../../scripts/tsdown-args.js'
|
||||
import { argv } from '../../scripts/tsdown-args.mjs'
|
||||
|
||||
/** @import {Options} from 'tsdown' */
|
||||
|
||||
const config = [
|
||||
{ dir: 'composables', files: ['codeRepl.ts', 'pdf.ts', 'rustRepl.ts', 'size.ts', 'audio.ts', 'demo.ts'] },
|
||||
@ -17,13 +18,16 @@ const clientExternal = [
|
||||
]
|
||||
|
||||
export default defineConfig((cli) => {
|
||||
const DEFAULT_OPTIONS: Options = {
|
||||
/** @type {Options} */
|
||||
const DEFAULT_OPTIONS = {
|
||||
dts: true,
|
||||
sourcemap: false,
|
||||
format: 'esm',
|
||||
clean: !cli.watch,
|
||||
}
|
||||
const options: Options[] = []
|
||||
|
||||
/** @type {Options[]} */
|
||||
const options = []
|
||||
|
||||
// shared
|
||||
options.push({
|
||||
@ -48,7 +52,7 @@ export default defineConfig((cli) => {
|
||||
entry: files.map(file => `./src/client/${dir}/${file}`),
|
||||
outDir: `./lib/client/${dir}`,
|
||||
external: clientExternal,
|
||||
}) as Options))
|
||||
})))
|
||||
}
|
||||
return options
|
||||
}) as UserConfigFn
|
||||
})
|
||||
@ -1,12 +1,13 @@
|
||||
import type { Options, UserConfigFn } from 'tsdown'
|
||||
import { defineConfig } from 'tsdown'
|
||||
import { argv } from '../../scripts/tsdown-args.js'
|
||||
import { argv } from '../../scripts/tsdown-args.mjs'
|
||||
|
||||
const sharedExternal: (string | RegExp)[] = [
|
||||
/** @import {Options} from 'tsdown' */
|
||||
|
||||
const sharedExternal = [
|
||||
/.*\/shared\/index\.js$/,
|
||||
]
|
||||
|
||||
const clientExternal: (string | RegExp)[] = [
|
||||
const clientExternal = [
|
||||
...sharedExternal,
|
||||
/^@internal/,
|
||||
/.*\.vue$/,
|
||||
@ -14,13 +15,15 @@ const clientExternal: (string | RegExp)[] = [
|
||||
]
|
||||
|
||||
export default defineConfig(() => {
|
||||
const DEFAULT_OPTIONS: Options = {
|
||||
/** @type {Options} */
|
||||
const DEFAULT_OPTIONS = {
|
||||
dts: true,
|
||||
sourcemap: false,
|
||||
format: 'esm',
|
||||
}
|
||||
|
||||
const options: Options[] = []
|
||||
/** @type {Options[]} */
|
||||
const options = []
|
||||
|
||||
// shared
|
||||
options.push({
|
||||
@ -77,4 +80,4 @@ export default defineConfig(() => {
|
||||
}
|
||||
|
||||
return options
|
||||
}) as UserConfigFn
|
||||
})
|
||||
@ -1,10 +1,16 @@
|
||||
import process from 'node:process'
|
||||
import minimist from 'minimist'
|
||||
|
||||
interface ArgvOptions {
|
||||
client: boolean
|
||||
node: boolean
|
||||
}
|
||||
// interface ArgvOptions {
|
||||
// client: boolean
|
||||
// node: boolean
|
||||
// }
|
||||
|
||||
/**
|
||||
* @typedef {object} ArgvOptions
|
||||
* @property {boolean} client - 是否构建客户端
|
||||
* @property {boolean} node - 是否构建 node 端
|
||||
*/
|
||||
|
||||
const rawArgv = process.argv.slice(2)
|
||||
const tsupArgv = rawArgv.includes('--') ? rawArgv.slice(rawArgv.indexOf('--') + 1) : []
|
||||
@ -24,7 +30,8 @@ const parsed = tsupArgv.length
|
||||
all: true,
|
||||
}
|
||||
|
||||
export const argv: ArgvOptions = {
|
||||
/** @type {ArgvOptions} */
|
||||
export const argv = {
|
||||
client: parsed.client || parsed.all,
|
||||
node: parsed.node || parsed.all,
|
||||
}
|
||||
@ -1,15 +1,16 @@
|
||||
import type { Options, UserConfigFn } from 'tsdown'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import process from 'node:process'
|
||||
import { defineConfig } from 'tsdown'
|
||||
import { argv } from '../scripts/tsdown-args.js'
|
||||
import { argv } from '../scripts/tsdown-args.mjs'
|
||||
|
||||
const sharedExternal: (string | RegExp)[] = [
|
||||
/** @import {Options} from 'tsdown' */
|
||||
|
||||
const sharedExternal = [
|
||||
/.*\/shared\/index\.js$/,
|
||||
]
|
||||
|
||||
const clientExternal: (string | RegExp)[] = [
|
||||
const clientExternal = [
|
||||
...sharedExternal,
|
||||
/.*\.vue$/,
|
||||
/^@internal/,
|
||||
@ -23,7 +24,8 @@ const featuresComposables = fs.readdirSync(
|
||||
)
|
||||
|
||||
export default defineConfig((cli) => {
|
||||
const DEFAULT_OPTIONS: Options = {
|
||||
/** @type {Options} */
|
||||
const DEFAULT_OPTIONS = {
|
||||
dts: true,
|
||||
sourcemap: false,
|
||||
watch: cli.watch,
|
||||
@ -31,7 +33,8 @@ export default defineConfig((cli) => {
|
||||
silent: !!cli.watch,
|
||||
clean: !cli.watch,
|
||||
}
|
||||
const options: Options[] = []
|
||||
/** @type {Options[]} */
|
||||
const options = []
|
||||
|
||||
// shared
|
||||
options.push({
|
||||
@ -110,7 +113,7 @@ export default defineConfig((cli) => {
|
||||
...featuresComposables.map(file => `./${file.replace('.ts', '.js')}`),
|
||||
],
|
||||
})),
|
||||
] as Options[])
|
||||
])
|
||||
}
|
||||
return options
|
||||
}) as UserConfigFn
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user