vite 8.2.1 → 8.3.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,2 +1,2 @@
1
- import { $ as mergeConfig, A as createServer, B as ssrTransform, C as fetchModule, D as optimizeDeps, E as createBuilder, F as createIdResolver, G as resolveEnvPrefix, H as createServerModuleRunnerTransport, I as perEnvironmentState, J as createLogger, K as transformWithOxc, L as isFileLoadingAllowed, M as formatPostcssSourceMap, N as preprocessCSS, P as searchForWorkspaceRoot, Q as mergeAlias, R as isFileServingAllowed, S as DevEnvironment, T as build, U as buildErrorMessage, V as createServerModuleRunner, W as loadEnv, X as createFilter, Y as perEnvironmentPlugin, Z as isCSSRequest, _ as runnerImport, a as minifySync, at as DEFAULT_CLIENT_MAIN_FIELDS, b as createRunnableDevEnvironment, c as parseAstAsync, ct as DEFAULT_SERVER_MAIN_FIELDS, d as isFetchableDevEnvironment, et as normalizePath, g as sortUserPlugins, h as resolveConfig, i as minify, it as DEFAULT_CLIENT_CONDITIONS, k as createServerHotChannel, l as parseSync, lt as VERSION, m as loadConfigFromFile, n as esbuildVersion, nt as rollupVersion, o as parse, ot as DEFAULT_EXTERNAL_CONDITIONS, p as defineConfig, q as transformWithEsbuild, r as esmExternalRequirePlugin, rt as withFilter, s as parseAst, st as DEFAULT_SERVER_CONDITIONS, t as Visitor, tt as rolldownVersion, u as createFetchableDevEnvironment, ut as defaultAllowedOrigins, v as preview, w as BuildEnvironment, x as isRunnableDevEnvironment, z as send } from "./chunks/node.js";
1
+ import { $ as mergeConfig, A as optimizeDeps, B as createServerModuleRunner, D as formatPostcssSourceMap, E as createBuilder, F as searchForWorkspaceRoot, G as transformWithEsbuild, H as createLogger, I as isFileLoadingAllowed, J as resolveEnvPrefix, K as perEnvironmentState, L as isFileServingAllowed, M as createServerHotChannel, N as createServer, O as preprocessCSS, Q as mergeAlias, R as send, S as preview, T as build, U as buildErrorMessage, V as createServerModuleRunnerTransport, W as transformWithOxc, X as createFilter, Y as perEnvironmentPlugin, Z as isCSSRequest, _ as runnerImport, a as minifySync, at as DEFAULT_CLIENT_MAIN_FIELDS, b as DevEnvironment, c as parseAstAsync, ct as DEFAULT_SERVER_MAIN_FIELDS, d as isFetchableDevEnvironment, et as normalizePath, g as sortUserPlugins, h as resolveConfig, i as minify, it as DEFAULT_CLIENT_CONDITIONS, k as createIdResolver, l as parseSync, lt as VERSION, m as loadConfigFromFile, n as esbuildVersion, nt as rollupVersion, o as parse, ot as DEFAULT_EXTERNAL_CONDITIONS, p as defineConfig, q as loadEnv, r as esmExternalRequirePlugin, rt as withFilter, s as parseAst, st as DEFAULT_SERVER_CONDITIONS, t as Visitor, tt as rolldownVersion, u as createFetchableDevEnvironment, ut as defaultAllowedOrigins, v as createRunnableDevEnvironment, w as BuildEnvironment, x as fetchModule, y as isRunnableDevEnvironment, z as ssrTransform } from "./chunks/node.js";
2
2
  export { BuildEnvironment, DevEnvironment, Visitor, build, buildErrorMessage, createBuilder, createFetchableDevEnvironment, createFilter, createIdResolver, createLogger, createRunnableDevEnvironment, createServer, createServerHotChannel, createServerModuleRunner, createServerModuleRunnerTransport, defaultAllowedOrigins, DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_EXTERNAL_CONDITIONS as defaultExternalConditions, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, defineConfig, esbuildVersion, esmExternalRequirePlugin, fetchModule, formatPostcssSourceMap, isCSSRequest, isFetchableDevEnvironment, isFileLoadingAllowed, isFileServingAllowed, isRunnableDevEnvironment, loadConfigFromFile, loadEnv, mergeAlias, mergeConfig, minify, minifySync, ssrTransform as moduleRunnerTransform, normalizePath, optimizeDeps, parse, parseAst, parseAstAsync, parseSync, perEnvironmentPlugin, perEnvironmentState, preprocessCSS, preview, resolveConfig, resolveEnvPrefix, rolldownVersion, rollupVersion, runnerImport, searchForWorkspaceRoot, send, sortUserPlugins, transformWithEsbuild, transformWithOxc, VERSION as version, withFilter };
