vite 8.0.12 → 8.0.13

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.
@@ -8,7 +8,7 @@ let nanoid = (size = 21) => {
8
8
  return id;
9
9
  };
10
10
  //#endregion
11
- //#region \0@oxc-project+runtime@0.129.0/helpers/typeof.js
11
+ //#region \0@oxc-project+runtime@0.130.0/helpers/typeof.js
12
12
  function _typeof(o) {
13
13
  "@babel/helpers - typeof";
14
14
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -18,7 +18,7 @@ function _typeof(o) {
18
18
  }, _typeof(o);
19
19
  }
20
20
  //#endregion
21
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPrimitive.js
21
+ //#region \0@oxc-project+runtime@0.130.0/helpers/toPrimitive.js
22
22
  function toPrimitive(t, r) {
23
23
  if ("object" != _typeof(t) || !t) return t;
24
24
  var e = t[Symbol.toPrimitive];
@@ -30,13 +30,13 @@ function toPrimitive(t, r) {
30
30
  return ("string" === r ? String : Number)(t);
31
31
  }
32
32
  //#endregion
33
- //#region \0@oxc-project+runtime@0.129.0/helpers/toPropertyKey.js
33
+ //#region \0@oxc-project+runtime@0.130.0/helpers/toPropertyKey.js
34
34
  function toPropertyKey(t) {
35
35
  var i = toPrimitive(t, "string");
36
36
  return "symbol" == _typeof(i) ? i : i + "";
37
37
  }
38
38
  //#endregion
39
- //#region \0@oxc-project+runtime@0.129.0/helpers/defineProperty.js
39
+ //#region \0@oxc-project+runtime@0.130.0/helpers/defineProperty.js
40
40
  function _defineProperty(e, r, t) {
41
41
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
42
42
  value: t,
@@ -1218,20 +1218,30 @@ if (isBundleMode && typeof DevRuntime !== "undefined") {
1218
1218
  }
1219
1219
  applyUpdates(_boundaries) {}
1220
1220
  }
1221
- const wrappedSocket = { send(message) {
1221
+ const clientId = nanoid();
1222
+ transport.send({
1223
+ type: "custom",
1224
+ event: "vite:module-loaded",
1225
+ data: {
1226
+ modules: [],
1227
+ clientId
1228
+ }
1229
+ });
1230
+ (_ref = globalThis).__rolldown_runtime__ ?? (_ref.__rolldown_runtime__ = new ViteDevRuntime({ send(message) {
1222
1231
  switch (message.type) {
1223
1232
  case "hmr:module-registered":
1224
1233
  transport.send({
1225
1234
  type: "custom",
1226
1235
  event: "vite:module-loaded",
1227
- data: { modules: message.modules.slice() }
1236
+ data: {
1237
+ modules: message.modules.slice(),
1238
+ clientId
1239
+ }
1228
1240
  });
1229
1241
  break;
1230
1242
  default: throw new Error(`Unknown message type: ${JSON.stringify(message)}`);
1231
1243
  }
1232
- } };
1233
- const clientId = nanoid();
1234
- (_ref = globalThis).__rolldown_runtime__ ?? (_ref.__rolldown_runtime__ = new ViteDevRuntime(wrappedSocket, clientId));
1244
+ } }, clientId));
1235
1245
  }
1236
1246
  //#endregion
1237
1247
  export { ErrorOverlay, createHotContext, injectQuery, removeStyle, updateStyle };
@@ -1,4 +1,4 @@
1
- import { i as __require, t as __commonJSMin } from "./chunk.js";
1
+ import { H as __require, z as __commonJSMin } from "./logger.js";
2
2
  import { t as require_lib } from "./lib.js";
3
3
  //#region ../../node_modules/.pnpm/postcss-modules@6.0.1_postcss@8.5.14/node_modules/postcss-modules/build/fs.js
4
4
  var require_fs = /* @__PURE__ */ __commonJSMin(((exports) => {
@@ -1,4 +1,4 @@
1
- import { t as __commonJSMin } from "./chunk.js";
1
+ import { z as __commonJSMin } from "./logger.js";
2
2
  //#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/parse.js
3
3
  var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
4
  var openParentheses = "(".charCodeAt(0);
@@ -1,8 +1,43 @@
1
- import { o as __toESM, t as __commonJSMin } from "./chunk.js";
1
+ import { createRequire } from "node:module";
2
2
  import { readFileSync } from "node:fs";
3
3
  import path, { resolve } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import readline from "node:readline";
6
+ //#region \0rolldown/runtime.js
7
+ var __create = Object.create;
8
+ var __defProp = Object.defineProperty;
9
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
+ var __getOwnPropNames = Object.getOwnPropertyNames;
11
+ var __getProtoOf = Object.getPrototypeOf;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
14
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
15
+ var __exportAll = (all, no_symbols) => {
16
+ let target = {};
17
+ for (var name in all) __defProp(target, name, {
18
+ get: all[name],
19
+ enumerable: true
20
+ });
21
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
22
+ return target;
23
+ };
24
+ var __copyProps = (to, from, except, desc) => {
25
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
26
+ key = keys[i];
27
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
28
+ get: ((k) => from[k]).bind(null, key),
29
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
30
+ });
31
+ }
32
+ return to;
33
+ };
34
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
35
+ value: mod,
36
+ enumerable: true
37
+ }) : target, mod));
38
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
39
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
40
+ //#endregion
6
41
  //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
7
42
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8
43
  let p = process || {}, argv = p.argv || [], env = p.env || {};
@@ -319,4 +354,4 @@ function printServerUrls(urls, optionsHost, info) {
319
354
  if (urls.network.length === 0 && optionsHost === void 0) info(import_picocolors.default.dim(` ${import_picocolors.default.green("➜")} ${import_picocolors.default.bold("Network")}: use `) + import_picocolors.default.bold("--host") + import_picocolors.default.dim(" to expose"));
320
355
  }
321
356
  //#endregion
