Skip to content

Commit d5eaeb2

Browse files
committed
build: remove tsup , migrate to tsdown
1 parent 3ee54e8 commit d5eaeb2

File tree

18 files changed

+53
-482
lines changed

18 files changed

+53
-482
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"picocolors",
1010
"picomatch",
1111
"proxied",
12-
"referer"
12+
"referer",
13+
"tsdown"
1314
],
1415
"typescript.tsdk": "node_modules/typescript/lib",
1516
"markdownlint.config": {

docs/.vitepress/config.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import type { DefaultTheme, UserConfig } from 'vitepress'
12
import { defineConfig } from 'vitepress'
23
import { version } from '../../package.json'
34

4-
export default defineConfig({
5+
const vitepressConfig: UserConfig<DefaultTheme.Config> = defineConfig({
56
lang: 'zh-CN',
67
title: 'Mock-Dev-Server',
7-
description:
8-
'Mock-dev-server is injected into the Vite development environment to simulate API request and response data.',
8+
description: 'Mock-dev-server is injected into the Vite development environment to simulate API request and response data.',
99
lastUpdated: true,
1010
cleanUrls: true,
1111
markdown: {
@@ -34,8 +34,7 @@ export default defineConfig({
3434
lang: 'zh-CN',
3535
themeConfig: {
3636
editLink: {
37-
pattern:
38-
'https://github.com/pengzhanbo/vite-plugin-mock-dev-server/edit/main/docs/:path',
37+
pattern: 'https://github.com/pengzhanbo/vite-plugin-mock-dev-server/edit/main/docs/:path',
3938
text: '在Github编辑此页',
4039
},
4140
footer: {
@@ -122,8 +121,7 @@ export default defineConfig({
122121
lang: 'en-US',
123122
themeConfig: {
124123
editLink: {
125-
pattern:
126-
'https://github.com/pengzhanbo/vite-plugin-mock-dev-server/edit/main/docs/:path',
124+
pattern: 'https://github.com/pengzhanbo/vite-plugin-mock-dev-server/edit/main/docs/:path',
127125
text: 'Edit this page on Github',
128126
},
129127
footer: {
@@ -213,3 +211,4 @@ export default defineConfig({
213211
},
214212
},
215213
})
214+
export default vitepressConfig

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"conventional-changelog-cli": "catalog:dev",
3636
"eslint": "catalog:dev",
3737
"tsdown": "catalog:dev",
38-
"tsup": "catalog:dev",
3938
"typescript": "catalog:dev",
4039
"vitest": "catalog:dev"
4140
}

plugin/deprecate.mjs

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

plugin/src/core/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type PluginContext<T = Plugin['buildEnd']> = T extends (
2727
export async function generateMockServer(
2828
ctx: PluginContext,
2929
options: ResolvedMockServerPluginOptions,
30-
) {
30+
): Promise<void> {
3131
const include = toArray(options.include)
3232
const exclude = toArray(options.exclude)
3333
const cwd = options.cwd || process.cwd()

plugin/src/core/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ function aliasPlugin(alias: Alias[]): Plugin {
9090
}
9191
}
9292

93-
export function aliasMatches(pattern: string | RegExp, importee: string) {
93+
export function aliasMatches(pattern: string | RegExp, importee: string): boolean {
9494
if (pattern instanceof RegExp)
9595
return pattern.test(importee)
9696

plugin/src/core/define.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import type { ResolvedConfig } from 'vite'
1616
import process from 'node:process'
1717

18-
export function viteDefine(config: ResolvedConfig) {
18+
export function viteDefine(config: ResolvedConfig): Record<string, string> {
1919
const processNodeEnv: Record<string, string> = {}
2020

2121
const nodeEnv = process.env.NODE_ENV || config.mode

plugin/src/core/mockCompiler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { loadFromCode, transformWithEsbuild } from './compiler'
1212
import { transformMockData, transformRawData } from './transform'
1313
import { debug, lookupFile, normalizePath } from './utils'
1414

15-
export function createMockCompiler(options: ResolvedMockServerPluginOptions) {
15+
export function createMockCompiler(options: ResolvedMockServerPluginOptions): MockCompiler {
1616
return new MockCompiler(options)
1717
}
1818

@@ -42,11 +42,11 @@ export class MockCompiler extends EventEmitter {
4242
catch {}
4343
}
4444

45-
get mockData() {
45+
get mockData(): Record<string, MockOptions> {
4646
return this._mockData
4747
}
4848

49-
run() {
49+
run(): void {
5050
const { include, exclude } = this.options
5151
/**
5252
* 使用 rollup 提供的 include/exclude 规则,
@@ -156,7 +156,7 @@ export class MockCompiler extends EventEmitter {
156156
})
157157
}
158158

159-
close() {
159+
close(): void {
160160
this.mockWatcher?.close()
161161
this.depsWatcher?.close()
162162
}

plugin/src/core/requestRecovery.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Buffer } from 'node:buffer'
1111
const cache = new WeakMap<Connect.IncomingMessage, Buffer>()
1212

1313
// 备份请求数据
14-
export function collectRequest(req: Connect.IncomingMessage) {
14+
export function collectRequest(req: Connect.IncomingMessage): void {
1515
const chunks: Buffer[] = []
1616
req.addListener('data', (chunk) => {
1717
chunks.push(Buffer.from(chunk))
@@ -26,7 +26,7 @@ export function collectRequest(req: Connect.IncomingMessage) {
2626
* vite 在 proxy 配置中,允许通过 configure 访问 http-proxy 实例,
2727
* 通过 http-proxy 的 proxyReq 事件,重新写入请求流
2828
*/
29-
export function recoverRequest(config: UserConfig) {
29+
export function recoverRequest(config: UserConfig): void {
3030
if (!config.server)
3131
return
3232

plugin/src/core/sse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class SSEStream extends Transform {
5252
return super.pipe(destination, options)
5353
}
5454

55-
_transform(message: SSEMessage, encoding: string, callback: (error?: (Error | null), data?: any) => void) {
55+
_transform(message: SSEMessage, encoding: string, callback: (error?: (Error | null), data?: any) => void): void {
5656
if (message.comment)
5757
this.push(`: ${message.comment}\n`)
5858
if (message.event)

0 commit comments

Comments
 (0)