vite 6.0.0-beta.1 → 6.0.0-beta.3
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 +17 -215
- package/README.md +4 -4
- package/bin/vite.js +4 -0
- package/dist/client/client.mjs +8 -10
- package/dist/node/chunks/dep-CBTZ9M2V.js +7220 -0
- package/dist/node/chunks/{dep-BZ_CwQkz.js → dep-ChZnDG_O.js} +22174 -27804
- package/dist/node/chunks/dep-DHwgfHPT.js +1103 -0
- package/dist/node/chunks/dep-wWOLM6NS.js +593 -0
- package/dist/node/cli.js +10 -12
- package/dist/node/constants.js +7 -2
- package/dist/node/index.d.ts +118 -92
- package/dist/node/index.js +8 -118
- package/dist/node/module-runner.d.ts +75 -53
- package/dist/node/module-runner.js +151 -159
- package/dist/node-cjs/publicUtils.cjs +2869 -2636
- package/index.cjs +1 -1
- package/index.d.cts +1 -1
- package/package.json +17 -17
- package/dist/node/chunks/dep-BZeeNeMJ.js +0 -6843
- package/dist/node/chunks/dep-DiM5uMHt.js +0 -993
- package/dist/node/chunks/dep-IQS-Za7F.js +0 -561
@@ -1,5 +1,5 @@
|
|
1
1
|
import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
|
2
|
-
import {
|
2
|
+
import { HotPayload, Update } from '../../types/hmrPayload.js';
|
3
3
|
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
4
4
|
|
5
5
|
interface SourceMapLike {
|
@@ -47,13 +47,13 @@ interface HMRConnection {
|
|
47
47
|
/**
|
48
48
|
* Send message to the client.
|
49
49
|
*/
|
50
|
-
send(messages:
|
50
|
+
send(messages: HotPayload): void;
|
51
51
|
}
|
52
52
|
declare class HMRMessenger {
|
53
53
|
private connection;
|
54
54
|
constructor(connection: HMRConnection);
|
55
55
|
private queue;
|
56
|
-
send(
|
56
|
+
send(payload: HotPayload): void;
|
57
57
|
flush(): void;
|
58
58
|
}
|
59
59
|
declare class HMRClient {
|
@@ -111,20 +111,14 @@ declare class ModuleRunner {
|
|
111
111
|
options: ModuleRunnerOptions;
|
112
112
|
evaluator: ModuleEvaluator;
|
113
113
|
private debug?;
|
114
|
-
|
115
|
-
* Holds the cache of modules
|
116
|
-
* Keys of the map are ids
|
117
|
-
*/
|
118
|
-
moduleCache: ModuleCacheMap;
|
114
|
+
evaluatedModules: EvaluatedModules;
|
119
115
|
hmrClient?: HMRClient;
|
120
|
-
private readonly urlToIdMap;
|
121
|
-
private readonly fileToIdMap;
|
122
116
|
private readonly envProxy;
|
123
117
|
private readonly transport;
|
124
118
|
private readonly resetSourceMapSupport?;
|
125
119
|
private readonly root;
|
126
|
-
private readonly
|
127
|
-
private
|
120
|
+
private readonly concurrentModuleNodePromises;
|
121
|
+
private closed;
|
128
122
|
constructor(options: ModuleRunnerOptions, evaluator: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
|
129
123
|
/**
|
130
124
|
* URL to execute. Accepts file path, server path or id relative to the root.
|
@@ -138,18 +132,18 @@ declare class ModuleRunner {
|
|
138
132
|
* Clears all caches, removes all HMR listeners, and resets source map support.
|
139
133
|
* This method doesn't stop the HMR connection.
|
140
134
|
*/
|
141
|
-
|
135
|
+
close(): Promise<void>;
|
142
136
|
/**
|
143
|
-
* Returns `true` if the runtime has been
|
137
|
+
* Returns `true` if the runtime has been closed by calling `close()` method.
|
144
138
|
*/
|
145
|
-
|
139
|
+
isClosed(): boolean;
|
146
140
|
private processImport;
|
147
141
|
private isCircularModule;
|
148
142
|
private isCircularImport;
|
149
143
|
private cachedRequest;
|
150
144
|
private cachedModule;
|
151
145
|
private getModuleInformation;
|
152
|
-
protected directRequest(
|
146
|
+
protected directRequest(url: string, mod: EvaluatedModuleNode, _callstack: string[]): Promise<any>;
|
153
147
|
}
|
154
148
|
|
155
149
|
interface RetrieveFileHandler {
|
@@ -202,31 +196,23 @@ interface ModuleRunnerContext {
|
|
202
196
|
[ssrImportMetaKey]: ModuleRunnerImportMeta;
|
203
197
|
}
|
204
198
|
interface ModuleEvaluator {
|
199
|
+
/**
|
200
|
+
* Number of prefixed lines in the transformed code.
|
201
|
+
*/
|
202
|
+
startOffset?: number;
|
205
203
|
/**
|
206
204
|
* Run code that was transformed by Vite.
|
207
205
|
* @param context Function context
|
208
206
|
* @param code Transformed code
|
209
|
-
* @param
|
207
|
+
* @param module The module node
|
210
208
|
*/
|
211
|
-
runInlinedModule(context: ModuleRunnerContext, code: string,
|
209
|
+
runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
|
212
210
|
/**
|
213
211
|
* Run externalized module.
|
214
212
|
* @param file File URL to the external module
|
215
213
|
*/
|
216
214
|
runExternalModule(file: string): Promise<any>;
|
217
215
|
}
|
218
|
-
interface ModuleCache {
|
219
|
-
promise?: Promise<any>;
|
220
|
-
exports?: any;
|
221
|
-
evaluated?: boolean;
|
222
|
-
map?: DecodedMap;
|
223
|
-
meta?: ResolvedResult;
|
224
|
-
/**
|
225
|
-
* Module ids that imports this module
|
226
|
-
*/
|
227
|
-
importers?: Set<string>;
|
228
|
-
imports?: Set<string>;
|
229
|
-
}
|
230
216
|
type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
|
231
217
|
interface CachedFetchResult {
|
232
218
|
/**
|
@@ -246,7 +232,7 @@ interface ExternalFetchResult {
|
|
246
232
|
* Type of the module. Will be used to determine if import statement is correct.
|
247
233
|
* For example, if Vite needs to throw an error if variable is not actually exported
|
248
234
|
*/
|
249
|
-
type
|
235
|
+
type: 'module' | 'commonjs' | 'builtin' | 'network';
|
250
236
|
}
|
251
237
|
interface ViteFetchResult {
|
252
238
|
/**
|
@@ -263,7 +249,11 @@ interface ViteFetchResult {
|
|
263
249
|
/**
|
264
250
|
* Module ID in the server module graph.
|
265
251
|
*/
|
266
|
-
|
252
|
+
id: string;
|
253
|
+
/**
|
254
|
+
* Module URL used in the import.
|
255
|
+
*/
|
256
|
+
url: string;
|
267
257
|
/**
|
268
258
|
* Invalidate module on the client side.
|
269
259
|
*/
|
@@ -271,10 +261,12 @@ interface ViteFetchResult {
|
|
271
261
|
}
|
272
262
|
type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
|
273
263
|
url: string;
|
264
|
+
id: string;
|
274
265
|
};
|
275
266
|
type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
276
267
|
interface FetchFunctionOptions {
|
277
268
|
cached?: boolean;
|
269
|
+
startOffset?: number;
|
278
270
|
}
|
279
271
|
interface ModuleRunnerHmr {
|
280
272
|
/**
|
@@ -308,7 +300,7 @@ interface ModuleRunnerOptions {
|
|
308
300
|
/**
|
309
301
|
* Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
|
310
302
|
*/
|
311
|
-
|
303
|
+
evaluatedModules?: EvaluatedModules;
|
312
304
|
}
|
313
305
|
interface ImportMetaEnv {
|
314
306
|
[key: string]: any;
|
@@ -319,36 +311,66 @@ interface ImportMetaEnv {
|
|
319
311
|
SSR: boolean;
|
320
312
|
}
|
321
313
|
|
322
|
-
declare class
|
323
|
-
|
324
|
-
|
325
|
-
|
314
|
+
declare class EvaluatedModuleNode {
|
315
|
+
id: string;
|
316
|
+
url: string;
|
317
|
+
importers: Set<string>;
|
318
|
+
imports: Set<string>;
|
319
|
+
evaluated: boolean;
|
320
|
+
meta: ResolvedResult | undefined;
|
321
|
+
promise: Promise<any> | undefined;
|
322
|
+
exports: any | undefined;
|
323
|
+
file: string;
|
324
|
+
map: DecodedMap | undefined;
|
325
|
+
constructor(id: string, url: string);
|
326
|
+
}
|
327
|
+
declare class EvaluatedModules {
|
328
|
+
readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
|
329
|
+
readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
|
330
|
+
readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
|
331
|
+
/**
|
332
|
+
* Returns the module node by the resolved module ID. Usually, module ID is
|
333
|
+
* the file system path with query and/or hash. It can also be a virtual module.
|
334
|
+
*
|
335
|
+
* Module runner graph will have 1 to 1 mapping with the server module graph.
|
336
|
+
* @param id Resolved module ID
|
337
|
+
*/
|
338
|
+
getModuleById(id: string): EvaluatedModuleNode | undefined;
|
326
339
|
/**
|
327
|
-
*
|
340
|
+
* Returns all modules related to the file system path. Different modules
|
341
|
+
* might have different query parameters or hash, so it's possible to have
|
342
|
+
* multiple modules for the same file.
|
343
|
+
* @param file The file system path of the module
|
328
344
|
*/
|
329
|
-
|
330
|
-
setByModuleId(modulePath: string, mod: ModuleCache): this;
|
331
|
-
set(fsPath: string, mod: ModuleCache): this;
|
332
|
-
getByModuleId(modulePath: string): ModuleCache;
|
333
|
-
get(fsPath: string): ModuleCache;
|
334
|
-
deleteByModuleId(modulePath: string): boolean;
|
335
|
-
delete(fsPath: string): boolean;
|
336
|
-
invalidateUrl(id: string): void;
|
337
|
-
invalidateModule(module: ModuleCache): void;
|
345
|
+
getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
|
338
346
|
/**
|
339
|
-
*
|
347
|
+
* Returns the module node by the URL that was used in the import statement.
|
348
|
+
* Unlike module graph on the server, the URL is not resolved and is used as is.
|
349
|
+
* @param url Server URL that was used in the import statement
|
340
350
|
*/
|
341
|
-
|
351
|
+
getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
|
342
352
|
/**
|
343
|
-
*
|
353
|
+
* Ensure that module is in the graph. If the module is already in the graph,
|
354
|
+
* it will return the existing module node. Otherwise, it will create a new
|
355
|
+
* module node and add it to the graph.
|
356
|
+
* @param id Resolved module ID
|
357
|
+
* @param url URL that was used in the import statement
|
344
358
|
*/
|
345
|
-
|
346
|
-
|
359
|
+
ensureModule(id: string, url: string): EvaluatedModuleNode;
|
360
|
+
invalidateModule(node: EvaluatedModuleNode): void;
|
361
|
+
/**
|
362
|
+
* Extracts the inlined source map from the module code and returns the decoded
|
363
|
+
* source map. If the source map is not inlined, it will return null.
|
364
|
+
* @param id Resolved module ID
|
365
|
+
*/
|
366
|
+
getModuleSourceMapById(id: string): DecodedMap | null;
|
367
|
+
clear(): void;
|
347
368
|
}
|
348
369
|
|
349
370
|
declare class ESModulesEvaluator implements ModuleEvaluator {
|
371
|
+
startOffset: number;
|
350
372
|
runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
|
351
373
|
runExternalModule(filepath: string): Promise<any>;
|
352
374
|
}
|
353
375
|
|
354
|
-
export { ESModulesEvaluator, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRConnection, type HMRLogger, type
|
376
|
+
export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRConnection, type HMRLogger, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHMRConnection, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, RemoteRunnerTransport, type ResolvedResult, type RunnerTransport, type SSRImportMetadata, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|