322
- export { OPTIMIZABLE_ENTRY_RE as A, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR as C, JS_TYPES_RE as D, FS_PREFIX as E, defaultAllowedOrigins as F, loopbackHosts as I, wildcardHosts as L, SPECIAL_QUERY_RE as M, VERSION as N, KNOWN_ASSET_TYPES as O, VITE_PACKAGE_DIR as P, require_picocolors as R, ENV_PUBLIC_PATH as S, ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET as T, DEFAULT_SERVER_CONDITIONS as _, CLIENT_ENTRY as a, DEV_PROD_CONDITION as b, DEFAULT_ASSETS_INLINE_LIMIT as c, DEFAULT_CLIENT_MAIN_FIELDS as d, DEFAULT_CONFIG_FILES as f, DEFAULT_PREVIEW_PORT as g, DEFAULT_EXTERNAL_CONDITIONS as h, CLIENT_DIR as i, ROLLUP_HOOKS as j, METADATA_FILENAME as k, DEFAULT_ASSETS_RE as l, DEFAULT_EXTENSIONS as m, createLogger as n, CLIENT_PUBLIC_PATH as o, DEFAULT_DEV_PORT as p, printServerUrls as r, CSS_LANGS_RE as s, LogLevels as t, DEFAULT_CLIENT_CONDITIONS as u, DEFAULT_SERVER_MAIN_FIELDS as v, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR as w, ENV_ENTRY as x, DEP_VERSION_RE as y };
357
+ export { OPTIMIZABLE_ENTRY_RE as A, __esmMin as B, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR as C, JS_TYPES_RE as D, FS_PREFIX as E, defaultAllowedOrigins as F, __require as H, loopbackHosts as I, wildcardHosts as L, SPECIAL_QUERY_RE as M, VERSION as N, KNOWN_ASSET_TYPES as O, VITE_PACKAGE_DIR as P, require_picocolors as R, ENV_PUBLIC_PATH as S, ESBUILD_BASELINE_WIDELY_AVAILABLE_TARGET as T, __toCommonJS as U, __exportAll as V, __toESM as W, DEFAULT_SERVER_CONDITIONS as _, CLIENT_ENTRY as a, DEV_PROD_CONDITION as b, DEFAULT_ASSETS_INLINE_LIMIT as c, DEFAULT_CLIENT_MAIN_FIELDS as d, DEFAULT_CONFIG_FILES as f, DEFAULT_PREVIEW_PORT as g, DEFAULT_EXTERNAL_CONDITIONS as h, CLIENT_DIR as i, ROLLUP_HOOKS as j, METADATA_FILENAME as k, DEFAULT_ASSETS_RE as l, DEFAULT_EXTENSIONS as m, createLogger as n, CLIENT_PUBLIC_PATH as o, DEFAULT_DEV_PORT as p, printServerUrls as r, CSS_LANGS_RE as s, LogLevels as t, DEFAULT_CLIENT_CONDITIONS as u, DEFAULT_SERVER_MAIN_FIELDS as v, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR as w, ENV_ENTRY as x, DEP_VERSION_RE as y, __commonJSMin as z };
@@ -1,5 +1,4 @@
1
- import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "./chunk.js";
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";
1
+ import { A as OPTIMIZABLE_ENTRY_RE, B as __esmMin, C as ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, D as JS_TYPES_RE, E as FS_PREFIX, F as defaultAllowedOrigins, H as __require, 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, U as __toCommonJS, V as __exportAll, W as __toESM, _ 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, z as __commonJSMin } from "./logger.js";
3
2
  import { builtinModules, createRequire } from "node:module";
4
3
  import { parseAst, parseAstAsync } from "rolldown/parseAst";
5
4
  import { esmExternalRequirePlugin, esmExternalRequirePlugin as esmExternalRequirePlugin$1 } from "rolldown/plugins";
@@ -11,7 +10,7 @@ import fsp, { constants } from "node:fs/promises";
11
10
  import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
12
11
  import { format, formatWithOptions, inspect, parseEnv, promisify, stripVTControlCharacters } from "node:util";
13
12
  import { performance as performance$1 } from "node:perf_hooks";
14
- import crypto, { randomUUID } from "node:crypto";
13
+ import crypto from "node:crypto";
15
14
  import picomatch from "picomatch";
16
15
  import { VERSION as rolldownVersion, rolldown } from "rolldown";
17
16
  import os from "node:os";
@@ -3361,21 +3360,6 @@ function shouldSkipWarning(warning) {
3361
3360
  return false;
3362
3361
  }