@@ -1,7 +1,7 @@
1
1
  import { a as ExternalFetchResult, c as ViteFetchResult, i as createWebSocketModuleRunnerTransport, n as ModuleRunnerTransportHandlers, o as FetchFunctionOptions, r as NormalizedModuleRunnerTransport, s as FetchResult, t as ModuleRunnerTransport } from "./chunks/moduleRunnerTransport.js";
2
2
  import { ModuleNamespace, ViteHotContext } from "#types/hot";
3
- import { HotPayload, Update } from "#types/hmrPayload";
4
3
  import { InferCustomEventPayload } from "#types/customEvent";
4
+ import { HotPayload, Update } from "#types/hmrPayload";
5
5
  //#region src/module-runner/sourcemap/decoder.d.ts
6
6
  interface SourceMapLike {
7
7
  version: number;
@@ -88,18 +88,18 @@ interface SSRImportMetadata extends DefineImportMetadata {
88
88
  }
89
89
  //#endregion
90
90
  //#region src/module-runner/constants.d.ts
91
- declare const ssrModuleExportsKey = "__vite_ssr_exports__";
92
- declare const ssrImportKey = "__vite_ssr_import__";
93
- declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
94
- declare const ssrExportAllKey = "__vite_ssr_exportAll__";
95
- declare const ssrExportNameKey = "__vite_ssr_exportName__";
96
- declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
91
+ export declare const ssrModuleExportsKey = "__vite_ssr_exports__";
92
+ export declare const ssrImportKey = "__vite_ssr_import__";
93
+ export declare const ssrDynamicImportKey = "__vite_ssr_dynamic_import__";
94
+ export declare const ssrExportAllKey = "__vite_ssr_exportAll__";
95
+ export declare const ssrExportNameKey = "__vite_ssr_exportName__";
96
+ export declare const ssrImportMetaKey = "__vite_ssr_import_meta__";
97
97
  //#endregion
98
98
  //#region src/module-runner/runner.d.ts
99
99
  interface ModuleRunnerDebugger {
100
100
  (formatter: unknown, ...args: unknown[]): void;
101
101
  }
102
- declare class ModuleRunner {
102
+ export declare class ModuleRunner {
103
103
  options: ModuleRunnerOptions;
104
104
  evaluator: ModuleEvaluator;
105
105
  private debug?;
@@ -252,7 +252,7 @@ declare class EvaluatedModuleNode {
252
252
  map: DecodedMap | undefined;
253
253
  constructor(id: string, url: string);
254
254
  }
255
- declare class EvaluatedModules {
255
+ export declare class EvaluatedModules {
256
256
  readonly idToModuleMap: Map<string, EvaluatedModuleNode>;
257
257
  readonly fileToModulesMap: Map<string, Set<EvaluatedModuleNode>>;
258
258
  readonly urlToIdModuleMap: Map<string, EvaluatedModuleNode>;
@@ -294,20 +294,20 @@ declare class EvaluatedModules {
294
294
  getModuleSourceMapById(id: string): DecodedMap | null;
295
295
  clear(): void;
296
296
  }
297
- declare function normalizeModuleId(file: string): string;
297
+ export declare function normalizeModuleId(file: string): string;
298
298
  //#endregion
299
299
  //#region src/module-runner/esmEvaluator.d.ts
300
- declare class ESModulesEvaluator implements ModuleEvaluator {
300
+ export declare class ESModulesEvaluator implements ModuleEvaluator {
301
301
  readonly startOffset: number;
302
302
  runInlinedModule(context: ModuleRunnerContext, code: string): Promise<any>;
303
303
  runExternalModule(filepath: string): Promise<any>;
304
304
  }
305
305
  //#endregion
306
306
  //#region src/module-runner/createImportMeta.d.ts
307
- declare function createDefaultImportMeta(modulePath: string): ModuleRunnerImportMeta;
307
+ export declare function createDefaultImportMeta(modulePath: string): ModuleRunnerImportMeta;
308
308
  /**
309
309
  * Create import.meta object for Node.js.
310
310
  */
311
- declare function createNodeImportMeta(modulePath: string): ModuleRunnerImportMeta;
311
+ export declare function createNodeImportMeta(modulePath: string): ModuleRunnerImportMeta;
312
312
  //#endregion
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 };
313
+ export { type EvaluatedModuleNode, type FetchFunction, type FetchFunctionOptions, type FetchResult, type HMRLogger, type InterceptorOptions, type ModuleEvaluator, type ModuleRunnerContext, type ModuleRunnerHmr, type ModuleRunnerImportMeta, type ModuleRunnerOptions, type ModuleRunnerTransport, type ModuleRunnerTransportHandlers, type ResolvedResult, type SSRImportMetadata, createWebSocketModuleRunnerTransport };
@@ -40,71 +40,6 @@ function promiseWithResolvers() {
40
40
  };
41
41
  }
42
42
  //#endregion
43
- //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
44
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
45
- function normalizeWindowsPath(input = "") {
46
- return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
47
- }
48
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
49
- function cwd() {
50
- return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
51
- }
52
- const resolve = function(...arguments_) {
53
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
54
- let resolvedPath = "", resolvedAbsolute = !1;
55
- for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
56
- let path = index >= 0 ? arguments_[index] : cwd();
57
- !path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));
58
- }
59
- return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
60
- };
61
- function normalizeString(path, allowAboveRoot) {
62
- let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
63
- for (let index = 0; index <= path.length; ++index) {
64
- if (index < path.length) char = path[index];
65
- else if (char === "/") break;
66
- else char = "/";
67
- if (char === "/") {
68
- if (lastSlash !== index - 1 && dots !== 1) if (dots === 2) {
69
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
70
- if (res.length > 2) {
71
- let lastSlashIndex = res.lastIndexOf("/");
72
- lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
73
- continue;
74
- }
75
- if (res.length > 0) {
76
- res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
77
- continue;
78
- }
79
- }
80
- allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
81
- } else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
82
- lastSlash = index, dots = 0;
83
- } else char === "." && dots !== -1 ? ++dots : dots = -1;
84
- }
85
- return res;
86
- }
87
- const isAbsolute = function(p) {
88
- return _IS_ABSOLUTE_RE.test(p);
89
- }, dirname = function(p) {
90
- let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
91
- return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
92
- }, textDecoder = new TextDecoder(), decodeBase64 = (() => {
93
- let capturedBuffer = typeof Buffer == "function" ? Buffer : void 0;
94
- 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)));
95
- })(), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
96
- function encodePathChars(filepath) {
97
- 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;
98
- }
99
- const posixDirname = dirname, posixResolve = resolve;
100
- function posixPathToFileHref(posixPath) {
101
- let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
102
- return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.includes("?") && (resolved = resolved.replace(questionRegex, "%3F")), resolved.includes("#") && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
103
- }
104
- function toWindowsPath(path) {
105
- return path.replace(/\//g, "\\");
106
- }
107
- //#endregion
108
43
  //#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
109
44
  var comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = /* @__PURE__ */ new Uint8Array(64), charToInt = /* @__PURE__ */ new Uint8Array(128);
110
45
  for (let i = 0; i < chars.length; i++) {
@@ -227,6 +162,73 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
227
162
  return found ? index = (bias === -1 ? upperBound : lowerBound)(segments, column, index) : bias === -1 && index++, index === -1 || index === segments.length ? -1 : index;
228
163
  }
229
164
  //#endregion
165
+ //#region ../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
166
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
167
+ function normalizeWindowsPath(input = "") {
168
+ return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
169
+ }
170
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
171
+ function cwd() {
172
+ return typeof process < "u" && typeof process.cwd == "function" ? process.cwd().replace(/\\/g, "/") : "/";
173
+ }
174
+ const resolve = function(...arguments_) {
175
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
176
+ let resolvedPath = "", resolvedAbsolute = !1;
177
+ for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
178
+ let path = index >= 0 ? arguments_[index] : cwd();
179
+ !path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));
180
+ }
181
+ return resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : ".";
182
+ };
183
+ function normalizeString(path, allowAboveRoot) {
184
+ let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
185
+ for (let index = 0; index <= path.length; ++index) {
186
+ if (index < path.length) char = path[index];
187
+ else if (char === "/") break;
188
+ else char = "/";
189
+ if (char === "/") {
190
+ if (lastSlash !== index - 1 && dots !== 1) {
191
+ if (dots === 2) {
192
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
193
+ if (res.length > 2) {
194
+ let lastSlashIndex = res.lastIndexOf("/");
195
+ lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
196
+ continue;
197
+ }
198
+ if (res.length > 0) {
199
+ res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
200
+ continue;
201
+ }
202
+ }
203
+ allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
204
+ } else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
205
+ }
206
+ lastSlash = index, dots = 0;
207
+ } else char === "." && dots !== -1 ? ++dots : dots = -1;
208
+ }
209
+ return res;
210
+ }
211
+ const isAbsolute = function(p) {
212
+ return _IS_ABSOLUTE_RE.test(p);
213
+ }, dirname = function(p) {
214
+ let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
215
+ return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
216
+ }, textDecoder = new TextDecoder(), decodeBase64 = (() => {
217
+ let capturedBuffer = typeof Buffer == "function" ? Buffer : void 0;
218
+ 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)));
219
+ })(), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
220
+ function encodePathChars(filepath) {
221
+ 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;
222
+ }
223
+ const posixDirname = dirname, posixResolve = resolve;
224
+ function posixPathToFileHref(posixPath) {
225
+ let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
226
+ return (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== "/" && (resolved += "/"), resolved = encodePathChars(resolved), resolved.includes("?") && (resolved = resolved.replace(questionRegex, "%3F")), resolved.includes("#") && (resolved = resolved.replace(hashRegex, "%23")), new URL(`file://${resolved}`).href;
227
+ }
228
+ function toWindowsPath(path) {
229
+ return path.replace(/\//g, "\\");
230
+ }
231
+ //#endregion
230
232
  //#region src/module-runner/sourcemap/decoder.ts
231
233
  var DecodedMap = class {
232
234
  map;
@@ -354,6 +356,12 @@ function normalizeModuleId(file) {
354
356
  return prefixedBuiltins.has(file) ? file : slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/").replace(/^file:\/+/, isWindows ? "" : "/");
355
357
  }
356
358
  //#endregion
359
+ //#region src/shared/builtin.ts
360
+ function createIsBuiltin(builtins) {
361
+ let plainBuiltinsSet = new Set(builtins.filter((builtin) => typeof builtin == "string")), regexBuiltins = builtins.filter((builtin) => typeof builtin != "string");
362
+ return (id) => plainBuiltinsSet.has(id) || regexBuiltins.some((regexp) => regexp.test(id));
363
+ }
364
+ //#endregion
357
365
  //#region src/shared/hmr.ts
358
366
  var HMRContext = class {
359
367
  hmrClient;
@@ -520,28 +528,6 @@ var HMRContext = class {
520
528
  }
521
529
  };
522
530
  //#endregion
523
- //#region src/shared/ssrTransform.ts
524
- /**
525
- * Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
526
- * Top-level imports and dynamic imports work slightly differently in Node.js.
527
- * This function normalizes the differences so it matches prod behaviour.
528
- */
529
- function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
530
- if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
531
- let missingBindings = metadata.importedNames.filter((s) => !(s in mod));
532
- if (missingBindings.length) {
533
- let lastBinding = missingBindings[missingBindings.length - 1];
534
- throw SyntaxError(moduleType === "module" ? `[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'` : `\
535
- [vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
536
- CommonJS modules can always be imported via the default export, for example using:
537
-
538
- import pkg from '${rawId}';
539
- const {${missingBindings.join(", ")}} = pkg;
540
- `);
541
- }
542
- }
543
- }
544
- //#endregion
545
531
  //#region ../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/non-secure/index.js
546
532
  let nanoid = (size = 21) => {
547
533
  let id = "", i = size | 0;
@@ -652,14 +638,18 @@ const createInvokeableTransport = (transport) => {
652
638
  } } : {},
653
639
  async send(data) {
654
640
  if (invokeableTransport.send) {
655
- if (!isConnected) if (connectingPromise) await connectingPromise;
656
- else throw new SendBeforeConnectError("send was called before connect");
641
+ if (!isConnected) {
642
+ if (connectingPromise) await connectingPromise;
643
+ else throw new SendBeforeConnectError("send was called before connect");
644
+ }
657
645
  await invokeableTransport.send(data);
658
646
  }
659
647
  },
660
648
  async invoke(name, data) {
661
- if (!isConnected) if (connectingPromise) await connectingPromise;
662
- else throw new SendBeforeConnectError("invoke was called before connect");
649
+ if (!isConnected) {
650
+ if (connectingPromise) await connectingPromise;
651
+ else throw new SendBeforeConnectError("invoke was called before connect");
652
+ }
663
653
  return invokeableTransport.invoke(name, data);
664
654
  }
665
655
  };
