vite 8.2.2 → 8.3.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.
@@ -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;
@@ -40,73 +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) {
69
- if (dots === 2) {
70
- if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
71
- if (res.length > 2) {
72
- let lastSlashIndex = res.lastIndexOf("/");
73
- lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
74
- continue;
75
- }
76
- if (res.length > 0) {
77
- res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
78
- continue;
79
- }
80
- }
81
- allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
82
- } else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
83
- }
84
- lastSlash = index, dots = 0;
85
- } else char === "." && dots !== -1 ? ++dots : dots = -1;
86
- }
87
- return res;
88
- }
89
- const isAbsolute = function(p) {
90
- return _IS_ABSOLUTE_RE.test(p);
91
- }, dirname = function(p) {
92
- let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
93
- return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
94
- }, textDecoder = new TextDecoder(), decodeBase64 = (() => {
95
- let capturedBuffer = typeof Buffer == "function" ? Buffer : void 0;
96
- 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)));
97
- })(), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
98
- function encodePathChars(filepath) {
99
- 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;
100
- }
101
- const posixDirname = dirname, posixResolve = resolve;
102
- function posixPathToFileHref(posixPath) {
103
- let resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);
104
- 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;
105
- }
106
- function toWindowsPath(path) {
107
- return path.replace(/\//g, "\\");
108
- }
109
- //#endregion
110
43
  //#region ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
111
44
  var comma = 44, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar = /* @__PURE__ */ new Uint8Array(64), charToInt = /* @__PURE__ */ new Uint8Array(128);
112
45
  for (let i = 0; i < chars.length; i++) {
@@ -229,6 +162,73 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
229
162
  return found ? index = (bias === -1 ? upperBound : lowerBound)(segments, column, index) : bias === -1 && index++, index === -1 || index === segments.length ? -1 : index;
230
163
  }
231
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.at(-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
232
232
  //#region src/module-runner/sourcemap/decoder.ts
233
233
  var DecodedMap = class {
234
234
  map;
@@ -356,6 +356,12 @@ function normalizeModuleId(file) {
356
356
  return prefixedBuiltins.has(file) ? file : slash(file).replace(/^\/@fs\//, isWindows ? "" : "/").replace(/^node:/, "").replace(/^\/+/, "/").replace(/^file:\/+/, isWindows ? "" : "/");
357
357
  }
358
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
359
365
  //#region src/shared/hmr.ts
360
366
  var HMRContext = class {
361
367
  hmrClient;
@@ -522,28 +528,6 @@ var HMRContext = class {
522
528
  }
523
529
  };
524
530
  //#endregion
525
- //#region src/shared/ssrTransform.ts
526
- /**
527
- * Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
528
- * Top-level imports and dynamic imports work slightly differently in Node.js.
529
- * This function normalizes the differences so it matches prod behaviour.
530
- */
531
- function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
532
- if (!metadata?.isDynamicImport && metadata?.importedNames?.length) {
533
- let missingBindings = metadata.importedNames.filter((s) => !(s in mod));
534
- if (missingBindings.length) {
535
- let lastBinding = missingBindings[missingBindings.length - 1];
536
- throw SyntaxError(moduleType === "module" ? `[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'` : `\
537
- [vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
538
- CommonJS modules can always be imported via the default export, for example using:
539
-
540
- import pkg from '${rawId}';
541
- const {${missingBindings.join(", ")}} = pkg;
542
- `);
543
- }
544
- }
545
- }
546
- //#endregion
547
531
  //#region ../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/non-secure/index.js
548
532
  let nanoid = (size = 21) => {
549
533
  let id = "", i = size | 0;
@@ -715,19 +699,118 @@ const createWebSocketModuleRunnerTransport = (options) => {
715
699
  };
716
700
  };
717
701
  //#endregion
718
- //#region src/shared/builtin.ts
719
- function createIsBuiltin(builtins) {
720
- let plainBuiltinsSet = new Set(builtins.filter((builtin) => typeof builtin == "string")), regexBuiltins = builtins.filter((builtin) => typeof builtin != "string");
721
- 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.at(-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
+ }
722
722
  }
723
723
  //#endregion
724
724
  //#region src/module-runner/constants.ts
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__", noop = () => {}, silentConsole = {
726
- debug: noop,
727
- error: noop
728
- }, hmrLogger = {
729
- debug: (...msg) => console.log("[vite]", ...msg),
730
- 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
+ }
731
814
  };
732
815
  //#endregion
733
816
  //#region src/shared/hmrHandler.ts
@@ -766,7 +849,7 @@ function createHMRHandlerForRunner(runner) {
766
849
  break;
767
850
  case "update":
768
851
  await hmrClient.notifyListeners("vite:beforeUpdate", payload), await Promise.all(payload.updates.map(async (update) => {
769
- 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);
770
853
  hmrClient.logger.error("css hmr is not supported in runner mode.");
771
854
  })), await hmrClient.notifyListeners("vite:afterUpdate", payload);
772
855
  break;
@@ -827,8 +910,14 @@ function findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {
827
910
  return entrypoints;
828
911
  }
829
912
  //#endregion
830
- //#region src/module-runner/sourcemap/interceptor.ts
831
- 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) => {
832
921
  for (let handler of handlers) {
833
922
  let result = handler(...args);
834
923
  if (result) return result;
@@ -1014,98 +1103,6 @@ function enableSourceMapSupport(runner) {
1014
1103
  return interceptStackTrace(runner, typeof runner.options.sourcemapInterceptor == "object" ? runner.options.sourcemapInterceptor : void 0);
1015
1104
  }
1016
1105
  //#endregion
1017
- //#region src/module-runner/esmEvaluator.ts
1018
- var ESModulesEvaluator = class {
1019
- startOffset = getAsyncFunctionDeclarationPaddingLineCount() + 1;
1020
- async runInlinedModule(context, code) {
1021
- 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]);
1022
- }
1023
- runExternalModule(filepath) {
1024
- return import(filepath);
1025
- }
1026
- };
1027
- //#endregion
1028
- //#region src/module-runner/importMetaResolver.ts
1029
- const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/", customizationHooksModule = `
1030
-
1031
- export async function resolve(specifier, context, nextResolve) {
1032
- if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
1033
- const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
1034
- const [parsedSpecifier, parsedImporter] = JSON.parse(data)
1035
- specifier = parsedSpecifier
1036
- context.parentURL = parsedImporter
1037
- }
1038
- return nextResolve(specifier, context)
1039
- }
1040
-
1041
- `;
1042
- function customizationHookResolve(specifier, context, nextResolve) {
1043
- if (specifier.startsWith(customizationHookNamespace)) {
1044
- let data = specifier.slice(42), [parsedSpecifier, parsedImporter] = JSON.parse(data);
1045
- specifier = parsedSpecifier, context.parentURL = parsedImporter;
1046
- }
1047
- return nextResolve(specifier, context);
1048
- }
1049
- let isHookRegistered = !1;
1050
- function createImportMetaResolver() {
1051
- if (isHookRegistered) return importMetaResolveWithCustomHook;
1052
- let module;
1053
- try {
1054
- module = typeof process < "u" ? process.getBuiltinModule("node:module").Module : void 0;
1055
- } catch {
1056
- return;
1057
- }
1058
- if (module) {
1059
- if (module.registerHooks) return module.registerHooks({ resolve: customizationHookResolve }), isHookRegistered = !0, importMetaResolveWithCustomHook;
1060
- if (module.register) {
1061
- try {
1062
- let hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;
1063
- module.register(hookModuleContent);
1064
- } catch (e) {
1065
- if ("code" in e && e.code === "ERR_NETWORK_IMPORT_DISALLOWED") return;
1066
- throw e;
1067
- }
1068
- return isHookRegistered = !0, importMetaResolveWithCustomHook;
1069
- }
1070
- }
1071
- }
1072
- function importMetaResolveWithCustomHook(specifier, importer) {
1073
- return import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);
1074
- }
1075
- //#endregion
1076
- //#region src/module-runner/createImportMeta.ts
1077
- const envProxy = new Proxy({}, { get(_, p) {
1078
- throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
1079
- } });
1080
- function createDefaultImportMeta(modulePath) {
1081
- let href = posixPathToFileHref(modulePath), filename = modulePath, dirname = posixDirname(modulePath);
1082
- return {
1083
- filename: isWindows ? toWindowsPath(filename) : filename,
1084
- dirname: isWindows ? toWindowsPath(dirname) : dirname,
1085
- url: href,
1086
- env: envProxy,
1087
- resolve(_id, _parent) {
1088
- throw Error("[module runner] \"import.meta.resolve\" is not supported.");
1089
- },
1090
- glob() {
1091
- throw Error("[module runner] \"import.meta.glob\" is statically replaced during file transformation. Make sure to reference it by the full name.");
1092
- }
1093
- };
1094
- }
1095
- /**
1096
- * Create import.meta object for Node.js.
1097
- */
1098
- function createNodeImportMeta(modulePath) {
1099
- let defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url, importMetaResolver = createImportMetaResolver();
1100
- return {
1101
- ...defaultMeta,
1102
- main: !1,
1103
- resolve(id, parent) {
1104
- return (importMetaResolver ?? defaultMeta.resolve)(id, parent ?? href);
1105
- }
1106
- };
1107
- }
1108
- //#endregion
1109
1106
  //#region src/module-runner/runner.ts
1110
1107
  var ModuleRunner = class {
1111
1108
  options;
@@ -1168,7 +1165,7 @@ var ModuleRunner = class {
1168
1165
  return !1;
1169
1166
  }
1170
1167
  async cachedRequest(url, mod, callstack = [], metadata) {
1171
- let meta = mod.meta, moduleId = meta.id, importee = callstack[callstack.length - 1];
1168
+ let meta = mod.meta, moduleId = meta.id, importee = callstack.at(-1);
1172
1169
  if (importee && mod.importers.add(importee), mod.evaluated && mod.promise) return this.processImport(await mod.promise, meta, metadata);
1173
1170
  if (mod.promise) return mod.exports && (callstack.includes(moduleId) || this.isCircularRequest(mod, callstack)) ? this.processImport(mod.exports, meta, metadata) : this.processImport(await mod.promise, meta, metadata);
1174
1171
  let debugTimer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.2.2",
3
+ "version": "8.3.0-beta.1",
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.26",
62
- "rolldown": "~1.2.4",
60
+ "picomatch": "^4.0.7",
61
+ "postcss": "^8.5.28",
62
+ "rolldown": "~1.2.6",
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.5",
76
- "@vitejs/devtools": "^0.4.12",
77
- "@vitest/utils": "4.1.10",
76
+ "@vitejs/devtools": "^0.7.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.14",
80
+ "baseline-browser-mapping": "^2.11.21",
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.1",
88
+ "es-module-lexer": "^2.3.2",
89
89
  "esbuild": "^0.28.2",
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": "^1.2.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",
@@ -109,20 +109,20 @@
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.2",
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.102.0",
115
+ "sass": "^1.104.0",
116
+ "sass-embedded": "^1.104.0",
117
117
  "sirv": "^3.0.2",
118
118
  "strip-literal": "^4.0.0",
119
- "terser": "^5.50.0",
119
+ "terser": "^5.51.2",
120
120
  "ufo": "^1.6.4",
121
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 || ^0.5.0",
125
+ "@vitejs/devtools": "^0.7.1",
126
126
  "esbuild": "^0.27.0 || ^0.28.0",
127
127
  "jiti": ">=1.21.0",
128
128
  "less": "^4.0.0",
@@ -39,8 +39,10 @@ export interface WebSocketConnectionPayload {
39
39
  }
40
40
 
41
41
  export interface InvalidatePayload {
42
+ /** Module URL of the invalidated module */
42
43
  path: string
43
44
  message: string | undefined
45
+ /** Module URL of the first module that invalidated the update */
44
46
  firstInvalidatedBy: string
45
47
  }
46
48
 
@@ -38,7 +38,9 @@ export interface BundledDevUpdatePayload {
38
38
 
39
39
  export interface Update {
40
40
  type: 'js-update' | 'css-update'
41
+ /** Module URL of the HMR boundary */
41
42
  path: string
43
+ /** Module URL of the accepted module */
42
44
  acceptedPath: string
43
45
  timestamp: number
44
46
  /** @internal */
@@ -1,11 +1,11 @@
1
1
  /* eslint-disable @typescript-eslint/ban-ts-comment */
2
2
 
3
+ // @ts-ignore `less` may not be installed
4
+ import type Less from 'less'
3
5
  // @ts-ignore `sass` may not be installed
4
6
  import type DartSass from 'sass'
5
7
  // @ts-ignore `sass-embedded` may not be installed
6
8
  import type SassEmbedded from 'sass-embedded'
7
- // @ts-ignore `less` may not be installed
8
- import type Less from 'less'
9
9
  // @ts-ignore `stylus` may not be installed
10
10
  import type Stylus from 'stylus'
11
11
 
@@ -0,0 +1,9 @@
1
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+
3
+ // @ts-ignore `@vitejs/devtools` may not be installed
4
+ import type * as DevToolsConfig from '@vitejs/devtools/config'
5
+
6
+ /* eslint-enable @typescript-eslint/ban-ts-comment */
7
+
8
+ export type DevToolsConfig = DevToolsConfig.DevToolsConfig
9
+ export type ResolvedDevToolsConfig = DevToolsConfig.ResolvedDevToolsConfig