3363
3362
  function oxcPlugin(config) {
3364
- if (config.isBundled) return perEnvironmentPlugin("native:transform", (environment) => {
3365
- const { jsxInject, include = /\.(m?ts|[jt]sx)$/, exclude = /\.js$/, jsxRefreshInclude, jsxRefreshExclude, ..._transformOptions } = config.oxc;
3366
- const transformOptions = _transformOptions;
3367
- transformOptions.sourcemap = environment.config.mode !== "build" || !!environment.config.build.sourcemap;
3368
- return viteTransformPlugin({
3369
- root: environment.config.root,
3370
- include,
3371
- exclude,
3372
- jsxRefreshInclude,
3373
- jsxRefreshExclude,
3374
- isServerConsumer: environment.config.consumer === "server",
3375
- jsxInject,
3376
- transformOptions
3377
- });
3378
- });
3379
3363
  const { jsxInject, include, exclude, jsxRefreshInclude, jsxRefreshExclude, ...oxcTransformOptions } = config.oxc;
3380
3364
  const filter = createFilter$1(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/);
3381
3365
  const jsxRefreshFilter = jsxRefreshInclude || jsxRefreshExclude ? createFilter$1(jsxRefreshInclude, jsxRefreshExclude) : void 0;
@@ -3400,6 +3384,24 @@ function oxcPlugin(config) {
3400
3384
  let server;
3401
3385
  return {
3402
3386
  name: "vite:oxc",
3387
+ applyToEnvironment(environment) {
3388
+ if (environment.config.isBundled) {
3389
+ const { jsxInject, include = /\.(m?ts|[jt]sx)$/, exclude = /\.js$/, jsxRefreshInclude, jsxRefreshExclude, ..._transformOptions } = environment.config.oxc;
3390
+ const transformOptions = _transformOptions;
3391
+ transformOptions.sourcemap = environment.config.mode !== "build" || !!environment.config.build.sourcemap;
3392
+ return viteTransformPlugin({
3393
+ root: environment.config.root,
3394
+ include,
3395
+ exclude,
3396
+ jsxRefreshInclude,
3397
+ jsxRefreshExclude,
3398
+ isServerConsumer: environment.config.consumer === "server",
3399
+ jsxInject,
3400
+ transformOptions
3401
+ });
3402
+ }
3403
+ return true;
3404
+ },
3403
3405
  configureServer(_server) {
3404
3406
  server = _server;
3405
3407
  },
@@ -4453,6 +4455,7 @@ function optimizedDepsPlugin() {
4453
4455
  return {
4454
4456
  name: "vite:optimized-deps",
4455
4457
  applyToEnvironment(environment) {
4458
+ if (environment.config.isBundled) return false;
4456
4459
  return !isDepOptimizationDisabled(environment.config.optimizeDeps);
4457
4460
  },
4458
4461
  resolveId(id) {
@@ -11361,6 +11364,7 @@ function isRefIdentifier(id, parent, parentStack) {
11361
11364
  if (isNodeInPattern(parent) && parent.value === id) return false;
11362
11365
  if (parent.type === "ArrayPattern" && !isInDestructuringAssignment(parent, parentStack)) return false;
11363
11366
  if (parent.type === "MemberExpression" && parent.property === id && !parent.computed) return false;
11367
+ if ((parent.type === "LabeledStatement" || parent.type === "BreakStatement" || parent.type === "ContinueStatement") && parent.label === id) return false;
11364
11368
  if (parent.type === "MetaProperty") return false;
11365
11369
  if (parent.type === "ExportSpecifier" || parent.type === "ExportAllDeclaration") return false;
11366
11370
  if (id.name === "arguments") return false;
@@ -19165,7 +19169,7 @@ async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceI
19165
19169
  source: content
19166
19170
  });
19167
19171
  if (environment.config.command === "build" && noInlineRE.test(postfix)) postfix = postfix.replace(noInlineRE, "").replace(/^&/, "?");
19168
- if (environment.config.command === "serve" && environment.config.experimental.bundledDev) url = toOutputFilePathInJSForBundledDev(environment, pluginContext.getFileName(referenceId));
19172
+ if (environment.config.command === "serve" && environment.config.isBundled) url = toOutputFilePathInJSForBundledDev(environment, pluginContext.getFileName(referenceId));
19169
19173
  else url = `__VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}`;
19170
19174
  }
19171
19175
  cache.set(id, url);
@@ -20426,8 +20430,8 @@ function cssPlugin(config) {
20426
20430
  preprocessorWorkerController = createPreprocessorWorkerController(normalizeMaxWorkers(config.css.preprocessorMaxWorkers));
20427
20431
  preprocessorWorkerControllerCache.set(config, preprocessorWorkerController);
20428
20432
  },
20429
- buildEnd() {
20430
- preprocessorWorkerController?.close();
20433
+ async buildEnd() {
20434
+ await preprocessorWorkerController?.close();
20431
20435
  },
20432
20436
  load: {
20433
20437
  filter: { id: CSS_LANGS_RE },
@@ -20498,7 +20502,9 @@ function cssPostPlugin(config) {
20498
20502
  else if (typeof assetFileNames === "string") return path.join(path.dirname(assetFileNames), cssAssetNameDir);
20499
20503
  else return path.dirname(assetFileNames({
20500
20504
  type: "asset",
20505
+ name: cssAssetName,
20501
20506
  names: [cssAssetName],
20507
+ originalFileName,
20502
20508
  originalFileNames: originalFileName ? [originalFileName] : [],
20503
20509
  source: "/* vite internal call, ignore */"
20504
20510
  }));
@@ -20555,7 +20561,7 @@ function cssPostPlugin(config) {
20555
20561
  const cssContent = await getContentWithSourcemap(css);
20556
20562
  return {
20557
20563
  code: [
20558
- config.isBundled ? `const { updateStyle: __vite__updateStyle, removeStyle: __vite__removeStyle } = import.meta.hot._internal` : `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path.posix.join(config.base, CLIENT_PUBLIC_PATH))}`,
20564
+ this.environment.config.isBundled ? `const { updateStyle: __vite__updateStyle, removeStyle: __vite__removeStyle } = import.meta.hot._internal` : `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path.posix.join(config.base, CLIENT_PUBLIC_PATH))}`,
20559
20565
  `const __vite__id = ${JSON.stringify(id)}`,
20560
20566
  `const __vite__css = ${JSON.stringify(cssContent)}`,
20561
20567
  `__vite__updateStyle(__vite__id, __vite__css)`,
@@ -20810,6 +20816,9 @@ function injectInlinedCSS(s, ctx, code, format, injectCode) {
20810
20816
  function cssAnalysisPlugin(config) {
20811
20817
  return {
20812
20818
  name: "vite:css-analysis",
20819
+ applyToEnvironment(environment) {
20820
+ return !environment.config.isBundled;
20821
+ },
20813
20822
  transform: {
20814
20823
  filter: { id: {
20815
20824
  include: CSS_LANGS_RE,
@@ -21469,8 +21478,8 @@ const scssProcessor = (maxWorkers) => {
21469
21478
  let failedSassEmbedded;
21470
21479
  const normalizedErrors = /* @__PURE__ */ new WeakSet();
21471
21480
  return {
21472
- close() {
21473
- worker?.stop();
21481
+ async close() {
21482
+ await worker?.stop();
21474
21483
  },
21475
21484
  async process(environment, source, root, options, resolvers) {
21476
21485
  let sassPackage = loadSassPackage(root, failedSassEmbedded ?? false);
@@ -21766,10 +21775,12 @@ const createPreprocessorWorkerController = (maxWorkers) => {
21766
21775
  opts.syntax = "indented";
21767
21776
  return scss.process(environment, source, root, opts, resolvers);
21768
21777
  };
21769
- const close = () => {
21770
- less.close();
21771
- scss.close();
21772
- styl.close();
21778
+ const close = async () => {
21779
+ await Promise.all([
21780
+ less.close(),
21781
+ scss.close(),
21782
+ styl.close()
21783
+ ]);
21773
21784
  };
21774
21785
  return {
21775
21786
  ["less"]: less.process,
@@ -22067,12 +22078,13 @@ function resolveLibCssFilename(libOptions, root, packageCache) {
22067
22078
  //#region src/node/plugins/modulePreloadPolyfill.ts
22068
22079
  const modulePreloadPolyfillId = "vite/modulepreload-polyfill";
22069
22080
  const resolvedModulePreloadPolyfillId = "\0" + modulePreloadPolyfillId + ".js";
22070
- function modulePreloadPolyfillPlugin(config) {
22071
- if (config.isBundled) return perEnvironmentPlugin("native:modulepreload-polyfill", (environment) => {
22072
- return viteModulePreloadPolyfillPlugin({ isServer: environment.config.consumer !== "client" });
22073
- });
22081
+ function modulePreloadPolyfillPlugin() {
22074
22082
  return {
22075
22083
  name: "vite:modulepreload-polyfill",
22084
+ applyToEnvironment(environment) {
22085
+ if (environment.config.isBundled) return viteModulePreloadPolyfillPlugin({ isServer: environment.config.consumer !== "client" });
22086
+ return true;
22087
+ },
22076
22088
  resolveId: {
22077
22089
  filter: { id: exactRegex(modulePreloadPolyfillId) },
22078
22090
  handler(_id) {
@@ -22280,6 +22292,9 @@ function buildHtmlPlugin(config) {
22280
22292
  isAsyncScriptMap.set(config, /* @__PURE__ */ new Map());
22281
22293
  return {
22282
22294
  name: "vite:build-html",
22295
+ applyToEnvironment(environment) {
22296
+ return environment.config.isBundled;
22297
+ },
22283
22298
  transform: {
22284
22299
  filter: { id: /\.html$/ },
22285
22300
  async handler(html, id) {
@@ -22837,7 +22852,6 @@ const nonJsRe = /\.json(?:$|\?)/;
22837
22852
  const isNonJsRequest = (request) => nonJsRe.test(request);
22838
22853
  const escapedDotRE = /(?<!\\)\\./g;
22839
22854
  function definePlugin(config) {
22840
- const isBundled = config.isBundled;
22841
22855
  const isBuild = config.command === "build";
22842
22856
  const isBuildLib = isBuild && config.build.lib;
22843
22857
  const processEnv = {};
@@ -22852,21 +22866,22 @@ function definePlugin(config) {
22852
22866
  "globalThis.process.env.NODE_ENV": JSON.stringify(nodeEnv)
22853
22867
  });
22854
22868
  }
22855
- const importMetaKeys = {};
22856
- const importMetaEnvKeys = {};
22857
- const importMetaFallbackKeys = {};
22858
- if (isBuild) importMetaKeys["import.meta.hot"] = `undefined`;
22859
- if (isBundled) {
22860
- for (const key in config.env) {
22861
- const val = JSON.stringify(config.env[key]);
22862
- importMetaKeys[`import.meta.env.${key}`] = val;
22863
- importMetaEnvKeys[key] = val;
22864
- }
22865
- importMetaKeys["import.meta.env.SSR"] = `undefined`;
22866
- importMetaFallbackKeys["import.meta.env"] = `undefined`;
22867
- }
22868
22869
  function generatePattern(environment) {
22870
+ const isBundled = environment.config.isBundled;
22869
22871
  const keepProcessEnv = environment.config.keepProcessEnv;
22872
+ const importMetaKeys = {};
22873
+ const importMetaEnvKeys = {};
22874
+ const importMetaFallbackKeys = {};
22875
+ if (isBuild) importMetaKeys["import.meta.hot"] = `undefined`;
22876
+ if (isBundled) {
22877
+ for (const key in config.env) {
22878
+ const val = JSON.stringify(config.env[key]);
22879
+ importMetaKeys[`import.meta.env.${key}`] = val;
22880
+ importMetaEnvKeys[key] = val;
22881
+ }
22882
+ importMetaKeys["import.meta.env.SSR"] = `undefined`;
22883
+ importMetaFallbackKeys["import.meta.env"] = `undefined`;
22884
+ }
22870
22885
  const userDefine = {};
22871
22886
  const userDefineEnv = {};
22872
22887
  for (const key in environment.config.define) {
@@ -22904,21 +22919,24 @@ function definePlugin(config) {
22904
22919
  }
22905
22920
  return pattern;
22906
22921
  }
22907
- if (isBundled) return {
22908
- name: "vite:define",
22909
- options(option) {
22910
- const [define, _pattern, importMetaEnvVal] = getPattern(this.environment);
22911
- define["import.meta.env"] = importMetaEnvVal;
22912
- define["import.meta.env.*"] = "undefined";
22913
- option.transform ??= {};
22914
- option.transform.define = {
22915
- ...option.transform.define,
22916
- ...define
22917
- };
22918
- }
22919
- };
22920
22922
  return {
22921
22923
  name: "vite:define",
22924
+ applyToEnvironment(environment) {
22925
+ if (environment.config.isBundled) return {
22926
+ name: "vite:define",
22927
+ options(option) {
22928
+ const [define, _pattern, importMetaEnvVal] = getPattern(this.environment);
22929
+ define["import.meta.env"] = importMetaEnvVal;
22930
+ define["import.meta.env.*"] = "undefined";
22931
+ option.transform ??= {};
22932
+ option.transform.define = {
22933
+ ...option.transform.define,
22934
+ ...define
22935
+ };
22936
+ }
22937
+ };
22938
+ return true;
22939
+ },
22922
22940
  transform: { handler(code, id) {
22923
22941
  if (this.environment.config.consumer === "client") return;
22924
22942
  if (isHTMLRequest(id) || isCSSRequest(id) || isNonJsRequest(id) || config.assetsInclude(id)) return;
@@ -22984,6 +23002,9 @@ function clientInjectionsPlugin(config) {
22984
23002
  });
22985
23003
  return {
22986
23004
  name: "vite:client-inject",
23005
+ applyToEnvironment(environment) {
23006
+ return !environment.config.isBundled;
23007
+ },
22987
23008
  async buildStart() {
22988
23009
  injectConfigValues = await createClientConfigValueReplacer(config);
22989
23010
  },
@@ -24908,6 +24929,7 @@ var MemoryFiles = class {
24908
24929
  };
24909
24930
  var FullBundleDevEnvironment = class extends DevEnvironment {
24910
24931
  devEngine;
24932
+ initialBuildCompleted = false;
24911
24933
  clients = new Clients();
24912
24934
  invalidateCalledModules = /* @__PURE__ */ new Map();
24913
24935
  debouncedFullReload = debounce(20, () => {
@@ -24932,8 +24954,8 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
24932
24954
  if (Array.isArray(rollupOptions.output) && rollupOptions.output.length > 1) throw new Error("multiple output options are not supported in dev mode");
24933
24955
  const outputOptions = Array.isArray(rollupOptions.output) ? rollupOptions.output[0] : rollupOptions.output;
24934
24956
  this.hot.on("vite:module-loaded", (payload, client) => {
24935
- const clientId = this.clients.setupIfNeeded(client);
24936
- this.devEngine.registerModules(clientId, payload.modules);
24957
+ this.clients.setupIfNeeded(client, payload.clientId);
24958
+ this.devEngine.registerModules(payload.clientId, payload.modules);
24937
24959
  });
24938
24960
  this.hot.on("vite:client:disconnect", (_payload, client) => {
24939
24961
  const clientId = this.clients.delete(client);
@@ -24993,6 +25015,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
24993
25015
  type: "full-reload",
24994
25016
  path: "*"
24995
25017
  });
25018
+ this.initialBuildCompleted = true;
24996
25019
  });
24997
25020
  }
24998
25021
  async waitForInitialBuildFinish() {
@@ -25030,7 +25053,7 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
25030
25053
  }
25031
25054
  async triggerBundleRegenerationIfStale() {
25032
25055
  const bundleState = await this.devEngine.getBundleState();
25033
- const shouldTrigger = bundleState.hasStaleOutput && !bundleState.lastFullBuildFailed;
25056
+ const shouldTrigger = bundleState.hasStaleOutput && !bundleState.lastFullBuildFailed && this.initialBuildCompleted;
25034
25057
  if (shouldTrigger) {
25035
25058
  this.devEngine.ensureLatestBuildOutput().then(() => {
25036
25059
  this.debouncedFullReload();
@@ -25039,15 +25062,25 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
25039
25062
  }
25040
25063
  return shouldTrigger;
25041
25064
  }
25065
+ async triggerLazyBundling(moduleId, clientId) {
25066
+ if (!moduleId || !clientId) return;
25067
+ debug$7?.(`TRIGGER-LAZY: trigger lazy bundling for module ${moduleId} for client ${clientId}`);
25068
+ return await this.devEngine.compileEntry(moduleId, clientId);
25069
+ }
25042
25070
  async close() {
25043
25071
  this.memoryFiles.clear();
25044
25072
  await Promise.all([super.close(), this.devEngine.close()]);
25073
+ this.initialBuildCompleted = false;
25045
25074
  }
25046
25075
  async getRolldownOptions() {
25047
25076
  const chunkMetadataMap = new ChunkMetadataMap();
25048
25077
  const rolldownOptions = resolveRolldownOptions(this, chunkMetadataMap);
25049
25078
  rolldownOptions.experimental ??= {};
25050
- rolldownOptions.experimental.devMode = { implement: await getHmrImplementation(this.getTopLevelConfig()) };
25079
+ rolldownOptions.experimental.devMode = {
25080
+ lazy: true,
25081
+ ...typeof rolldownOptions.experimental.devMode === "object" ? rolldownOptions.experimental.devMode : {},
25082
+ implement: await getHmrImplementation(this.getTopLevelConfig())
25083
+ };
25051
25084
  rolldownOptions.optimization ??= {};
25052
25085
  rolldownOptions.optimization.inlineConst = false;
25053
25086
  if (Array.isArray(rolldownOptions.output)) for (const output of rolldownOptions.output) {
@@ -25113,13 +25146,11 @@ var FullBundleDevEnvironment = class extends DevEnvironment {
25113
25146
  var Clients = class {
25114
25147
  clientToId = /* @__PURE__ */ new Map();
25115
25148
  idToClient = /* @__PURE__ */ new Map();
25116
- setupIfNeeded(client) {
25149
+ setupIfNeeded(client, clientId) {
25117
25150
  const id = this.clientToId.get(client);
25118
- if (id) return id;
25119
- const newId = randomUUID();
25120
- this.clientToId.set(client, newId);
25121
- this.idToClient.set(newId, client);
25122
- return newId;
25151
+ if (id && id !== clientId) throw new Error("client ID conflict detected. Please restart the dev server.");
25152
+ this.clientToId.set(client, clientId);
25153
+ this.idToClient.set(clientId, client);
25123
25154
  }
25124
25155
  get(id) {
25125
25156
  return this.idToClient.get(id);
@@ -25985,6 +26016,27 @@ function memoryFilesMiddleware(server) {
25985
26016
  };
25986
26017
  }
25987
26018
  //#endregion
26019
+ //#region src/node/server/middlewares/triggerLazyBundling.ts
26020
+ function triggerLazyBundlingMiddleware(server) {
26021
+ const environment = server.environments.client instanceof FullBundleDevEnvironment ? server.environments.client : void 0;
26022
+ if (!environment) throw new Error("triggerLazyBundlingMiddleware can only be used for fullBundleMode");
26023
+ return async function viteTriggerLazyBundlingMiddleware(req, res, next) {
26024
+ if (!req.url?.startsWith("/@vite/lazy?")) return next();
26025
+ let params;
26026
+ try {
26027
+ params = new URL(`http://localhost${req.url}`).searchParams;
26028
+ } catch {
26029
+ return next();
26030
+ }
26031
+ const moduleId = params.get("id");
26032
+ const clientId = params.get("clientId");
26033
+ const code = await environment.triggerLazyBundling(moduleId, clientId);
26034
+ if (code == null) return next();
26035
+ res.setHeader("Content-Type", "application/javascript");
26036
+ return res.end(code);
26037
+ };
26038
+ }
26039
+ //#endregion
25988
26040
  //#region src/node/server/index.ts
25989
26041
  var server_exports = /* @__PURE__ */ __exportAll({
25990
26042
  _createServer: () => _createServer,
@@ -26282,8 +26334,10 @@ async function _createServer(inlineConfig = {}, options) {
26282
26334
  else next();
26283
26335
  });
26284
26336
  if (publicDir) middlewares.use(servePublicMiddleware(server, publicFiles));
26285
- if (config.experimental.bundledDev) middlewares.use(memoryFilesMiddleware(server));
26286
- else {
26337
+ if (config.experimental.bundledDev) {
26338
+ middlewares.use(triggerLazyBundlingMiddleware(server));
26339
+ middlewares.use(memoryFilesMiddleware(server));
26340
+ } else {
26287
26341
  middlewares.use(transformMiddleware(server));
26288
26342
  middlewares.use(serveRawFsMiddleware(server));
26289
26343
  middlewares.use(serveStaticMiddleware(server));
@@ -27236,12 +27290,16 @@ async function workerFileToUrl(config, id) {
27236
27290
  }, config.logger);
27237
27291
  return bundle;
27238
27292
  }
27239
- function webWorkerPostPlugin(config) {
27240
- if (config.isBundled) return perEnvironmentPlugin("native:web-worker-post-plugin", (environment) => {
27241
- if (environment.config.worker.format === "iife") return viteWebWorkerPostPlugin();
27242
- });
27293
+ function webWorkerPostPlugin(_config) {
27243
27294
  return {
27244
27295
  name: "vite:worker-post",
27296
+ applyToEnvironment(environment) {
27297
+ if (environment.config.isBundled) {
27298
+ if (environment.config.worker.format === "iife") return viteWebWorkerPostPlugin();
27299
+ return false;
27300
+ }
27301
+ return true;
27302
+ },
27245
27303
  transform: {
27246
27304
  filter: { code: "import.meta" },
27247
27305
  order: "post",
@@ -27298,13 +27356,14 @@ function webWorkerPlugin(config) {
27298
27356
  if (!workerMatch) return;
27299
27357
  const { format } = config.worker;
27300
27358
  const workerConstructor = workerMatch[1] === "sharedworker" ? "SharedWorker" : "Worker";
27301
- const workerType = config.isBundled ? format === "es" ? "module" : "classic" : "module";
27359
+ const isBundled = this.environment.config.isBundled;
27360
+ const workerType = isBundled ? format === "es" ? "module" : "classic" : "module";
27302
27361
  const workerTypeOption = `{
27303
27362
  ${workerType === "module" ? `type: "module",` : ""}
27304
27363
  name: options?.name
27305
27364
  }`;
27306
27365
  let urlCode;
27307
- if (config.isBundled) if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) urlCode = "self.location.href";
27366
+ if (isBundled) if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) urlCode = "self.location.href";
27308
27367
  else if (inlineRE.test(id)) {
27309
27368
  const result = await bundleWorkerEntry(config, id);
27310
27369
  for (const file of result.watchedFiles) this.addWatchFile(file);
@@ -27341,7 +27400,7 @@ function webWorkerPlugin(config) {
27341
27400
  } else {
27342
27401
  const result = await workerFileToUrl(config, id);
27343
27402
  let url;
27344
- if (this.environment.config.command === "serve" && this.environment.config.experimental.bundledDev) url = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
27403
+ if (this.environment.config.command === "serve" && this.environment.config.isBundled) url = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
27345
27404
  else url = result.entryUrlPlaceholder;
27346
27405
  urlCode = JSON.stringify(url);
27347
27406
  for (const file of result.watchedFiles) this.addWatchFile(file);
@@ -27375,7 +27434,7 @@ function webWorkerPlugin(config) {
27375
27434
  let injectEnv = "";
27376
27435
  if (workerType === "classic") injectEnv = `importScripts(${JSON.stringify(path.posix.join(config.base, ENV_PUBLIC_PATH))})\n`;
27377
27436
  else if (workerType === "module") injectEnv = `import ${JSON.stringify(ENV_PUBLIC_PATH)}\n`;
27378
- else if (workerType === "ignore") if (config.isBundled) injectEnv = "";
27437
+ else if (workerType === "ignore") if (this.environment.config.isBundled) injectEnv = "";
27379
27438
  else {
27380
27439
  const environment = this.environment;
27381
27440
  injectEnv = ((environment.mode === "dev" ? environment.moduleGraph : void 0)?.getModuleById(ENV_ENTRY))?.transformResult?.code || "";
@@ -27459,6 +27518,7 @@ function preAliasPlugin(config) {
27459
27518
  return {
27460
27519
  name: "vite:pre-alias",
27461
27520
  applyToEnvironment(environment) {
27521
+ if (environment.config.isBundled) return false;
27462
27522
  return !isDepOptimizationDisabled(environment.config.optimizeDeps);
27463
27523
  },
27464
27524
  async resolveId(id, importer, options) {
@@ -27605,6 +27665,9 @@ function importAnalysisPlugin(config) {
27605
27665
  }
27606
27666
  return {
27607
27667
  name: "vite:import-analysis",
27668
+ applyToEnvironment(environment) {
27669
+ return !environment.config.isBundled;
27670
+ },
27608
27671
  async transform(source, importer) {
27609
27672
  const environment = this.environment;
27610
27673
  const ssr = environment.config.consumer === "server";
@@ -28094,7 +28157,6 @@ async function getWorkerType(raw, clean, i) {
28094
28157
  }
28095
28158
  const workerImportMetaUrlRE = /\bnew\s+(?:Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\))/dg;
28096
28159
  function workerImportMetaUrlPlugin(config) {
28097
- const isBundled = config.isBundled;
28098
28160
  let workerResolver;
28099
28161
  const fsResolveOptions = {
28100
28162
  ...config.resolve,
@@ -28112,6 +28174,7 @@ function workerImportMetaUrlPlugin(config) {
28112
28174
  transform: {
28113
28175
  filter: { code: workerImportMetaUrlRE },
28114
28176
  async handler(code, id) {
28177
+ const isBundled = this.environment.config.isBundled;
28115
28178
  let s;
28116
28179
  const cleanString = stripLiteral(code);
28117
28180
  const re = new RegExp(workerImportMetaUrlRE);
@@ -28141,7 +28204,7 @@ function workerImportMetaUrlPlugin(config) {
28141
28204
  let builtUrl;
28142
28205
  if (isBundled) {
28143
28206
  const result = await workerFileToUrl(config, file);
28144
- if (this.environment.config.command === "serve" && this.environment.config.experimental.bundledDev) builtUrl = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
28207
+ if (this.environment.config.command === "serve") builtUrl = toOutputFilePathInJSForBundledDev(this.environment, result.entryFilename);
28145
28208
  else builtUrl = result.entryUrlPlaceholder;
28146
28209
  for (const file of result.watchedFiles) this.addWatchFile(file);
28147
28210
  } else {
@@ -28696,23 +28759,26 @@ function dynamicImportVarsPlugin(config) {
28696
28759
  tryIndex: false,
28697
28760
  extensions: []
28698
28761
  });
28699
- if (config.isBundled) return perEnvironmentPlugin("native:dynamic-import-vars", (environment) => {
28700
- const { include, exclude } = environment.config.build.dynamicImportVarsOptions;
28701
- return viteDynamicImportVarsPlugin({
28702
- include,
28703
- exclude,
28704
- resolver(id, importer) {
28705
- return resolve(environment, id, importer);
28706
- },
28707
- sourcemap: !!environment.config.build.sourcemap
28708
- });
28709
- });
28710
28762
  const getFilter = perEnvironmentState((environment) => {
28711
28763
  const { include, exclude } = environment.config.build.dynamicImportVarsOptions;
28712
28764
  return createFilter$1(include, exclude);
28713
28765
  });
28714
28766
  return {
28715
28767
  name: "vite:dynamic-import-vars",
28768
+ applyToEnvironment(environment) {
28769
+ if (environment.config.isBundled) {
28770
+ const { include, exclude } = environment.config.build.dynamicImportVarsOptions;
28771
+ return viteDynamicImportVarsPlugin({
28772
+ include,
28773
+ exclude,
28774
+ resolver(id, importer) {
28775
+ return resolve(environment, id, importer);
28776
+ },
28777
+ sourcemap: !!environment.config.build.sourcemap
28778
+ });
28779
+ }
28780
+ return true;
28781
+ },
28716
28782
  resolveId: {
28717
28783
  filter: { id: exactRegex(dynamicImportHelperId) },
28718
28784
  handler(id) {
@@ -28770,14 +28836,17 @@ function dynamicImportVarsPlugin(config) {
28770
28836
  //#endregion
28771
28837
  //#region src/node/plugins/importMetaGlob.ts
28772
28838
  function importGlobPlugin(config) {
28773
- if (config.isBundled) return viteImportGlobPlugin({
28774
- root: config.root,
28775
- sourcemap: !!config.build.sourcemap,
28776
- restoreQueryExtension: config.experimental.importGlobRestoreExtension
28777
- });
28778
28839
  const importGlobMaps = /* @__PURE__ */ new Map();
28779
28840
  return {
28780
28841
  name: "vite:import-glob",
28842
+ applyToEnvironment(environment) {
28843
+ if (environment.config.isBundled) return viteImportGlobPlugin({
28844
+ root: environment.config.root,
28845
+ sourcemap: !!environment.config.build.sourcemap,
28846
+ restoreQueryExtension: environment.config.experimental.importGlobRestoreExtension
28847
+ });
28848
+ return true;
28849
+ },
28781
28850
  buildStart() {
28782
28851
  importGlobMaps.clear();
28783
28852
  },
@@ -29745,29 +29814,34 @@ function esbuildBannerFooterCompatPlugin(config) {
29745
29814
  //#region src/node/plugins/index.ts
29746
29815
  async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
29747
29816
  const isBuild = config.command === "build";
29748
- const isBundled = config.isBundled;
29749
29817
  const isWorker = config.isWorker;
29750
- const buildPlugins = isBundled ? (await Promise.resolve().then(() => build_exports)).resolveBuildPlugins(config) : {
29818
+ const buildPlugins = isBuild || Object.values(config.environments).some((env) => env.isBundled) ? (await Promise.resolve().then(() => build_exports)).resolveBuildPlugins(config) : {
29751
29819
  pre: [],
29752
29820
  post: []
29753
29821
  };
29754
29822
  const devtoolsIntegrationPlugin = config.devtools.enabled && !isWorker ? await loadDevToolsIntegrationPlugin(config) : null;
29755
29823
  const { modulePreload } = config.build;
29756
29824
  return [
29757
- !isBundled ? optimizedDepsPlugin() : null,
29825
+ optimizedDepsPlugin(),
29758
29826
  !isWorker ? watchPackageDataPlugin(config.packageCache) : null,
29759
- !isBundled ? preAliasPlugin(config) : null,
29760
- isBundled && !config.resolve.alias.some((v) => v.customResolver) ? viteAliasPlugin({ entries: config.resolve.alias.map((item) => {
29761
- return {
29762
- find: item.find,
29763
- replacement: item.replacement
29764
- };
29765
- }) }) : alias$1({
29766
- entries: config.resolve.alias,
29767
- customResolver: viteAliasCustomResolver
29768
- }),
29827
+ preAliasPlugin(config),
29828
+ {
29829
+ ...alias$1({
29830
+ entries: config.resolve.alias,
29831
+ customResolver: viteAliasCustomResolver
29832
+ }),
29833
+ applyToEnvironment(environment) {
29834
+ if (environment.config.isBundled && !environment.config.resolve.alias.some((v) => v.customResolver)) return viteAliasPlugin({ entries: config.resolve.alias.map((item) => {
29835
+ return {
29836
+ find: item.find,
29837
+ replacement: item.replacement
29838
+ };
29839
+ }) });
29840
+ return true;
29841
+ }
29842
+ },
29769
29843
  ...prePlugins,
29770
- modulePreload !== false && modulePreload.polyfill ? modulePreloadPolyfillPlugin(config) : null,
29844
+ modulePreload !== false && modulePreload.polyfill ? modulePreloadPolyfillPlugin() : null,
29771
29845
  ...oxcResolvePlugin({
29772
29846
  root: config.root,
29773
29847
  isProduction: config.isProduction,
@@ -29780,12 +29854,18 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
29780
29854
  }, isWorker ? {
29781
29855
  ...config,
29782
29856
  consumer: "client",
29857
+ isBundled: true,
29783
29858
  optimizeDepsPluginNames: []
29784
29859
  } : void 0),
29785
29860
  htmlInlineProxyPlugin(config),
29786
29861
  cssPlugin(config),
29787
29862
  esbuildBannerFooterCompatPlugin(config),
29788
- config.oxc !== false && !isBundled ? oxcRuntimePlugin() : null,
29863
+ config.oxc !== false ? {
29864
+ ...oxcRuntimePlugin(),
29865
+ applyToEnvironment(environment) {
29866
+ return !environment.config.isBundled;
29867
+ }
29868
+ } : null,
29789
29869
  config.oxc !== false ? oxcPlugin(config) : null,
29790
29870
  viteJsonPlugin({
29791
29871
  ...config.json,
@@ -29799,7 +29879,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
29799
29879
  viteWasmFallbackPlugin(),
29800
29880
  definePlugin(config),
29801
29881
  cssPostPlugin(config),
29802
- isBundled && buildHtmlPlugin(config),
29882
+ buildHtmlPlugin(config),
29803
29883
  workerImportMetaUrlPlugin(config),
29804
29884
  assetImportMetaUrlPlugin(config),
29805
29885
  ...buildPlugins.pre,
@@ -29808,11 +29888,9 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
29808
29888
  ...postPlugins,
29809
29889
  ...buildPlugins.post,
29810
29890
  devtoolsIntegrationPlugin,
29811
- ...isBundled ? [] : [
29812
- clientInjectionsPlugin(config),
29813
- cssAnalysisPlugin(config),
29814
- importAnalysisPlugin(config)
29815
- ]
29891
+ clientInjectionsPlugin(config),
29892
+ cssAnalysisPlugin(config),
29893
+ importAnalysisPlugin(config)
29816
29894
  ].filter(Boolean);
29817
29895
  }
29818
29896
  async function loadDevToolsIntegrationPlugin(config) {
@@ -32058,7 +32136,7 @@ const perEnvironmentOrWorkerPlugin = (name, overrideEnvConfig, f) => {
32058
32136
  };
32059
32137
  function oxcResolvePlugin(resolveOptions, overrideEnvConfig) {
32060
32138
  return [...resolveOptions.optimizeDeps && !resolveOptions.isBuild ? [optimizerResolvePlugin(resolveOptions)] : [], ...perEnvironmentOrWorkerPlugin("vite:resolve-builtin", overrideEnvConfig, (partialEnv, getEnv) => {
32061
- const depsOptimizerEnabled = resolveOptions.optimizeDeps && !resolveOptions.isBuild && !partialEnv.config.experimental.bundledDev && !isDepOptimizationDisabled(partialEnv.config.optimizeDeps);
32139
+ const depsOptimizerEnabled = resolveOptions.optimizeDeps && !resolveOptions.isBuild && !partialEnv.config.isBundled && !isDepOptimizationDisabled(partialEnv.config.optimizeDeps);
32062
32140
  const getDepsOptimizer = () => {
32063
32141
  const env = getEnv();
32064
32142
  if (env.mode !== "dev") throw new Error("The environment mode should be dev");
@@ -32143,7 +32221,7 @@ function optimizerResolvePlugin(resolveOptions) {
32143
32221
  return {
32144
32222
  name: "vite:resolve-dev",
32145
32223
  applyToEnvironment(environment) {
32146
- return !environment.config.experimental.bundledDev && !isDepOptimizationDisabled(environment.config.optimizeDeps);
32224
+ return !environment.config.isBundled && !isDepOptimizationDisabled(environment.config.optimizeDeps);
32147
32225
  },
32148
32226
  resolveId: {
32149
32227
  filter: { id: { exclude: [
@@ -32764,9 +32842,9 @@ function prepareOutDirPlugin() {
32764
32842
  order: "pre",
32765
32843
  handler() {
32766
32844
  if (rendered.has(this.environment)) return;
32767
- rendered.add(this.environment);
32768
32845
  const { config } = this.environment;
32769
32846
  if (config.build.write) {
32847
+ rendered.add(this.environment);
32770
32848
  const { root, build: options } = config;
32771
32849
  const resolvedOutDirs = getResolvedOutDirs(root, options.outDir, options.rollupOptions.output);
32772
32850
  prepareOutDir(resolvedOutDirs, resolveEmptyOutDir(options.emptyOutDir, root, resolvedOutDirs, this.environment.logger), this.environment);
@@ -32891,12 +32969,15 @@ function resolveBuildPlugins(config) {
32891
32969
  return {
32892
32970
  pre: [
32893
32971
  ...isBuild && !config.isWorker ? [prepareOutDirPlugin()] : [],
32894
- perEnvironmentPlugin("vite:rollup-options-plugins", async (environment) => (await asyncFlatten(arraify(environment.config.build.rollupOptions.plugins))).filter(Boolean)),
32972
+ perEnvironmentPlugin("vite:rollup-options-plugins", async (environment) => {
32973
+ if (!isBuild && !environment.config.isBundled) return false;
32974
+ return (await asyncFlatten(arraify(environment.config.build.rollupOptions.plugins))).filter(Boolean);
32975
+ }),
32895
32976
  ...config.isWorker ? [webWorkerPostPlugin(config)] : []
32896
32977
  ],
32897
32978
  post: [
32898
32979
  ...isBuild ? buildImportAnalysisPlugin(config) : [],
32899
- ...config.build.minify === "esbuild" ? [buildEsbuildPlugin()] : [],
32980
+ ...isBuild && config.build.minify === "esbuild" ? [buildEsbuildPlugin()] : [],
32900
32981
  ...isBuild ? [terserPlugin(config)] : [],
32901
32982
  ...isBuild && !config.isWorker ? [
32902
32983
  licensePlugin(),
@@ -33859,9 +33940,14 @@ function convertEsbuildPluginToRolldownPlugin(esbuildPlugin) {
33859
33940
  if (!isSetupDone) await setup([{ name: "vite:dep-scan" }], inputOptions.platform ?? "node");
33860
33941
  for (const cb of onStartCallbacks) cb();
33861
33942
  },
33862
- generateBundle() {
33863
- const buildResult = new Proxy({}, { get(_target, _prop) {
33864
- throw new Error("Not implemented");
33943
+ generateBundle(_outputOpts, _bundle, isWrite) {
33944
+ const buildResult = new Proxy({
33945
+ metafile: void 0,
33946
+ mangleCache: void 0,
33947
+ ...isWrite ? { outputFiles: void 0 } : {}
33948
+ }, { get(_target, prop) {
33949
+ if (prop in _target || typeof prop === "symbol") return _target[prop];
33950
+ throw new Error("Not implemented property: " + prop);
33865
33951
  } });
33866
33952
  for (const cb of onEndCallbacks) cb(buildResult);
33867
33953
  },
@@ -34090,9 +34176,11 @@ function resolveDevEnvironmentOptions(dev, environmentName, consumer, preTransfo
34090
34176
  sourcemapIgnoreList: resolved.sourcemapIgnoreList === false ? () => false : resolved.sourcemapIgnoreList
34091
34177
  };
34092
34178
  }
34093
- function resolveEnvironmentOptions(options, alias, preserveSymlinks, forceOptimizeDeps, logger, environmentName, isBundledDev, isSsrTargetWebworkerSet, preTransformRequests) {
34094
- const consumer = options.consumer ?? (environmentName === "client" ? "client" : "server");
34179
+ function resolveEnvironmentOptions(options, alias, preserveSymlinks, forceOptimizeDeps, logger, environmentName, isBuild, isBundledDev, isSsrTargetWebworkerSet, preTransformRequests) {
34180
+ const isClientEnvironment = environmentName === "client";
34181
+ const consumer = options.consumer ?? (isClientEnvironment ? "client" : "server");
34095
34182
  const isSsrTargetWebworkerEnvironment = isSsrTargetWebworkerSet && environmentName === "ssr";
34183
+ const isBundled = options.isBundled ?? (isBuild || isClientEnvironment && isBundledDev);
34096
34184
  if (options.define?.["process.env"]) {
34097
34185
  const processEnvDefine = options.define["process.env"];
34098
34186
  if (typeof processEnvDefine === "object") {
@@ -34108,7 +34196,8 @@ function resolveEnvironmentOptions(options, alias, preserveSymlinks, forceOptimi
34108
34196
  consumer,
34109
34197
  optimizeDeps: resolveDepOptimizationOptions(options.optimizeDeps, resolve.preserveSymlinks, forceOptimizeDeps, consumer, logger),
34110
34198
  dev: resolveDevEnvironmentOptions(options.dev, environmentName, consumer, preTransformRequests),
34111
- build: resolveBuildEnvironmentOptions(options.build ?? {}, logger, consumer, isBundledDev, isSsrTargetWebworkerEnvironment),
34199
+ build: resolveBuildEnvironmentOptions(options.build ?? {}, logger, consumer, isBundled && !isBuild, isSsrTargetWebworkerEnvironment),
34200
+ isBundled,
34112
34201
  plugins: void 0,
34113
34202
  optimizeDepsPluginNames: void 0
34114
34203
  };
@@ -34349,7 +34438,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
34349
34438
  config.resolve.mainFields = config.environments.client.resolve?.mainFields;
34350
34439
  const resolvedDefaultResolve = resolveResolveOptions(config.resolve, logger);
34351
34440
  const resolvedEnvironments = {};
34352
- for (const environmentName of Object.keys(config.environments)) resolvedEnvironments[environmentName] = resolveEnvironmentOptions(config.environments[environmentName], resolvedDefaultResolve.alias, resolvedDefaultResolve.preserveSymlinks, inlineConfig.forceOptimizeDeps, logger, environmentName, isBundledDev, config.ssr?.target === "webworker", config.server?.preTransformRequests);
34441
+ for (const environmentName of Object.keys(config.environments)) resolvedEnvironments[environmentName] = resolveEnvironmentOptions(config.environments[environmentName], resolvedDefaultResolve.alias, resolvedDefaultResolve.preserveSymlinks, inlineConfig.forceOptimizeDeps, logger, environmentName, isBuild, isBundledDev, config.ssr?.target === "webworker", config.server?.preTransformRequests);
34353
34442
  const backwardCompatibleOptimizeDeps = resolvedEnvironments.client.optimizeDeps;
34354
34443
  const resolvedDevEnvironmentOptions = resolveDevEnvironmentOptions(config.dev, void 0, void 0);
34355
34444
  const resolvedBuildOptions = resolveBuildEnvironmentOptions(config.build ?? {}, logger, void 0, isBundledDev);
@@ -34449,7 +34538,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
34449
34538
  cacheDir,
34450
34539
  command,
34451
34540
  mode,
34452
- isBundled: config.experimental?.bundledDev || isBuild,
34453
34541
  isWorker: false,
34454
34542
  mainConfig: null,
34455
34543
  bundleChain: [],
@@ -1,4 +1,4 @@
1
- import { i as __require, t as __commonJSMin } from "./chunk.js";
1
+ import { H as __require, z as __commonJSMin } from "./logger.js";
2
2
  import { t as require_lib } from "./lib.js";
3
3
  //#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.14/node_modules/postcss-import/lib/format-import-prelude.js
4
4
  var require_format_import_prelude = /* @__PURE__ */ __commonJSMin(((exports, module) => {
package/dist/node/cli.js CHANGED
@@ -1,5 +1,4 @@
1
- import { o as __toESM } from "./chunks/chunk.js";
2
- import { N as VERSION, R as require_picocolors, n as createLogger } from "./chunks/logger.js";
1
+ import { N as VERSION, R as require_picocolors, W as __toESM, n as createLogger } from "./chunks/logger.js";
3
2
  import fs from "node:fs";
4
3
  import path from "node:path";
5
4
  import { inspect } from "node:util";
@@ -3288,6 +3288,17 @@ interface SharedEnvironmentOptions {
3288
3288
  * Optimize deps config
3289
3289
  */
3290
3290
  optimizeDeps?: DepOptimizationOptions;
3291
+ /**
3292
+ * Whether this environment produces a bundled output.
3293
+ *
3294
+ * During `build`, this defaults to `true` for every environment.
3295
+ * During `serve`, this defaults to `true` only for the client environment
3296
+ * when `experimental.bundledDev` is enabled, and `false` otherwise.
3297
+ * Setting this explicitly on an environment always overrides the default.
3298
+ *
3299
+ * @experimental
3300
+ */
3301
+ isBundled?: boolean;
3291
3302
  }
3292
3303
  interface EnvironmentOptions extends SharedEnvironmentOptions {
3293
3304
  /**
@@ -3308,6 +3319,7 @@ type ResolvedEnvironmentOptions = {
3308
3319
  optimizeDeps: DepOptimizationOptions;
3309
3320
  dev: ResolvedDevEnvironmentOptions;
3310
3321
  build: ResolvedBuildEnvironmentOptions;
3322
+ isBundled: boolean;
3311
3323
  plugins: readonly Plugin[];
3312
3324
  };
3313
3325
  type DefaultEnvironmentOptions = Omit<EnvironmentOptions, "consumer" | "resolve" | "keepProcessEnv"> & {
@@ -3532,7 +3544,11 @@ interface ExperimentalOptions {
3532
3544
  */
3533
3545
  hmrPartialAccept?: boolean;
3534
3546
  /**
3535
- * Enable full bundle mode.
3547
+ * Enable full bundle mode during `serve`.
3548
+ *
3549
+ * This seeds the default for the client environment's `isBundled` option.
3550
+ * Other environments default to `false` during `serve`. Any environment
3551
+ * can override its `isBundled` value via `environments[name].isBundled`.
3536
3552
  *
3537
3553
  * This is highly experimental.
3538
3554
  *
@@ -3592,8 +3608,7 @@ interface ResolvedConfig extends Readonly<Omit<UserConfig, "plugins" | "css" | "
3592
3608
  publicDir: string;
3593
3609
  cacheDir: string;
3594
3610
  command: "build" | "serve";
3595
- mode: string; /** `true` when build or full-bundle mode dev */
3596
- isBundled: boolean;
3611
+ mode: string;
3597
3612
  isWorker: boolean;
3598
3613
  isProduction: boolean;
3599
3614
  envDir: string | false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "8.0.12",
3
+ "version": "8.0.13",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -63,7 +63,7 @@
63
63
  "lightningcss": "^1.32.0",
64
64
  "picomatch": "^4.0.4",
65
65
  "postcss": "^8.5.14",
66
- "rolldown": "1.0.0",
66
+ "rolldown": "1.0.1",
67
67
  "tinyglobby": "^0.2.16"
68
68
  },
69
69
  "optionalDependencies": {
@@ -18,7 +18,7 @@ export interface CustomEventMap {
18
18
  /** @internal */
19
19
  'vite:forward-console': ForwardConsolePayload
20
20
  /** @internal */
21
- 'vite:module-loaded': { modules: string[] }
21
+ 'vite:module-loaded': { modules: string[]; clientId: string }
22
22
 
23
23
  // server events
24
24
  'vite:client:connect': undefined
@@ -1,37 +0,0 @@
1
- import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
10
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
11
- var __exportAll = (all, no_symbols) => {
12
- let target = {};
13
- for (var name in all) __defProp(target, name, {
14
- get: all[name],
15
- enumerable: true
16
- });
17
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
- return target;
19
- };
20
- var __copyProps = (to, from, except, desc) => {
21
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
22
- key = keys[i];
23
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
24
- get: ((k) => from[k]).bind(null, key),
25
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
26
- });
27
- }
28
- return to;
29
- };
30
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
31
- value: mod,
32
- enumerable: true
33
- }) : target, mod));
34
- var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
36
- //#endregion
37
- export { __toCommonJS as a, __require as i, __esmMin as n, __toESM as o, __exportAll as r, __commonJSMin as t };