vite 6.3.5 → 7.0.0-beta.1
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.
- package/LICENSE.md +29 -0
- package/bin/vite.js +4 -4
- package/dist/client/client.mjs +793 -921
- package/dist/client/env.mjs +14 -19
- package/dist/node/chunks/dep-3PhSlasG.js +5 -0
- package/dist/node/chunks/dep-B4i1tHPo.js +30 -0
- package/dist/node/chunks/dep-BO5GbxpL.js +7345 -0
- package/dist/node/chunks/dep-BaSfMtGz.js +5 -0
- package/dist/node/chunks/dep-Bb92EWrU.js +5 -0
- package/dist/node/chunks/dep-C9KS6hrN.js +5 -0
- package/dist/node/chunks/dep-Ctugieod.js +150 -0
- package/dist/node/chunks/dep-D5HXLrlI.js +378 -0
- package/dist/node/chunks/dep-Da5Rc_CS.js +36548 -0
- package/dist/node/chunks/dep-Dg4W3IAQ.js +5597 -0
- package/dist/node/chunks/dep-uSUFJk9A.js +446 -0
- package/dist/node/cli.js +617 -865
- package/dist/node/constants.js +3 -148
- package/dist/node/index.d.ts +2724 -3124
- package/dist/node/index.js +25 -188
- package/dist/node/module-runner.d.ts +243 -234
- package/dist/node/module-runner.js +1043 -1172
- package/dist/node/moduleRunnerTransport-BWUZBVLX.d.ts +88 -0
- package/package.json +38 -41
- package/types/importGlob.d.ts +4 -0
- package/types/internal/cssPreprocessorOptions.d.ts +3 -22
- package/dist/node/chunks/dep-3RmXg9uo.js +0 -553
- package/dist/node/chunks/dep-AiMcmC_f.js +0 -822
- package/dist/node/chunks/dep-CvfTChi5.js +0 -8218
- package/dist/node/chunks/dep-DBxKXgDP.js +0 -49496
- package/dist/node/chunks/dep-SgSik2vo.js +0 -7113
- package/dist/node/moduleRunnerTransport.d-DJ_mE5sf.d.ts +0 -87
- package/dist/node-cjs/publicUtils.cjs +0 -3986
- package/index.cjs +0 -96
- package/index.d.cts +0 -6
@@ -1,290 +1,299 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
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-BWUZBVLX.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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
version: number;
|
9
|
+
mappings?: string;
|
10
|
+
names?: string[];
|
11
|
+
sources?: string[];
|
12
|
+
sourcesContent?: string[];
|
13
13
|
}
|
14
14
|
declare class DecodedMap {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
26
|
+
lastKey: number;
|
27
|
+
lastNeedle: number;
|
28
|
+
lastIndex: number;
|
29
29
|
}
|
30
|
-
|
30
|
+
//#endregion
|
31
|
+
//#region src/shared/hmr.d.ts
|
31
32
|
type CustomListenersMap = Map<string, ((data: any) => void)[]>;
|
32
33
|
interface HotModule {
|
33
|
-
|
34
|
-
|
34
|
+
id: string;
|
35
|
+
callbacks: HotCallback[];
|
35
36
|
}
|
36
37
|
interface HotCallback {
|
37
|
-
|
38
|
-
|
38
|
+
deps: string[];
|
39
|
+
fn: (modules: Array<ModuleNamespace | undefined>) => void;
|
39
40
|
}
|
40
41
|
interface HMRLogger {
|
41
|
-
|
42
|
-
|
42
|
+
error(msg: string | Error): void;
|
43
|
+
debug(...msg: unknown[]): void;
|
43
44
|
}
|
44
45
|
declare class HMRClient {
|
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
|
-
|
46
|
+
logger: HMRLogger;
|
47
|
+
private transport;
|
48
|
+
private importUpdatedModule;
|
49
|
+
hotModulesMap: Map<string, HotModule>;
|
50
|
+
disposeMap: Map<string, (data: any) => void | Promise<void>>;
|
51
|
+
pruneMap: Map<string, (data: any) => void | Promise<void>>;
|
52
|
+
dataMap: Map<string, any>;
|
53
|
+
customListenersMap: CustomListenersMap;
|
54
|
+
ctxToListenersMap: Map<string, CustomListenersMap>;
|
55
|
+
currentFirstInvalidatedBy: string | undefined;
|
56
|
+
constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
|
57
|
+
notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
|
58
|
+
send(payload: HotPayload): void;
|
59
|
+
clear(): void;
|
60
|
+
prunePaths(paths: string[]): Promise<void>;
|
61
|
+
protected warnFailedUpdate(err: Error, path: string | string[]): void;
|
62
|
+
private updateQueue;
|
63
|
+
private pendingUpdateQueue;
|
64
|
+
/**
|
65
|
+
* buffer multiple hot updates triggered by the same src change
|
66
|
+
* so that they are invoked in the same order they were sent.
|
67
|
+
* (otherwise the order may be inconsistent because of the http request round trip)
|
68
|
+
*/
|
69
|
+
queueUpdate(payload: Update): Promise<void>;
|
70
|
+
private fetchUpdate;
|
70
71
|
}
|
71
|
-
|
72
|
+
//#endregion
|
73
|
+
//#region src/shared/ssrTransform.d.ts
|
72
74
|
interface DefineImportMetadata {
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
75
|
+
/**
|
76
|
+
* Imported names before being transformed to `ssrImportKey`
|
77
|
+
*
|
78
|
+
* import foo, { bar as baz, qux } from 'hello'
|
79
|
+
* => ['default', 'bar', 'qux']
|
80
|
+
*
|
81
|
+
* import * as namespace from 'world
|
82
|
+
* => undefined
|
83
|
+
*/
|
84
|
+
importedNames?: string[];
|
83
85
|
}
|
84
86
|
interface SSRImportMetadata extends DefineImportMetadata {
|
85
|
-
|
87
|
+
isDynamicImport?: boolean;
|
86
88
|
}
|
87
|
-
|
89
|
+
/**
|
90
|
+
* Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
|
91
|
+
* Top-level imports and dynamic imports work slightly differently in Node.js.
|
92
|
+
* This function normalizes the differences so it matches prod behaviour.
|
93
|
+
*/
|
94
|
+
//#endregion
|
95
|
+
//#region src/module-runner/constants.d.ts
|
88
96
|
declare const ssrModuleExportsKey = "__vite_ssr_exports__";
|
89
97
|
declare const ssrImportKey = "__vite_ssr_import__";
|
90
98
|
declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
|
91
99
|
declare const ssrExportAllKey = "__vite_ssr_exportAll__";
|
100
|
+
declare const ssrExportNameKey = "__vite_ssr_exportName__";
|
92
101
|
declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
|
93
|
-
|
102
|
+
//#endregion
|
103
|
+
//#region src/module-runner/runner.d.ts
|
94
104
|
interface ModuleRunnerDebugger {
|
95
|
-
|
105
|
+
(formatter: unknown, ...args: unknown[]): void;
|
96
106
|
}
|
97
107
|
declare class ModuleRunner {
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
108
|
+
options: ModuleRunnerOptions;
|
109
|
+
evaluator: ModuleEvaluator;
|
110
|
+
private debug?;
|
111
|
+
evaluatedModules: EvaluatedModules;
|
112
|
+
hmrClient?: HMRClient;
|
113
|
+
private readonly envProxy;
|
114
|
+
private readonly transport;
|
115
|
+
private readonly resetSourceMapSupport?;
|
116
|
+
private readonly concurrentModuleNodePromises;
|
117
|
+
private closed;
|
118
|
+
constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
|
119
|
+
/**
|
120
|
+
* URL to execute. Accepts file path, server path or id relative to the root.
|
121
|
+
*/
|
122
|
+
import<T = any>(url: string): Promise<T>;
|
123
|
+
/**
|
124
|
+
* Clear all caches including HMR listeners.
|
125
|
+
*/
|
126
|
+
clearCache(): void;
|
127
|
+
/**
|
128
|
+
* Clears all caches, removes all HMR listeners, and resets source map support.
|
129
|
+
* This method doesn't stop the HMR connection.
|
130
|
+
*/
|
131
|
+
close(): Promise<void>;
|
132
|
+
/**
|
133
|
+
* Returns `true` if the runtime has been closed by calling `close()` method.
|
134
|
+
*/
|
135
|
+
isClosed(): boolean;
|
136
|
+
private processImport;
|
137
|
+
private isCircularModule;
|
138
|
+
private isCircularImport;
|
139
|
+
private cachedRequest;
|
140
|
+
private cachedModule;
|
141
|
+
private getModuleInformation;
|
142
|
+
protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>;
|
133
143
|
}
|
134
|
-
|
144
|
+
//#endregion
|
145
|
+
//#region src/module-runner/sourcemap/interceptor.d.ts
|
135
146
|
interface RetrieveFileHandler {
|
136
|
-
|
147
|
+
(path: string): string | null | undefined | false;
|
137
148
|
}
|
138
149
|
interface RetrieveSourceMapHandler {
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
150
|
+
(path: string): null | {
|
151
|
+
url: string;
|
152
|
+
map: any;
|
153
|
+
};
|
143
154
|
}
|
144
155
|
interface InterceptorOptions {
|
145
|
-
|
146
|
-
|
156
|
+
retrieveFile?: RetrieveFileHandler;
|
157
|
+
retrieveSourceMap?: RetrieveSourceMapHandler;
|
147
158
|
}
|
148
|
-
|
159
|
+
//#endregion
|
160
|
+
//#region src/module-runner/types.d.ts
|
149
161
|
interface ModuleRunnerImportMeta extends ImportMeta {
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
162
|
+
url: string;
|
163
|
+
env: ImportMetaEnv;
|
164
|
+
hot?: ViteHotContext;
|
165
|
+
[key: string]: any;
|
154
166
|
}
|
155
167
|
interface ModuleRunnerContext {
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
168
|
+
[ssrModuleExportsKey]: Record<string, any>;
|
169
|
+
[ssrImportKey]: (id: string, metadata?: DefineImportMetadata) => Promise<any>;
|
170
|
+
[ssrDynamicImportKey]: (id: string, options?: ImportCallOptions) => Promise<any>;
|
171
|
+
[ssrExportAllKey]: (obj: any) => void;
|
172
|
+
[ssrExportNameKey]: (name: string, getter: () => unknown) => void;
|
173
|
+
[ssrImportMetaKey]: ModuleRunnerImportMeta;
|
161
174
|
}
|
162
175
|
interface ModuleEvaluator {
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
182
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
199
|
+
/**
|
200
|
+
* Configure HMR logger.
|
201
|
+
*/
|
202
|
+
logger?: false | HMRLogger;
|
190
203
|
}
|
191
204
|
interface ModuleRunnerOptions {
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
227
|
+
[key: string]: any;
|
228
|
+
BASE_URL: string;
|
229
|
+
MODE: string;
|
230
|
+
DEV: boolean;
|
231
|
+
PROD: boolean;
|
232
|
+
SSR: boolean;
|
225
233
|
}
|
226
|
-
|
234
|
+
//#endregion
|
235
|
+
//#region src/module-runner/evaluatedModules.d.ts
|
227
236
|
declare class EvaluatedModuleNode {
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
237
|
+
id: string;
|
238
|
+
url: string;
|
239
|
+
importers: Set<string>;
|
240
|
+
imports: Set<string>;
|
241
|
+
evaluated: boolean;
|
242
|
+
meta: ResolvedResult | undefined;
|
243
|
+
promise: Promise<any> | undefined;
|
244
|
+
exports: any | undefined;
|
245
|
+
file: string;
|
246
|
+
map: DecodedMap | undefined;
|
247
|
+
constructor(id: string, url: string);
|
239
248
|
}
|
240
249
|
declare class EvaluatedModules {
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
250
|
+
readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
|
251
|
+
readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
|
252
|
+
readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
|
253
|
+
/**
|
254
|
+
* Returns the module node by the resolved module ID. Usually, module ID is
|
255
|
+
* the file system path with query and/or hash. It can also be a virtual module.
|
256
|
+
*
|
257
|
+
* Module runner graph will have 1 to 1 mapping with the server module graph.
|
258
|
+
* @param id Resolved module ID
|
259
|
+
*/
|
260
|
+
getModuleById(id: string): EvaluatedModuleNode | undefined;
|
261
|
+
/**
|
262
|
+
* Returns all modules related to the file system path. Different modules
|
263
|
+
* might have different query parameters or hash, so it's possible to have
|
264
|
+
* multiple modules for the same file.
|
265
|
+
* @param file The file system path of the module
|
266
|
+
*/
|
267
|
+
getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
|
268
|
+
/**
|
269
|
+
* Returns the module node by the URL that was used in the import statement.
|
270
|
+
* Unlike module graph on the server, the URL is not resolved and is used as is.
|
271
|
+
* @param url Server URL that was used in the import statement
|
272
|
+
*/
|
273
|
+
getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
|
274
|
+
/**
|
275
|
+
* Ensure that module is in the graph. If the module is already in the graph,
|
276
|
+
* it will return the existing module node. Otherwise, it will create a new
|
277
|
+
* module node and add it to the graph.
|
278
|
+
* @param id Resolved module ID
|
279
|
+
* @param url URL that was used in the import statement
|
280
|
+
*/
|
281
|
+
ensureModule(id: string, url: string): EvaluatedModuleNode;
|
282
|
+
invalidateModule(node: EvaluatedModuleNode): void;
|
283
|
+
/**
|
284
|
+
* Extracts the inlined source map from the module code and returns the decoded
|
285
|
+
* source map. If the source map is not inlined, it will return null.
|
286
|
+
* @param id Resolved module ID
|
287
|
+
*/
|
288
|
+
getModuleSourceMapById(id: string): DecodedMap | null;
|
289
|
+
clear(): void;
|
281
290
|
}
|
282
|
-
|
291
|
+
//#endregion
|
292
|
+
//#region src/module-runner/esmEvaluator.d.ts
|
283
293
|
declare class ESModulesEvaluator implements ModuleEvaluator {
|
284
|
-
|
285
|
-
|
286
|
-
|
294
|
+
readonly startOffset: number;
|
295
|
+
runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
|
296
|
+
runExternalModule(filepath: string): Promise<any>;
|
287
297
|
}
|
288
|
-
|
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 };
|
298
|
+
//#endregion
|
299
|
+
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 };
|