vite 6.3.4 → 7.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,290 +1,302 @@
1
- import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
2
- import { Update, HotPayload } from '../../types/hmrPayload.js';
3
- import { InferCustomEventPayload } from '../../types/customEvent.js';
4
- import { N as NormalizedModuleRunnerTransport, E as ExternalFetchResult, V as ViteFetchResult, M as ModuleRunnerTransport, F as FetchFunctionOptions, a as FetchResult } from './moduleRunnerTransport.d-DJ_mE5sf.js';
5
- export { b as ModuleRunnerTransportHandlers, c as createWebSocketModuleRunnerTransport } from './moduleRunnerTransport.d-DJ_mE5sf.js';
1
+ import { ExternalFetchResult, FetchFunctionOptions, FetchResult, ModuleRunnerTransport, ModuleRunnerTransportHandlers, NormalizedModuleRunnerTransport, ViteFetchResult, createWebSocketModuleRunnerTransport } from "./moduleRunnerTransport-CnL9s_k9.js";
2
+ import { ModuleNamespace, ViteHotContext } from "../../types/hot.js";
3
+ import { HotPayload, Update } from "../../types/hmrPayload.js";
4
+ import { InferCustomEventPayload } from "../../types/customEvent.js";
6
5
 
6
+ //#region src/module-runner/sourcemap/decoder.d.ts
7
7
  interface SourceMapLike {
8
- version: number;
9
- mappings?: string;
10
- names?: string[];
11
- sources?: string[];
12
- sourcesContent?: string[];
8
+ version: number;
9
+ mappings?: string;
10
+ names?: string[];
11
+ sources?: string[];
12
+ sourcesContent?: string[];
13
13
  }
14
14
  declare class DecodedMap {
15
- map: SourceMapLike;
16
- _encoded: string;
17
- _decoded: undefined | number[][][];
18
- _decodedMemo: Stats;
19
- url: string;
20
- version: number;
21
- names: string[];
22
- resolvedSources: string[];
23
- constructor(map: SourceMapLike, from: string);
15
+ map: SourceMapLike;
16
+ _encoded: string;
17
+ _decoded: undefined | number[][][];
18
+ _decodedMemo: Stats;
19
+ url: string;
20
+ version: number;
21
+ names: string[];
22
+ resolvedSources: string[];
23
+ constructor(map: SourceMapLike, from: string);
24
24
  }
25
25
  interface Stats {
26
- lastKey: number;
27
- lastNeedle: number;
28
- lastIndex: number;
29
- }
30
-
26
+ lastKey: number;
27
+ lastNeedle: number;
28
+ lastIndex: number;
29
+ } //#endregion
30
+ //#region src/shared/hmr.d.ts
31
31
  type CustomListenersMap = Map<string, ((data: any) => void)[]>;
32
32
  interface HotModule {
33
- id: string;
34
- callbacks: HotCallback[];
33
+ id: string;
34
+ callbacks: HotCallback[];
35
35
  }
36
36
  interface HotCallback {
37
- deps: string[];
38
- fn: (modules: Array<ModuleNamespace | undefined>) => void;
37
+ deps: string[];
38
+ fn: (modules: Array<ModuleNamespace | undefined>) => void;
39
39
  }
40
40
  interface HMRLogger {
41
- error(msg: string | Error): void;
42
- debug(...msg: unknown[]): void;
41
+ error(msg: string | Error): void;
42
+ debug(...msg: unknown[]): void;
43
43
  }
