vite 8.0.2 → 8.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  /// <reference path="./types/importMeta.d.ts" />
2
2
 
3
+ // virtual modules
4
+ declare module 'vite/modulepreload-polyfill' {}
5
+
3
6
  // CSS modules
4
7
  type CSSModuleClasses = { readonly [key: string]: string }
5
8
 
@@ -1,5 +1,5 @@
1
1
  import "@vite/env";
2
- //#region \0@oxc-project+runtime@0.121.0/helpers/typeof.js
2
+ //#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
3
3
  function _typeof(o) {
4
4
  "@babel/helpers - typeof";
5
5
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -9,7 +9,7 @@ function _typeof(o) {
9
9
  }, _typeof(o);
10
10
  }
11
11
  //#endregion
12
- //#region \0@oxc-project+runtime@0.121.0/helpers/toPrimitive.js
12
+ //#region \0@oxc-project+runtime@0.122.0/helpers/toPrimitive.js
13
13
  function toPrimitive(t, r) {
14
14
  if ("object" != _typeof(t) || !t) return t;
15
15
  var e = t[Symbol.toPrimitive];
@@ -21,13 +21,13 @@ function toPrimitive(t, r) {
21
21
  return ("string" === r ? String : Number)(t);
22
22
  }
23
23
  //#endregion
24
- //#region \0@oxc-project+runtime@0.121.0/helpers/toPropertyKey.js
24
+ //#region \0@oxc-project+runtime@0.122.0/helpers/toPropertyKey.js
25
25
  function toPropertyKey(t) {
26
26
  var i = toPrimitive(t, "string");
27
27
  return "symbol" == _typeof(i) ? i : i + "";
28
28
  }
29
29
  //#endregion
30
- //#region \0@oxc-project+runtime@0.121.0/helpers/defineProperty.js
30
+ //#region \0@oxc-project+runtime@0.122.0/helpers/defineProperty.js
31
31
  function _defineProperty(e, r, t) {
32
32
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
33
33
  value: t,
@@ -4555,6 +4555,7 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4555
4555
  return new _processor["default"](processor);
4556
4556
  };
4557
4557
  Object.assign(parser, selectors);
4558
+ delete parser.__esModule;
4558
4559
  exports["default"] = parser;
4559
4560
  module.exports = exports.default;
4560
4561
  }));