@@ -709,19 +699,118 @@ const createWebSocketModuleRunnerTransport = (options) => {
709
699
  };
710
700
  };
711
701
  //#endregion
712
- //#region src/shared/builtin.ts
713
- function createIsBuiltin(builtins) {
714
- let plainBuiltinsSet = new Set(builtins.filter((builtin) => typeof builtin == "string")), regexBuiltins = builtins.filter((builtin) => typeof builtin != "string");
715
- return (id) => plainBuiltinsSet.has(id) || regexBuiltins.some((regexp) => regexp.test(id));
702
+ //#region src/shared/ssrTransform.ts
703
+ /**
704
+ * Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
705
+ * Top-level imports and dynamic imports work slightly differently in Node.js.
706
+ * This function normalizes the differences so it matches prod behaviour.
707
+ */
708
+ function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
709
+ if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
710
+ let missingBindings = metadata.importedNames.filter((s) => !(s in mod));
711
+ if (missingBindings.length) {
712
+ let lastBinding = missingBindings[missingBindings.length - 1];
713
+ throw SyntaxError(moduleType === "module" ? `[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'` : `\
714
+ [vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
715
+ CommonJS modules can always be imported via the default export, for example using:
716
+
717
+ import pkg from '${rawId}';
718
+ const {${missingBindings.join(", ")}} = pkg;
719
+ `);
720
+ }
721
+ }
716
722
  }