44
44
  declare class HMRClient {
45
- logger: HMRLogger;
46
- private transport;
47
- private importUpdatedModule;
48
- hotModulesMap: Map<string, HotModule>;
49
- disposeMap: Map<string, (data: any) => void | Promise<void>>;
50
- pruneMap: Map<string, (data: any) => void | Promise<void>>;
51
- dataMap: Map<string, any>;
52
- customListenersMap: CustomListenersMap;
53
- ctxToListenersMap: Map<string, CustomListenersMap>;
54
- currentFirstInvalidatedBy: string | undefined;
55
- constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
56
- notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
57
- send(payload: HotPayload): void;
58
- clear(): void;
59
- prunePaths(paths: string[]): Promise<void>;
60
- protected warnFailedUpdate(err: Error, path: string | string[]): void;
61
- private updateQueue;
62
- private pendingUpdateQueue;
63
- /**
64
- * buffer multiple hot updates triggered by the same src change
65
- * so that they are invoked in the same order they were sent.
66
- * (otherwise the order may be inconsistent because of the http request round trip)
67
- */
68
- queueUpdate(payload: Update): Promise<void>;
69
- private fetchUpdate;
70
- }
71
-
45
+ logger: HMRLogger;
46
+ private transport;
47
+ private importUpdatedModule;
48
+ hotModulesMap: Map<string, HotModule>;
49
+ disposeMap: Map<string, (data: any) => void | Promise<void>>;
50
+ pruneMap: Map<string, (data: any) => void | Promise<void>>;
51
+ dataMap: Map<string, any>;
52
+ customListenersMap: CustomListenersMap;
53
+ ctxToListenersMap: Map<string, CustomListenersMap>;
54
+ currentFirstInvalidatedBy: string | undefined;
55
+ constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
56
+ notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
57
+ send(payload: HotPayload): void;
58
+ clear(): void;
59
+ prunePaths(paths: string[]): Promise<void>;
60
+ protected warnFailedUpdate(err: Error, path: string | string[]): void;
61
+ private updateQueue;
62
+ private pendingUpdateQueue;
63
+ /**
64
+ * buffer multiple hot updates triggered by the same src change
65
+ * so that they are invoked in the same order they were sent.
66
+ * (otherwise the order may be inconsistent because of the http request round trip)
67
+ */
68
+ queueUpdate(payload: Update): Promise<void>;
69
+ private fetchUpdate;
70
+ } //#endregion
71
+ //#region src/shared/ssrTransform.d.ts
72
72
  interface DefineImportMetadata {
73
- /**
74
- * Imported names before being transformed to `ssrImportKey`
75
- *
76
- * import foo, { bar as baz, qux } from 'hello'
77
- * => ['default', 'bar', 'qux']
78
- *
79
- * import * as namespace from 'world
80
- * => undefined
81
- */
82
- importedNames?: string[];
73
+ /**
74
+ * Imported names before being transformed to `ssrImportKey`
75
+ *
76
+ * import foo, { bar as baz, qux } from 'hello'
77
+ * => ['default', 'bar', 'qux']
78
+ *
79
+ * import * as namespace from 'world
80
+ * => undefined
81
+ */
82
+ importedNames?: string[];
83
83
  }
84
84
  interface SSRImportMetadata extends DefineImportMetadata {
85
- isDynamicImport?: boolean;
85
+ isDynamicImport?: boolean;
86
86
  }
87
87
 
88
+ //#endregion
89
+ //#region src/module-runner/constants.d.ts
90
+ /**
91
+ * Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
92
+ * Top-level imports and dynamic imports work slightly differently in Node.js.
93
+ * This function normalizes the differences so it matches prod behaviour.
94
+ */
88
95
  declare const ssrModuleExportsKey = "__vite_ssr_exports__";
89
96
  declare const ssrImportKey = "__vite_ssr_import__";
90
97
  declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
91
98
  declare const ssrExportAllKey = "__vite_ssr_exportAll__";
92
99
  declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
93
100
 
101
+ //#endregion
102
+ //#region src/module-runner/runner.d.ts
94
103
  interface ModuleRunnerDebugger {
95
- (formatter: unknown, ...args: unknown[]): void;
104
+ (formatter: unknown, ...args: unknown[]): void;
96
105
  }