@@ -8,34 +8,34 @@ interface FetchFunctionOptions {
8
8
  type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
9
9
  interface CachedFetchResult {
10
10
  /**
11
- * If module cached in the runner, we can just confirm
12
- * it wasn't invalidated on the server side.
11
+ * If the module is cached in the runner, this confirms
12
+ * it was not invalidated on the server side.
13
13
  */
14
14
  cache: true;
15
15
  }
16
16
  interface ExternalFetchResult {
17
17
  /**
18
- * The path to the externalized module starting with file://,
19
- * by default this will be imported via a dynamic "import"
20
- * instead of being transformed by vite and loaded with vite runner
18
+ * The path to the externalized module starting with file://.
19
+ * By default this will be imported via a dynamic "import"
20
+ * instead of being transformed by Vite and loaded with the Vite runner.
21
21
  */
22
22
  externalize: string;
23
23
  /**
24
- * Type of the module. Will be used to determine if import statement is correct.
25
- * For example, if Vite needs to throw an error if variable is not actually exported
24
+ * Type of the module. Used to determine if the import statement is correct.
25
+ * For example, if Vite needs to throw an error if a variable is not actually exported.
26
26
  */
27
27
  type: "module" | "commonjs" | "builtin" | "network";
28
28
  }
29
29
  interface ViteFetchResult {
30
30
  /**
31
- * Code that will be evaluated by vite runner
32
- * by default this will be wrapped in an async function
31
+ * Code that will be evaluated by the Vite runner.
32
+ * By default this will be wrapped in an async function.
33
33
  */
34
34
  code: string;
35
35
  /**
36
36
  * File path of the module on disk.
37
- * This will be resolved as import.meta.url/filename
38
- * Will be equal to `null` for virtual modules
37
+ * This will be resolved as import.meta.url/filename.
38
+ * Will be `null` for virtual modules.
39
39
  */
40
40
  file: string | null;
41
41
  /**
@@ -2,7 +2,7 @@ import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __
2
2
  import { A as OPTIMIZABLE_ENTRY_RE, C as ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, D as JS_TYPES_RE, E as FS_PREFIX, F as defaultAllowedOrigins, I as loopbackHosts, L as wildcardHosts, M as SPECIAL_QUERY_RE, N as VERSION, O as KNOWN_ASSET_TYPES, P as VITE_PACKAGE_DIR, R as require_picocolors, S as ENV_PUBLIC_PATH, T as ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET, _ as DEFAULT_SERVER_CONDITIONS, a as CLIENT_ENTRY, b as DEV_PROD_CONDITION, c as DEFAULT_ASSETS_INLINE_LIMIT, d as DEFAULT_CLIENT_MAIN_FIELDS, f as DEFAULT_CONFIG_FILES, g as DEFAULT_PREVIEW_PORT, h as DEFAULT_EXTERNAL_CONDITIONS, i as CLIENT_DIR, j as ROLLUP_HOOKS, k as METADATA_FILENAME, l as DEFAULT_ASSETS_RE, m as DEFAULT_EXTENSIONS, n as createLogger, o as CLIENT_PUBLIC_PATH, p as DEFAULT_DEV_PORT, r as printServerUrls, s as CSS_LANGS_RE, t as LogLevels, u as DEFAULT_CLIENT_CONDITIONS, v as DEFAULT_SERVER_MAIN_FIELDS, w as ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, x as ENV_ENTRY, y as DEP_VERSION_RE } from "./logger.js";
3
3
  import { builtinModules, createRequire } from "node:module";
4
4
  import { parseAst, parseAstAsync } from "rolldown/parseAst";
5
- import { esmExternalRequirePlugin } from "rolldown/plugins";
5
+ import { esmExternalRequirePlugin, esmExternalRequirePlugin as esmExternalRequirePlugin$1 } from "rolldown/plugins";
6
6
  import { TsconfigCache, Visitor, minify, minifySync, parse, parseSync, transformSync } from "rolldown/utils";
7
7
  import * as fs$1 from "node:fs";
8
8
  import fs, { existsSync, readFileSync } from "node:fs";
@@ -2252,7 +2252,7 @@ function hasBothRollupOptionsAndRolldownOptions(options) {
2252
2252
  options.worker,
2253
2253
  options.optimizeDeps,
2254
2254
  options.ssr?.optimizeDeps
2255
- ]) if (opt != null && opt.rollupOptions != null && opt.rolldownOptions != null) return true;
2255
+ ]) if (opt != null && opt.rollupOptions != null && opt.rolldownOptions != null && opt.rollupOptions !== opt.rolldownOptions) return true;
2256
2256
  return false;
2257
2257
  }
2258
2258
  function mergeConfigRecursively(defaults, overrides, rootPath) {
@@ -2521,6 +2521,25 @@ function monotonicDateNow() {
2521
2521
  lastDateNow++;
2522
2522
  return lastDateNow;
2523
2523
  }
2524
+ function formatAndTruncateFileList(files) {
2525
+ const MAX_LOG_LENGTH = 500;
2526
+ let log = "";
2527
+ let truncated = false;
2528
+ for (let i = 0; i < files.length; i++) {
2529
+ const file = files[i];
2530
+ if (log === "") log = file;
2531
+ else if (log.length + 2 + file.length < MAX_LOG_LENGTH) log += ", " + file;
2532
+ else {
2533
+ log += ` and ${files.length - i} more`;
2534
+ truncated = true;
2535
+ break;
2536
+ }
2537
+ }
2538
+ return {
2539
+ formatted: log,
2540
+ truncated
2541
+ };
2542
+ }
2524
2543
  //#endregion
2525
2544
  //#region src/node/plugin.ts
2526
2545
  async function resolveEnvironmentPlugins(environment) {
@@ -2795,7 +2814,7 @@ async function reloadOnTsconfigChange(server, changedFile) {
2795
2814
  }
2796
2815
  }
2797
2816
  //#endregion
2798
- //#region ../../node_modules/.pnpm/artichokie@0.4.2/node_modules/artichokie/dist/index.js
2817
+ //#region ../../node_modules/.pnpm/artichokie@0.4.3/node_modules/artichokie/dist/index.js
2799
2818
  const AsyncFunction = async function() {}.constructor;
2800
2819
  const codeToDataUrl = (code) => `data:application/javascript,${encodeURIComponent(code + "\n//# sourceURL=[worker-eval(artichokie)]")}`;
2801
2820
  const viteSsrDynamicImport = "__vite_ssr_dynamic_import__";
@@ -3024,10 +3043,10 @@ function genWorkerCode(fn, isModule, waitTimeout, parentFunctions) {
3024
3043
  else return resArgs.result;
3025
3044
  };
3026
3045
  asyncPort.on("message", (args) => {
3027
- const id$1 = args.id;
3028
- if (resolvers.has(id$1)) {
3029
- const { resolve, reject } = resolvers.get(id$1);
3030
- resolvers.delete(id$1);
3046
+ const id = args.id;
3047
+ if (resolvers.has(id)) {
3048
+ const { resolve, reject } = resolvers.get(id);
3049
+ resolvers.delete(id);
3031
3050
  if ("result" in args) resolve(args.result);
3032
3051
  else reject(args.error);
3033
3052
  }
@@ -11328,6 +11347,7 @@ function isRefIdentifier(id, parent, parentStack) {
11328
11347
  if (isNodeInPattern(parent) && parent.value === id) return false;
11329
11348
  if (parent.type === "ArrayPattern" && !isInDestructuringAssignment(parent, parentStack)) return false;
11330
11349
  if (parent.type === "MemberExpression" && parent.property === id && !parent.computed) return false;
11350
+ if (parent.type === "MetaProperty") return false;
11331
11351
  if (parent.type === "ExportSpecifier" || parent.type === "ExportAllDeclaration") return false;
11332
11352
  if (id.name === "arguments") return false;
11333
11353
  return true;
@@ -15989,7 +16009,7 @@ require_subprotocol();
15989
16009
  require_websocket();
15990
16010
  var import_websocket_server = /* @__PURE__ */ __toESM(require_websocket_server(), 1);
15991
16011
  //#endregion
15992
- //#region ../../node_modules/.pnpm/host-validation-middleware@0.1.2/node_modules/host-validation-middleware/dist/index.js
16012
+ //#region ../../node_modules/.pnpm/host-validation-middleware@0.1.4/node_modules/host-validation-middleware/dist/index.js
15993
16013
  /**
15994
16014
  * This function assumes that the input is not malformed.
15995
16015
  * This is because we only care about browser requests.
@@ -16051,8 +16071,8 @@ function isHostAllowed(hostHeader, allowedHosts) {
16051
16071
  * If the host header is not in the allowed hosts list, a 403 Forbidden response
16052
16072
  * is sent.
16053
16073
  */
16054
- function hostValidationMiddleware$2(options) {
16055
- return async function hostValidationMiddleware$1(req, res, next) {
16074
+ function hostValidationMiddleware$1(options) {
16075
+ return async function hostValidationMiddleware(req, res, next) {
16056
16076
  const hostHeader = req.headers.host;
16057
16077
  if (!isHostAllowed(hostHeader, options.allowedHosts)) {
16058
16078
  const hostname = hostHeader?.replace(/:\d+$/, "") ?? "";
@@ -22126,6 +22146,40 @@ function handleParseError(parserError, html, filePath, warnings) {
22126
22146
  warnings[parseError.code] ??= `Unable to parse HTML; ${parseError.message}\n at ${parseError.loc.file}:${parseError.loc.line}:${parseError.loc.column}\n` + parseError.frame;
22127
22147
  }
22128
22148
  /**
22149
+ * Collects CSS files for a chunk by traversing its imports depth-first,
22150
+ * using a cache to avoid re-analyzing chunks while still returning the
22151
+ * correct files when the same chunk is reached via different entry points.
22152
+ */
22153
+ function getCssFilesForChunk(chunk, bundle, analyzedImportedCssFiles, seenChunks = /* @__PURE__ */ new Set(), seenCss = /* @__PURE__ */ new Set()) {
22154
+ if (seenChunks.has(chunk.fileName)) return [];
22155
+ seenChunks.add(chunk.fileName);
22156
+ if (analyzedImportedCssFiles.has(chunk)) {
22157
+ const additionals = analyzedImportedCssFiles.get(chunk).filter((file) => !seenCss.has(file));
22158
+ additionals.forEach((file) => seenCss.add(file));
22159
+ return additionals;
22160
+ }
22161
+ const allFiles = [];
22162
+ const filteredFiles = [];
22163
+ chunk.imports.forEach((file) => {
22164
+ const importee = bundle[file];
22165
+ if (importee?.type === "chunk") {
22166
+ const importeeCss = getCssFilesForChunk(importee, bundle, analyzedImportedCssFiles, seenChunks, seenCss);
22167
+ filteredFiles.push(...importeeCss);
22168
+ if (analyzedImportedCssFiles.has(importee)) allFiles.push(...analyzedImportedCssFiles.get(importee));
22169
+ else allFiles.push(...importeeCss);
22170
+ }
22171
+ });
22172
+ chunk.viteMetadata.importedCss.forEach((file) => {
22173
+ allFiles.push(file);
22174
+ if (!seenCss.has(file)) {
22175
+ seenCss.add(file);
22176
+ filteredFiles.push(file);
22177
+ }
22178
+ });
22179
+ analyzedImportedCssFiles.set(chunk, unique(allFiles));
22180
+ return filteredFiles;
22181
+ }
22182
+ /**
22129
22183
  * Compiles index.html into an entry js module
22130
22184
  */
22131
22185
  function buildHtmlPlugin(config) {
@@ -22343,29 +22397,7 @@ function buildHtmlPlugin(config) {
22343
22397
  href: toOutputPath(file)
22344
22398
  }
22345
22399
  });
22346
- const getCssFilesForChunk = (chunk, seenChunks = /* @__PURE__ */ new Set(), seenCss = /* @__PURE__ */ new Set()) => {
22347
- if (seenChunks.has(chunk.fileName)) return [];
22348
- seenChunks.add(chunk.fileName);
22349
- if (analyzedImportedCssFiles.has(chunk)) {
22350
- const additionals = analyzedImportedCssFiles.get(chunk).filter((file) => !seenCss.has(file));
22351
- additionals.forEach((file) => seenCss.add(file));
22352
- return additionals;
22353
- }
22354
- const files = [];
22355
- chunk.imports.forEach((file) => {
22356
- const importee = bundle[file];
22357
- if (importee?.type === "chunk") files.push(...getCssFilesForChunk(importee, seenChunks, seenCss));
22358
- });
22359
- analyzedImportedCssFiles.set(chunk, files);
22360
- chunk.viteMetadata.importedCss.forEach((file) => {
22361
- if (!seenCss.has(file)) {
22362
- seenCss.add(file);
22363
- files.push(file);
22364
- }
22365
- });
22366
- return files;
22367
- };
22368
- const getCssTagsForChunk = (chunk, toOutputPath) => getCssFilesForChunk(chunk).map((file) => toStyleSheetLinkTag(file, toOutputPath));
22400
+ const getCssTagsForChunk = (chunk, toOutputPath) => getCssFilesForChunk(chunk, bundle, analyzedImportedCssFiles).map((file) => toStyleSheetLinkTag(file, toOutputPath));
22369
22401
  for (const [normalizedId, html] of processedHtml(this)) {
22370
22402
  const relativeUrlPath = normalizePath(path.relative(config.root, normalizedId));
22371
22403
  const assetsBase = getBaseInHTML(relativeUrlPath, config);
@@ -22931,7 +22963,7 @@ async function getHmrImplementation(config) {
22931
22963
  //#endregion
22932
22964
  //#region src/node/ssr/fetchModule.ts
22933
22965
  /**
22934
- * Fetch module information for Vite runner.
22966
+ * Fetch module information for Vite module runner.
22935
22967
  * @experimental
22936
22968
  */
22937
22969
  async function fetchModule(environment, url, importer, options = {}) {
@@ -23094,6 +23126,9 @@ function createDepsOptimizer(environment) {
23094
23126
  (async () => {
23095
23127
  try {
23096
23128
  debug$9?.(import_picocolors.default.green(`scanning for dependencies...`));
23129
+ const scanTimer = setTimeout(() => {
23130
+ logger.info("[optimizer] scanning dependencies...", { timestamp: true });
23131
+ }, 1e3);
23097
23132
  let deps;
23098
23133
  try {
23099
23134
  discover = discoverProjectDependencies(devToScanEnvironment(environment));
@@ -23102,6 +23137,8 @@ function createDepsOptimizer(environment) {
23102
23137
  } catch (e) {
23103
23138
  environment.logger.error(import_picocolors.default.red("(!) Failed to run dependency scan. Skipping dependency pre-bundling. " + e.stack));
23104
23139
  return;
23140
+ } finally {
23141
+ clearTimeout(scanTimer);
23105
23142
  }
23106
23143
  const manuallyIncluded = Object.keys(manuallyIncludedDepsInfo);
23107
23144
  discoveredDepsWhileScanning.push(...Object.keys(metadata.discovered).filter((dep) => !deps[dep] && !manuallyIncluded.includes(dep)));
@@ -24414,6 +24451,12 @@ var DevEnvironment = class extends BaseEnvironment {
24414
24451
  await this.depsOptimizer?.init();
24415
24452
  warmupFiles(server, this);
24416
24453
  }
24454
+ /**
24455
+ * Called by the module runner to retrieve information about the specified
24456
+ * module. Internally calls `transformRequest` and wraps the result in the
24457
+ * format that the module runner understands.
24458
+ * This method is not meant to be called manually.
24459
+ */
24417
24460
  fetchModule(id, importer, options) {
24418
24461
  return fetchModule(this, id, importer, {
24419
24462
  ...this._remoteRunnerOptions,
@@ -24742,7 +24785,10 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
24742
24785
  type: "update",
24743
24786
  updates
24744
24787
  });
24745
- this.logger.info(import_picocolors.default.green(`hmr update `) + import_picocolors.default.dim([...new Set(updates.map((u) => u.path))].join(", ")), {
24788
+ const filePaths = [...new Set(updates.map((u) => u.path))];
24789
+ const { formatted, truncated } = formatAndTruncateFileList(filePaths);
24790
+ if (truncated) debugHmr?.(`hmr update ${filePaths.join(", ")}`);
24791
+ this.logger.info(import_picocolors.default.green(`hmr update `) + import_picocolors.default.dim(formatted), {
24746
24792
  clear: !invalidateInformation,
24747
24793
  timestamp: true
24748
24794
  });
@@ -25792,7 +25838,7 @@ function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions
25792
25838
  return list;
25793
25839
  }
25794
25840
  function hostValidationMiddleware(allowedHosts, isPreview) {
25795
- return hostValidationMiddleware$2({
25841
+ return hostValidationMiddleware$1({
25796
25842
  allowedHosts: Object.freeze([...allowedHosts]),
25797
25843
  generateErrorMessage(hostname) {
25798
25844
  const hostnameWithQuotes = JSON.stringify(hostname);
@@ -26668,7 +26714,10 @@ function updateModules(environment, file, modules, timestamp, firstInvalidatedBy
26668
26714
  debugHmr?.(import_picocolors.default.yellow(`no update happened `) + import_picocolors.default.dim(file));
26669
26715
  return;
26670
26716
  }
26671
- environment.logger.info(import_picocolors.default.green(`hmr update `) + import_picocolors.default.dim([...new Set(updates.map((u) => u.path))].join(", ")), {
26717
+ const filePaths = [...new Set(updates.map((u) => u.path))];
26718
+ const { formatted, truncated } = formatAndTruncateFileList(filePaths);
26719
+ if (truncated) debugHmr?.(`hmr update ${filePaths.join(", ")}`);
26720
+ environment.logger.info(import_picocolors.default.green(`hmr update `) + import_picocolors.default.dim(formatted), {
26672
26721
  clear: !firstInvalidatedBy,
26673
26722
  timestamp: true
26674
26723
  });
@@ -29043,7 +29092,7 @@ function createFilterForTransform(idFilter, codeFilter, moduleTypeFilter, cwd) {
29043
29092
  };
29044
29093
  }
29045
29094
  //#endregion
29046
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/helpers.js
29095
+ //#region ../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/helpers.js
29047
29096
  function notNullish(v) {
29048
29097
  return v != null;
29049
29098
  }
@@ -29051,7 +29100,7 @@ function isPrimitive(value) {
29051
29100
  return value === null || typeof value !== "function" && typeof value !== "object";
29052
29101
  }
29053
29102
  //#endregion
29054
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
29103
+ //#region ../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
29055
29104
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
29056
29105
  function normalizeWindowsPath(input = "") {
29057
29106
  if (!input) return input;
@@ -29130,7 +29179,7 @@ const isAbsolute$2 = function(p) {
29130
29179
  return _IS_ABSOLUTE_RE.test(p);
29131
29180
  };
29132
29181
  //#endregion
29133
- //#region ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/source-map.js
29182
+ //#region ../../node_modules/.pnpm/@vitest+utils@4.1.2/node_modules/@vitest/utils/dist/source-map.js
29134
29183
  var comma = ",".charCodeAt(0);
29135
29184
  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
29136
29185
  var intToChar = new Uint8Array(64);
@@ -30621,13 +30670,20 @@ const svelteScriptModuleRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+)
30621
30670
  const svelteModuleRE = /\smodule\b/i;
30622
30671
  function rolldownScanPlugin(environment, depImports, missing, entries) {
30623
30672
  const seen = /* @__PURE__ */ new Map();
30624
- async function resolveId(id, importer) {
30625
- return environment.pluginContainer.resolveId(id, importer && normalizePath(importer), { scan: true });
30673
+ async function resolveId(id, importer, options) {
30674
+ return environment.pluginContainer.resolveId(id, importer && normalizePath(importer), {
30675
+ scan: true,
30676
+ ...options
30677
+ });
30626
30678
  }
30627
- const resolve = async (id, importer) => {
30628
- const key = id + (importer && path.dirname(importer));
30679
+ const resolve = async (id, importer, options) => {
30680
+ const key = JSON.stringify([
30681
+ id,
30682
+ importer && path.dirname(importer),
30683
+ options
30684
+ ]);
30629
30685
  if (seen.has(key)) return seen.get(key);
30630
- const res = (await resolveId(id, importer))?.id;
30686
+ const res = (await resolveId(id, importer, options))?.id;
30631
30687
  seen.set(key, res);
30632
30688
  return res;
30633
30689
  };
@@ -31332,9 +31388,15 @@ function runOptimizeDeps(environment, depsInfo) {
31332
31388
  cancel: cleanUp
31333
31389
  };
31334
31390
  const start = performance$1.now();
31391
+ const bundleTimer = setTimeout(() => {
31392
+ environment.logger.info("[optimizer] bundling dependencies...", { timestamp: true });
31393
+ }, 1e3);
31335
31394
  const preparedRun = prepareRolldownOptimizerRun(environment, depsInfo, processingCacheDir, optimizerContext);
31336
31395
  const runResult = preparedRun.then(({ context, idToExports }) => {
31337
- if (!context || optimizerContext.cancelled) return cancelledResult;
31396
+ if (!context || optimizerContext.cancelled) {
31397
+ clearTimeout(bundleTimer);
31398
+ return cancelledResult;
31399
+ }
31338
31400
  return context.build().then((result) => {
31339
31401
  const depForEntryFileName = {};
31340
31402
  for (const dep of Object.values(depsInfo)) {
@@ -31365,9 +31427,11 @@ function runOptimizeDeps(environment, depsInfo) {
31365
31427
  });
31366
31428
  }
31367
31429
  }
31430
+ clearTimeout(bundleTimer);
31368
31431
  debug$2?.(`Dependencies bundled in ${(performance$1.now() - start).toFixed(2)}ms`);
31369
31432
  return successfulResult;
31370
31433
  }).catch((e) => {
31434
+ clearTimeout(bundleTimer);
31371
31435
  if (e.errors && e.message.includes("The build was canceled")) return cancelledResult;
31372
31436
  e.message = import_picocolors.default.red("Error during dependency optimization:\n\n") + e.message;
31373
31437
  throw e;
@@ -31995,6 +32059,7 @@ function resolveSubpathImports(id, importer, options) {
31995
32059
  importsPath = path.relative(basedir, path.join(pkgData.dir, importsPath));
31996
32060
  if (!relativePrefixRE.test(importsPath)) importsPath = `./${importsPath}`;
31997
32061
  }
32062
+ if (importsPath == null) return;
31998
32063
  return importsPath + postfix;
31999
32064
  }
32000
32065
  function ensureVersionQuery(resolved, id, options, depsOptimizer) {
@@ -32628,7 +32693,7 @@ const _buildEnvironmentOptionsDefaults = Object.freeze({
32628
32693
  watch: null
32629
32694
  });
32630
32695
  const buildEnvironmentOptionsDefaults = _buildEnvironmentOptionsDefaults;
32631
- function resolveBuildEnvironmentOptions(raw, logger, consumer, isBundledDev) {
32696
+ function resolveBuildEnvironmentOptions(raw, logger, consumer, isBundledDev, isSsrTargetWebworkerEnvironment) {
32632
32697
  const deprecatedPolyfillModulePreload = raw.polyfillModulePreload;
32633
32698
  const { polyfillModulePreload, ...rest } = raw;
32634
32699
  raw = rest;
@@ -32646,7 +32711,7 @@ function resolveBuildEnvironmentOptions(raw, logger, consumer, isBundledDev) {
32646
32711
  }, raw);
32647
32712
  setupRollupOptionCompat(merged, "build");
32648
32713
  merged.rolldownOptions = {
32649
- platform: consumer === "server" ? "node" : "browser",
32714
+ platform: consumer === "client" || isSsrTargetWebworkerEnvironment ? "browser" : "node",
32650
32715
  ...merged.rolldownOptions
32651
32716
  };
32652
32717
  if (merged.target === "baseline-widely-available") merged.target = ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET;
@@ -32740,6 +32805,7 @@ function resolveRolldownOptions(environment, chunkMetadataMap) {
32740
32805
  }
32741
32806
  };
32742
32807
  const isSsrTargetWebworkerEnvironment = environment.name === "ssr" && environment.getTopLevelConfig().ssr?.target === "webworker";
32808
+ if (isSsrTargetWebworkerEnvironment) plugins.push(esmExternalRequirePlugin());
32743
32809
  const buildOutputOptions = (output = {}) => {
32744
32810
  if (output.output) logger.warn("You've set \"rollupOptions.output.output\" in your config. This is deprecated and will override all Vite.js default output options. Please use \"rollupOptions.output\" instead.");
32745
32811
  if (output.file) throw new Error("Vite does not support \"rollupOptions.output.file\". Please use \"rollupOptions.output.dir\" and \"rollupOptions.output.entryFileNames\" instead.");
@@ -33860,7 +33926,7 @@ function resolveEnvironmentOptions(options, alias, preserveSymlinks, forceOptimi
33860
33926
  consumer,
33861
33927
  optimizeDeps: resolveDepOptimizationOptions(options.optimizeDeps, resolve.preserveSymlinks, forceOptimizeDeps, consumer, logger),
33862
33928
  dev: resolveDevEnvironmentOptions(options.dev, environmentName, consumer, preTransformRequests),
33863
- build: resolveBuildEnvironmentOptions(options.build ?? {}, logger, consumer, isBundledDev),
33929
+ build: resolveBuildEnvironmentOptions(options.build ?? {}, logger, consumer, isBundledDev, isSsrTargetWebworkerEnvironment),
33864
33930
  plugins: void 0,
33865
33931
  optimizeDepsPluginNames: void 0
33866
33932
  };
@@ -34656,4 +34722,4 @@ const parseAst$1 = parseAst;
34656
34722
  const parseAstAsync$1 = parseAstAsync;
34657
34723
  const esbuildVersion = "0.25.0";
34658
34724
  //#endregion
34659
- export { depsFromOptimizedDepInfo as $, builderOptionsDefaults as A, searchForWorkspaceRoot as At, resolveBuilderOptions as B, transformWithEsbuild as Bt, resolvePreviewOptions as C, send as Ct, ChunkMetadataMap as D, fetchModule as Dt, BuildEnvironment as E, isFileServingAllowed as Et, injectEnvironmentToHooks as F, createServerModuleRunnerTransport as Ft, toOutputFilePathInHtml as G, mergeConfig as Gt, resolveRolldownOptions as H, createFilter$1 as Ht, onRollupLog as I, buildErrorMessage as It, addManuallyIncludedOptimizeDeps as J, rollupVersion as Jt, toOutputFilePathInJS as K, normalizePath as Kt, resolveBuildEnvironmentOptions as L, loadEnv as Lt, createBuilder as M, perEnvironmentState as Mt, createToImportMetaURLBasedRelativeRuntime as N, ssrTransform as Nt, build as O, formatPostcssSourceMap as Ot, enhanceRollupError as P, createServerModuleRunner as Pt, createIsOptimizedDepUrl as Q, resolveBuildOutputs as R, resolveEnvPrefix as Rt, preview as S, serverConfigDefaults as St, isRunnableDevEnvironment as T, isFileLoadingAllowed as Tt, resolveUserExternal as U, isCSSRequest as Ut, resolveLibFilename as V, perEnvironmentPlugin as Vt, toOutputFilePathInCss as W, mergeAlias as Wt, cleanupDepsCacheStaleDirs as X, addOptimizedDepInfo as Y, withFilter as Yt, createIsOptimizedDepFile as Z, resolveConfig as _, createServer$2 as _t, minifySync as a, initDepsOptimizerMetadata as at, sortUserPlugins as b, resolveServerOptions as bt, parseAstAsync$1 as c, optimizeDeps as ct, isFetchableDevEnvironment as d, optimizedDepInfoFromId as dt, depsLogString as et, defineConfig as f, optimizedDepNeedsInterop as ft, resolveBaseUrl as g, _createServer as gt, loadConfigFromFile as h, createServerHotChannel as ht, minify as i, getOptimizedDepPath as it, clearLine as j, createIdResolver as jt, buildEnvironmentOptionsDefaults as k, preprocessCSS as kt, parseSync as l, optimizeExplicitEnvironmentDeps as lt, isResolvedConfig as m, toDiscoveredDependencies as mt, esbuildVersion as n, extractExportsData as nt, parse as o, isDepOptimizationDisabled as ot, getDefaultEnvironmentOptions as p, runOptimizeDeps as pt, toOutputFilePathWithoutRuntime as q, rolldownVersion as qt, esmExternalRequirePlugin as r, getDepsCacheDir as rt, parseAst$1 as s, loadCachedDepOptimizationMetadata as st, Visitor as t, discoverProjectDependencies as tt, createFetchableDevEnvironment as u, optimizedDepInfoFromFile as ut, resolveDevEnvironmentOptions as v, createServerCloseFn as vt, createRunnableDevEnvironment as w, DevEnvironment as wt, runnerImport as x, restartServerWithUrls as xt, resolveDevToolsConfig as y, resolveForwardConsoleOptions as yt, resolveBuildPlugins as z, transformWithOxc as zt };
34725
+ export { depsFromOptimizedDepInfo as $, builderOptionsDefaults as A, searchForWorkspaceRoot as At, resolveBuilderOptions as B, transformWithEsbuild as Bt, resolvePreviewOptions as C, send as Ct, ChunkMetadataMap as D, fetchModule as Dt, BuildEnvironment as E, isFileServingAllowed as Et, injectEnvironmentToHooks as F, createServerModuleRunnerTransport as Ft, toOutputFilePathInHtml as G, mergeConfig as Gt, resolveRolldownOptions as H, createFilter$1 as Ht, onRollupLog as I, buildErrorMessage as It, addManuallyIncludedOptimizeDeps as J, rollupVersion as Jt, toOutputFilePathInJS as K, normalizePath as Kt, resolveBuildEnvironmentOptions as L, loadEnv as Lt, createBuilder as M, perEnvironmentState as Mt, createToImportMetaURLBasedRelativeRuntime as N, ssrTransform as Nt, build as O, formatPostcssSourceMap as Ot, enhanceRollupError as P, createServerModuleRunner as Pt, createIsOptimizedDepUrl as Q, resolveBuildOutputs as R, resolveEnvPrefix as Rt, preview as S, serverConfigDefaults as St, isRunnableDevEnvironment as T, isFileLoadingAllowed as Tt, resolveUserExternal as U, isCSSRequest as Ut, resolveLibFilename as V, perEnvironmentPlugin as Vt, toOutputFilePathInCss as W, mergeAlias as Wt, cleanupDepsCacheStaleDirs as X, addOptimizedDepInfo as Y, withFilter as Yt, createIsOptimizedDepFile as Z, resolveConfig as _, createServer$2 as _t, minifySync as a, initDepsOptimizerMetadata as at, sortUserPlugins as b, resolveServerOptions as bt, parseAstAsync$1 as c, optimizeDeps as ct, isFetchableDevEnvironment as d, optimizedDepInfoFromId as dt, depsLogString as et, defineConfig as f, optimizedDepNeedsInterop as ft, resolveBaseUrl as g, _createServer as gt, loadConfigFromFile as h, createServerHotChannel as ht, minify as i, getOptimizedDepPath as it, clearLine as j, createIdResolver as jt, buildEnvironmentOptionsDefaults as k, preprocessCSS as kt, parseSync as l, optimizeExplicitEnvironmentDeps as lt, isResolvedConfig as m, toDiscoveredDependencies as mt, esbuildVersion as n, extractExportsData as nt, parse as o, isDepOptimizationDisabled as ot, getDefaultEnvironmentOptions as p, runOptimizeDeps as pt, toOutputFilePathWithoutRuntime as q, rolldownVersion as qt, esmExternalRequirePlugin$1 as r, getDepsCacheDir as rt, parseAst$1 as s, loadCachedDepOptimizationMetadata as st, Visitor as t, discoverProjectDependencies as tt, createFetchableDevEnvironment as u, optimizedDepInfoFromFile as ut, resolveDevEnvironmentOptions as v, createServerCloseFn as vt, createRunnableDevEnvironment as w, DevEnvironment as wt, runnerImport as x, restartServerWithUrls as xt, resolveDevToolsConfig as y, resolveForwardConsoleOptions as yt, resolveBuildPlugins as z, transformWithOxc as zt };
@@ -31,7 +31,7 @@ import { GeneralImportGlobOptions, ImportGlobFunction, ImportGlobOptions, KnownA
31
31
 
32
32
  //#region \0rolldown/runtime.js
33
33
  //#endregion
34
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.1.5_typescript@5.9.3_vite@packages+vite_vue@3.5.30_typescript@5.9.3_/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
34
+ //#region ../../node_modules/.pnpm/@vitejs+devtools@0.1.13_typescript@6.0.2_vite@packages+vite/node_modules/@vitejs/devtools/dist/cli-commands.d.ts
35
35
  //#region src/node/cli-commands.d.ts
36
36
  interface StartOptions {
37
37
  root?: string;
@@ -41,7 +41,7 @@ interface StartOptions {
41
41
  open?: boolean;
42
42
  }
43
43
  //#endregion
44
- //#region ../../node_modules/.pnpm/@vitejs+devtools@0.1.5_typescript@5.9.3_vite@packages+vite_vue@3.5.30_typescript@5.9.3_/node_modules/@vitejs/devtools/dist/config.d.ts
44
+ //#region ../../node_modules/.pnpm/@vitejs+devtools@0.1.13_typescript@6.0.2_vite@packages+vite/node_modules/@vitejs/devtools/dist/config.d.ts
45
45
  //#region src/node/config.d.ts
46
46
  interface DevToolsConfig extends Partial<StartOptions> {
47
47
  enabled: boolean;
@@ -1608,6 +1608,12 @@ declare class DevEnvironment extends BaseEnvironment {
1608
1608
  * - new instance `listen`
1609
1609
  */
1610
1610
  listen(server: ViteDevServer): Promise<void>;
1611
+ /**
1612
+ * Called by the module runner to retrieve information about the specified
1613
+ * module. Internally calls `transformRequest` and wraps the result in the
1614
+ * format that the module runner understands.
1615
+ * This method is not meant to be called manually.
1616
+ */
1611
1617
  fetchModule(id: string, importer?: string, options?: FetchFunctionOptions): Promise<moduleRunner_FetchResult>;
1612
1618
  reloadModule(module: EnvironmentModuleNode): Promise<void>;
1613
1619
  transformRequest(url: string, options?: TransformOptionsInternal): Promise<TransformResult | null>;
@@ -3727,7 +3733,7 @@ interface FetchModuleOptions {
3727
3733
  startOffset?: number;
3728
3734
  }
3729
3735
  /**
3730
- * Fetch module information for Vite runner.
3736
+ * Fetch module information for Vite module runner.
3731
3737
  * @experimental
3732
3738
  */
3733
3739
  declare function fetchModule(environment: DevEnvironment, url: string, importer?: string, options?: FetchModuleOptions): Promise<moduleRunner_FetchResult>;
@@ -88,7 +88,7 @@ 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
- }, decodeBase64 = typeof atob < "u" ? atob : (str) => Buffer.from(str, "base64").toString("utf-8"), percentRegEx = /%/g, backslashRegEx = /\\/g, newlineRegEx = /\n/g, carriageReturnRegEx = /\r/g, tabRegEx = /\t/g, questionRegex = /\?/g, hashRegex = /#/g;
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;
92
92
  function encodePathChars(filepath) {
93
93
  return filepath.indexOf("%") !== -1 && (filepath = filepath.replace(percentRegEx, "%25")), !isWindows && filepath.indexOf("\\") !== -1 && (filepath = filepath.replace(backslashRegEx, "%5C")), filepath.indexOf("\n") !== -1 && (filepath = filepath.replace(newlineRegEx, "%0A")), filepath.indexOf("\r") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, "%0D")), filepath.indexOf(" ") !== -1 && (filepath = filepath.replace(tabRegEx, "%09")), filepath;
94
94
  }
@@ -749,10 +749,14 @@ function createHMRHandlerForRunner(runner) {
749
749
  let { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(runner, getModulesByFile(runner, slash(triggeredBy))) : findAllEntrypoints(runner);
750
750
  if (!clearEntrypointUrls.size) break;
751
751
  hmrClient.logger.debug("program reload"), await hmrClient.notifyListeners("vite:beforeFullReload", payload), runner.evaluatedModules.clear();
752
- for (let url of clearEntrypointUrls) try {
753
- await runner.import(url);
754
- } catch (err) {
755
- err.code !== "ERR_OUTDATED_OPTIMIZED_DEP" && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
752
+ for (let url of clearEntrypointUrls) {
753
+ if (runner.isClosed()) break;
754
+ try {
755
+ await runner.import(url);
756
+ } catch (err) {
757
+ if (runner.isClosed()) break;
758
+ err.code !== "ERR_OUTDATED_OPTIMIZED_DEP" && hmrClient.logger.error(`An error happened during full reload\n${err.message}\n${err.stack}`);
759
+ }
756
760
  }
757
761
  break;
758
762
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.0.2",
3
+ "version": "8.0.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -61,9 +61,9 @@
61
61
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
62
62
  "dependencies": {
63
63
  "lightningcss": "^1.32.0",
64
- "picomatch": "^4.0.3",
64
+ "picomatch": "^4.0.4",
65
65
  "postcss": "^8.5.8",
66
- "rolldown": "1.0.0-rc.11",
66
+ "rolldown": "1.0.0-rc.12",
67
67
  "tinyglobby": "^0.2.15"
68
68
  },
69
69
  "optionalDependencies": {
@@ -80,10 +80,10 @@
80
80
  "@vercel/detect-agent": "^1.2.1",
81
81
  "@types/escape-html": "^1.0.4",
82
82
  "@types/pnpapi": "^0.0.5",
83
- "@vitest/utils": "4.1.0",
84
- "@vitejs/devtools": "^0.1.5",
85
- "artichokie": "^0.4.2",
86
- "baseline-browser-mapping": "^2.10.10",
83
+ "@vitest/utils": "4.1.2",
84
+ "@vitejs/devtools": "^0.1.13",
85
+ "artichokie": "^0.4.3",
86
+ "baseline-browser-mapping": "^2.10.15",
87
87
  "cac": "^7.0.0",
88
88
  "chokidar": "^3.6.0",
89
89
  "connect": "^3.7.0",
@@ -92,11 +92,11 @@
92
92
  "cross-spawn": "^7.0.6",
93
93
  "dotenv-expand": "^12.0.3",
94
94
  "es-module-lexer": "^1.7.0",
95
- "esbuild": "^0.27.4",
95
+ "esbuild": "^0.28.0",
96
96
  "escape-html": "^1.0.3",
97
97
  "estree-walker": "^3.0.3",
98
98
  "etag": "^1.8.1",
99
- "host-validation-middleware": "^0.1.2",
99
+ "host-validation-middleware": "^0.1.4",
100
100
  "http-proxy-3": "^1.23.2",
101
101
  "launch-editor-middleware": "^2.13.2",
102
102
  "magic-string": "^0.30.21",
@@ -114,11 +114,11 @@
114
114
  "postcss-modules": "^6.0.1",
115
115
  "premove": "^4.0.0",
116
116
  "resolve.exports": "^2.0.3",
117
- "rolldown-plugin-dts": "^0.22.5",
117
+ "rolldown-plugin-dts": "^0.23.2",
118
118
  "rollup": "^4.59.0",
119
119
  "rollup-plugin-license": "^3.7.0",
120
- "sass": "^1.98.0",
121
- "sass-embedded": "^1.98.0",
120
+ "sass": "^1.99.0",
121
+ "sass-embedded": "^1.99.0",
122
122
  "sirv": "^3.0.2",
123
123
  "strip-literal": "^3.1.0",
124
124
  "terser": "^5.46.1",
@@ -128,7 +128,7 @@
128
128
  "peerDependencies": {
129
129
  "@types/node": "^20.19.0 || >=22.12.0",
130
130
  "@vitejs/devtools": "^0.1.0",
131
- "esbuild": "^0.27.0",
131
+ "esbuild": "^0.27.0 || ^0.28.0",
132
132
  "jiti": ">=1.21.0",
133
133
  "less": "^4.0.0",
134
134
  "sass": "^1.70.0",