vite 6.0.0-beta.8 → 6.0.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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/LICENSE.md +247 -13
- package/client.d.ts +14 -0
- package/dist/client/client.mjs +343 -93
- package/dist/node/chunks/dep-0q9rEWat.js +822 -0
- package/dist/node/chunks/dep-3RmXg9uo.js +553 -0
- package/dist/node/chunks/dep-C1dfssTZ.js +7002 -0
- package/dist/node/chunks/{dep-Ddvoc4zx.js → dep-C6qYk3zB.js} +21241 -16553
- package/dist/node/chunks/{dep-CdoEeCn3.js → dep-DnSxfB-q.js} +0 -4
- package/dist/node/cli.js +7 -8
- package/dist/node/constants.js +13 -18
- package/dist/node/index.d.ts +1728 -1590
- package/dist/node/index.js +6 -38
- package/dist/node/module-runner.d.ts +92 -99
- package/dist/node/module-runner.js +269 -94
- package/dist/node-cjs/publicUtils.cjs +2699 -2747
- package/index.cjs +35 -3
- package/misc/false.js +1 -0
- package/misc/true.js +1 -0
- package/package.json +32 -31
- package/types/hmrPayload.d.ts +5 -0
- package/dist/node/chunks/dep-DUn1iy3F.js +0 -913
- package/dist/node/chunks/dep-mtw2NpNs.js +0 -589
- package/dist/node/chunks/dep-qU9-vqRp.js +0 -7216
package/dist/node/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
3
|
-
export { B as BuildEnvironment, D as DevEnvironment,
|
4
|
-
export { VERSION as version } from './constants.js';
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-C6qYk3zB.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-C6qYk3zB.js';
|
4
|
+
export { DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import 'node:fs';
|
7
7
|
import 'node:fs/promises';
|
@@ -21,7 +21,6 @@ import 'net';
|
|
21
21
|
import 'events';
|
22
22
|
import 'url';
|
23
23
|
import 'http';
|
24
|
-
import 'fs/promises';
|
25
24
|
import 'stream';
|
26
25
|
import 'os';
|
27
26
|
import 'child_process';
|
@@ -33,17 +32,17 @@ import 'module';
|
|
33
32
|
import 'node:readline';
|
34
33
|
import 'node:process';
|
35
34
|
import 'node:buffer';
|
35
|
+
import 'node:events';
|
36
36
|
import 'crypto';
|
37
37
|
import 'node:assert';
|
38
38
|
import 'node:v8';
|
39
39
|
import 'node:worker_threads';
|
40
|
-
import 'node:events';
|
41
40
|
import 'zlib';
|
42
41
|
import 'buffer';
|
43
42
|
import 'https';
|
44
43
|
import 'tls';
|
45
44
|
import 'assert';
|
46
|
-
import 'querystring';
|
45
|
+
import 'node:querystring';
|
47
46
|
import 'node:zlib';
|
48
47
|
|
49
48
|
const CSS_LANGS_RE = (
|
@@ -150,35 +149,4 @@ function splitVendorChunkPlugin() {
|
|
150
149
|
};
|
151
150
|
}
|
152
151
|
|
153
|
-
|
154
|
-
constructor(options) {
|
155
|
-
this.options = options;
|
156
|
-
}
|
157
|
-
register(environment) {
|
158
|
-
this.options.onMessage(async (data) => {
|
159
|
-
if (typeof data !== "object" || !data || !data.__v) return;
|
160
|
-
const method = data.m;
|
161
|
-
const parameters = data.a;
|
162
|
-
try {
|
163
|
-
const result = await environment[method](...parameters);
|
164
|
-
this.options.send({
|
165
|
-
__v: true,
|
166
|
-
r: result,
|
167
|
-
i: data.i
|
168
|
-
});
|
169
|
-
} catch (error) {
|
170
|
-
this.options.send({
|
171
|
-
__v: true,
|
172
|
-
e: {
|
173
|
-
name: error.name,
|
174
|
-
message: error.message,
|
175
|
-
stack: error.stack
|
176
|
-
},
|
177
|
-
i: data.i
|
178
|
-
});
|
179
|
-
}
|
180
|
-
});
|
181
|
-
}
|
182
|
-
}
|
183
|
-
|
184
|
-
export { RemoteEnvironmentTransport, isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|
152
|
+
export { isCSSRequest, splitVendorChunk, splitVendorChunkPlugin };
|
@@ -2,6 +2,89 @@ import { ModuleNamespace, ViteHotContext } from '../../types/hot.js';
|
|
2
2
|
import { HotPayload, Update } from '../../types/hmrPayload.js';
|
3
3
|
import { InferCustomEventPayload } from '../../types/customEvent.js';
|
4
4
|
|
5
|
+
interface FetchFunctionOptions {
|
6
|
+
cached?: boolean;
|
7
|
+
startOffset?: number;
|
8
|
+
}
|
9
|
+
type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
|
10
|
+
interface CachedFetchResult {
|
11
|
+
/**
|
12
|
+
* If module cached in the runner, we can just confirm
|
13
|
+
* it wasn't invalidated on the server side.
|
14
|
+
*/
|
15
|
+
cache: true;
|
16
|
+
}
|
17
|
+
interface ExternalFetchResult {
|
18
|
+
/**
|
19
|
+
* The path to the externalized module starting with file://,
|
20
|
+
* by default this will be imported via a dynamic "import"
|
21
|
+
* instead of being transformed by vite and loaded with vite runner
|
22
|
+
*/
|
23
|
+
externalize: string;
|
24
|
+
/**
|
25
|
+
* Type of the module. Will be used to determine if import statement is correct.
|
26
|
+
* For example, if Vite needs to throw an error if variable is not actually exported
|
27
|
+
*/
|
28
|
+
type: 'module' | 'commonjs' | 'builtin' | 'network';
|
29
|
+
}
|
30
|
+
interface ViteFetchResult {
|
31
|
+
/**
|
32
|
+
* Code that will be evaluated by vite runner
|
33
|
+
* by default this will be wrapped in an async function
|
34
|
+
*/
|
35
|
+
code: string;
|
36
|
+
/**
|
37
|
+
* File path of the module on disk.
|
38
|
+
* This will be resolved as import.meta.url/filename
|
39
|
+
* Will be equal to `null` for virtual modules
|
40
|
+
*/
|
41
|
+
file: string | null;
|
42
|
+
/**
|
43
|
+
* Module ID in the server module graph.
|
44
|
+
*/
|
45
|
+
id: string;
|
46
|
+
/**
|
47
|
+
* Module URL used in the import.
|
48
|
+
*/
|
49
|
+
url: string;
|
50
|
+
/**
|
51
|
+
* Invalidate module on the client side.
|
52
|
+
*/
|
53
|
+
invalidate: boolean;
|
54
|
+
}
|
55
|
+
type InvokeMethods = {
|
56
|
+
fetchModule: (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
57
|
+
};
|
58
|
+
|
59
|
+
type ModuleRunnerTransportHandlers = {
|
60
|
+
onMessage: (data: HotPayload) => void;
|
61
|
+
onDisconnection: () => void;
|
62
|
+
};
|
63
|
+
/**
|
64
|
+
* "send and connect" or "invoke" must be implemented
|
65
|
+
*/
|
66
|
+
interface ModuleRunnerTransport {
|
67
|
+
connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void;
|
68
|
+
disconnect?(): Promise<void> | void;
|
69
|
+
send?(data: HotPayload): Promise<void> | void;
|
70
|
+
invoke?(data: HotPayload): Promise<{
|
71
|
+
r: any;
|
72
|
+
} | {
|
73
|
+
e: any;
|
74
|
+
}>;
|
75
|
+
timeout?: number;
|
76
|
+
}
|
77
|
+
interface NormalizedModuleRunnerTransport {
|
78
|
+
connect?(onMessage?: (data: HotPayload) => void): Promise<void> | void;
|
79
|
+
disconnect?(): Promise<void> | void;
|
80
|
+
send(data: HotPayload): Promise<void>;
|
81
|
+
invoke<T extends keyof InvokeMethods>(name: T, data: Parameters<InvokeMethods[T]>): Promise<ReturnType<Awaited<InvokeMethods[T]>>>;
|
82
|
+
}
|
83
|
+
declare const createWebSocketModuleRunnerTransport: (options: {
|
84
|
+
createConnection: () => WebSocket;
|
85
|
+
pingInterval?: number;
|
86
|
+
}) => Required<Pick<ModuleRunnerTransport, "connect" | "disconnect" | "send">>;
|
87
|
+
|
5
88
|
interface SourceMapLike {
|
6
89
|
version: number;
|
7
90
|
mappings?: string;
|
@@ -39,25 +122,9 @@ interface HMRLogger {
|
|
39
122
|
error(msg: string | Error): void;
|
40
123
|
debug(...msg: unknown[]): void;
|
41
124
|
}
|
42
|
-
interface HMRConnection {
|
43
|
-
/**
|
44
|
-
* Checked before sending messages to the client.
|
45
|
-
*/
|
46
|
-
isReady(): boolean;
|
47
|
-
/**
|
48
|
-
* Send message to the client.
|
49
|
-
*/
|
50
|
-
send(messages: HotPayload): void;
|
51
|
-
}
|
52
|
-
declare class HMRMessenger {
|
53
|
-
private connection;
|
54
|
-
constructor(connection: HMRConnection);
|
55
|
-
private queue;
|
56
|
-
send(payload: HotPayload): void;
|
57
|
-
flush(): void;
|
58
|
-
}
|
59
125
|
declare class HMRClient {
|
60
126
|
logger: HMRLogger;
|
127
|
+
private transport;
|
61
128
|
private importUpdatedModule;
|
62
129
|
hotModulesMap: Map<string, HotModule>;
|
63
130
|
disposeMap: Map<string, (data: any) => void | Promise<void>>;
|
@@ -65,9 +132,9 @@ declare class HMRClient {
|
|
65
132
|
dataMap: Map<string, any>;
|
66
133
|
customListenersMap: CustomListenersMap;
|
67
134
|
ctxToListenersMap: Map<string, CustomListenersMap>;
|
68
|
-
|
69
|
-
constructor(logger: HMRLogger, connection: HMRConnection, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
|
135
|
+
constructor(logger: HMRLogger, transport: NormalizedModuleRunnerTransport, importUpdatedModule: (update: Update) => Promise<ModuleNamespace>);
|
70
136
|
notifyListeners<T extends string>(event: T, data: InferCustomEventPayload<T>): Promise<void>;
|
137
|
+
send(payload: HotPayload): void;
|
71
138
|
clear(): void;
|
72
139
|
prunePaths(paths: string[]): Promise<void>;
|
73
140
|
protected warnFailedUpdate(err: Error, path: string | string[]): void;
|
@@ -119,7 +186,7 @@ declare class ModuleRunner {
|
|
119
186
|
private readonly root;
|
120
187
|
private readonly concurrentModuleNodePromises;
|
121
188
|
private closed;
|
122
|
-
constructor(options: ModuleRunnerOptions, evaluator
|
189
|
+
constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
|
123
190
|
/**
|
124
191
|
* URL to execute. Accepts file path, server path or id relative to the root.
|
125
192
|
*/
|
@@ -160,28 +227,6 @@ interface InterceptorOptions {
|
|
160
227
|
retrieveSourceMap?: RetrieveSourceMapHandler;
|
161
228
|
}
|
162
229
|
|
163
|
-
interface RunnerTransport {
|
164
|
-
fetchModule: FetchFunction;
|
165
|
-
}
|
166
|
-
declare class RemoteRunnerTransport implements RunnerTransport {
|
167
|
-
private readonly options;
|
168
|
-
private rpcPromises;
|
169
|
-
constructor(options: {
|
170
|
-
send: (data: any) => void;
|
171
|
-
onMessage: (handler: (data: any) => void) => void;
|
172
|
-
timeout?: number;
|
173
|
-
});
|
174
|
-
private resolve;
|
175
|
-
fetchModule(id: string, importer?: string): Promise<FetchResult>;
|
176
|
-
}
|
177
|
-
|
178
|
-
interface ModuleRunnerHMRConnection extends HMRConnection {
|
179
|
-
/**
|
180
|
-
* Configure how HMR is handled when this connection triggers an update.
|
181
|
-
* This method expects that connection will start listening for HMR updates and call this callback when it's received.
|
182
|
-
*/
|
183
|
-
onUpdate(callback: (payload: HotPayload) => void): void;
|
184
|
-
}
|
185
230
|
interface ModuleRunnerImportMeta extends ImportMeta {
|
186
231
|
url: string;
|
187
232
|
env: ImportMetaEnv;
|
@@ -213,66 +258,12 @@ interface ModuleEvaluator {
|
|
213
258
|
*/
|
214
259
|
runExternalModule(file: string): Promise<any>;
|
215
260
|
}
|
216
|
-
type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
|
217
|
-
interface CachedFetchResult {
|
218
|
-
/**
|
219
|
-
* If module cached in the runner, we can just confirm
|
220
|
-
* it wasn't invalidated on the server side.
|
221
|
-
*/
|
222
|
-
cache: true;
|
223
|
-
}
|
224
|
-
interface ExternalFetchResult {
|
225
|
-
/**
|
226
|
-
* The path to the externalized module starting with file://,
|
227
|
-
* by default this will be imported via a dynamic "import"
|
228
|
-
* instead of being transformed by vite and loaded with vite runner
|
229
|
-
*/
|
230
|
-
externalize: string;
|
231
|
-
/**
|
232
|
-
* Type of the module. Will be used to determine if import statement is correct.
|
233
|
-
* For example, if Vite needs to throw an error if variable is not actually exported
|
234
|
-
*/
|
235
|
-
type: 'module' | 'commonjs' | 'builtin' | 'network';
|
236
|
-
}
|
237
|
-
interface ViteFetchResult {
|
238
|
-
/**
|
239
|
-
* Code that will be evaluated by vite runner
|
240
|
-
* by default this will be wrapped in an async function
|
241
|
-
*/
|
242
|
-
code: string;
|
243
|
-
/**
|
244
|
-
* File path of the module on disk.
|
245
|
-
* This will be resolved as import.meta.url/filename
|
246
|
-
* Will be equal to `null` for virtual modules
|
247
|
-
*/
|
248
|
-
file: string | null;
|
249
|
-
/**
|
250
|
-
* Module ID in the server module graph.
|
251
|
-
*/
|
252
|
-
id: string;
|
253
|
-
/**
|
254
|
-
* Module URL used in the import.
|
255
|
-
*/
|
256
|
-
url: string;
|
257
|
-
/**
|
258
|
-
* Invalidate module on the client side.
|
259
|
-
*/
|
260
|
-
invalidate: boolean;
|
261
|
-
}
|
262
261
|
type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
|
263
262
|
url: string;
|
264
263
|
id: string;
|
265
264
|
};
|
266
265
|
type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
267
|
-
interface FetchFunctionOptions {
|
268
|
-
cached?: boolean;
|
269
|
-
startOffset?: number;
|
270
|
-
}
|
271
266
|
interface ModuleRunnerHmr {
|
272
|
-
/**
|
273
|
-
* Configure how HMR communicates between the client and the server.
|
274
|
-
*/
|
275
|
-
connection: ModuleRunnerHMRConnection;
|
276
267
|
/**
|
277
268
|
* Configure HMR logger.
|
278
269
|
*/
|
@@ -286,7 +277,7 @@ interface ModuleRunnerOptions {
|
|
286
277
|
/**
|
287
278
|
* A set of methods to communicate with the server.
|
288
279
|
*/
|
289
|
-
transport:
|
280
|
+
transport: ModuleRunnerTransport;
|
290
281
|
/**
|
291
282
|
* Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available.
|
292
283
|
* Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method.
|
@@ -295,8 +286,10 @@ interface ModuleRunnerOptions {
|
|
295
286
|
sourcemapInterceptor?: false | 'node' | 'prepareStackTrace' | InterceptorOptions;
|
296
287
|
/**
|
297
288
|
* Disable HMR or configure HMR options.
|
289
|
+
*
|
290
|
+
* @default true
|
298
291
|
*/
|
299
|
-
hmr?:
|
292
|
+
hmr?: boolean | ModuleRunnerHmr;
|
300
293
|
/**
|
301
294
|
* Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
|
302
295
|
*/
|
@@ -373,4 +366,4 @@ declare class ESModulesEvaluator implements ModuleEvaluator {
|
|
373
366
|
runExternalModule(filepath: string): Promise<any>;
|
374
367
|
}
|
375
368
|
|
376
|
-
export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, type FetchFunction, type FetchFunctionOptions, type FetchResult, type
|
369
|
+
export { ESModulesEvaluator, EvaluatedModuleNode, EvaluatedModules, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRLogger, type InterceptorOptions, type ModuleEvaluator, ModuleRunner, type ModuleRunnerContext, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, type ModuleRunnerTransport, type ModuleRunnerTransportHandlers, type ResolvedResult, type SSRImportMetadata, createWebSocketModuleRunnerTransport, ssrDynamicImportKey, ssrExportAllKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
|