97
106
  declare class ModuleRunner {
98
- options: ModuleRunnerOptions;
99
- evaluator: ModuleEvaluator;
100
- private debug?;
101
- evaluatedModules: EvaluatedModules;
102
- hmrClient?: HMRClient;
103
- private readonly envProxy;
104
- private readonly transport;
105
- private readonly resetSourceMapSupport?;
106
- private readonly concurrentModuleNodePromises;
107
- private closed;
108
- constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
109
- /**
110
- * URL to execute. Accepts file path, server path or id relative to the root.
111
- */
112
- import<T = any>(url: string): Promise<T>;
113
- /**
114
- * Clear all caches including HMR listeners.
115
- */
116
- clearCache(): void;
117
- /**
118
- * Clears all caches, removes all HMR listeners, and resets source map support.
119
- * This method doesn't stop the HMR connection.
120
- */
121
- close(): Promise<void>;
122
- /**
123
- * Returns `true` if the runtime has been closed by calling `close()` method.
124
- */
125
- isClosed(): boolean;
126
- private processImport;
127
- private isCircularModule;
128
- private isCircularImport;
129
- private cachedRequest;
130
- private cachedModule;
131
- private getModuleInformation;
132
- protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>;
107
+ options: ModuleRunnerOptions;
108
+ evaluator: ModuleEvaluator;
109
+ private debug?;
110
+ evaluatedModules: EvaluatedModules;
111
+ hmrClient?: HMRClient;
112
+ private readonly envProxy;
113
+ private readonly transport;
114
+ private readonly resetSourceMapSupport?;
115
+ private readonly concurrentModuleNodePromises;
116
+ private closed;
117
+ constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
118
+ /**
119
+ * URL to execute. Accepts file path, server path or id relative to the root.
120
+ */
121
+ import<T = any>(url: string): Promise<T>;
122
+ /**
123
+ * Clear all caches including HMR listeners.
124
+ */
125
+ clearCache(): void;
126
+ /**
127
+ * Clears all caches, removes all HMR listeners, and resets source map support.
128
+ * This method doesn't stop the HMR connection.
129
+ */
130
+ close(): Promise<void>;
131
+ /**
132
+ * Returns `true` if the runtime has been closed by calling `close()` method.
133
+ */
134
+ isClosed(): boolean;
135
+ private processImport;
136
+ private isCircularModule;
137
+ private isCircularImport;
138
+ private cachedRequest;
139
+ private cachedModule;
140
+ private getModuleInformation;
141
+ protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>;
133
142
  }
134
143
 
144
+ //#endregion
145
+ //#region src/module-runner/sourcemap/interceptor.d.ts
135
146
  interface RetrieveFileHandler {
136
- (path: string): string | null | undefined | false;
147
+ (path: string): string | null | undefined | false;
137
148
  }
138
149
  interface RetrieveSourceMapHandler {
139
- (path: string): null | {
140
- url: string;
141
- map: any;
142
- };
150
+ (path: string): null | {
151
+ url: string;
152
+ map: any;
153
+ };
143
154
  }
144
155
  interface InterceptorOptions {
145
- retrieveFile?: RetrieveFileHandler;
146
- retrieveSourceMap?: RetrieveSourceMapHandler;
156
+ retrieveFile?: RetrieveFileHandler;
157
+ retrieveSourceMap?: RetrieveSourceMapHandler;
147
158
  }
148
159
 
160
+ //#endregion
161
+ //#region src/module-runner/types.d.ts
149
162
  interface ModuleRunnerImportMeta extends ImportMeta {
150
- url: string;
151
- env: ImportMetaEnv;
152
- hot?: ViteHotContext;
153
- [key: string]: any;
163
+ url: string;
164
+ env: ImportMetaEnv;
165
+ hot?: ViteHotContext;
166
+ [key: string]: any;
154
167
  }
155
168
  interface ModuleRunnerContext {
156
- [ssrModuleExportsKey]: Record<string, any>;
157
- [ssrImportKey]: (id: string, metadata?: DefineImportMetadata) => Promise<any>;
158
- [ssrDynamicImportKey]: (id: string, options?: ImportCallOptions) => Promise<any>;
159
- [ssrExportAllKey]: (obj: any) => void;
160
- [ssrImportMetaKey]: ModuleRunnerImportMeta;
169
+ [ssrModuleExportsKey]: Record<string, any>;
170
+ [ssrImportKey]: (id: string, metadata?: DefineImportMetadata) => Promise<any>;
171
+ [ssrDynamicImportKey]: (id: string, options?: ImportCallOptions) => Promise<any>;
172
+ [ssrExportAllKey]: (obj: any) => void;
173
+ [ssrImportMetaKey]: ModuleRunnerImportMeta;
161
174
  }