717
723
  //#endregion
718
724
  //#region src/module-runner/constants.ts
719
- const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrExportNameKey = "__vite_ssr_exportName__", ssrImportMetaKey = "__vite_ssr_import_meta__", noop = () => {}, silentConsole = {
720
- debug: noop,
721
- error: noop
722
- }, hmrLogger = {
723
- debug: (...msg) => console.log("[vite]", ...msg),
724
- error: (error) => console.log("[vite]", error)
725
+ const ssrModuleExportsKey = "__vite_ssr_exports__", ssrImportKey = "__vite_ssr_import__", ssrDynamicImportKey = "__vite_ssr_dynamic_import__", ssrExportAllKey = "__vite_ssr_exportAll__", ssrExportNameKey = "__vite_ssr_exportName__", ssrImportMetaKey = "__vite_ssr_import_meta__", customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/", customizationHooksModule = `
726
+
727
+ export async function resolve(specifier, context, nextResolve) {
728
+ if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
729
+ const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
730
+ const [parsedSpecifier, parsedImporter] = JSON.parse(data)
731
+ specifier = parsedSpecifier
732
+ context.parentURL = parsedImporter
733
+ }
734
+ return nextResolve(specifier, context)
735
+ }
736
+
737
+ `;
738
+ function customizationHookResolve(specifier, context, nextResolve) {
739
+ if (specifier.startsWith(customizationHookNamespace)) {
740
+ let data = specifier.slice(42), [parsedSpecifier, parsedImporter] = JSON.parse(data);
741
+ specifier = parsedSpecifier, context.parentURL = parsedImporter;
742
+ }
743
+ return nextResolve(specifier, context);
744
+ }
745
+ let isHookRegistered = !1;
746
+ function createImportMetaResolver() {
747
+ if (isHookRegistered) return importMetaResolveWithCustomHook;
748
+ let module;
749
+ try {
750
+ module = typeof process < "u" ? process.getBuiltinModule("node:module").Module : void 0;
751
+ } catch {
752
+ return;
753
+ }
754
+ if (module) {
755
+ if (module.registerHooks) return module.registerHooks({ resolve: customizationHookResolve }), isHookRegistered = !0, importMetaResolveWithCustomHook;
756
+ if (module.register) {
757
+ try {
758
+ let hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
759
+ module.register(hookModuleContent);
760
+ } catch (e) {
761
+ if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
762
+ throw e;
763
+ }
764
+ return isHookRegistered = !0, importMetaResolveWithCustomHook;
765
+ }
766
+ }
767
+ }
768
+ function importMetaResolveWithCustomHook(specifier, importer) {
769
+ return import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
770
+ }
771
+ //#endregion
772
+ //#region src/module-runner/createImportMeta.ts
773
+ const envProxy = new Proxy({}, { get(_, p) {
774
+ throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
775
+ } });
776
+ function createDefaultImportMeta(modulePath) {
777
+ let href = posixPathToFileHref(modulePath), filename = modulePath, dirname = posixDirname(modulePath);
778
+ return {
779
+ filename: isWindows ? toWindowsPath(filename) : filename,
780
+ dirname: isWindows ? toWindowsPath(dirname) : dirname,
781
+ url: href,
782
+ env: envProxy,
783
+ resolve(_id, _parent) {
784
+ throw Error("[module runner] \"import.meta.resolve\" is not supported.");
785
+ },
786
+ glob() {
787
+ throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
788
+ }
789
+ };
790
+ }
791
+ /**
792
+ * Create import.meta object for Node.js.
793
+ */
794
+ function createNodeImportMeta(modulePath) {
795
+ let defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url, importMetaResolver = createImportMetaResolver();
796
+ return {
797
+ ...defaultMeta,
798
+ main: !1,
799
+ resolve(id, parent) {
800
+ return (importMetaResolver ?? defaultMeta.resolve)(id, parent ?? href);
801
+ }
802
+ };
803
+ }
804
+ //#endregion
805
+ //#region src/module-runner/esmEvaluator.ts
806
+ var ESModulesEvaluator = class {
807
+ startOffset = getAsyncFunctionDeclarationPaddingLineCount() + 1;
808
+ async runInlinedModule(context, code) {
809
+ await new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";\n" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
810
+ }
811
+ runExternalModule(filepath) {
812
+ return import(filepath);
813
+ }
725
814
  };
726
815
  //#endregion
727
816
  //#region src/shared/hmrHandler.ts
@@ -760,7 +849,7 @@ function createHMRHandlerForRunner(runner) {
760
849
  break;
761
850
  case "update":
762
851
  await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(payload.updates.map(async (update) => {
763
- if (update.type === "js-update") return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);
852
+ if (update.type === "js-update") return hmrClient.queueUpdate(update);
764
853
  hmrClient.logger.error("css hmr is not supported in runner mode.");
765
854
  })), await hmrClient.notifyListeners("vite:afterUpdate", payload);
766
855
  break;
@@ -821,8 +910,14 @@ function findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {
821
910
  return entrypoints;
822
911
  }
823
912
  //#endregion
824
- //#region src/module-runner/sourcemap/interceptor.ts
825
- const sourceMapCache = {}, fileContentsCache = {}, evaluatedModulesCache = /* @__PURE__ */ new Set(), retrieveFileHandlers = /* @__PURE__ */ new Set(), retrieveSourceMapHandlers = /* @__PURE__ */ new Set(), createExecHandlers = (handlers) => ((...args) => {
913
+ //#region src/module-runner/hmrLogger.ts
914
+ const noop = () => {}, silentConsole = {
915
+ debug: noop,
916
+ error: noop
917
+ }, hmrLogger = {
918
+ debug: (...msg) => console.log("[vite]", ...msg),
919
+ error: (error) => console.log("[vite]", error)
920
+ }, sourceMapCache = {}, fileContentsCache = {}, evaluatedModulesCache = /* @__PURE__ */ new Set(), retrieveFileHandlers = /* @__PURE__ */ new Set(), retrieveSourceMapHandlers = /* @__PURE__ */ new Set(), createExecHandlers = (handlers) => ((...args) => {
826
921
  for (let handler of handlers) {
827
922
  let result = handler(...args);
828
923
  if (result) return result;
@@ -1008,98 +1103,6 @@ function enableSourceMapSupport(runner) {
1008
1103
  return interceptStackTrace(runner, typeof runner.options.sourcemapInterceptor == "object" ? runner.options.sourcemapInterceptor : void 0);
1009
1104
  }
1010
1105
  //#endregion
1011
- //#region src/module-runner/esmEvaluator.ts
1012
- var ESModulesEvaluator = class {
1013
- startOffset = getAsyncFunctionDeclarationPaddingLineCount() + 1;
1014
- async runInlinedModule(context, code) {
1015
- await new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, "\"use strict\";\n" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);
1016
- }
1017
- runExternalModule(filepath) {
1018
- return import(filepath);
1019
- }
1020
- };
1021
- //#endregion
1022
- //#region src/module-runner/importMetaResolver.ts
1023
- const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/", customizationHooksModule = `
1024
-
1025
- export async function resolve(specifier, context, nextResolve) {
1026
- if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
1027
- const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
1028
- const [parsedSpecifier, parsedImporter] = JSON.parse(data)
1029
- specifier = parsedSpecifier
1030
- context.parentURL = parsedImporter
1031
- }
1032
- return nextResolve(specifier, context)
1033
- }
1034
-
1035
- `;
1036
- function customizationHookResolve(specifier, context, nextResolve) {
1037
- if (specifier.startsWith(customizationHookNamespace)) {
1038
- let data = specifier.slice(42), [parsedSpecifier, parsedImporter] = JSON.parse(data);
1039
- specifier = parsedSpecifier, context.parentURL = parsedImporter;
1040
- }
1041
- return nextResolve(specifier, context);
1042
- }
1043
- let isHookRegistered = !1;
1044
- function createImportMetaResolver() {
1045
- if (isHookRegistered) return importMetaResolveWithCustomHook;
1046
- let module;
1047
- try {
1048
- module = typeof process < "u" ? process.getBuiltinModule("node:module").Module : void 0;
1049
- } catch {
1050
- return;
1051
- }
1052
- if (module) {
1053
- if (module.registerHooks) return module.registerHooks({ resolve: customizationHookResolve }), isHookRegistered = !0, importMetaResolveWithCustomHook;
1054
- if (module.register) {
1055
- try {
1056
- let hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
1057
- module.register(hookModuleContent);
1058
- } catch (e) {
1059
- if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
1060
- throw e;
1061
- }
1062
- return isHookRegistered = !0, importMetaResolveWithCustomHook;
1063
- }
1064
- }
1065
- }
1066
- function importMetaResolveWithCustomHook(specifier, importer) {
1067
- return import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
1068
- }
1069
- //#endregion
1070
- //#region src/module-runner/createImportMeta.ts
1071
- const envProxy = new Proxy({}, { get(_, p) {
1072
- throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
1073
- } });
1074
- function createDefaultImportMeta(modulePath) {
1075
- let href = posixPathToFileHref(modulePath), filename = modulePath, dirname = posixDirname(modulePath);
1076
- return {
1077
- filename: isWindows ? toWindowsPath(filename) : filename,
1078
- dirname: isWindows ? toWindowsPath(dirname) : dirname,
1079
- url: href,
1080
- env: envProxy,
1081
- resolve(_id, _parent) {
1082
- throw Error("[module runner] \"import.meta.resolve\" is not supported.");
1083
- },
1084
- glob() {
1085
- throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
1086
- }
1087
- };
1088
- }
1089
- /**
1090
- * Create import.meta object for Node.js.
1091
- */
1092
- function createNodeImportMeta(modulePath) {
1093
- let defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url, importMetaResolver = createImportMetaResolver();
1094
- return {
1095
- ...defaultMeta,
1096
- main: !1,
1097
- resolve(id, parent) {
1098
- return (importMetaResolver ?? defaultMeta.resolve)(id, parent ?? href);
1099
- }
1100
- };
1101
- }
1102
- //#endregion
1103
1106
  //#region src/module-runner/runner.ts
1104
1107
  var ModuleRunner = class {
1105
1108
  options;
@@ -1156,9 +1159,8 @@ var ModuleRunner = class {
1156
1159
  if (visited.has(mod.id)) return !1;
1157
1160
  visited.add(mod.id);
1158
1161
  for (let importedModuleId of mod.imports) {
1159
- if (callstack.includes(importedModuleId)) return !0;
1160
1162
  let importedModule = this.evaluatedModules.getModuleById(importedModuleId);
1161
- if (importedModule?.promise && !importedModule.evaluated && this.isCircularRequest(importedModule, callstack, visited)) return !0;
1163
+ if (!(!importedModule?.promise || importedModule.evaluated) && (callstack.includes(importedModuleId) || this.isCircularRequest(importedModule, callstack, visited))) return !0;
1162
1164
  }
1163
1165
  return !1;
1164
1166
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.2.1",
3
+ "version": "8.3.0-beta.0",
4
4
  "description": "Native-ESM powered web dev build tool",
5
5
  "keywords": [
6
6
  "build-tool",
@@ -57,9 +57,9 @@
57
57
  },
58
58
  "dependencies": {
59
59
  "lightningcss": "^1.33.0",
60
- "picomatch": "^4.0.5",
61
- "postcss": "^8.5.25",
62
- "rolldown": "~1.2.1",
60
+ "picomatch": "^4.0.7",
61
+ "postcss": "^8.5.26",
62
+ "rolldown": "~1.2.6",
63
63
  "tinyglobby": "^0.2.17"
64
64
  },
65
65
  "devDependencies": {
@@ -72,12 +72,12 @@
72
72
  "@rollup/pluginutils": "^5.4.0",
73
73
  "@types/escape-html": "^1.0.4",
74
74
  "@types/pnpapi": "^0.0.5",
75
- "@vercel/detect-agent": "^1.2.3",
76
- "@vitejs/devtools": "^0.4.10",
77
- "@vitest/utils": "4.1.10",
75
+ "@vercel/detect-agent": "^1.2.5",
76
+ "@vitejs/devtools": "^0.5.1",
77
+ "@vitest/utils": "4.1.11",
78
78
  "@voidzero-dev/vite-task-client": "^0.2.0",
79
79
  "artichokie": "^0.4.4",
80
- "baseline-browser-mapping": "^2.11.10",
80
+ "baseline-browser-mapping": "^2.11.20",
81
81
  "cac": "^7.0.0",
82
82
  "chokidar": "^3.6.0",
83
83
  "connect": "^3.7.0",
@@ -85,8 +85,8 @@
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.1",
89
- "esbuild": "^0.28.1",
88
+ "es-module-lexer": "^2.3.2",
89
+ "esbuild": "^0.28.2",
90
90
  "escape-html": "^1.0.3",
91
91
  "estree-walker": "^3.0.3",
92
92
  "etag": "^1.8.1",
@@ -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": "^1.1.0",
97
+ "magic-string": "^1.2.3",
98
98
  "mlly": "^1.8.2",
99
99
  "mrmime": "^2.0.1",
100
100
  "nanoid": "^5.1.16",
@@ -104,25 +104,25 @@
104
104
  "pathe": "^2.0.3",
105
105
  "periscopic": "^4.0.3",
106
106
  "picocolors": "^1.1.1",
107
- "postcss-import": "^16.1.1",
107
+ "postcss-import": "^16.2.0",
108
108
  "postcss-load-config": "^6.0.1",
109
109
  "postcss-modules": "^9.0.1",
110
110
  "premove": "^4.0.0",
111
111
  "resolve.exports": "^2.0.3",
112
- "rolldown-plugin-dts": "^0.28.0",
112
+ "rolldown-plugin-dts": "^0.28.3",
113
113
  "rollup": "^4.59.0",
114
114
  "rollup-plugin-license": "^3.7.1",
115
- "sass": "^1.102.0",
116
- "sass-embedded": "^1.100.0",
115
+ "sass": "^1.103.1",
116
+ "sass-embedded": "^1.103.1",
117
117
  "sirv": "^3.0.2",
118
118
  "strip-literal": "^4.0.0",
119
- "terser": "^5.49.0",
119
+ "terser": "^5.51.2",
120
120
  "ufo": "^1.6.4",
121
- "ws": "^8.21.1"
121
+ "ws": "^8.21.3"
122
122
  },
123
123
  "peerDependencies": {
124
124
  "@types/node": "^20.19.0 || >=22.12.0",
125
- "@vitejs/devtools": "^0.4.0",
125
+ "@vitejs/devtools": "^0.4.0 || ^0.5.0",
126
126
  "esbuild": "^0.27.0 || ^0.28.0",
127
127
  "jiti": ">=1.21.0",
128
128
  "less": "^4.0.0",