-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
types.ts
109 lines (93 loc) · 2.52 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import type { ViteHotContext } from 'vite/types/hot'
import type { ModuleCacheMap, ViteNodeRunner } from './client'
export type Nullable<T> = T | null | undefined
export type Arrayable<T> = T | Array<T>
export interface DepsHandlingOptions {
external?: (string | RegExp)[]
inline?: (string | RegExp)[] | true
/**
* Try to guess the CJS version of a package when it's invalid ESM
* @default false
*/
fallbackCJS?: boolean
registerNodeLoader?: boolean
}
export interface StartOfSourceMap {
file?: string
sourceRoot?: string
}
export interface RawSourceMap extends StartOfSourceMap {
version: string
sources: string[]
names: string[]
sourcesContent?: string[]
mappings: string
}
export interface FetchResult {
code?: string
externalize?: string
map?: RawSourceMap
}
export type HotContext = Omit<ViteHotContext, 'acceptDeps' | 'decline'>
export type FetchFunction = (id: string) => Promise<FetchResult>
export type ResolveIdFunction = (id: string, importer?: string) => Promise<ViteNodeResolveId | null>
export type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) => HotContext
export interface ModuleCache {
promise?: Promise<any>
exports?: any
code?: string
/**
* Module ids that imports this module
*/
importers?: Set<string>
}
export interface ViteNodeRunnerOptions {
root: string
fetchModule: FetchFunction
resolveId?: ResolveIdFunction
createHotContext?: CreateHotContextFunction
base?: string
moduleCache?: ModuleCacheMap
interopDefault?: boolean
requestStubs?: Record<string, any>
debug?: boolean
}
export interface ViteNodeResolveId {
external?: boolean | 'absolute' | 'relative'
id: string
meta?: Record<string, any> | null
moduleSideEffects?: boolean | 'no-treeshake' | null
syntheticNamedExports?: boolean | string | null
}
export interface ViteNodeServerOptions {
/**
* Inject inline sourcemap to modules
* @default 'inline'
*/
sourcemap?: 'inline' | boolean
/**
* Deps handling
*/
deps?: DepsHandlingOptions
/**
* Transform method for modules
*/
transformMode?: {
ssr?: RegExp[]
web?: RegExp[]
}
debug?: DebuggerOptions
}
export interface DebuggerOptions {
/**
* Dump the transformed module to filesystem
* Passing a string will dump to the specified path
*/
dumpModules?: boolean | string
/**
* Read dumpped module from filesystem whenever exists.
* Useful for debugging by modifying the dump result from the filesystem.
*/
loadDumppedModules?: boolean
}
export type { ModuleCacheMap }