162
175
  interface ModuleEvaluator {
163
- /**
164
- * Number of prefixed lines in the transformed code.
165
- */
166
- startOffset?: number;
167
- /**
168
- * Run code that was transformed by Vite.
169
- * @param context Function context
170
- * @param code Transformed code
171
- * @param module The module node
172
- */
173
- runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
174
- /**
175
- * Run externalized module.
176
- * @param file File URL to the external module
177
- */
178
- runExternalModule(file: string): Promise<any>;
176
+ /**
177
+ * Number of prefixed lines in the transformed code.
178
+ */
179
+ startOffset?: number;
180
+ /**
181
+ * Run code that was transformed by Vite.
182
+ * @param context Function context
183
+ * @param code Transformed code
184
+ * @param module The module node
185
+ */
186
+ runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
187
+ /**
188
+ * Run externalized module.
189
+ * @param file File URL to the external module
190
+ */
191
+ runExternalModule(file: string): Promise<any>;
179
192
  }
180
193
  type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
181
- url: string;
182
- id: string;
194
+ url: string;
195
+ id: string;
183
196
  };
184
197
  type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
185
198
  interface ModuleRunnerHmr {
186
- /**
187
- * Configure HMR logger.
188
- */
189
- logger?: false | HMRLogger;
199
+ /**
200
+ * Configure HMR logger.
201
+ */
202
+ logger?: false | HMRLogger;
190
203
  }
191
204
  interface ModuleRunnerOptions {
192
- /**
193
- * Root of the project
194
- * @deprecated not used and to be removed
195
- */
196
- root?: string;
197
- /**
198
- * A set of methods to communicate with the server.
199
- */
200
- transport: ModuleRunnerTransport;
201
- /**
202
- * Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available.
203
- * Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method.
204
- * You can provide an object to configure how file contents and source maps are resolved for files that were not processed by Vite.
205
- */
206
- sourcemapInterceptor?: false | 'node' | 'prepareStackTrace' | InterceptorOptions;
207
- /**
208
- * Disable HMR or configure HMR options.
209
- *
210
- * @default true
211
- */
212
- hmr?: boolean | ModuleRunnerHmr;
213
- /**
214
- * Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
215
- */
216
- evaluatedModules?: EvaluatedModules;
205
+ /**
206
+ * A set of methods to communicate with the server.
207
+ */
208
+ transport: ModuleRunnerTransport;
209
+ /**
210
+ * Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available.
211
+ * Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method.
212
+ * You can provide an object to configure how file contents and source maps are resolved for files that were not processed by Vite.
213
+ */
214
+ sourcemapInterceptor?: false | 'node' | 'prepareStackTrace' | InterceptorOptions;
215
+ /**
216
+ * Disable HMR or configure HMR options.
217
+ *
218
+ * @default true
219
+ */
220
+ hmr?: boolean | ModuleRunnerHmr;
221
+ /**
222
+ * Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
223
+ */
224
+ evaluatedModules?: EvaluatedModules;
217
225
  }
218
226
  interface ImportMetaEnv {
219
- [key: string]: any;
220
- BASE_URL: string;
221
- MODE: string;
222
- DEV: boolean;
223
- PROD: boolean;
224
- SSR: boolean;
227
+ [key: string]: any;
228
+ BASE_URL: string;
229
+ MODE: string;
230
+ DEV: boolean;
231
+ PROD: boolean;
232
+ SSR: boolean;
225
233
  }
226
234
 
235
+ //#endregion
236
+ //#region src/module-runner/evaluatedModules.d.ts
227
237
  declare class EvaluatedModuleNode {
228
- id: string;
229
- url: string;
230
- importers: Set<string>;
231
- imports: Set<string>;
232
- evaluated: boolean;
233
- meta: ResolvedResult | undefined;
234
- promise: Promise<any> | undefined;
235
- exports: any | undefined;
236
- file: string;
237
- map: DecodedMap | undefined;
238
- constructor(id: string, url: string);
238
+ id: string;
239
+ url: string;
240
+ importers: Set<string>;
241
+ imports: Set<string>;
242
+ evaluated: boolean;
243
+ meta: ResolvedResult | undefined;
244
+ promise: Promise<any> | undefined;
245
+ exports: any | undefined;
246
+ file: string;
247
+ map: DecodedMap | undefined;
248
+ constructor(id: string, url: string);
239
249
  }
