vite 8.1.4 → 8.2.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.
@@ -2,7 +2,6 @@ import { a as ExternalFetchResult, c as ViteFetchResult, i as createWebSocketMod
2
2
  import { ModuleNamespace, ViteHotContext } from "#types/hot";
3
3
  import { HotPayload, Update } from "#types/hmrPayload";
4
4
  import { InferCustomEventPayload } from "#types/customEvent";
5
-
6
5
  //#region src/module-runner/sourcemap/decoder.d.ts
7
6
  interface SourceMapLike {
8
7
  version: number;
@@ -63,10 +62,10 @@ declare class HMRClient {
63
62
  private updateQueue;
64
63
  private pendingUpdateQueue;
65
64
  /**
66
- * buffer multiple hot updates triggered by the same src change
67
- * so that they are invoked in the same order they were sent.
68
- * (otherwise the order may be inconsistent because of the http request round trip)
69
- */
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
+ */
70
69
  queueUpdate(payload: Update): Promise<void>;
71
70
  private fetchUpdate;
72
71
  }
@@ -74,14 +73,14 @@ declare class HMRClient {
74
73
  //#region src/shared/ssrTransform.d.ts
75
74
  interface DefineImportMetadata {
76
75
  /**
77
- * Imported names before being transformed to `ssrImportKey`
78
- *
79
- * import foo, { bar as baz, qux } from 'hello'
80
- * => ['default', 'bar', 'qux']
81
- *
82
- * import * as namespace from 'world
83
- * => undefined
84
- */
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
+ */
85
84
  importedNames?: string[];
86
85
  }
87
86
  interface SSRImportMetadata extends DefineImportMetadata {
@@ -114,21 +113,21 @@ declare class ModuleRunner {
114
113
  private closed;
115
114
  constructor(options: ModuleRunnerOptions, evaluator?: ModuleEvaluator, debug?: ModuleRunnerDebugger | undefined);
116
115
  /**
117
- * URL to execute. Accepts file path, server path or id relative to the root.
118
- */
116
+ * URL to execute. Accepts file path, server path or id relative to the root.
117
+ */
119
118
  import<T = any>(url: string): Promise<T>;
120
119
  /**
121
- * Clear all caches including HMR listeners.
122
- */
120
+ * Clear all caches including HMR listeners.
121
+ */
123
122
  clearCache(): void;
124
123
  /**
125
- * Clears all caches, removes all HMR listeners, and resets source map support.
126
- * This method doesn't stop the HMR connection.
127
- */
124
+ * Clears all caches, removes all HMR listeners, and resets source map support.
125
+ * This method doesn't stop the HMR connection.
126
+ */
128
127
  close(): Promise<void>;
129
128
  /**
130
- * Returns `true` if the runtime has been closed by calling `close()` method.
131
- */
129
+ * Returns `true` if the runtime has been closed by calling `close()` method.
130
+ */
132
131
  isClosed(): boolean;
133
132
  private processImport;
134
133
  private isCircularRequest;
@@ -175,20 +174,20 @@ interface ModuleRunnerContext {
175
174
  }
176
175
  interface ModuleEvaluator {
177
176
  /**
178
- * Number of prefixed lines in the transformed code.
179
- */
177
+ * Number of prefixed lines in the transformed code.
178
+ */
180
179
  startOffset?: number;
181
180
  /**
182
- * Run code that was transformed by Vite.
183
- * @param context Function context
184
- * @param code Transformed code
185
- * @param module The module node
186
- */
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
+ */
187
186
  runInlinedModule(context: ModuleRunnerContext, code: string, module: Readonly<EvaluatedModuleNode>): Promise<any>;
188
187
  /**
189
- * Run externalized module.
190
- * @param file File URL to the external module
191
- */
188
+ * Run externalized module.
189
+ * @param file File URL to the external module
190
+ */
192
191
  runExternalModule(file: string): Promise<any>;
193
192
  }
194
193
  type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
@@ -198,36 +197,36 @@ type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
198
197
  type FetchFunction = (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
199
198
  interface ModuleRunnerHmr {
200
199
  /**
201
- * Configure HMR logger.
202
- */
200
+ * Configure HMR logger.
201
+ */
203
202
  logger?: false | HMRLogger;
204
203
  }
205
204
  interface ModuleRunnerOptions {
206
205
  /**
207
- * A set of methods to communicate with the server.
208
- */
206
+ * A set of methods to communicate with the server.
207
+ */
209
208
  transport: ModuleRunnerTransport;
210
209
  /**
211
- * Configure how source maps are resolved. Prefers `node` if `process.setSourceMapsEnabled` is available.
212
- * Otherwise it will use `prepareStackTrace` by default which overrides `Error.prepareStackTrace` method.
213
- * You can provide an object to configure how file contents and source maps are resolved for files that were not processed by Vite.
214
- */
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
+ */
215
214
  sourcemapInterceptor?: false | "node" | "prepareStackTrace" | InterceptorOptions;
216
215
  /**
217
- * Disable HMR or configure HMR options.
218
- *
219
- * @default true
220
- */
216
+ * Disable HMR or configure HMR options.
217
+ *
218
+ * @default true
219
+ */
221
220
  hmr?: boolean | ModuleRunnerHmr;
222
221
  /**
223
- * Create import.meta object for the module.
224
- *
225
- * @default createDefaultImportMeta
226
- */
222
+ * Create import.meta object for the module.
223
+ *
224
+ * @default createDefaultImportMeta
225
+ */
227
226
  createImportMeta?: (modulePath: string) => ModuleRunnerImportMeta | Promise<ModuleRunnerImportMeta>;
228
227
  /**
229
- * Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
230
- */
228
+ * Custom module cache. If not provided, creates a separate module cache for each ModuleRunner instance.
229
+ */
231
230
  evaluatedModules?: EvaluatedModules;
232
231
  }
233
232
  interface ImportMetaEnv {
@@ -258,40 +257,40 @@ declare class EvaluatedModules {
258
257
  readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
259
258
  readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
260
259
  /**
261
- * Returns the module node by the resolved module ID. Usually, module ID is
262
- * the file system path with query and/or hash. It can also be a virtual module.
263
- *
264
- * Module runner graph will have 1 to 1 mapping with the server module graph.
265
- * @param id Resolved module ID
266
- */
260
+ * Returns the module node by the resolved module ID. Usually, module ID is
261
+ * the file system path with query and/or hash. It can also be a virtual module.
262
+ *
263
+ * Module runner graph will have 1 to 1 mapping with the server module graph.
264
+ * @param id Resolved module ID
265
+ */
267
266
  getModuleById(id: string): EvaluatedModuleNode | undefined;
268
267
  /**
269
- * Returns all modules related to the file system path. Different modules
270
- * might have different query parameters or hash, so it's possible to have
271
- * multiple modules for the same file.
272
- * @param file The file system path of the module
273
- */
268
+ * Returns all modules related to the file system path. Different modules
269
+ * might have different query parameters or hash, so it's possible to have
270
+ * multiple modules for the same file.
271
+ * @param file The file system path of the module
272
+ */
274
273
  getModulesByFile(file: string): Set<EvaluatedModuleNode> | undefined;
275
274
  /**
276
- * Returns the module node by the URL that was used in the import statement.
277
- * Unlike module graph on the server, the URL is not resolved and is used as is.
278
- * @param url Server URL that was used in the import statement
279
- */
275
+ * Returns the module node by the URL that was used in the import statement.
276
+ * Unlike module graph on the server, the URL is not resolved and is used as is.
277
+ * @param url Server URL that was used in the import statement
278
+ */
280
279
  getModuleByUrl(url: string): EvaluatedModuleNode | undefined;
281
280
  /**
282
- * Ensure that module is in the graph. If the module is already in the graph,
283
- * it will return the existing module node. Otherwise, it will create a new
284
- * module node and add it to the graph.
285
- * @param id Resolved module ID
286
- * @param url URL that was used in the import statement
287
- */
281
+ * Ensure that module is in the graph. If the module is already in the graph,
282
+ * it will return the existing module node. Otherwise, it will create a new
283
+ * module node and add it to the graph.
284
+ * @param id Resolved module ID
285
+ * @param url URL that was used in the import statement
286
+ */
288
287
  ensureModule(id: string, url: string): EvaluatedModuleNode;
289
288
  invalidateModule(node: EvaluatedModuleNode): void;
290
289
  /**
291
- * Extracts the inlined source map from the module code and returns the decoded
292
- * source map. If the source map is not inlined, it will return null.
293
- * @param id Resolved module ID
294
- */
290
+ * Extracts the inlined source map from the module code and returns the decoded
291
+ * source map. If the source map is not inlined, it will return null.
292
+ * @param id Resolved module ID
293
+ */
295
294
  getModuleSourceMapById(id: string): DecodedMap | null;
296
295
  clear(): void;
297
296
  }
@@ -307,8 +306,8 @@ declare class ESModulesEvaluator implements ModuleEvaluator {
307
306
  //#region src/module-runner/createImportMeta.d.ts
308
307
  declare function createDefaultImportMeta(modulePath: string): ModuleRunnerImportMeta;
309
308
  /**
310
- * Create import.meta object for Node.js.
311
- */
309
+ * Create import.meta object for Node.js.
310
+ */
312
311
  declare function createNodeImportMeta(modulePath: string): ModuleRunnerImportMeta;
313
312
  //#endregion
314
313
  export { ESModulesEvaluator, type 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, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };
@@ -65,7 +65,7 @@ function normalizeString(path, allowAboveRoot) {
65
65
  else if (char === "/") break;
66
66
  else char = "/";
67
67
  if (char === "/") {
68
- if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
68
+ if (lastSlash !== index - 1 && dots !== 1) if (dots === 2) {
69
69
  if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
70
70
  if (res.length > 2) {
71
71
  let lastSlashIndex = res.lastIndexOf("/");
@@ -88,7 +88,10 @@ const isAbsolute = function(p) {
88
88
  }, dirname = function(p) {
89
89
  let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
90
90
  return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
91
- }, textDecoder = new TextDecoder(), decodeBase64 = typeof Buffer == "function" && typeof Buffer.from == "function" ? (base64) => Buffer.from(base64, "base64").toString("utf-8") : (base64) => textDecoder.decode(Uint8Array.from(atob(base64), (c) => c.charCodeAt(0))), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
91
+ }, textDecoder = new TextDecoder(), decodeBase64 = (() => {
92
+ let capturedBuffer = typeof Buffer == "function" ? Buffer : void 0;
93
+ return capturedBuffer && typeof capturedBuffer.from == "function" ? (base64) => capturedBuffer.from(base64, "base64").toString("utf-8") : (base64) => textDecoder.decode(Uint8Array.from(atob(base64), (c) => c.charCodeAt(0)));
94
+ })(), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
92
95
  function encodePathChars(filepath) {
93
96
  return filepath.includes("%") && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.includes("\\") && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.includes("\n") && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.includes("\r") && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.includes(" ") && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
94
97
  }
@@ -461,13 +464,17 @@ var HMRContext = class {
461
464
  this.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();
462
465
  }
463
466
  async prunePaths(paths) {
464
- await Promise.all(paths.map((path) => {
465
- let disposer = this.disposeMap.get(path);
466
- if (disposer) return disposer(this.dataMap.get(path));
467
- })), await Promise.all(paths.map((path) => {
468
- let fn = this.pruneMap.get(path);
469
- if (fn) return fn(this.dataMap.get(path));
470
- }));
467
+ try {
468
+ await Promise.all(paths.map((path) => {
469
+ let disposer = this.disposeMap.get(path);
470
+ if (disposer) return disposer(this.dataMap.get(path));
471
+ })), await Promise.all(paths.map((path) => {
472
+ let fn = this.pruneMap.get(path);
473
+ if (fn) return fn(this.dataMap.get(path));
474
+ }));
475
+ } finally {
476
+ paths.forEach((path) => this.dataMap.delete(path));
477
+ }
471
478
  }
472
479
  warnFailedUpdate(err, path) {
473
480
  (!(err instanceof Error) || !err.message.includes("fetch")) && this.logger.error(err), this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);
@@ -784,6 +791,7 @@ function createHMRHandlerForRunner(runner) {
784
791
  break;
785
792
  }
786
793
  case "ping": break;
794
+ case "bundled-dev-update": break;
787
795
  default: return payload;
788
796
  }
789
797
  });
@@ -863,11 +871,7 @@ function retrieveSourceMap(source) {
863
871
  let sourceMappingURL = retrieveSourceMapURL(source);
864
872
  if (!sourceMappingURL) return null;
865
873
  let sourceMapData;
866
- if (reSourceMap.test(sourceMappingURL)) {
867
- let rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1);
868
- sourceMapData = Buffer.from(rawData, "base64").toString(), sourceMappingURL = source;
869
- } else sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL);
870
- return sourceMapData ? {
874
+ return reSourceMap.test(sourceMappingURL) ? (sourceMapData = decodeBase64(sourceMappingURL.slice(sourceMappingURL.indexOf(",") + 1)), sourceMappingURL = source) : (sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL)), sourceMapData ? {
871
875
  url: sourceMappingURL,
872
876
  map: sourceMapData
873
877
  } : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.1.4",
3
+ "version": "8.2.0-beta.0",
4
4
  "description": "Native-ESM powered web dev build tool",
5
5
  "keywords": [
6
6
  "build-tool",
@@ -56,10 +56,10 @@
56
56
  "./package.json": "./package.json"
57
57
  },
58
58
  "dependencies": {
59
- "lightningcss": "^1.32.0",
59
+ "lightningcss": "^1.33.0",
60
60
  "picomatch": "^4.0.5",
61
- "postcss": "^8.5.16",
62
- "rolldown": "~1.1.4",
61
+ "postcss": "^8.5.20",
62
+ "rolldown": "~1.2.0",
63
63
  "tinyglobby": "^0.2.17"
64
64
  },
65
65
  "devDependencies": {
@@ -73,11 +73,11 @@
73
73
  "@types/escape-html": "^1.0.4",
74
74
  "@types/pnpapi": "^0.0.5",
75
75
  "@vercel/detect-agent": "^1.2.3",
76
- "@vitejs/devtools": "^0.3.4",
77
- "@vitest/utils": "4.1.9",
76
+ "@vitejs/devtools": "^0.4.1",
77
+ "@vitest/utils": "4.1.10",
78
78
  "@voidzero-dev/vite-task-client": "^0.2.0",
79
79
  "artichokie": "^0.4.4",
80
- "baseline-browser-mapping": "^2.10.42",
80
+ "baseline-browser-mapping": "^2.10.43",
81
81
  "cac": "^7.0.0",
82
82
  "chokidar": "^3.6.0",
83
83
  "connect": "^3.7.0",
@@ -85,7 +85,7 @@
85
85
  "cors": "^2.8.6",
86
86
  "cross-spawn": "^7.0.6",
87
87
  "dotenv-expand": "^13.0.0",
88
- "es-module-lexer": "^2.3.0",
88
+ "es-module-lexer": "^2.3.1",
89
89
  "esbuild": "^0.28.1",
90
90
  "escape-html": "^1.0.3",
91
91
  "estree-walker": "^3.0.3",
@@ -94,7 +94,7 @@
94
94
  "host-validation-middleware": "^0.1.4",
95
95
  "http-proxy-3": "^1.23.3",
96
96
  "launch-editor-middleware": "^2.14.1",
97
- "magic-string": "^0.30.21",
97
+ "magic-string": "^1.0.0",
98
98
  "mlly": "^1.8.2",
99
99
  "mrmime": "^2.0.1",
100
100
  "nanoid": "^5.1.16",
@@ -106,23 +106,23 @@
106
106
  "picocolors": "^1.1.1",
107
107
  "postcss-import": "^16.1.1",
108
108
  "postcss-load-config": "^6.0.1",
109
- "postcss-modules": "^9.0.0",
109
+ "postcss-modules": "^9.0.1",
110
110
  "premove": "^4.0.0",
111
111
  "resolve.exports": "^2.0.3",
112
- "rolldown-plugin-dts": "^0.26.0",
112
+ "rolldown-plugin-dts": "^0.27.9",
113
113
  "rollup": "^4.59.0",
114
114
  "rollup-plugin-license": "^3.7.1",
115
115
  "sass": "^1.101.0",
116
116
  "sass-embedded": "^1.100.0",
117
117
  "sirv": "^3.0.2",
118
118
  "strip-literal": "^3.1.0",
119
- "terser": "^5.48.0",
119
+ "terser": "^5.49.0",
120
120
  "ufo": "^1.6.4",
121
- "ws": "^8.21.0"
121
+ "ws": "^8.21.1"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "@types/node": "^20.19.0 || >=22.12.0",
125
- "@vitejs/devtools": "^0.3.0",
125
+ "@vitejs/devtools": "^0.4.0",
126
126
  "esbuild": "^0.27.0 || ^0.28.0",
127
127
  "jiti": ">=1.21.0",
128
128
  "less": "^4.0.0",
@@ -18,7 +18,7 @@ export interface CustomEventMap {
18
18
  /** @internal */
19
19
  'vite:forward-console': ForwardConsolePayload
20
20
  /** @internal */
21
- 'vite:module-loaded': { modules: string[]; clientId: string }
21
+ 'vite:client-connected': { clientId: string }
22
22
 
23
23
  // server events
24
24
  'vite:client:connect': undefined
@@ -4,6 +4,7 @@ export type HotPayload =
4
4
  | ConnectedPayload
5
5
  | PingPayload
6
6
  | UpdatePayload
7
+ | BundledDevUpdatePayload
7
8
  | FullReloadPayload
8
9
  | CustomPayload
9
10
  | ErrorPayload
@@ -22,14 +23,21 @@ export interface UpdatePayload {
22
23
  updates: Update[]
23
24
  }
24
25
 
26
+ /**
27
+ * Full-bundle-mode update notification. The client computes the HMR boundaries
28
+ * itself from `changedIds`.
29
+ */
30
+ export interface BundledDevUpdatePayload {
31
+ type: 'bundled-dev-update'
32
+ changedIds: string[]
33
+ /** URL of the per-client HMR patch chunk */
34
+ url: string
35
+ /** Per-client sequence number */
36
+ seq: number
37
+ }
38
+
25
39
  export interface Update {
26
40
  type: 'js-update' | 'css-update'
27
- /**
28
- * URL of HMR patch chunk
29
- *
30
- * This only exists when full-bundle mode is enabled.
31
- */
32
- url?: string
33
41
  path: string
34
42
  acceptedPath: string
35
43
  timestamp: number
@@ -53,6 +61,12 @@ export interface FullReloadPayload {
53
61
  path?: string
54
62
  /** @internal */
55
63
  triggeredBy?: string
64
+ /**
65
+ * When set, only the bundling-fallback page acts on the reload;
66
+ * other pages ignore the message.
67
+ * @internal
68
+ */
69
+ ifFallback?: boolean
56
70
  }
57
71
 
58
72
  export interface CustomPayload {