Skip to content

Commit 0b6f062

Browse files
authored
build: enable isolatedDeclarations to improve dts generation speed (#64)
1 parent 524177c commit 0b6f062

7 files changed

Lines changed: 16 additions & 6 deletions

File tree

packages/devtools-rpc/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { BirpcOptions } from 'birpc'
1+
import type { BirpcOptions, BirpcReturn } from 'birpc'
22
import { createBirpc } from 'birpc'
33

44
export function createRpcClient<
@@ -10,7 +10,7 @@ export function createRpcClient<
1010
preset: BirpcOptions<ServerFunctions>
1111
rpcOptions?: Partial<BirpcOptions<ServerFunctions>>
1212
},
13-
) {
13+
): BirpcReturn<ServerFunctions, ClientFunctions> {
1414
const { preset, rpcOptions = {} } = options
1515
return createBirpc<ServerFunctions, ClientFunctions>(functions, {
1616
...preset,

packages/devtools-rpc/src/presets/ws/client.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { RpcClientPreset } from '..'
12
import { parse, stringify } from 'structured-clone-es'
23
import { defineRpcClientPreset } from '..'
34

@@ -10,7 +11,12 @@ export interface WebSocketRpcClientOptions {
1011

1112
function NOOP() {}
1213

13-
export const createWsRpcPreset = defineRpcClientPreset((options: WebSocketRpcClientOptions) => {
14+
export const createWsRpcPreset: RpcClientPreset<(options: WebSocketRpcClientOptions) => {
15+
on: (handler: (data: string) => void) => void
16+
post: (data: string) => void
17+
serialize: (obj: any) => string
18+
deserialize: (str: string) => unknown
19+
}> = defineRpcClientPreset((options: WebSocketRpcClientOptions) => {
1420
const ws = new WebSocket(options.url)
1521
const {
1622
onConnected = NOOP,

packages/devtools-rpc/src/presets/ws/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { BirpcGroup, BirpcOptions, ChannelOptions } from 'birpc'
22
import type { WebSocket } from 'ws'
3+
import type { RpcServerPreset } from '..'
34
import { parse, stringify } from 'structured-clone-es'
45
import { WebSocketServer } from 'ws'
56
import { defineRpcServerPreset } from '..'
@@ -12,7 +13,7 @@ export interface WebSocketRpcServerOptions {
1213

1314
function NOOP() {}
1415

15-
export const createWsRpcPreset = defineRpcServerPreset((options: WebSocketRpcServerOptions) => {
16+
export const createWsRpcPreset: RpcServerPreset<(options: WebSocketRpcServerOptions) => <ClientFunctions, ServerFunctions>(rpc: BirpcGroup<ClientFunctions, ServerFunctions>, options?: Pick<BirpcOptions<ClientFunctions>, 'serialize' | 'deserialize'>) => void> = defineRpcServerPreset((options: WebSocketRpcServerOptions) => {
1617
const {
1718
port,
1819
onConnected = NOOP,

packages/devtools-rpc/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function createRpcServer<
1010
preset: (rpc: BirpcGroup<ClientFunctions, ServerFunctions>) => void
1111
rpcOptions?: EventOptions<ClientFunctions>
1212
},
13-
) {
13+
): BirpcGroup<ClientFunctions, ServerFunctions> {
1414
const rpc = createBirpcGroup<ClientFunctions, ServerFunctions>(functions, [], options?.rpcOptions ?? {})
1515
options?.preset(rpc)
1616

packages/devtools-rpc/tsdown.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ export default defineConfig([{
66
],
77
clean: true,
88
fixedExtension: true,
9+
dts: { isolatedDeclarations: true },
910
}, {
1011
entry: ['src/presets/ws/client.ts', 'src/presets/ws/server.ts', 'src/presets/index.ts'],
1112
clean: true,
1213
fixedExtension: true,
1314
outDir: 'dist/presets',
15+
dts: { isolatedDeclarations: true },
1416
}])

packages/devtools/src/dirs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import { fileURLToPath } from 'node:url'
22

3-
export const distDir = fileURLToPath(new URL('../dist/public', import.meta.url))
3+
export const distDir: string = fileURLToPath(new URL('../dist/public', import.meta.url))

packages/devtools/tsdown.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export default defineConfig({
1111
clean: false,
1212
target: 'esnext',
1313
fixedExtension: true,
14+
dts: { isolatedDeclarations: true },
1415
})

0 commit comments

Comments
 (0)