240
250
  declare class EvaluatedModules {
241
- readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
242
- readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
243
- readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
244
- /**
245
- * Returns the module node by the resolved module ID. Usually, module ID is
246
- * the file system path with query and/or hash. It can also be a virtual module.
247
- *
248
- * Module runner graph will have 1 to 1 mapping with the server module graph.
249
- * @param id Resolved module ID
250
- */
251
- getModuleById(id: string): EvaluatedModuleNode | undefined;
252
- /**
253
- * Returns all modules related to the file system path. Different modules
254
- * might have different query parameters or hash, so it's possible to have
255
- * multiple modules for the same file.
256
- * @param file The file system path of the module
257
- */
258
- getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
259
- /**
260
- * Returns the module node by the URL that was used in the import statement.
261
- * Unlike module graph on the server, the URL is not resolved and is used as is.
262
- * @param url Server URL that was used in the import statement
263
- */
264
- getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
265
- /**
266
- * Ensure that module is in the graph. If the module is already in the graph,
267
- * it will return the existing module node. Otherwise, it will create a new
268
- * module node and add it to the graph.
269
- * @param id Resolved module ID
270
- * @param url URL that was used in the import statement
271
- */
272
- ensureModule(id: string, url: string): EvaluatedModuleNode;
273
- invalidateModule(node: EvaluatedModuleNode): void;
274
- /**
275
- * Extracts the inlined source map from the module code and returns the decoded
276
- * source map. If the source map is not inlined, it will return null.
277
- * @param id Resolved module ID
278
- */
279
- getModuleSourceMapById(id: string): DecodedMap | null;
280
- clear(): void;
251
+ readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
252
+ readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
253
+ readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
254
+ /**
255
+ * Returns the module node by the resolved module ID. Usually, module ID is
256
+ * the file system path with query and/or hash. It can also be a virtual module.
257
+ *
258
+ * Module runner graph will have 1 to 1 mapping with the server module graph.
259
+ * @param id Resolved module ID
260
+ */
261
+ getModuleById(id: string): EvaluatedModuleNode | undefined;
262
+ /**
263
+ * Returns all modules related to the file system path. Different modules
264
+ * might have different query parameters or hash, so it's possible to have
265
+ * multiple modules for the same file.
266
+ * @param file The file system path of the module
267
+ */
268
+ getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
269
+ /**
270
+ * Returns the module node by the URL that was used in the import statement.
271
+ * Unlike module graph on the server, the URL is not resolved and is used as is.
272
+ * @param url Server URL that was used in the import statement
273
+ */
274
+ getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
275
+ /**
276
+ * Ensure that module is in the graph. If the module is already in the graph,
277
+ * it will return the existing module node. Otherwise, it will create a new
278
+ * module node and add it to the graph.
279
+ * @param id Resolved module ID
280
+ * @param url URL that was used in the import statement
281
+ */
282
+ ensureModule(id: string, url: string): EvaluatedModuleNode;
283
+ invalidateModule(node: EvaluatedModuleNode): void;
284
+ /**
285
+ * Extracts the inlined source map from the module code and returns the decoded
286
+ * source map. If the source map is not inlined, it will return null.
287
+ * @param id Resolved module ID
288
+ */
289
+ getModuleSourceMapById(id: string): DecodedMap | null;
290
+ clear(): void;
281
291
  }
282
292
 
293
+ //#endregion
294
+ //#region src/module-runner/esmEvaluator.d.ts
283
295
  declare class ESModulesEvaluator implements ModuleEvaluator {
284
- readonly startOffset: number;
285
- runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
286
- runExternalModule(filepath: string): Promise<any>;
296
+ readonly startOffset: number;
297
+ runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
298
+ runExternalModule(filepath: string): Promise<any>;
287
299
  }
288
300
 
289
- export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, FetchFunctionOptions, FetchResult, ModuleRunner, ModuleRunnerTransport, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
290
- export type { FetchFunction, HMRLogger, InterceptorOptions, ModuleEvaluator, ModuleRunnerContext, ModuleRunnerHmr, ModuleRunnerImportMeta, ModuleRunnerOptions, ResolvedResult, SSRImportMetadata };
301
+ //#endregion
302
+ export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, FetchFunction, FetchFunctionOptions, FetchResult, HMRLogger, InterceptorOptions, ModuleEvaluator, ModuleRunner, ModuleRunnerContext, ModuleRunnerHmr, ModuleRunnerImportMeta, ModuleRunnerOptions, ModuleRunnerTransport, ModuleRunnerTransportHandlers, ResolvedResult, SSRImportMetadata, createWebSocketModuleRunnerTransport, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };