vite 3.0.0-beta.5 → 3.0.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
1
  import fs$l, { promises as promises$2 } from 'node:fs';
2
- import path$o, { resolve as resolve$6, join as join$2, posix as posix$2, isAbsolute as isAbsolute$2, relative as relative$2, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
2
+ import path$n, { resolve as resolve$6, join as join$2, posix as posix$2, isAbsolute as isAbsolute$2, relative as relative$2, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
3
3
  import { URL as URL$3, pathToFileURL, URLSearchParams, parse as parse$k } from 'node:url';
4
4
  import { performance } from 'node:perf_hooks';
5
5
  import { createRequire as createRequire$1, builtinModules } from 'node:module';
6
6
  import require$$0$3 from 'tty';
7
7
  import { transform as transform$2, build as build$3, formatMessages } from 'esbuild';
8
- import path$n, { sep, resolve as resolve$4, posix as posix$1, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, win32 as win32$1, isAbsolute as isAbsolute$1, normalize } from 'path';
8
+ import require$$0$4, { sep, resolve as resolve$4, posix as posix$1, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, win32 as win32$1, isAbsolute as isAbsolute$1, normalize } from 'path';
9
9
  import * as require$$0$2 from 'fs';
10
10
  import require$$0__default, { statSync as statSync$1, existsSync, readFileSync, promises as promises$1, readdirSync } from 'fs';
11
- import require$$0$4 from 'events';
11
+ import require$$0$5 from 'events';
12
12
  import assert$1 from 'assert';
13
- import require$$0$5, { format as format$2, inspect } from 'util';
13
+ import require$$0$6, { format as format$2, inspect } from 'util';
14
14
  import require$$3$1 from 'net';
15
- import require$$0$8, { pathToFileURL as pathToFileURL$1 } from 'url';
15
+ import require$$0$9, { pathToFileURL as pathToFileURL$1 } from 'url';
16
16
  import require$$1$2 from 'http';
17
- import require$$0$6 from 'stream';
17
+ import require$$0$7 from 'stream';
18
18
  import require$$1 from 'os';
19
19
  import require$$2 from 'child_process';
20
20
  import os$3 from 'node:os';
@@ -22,11 +22,11 @@ import { createHash as createHash$2 } from 'node:crypto';
22
22
  import { promisify as promisify$4 } from 'node:util';
23
23
  import { promises } from 'node:dns';
24
24
  import resolve$5 from 'resolve';
25
- import { CLIENT_ENTRY, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, VALID_ID_PREFIX, FS_PREFIX, wildcardHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, loopbackHosts, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, JS_TYPES_RE, ESBUILD_MODULES_TARGET, CLIENT_DIR, NULL_BYTE_PLACEHOLDER, VERSION, VITE_PACKAGE_DIR, ENV_ENTRY, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
25
+ import { CLIENT_ENTRY, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, OPTIMIZABLE_ENTRY_RE, VALID_ID_PREFIX, FS_PREFIX, wildcardHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, loopbackHosts, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, JS_TYPES_RE, ESBUILD_MODULES_TARGET, CLIENT_DIR, NULL_BYTE_PLACEHOLDER, VERSION, VITE_PACKAGE_DIR, ENV_ENTRY, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
26
26
  import require$$5 from 'crypto';
27
- import require$$0$9 from 'buffer';
28
- import require$$0$7, { createRequire as createRequire$2 } from 'module';
29
- import require$$0$a from 'zlib';
27
+ import require$$0$a from 'buffer';
28
+ import require$$0$8, { createRequire as createRequire$2 } from 'module';
29
+ import require$$0$b from 'zlib';
30
30
  import require$$1$3 from 'https';
31
31
  import require$$4 from 'tls';
32
32
  import { STATUS_CODES } from 'node:http';
@@ -213,7 +213,7 @@ var picomatch$4 = {exports: {}};
213
213
 
214
214
  var utils$k = {};
215
215
 
216
- const path$m = path$n;
216
+ const path$m = require$$0$4;
217
217
  const WIN_SLASH = '\\\\/';
218
218
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
219
219
 
@@ -393,7 +393,7 @@ var constants$6 = {
393
393
 
394
394
  (function (exports) {
395
395
 
396
- const path = path$n;
396
+ const path = require$$0$4;
397
397
  const win32 = process.platform === 'win32';
398
398
  const {
399
399
  REGEX_BACKSLASH,
@@ -1930,7 +1930,7 @@ parse$j.fastpaths = (input, options) => {
1930
1930
 
1931
1931
  var parse_1$2 = parse$j;
1932
1932
 
1933
- const path$l = path$n;
1933
+ const path$l = require$$0$4;
1934
1934
  const scan$1 = scan_1;
1935
1935
  const parse$i = parse_1$2;
1936
1936
  const utils$h = utils$k;
@@ -2616,7 +2616,7 @@ const makeLegalIdentifier$1 = function makeLegalIdentifier(str) {
2616
2616
  return identifier || '_';
2617
2617
  };
2618
2618
 
2619
- var path$k = path$n;
2619
+ var path$k = require$$0$4;
2620
2620
 
2621
2621
  var commondir = function (basedir, relfiles) {
2622
2622
  if (relfiles) {
@@ -2669,7 +2669,7 @@ var old$1 = {};
2669
2669
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2670
2670
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
2671
2671
 
2672
- var pathModule = path$n;
2672
+ var pathModule = require$$0$4;
2673
2673
  var isWindows$5 = process.platform === 'win32';
2674
2674
  var fs$k = require$$0__default;
2675
2675
 
@@ -4324,7 +4324,7 @@ function ownProp (obj, field) {
4324
4324
  }
4325
4325
 
4326
4326
  var fs$i = require$$0__default;
4327
- var path$i = path$n;
4327
+ var path$i = require$$0$4;
4328
4328
  var minimatch = minimatch_1;
4329
4329
  var isAbsolute = pathIsAbsolute.exports;
4330
4330
  var Minimatch = minimatch.Minimatch;
@@ -4560,7 +4560,7 @@ function requireSync () {
4560
4560
  var rp = fs_realpath;
4561
4561
  var minimatch = minimatch_1;
4562
4562
  requireGlob().Glob;
4563
- var path = path$n;
4563
+ var path = require$$0$4;
4564
4564
  var assert = assert$1;
4565
4565
  var isAbsolute = pathIsAbsolute.exports;
4566
4566
  var common = common$c;
@@ -5219,8 +5219,8 @@ function requireGlob () {
5219
5219
  var rp = fs_realpath;
5220
5220
  var minimatch = minimatch_1;
5221
5221
  var inherits$1 = inherits.exports;
5222
- var EE = require$$0$4.EventEmitter;
5223
- var path = path$n;
5222
+ var EE = require$$0$5.EventEmitter;
5223
+ var path = require$$0$4;
5224
5224
  var assert = assert$1;
5225
5225
  var isAbsolute = pathIsAbsolute.exports;
5226
5226
  var globSync = requireSync();
@@ -11170,7 +11170,7 @@ function requireNode$1 () {
11170
11170
  hasRequiredNode$1 = 1;
11171
11171
  (function (module, exports) {
11172
11172
  const tty = require$$0$3;
11173
- const util = require$$0$5;
11173
+ const util = require$$0$6;
11174
11174
 
11175
11175
  /**
11176
11176
  * This is the Node.js implementation of `debug()`.
@@ -11647,6 +11647,10 @@ function isBuiltin(id) {
11647
11647
  function moduleListContains(moduleList, id) {
11648
11648
  return moduleList?.some((m) => m === id || id.startsWith(m + '/'));
11649
11649
  }
11650
+ function isOptimizable(id, optimizeDepsConfig) {
11651
+ return (OPTIMIZABLE_ENTRY_RE.test(id) ||
11652
+ (optimizeDepsConfig.extensions?.some((ext) => id.endsWith(ext)) ?? false));
11653
+ }
11650
11654
  const bareImportRE = /^[\w@](?!.*:\/\/)/;
11651
11655
  let isRunningWithYarnPnp;
11652
11656
  // TODO: use import()
@@ -11710,7 +11714,7 @@ const isCaseInsensitiveFS = testCaseInsensitiveFS();
11710
11714
  const isWindows$4 = os$3.platform() === 'win32';
11711
11715
  const VOLUME_RE = /^[A-Z]:/i;
11712
11716
  function normalizePath$3(id) {
11713
- return path$o.posix.normalize(isWindows$4 ? slash$1(id) : id);
11717
+ return path$n.posix.normalize(isWindows$4 ? slash$1(id) : id);
11714
11718
  }
11715
11719
  function fsPathFromId(id) {
11716
11720
  const fsPath = normalizePath$3(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
@@ -11738,7 +11742,7 @@ function isParentDirectory(dir, file) {
11738
11742
  (isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
11739
11743
  }
11740
11744
  function ensureVolumeInPath(file) {
11741
- return isWindows$4 ? path$o.resolve(file) : file;
11745
+ return isWindows$4 ? path$n.resolve(file) : file;
11742
11746
  }
11743
11747
  const queryRE = /\?.*$/s;
11744
11748
  const hashRE = /#.*$/s;
@@ -11755,7 +11759,7 @@ const isJSRequest = (url) => {
11755
11759
  if (knownJsSrcRE.test(url)) {
11756
11760
  return true;
11757
11761
  }
11758
- if (!path$o.extname(url) && !url.endsWith('/')) {
11762
+ if (!path$n.extname(url) && !url.endsWith('/')) {
11759
11763
  return true;
11760
11764
  }
11761
11765
  return false;
@@ -11836,7 +11840,7 @@ function prettifyUrl(url, root) {
11836
11840
  url = removeTimestampQuery(url);
11837
11841
  const isAbsoluteFile = url.startsWith(root);
11838
11842
  if (isAbsoluteFile || url.startsWith(FS_PREFIX)) {
11839
- let file = path$o.relative(root, isAbsoluteFile ? url : fsPathFromId(url));
11843
+ let file = path$n.relative(root, isAbsoluteFile ? url : fsPathFromId(url));
11840
11844
  const seg = file.split('/');
11841
11845
  const npmIndex = seg.indexOf(`node_modules`);
11842
11846
  const isSourceMap = file.endsWith('.map');
@@ -11861,12 +11865,12 @@ function isDefined(value) {
11861
11865
  }
11862
11866
  function lookupFile(dir, formats, options) {
11863
11867
  for (const format of formats) {
11864
- const fullPath = path$o.join(dir, format);
11868
+ const fullPath = path$n.join(dir, format);
11865
11869
  if (fs$l.existsSync(fullPath) && fs$l.statSync(fullPath).isFile()) {
11866
11870
  return options?.pathOnly ? fullPath : fs$l.readFileSync(fullPath, 'utf-8');
11867
11871
  }
11868
11872
  }
11869
- const parentDir = path$o.dirname(dir);
11873
+ const parentDir = path$n.dirname(dir);
11870
11874
  if (parentDir !== dir &&
11871
11875
  (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
11872
11876
  return lookupFile(parentDir, formats, options);
@@ -11928,7 +11932,7 @@ function generateCodeFrame(source, start = 0, end) {
11928
11932
  const lineLength = lines[j].length;
11929
11933
  if (j === i) {
11930
11934
  // push underline
11931
- const pad = start - (count - lineLength) + 1;
11935
+ const pad = Math.max(start - (count - lineLength) + 1, 0);
11932
11936
  const length = Math.max(1, end > count ? lineLength - pad : end - start);
11933
11937
  res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
11934
11938
  }
@@ -11946,7 +11950,7 @@ function generateCodeFrame(source, start = 0, end) {
11946
11950
  return res.join('\n');
11947
11951
  }
11948
11952
  function writeFile(filename, content) {
11949
- const dir = path$o.dirname(filename);
11953
+ const dir = path$n.dirname(filename);
11950
11954
  if (!fs$l.existsSync(dir)) {
11951
11955
  fs$l.mkdirSync(dir, { recursive: true });
11952
11956
  }
@@ -11976,17 +11980,17 @@ function emptyDir(dir, skip) {
11976
11980
  if (skip?.includes(file)) {
11977
11981
  continue;
11978
11982
  }
11979
- fs$l.rmSync(path$o.resolve(dir, file), { recursive: true, force: true });
11983
+ fs$l.rmSync(path$n.resolve(dir, file), { recursive: true, force: true });
11980
11984
  }
11981
11985
  }
11982
11986
  function copyDir(srcDir, destDir) {
11983
11987
  fs$l.mkdirSync(destDir, { recursive: true });
11984
11988
  for (const file of fs$l.readdirSync(srcDir)) {
11985
- const srcFile = path$o.resolve(srcDir, file);
11989
+ const srcFile = path$n.resolve(srcDir, file);
11986
11990
  if (srcFile === destDir) {
11987
11991
  continue;
11988
11992
  }
11989
- const destFile = path$o.resolve(destDir, file);
11993
+ const destFile = path$n.resolve(destDir, file);
11990
11994
  const stat = fs$l.statSync(srcFile);
11991
11995
  if (stat.isDirectory()) {
11992
11996
  copyDir(srcFile, destFile);
@@ -12010,7 +12014,7 @@ function ensureWatchedFile(watcher, file, root) {
12010
12014
  !file.includes('\0') &&
12011
12015
  fs$l.existsSync(file)) {
12012
12016
  // resolve file to normalized system path
12013
- watcher.add(path$o.resolve(file));
12017
+ watcher.add(path$n.resolve(file));
12014
12018
  }
12015
12019
  }
12016
12020
  const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
@@ -12568,7 +12572,7 @@ function buildReporterPlugin(config) {
12568
12572
  .length / 1024).toFixed(2)} KiB`;
12569
12573
  }
12570
12574
  function printFileInfo(filePath, content, type, maxLength, compressedSize = '') {
12571
- const outDir = normalizePath$3(path$o.relative(config.root, path$o.resolve(config.root, config.build.outDir))) + '/';
12575
+ const outDir = normalizePath$3(path$n.relative(config.root, path$n.resolve(config.root, config.build.outDir))) + '/';
12572
12576
  const kibs = content.length / 1024;
12573
12577
  const sizeColor = kibs > chunkLimit ? picocolors.exports.yellow : picocolors.exports.dim;
12574
12578
  config.logger.info(`${picocolors.exports.gray(picocolors.exports.white(picocolors.exports.dim(outDir)))}${writeColors[type](filePath.padEnd(maxLength + 2))} ${sizeColor(`${kibs.toFixed(2)} KiB${compressedSize}`)}`);
@@ -12580,7 +12584,7 @@ function buildReporterPlugin(config) {
12580
12584
  let transformedCount = 0;
12581
12585
  let chunkCount = 0;
12582
12586
  const logTransform = throttle((id) => {
12583
- writeLine(`transforming (${transformedCount}) ${picocolors.exports.dim(path$o.relative(config.root, id))}`);
12587
+ writeLine(`transforming (${transformedCount}) ${picocolors.exports.dim(path$n.relative(config.root, id))}`);
12584
12588
  });
12585
12589
  return {
12586
12590
  name: 'vite:reporter',
@@ -12735,8 +12739,8 @@ var __spreadValues = (a, b) => {
12735
12739
  };
12736
12740
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
12737
12741
  async function find(filename, options) {
12738
- let dir = path$n.dirname(path$n.resolve(filename));
12739
- const root = (options == null ? void 0 : options.root) ? path$n.resolve(options.root) : null;
12742
+ let dir = require$$0$4.dirname(require$$0$4.resolve(filename));
12743
+ const root = (options == null ? void 0 : options.root) ? require$$0$4.resolve(options.root) : null;
12740
12744
  while (dir) {
12741
12745
  const tsconfig = await tsconfigInDir(dir, options);
12742
12746
  if (tsconfig) {
@@ -12745,7 +12749,7 @@ async function find(filename, options) {
12745
12749
  if (root === dir) {
12746
12750
  break;
12747
12751
  }
12748
- const parent = path$n.dirname(dir);
12752
+ const parent = require$$0$4.dirname(dir);
12749
12753
  if (parent === dir) {
12750
12754
  break;
12751
12755
  } else {
@@ -12756,7 +12760,7 @@ async function find(filename, options) {
12756
12760
  throw new Error(`no tsconfig file found for ${filename}`);
12757
12761
  }
12758
12762
  async function tsconfigInDir(dir, options) {
12759
- const tsconfig = path$n.join(dir, "tsconfig.json");
12763
+ const tsconfig = require$$0$4.join(dir, "tsconfig.json");
12760
12764
  if (options == null ? void 0 : options.tsConfigPaths) {
12761
12765
  return options.tsConfigPaths.has(tsconfig) ? tsconfig : void 0;
12762
12766
  }
@@ -12773,7 +12777,7 @@ async function tsconfigInDir(dir, options) {
12773
12777
  }
12774
12778
  async function findAll(dir, options) {
12775
12779
  const files = [];
12776
- for await (const tsconfigFile of findTSConfig(path$n.resolve(dir), options)) {
12780
+ for await (const tsconfigFile of findTSConfig(require$$0$4.resolve(dir), options)) {
12777
12781
  files.push(tsconfigFile);
12778
12782
  }
12779
12783
  return files;
@@ -12785,9 +12789,9 @@ async function* findTSConfig(dir, options, visited = /* @__PURE__ */ new Set())
12785
12789
  const dirents = await promises$1.readdir(dir, { withFileTypes: true });
12786
12790
  for (const dirent of dirents) {
12787
12791
  if (dirent.isDirectory() && (!(options == null ? void 0 : options.skip) || !options.skip(dirent.name))) {
12788
- yield* findTSConfig(path$n.resolve(dir, dirent.name), options, visited);
12792
+ yield* findTSConfig(require$$0$4.resolve(dir, dirent.name), options, visited);
12789
12793
  } else if (dirent.isFile() && dirent.name === "tsconfig.json") {
12790
- yield path$n.resolve(dir, dirent.name);
12794
+ yield require$$0$4.resolve(dir, dirent.name);
12791
12795
  }
12792
12796
  }
12793
12797
  } catch (e) {
@@ -12906,18 +12910,18 @@ function stripBom(string) {
12906
12910
  }
12907
12911
  return string;
12908
12912
  }
12909
- var POSIX_SEP_RE = new RegExp("\\" + path$n.posix.sep, "g");
12910
- var NATIVE_SEP_RE = new RegExp("\\" + path$n.sep, "g");
12913
+ var POSIX_SEP_RE = new RegExp("\\" + require$$0$4.posix.sep, "g");
12914
+ var NATIVE_SEP_RE = new RegExp("\\" + require$$0$4.sep, "g");
12911
12915
  var PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map();
12912
12916
  var GLOB_ALL_PATTERN = `**/*`;
12913
12917
  var DEFAULT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
12914
12918
  var DEFAULT_EXTENSIONS_RE_GROUP = `\\.(?:${DEFAULT_EXTENSIONS.map((ext) => ext.substring(1)).join("|")})`;
12915
12919
  new Function("path", "return import(path).then(m => m.default)");
12916
12920
  async function resolveTSConfig(filename) {
12917
- if (path$n.extname(filename) !== ".json") {
12921
+ if (require$$0$4.extname(filename) !== ".json") {
12918
12922
  return;
12919
12923
  }
12920
- const tsconfig = path$n.resolve(filename);
12924
+ const tsconfig = require$$0$4.resolve(filename);
12921
12925
  try {
12922
12926
  const stat = await promises$1.stat(tsconfig);
12923
12927
  if (stat.isFile() || stat.isFIFO()) {
@@ -12931,21 +12935,21 @@ async function resolveTSConfig(filename) {
12931
12935
  throw new Error(`no tsconfig file found for ${filename}`);
12932
12936
  }
12933
12937
  function posix2native(filename) {
12934
- return path$n.posix.sep !== path$n.sep && filename.includes(path$n.posix.sep) ? filename.replace(POSIX_SEP_RE, path$n.sep) : filename;
12938
+ return require$$0$4.posix.sep !== require$$0$4.sep && filename.includes(require$$0$4.posix.sep) ? filename.replace(POSIX_SEP_RE, require$$0$4.sep) : filename;
12935
12939
  }
12936
12940
  function native2posix(filename) {
12937
- return path$n.posix.sep !== path$n.sep && filename.includes(path$n.sep) ? filename.replace(NATIVE_SEP_RE, path$n.posix.sep) : filename;
12941
+ return require$$0$4.posix.sep !== require$$0$4.sep && filename.includes(require$$0$4.sep) ? filename.replace(NATIVE_SEP_RE, require$$0$4.posix.sep) : filename;
12938
12942
  }
12939
12943
  function resolve2posix(dir, filename) {
12940
- if (path$n.sep === path$n.posix.sep) {
12941
- return dir ? path$n.resolve(dir, filename) : path$n.resolve(filename);
12944
+ if (require$$0$4.sep === require$$0$4.posix.sep) {
12945
+ return dir ? require$$0$4.resolve(dir, filename) : require$$0$4.resolve(filename);
12942
12946
  }
12943
- return native2posix(dir ? path$n.resolve(posix2native(dir), posix2native(filename)) : path$n.resolve(posix2native(filename)));
12947
+ return native2posix(dir ? require$$0$4.resolve(posix2native(dir), posix2native(filename)) : require$$0$4.resolve(posix2native(filename)));
12944
12948
  }
12945
12949
  function resolveReferencedTSConfigFiles(result) {
12946
- const dir = path$n.dirname(result.tsconfigFile);
12950
+ const dir = require$$0$4.dirname(result.tsconfigFile);
12947
12951
  return result.tsconfig.references.map((ref) => {
12948
- const refPath = ref.path.endsWith(".json") ? ref.path : path$n.join(ref.path, "tsconfig.json");
12952
+ const refPath = ref.path.endsWith(".json") ? ref.path : require$$0$4.join(ref.path, "tsconfig.json");
12949
12953
  return resolve2posix(dir, refPath);
12950
12954
  });
12951
12955
  }
@@ -12961,7 +12965,7 @@ function resolveSolutionTSConfig(filename, result) {
12961
12965
  return result;
12962
12966
  }
12963
12967
  function isIncluded(filename, result) {
12964
- const dir = native2posix(path$n.dirname(result.tsconfigFile));
12968
+ const dir = native2posix(require$$0$4.dirname(result.tsconfigFile));
12965
12969
  const files = (result.tsconfig.files || []).map((file) => resolve2posix(dir, file));
12966
12970
  const absoluteFilename = resolve2posix(null, filename);
12967
12971
  if (files.includes(filename)) {
@@ -13088,7 +13092,7 @@ async function parseFile$1(tsconfigFile, cache) {
13088
13092
  const json = toJson(tsconfigJson);
13089
13093
  const result = {
13090
13094
  tsconfigFile,
13091
- tsconfig: normalizeTSConfig(JSON.parse(json), path$n.dirname(tsconfigFile))
13095
+ tsconfig: normalizeTSConfig(JSON.parse(json), require$$0$4.dirname(tsconfigFile))
13092
13096
  };
13093
13097
  cache == null ? void 0 : cache.set(tsconfigFile, result);
13094
13098
  return result;
@@ -13098,7 +13102,7 @@ async function parseFile$1(tsconfigFile, cache) {
13098
13102
  }
13099
13103
  function normalizeTSConfig(tsconfig, dir) {
13100
13104
  var _a;
13101
- if (((_a = tsconfig.compilerOptions) == null ? void 0 : _a.baseUrl) && !path$n.isAbsolute(tsconfig.compilerOptions.baseUrl)) {
13105
+ if (((_a = tsconfig.compilerOptions) == null ? void 0 : _a.baseUrl) && !require$$0$4.isAbsolute(tsconfig.compilerOptions.baseUrl)) {
13102
13106
  tsconfig.compilerOptions.baseUrl = resolve2posix(dir, tsconfig.compilerOptions.baseUrl);
13103
13107
  }
13104
13108
  return tsconfig;
@@ -13140,9 +13144,9 @@ function resolveExtends(extended, from) {
13140
13144
  } catch (e) {
13141
13145
  error = e;
13142
13146
  }
13143
- if (!path$n.isAbsolute(extended) && !extended.startsWith("./") && !extended.startsWith("../")) {
13147
+ if (!require$$0$4.isAbsolute(extended) && !extended.startsWith("./") && !extended.startsWith("../")) {
13144
13148
  try {
13145
- const fallbackExtended = path$n.join(extended, "tsconfig.json");
13149
+ const fallbackExtended = require$$0$4.join(extended, "tsconfig.json");
13146
13150
  return createRequire$2(from).resolve(fallbackExtended);
13147
13151
  } catch (e) {
13148
13152
  error = e;
@@ -13163,7 +13167,7 @@ var EXTENDABLE_KEYS = [
13163
13167
  function extendTSConfig(extending, extended) {
13164
13168
  const extendingConfig = extending.tsconfig;
13165
13169
  const extendedConfig = extended.tsconfig;
13166
- const relativePath = native2posix(path$n.relative(path$n.dirname(extending.tsconfigFile), path$n.dirname(extended.tsconfigFile)));
13170
+ const relativePath = native2posix(require$$0$4.relative(require$$0$4.dirname(extending.tsconfigFile), require$$0$4.dirname(extended.tsconfigFile)));
13167
13171
  for (const key of Object.keys(extendedConfig).filter((key2) => EXTENDABLE_KEYS.includes(key2))) {
13168
13172
  if (key === "compilerOptions") {
13169
13173
  if (!extendingConfig.compilerOptions) {
@@ -13212,10 +13216,10 @@ function rebaseRelative(key, value, prependPath) {
13212
13216
  }
13213
13217
  }
13214
13218
  function rebasePath(value, prependPath) {
13215
- if (path$n.isAbsolute(value)) {
13219
+ if (require$$0$4.isAbsolute(value)) {
13216
13220
  return value;
13217
13221
  } else {
13218
- return path$n.posix.normalize(path$n.posix.join(prependPath, value));
13222
+ return require$$0$4.posix.normalize(require$$0$4.posix.join(prependPath, value));
13219
13223
  }
13220
13224
  }
13221
13225
  var TSConfckParseError = class extends Error {
@@ -13238,7 +13242,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
13238
13242
  if (!loader) {
13239
13243
  // if the id ends with a valid ext, use it (e.g. vue blocks)
13240
13244
  // otherwise, cleanup the query before checking the ext
13241
- const ext = path$o
13245
+ const ext = path$n
13242
13246
  .extname(/\.\w+$/.test(filename) ? filename : cleanUrl(filename))
13243
13247
  .slice(1);
13244
13248
  if (ext === 'cjs' || ext === 'mjs') {
@@ -13547,7 +13551,7 @@ async function loadTsconfigJsonForFile(filename) {
13547
13551
  function reloadOnTsconfigChange(changedFile) {
13548
13552
  // any tsconfig.json that's added in the workspace could be closer to a code file than a previously cached one
13549
13553
  // any json file in the tsconfig cache could have been used to compile ts
13550
- if (path$o.basename(changedFile) === 'tsconfig.json' ||
13554
+ if (path$n.basename(changedFile) === 'tsconfig.json' ||
13551
13555
  (changedFile.endsWith('.json') &&
13552
13556
  tsconfckParseOptions?.cache?.has(changedFile))) {
13553
13557
  server.config.logger.info(`changed tsconfig file detected: ${changedFile} - Clearing cache and forcing full-reload to ensure typescript is compiled with updated config values.`, { clear: server.config.clearScreen, timestamp: true });
@@ -13786,7 +13790,7 @@ var path$h = {};
13786
13790
 
13787
13791
  Object.defineProperty(path$h, "__esModule", { value: true });
13788
13792
  path$h.removeLeadingDotSegment = path$h.escape = path$h.makeAbsolute = path$h.unixify = void 0;
13789
- const path$g = path$n;
13793
+ const path$g = require$$0$4;
13790
13794
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
13791
13795
  const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
13792
13796
  /**
@@ -13992,7 +13996,7 @@ var isGlob$2 = function isGlob(str, options) {
13992
13996
  };
13993
13997
 
13994
13998
  var isGlob$1 = isGlob$2;
13995
- var pathPosixDirname = path$n.posix.dirname;
13999
+ var pathPosixDirname = require$$0$4.posix.dirname;
13996
14000
  var isWin32 = require$$1.platform() === 'win32';
13997
14001
 
13998
14002
  var slash = '/';
@@ -14489,7 +14493,7 @@ var toRegexRange_1 = toRegexRange$1;
14489
14493
  * Licensed under the MIT License.
14490
14494
  */
14491
14495
 
14492
- const util$2 = require$$0$5;
14496
+ const util$2 = require$$0$6;
14493
14497
  const toRegexRange = toRegexRange_1;
14494
14498
 
14495
14499
  const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
@@ -15452,7 +15456,7 @@ braces$2.create = (input, options = {}) => {
15452
15456
 
15453
15457
  var braces_1 = braces$2;
15454
15458
 
15455
- const util$1 = require$$0$5;
15459
+ const util$1 = require$$0$6;
15456
15460
  const braces$1 = braces_1;
15457
15461
  const picomatch$2 = picomatch$4.exports;
15458
15462
  const utils$b = utils$k;
@@ -15920,7 +15924,7 @@ var micromatch_1 = micromatch$1;
15920
15924
 
15921
15925
  Object.defineProperty(pattern$1, "__esModule", { value: true });
15922
15926
  pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
15923
- const path$f = path$n;
15927
+ const path$f = require$$0$4;
15924
15928
  const globParent$1 = globParent$2;
15925
15929
  const micromatch = micromatch_1;
15926
15930
  const GLOBSTAR$1 = '**';
@@ -16096,7 +16100,7 @@ var stream$4 = {};
16096
16100
  * Copyright (c) 2014-2020 Teambition
16097
16101
  * Licensed under the MIT license.
16098
16102
  */
16099
- const Stream = require$$0$6;
16103
+ const Stream = require$$0$7;
16100
16104
  const PassThrough = Stream.PassThrough;
16101
16105
  const slice = Array.prototype.slice;
16102
16106
 
@@ -16839,7 +16843,7 @@ var fs$b = {};
16839
16843
  } (fs$b));
16840
16844
 
16841
16845
  Object.defineProperty(settings$2, "__esModule", { value: true });
16842
- const path$d = path$n;
16846
+ const path$d = require$$0$4;
16843
16847
  const fsStat$3 = out$3;
16844
16848
  const fs$a = fs$b;
16845
16849
  class Settings$1 {
@@ -17251,7 +17255,7 @@ class Reader$1 {
17251
17255
  reader$1.default = Reader$1;
17252
17256
 
17253
17257
  Object.defineProperty(async$2, "__esModule", { value: true });
17254
- const events_1 = require$$0$4;
17258
+ const events_1 = require$$0$5;
17255
17259
  const fsScandir$2 = out$1;
17256
17260
  const fastq = queue.exports;
17257
17261
  const common$5 = common$7;
@@ -17380,7 +17384,7 @@ function callSuccessCallback(callback, entries) {
17380
17384
  var stream$1 = {};
17381
17385
 
17382
17386
  Object.defineProperty(stream$1, "__esModule", { value: true });
17383
- const stream_1$5 = require$$0$6;
17387
+ const stream_1$5 = require$$0$7;
17384
17388
  const async_1$2 = async$2;
17385
17389
  class StreamProvider {
17386
17390
  constructor(_root, _settings) {
@@ -17493,7 +17497,7 @@ sync$4.default = SyncProvider;
17493
17497
  var settings$1 = {};
17494
17498
 
17495
17499
  Object.defineProperty(settings$1, "__esModule", { value: true });
17496
- const path$c = path$n;
17500
+ const path$c = require$$0$4;
17497
17501
  const fsScandir = out$1;
17498
17502
  class Settings {
17499
17503
  constructor(_options = {}) {
@@ -17555,7 +17559,7 @@ function getSettings(settingsOrOptions = {}) {
17555
17559
  var reader = {};
17556
17560
 
17557
17561
  Object.defineProperty(reader, "__esModule", { value: true });
17558
- const path$b = path$n;
17562
+ const path$b = require$$0$4;
17559
17563
  const fsStat$2 = out$3;
17560
17564
  const utils$6 = utils$g;
17561
17565
  class Reader {
@@ -17588,7 +17592,7 @@ class Reader {
17588
17592
  reader.default = Reader;
17589
17593
 
17590
17594
  Object.defineProperty(stream$2, "__esModule", { value: true });
17591
- const stream_1$3 = require$$0$6;
17595
+ const stream_1$3 = require$$0$7;
17592
17596
  const fsStat$1 = out$3;
17593
17597
  const fsWalk$1 = out$2;
17594
17598
  const reader_1$1 = reader;
@@ -17908,7 +17912,7 @@ class EntryTransformer {
17908
17912
  entry.default = EntryTransformer;
17909
17913
 
17910
17914
  Object.defineProperty(provider, "__esModule", { value: true });
17911
- const path$a = path$n;
17915
+ const path$a = require$$0$4;
17912
17916
  const deep_1 = deep;
17913
17917
  const entry_1 = entry$1;
17914
17918
  const error_1 = error$2;
@@ -17986,7 +17990,7 @@ async$6.default = ProviderAsync;
17986
17990
  var stream = {};
17987
17991
 
17988
17992
  Object.defineProperty(stream, "__esModule", { value: true });
17989
- const stream_1$1 = require$$0$6;
17993
+ const stream_1$1 = require$$0$7;
17990
17994
  const stream_2 = stream$2;
17991
17995
  const provider_1$1 = provider;
17992
17996
  class ProviderStream extends provider_1$1.default {
@@ -18220,7 +18224,7 @@ var dist = {};
18220
18224
  (function (exports) {
18221
18225
  Object.defineProperty(exports, "__esModule", { value: true });
18222
18226
  exports.lilconfigSync = exports.lilconfig = exports.defaultLoaders = void 0;
18223
- const path = path$n;
18227
+ const path = require$$0$4;
18224
18228
  const fs = require$$0__default;
18225
18229
  const os = require$$1;
18226
18230
  const fsReadFileAsync = fs.promises.readFile;
@@ -25697,7 +25701,7 @@ var browser$1 = {
25697
25701
  var require$$3 = /*@__PURE__*/getAugmentedNamespace(browser$1);
25698
25702
 
25699
25703
  // eslint-disable-next-line n/no-deprecated-api
25700
- const { createRequire, createRequireFromPath } = require$$0$7;
25704
+ const { createRequire, createRequireFromPath } = require$$0$8;
25701
25705
 
25702
25706
  function req$2 (name, rootFile) {
25703
25707
  const create = createRequire || createRequireFromPath;
@@ -25837,8 +25841,8 @@ const plugins = (config, file) => {
25837
25841
 
25838
25842
  var plugins_1 = plugins;
25839
25843
 
25840
- const resolve$1 = path$n.resolve;
25841
- const url$4 = require$$0$8;
25844
+ const resolve$1 = require$$0$4.resolve;
25845
+ const url$4 = require$$0$9;
25842
25846
 
25843
25847
  const config$1 = dist;
25844
25848
  const yaml = require$$3;
@@ -27095,7 +27099,7 @@ async function injectSourcesContent(map, file, logger) {
27095
27099
  let sourceRoot;
27096
27100
  try {
27097
27101
  // The source root is undefined for virtual modules and permission errors.
27098
- sourceRoot = await promises$2.realpath(path$o.resolve(path$o.dirname(file), map.sourceRoot || ''));
27102
+ sourceRoot = await promises$2.realpath(path$n.resolve(path$n.dirname(file), map.sourceRoot || ''));
27099
27103
  }
27100
27104
  catch { }
27101
27105
  const missingSources = [];
@@ -27103,7 +27107,7 @@ async function injectSourcesContent(map, file, logger) {
27103
27107
  if (sourcePath && !virtualSourceRE.test(sourcePath)) {
27104
27108
  sourcePath = decodeURI(sourcePath);
27105
27109
  if (sourceRoot) {
27106
- sourcePath = path$o.resolve(sourceRoot, sourcePath);
27110
+ sourcePath = path$n.resolve(sourceRoot, sourcePath);
27107
27111
  }
27108
27112
  return promises$2.readFile(sourcePath, 'utf-8').catch(() => {
27109
27113
  missingSources.push(sourcePath);
@@ -33286,7 +33290,7 @@ function assetPlugin(config) {
33286
33290
  let s;
33287
33291
  const toRelative = (filename, importer) => {
33288
33292
  return {
33289
- runtime: `new URL(${JSON.stringify(path$o.posix.relative(path$o.dirname(importer), filename))},import.meta.url).href`
33293
+ runtime: `new URL(${JSON.stringify(path$n.posix.relative(path$n.dirname(importer), filename))},import.meta.url).href`
33290
33294
  };
33291
33295
  };
33292
33296
  // Urls added with JS using e.g.
@@ -33353,7 +33357,7 @@ function checkPublicFile(url, { publicDir }) {
33353
33357
  if (!publicDir || !url.startsWith('/')) {
33354
33358
  return;
33355
33359
  }
33356
- const publicFile = path$o.join(publicDir, cleanUrl(url));
33360
+ const publicFile = path$n.join(publicDir, cleanUrl(url));
33357
33361
  if (fs$l.existsSync(publicFile)) {
33358
33362
  return publicFile;
33359
33363
  }
@@ -33377,12 +33381,12 @@ function fileToDevUrl(id, config) {
33377
33381
  }
33378
33382
  else if (id.startsWith(config.root)) {
33379
33383
  // in project root, infer short public path
33380
- rtn = '/' + path$o.posix.relative(config.root, id);
33384
+ rtn = '/' + path$n.posix.relative(config.root, id);
33381
33385
  }
33382
33386
  else {
33383
33387
  // outside of project root, use absolute fs path
33384
33388
  // (this is special handled by the serve static middleware
33385
- rtn = path$o.posix.join(FS_PREFIX + id);
33389
+ rtn = path$n.posix.join(FS_PREFIX + id);
33386
33390
  }
33387
33391
  const origin = config.server?.origin ?? '';
33388
33392
  const devBase = config.base;
@@ -33393,7 +33397,7 @@ function getAssetFilename(hash, config) {
33393
33397
  }
33394
33398
  function resolveAssetFileNames(config) {
33395
33399
  const output = config.build?.rollupOptions?.output;
33396
- const defaultAssetFileNames = path$o.posix.join(config.build.assetsDir, '[name].[hash][extname]');
33400
+ const defaultAssetFileNames = path$n.posix.join(config.build.assetsDir, '[name].[hash][extname]');
33397
33401
  // Steps to determine which assetFileNames will be actually used.
33398
33402
  // First, if output is an object or string, use assetFileNames in it.
33399
33403
  // And a default assetFileNames as fallback.
@@ -33429,10 +33433,10 @@ function resolveAssetFileNames(config) {
33429
33433
  * @returns output filename
33430
33434
  */
33431
33435
  function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
33432
- const basename = path$o.basename(file);
33436
+ const basename = path$n.basename(file);
33433
33437
  // placeholders for `assetFileNames`
33434
33438
  // `hash` is slightly different from the rollup's one
33435
- const extname = path$o.extname(basename);
33439
+ const extname = path$n.extname(basename);
33436
33440
  const ext = extname.substring(1);
33437
33441
  const name = basename.slice(0, -extname.length);
33438
33442
  const hash = contentHash;
@@ -33524,7 +33528,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
33524
33528
  }
33525
33529
  const emittedSet = emittedHashMap.get(config);
33526
33530
  if (!emittedSet.has(contentHash)) {
33527
- const name = normalizePath$3(path$o.relative(config.root, file));
33531
+ const name = normalizePath$3(path$n.relative(config.root, file));
33528
33532
  pluginContext.emitFile({
33529
33533
  name,
33530
33534
  fileName,
@@ -33543,8 +33547,8 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
33543
33547
  return publicFileToBuiltUrl(url, config);
33544
33548
  }
33545
33549
  const file = url.startsWith('/')
33546
- ? path$o.join(config.root, url)
33547
- : path$o.join(path$o.dirname(importer), url);
33550
+ ? path$n.join(config.root, url)
33551
+ : path$n.join(path$n.dirname(importer), url);
33548
33552
  return fileToBuiltUrl(file, config, pluginContext,
33549
33553
  // skip public check since we just did it above
33550
33554
  true);
@@ -33671,7 +33675,7 @@ const debug$d = createDebugger('vite:resolve-details', {
33671
33675
  });
33672
33676
  function invalidatePackageData(packageCache, pkgPath) {
33673
33677
  packageCache.delete(pkgPath);
33674
- const pkgDir = path$o.dirname(pkgPath);
33678
+ const pkgDir = path$n.dirname(pkgPath);
33675
33679
  packageCache.forEach((pkg, cacheKey) => {
33676
33680
  if (pkg.dir === pkgDir) {
33677
33681
  packageCache.delete(cacheKey);
@@ -33716,7 +33720,7 @@ function loadPackageData(pkgPath, preserveSymlinks, packageCache) {
33716
33720
  return cached;
33717
33721
  }
33718
33722
  const data = JSON.parse(fs$l.readFileSync(pkgPath, 'utf-8'));
33719
- const pkgDir = path$o.dirname(pkgPath);
33723
+ const pkgDir = path$n.dirname(pkgPath);
33720
33724
  const { sideEffects } = data;
33721
33725
  let hasSideEffects;
33722
33726
  if (typeof sideEffects === 'boolean') {
@@ -33798,10 +33802,10 @@ function resolvePlugin(resolveOptions) {
33798
33802
  return {
33799
33803
  name: 'vite:resolve',
33800
33804
  async resolveId(id, importer, resolveOpts) {
33805
+ const ssr = resolveOpts?.ssr === true;
33801
33806
  // We need to delay depsOptimizer until here instead of passing it as an option
33802
33807
  // the resolvePlugin because the optimizer is created on server listen during dev
33803
- const depsOptimizer = resolveOptions.getDepsOptimizer?.();
33804
- const ssr = resolveOpts?.ssr === true;
33808
+ const depsOptimizer = resolveOptions.getDepsOptimizer?.({ ssr });
33805
33809
  if (id.startsWith(browserExternalId)) {
33806
33810
  return id;
33807
33811
  }
@@ -33833,7 +33837,7 @@ function resolvePlugin(resolveOptions) {
33833
33837
  if (asSrc && depsOptimizer?.isOptimizedDepUrl(id)) {
33834
33838
  const optimizedPath = id.startsWith(FS_PREFIX)
33835
33839
  ? fsPathFromId(id)
33836
- : normalizePath$3(ensureVolumeInPath(path$o.resolve(root, id.slice(1))));
33840
+ : normalizePath$3(ensureVolumeInPath(path$n.resolve(root, id.slice(1))));
33837
33841
  return optimizedPath;
33838
33842
  }
33839
33843
  // explicit fs paths that starts with /@fs/*
@@ -33848,7 +33852,7 @@ function resolvePlugin(resolveOptions) {
33848
33852
  // URL
33849
33853
  // /foo -> /fs-root/foo
33850
33854
  if (asSrc && id.startsWith('/')) {
33851
- const fsPath = path$o.resolve(root, id.slice(1));
33855
+ const fsPath = path$n.resolve(root, id.slice(1));
33852
33856
  if ((res = tryFsResolve(fsPath, options))) {
33853
33857
  isDebug$4 && debug$c(`[url] ${picocolors.exports.cyan(id)} -> ${picocolors.exports.dim(res)}`);
33854
33858
  return res;
@@ -33857,15 +33861,15 @@ function resolvePlugin(resolveOptions) {
33857
33861
  // relative
33858
33862
  if (id.startsWith('.') ||
33859
33863
  ((preferRelative || importer?.endsWith('.html')) && /^\w/.test(id))) {
33860
- const basedir = importer ? path$o.dirname(importer) : process.cwd();
33861
- const fsPath = path$o.resolve(basedir, id);
33864
+ const basedir = importer ? path$n.dirname(importer) : process.cwd();
33865
+ const fsPath = path$n.resolve(basedir, id);
33862
33866
  // handle browser field mapping for relative imports
33863
33867
  const normalizedFsPath = normalizePath$3(fsPath);
33864
33868
  if (depsOptimizer?.isOptimizedDepFile(normalizedFsPath)) {
33865
33869
  // Optimized files could not yet exist in disk, resolve to the full path
33866
33870
  // Inject the current browserHash version if the path doesn't have one
33867
33871
  if (!normalizedFsPath.match(DEP_VERSION_RE)) {
33868
- const browserHash = optimizedDepInfoFromFile(depsOptimizer.metadata({ ssr }), normalizedFsPath)?.browserHash;
33872
+ const browserHash = optimizedDepInfoFromFile(depsOptimizer.metadata, normalizedFsPath)?.browserHash;
33869
33873
  if (browserHash) {
33870
33874
  return injectQuery(normalizedFsPath, `v=${browserHash}`);
33871
33875
  }
@@ -33925,7 +33929,7 @@ function resolvePlugin(resolveOptions) {
33925
33929
  asSrc &&
33926
33930
  depsOptimizer &&
33927
33931
  !options.scan &&
33928
- (res = await tryOptimizedResolve(depsOptimizer, ssr, id, importer))) {
33932
+ (res = await tryOptimizedResolve(depsOptimizer, id, importer))) {
33929
33933
  return res;
33930
33934
  }
33931
33935
  if (targetWeb &&
@@ -33942,7 +33946,7 @@ function resolvePlugin(resolveOptions) {
33942
33946
  if (ssrNoExternal === true) {
33943
33947
  let message = `Cannot bundle Node.js built-in "${id}"`;
33944
33948
  if (importer) {
33945
- message += ` imported from "${path$o.relative(process.cwd(), importer)}"`;
33949
+ message += ` imported from "${path$n.relative(process.cwd(), importer)}"`;
33946
33950
  }
33947
33951
  message += `. Consider disabling ssr.noExternal or remove the built-in dependency.`;
33948
33952
  this.error(message);
@@ -34063,7 +34067,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
34063
34067
  return;
34064
34068
  }
34065
34069
  if (tryPrefix) {
34066
- const prefixed = `${path$o.dirname(file)}/${tryPrefix}${path$o.basename(file)}`;
34070
+ const prefixed = `${path$n.dirname(file)}/${tryPrefix}${path$n.basename(file)}`;
34067
34071
  return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb);
34068
34072
  }
34069
34073
  }
@@ -34091,7 +34095,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34091
34095
  // first path part (since periods are sadly allowed in package names).
34092
34096
  // At the same time, skip the first path part if it begins with "@"
34093
34097
  // (since "@foo/bar" should be treated as the top-level path).
34094
- if (possiblePkgIds.length ? path$o.extname(part) : part[0] === '@') {
34098
+ if (possiblePkgIds.length ? path$n.extname(part) : part[0] === '@') {
34095
34099
  continue;
34096
34100
  }
34097
34101
  const possiblePkgId = nestedPath.slice(0, slashIndex);
@@ -34102,9 +34106,9 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34102
34106
  basedir = root;
34103
34107
  }
34104
34108
  else if (importer &&
34105
- path$o.isAbsolute(importer) &&
34109
+ path$n.isAbsolute(importer) &&
34106
34110
  fs$l.existsSync(cleanUrl(importer))) {
34107
- basedir = path$o.dirname(importer);
34111
+ basedir = path$n.dirname(importer);
34108
34112
  }
34109
34113
  else {
34110
34114
  basedir = root;
@@ -34152,7 +34156,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34152
34156
  if (!externalize) {
34153
34157
  return resolved;
34154
34158
  }
34155
- const resolvedExt = path$o.extname(resolved.id);
34159
+ const resolvedExt = path$n.extname(resolved.id);
34156
34160
  let resolvedId = id;
34157
34161
  if (isDeepImport) {
34158
34162
  // check ext before externalizing - only externalize
@@ -34160,7 +34164,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34160
34164
  if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) {
34161
34165
  return;
34162
34166
  }
34163
- if (!pkg?.data.exports && path$o.extname(id) !== resolvedExt) {
34167
+ if (!pkg?.data.exports && path$n.extname(id) !== resolvedExt) {
34164
34168
  resolvedId += resolvedExt;
34165
34169
  }
34166
34170
  }
@@ -34197,7 +34201,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34197
34201
  // otherwise we may introduce duplicated modules for externalized files
34198
34202
  // from pre-bundled deps.
34199
34203
  if (!isBuild) {
34200
- const versionHash = depsOptimizer.metadata({ ssr }).browserHash;
34204
+ const versionHash = depsOptimizer.metadata.browserHash;
34201
34205
  if (versionHash && isJsType) {
34202
34206
  resolved = injectQuery(resolved, `v=${versionHash}`);
34203
34207
  }
@@ -34221,12 +34225,9 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34221
34225
  return { id: resolved };
34222
34226
  }
34223
34227
  }
34224
- async function tryOptimizedResolve(depsOptimizer, ssr, id, importer) {
34228
+ async function tryOptimizedResolve(depsOptimizer, id, importer) {
34225
34229
  await depsOptimizer.scanProcessing;
34226
- const metadata = depsOptimizer.metadata({ ssr });
34227
- if (!metadata) {
34228
- return;
34229
- }
34230
+ const metadata = depsOptimizer.metadata;
34230
34231
  const depInfo = optimizedDepInfoFromId(metadata, id);
34231
34232
  if (depInfo) {
34232
34233
  return depsOptimizer.getOptimizedDepId(depInfo);
@@ -34249,7 +34250,7 @@ async function tryOptimizedResolve(depsOptimizer, ssr, id, importer) {
34249
34250
  if (resolvedSrc == null) {
34250
34251
  try {
34251
34252
  // this may throw errors if unable to resolve, e.g. aliased id
34252
- resolvedSrc = normalizePath$3(resolveFrom(id, path$o.dirname(importer)));
34253
+ resolvedSrc = normalizePath$3(resolveFrom(id, path$n.dirname(importer)));
34253
34254
  }
34254
34255
  catch {
34255
34256
  // this is best-effort only so swallow errors
@@ -34295,7 +34296,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
34295
34296
  // the heuristics here is to actually read the browser entry when
34296
34297
  // possible and check for hints of UMD. If it is UMD, prefer "module"
34297
34298
  // instead; Otherwise, assume it's ESM and use it.
34298
- const resolvedBrowserEntry = tryFsResolve(path$o.join(dir, browserEntry), options);
34299
+ const resolvedBrowserEntry = tryFsResolve(path$n.join(dir, browserEntry), options);
34299
34300
  if (resolvedBrowserEntry) {
34300
34301
  const content = fs$l.readFileSync(resolvedBrowserEntry, 'utf-8');
34301
34302
  if ((/typeof exports\s*==/.test(content) &&
@@ -34328,7 +34329,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
34328
34329
  for (let entry of entryPoints) {
34329
34330
  // make sure we don't get scripts when looking for sass
34330
34331
  if (options.mainFields?.[0] === 'sass' &&
34331
- !options.extensions?.includes(path$o.extname(entry))) {
34332
+ !options.extensions?.includes(path$n.extname(entry))) {
34332
34333
  entry = '';
34333
34334
  options.skipPackageJson = true;
34334
34335
  }
@@ -34337,7 +34338,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
34337
34338
  if (targetWeb && isObject$2(browserField)) {
34338
34339
  entry = mapWithBrowserField(entry, browserField) || entry;
34339
34340
  }
34340
- const entryPointPath = path$o.join(dir, entry);
34341
+ const entryPointPath = path$n.join(dir, entry);
34341
34342
  const resolvedEntryPoint = tryFsResolve(entryPointPath, options);
34342
34343
  if (resolvedEntryPoint) {
34343
34344
  isDebug$4 &&
@@ -34397,7 +34398,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
34397
34398
  }
34398
34399
  if (!relativeId) {
34399
34400
  throw new Error(`Package subpath '${relativeId}' is not defined by "exports" in ` +
34400
- `${path$o.join(dir, 'package.json')}.`);
34401
+ `${path$n.join(dir, 'package.json')}.`);
34401
34402
  }
34402
34403
  }
34403
34404
  else if (targetWeb && isObject$2(browserField)) {
@@ -34412,7 +34413,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
34412
34413
  }
34413
34414
  }
34414
34415
  if (relativeId) {
34415
- const resolved = tryFsResolve(path$o.join(dir, relativeId), options, !exportsField, // try index only if no exports field
34416
+ const resolved = tryFsResolve(path$n.join(dir, relativeId), options, !exportsField, // try index only if no exports field
34416
34417
  targetWeb);
34417
34418
  if (resolved) {
34418
34419
  isDebug$4 &&
@@ -34426,10 +34427,10 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
34426
34427
  let res;
34427
34428
  const pkg = importer && idToPkgMap.get(importer);
34428
34429
  if (pkg && isObject$2(pkg.data.browser)) {
34429
- const mapId = isFilePath ? './' + slash$1(path$o.relative(pkg.dir, id)) : id;
34430
+ const mapId = isFilePath ? './' + slash$1(path$n.relative(pkg.dir, id)) : id;
34430
34431
  const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser);
34431
34432
  if (browserMappedPath) {
34432
- const fsPath = path$o.join(pkg.dir, browserMappedPath);
34433
+ const fsPath = path$n.join(pkg.dir, browserMappedPath);
34433
34434
  if ((res = tryFsResolve(fsPath, options))) {
34434
34435
  isDebug$4 &&
34435
34436
  debug$c(`[browser mapped] ${picocolors.exports.cyan(id)} -> ${picocolors.exports.dim(res)}`);
@@ -34455,9 +34456,9 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
34455
34456
  * - Returning `false` means this id is explicitly externalized for browser
34456
34457
  */
34457
34458
  function mapWithBrowserField(relativePathInPkgDir, map) {
34458
- const normalizedPath = path$o.posix.normalize(relativePathInPkgDir);
34459
+ const normalizedPath = path$n.posix.normalize(relativePathInPkgDir);
34459
34460
  for (const key in map) {
34460
- const normalizedKey = path$o.posix.normalize(key);
34461
+ const normalizedKey = path$n.posix.normalize(key);
34461
34462
  if (normalizedPath === normalizedKey ||
34462
34463
  equalWithoutSuffix(normalizedPath, normalizedKey, '.js') ||
34463
34464
  equalWithoutSuffix(normalizedPath, normalizedKey, '/index.js')) {
@@ -34499,7 +34500,7 @@ const externalTypes = [
34499
34500
  'tsx',
34500
34501
  ...KNOWN_ASSET_TYPES
34501
34502
  ];
34502
- function esbuildDepPlugin(qualified, exportsData, config) {
34503
+ function esbuildDepPlugin(qualified, exportsData, config, ssr) {
34503
34504
  // remove optimizable extensions from `externalTypes` list
34504
34505
  const allExternalTypes = config.optimizeDeps.extensions
34505
34506
  ? externalTypes.filter((type) => !config.optimizeDeps.extensions?.includes('.' + type))
@@ -34517,14 +34518,14 @@ function esbuildDepPlugin(qualified, exportsData, config) {
34517
34518
  // explicit resolveDir - this is passed only during yarn pnp resolve for
34518
34519
  // entries
34519
34520
  if (resolveDir) {
34520
- _importer = normalizePath$3(path$o.join(resolveDir, '*'));
34521
+ _importer = normalizePath$3(path$n.join(resolveDir, '*'));
34521
34522
  }
34522
34523
  else {
34523
34524
  // map importer ids to file paths for correct resolution
34524
34525
  _importer = importer in qualified ? qualified[importer] : importer;
34525
34526
  }
34526
34527
  const resolver = kind.startsWith('require') ? _resolveRequire : _resolve;
34527
- return resolver(id, _importer, undefined);
34528
+ return resolver(id, _importer, undefined, ssr);
34528
34529
  };
34529
34530
  const resolveResult = (id, resolved) => {
34530
34531
  if (resolved.startsWith(browserExternalId)) {
@@ -34533,6 +34534,9 @@ function esbuildDepPlugin(qualified, exportsData, config) {
34533
34534
  namespace: 'browser-external'
34534
34535
  };
34535
34536
  }
34537
+ if (ssr && isBuiltin(resolved)) {
34538
+ return;
34539
+ }
34536
34540
  if (isExternalUrl(resolved)) {
34537
34541
  return {
34538
34542
  path: resolved,
@@ -34540,7 +34544,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
34540
34544
  };
34541
34545
  }
34542
34546
  return {
34543
- path: path$o.resolve(resolved)
34547
+ path: path$n.resolve(resolved)
34544
34548
  };
34545
34549
  };
34546
34550
  return {
@@ -34623,10 +34627,10 @@ function esbuildDepPlugin(qualified, exportsData, config) {
34623
34627
  // referenced via relative imports - if we don't separate the proxy and
34624
34628
  // the actual module, esbuild will create duplicated copies of the same
34625
34629
  // module!
34626
- const root = path$o.resolve(config.root);
34630
+ const root = path$n.resolve(config.root);
34627
34631
  build.onLoad({ filter: /.*/, namespace: 'dep' }, ({ path: id }) => {
34628
34632
  const entryFile = qualified[id];
34629
- let relativePath = normalizePath$3(path$o.relative(root, entryFile));
34633
+ let relativePath = normalizePath$3(path$n.relative(root, entryFile));
34630
34634
  if (!relativePath.startsWith('./') &&
34631
34635
  !relativePath.startsWith('../') &&
34632
34636
  relativePath !== '.') {
@@ -35652,7 +35656,7 @@ async function scanImports(config) {
35652
35656
  entries = await globEntries(explicitEntryPatterns, config);
35653
35657
  }
35654
35658
  else if (buildInput) {
35655
- const resolvePath = (p) => path$o.resolve(config.root, p);
35659
+ const resolvePath = (p) => path$n.resolve(config.root, p);
35656
35660
  if (typeof buildInput === 'string') {
35657
35661
  entries = [resolvePath(buildInput)];
35658
35662
  }
@@ -35735,7 +35739,7 @@ const contextRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
35735
35739
  function esbuildScanPlugin(config, container, depImports, missing, entries) {
35736
35740
  const seen = new Map();
35737
35741
  const resolve = async (id, importer) => {
35738
- const key = id + (importer && path$o.dirname(importer));
35742
+ const key = id + (importer && path$n.dirname(importer));
35739
35743
  if (seen.has(key)) {
35740
35744
  return seen.get(key);
35741
35745
  }
@@ -35752,8 +35756,6 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35752
35756
  '@vite/client',
35753
35757
  '@vite/env'
35754
35758
  ];
35755
- const isOptimizable = (id) => OPTIMIZABLE_ENTRY_RE.test(id) ||
35756
- !!config.optimizeDeps.extensions?.some((ext) => id.endsWith(ext));
35757
35759
  const externalUnlessEntry = ({ path }) => ({
35758
35760
  path,
35759
35761
  external: !entries.includes(path)
@@ -35791,7 +35793,8 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35791
35793
  // It is possible for the scanner to scan html types in node_modules.
35792
35794
  // If we can optimize this html type, skip it so it's handled by the
35793
35795
  // bare import resolve, and recorded as optimization dep.
35794
- if (resolved.includes('node_modules') && isOptimizable(resolved))
35796
+ if (resolved.includes('node_modules') &&
35797
+ isOptimizable(resolved, config.optimizeDeps))
35795
35798
  return;
35796
35799
  return {
35797
35800
  path: resolved,
@@ -35911,7 +35914,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35911
35914
  }
35912
35915
  if (resolved.includes('node_modules') || include?.includes(id)) {
35913
35916
  // dependency or forced included, externalize and stop crawling
35914
- if (isOptimizable(resolved)) {
35917
+ if (isOptimizable(resolved, config.optimizeDeps)) {
35915
35918
  depImports[id] = resolved;
35916
35919
  }
35917
35920
  return externalUnlessEntry({ path: id });
@@ -35920,7 +35923,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35920
35923
  const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
35921
35924
  // linked package, keep crawling
35922
35925
  return {
35923
- path: path$o.resolve(resolved),
35926
+ path: path$n.resolve(resolved),
35924
35927
  namespace
35925
35928
  };
35926
35929
  }
@@ -35962,7 +35965,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35962
35965
  }
35963
35966
  const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
35964
35967
  return {
35965
- path: path$o.resolve(cleanUrl(resolved)),
35968
+ path: path$n.resolve(cleanUrl(resolved)),
35966
35969
  namespace
35967
35970
  };
35968
35971
  }
@@ -35975,7 +35978,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
35975
35978
  // presence of import.meta.glob, since it results in import relationships
35976
35979
  // but isn't crawled by esbuild.
35977
35980
  build.onLoad({ filter: JS_TYPES_RE }, ({ path: id }) => {
35978
- let ext = path$o.extname(id).slice(1);
35981
+ let ext = path$n.extname(id).slice(1);
35979
35982
  if (ext === 'mjs')
35980
35983
  ext = 'js';
35981
35984
  let contents = fs$l.readFileSync(id, 'utf-8');
@@ -36017,7 +36020,7 @@ function extractImportPaths(code) {
36017
36020
  }
36018
36021
  function shouldExternalizeDep(resolvedId, rawId) {
36019
36022
  // not a valid file path
36020
- if (!path$o.isAbsolute(resolvedId)) {
36023
+ if (!path$n.isAbsolute(resolvedId)) {
36021
36024
  return true;
36022
36025
  }
36023
36026
  // virtual id
@@ -36167,7 +36170,7 @@ var safeBuffer = {exports: {}};
36167
36170
  /* eslint-disable node/no-deprecated-api */
36168
36171
 
36169
36172
  (function (module, exports) {
36170
- var buffer = require$$0$9;
36173
+ var buffer = require$$0$a;
36171
36174
  var Buffer = buffer.Buffer;
36172
36175
 
36173
36176
  // alternative to using Object.keys for old browsers
@@ -36232,7 +36235,7 @@ var safeBuffer = {exports: {}};
36232
36235
 
36233
36236
  (function (exports) {
36234
36237
  var fs = require$$0__default;
36235
- var path = path$n;
36238
+ var path = require$$0$4;
36236
36239
  var SafeBuffer = safeBuffer.exports;
36237
36240
 
36238
36241
  Object.defineProperty(exports, 'commentRegex', {
@@ -37375,7 +37378,7 @@ function serveStaticMiddleware(dir, server) {
37375
37378
  // also skip internal requests `/@fs/ /@vite-client` etc...
37376
37379
  const cleanedUrl = cleanUrl(req.url);
37377
37380
  if (cleanedUrl.endsWith('/') ||
37378
- path$o.extname(cleanedUrl) === '.html' ||
37381
+ path$n.extname(cleanedUrl) === '.html' ||
37379
37382
  isInternalRequest(req.url)) {
37380
37383
  return next();
37381
37384
  }
@@ -37396,7 +37399,7 @@ function serveStaticMiddleware(dir, server) {
37396
37399
  }
37397
37400
  }
37398
37401
  const resolvedUrl = redirected || url;
37399
- let fileUrl = path$o.resolve(dir, resolvedUrl.replace(/^\//, ''));
37402
+ let fileUrl = path$n.resolve(dir, resolvedUrl.replace(/^\//, ''));
37400
37403
  if (resolvedUrl.endsWith('/') && !fileUrl.endsWith('/')) {
37401
37404
  fileUrl = fileUrl + '/';
37402
37405
  }
@@ -37420,7 +37423,7 @@ function serveRawFsMiddleware(server) {
37420
37423
  // searching based from fs root.
37421
37424
  if (url.startsWith(FS_PREFIX)) {
37422
37425
  // restrict files outside of `fs.allow`
37423
- if (!ensureServingAccess(slash$1(path$o.resolve(fsPathFromId(url))), server, res, next)) {
37426
+ if (!ensureServingAccess(slash$1(path$n.resolve(fsPathFromId(url))), server, res, next)) {
37424
37427
  return;
37425
37428
  }
37426
37429
  url = url.slice(FS_PREFIX.length);
@@ -37571,7 +37574,7 @@ async function doTransform(url, server, options, timestamp) {
37571
37574
  // resolve
37572
37575
  const id = (await pluginContainer.resolveId(url, undefined, { ssr }))?.id || url;
37573
37576
  const result = loadAndTransform(id, url, server, options, timestamp);
37574
- const depsOptimizer = getDepsOptimizer(config);
37577
+ const depsOptimizer = getDepsOptimizer(config, { ssr });
37575
37578
  if (depsOptimizer && !config.legacy?.devDepsScanner) {
37576
37579
  depsOptimizer.delayDepsOptimizerUntil(id, () => result);
37577
37580
  }
@@ -37613,7 +37616,7 @@ async function loadAndTransform(id, url, server, options, timestamp) {
37613
37616
  if (code) {
37614
37617
  try {
37615
37618
  map = (convertSourceMap.fromSource(code) ||
37616
- convertSourceMap.fromMapFileSource(code, path$o.dirname(file)))?.toObject();
37619
+ convertSourceMap.fromMapFileSource(code, path$n.dirname(file)))?.toObject();
37617
37620
  }
37618
37621
  catch (e) {
37619
37622
  logger.warn(`Failed to load source map for ${url}.`, {
@@ -37696,28 +37699,28 @@ const isDebugEnabled$1 = _debug('vite:deps').enabled;
37696
37699
  */
37697
37700
  const debounceMs = 100;
37698
37701
  const depsOptimizerMap = new WeakMap();
37699
- function getDepsOptimizer(config) {
37702
+ const devSsrDepsOptimizerMap = new WeakMap();
37703
+ function getDepsOptimizer(config, type) {
37700
37704
  // Workers compilation shares the DepsOptimizer from the main build
37701
- return depsOptimizerMap.get(config.mainConfig || config);
37705
+ const isDevSsr = type.ssr && config.command !== 'build';
37706
+ return (isDevSsr ? devSsrDepsOptimizerMap : depsOptimizerMap).get(config.mainConfig || config);
37702
37707
  }
37703
37708
  async function initDepsOptimizer(config, server) {
37709
+ await createDepsOptimizer(config, server);
37710
+ }
37711
+ async function initDevSsrDepsOptimizer(config) {
37712
+ await createDevSsrDepsOptimizer(config);
37713
+ }
37714
+ async function createDepsOptimizer(config, server) {
37704
37715
  const { logger } = config;
37705
37716
  const isBuild = config.command === 'build';
37706
37717
  const scan = config.command !== 'build' && config.legacy?.devDepsScanner;
37707
37718
  const sessionTimestamp = Date.now().toString();
37708
37719
  const cachedMetadata = loadCachedDepOptimizationMetadata(config);
37709
37720
  let handle;
37710
- let ssrServerDepsMetadata;
37711
- let _metadata = cachedMetadata || initDepsOptimizerMetadata(config, sessionTimestamp);
37721
+ let metadata = cachedMetadata || initDepsOptimizerMetadata(config, sessionTimestamp);
37712
37722
  const depsOptimizer = {
37713
- metadata: (options) => {
37714
- if (isBuild || !options.ssr) {
37715
- return _metadata;
37716
- }
37717
- else {
37718
- return ssrServerDepsMetadata;
37719
- }
37720
- },
37723
+ metadata,
37721
37724
  registerMissingImport,
37722
37725
  run: () => debouncedProcessing(0),
37723
37726
  isOptimizedDepFile: (id) => isOptimizedDepFile(id, config),
@@ -37730,9 +37733,6 @@ async function initDepsOptimizer(config, server) {
37730
37733
  options: config.optimizeDeps
37731
37734
  };
37732
37735
  depsOptimizerMap.set(config, depsOptimizer);
37733
- if (!isBuild && config.ssr) {
37734
- ssrServerDepsMetadata = await optimizeServerSsrDeps(config);
37735
- }
37736
37736
  let newDepsDiscovered = false;
37737
37737
  let newDepsToLog = [];
37738
37738
  let newDepsToLogHandle;
@@ -37763,7 +37763,6 @@ async function initDepsOptimizer(config, server) {
37763
37763
  if (!scan) {
37764
37764
  // Initialize discovered deps with manually added optimizeDeps.include info
37765
37765
  const discovered = await initialProjectDependencies(config, sessionTimestamp);
37766
- const metadata = _metadata;
37767
37766
  for (const depInfo of Object.values(discovered)) {
37768
37767
  addOptimizedDepInfo(metadata, 'discovered', {
37769
37768
  ...depInfo,
@@ -37779,7 +37778,6 @@ async function initDepsOptimizer(config, server) {
37779
37778
  setTimeout(async () => {
37780
37779
  try {
37781
37780
  debuggerViteDeps(picocolors.exports.green(`scanning for dependencies...`));
37782
- const metadata = _metadata;
37783
37781
  const discovered = await discoverProjectDependencies(config, sessionTimestamp);
37784
37782
  // Respect the scan phase discover order to improve reproducibility
37785
37783
  for (const depInfo of Object.values(discovered)) {
@@ -37811,7 +37809,7 @@ async function initDepsOptimizer(config, server) {
37811
37809
  // Ensure that a rerun will not be issued for current discovered deps
37812
37810
  if (handle)
37813
37811
  clearTimeout(handle);
37814
- if (Object.keys(_metadata.discovered).length === 0) {
37812
+ if (Object.keys(metadata.discovered).length === 0) {
37815
37813
  currentlyProcessing = false;
37816
37814
  return;
37817
37815
  }
@@ -37823,7 +37821,6 @@ async function initDepsOptimizer(config, server) {
37823
37821
  // dependencies have changed.
37824
37822
  // if the rerun fails, _metadata remains untouched, current discovered
37825
37823
  // deps are cleaned, and a fullReload is issued
37826
- let metadata = _metadata;
37827
37824
  // All deps, previous known and newly discovered are rebundled,
37828
37825
  // respect insertion order to keep the metadata file stable
37829
37826
  const newDeps = {};
@@ -37903,7 +37900,7 @@ async function initDepsOptimizer(config, server) {
37903
37900
  if (isRerun) {
37904
37901
  newDepsToLog.push(...Object.keys(newData.optimized).filter((dep) => !metadata.optimized[dep]));
37905
37902
  }
37906
- metadata = _metadata = newData;
37903
+ metadata = depsOptimizer.metadata = newData;
37907
37904
  resolveEnqueuedProcessingPromises();
37908
37905
  };
37909
37906
  if (!needsReload) {
@@ -37975,7 +37972,7 @@ async function initDepsOptimizer(config, server) {
37975
37972
  // debounce time to wait for new missing deps finished, issue a new
37976
37973
  // optimization of deps (both old and newly found) once the previous
37977
37974
  // optimizeDeps processing is finished
37978
- const deps = Object.keys(_metadata.discovered);
37975
+ const deps = Object.keys(metadata.discovered);
37979
37976
  const depsString = depsLogString(deps);
37980
37977
  debuggerViteDeps(picocolors.exports.green(`new dependencies found: ${depsString}`));
37981
37978
  runOptimizer();
@@ -37990,7 +37987,6 @@ async function initDepsOptimizer(config, server) {
37990
37987
  if (!isBuild && ssr) {
37991
37988
  config.logger.error(`Error: ${id} is a missing dependency in SSR dev server, it needs to be added to optimizeDeps.include`);
37992
37989
  }
37993
- const metadata = _metadata;
37994
37990
  const optimized = metadata.optimized[id];
37995
37991
  if (optimized) {
37996
37992
  return optimized;
@@ -38070,7 +38066,7 @@ async function initDepsOptimizer(config, server) {
38070
38066
  if (!firstRunEnsured && !firstRunCalled && registeredIds.length === 0) {
38071
38067
  setTimeout(() => {
38072
38068
  if (!firstRunCalled && registeredIds.length === 0) {
38073
- getDepsOptimizer(config)?.run();
38069
+ debouncedProcessing(0); // queue the optimizer run
38074
38070
  }
38075
38071
  }, runOptimizerIfIdleAfterMs);
38076
38072
  }
@@ -38109,7 +38105,7 @@ async function initDepsOptimizer(config, server) {
38109
38105
  runOptimizerWhenIdle();
38110
38106
  }
38111
38107
  else {
38112
- getDepsOptimizer(config)?.run();
38108
+ debouncedProcessing(0); // queue the optimizer run
38113
38109
  }
38114
38110
  }
38115
38111
  };
@@ -38122,7 +38118,27 @@ async function initDepsOptimizer(config, server) {
38122
38118
  }
38123
38119
  }
38124
38120
  }
38125
- return depsOptimizer;
38121
+ }
38122
+ async function createDevSsrDepsOptimizer(config) {
38123
+ const metadata = await optimizeServerSsrDeps(config);
38124
+ const depsOptimizer = {
38125
+ metadata,
38126
+ isOptimizedDepFile: (id) => isOptimizedDepFile(id, config),
38127
+ isOptimizedDepUrl: createIsOptimizedDepUrl(config),
38128
+ getOptimizedDepId: (depInfo) => `${depInfo.file}?v=${depInfo.browserHash}`,
38129
+ registerMissingImport: () => {
38130
+ throw new Error('Vite Internal Error: registerMissingImport is not supported in dev SSR');
38131
+ },
38132
+ // noop, there is no scanning during dev SSR
38133
+ // the optimizer blocks the server start
38134
+ run: () => { },
38135
+ registerWorkersSource: (id) => { },
38136
+ delayDepsOptimizerUntil: (id, done) => { },
38137
+ resetRegisteredIds: () => { },
38138
+ ensureFirstRun: () => { },
38139
+ options: config.optimizeDeps
38140
+ };
38141
+ devSsrDepsOptimizerMap.set(config, depsOptimizer);
38126
38142
  }
38127
38143
  async function preTransformOptimizeDepsEntries(server) {
38128
38144
  const { config } = server;
@@ -38139,7 +38155,7 @@ async function preTransformOptimizeDepsEntries(server) {
38139
38155
  for (const entry of explicitEntries) {
38140
38156
  const url = entry.startsWith(root + '/')
38141
38157
  ? entry.slice(root.length)
38142
- : path$o.posix.join(FS_PREFIX + entry);
38158
+ : path$n.posix.join(FS_PREFIX + entry);
38143
38159
  transformRequest(url, server, { ssr: false }).catch((e) => {
38144
38160
  config.logger.error(e.message);
38145
38161
  });
@@ -38217,14 +38233,14 @@ function loadCachedDepOptimizationMetadata(config, force = config.optimizeDeps.f
38217
38233
  const log = asCommand ? config.logger.info : debug$a;
38218
38234
  // Before Vite 2.9, dependencies were cached in the root of the cacheDir
38219
38235
  // For compat, we remove the cache if we find the old structure
38220
- if (fs$l.existsSync(path$o.join(config.cacheDir, '_metadata.json'))) {
38236
+ if (fs$l.existsSync(path$n.join(config.cacheDir, '_metadata.json'))) {
38221
38237
  emptyDir(config.cacheDir);
38222
38238
  }
38223
38239
  const depsCacheDir = getDepsCacheDir(config, ssr);
38224
38240
  if (!force) {
38225
38241
  let cachedMetadata;
38226
38242
  try {
38227
- const cachedMetadataPath = path$o.join(depsCacheDir, '_metadata.json');
38243
+ const cachedMetadataPath = path$n.join(depsCacheDir, '_metadata.json');
38228
38244
  cachedMetadata = parseDepsOptimizerMetadata(fs$l.readFileSync(cachedMetadataPath, 'utf-8'), depsCacheDir);
38229
38245
  }
38230
38246
  catch (e) { }
@@ -38317,7 +38333,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38317
38333
  }
38318
38334
  // a hint for Node.js
38319
38335
  // all files in the cache directory should be recognized as ES modules
38320
- writeFile(path$o.resolve(processingCacheDir, 'package.json'), JSON.stringify({ type: 'module' }));
38336
+ writeFile(path$n.resolve(processingCacheDir, 'package.json'), JSON.stringify({ type: 'module' }));
38321
38337
  const metadata = initDepsOptimizerMetadata(config);
38322
38338
  metadata.browserHash = getOptimizedBrowserHash(metadata.hash, depsFromOptimizedDepInfo(depsInfo));
38323
38339
  // We prebundle dependencies with esbuild and cache them, but there is no need
@@ -38376,6 +38392,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38376
38392
  ? '__vite_process_env_NODE_ENV'
38377
38393
  : JSON.stringify(process.env.NODE_ENV || config.mode)
38378
38394
  };
38395
+ const platform = ssr && config.ssr?.target !== 'webworker' ? 'node' : 'browser';
38379
38396
  const start = performance.now();
38380
38397
  const result = await build$3({
38381
38398
  absWorkingDir: process.cwd(),
@@ -38384,11 +38401,15 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38384
38401
  // We can't use platform 'neutral', as esbuild has custom handling
38385
38402
  // when the platform is 'node' or 'browser' that can't be emulated
38386
38403
  // by using mainFields and conditions
38387
- platform: config.build.ssr && config.ssr?.target !== 'webworker'
38388
- ? 'node'
38389
- : 'browser',
38404
+ platform,
38390
38405
  define,
38391
38406
  format: 'esm',
38407
+ // See https://github.com/evanw/esbuild/issues/1921#issuecomment-1152991694
38408
+ banner: platform === 'node'
38409
+ ? {
38410
+ js: `import { createRequire } from 'module';const require = createRequire(import.meta.url);`
38411
+ }
38412
+ : undefined,
38392
38413
  target: isBuild ? config.build.target || undefined : ESBUILD_MODULES_TARGET,
38393
38414
  external: config.optimizeDeps?.exclude,
38394
38415
  logLevel: 'error',
@@ -38399,7 +38420,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38399
38420
  metafile: true,
38400
38421
  plugins: [
38401
38422
  ...plugins,
38402
- esbuildDepPlugin(flatIdDeps, flatIdToExports, config)
38423
+ esbuildDepPlugin(flatIdDeps, flatIdToExports, config, ssr)
38403
38424
  ],
38404
38425
  ...esbuildOptions,
38405
38426
  supported: {
@@ -38410,7 +38431,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38410
38431
  });
38411
38432
  const meta = result.metafile;
38412
38433
  // the paths in `meta.outputs` are relative to `process.cwd()`
38413
- const processingCacheDirOutputPath = path$o.relative(process.cwd(), processingCacheDir);
38434
+ const processingCacheDirOutputPath = path$n.relative(process.cwd(), processingCacheDir);
38414
38435
  for (const id in depsInfo) {
38415
38436
  const output = esbuildOutputFromId(meta.outputs, id, processingCacheDir);
38416
38437
  const { exportsData, ...info } = depsInfo[id];
@@ -38427,7 +38448,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38427
38448
  }
38428
38449
  for (const o of Object.keys(meta.outputs)) {
38429
38450
  if (!o.match(jsMapExtensionRE)) {
38430
- const id = path$o
38451
+ const id = path$n
38431
38452
  .relative(processingCacheDirOutputPath, o)
38432
38453
  .replace(jsExtensionRE, '');
38433
38454
  const file = getOptimizedDepPath(id, resolvedConfig, ssr);
@@ -38441,7 +38462,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
38441
38462
  }
38442
38463
  }
38443
38464
  }
38444
- const dataPath = path$o.join(processingCacheDir, '_metadata.json');
38465
+ const dataPath = path$n.join(processingCacheDir, '_metadata.json');
38445
38466
  writeFile(dataPath, stringifyDepsOptimizerMetadata(metadata, depsCacheDir));
38446
38467
  debug$a(`deps bundled in ${(performance.now() - start).toFixed(2)}ms`);
38447
38468
  return processingResult;
@@ -38451,18 +38472,23 @@ async function findKnownImports(config) {
38451
38472
  await addManuallyIncludedOptimizeDeps(deps, config);
38452
38473
  return Object.keys(deps);
38453
38474
  }
38454
- async function addManuallyIncludedOptimizeDeps(deps, config, extra, filter) {
38455
- const include = [...(config.optimizeDeps?.include ?? []), ...(extra ?? [])];
38456
- if (include) {
38475
+ async function addManuallyIncludedOptimizeDeps(deps, config, extra = [], filter) {
38476
+ const optimizeDepsInclude = config.optimizeDeps?.include ?? [];
38477
+ if (optimizeDepsInclude.length || extra.length) {
38457
38478
  const resolve = config.createResolver({ asSrc: false, scan: true });
38458
- for (const id of include) {
38479
+ for (const id of [...optimizeDepsInclude, ...extra]) {
38459
38480
  // normalize 'foo >bar` as 'foo > bar' to prevent same id being added
38460
38481
  // and for pretty printing
38461
38482
  const normalizedId = normalizeId(id);
38462
38483
  if (!deps[normalizedId] && filter?.(normalizedId) !== false) {
38463
38484
  const entry = await resolve(id);
38464
38485
  if (entry) {
38465
- deps[normalizedId] = entry;
38486
+ if (isOptimizable(entry, config.optimizeDeps)) {
38487
+ deps[normalizedId] = entry;
38488
+ }
38489
+ else if (optimizeDepsInclude.includes(id)) {
38490
+ config.logger.warn(`Cannot optimize included dependency: ${picocolors.exports.cyan(id)}`);
38491
+ }
38466
38492
  }
38467
38493
  else {
38468
38494
  throw new Error(`Failed to resolve force included dependency: ${picocolors.exports.cyan(id)}`);
@@ -38483,7 +38509,7 @@ function depsFromOptimizedDepInfo(depsInfo) {
38483
38509
  return Object.fromEntries(Object.entries(depsInfo).map((d) => [d[0], d[1].src]));
38484
38510
  }
38485
38511
  function getOptimizedDepPath(id, config, ssr = !!config.build.ssr) {
38486
- return normalizePath$3(path$o.resolve(getDepsCacheDir(config, ssr), flattenId(id) + '.js'));
38512
+ return normalizePath$3(path$n.resolve(getDepsCacheDir(config, ssr), flattenId(id) + '.js'));
38487
38513
  }
38488
38514
  function getDepsCacheSuffix(config, ssr) {
38489
38515
  let suffix = '';
@@ -38505,7 +38531,7 @@ function getProcessingDepsCacheDir(config, ssr) {
38505
38531
  return (getDepsCacheDirPrefix(config) + getDepsCacheSuffix(config, ssr) + '_temp');
38506
38532
  }
38507
38533
  function getDepsCacheDirPrefix(config) {
38508
- return normalizePath$3(path$o.resolve(config.cacheDir, 'deps'));
38534
+ return normalizePath$3(path$n.resolve(config.cacheDir, 'deps'));
38509
38535
  }
38510
38536
  function isOptimizedDepFile(id, config) {
38511
38537
  return id.startsWith(getDepsCacheDirPrefix(config));
@@ -38514,7 +38540,7 @@ function createIsOptimizedDepUrl(config) {
38514
38540
  const { root } = config;
38515
38541
  const depsCacheDir = getDepsCacheDirPrefix(config);
38516
38542
  // determine the url prefix of files inside cache directory
38517
- const depsCacheDirRelative = normalizePath$3(path$o.relative(root, depsCacheDir));
38543
+ const depsCacheDirRelative = normalizePath$3(path$n.relative(root, depsCacheDir));
38518
38544
  const depsCacheDirPrefix = depsCacheDirRelative.startsWith('../')
38519
38545
  ? // if the cache directory is outside root, the url prefix would be something
38520
38546
  // like '/@fs/absolute/path/to/node_modules/.vite'
@@ -38531,7 +38557,7 @@ function parseDepsOptimizerMetadata(jsonMetadata, depsCacheDir) {
38531
38557
  // Paths can be absolute or relative to the deps cache dir where
38532
38558
  // the _metadata.json is located
38533
38559
  if (key === 'file' || key === 'src') {
38534
- return normalizePath$3(path$o.resolve(depsCacheDir, value));
38560
+ return normalizePath$3(path$n.resolve(depsCacheDir, value));
38535
38561
  }
38536
38562
  return value;
38537
38563
  });
@@ -38590,14 +38616,14 @@ function stringifyDepsOptimizerMetadata(metadata, depsCacheDir) {
38590
38616
  // Paths can be absolute or relative to the deps cache dir where
38591
38617
  // the _metadata.json is located
38592
38618
  if (key === 'file' || key === 'src') {
38593
- return normalizePath$3(path$o.relative(depsCacheDir, value));
38619
+ return normalizePath$3(path$n.relative(depsCacheDir, value));
38594
38620
  }
38595
38621
  return value;
38596
38622
  }, 2);
38597
38623
  }
38598
38624
  function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
38599
38625
  const flatId = flattenId(id) + '.js';
38600
- return outputs[normalizePath$3(path$o.relative(process.cwd(), path$o.join(cacheDirOutputPath, flatId)))];
38626
+ return outputs[normalizePath$3(path$n.relative(process.cwd(), path$n.join(cacheDirOutputPath, flatId)))];
38601
38627
  }
38602
38628
  async function extractExportsData(filePath, config) {
38603
38629
  await init;
@@ -38626,7 +38652,7 @@ async function extractExportsData(filePath, config) {
38626
38652
  parseResult = parse$b(entryContent);
38627
38653
  }
38628
38654
  catch {
38629
- const loader = esbuildOptions.loader?.[path$o.extname(filePath)] || 'jsx';
38655
+ const loader = esbuildOptions.loader?.[path$n.extname(filePath)] || 'jsx';
38630
38656
  debug$a(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
38631
38657
  const transformed = await transformWithEsbuild(entryContent, filePath, {
38632
38658
  loader
@@ -38764,6 +38790,7 @@ var index$1 = {
38764
38790
  optimizedDepInfoFromFile: optimizedDepInfoFromFile,
38765
38791
  optimizedDepNeedsInterop: optimizedDepNeedsInterop,
38766
38792
  initDepsOptimizer: initDepsOptimizer,
38793
+ initDevSsrDepsOptimizer: initDevSsrDepsOptimizer,
38767
38794
  getDepsOptimizer: getDepsOptimizer
38768
38795
  };
38769
38796
 
@@ -38958,12 +38985,12 @@ pathToFileURL$1(process.cwd());
38958
38985
  const debugHmr = createDebugger('vite:hmr');
38959
38986
  const normalizedClientDir = normalizePath$3(CLIENT_DIR);
38960
38987
  function getShortName(file, root) {
38961
- return file.startsWith(root + '/') ? path$o.posix.relative(root, file) : file;
38988
+ return file.startsWith(root + '/') ? path$n.posix.relative(root, file) : file;
38962
38989
  }
38963
38990
  async function handleHMRUpdate(file, server) {
38964
38991
  const { ws, config, moduleGraph } = server;
38965
38992
  const shortFile = getShortName(file, config.root);
38966
- const fileName = path$o.basename(file);
38993
+ const fileName = path$n.basename(file);
38967
38994
  const isConfig = file === config.configFile;
38968
38995
  const isConfigDependency = config.configFileDependencies.some((name) => file === name);
38969
38996
  const isEnv = config.inlineConfig.envFile !== false &&
@@ -38971,7 +38998,7 @@ async function handleHMRUpdate(file, server) {
38971
38998
  if (isConfig || isConfigDependency || isEnv) {
38972
38999
  // auto restart server
38973
39000
  debugHmr(`[config change] ${picocolors.exports.dim(shortFile)}`);
38974
- config.logger.info(picocolors.exports.green(`${path$o.relative(process.cwd(), file)} changed, restarting server...`), { clear: true, timestamp: true });
39001
+ config.logger.info(picocolors.exports.green(`${path$n.relative(process.cwd(), file)} changed, restarting server...`), { clear: true, timestamp: true });
38975
39002
  try {
38976
39003
  await server.restart();
38977
39004
  }
@@ -39018,7 +39045,7 @@ async function handleHMRUpdate(file, server) {
39018
39045
  type: 'full-reload',
39019
39046
  path: config.server.middlewareMode
39020
39047
  ? '*'
39021
- : '/' + normalizePath$3(path$o.relative(config.root, file))
39048
+ : '/' + normalizePath$3(path$n.relative(config.root, file))
39022
39049
  });
39023
39050
  }
39024
39051
  else {
@@ -39059,16 +39086,19 @@ function updateModules(file, modules, timestamp, { config, ws }) {
39059
39086
  ws.send({
39060
39087
  type: 'full-reload'
39061
39088
  });
39089
+ return;
39062
39090
  }
39063
- else {
39064
- config.logger.info(updates
39065
- .map(({ path }) => picocolors.exports.green(`hmr update `) + picocolors.exports.dim(path))
39066
- .join('\n'), { clear: true, timestamp: true });
39067
- ws.send({
39068
- type: 'update',
39069
- updates
39070
- });
39091
+ if (updates.length === 0) {
39092
+ debugHmr(picocolors.exports.yellow(`no update happened `) + picocolors.exports.dim(file));
39093
+ return;
39071
39094
  }
39095
+ config.logger.info(updates
39096
+ .map(({ path }) => picocolors.exports.green(`hmr update `) + picocolors.exports.dim(path))
39097
+ .join('\n'), { clear: true, timestamp: true });
39098
+ ws.send({
39099
+ type: 'update',
39100
+ updates
39101
+ });
39072
39102
  }
39073
39103
  async function handleFileAddUnlink(file, server) {
39074
39104
  const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
@@ -39443,7 +39473,7 @@ function createIsSsrExternal(config) {
39443
39473
  return processedIds.get(id);
39444
39474
  }
39445
39475
  const external = !id.startsWith('.') &&
39446
- !path$o.isAbsolute(id) &&
39476
+ !path$n.isAbsolute(id) &&
39447
39477
  (isBuiltin(id) || (isConfiguredAsExternal(id) && isValidPackageEntry(id)));
39448
39478
  processedIds.set(id, external);
39449
39479
  return external;
@@ -39489,7 +39519,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
39489
39519
  ssrExternals.add(id);
39490
39520
  }
39491
39521
  else {
39492
- depsToTrace.add(path$o.dirname(pkgPath));
39522
+ depsToTrace.add(path$n.dirname(pkgPath));
39493
39523
  }
39494
39524
  continue;
39495
39525
  }
@@ -39505,7 +39535,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
39505
39535
  // trace the dependencies of linked packages
39506
39536
  else if (!esmEntry.includes('node_modules')) {
39507
39537
  const pkgPath = resolveFrom(`${id}/package.json`, root);
39508
- depsToTrace.add(path$o.dirname(pkgPath));
39538
+ depsToTrace.add(path$n.dirname(pkgPath));
39509
39539
  }
39510
39540
  // has separate esm/require entry, assume require entry is cjs
39511
39541
  else if (esmEntry !== requireEntry) {
@@ -39548,7 +39578,7 @@ function cjsShouldExternalizeForSSR(id, externals) {
39548
39578
  }
39549
39579
  // deep imports, check ext before externalizing - only externalize
39550
39580
  // extension-less imports and explicit .js imports
39551
- if (id.startsWith(e + '/') && (!path$o.extname(id) || id.endsWith('.js'))) {
39581
+ if (id.startsWith(e + '/') && (!path$n.extname(id) || id.endsWith('.js'))) {
39552
39582
  return true;
39553
39583
  }
39554
39584
  });
@@ -39573,8 +39603,8 @@ const debug$8 = createDebugger('vite:optimize-deps');
39573
39603
  function optimizedDepsPlugin(config) {
39574
39604
  return {
39575
39605
  name: 'vite:optimized-deps',
39576
- async resolveId(id) {
39577
- if (getDepsOptimizer(config)?.isOptimizedDepFile(id)) {
39606
+ async resolveId(id, source, { ssr }) {
39607
+ if (getDepsOptimizer(config, { ssr })?.isOptimizedDepFile(id)) {
39578
39608
  return id;
39579
39609
  }
39580
39610
  },
@@ -39582,53 +39612,51 @@ function optimizedDepsPlugin(config) {
39582
39612
  // The logic to register an id to wait until it is processed
39583
39613
  // is in importAnalysis, see call to delayDepsOptimizerUntil
39584
39614
  async load(id, options) {
39585
- const ssr = options?.ssr ?? false;
39586
- const depsOptimizer = getDepsOptimizer(config);
39615
+ const ssr = options?.ssr === true;
39616
+ const depsOptimizer = getDepsOptimizer(config, { ssr });
39587
39617
  if (depsOptimizer?.isOptimizedDepFile(id)) {
39588
- const metadata = depsOptimizer?.metadata({ ssr });
39589
- if (metadata) {
39590
- const file = cleanUrl(id);
39591
- const versionMatch = id.match(DEP_VERSION_RE);
39592
- const browserHash = versionMatch
39593
- ? versionMatch[1].split('=')[1]
39594
- : undefined;
39595
- // Search in both the currently optimized and newly discovered deps
39596
- const info = optimizedDepInfoFromFile(metadata, file);
39597
- if (info) {
39598
- if (browserHash && info.browserHash !== browserHash) {
39599
- throwOutdatedRequest(id);
39600
- }
39601
- try {
39602
- // This is an entry point, it may still not be bundled
39603
- await info.processing;
39604
- }
39605
- catch {
39606
- // If the refresh has not happened after timeout, Vite considers
39607
- // something unexpected has happened. In this case, Vite
39608
- // returns an empty response that will error.
39609
- throwProcessingError(id);
39610
- return;
39611
- }
39612
- const newMetadata = depsOptimizer.metadata({ ssr });
39613
- if (metadata !== newMetadata) {
39614
- const currentInfo = optimizedDepInfoFromFile(newMetadata, file);
39615
- if (info.browserHash !== currentInfo?.browserHash) {
39616
- throwOutdatedRequest(id);
39617
- }
39618
- }
39618
+ const metadata = depsOptimizer.metadata;
39619
+ const file = cleanUrl(id);
39620
+ const versionMatch = id.match(DEP_VERSION_RE);
39621
+ const browserHash = versionMatch
39622
+ ? versionMatch[1].split('=')[1]
39623
+ : undefined;
39624
+ // Search in both the currently optimized and newly discovered deps
39625
+ const info = optimizedDepInfoFromFile(metadata, file);
39626
+ if (info) {
39627
+ if (browserHash && info.browserHash !== browserHash) {
39628
+ throwOutdatedRequest(id);
39619
39629
  }
39620
- isDebug$2 && debug$8(`load ${picocolors.exports.cyan(file)}`);
39621
- // Load the file from the cache instead of waiting for other plugin
39622
- // load hooks to avoid race conditions, once processing is resolved,
39623
- // we are sure that the file has been properly save to disk
39624
39630
  try {
39625
- return await promises$2.readFile(file, 'utf-8');
39631
+ // This is an entry point, it may still not be bundled
39632
+ await info.processing;
39626
39633
  }
39627
- catch (e) {
39628
- // Outdated non-entry points (CHUNK), loaded after a rerun
39629
- throwOutdatedRequest(id);
39634
+ catch {
39635
+ // If the refresh has not happened after timeout, Vite considers
39636
+ // something unexpected has happened. In this case, Vite
39637
+ // returns an empty response that will error.
39638
+ throwProcessingError(id);
39639
+ return;
39640
+ }
39641
+ const newMetadata = depsOptimizer.metadata;
39642
+ if (metadata !== newMetadata) {
39643
+ const currentInfo = optimizedDepInfoFromFile(newMetadata, file);
39644
+ if (info.browserHash !== currentInfo?.browserHash) {
39645
+ throwOutdatedRequest(id);
39646
+ }
39630
39647
  }
39631
39648
  }
39649
+ isDebug$2 && debug$8(`load ${picocolors.exports.cyan(file)}`);
39650
+ // Load the file from the cache instead of waiting for other plugin
39651
+ // load hooks to avoid race conditions, once processing is resolved,
39652
+ // we are sure that the file has been properly save to disk
39653
+ try {
39654
+ return await promises$2.readFile(file, 'utf-8');
39655
+ }
39656
+ catch (e) {
39657
+ // Outdated non-entry points (CHUNK), loaded after a rerun
39658
+ throwOutdatedRequest(id);
39659
+ }
39632
39660
  }
39633
39661
  }
39634
39662
  };
@@ -39638,31 +39666,33 @@ function optimizedDepsBuildPlugin(config) {
39638
39666
  name: 'vite:optimized-deps-build',
39639
39667
  buildStart() {
39640
39668
  if (!config.isWorker) {
39641
- getDepsOptimizer(config)?.resetRegisteredIds();
39669
+ // This will be run for the current active optimizer, during build
39670
+ // it will be the SSR optimizer if config.build.ssr is defined
39671
+ getDepsOptimizer(config, { ssr: undefined })?.resetRegisteredIds();
39642
39672
  }
39643
39673
  },
39644
- async resolveId(id) {
39645
- if (getDepsOptimizer(config)?.isOptimizedDepFile(id)) {
39674
+ async resolveId(id, importer, { ssr }) {
39675
+ if (getDepsOptimizer(config, { ssr })?.isOptimizedDepFile(id)) {
39646
39676
  return id;
39647
39677
  }
39648
39678
  },
39649
- transform(_code, id) {
39650
- getDepsOptimizer(config)?.delayDepsOptimizerUntil(id, async () => {
39679
+ transform(_code, id, options) {
39680
+ const ssr = options?.ssr === true;
39681
+ getDepsOptimizer(config, { ssr })?.delayDepsOptimizerUntil(id, async () => {
39651
39682
  await this.load({ id });
39652
39683
  });
39653
39684
  },
39654
39685
  async load(id, options) {
39655
- const ssr = options?.ssr ?? false;
39656
- const depsOptimizer = getDepsOptimizer(config);
39657
- const metadata = depsOptimizer?.metadata({ ssr });
39658
- if (!metadata || !depsOptimizer?.isOptimizedDepFile(id)) {
39686
+ const ssr = options?.ssr === true;
39687
+ const depsOptimizer = getDepsOptimizer(config, { ssr });
39688
+ if (!depsOptimizer?.isOptimizedDepFile(id)) {
39659
39689
  return;
39660
39690
  }
39661
39691
  depsOptimizer?.ensureFirstRun();
39662
39692
  const file = cleanUrl(id);
39663
39693
  // Search in both the currently optimized and newly discovered deps
39664
39694
  // If all the inputs are dependencies, we aren't going to get any
39665
- const info = optimizedDepInfoFromFile(metadata, file);
39695
+ const info = optimizedDepInfoFromFile(depsOptimizer.metadata, file);
39666
39696
  if (info) {
39667
39697
  try {
39668
39698
  // This is an entry point, it may still not be bundled
@@ -39792,7 +39822,7 @@ async function extractImportedBindings(id, source, importSpec, importedBindings)
39792
39822
  */
39793
39823
  function importAnalysisPlugin(config) {
39794
39824
  const { root, base } = config;
39795
- const clientPublicPath = path$o.posix.join(base, CLIENT_PUBLIC_PATH);
39825
+ const clientPublicPath = path$n.posix.join(base, CLIENT_PUBLIC_PATH);
39796
39826
  const enablePartialAccept = config.experimental?.hmrPartialAccept;
39797
39827
  let server;
39798
39828
  return {
@@ -39827,12 +39857,12 @@ function importAnalysisPlugin(config) {
39827
39857
  ? `Install @vitejs/plugin-vue to handle .vue files.`
39828
39858
  : maybeJSX
39829
39859
  ? `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
39830
- : `You may need to install appropriate plugins to handle the ${path$o.extname(importer)} file format, or if it's an asset, add "**/*${path$o.extname(importer)}" to \`assetsInclude\` in your configuration.`;
39860
+ : `You may need to install appropriate plugins to handle the ${path$n.extname(importer)} file format, or if it's an asset, add "**/*${path$n.extname(importer)}" to \`assetsInclude\` in your configuration.`;
39831
39861
  this.error(`Failed to parse source for import analysis because the content ` +
39832
39862
  `contains invalid JS syntax. ` +
39833
39863
  msg, e.idx);
39834
39864
  }
39835
- const depsOptimizer = getDepsOptimizer(config);
39865
+ const depsOptimizer = getDepsOptimizer(config, { ssr });
39836
39866
  const { moduleGraph } = server;
39837
39867
  // since we are already in the transform phase of the importer, it must
39838
39868
  // have been loaded so its entry is guaranteed in the module graph.
@@ -39864,7 +39894,7 @@ function importAnalysisPlugin(config) {
39864
39894
  const importedBindings = enablePartialAccept
39865
39895
  ? new Map()
39866
39896
  : null;
39867
- const toAbsoluteUrl = (url) => path$o.posix.resolve(path$o.posix.dirname(importerModule.url), url);
39897
+ const toAbsoluteUrl = (url) => path$n.posix.resolve(path$n.posix.dirname(importerModule.url), url);
39868
39898
  const normalizeUrl = async (url, pos) => {
39869
39899
  if (base !== '/' && url.startsWith(base)) {
39870
39900
  url = url.replace(base, '/');
@@ -39877,8 +39907,7 @@ function importAnalysisPlugin(config) {
39877
39907
  // the dependency needs to be resolved starting from the original source location of the optimized file
39878
39908
  // because starting from node_modules/.vite will not find the dependency if it was not hoisted
39879
39909
  // (that is, if it is under node_modules directory in the package source of the optimized file)
39880
- for (const optimizedModule of depsOptimizer.metadata({ ssr })
39881
- .depInfoList) {
39910
+ for (const optimizedModule of depsOptimizer.metadata.depInfoList) {
39882
39911
  if (!optimizedModule.src)
39883
39912
  continue; // Ignore chunks
39884
39913
  if (optimizedModule.file === importerModule.file) {
@@ -39893,7 +39922,7 @@ function importAnalysisPlugin(config) {
39893
39922
  if (ssr) {
39894
39923
  return [url, url];
39895
39924
  }
39896
- this.error(`Failed to resolve import "${url}" from "${path$o.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
39925
+ this.error(`Failed to resolve import "${url}" from "${path$n.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
39897
39926
  }
39898
39927
  const isRelative = url.startsWith('.');
39899
39928
  const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer);
@@ -39907,7 +39936,7 @@ function importAnalysisPlugin(config) {
39907
39936
  fs$l.existsSync(cleanUrl(resolved.id))) {
39908
39937
  // an optimized deps may not yet exists in the filesystem, or
39909
39938
  // a regular file exists but is out of root: rewrite to absolute /@fs/ paths
39910
- url = path$o.posix.join(FS_PREFIX + resolved.id);
39939
+ url = path$n.posix.join(FS_PREFIX + resolved.id);
39911
39940
  }
39912
39941
  else {
39913
39942
  url = resolved.id;
@@ -39943,7 +39972,8 @@ function importAnalysisPlugin(config) {
39943
39972
  // its last updated timestamp to force the browser to fetch the most
39944
39973
  // up-to-date version of this module.
39945
39974
  try {
39946
- const depModule = await moduleGraph.ensureEntryFromUrl(url, ssr);
39975
+ // delay setting `isSelfAccepting` until the file is actually used (#7870)
39976
+ const depModule = await moduleGraph.ensureEntryFromUrl(url, ssr, canSkipImportAnalysis(url));
39947
39977
  if (depModule.lastHMRTimestamp > 0) {
39948
39978
  url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
39949
39979
  }
@@ -40034,7 +40064,7 @@ function importAnalysisPlugin(config) {
40034
40064
  // The browserHash in resolvedId could be stale in which case there will be a full
40035
40065
  // page reload. We could return a 404 in that case but it is safe to return the request
40036
40066
  const file = cleanUrl(resolvedId); // Remove ?v={hash}
40037
- const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata({ ssr }), file, config);
40067
+ const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata, file, config);
40038
40068
  if (needsInterop === undefined) {
40039
40069
  // Non-entry dynamic imports from dependencies will reach here as there isn't
40040
40070
  // optimize info for them, but they don't need es interop. If the request isn't
@@ -40407,7 +40437,7 @@ function buildImportAnalysisPlugin(config) {
40407
40437
  return null;
40408
40438
  }
40409
40439
  const { root } = config;
40410
- const depsOptimizer = getDepsOptimizer(config);
40440
+ const depsOptimizer = getDepsOptimizer(config, { ssr });
40411
40441
  const normalizeUrl = async (url, pos) => {
40412
40442
  let importerFile = importer;
40413
40443
  if (moduleListContains(config.optimizeDeps?.exclude, url)) {
@@ -40417,8 +40447,7 @@ function buildImportAnalysisPlugin(config) {
40417
40447
  // the dependency needs to be resolved starting from the original source location of the optimized file
40418
40448
  // because starting from node_modules/.vite will not find the dependency if it was not hoisted
40419
40449
  // (that is, if it is under node_modules directory in the package source of the optimized file)
40420
- for (const optimizedModule of depsOptimizer.metadata({ ssr })
40421
- .depInfoList) {
40450
+ for (const optimizedModule of depsOptimizer.metadata.depInfoList) {
40422
40451
  if (!optimizedModule.src)
40423
40452
  continue; // Ignore chunks
40424
40453
  if (optimizedModule.file === importer) {
@@ -40433,7 +40462,7 @@ function buildImportAnalysisPlugin(config) {
40433
40462
  if (ssr) {
40434
40463
  return [url, url];
40435
40464
  }
40436
- this.error(`Failed to resolve import "${url}" from "${path$o.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
40465
+ this.error(`Failed to resolve import "${url}" from "${path$n.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
40437
40466
  }
40438
40467
  // normalize all imports into resolved URLs
40439
40468
  // e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
@@ -40460,12 +40489,9 @@ function buildImportAnalysisPlugin(config) {
40460
40489
  str().prependLeft(expStart, `${preloadMethod}(() => `);
40461
40490
  str().appendRight(expEnd, `,${isModernFlag}?"${preloadMarker}":void 0${relativePreloadUrls ? ',import.meta.url' : ''})`);
40462
40491
  }
40463
- if (!depsOptimizer) {
40464
- continue;
40465
- }
40466
40492
  // static import or valid string in dynamic import
40467
40493
  // If resolvable, let's resolve it
40468
- if (specifier) {
40494
+ if (depsOptimizer && specifier) {
40469
40495
  // skip external / data uri
40470
40496
  if (isExternalUrl(specifier) || isDataUrl(specifier)) {
40471
40497
  continue;
@@ -40476,7 +40502,7 @@ function buildImportAnalysisPlugin(config) {
40476
40502
  if (depsOptimizer.isOptimizedDepFile(resolvedId) &&
40477
40503
  !resolvedId.match(optimizedDepChunkRE)) {
40478
40504
  const file = cleanUrl(resolvedId); // Remove ?v={hash}
40479
- const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata({ ssr }), file, config);
40505
+ const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata, file, config);
40480
40506
  let rewriteDone = false;
40481
40507
  if (needsInterop === undefined) {
40482
40508
  // Non-entry dynamic imports from dependencies will reach here as there isn't
@@ -40499,6 +40525,24 @@ function buildImportAnalysisPlugin(config) {
40499
40525
  }
40500
40526
  }
40501
40527
  }
40528
+ // Differentiate CSS imports that use the default export from those that
40529
+ // do not by injecting a ?used query - this allows us to avoid including
40530
+ // the CSS string when unnecessary (esbuild has trouble tree-shaking
40531
+ // them)
40532
+ if (specifier &&
40533
+ isCSSRequest(specifier) &&
40534
+ // always inject ?used query when it is a dynamic import
40535
+ // because there is no way to check whether the default export is used
40536
+ (source.slice(expStart, start).includes('from') || isDynamicImport) &&
40537
+ // already has ?used query (by import.meta.glob)
40538
+ !specifier.match(/\?used(&|$)/) &&
40539
+ // edge case for package names ending with .css (e.g normalize.css)
40540
+ !(bareImportRE.test(specifier) && !specifier.includes('/'))) {
40541
+ const url = specifier.replace(/\?|$/, (m) => `?used${m ? '&' : ''}`);
40542
+ str().overwrite(start, end, isDynamicImport ? `'${url}'` : url, {
40543
+ contentOnly: true
40544
+ });
40545
+ }
40502
40546
  }
40503
40547
  if (needPreloadHelper &&
40504
40548
  insertPreload &&
@@ -40600,7 +40644,7 @@ function buildImportAnalysisPlugin(config) {
40600
40644
  }
40601
40645
  }
40602
40646
  };
40603
- const normalizedFile = path$o.posix.join(path$o.posix.dirname(chunk.fileName), url);
40647
+ const normalizedFile = path$n.posix.join(path$n.posix.dirname(chunk.fileName), url);
40604
40648
  addDeps(normalizedFile);
40605
40649
  }
40606
40650
  let markerStartPos = code.indexOf(preloadMarkerWithQuote, end);
@@ -40618,7 +40662,7 @@ function buildImportAnalysisPlugin(config) {
40618
40662
  (hasRemovedPureCssChunk && deps.size > 0)
40619
40663
  ? `[${[...deps]
40620
40664
  .map((d) => JSON.stringify(relativePreloadUrls
40621
- ? path$o.relative(path$o.dirname(file), d)
40665
+ ? path$n.relative(path$n.dirname(file), d)
40622
40666
  : d))
40623
40667
  .join(',')}]`
40624
40668
  : `[]`, { contentOnly: true });
@@ -40789,7 +40833,7 @@ const assetAttrsConfig = {
40789
40833
  const isAsyncScriptMap = new WeakMap();
40790
40834
  async function traverseHtml(html, filePath, visitor) {
40791
40835
  // lazy load compiler
40792
- const { parse, transform } = await import('./dep-f32eac6f.js').then(function (n) { return n.c; });
40836
+ const { parse, transform } = await import('./dep-7018da1a.js').then(function (n) { return n.c; });
40793
40837
  // @vue/compiler-core doesn't like lowercase doctypes
40794
40838
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
40795
40839
  try {
@@ -40861,7 +40905,7 @@ function buildHtmlPlugin(config) {
40861
40905
  name: 'vite:build-html',
40862
40906
  async transform(html, id) {
40863
40907
  if (id.endsWith('.html')) {
40864
- const relativeUrlPath = slash$1(path$o.relative(config.root, id));
40908
+ const relativeUrlPath = slash$1(path$n.relative(config.root, id));
40865
40909
  const publicPath = `/${relativeUrlPath}`;
40866
40910
  const publicBase = getBaseInHTML(relativeUrlPath, config);
40867
40911
  const publicToRelative = (filename, importer) => publicBase + filename;
@@ -41133,7 +41177,7 @@ function buildHtmlPlugin(config) {
41133
41177
  return tags;
41134
41178
  };
41135
41179
  for (const [id, html] of processedHtml) {
41136
- const relativeUrlPath = path$o.posix.relative(config.root, id);
41180
+ const relativeUrlPath = path$n.posix.relative(config.root, id);
41137
41181
  const assetsBase = getBaseInHTML(relativeUrlPath, config);
41138
41182
  const toOutputAssetFilePath = (filename) => {
41139
41183
  if (isExternalUrl(filename)) {
@@ -41211,7 +41255,7 @@ function buildHtmlPlugin(config) {
41211
41255
  // all imports from entry have been inlined to html, prevent rollup from outputting it
41212
41256
  delete bundle[chunk.fileName];
41213
41257
  }
41214
- const shortEmitName = path$o.relative(config.root, id);
41258
+ const shortEmitName = path$n.relative(config.root, id);
41215
41259
  this.emitFile({
41216
41260
  type: 'asset',
41217
41261
  fileName: shortEmitName,
@@ -41295,7 +41339,7 @@ function getBaseInHTML(urlRelativePath, config) {
41295
41339
  // Prefer explicit URL if defined for linking to assets and public files from HTML,
41296
41340
  // even when base relative is specified
41297
41341
  return config.base === './' || config.base === ''
41298
- ? path$o.posix.join(path$o.posix.relative(urlRelativePath, '').slice(0, -2), './')
41342
+ ? path$n.posix.join(path$n.posix.relative(urlRelativePath, '').slice(0, -2), './')
41299
41343
  : config.base;
41300
41344
  }
41301
41345
  const headInjectRE = /([ \t]*)<\/head>/i;
@@ -41406,6 +41450,7 @@ const htmlProxyRE = /(\?|&)html-proxy\b/;
41406
41450
  const commonjsProxyRE = /\?commonjs-proxy/;
41407
41451
  const inlineRE = /(\?|&)inline\b/;
41408
41452
  const inlineCSSRE = /(\?|&)inline-css\b/;
41453
+ const usedRE = /(\?|&)used\b/;
41409
41454
  const varRE = /^var\(/i;
41410
41455
  const cssBundleName = 'style.css';
41411
41456
  const isCSSRequest = (request) => cssLangRE.test(request);
@@ -41532,10 +41577,10 @@ function cssPostPlugin(config) {
41532
41577
  return config.build.assetsDir;
41533
41578
  }
41534
41579
  else if (typeof assetFileNames === 'string') {
41535
- return path$o.dirname(assetFileNames);
41580
+ return path$n.dirname(assetFileNames);
41536
41581
  }
41537
41582
  else {
41538
- return path$o.dirname(assetFileNames({
41583
+ return path$n.dirname(assetFileNames({
41539
41584
  name: cssAssetName,
41540
41585
  type: 'asset',
41541
41586
  source: '/* vite internal call, ignore */'
@@ -41586,7 +41631,7 @@ function cssPostPlugin(config) {
41586
41631
  const cssContent = await getContentWithSourcemap(css);
41587
41632
  const devBase = config.base;
41588
41633
  return [
41589
- `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path$o.posix.join(devBase, CLIENT_PUBLIC_PATH))}`,
41634
+ `import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path$n.posix.join(devBase, CLIENT_PUBLIC_PATH))}`,
41590
41635
  `const __vite__id = ${JSON.stringify(id)}`,
41591
41636
  `const __vite__css = ${JSON.stringify(cssContent)}`,
41592
41637
  `__vite__updateStyle(__vite__id, __vite__css)`,
@@ -41611,18 +41656,20 @@ function cssPostPlugin(config) {
41611
41656
  styles.set(id, css);
41612
41657
  }
41613
41658
  let code;
41614
- if (modulesCode) {
41615
- code = modulesCode;
41659
+ if (usedRE.test(id)) {
41660
+ if (modulesCode) {
41661
+ code = modulesCode;
41662
+ }
41663
+ else {
41664
+ let content = css;
41665
+ if (config.build.minify) {
41666
+ content = await minifyCSS(content, config);
41667
+ }
41668
+ code = `export default ${JSON.stringify(content)}`;
41669
+ }
41616
41670
  }
41617
41671
  else {
41618
- let content = css;
41619
- if (config.build.minify) {
41620
- content = await minifyCSS(content, config);
41621
- }
41622
- // marking as pure to make it tree-shakable by minifier
41623
- // but the module itself is still treated as a non tree-shakable module
41624
- // because moduleSideEffects is 'no-treeshake'
41625
- code = `export default /* #__PURE__ */ (() => ${JSON.stringify(content)})()`;
41672
+ code = `export default ''`;
41626
41673
  }
41627
41674
  return {
41628
41675
  code,
@@ -41660,7 +41707,7 @@ function cssPostPlugin(config) {
41660
41707
  : undefined;
41661
41708
  const toRelative = (filename, importer) => {
41662
41709
  // relative base + extracted CSS
41663
- const relativePath = path$o.posix.relative(cssAssetDirname, filename);
41710
+ const relativePath = path$n.posix.relative(cssAssetDirname, filename);
41664
41711
  return relativePath.startsWith('.')
41665
41712
  ? relativePath
41666
41713
  : './' + relativePath;
@@ -41673,7 +41720,7 @@ function cssPostPlugin(config) {
41673
41720
  });
41674
41721
  // resolve public URL from CSS paths
41675
41722
  if (encodedPublicUrls) {
41676
- const relativePathToPublicFromCSS = path$o.posix.relative(cssAssetDirname, '');
41723
+ const relativePathToPublicFromCSS = path$n.posix.relative(cssAssetDirname, '');
41677
41724
  chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
41678
41725
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
41679
41726
  return toOutputFilePathInCss(publicUrl, 'public', cssAssetName, 'css', config, () => `${relativePathToPublicFromCSS}/${publicUrl}`);
@@ -41682,7 +41729,7 @@ function cssPostPlugin(config) {
41682
41729
  return chunkCSS;
41683
41730
  }
41684
41731
  function ensureFileExt(name, ext) {
41685
- return path$o.format({ ...path$o.parse(name), base: undefined, ext });
41732
+ return path$n.format({ ...path$n.parse(name), base: undefined, ext });
41686
41733
  }
41687
41734
  if (config.build.cssCodeSplit) {
41688
41735
  if (isPureCssChunk) {
@@ -41691,9 +41738,9 @@ function cssPostPlugin(config) {
41691
41738
  }
41692
41739
  if (opts.format === 'es' || opts.format === 'cjs') {
41693
41740
  const cssAssetName = chunk.facadeModuleId
41694
- ? normalizePath$3(path$o.relative(config.root, chunk.facadeModuleId))
41741
+ ? normalizePath$3(path$n.relative(config.root, chunk.facadeModuleId))
41695
41742
  : chunk.name;
41696
- const lang = path$o.extname(cssAssetName).slice(1);
41743
+ const lang = path$n.extname(cssAssetName).slice(1);
41697
41744
  const cssFileName = ensureFileExt(cssAssetName, '.css');
41698
41745
  if (chunk.isEntry && isPureCssChunk)
41699
41746
  cssEntryFiles.add(cssAssetName);
@@ -41746,7 +41793,7 @@ function cssPostPlugin(config) {
41746
41793
  // remove empty css chunks and their imports
41747
41794
  if (pureCssChunks.size) {
41748
41795
  const emptyChunkFiles = [...pureCssChunks]
41749
- .map((file) => path$o.basename(file))
41796
+ .map((file) => path$n.basename(file))
41750
41797
  .join('|')
41751
41798
  .replace(/\./g, '\\.');
41752
41799
  const emptyChunkRE = new RegExp(opts.format === 'es'
@@ -41893,15 +41940,15 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
41893
41940
  const postcssOptions = (postcssConfig && postcssConfig.options) || {};
41894
41941
  const postcssPlugins = postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [];
41895
41942
  if (needInlineImport) {
41896
- postcssPlugins.unshift((await import('./dep-3856e872.js').then(function (n) { return n.i; })).default({
41943
+ postcssPlugins.unshift((await import('./dep-41eb528c.js').then(function (n) { return n.i; })).default({
41897
41944
  async resolve(id, basedir) {
41898
41945
  const publicFile = checkPublicFile(id, config);
41899
41946
  if (publicFile) {
41900
41947
  return publicFile;
41901
41948
  }
41902
- const resolved = await atImportResolvers.css(id, path$o.join(basedir, '*'));
41949
+ const resolved = await atImportResolvers.css(id, path$n.join(basedir, '*'));
41903
41950
  if (resolved) {
41904
- return path$o.resolve(resolved);
41951
+ return path$n.resolve(resolved);
41905
41952
  }
41906
41953
  return id;
41907
41954
  }
@@ -41912,7 +41959,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
41912
41959
  logger: config.logger
41913
41960
  }));
41914
41961
  if (isModule) {
41915
- postcssPlugins.unshift((await import('./dep-a4ad4a6b.js').then(function (n) { return n.i; })).default({
41962
+ postcssPlugins.unshift((await import('./dep-be0b8380.js').then(function (n) { return n.i; })).default({
41916
41963
  ...modulesOptions,
41917
41964
  getJSON(cssFileName, _modules, outputFileName) {
41918
41965
  modules = _modules;
@@ -41924,7 +41971,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
41924
41971
  for (const key of getCssResolversKeys(atImportResolvers)) {
41925
41972
  const resolved = await atImportResolvers[key](id);
41926
41973
  if (resolved) {
41927
- return path$o.resolve(resolved);
41974
+ return path$n.resolve(resolved);
41928
41975
  }
41929
41976
  }
41930
41977
  return id;
@@ -41966,7 +42013,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
41966
42013
  else if (message.type === 'dir-dependency') {
41967
42014
  // https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
41968
42015
  const { dir, glob: globPattern = '**' } = message;
41969
- const pattern = out.escapePath(normalizePath$3(path$o.resolve(path$o.dirname(id), dir))) +
42016
+ const pattern = out.escapePath(normalizePath$3(path$n.resolve(path$n.dirname(id), dir))) +
41970
42017
  `/` +
41971
42018
  globPattern;
41972
42019
  const files = out.sync(pattern, {
@@ -42010,14 +42057,14 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
42010
42057
  };
42011
42058
  }
42012
42059
  async function formatPostcssSourceMap(rawMap, file) {
42013
- const inputFileDir = path$o.dirname(file);
42060
+ const inputFileDir = path$n.dirname(file);
42014
42061
  const sources = rawMap.sources.map((source) => {
42015
42062
  const cleanSource = cleanUrl(decodeURIComponent(source));
42016
42063
  // postcss returns virtual files
42017
42064
  if (/^<.+>$/.test(cleanSource)) {
42018
42065
  return `\0${cleanSource}`;
42019
42066
  }
42020
- return normalizePath$3(path$o.resolve(inputFileDir, cleanSource));
42067
+ return normalizePath$3(path$n.resolve(inputFileDir, cleanSource));
42021
42068
  });
42022
42069
  return {
42023
42070
  file,
@@ -42317,7 +42364,7 @@ const scss = async (source, root, options, resolvers) => {
42317
42364
  ? {
42318
42365
  sourceMap: true,
42319
42366
  omitSourceMapUrl: true,
42320
- sourceMapRoot: path$o.dirname(options.filename)
42367
+ sourceMapRoot: path$n.dirname(options.filename)
42321
42368
  }
42322
42369
  : {})
42323
42370
  };
@@ -42360,10 +42407,10 @@ const sass = (source, root, options, aliasResolver) => scss(source, root, {
42360
42407
  * root file as base.
42361
42408
  */
42362
42409
  async function rebaseUrls(file, rootFile, alias) {
42363
- file = path$o.resolve(file); // ensure os-specific flashes
42410
+ file = path$n.resolve(file); // ensure os-specific flashes
42364
42411
  // in the same dir, no need to rebase
42365
- const fileDir = path$o.dirname(file);
42366
- const rootDir = path$o.dirname(rootFile);
42412
+ const fileDir = path$n.dirname(file);
42413
+ const rootDir = path$n.dirname(rootFile);
42367
42414
  if (fileDir === rootDir) {
42368
42415
  return { file };
42369
42416
  }
@@ -42388,8 +42435,8 @@ async function rebaseUrls(file, rootFile, alias) {
42388
42435
  return url;
42389
42436
  }
42390
42437
  }
42391
- const absolute = path$o.resolve(fileDir, url);
42392
- const relative = path$o.relative(rootDir, absolute);
42438
+ const absolute = path$n.resolve(fileDir, url);
42439
+ const relative = path$n.relative(rootDir, absolute);
42393
42440
  return normalizePath$3(relative);
42394
42441
  };
42395
42442
  // fix css imports in less such as `@import "foo.css"`
@@ -42470,7 +42517,7 @@ function createViteLessPlugin(less, rootFile, alias, resolvers) {
42470
42517
  return false;
42471
42518
  }
42472
42519
  async loadFile(filename, dir, opts, env) {
42473
- const resolved = await this.resolvers.less(filename, path$o.join(dir, '*'));
42520
+ const resolved = await this.resolvers.less(filename, path$n.join(dir, '*'));
42474
42521
  if (resolved) {
42475
42522
  const result = await rebaseUrls(resolved, this.rootFile, this.alias);
42476
42523
  let contents;
@@ -42481,7 +42528,7 @@ function createViteLessPlugin(less, rootFile, alias, resolvers) {
42481
42528
  contents = fs$l.readFileSync(resolved, 'utf-8');
42482
42529
  }
42483
42530
  return {
42484
- filename: path$o.resolve(resolved),
42531
+ filename: path$n.resolve(resolved),
42485
42532
  contents
42486
42533
  };
42487
42534
  }
@@ -42506,7 +42553,7 @@ const styl = async (source, root, options) => {
42506
42553
  const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap, '\n');
42507
42554
  // Get preprocessor options.imports dependencies as stylus
42508
42555
  // does not return them with its builtin `.deps()` method
42509
- const importsDeps = (options.imports ?? []).map((dep) => path$o.resolve(dep));
42556
+ const importsDeps = (options.imports ?? []).map((dep) => path$n.resolve(dep));
42510
42557
  try {
42511
42558
  const ref = nodeStylus(content, options);
42512
42559
  if (options.enableSourcemap) {
@@ -42537,7 +42584,7 @@ function formatStylusSourceMap(mapBefore, root) {
42537
42584
  if (!mapBefore)
42538
42585
  return undefined;
42539
42586
  const map = { ...mapBefore };
42540
- const resolveFromRoot = (p) => normalizePath$3(path$o.resolve(root, p));
42587
+ const resolveFromRoot = (p) => normalizePath$3(path$n.resolve(root, p));
42541
42588
  if (map.file) {
42542
42589
  map.file = resolveFromRoot(map.file);
42543
42590
  }
@@ -42590,16 +42637,16 @@ function manifestPlugin(config) {
42590
42637
  generateBundle({ format }, bundle) {
42591
42638
  function getChunkName(chunk) {
42592
42639
  if (chunk.facadeModuleId) {
42593
- let name = normalizePath$3(path$o.relative(config.root, chunk.facadeModuleId));
42640
+ let name = normalizePath$3(path$n.relative(config.root, chunk.facadeModuleId));
42594
42641
  if (format === 'system' && !chunk.name.includes('-legacy')) {
42595
- const ext = path$o.extname(name);
42642
+ const ext = path$n.extname(name);
42596
42643
  const endPos = ext.length !== 0 ? -ext.length : undefined;
42597
42644
  name = name.slice(0, endPos) + `-legacy` + ext;
42598
42645
  }
42599
42646
  return name.replace(/\0/g, '');
42600
42647
  }
42601
42648
  else {
42602
- return `_` + path$o.basename(chunk.fileName);
42649
+ return `_` + path$n.basename(chunk.fileName);
42603
42650
  }
42604
42651
  }
42605
42652
  function getInternalImports(imports) {
@@ -42847,7 +42894,7 @@ function assetImportMetaUrlPlugin(config) {
42847
42894
  }
42848
42895
  }
42849
42896
  const url = rawUrl.slice(1, -1);
42850
- const file = path$o.resolve(path$o.dirname(id), url);
42897
+ const file = path$n.resolve(path$n.dirname(id), url);
42851
42898
  // Get final asset URL. Catch error if the file does not exist,
42852
42899
  // in which we can resort to the initial URL and let it resolve in runtime
42853
42900
  const builtUrl = await fileToUrl(file, config, this).catch(() => {
@@ -43028,7 +43075,7 @@ async function doBuild(inlineConfig = {}) {
43028
43075
  const ssr = !!options.ssr;
43029
43076
  const libOptions = options.lib;
43030
43077
  config.logger.info(picocolors.exports.cyan(`vite v${VERSION} ${picocolors.exports.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
43031
- const resolve = (p) => path$o.resolve(config.root, p);
43078
+ const resolve = (p) => path$n.resolve(config.root, p);
43032
43079
  const input = libOptions
43033
43080
  ? resolve(libOptions.entry)
43034
43081
  : typeof options.ssr === 'string'
@@ -43107,13 +43154,13 @@ async function doBuild(inlineConfig = {}) {
43107
43154
  ? `[name].${jsExt}`
43108
43155
  : libOptions
43109
43156
  ? resolveLibFilename(libOptions, format, config.root, jsExt)
43110
- : path$o.posix.join(options.assetsDir, `[name].[hash].js`),
43157
+ : path$n.posix.join(options.assetsDir, `[name].[hash].js`),
43111
43158
  chunkFileNames: libOptions
43112
43159
  ? `[name].[hash].${jsExt}`
43113
- : path$o.posix.join(options.assetsDir, `[name].[hash].js`),
43160
+ : path$n.posix.join(options.assetsDir, `[name].[hash].js`),
43114
43161
  assetFileNames: libOptions
43115
43162
  ? `[name].[ext]`
43116
- : path$o.posix.join(options.assetsDir, `[name].[hash].[ext]`),
43163
+ : path$n.posix.join(options.assetsDir, `[name].[hash].[ext]`),
43117
43164
  inlineDynamicImports: output.format === 'umd' ||
43118
43165
  output.format === 'iife' ||
43119
43166
  (ssrWorkerBuild && typeof input === 'string'),
@@ -43299,7 +43346,7 @@ function onRollupWarning(warning, warn, config) {
43299
43346
  async function cjsSsrResolveExternal(config, user) {
43300
43347
  // see if we have cached deps data available
43301
43348
  let knownImports;
43302
- const dataPath = path$o.join(getDepsCacheDir(config, false), '_metadata.json');
43349
+ const dataPath = path$n.join(getDepsCacheDir(config, false), '_metadata.json');
43303
43350
  try {
43304
43351
  const data = JSON.parse(fs$l.readFileSync(dataPath, 'utf-8'));
43305
43352
  knownImports = Object.keys(data.optimized);
@@ -44032,7 +44079,7 @@ function requireNode () {
44032
44079
  hasRequiredNode = 1;
44033
44080
  (function (module, exports) {
44034
44081
  var tty = require$$0$3;
44035
- var util = require$$0$5;
44082
+ var util = require$$0$6;
44036
44083
 
44037
44084
  /**
44038
44085
  * This is the Node.js implementation of `debug()`.
@@ -44733,7 +44780,7 @@ var parseurl$1 = {exports: {}};
44733
44780
  * @private
44734
44781
  */
44735
44782
 
44736
- var url$3 = require$$0$8;
44783
+ var url$3 = require$$0$9;
44737
44784
  var parse$9 = url$3.parse;
44738
44785
  var Url = url$3.Url;
44739
44786
 
@@ -45495,7 +45542,7 @@ var utilsMerge = {exports: {}};
45495
45542
  */
45496
45543
 
45497
45544
  var debug$4 = src.exports('connect:dispatcher');
45498
- var EventEmitter$3 = require$$0$4.EventEmitter;
45545
+ var EventEmitter$3 = require$$0$5.EventEmitter;
45499
45546
  var finalhandler = finalhandler_1;
45500
45547
  var http$4 = require$$1$2;
45501
45548
  var merge = utilsMerge.exports;
@@ -46240,9 +46287,9 @@ function vary (res, field) {
46240
46287
  var chokidar = {};
46241
46288
 
46242
46289
  const fs$9 = require$$0__default;
46243
- const { Readable } = require$$0$6;
46244
- const sysPath$3 = path$n;
46245
- const { promisify: promisify$3 } = require$$0$5;
46290
+ const { Readable } = require$$0$7;
46291
+ const sysPath$3 = require$$0$4;
46292
+ const { promisify: promisify$3 } = require$$0$6;
46246
46293
  const picomatch$1 = picomatch$4.exports;
46247
46294
 
46248
46295
  const readdir$1 = promisify$3(fs$9.readdir);
@@ -46933,7 +46980,7 @@ var require$$0 = [
46933
46980
  module.exports = require$$0;
46934
46981
  } (binaryExtensions$1));
46935
46982
 
46936
- const path$9 = path$n;
46983
+ const path$9 = require$$0$4;
46937
46984
  const binaryExtensions = binaryExtensions$1.exports;
46938
46985
 
46939
46986
  const extensions = new Set(binaryExtensions);
@@ -46944,7 +46991,7 @@ var constants$1 = {};
46944
46991
 
46945
46992
  (function (exports) {
46946
46993
 
46947
- const {sep} = path$n;
46994
+ const {sep} = require$$0$4;
46948
46995
  const {platform} = process;
46949
46996
  const os = require$$1;
46950
46997
 
@@ -47010,8 +47057,8 @@ var constants$1 = {};
47010
47057
  } (constants$1));
47011
47058
 
47012
47059
  const fs$8 = require$$0__default;
47013
- const sysPath$2 = path$n;
47014
- const { promisify: promisify$2 } = require$$0$5;
47060
+ const sysPath$2 = require$$0$4;
47061
+ const { promisify: promisify$2 } = require$$0$6;
47015
47062
  const isBinaryPath = isBinaryPath$1;
47016
47063
  const {
47017
47064
  isWindows: isWindows$2,
@@ -47655,8 +47702,8 @@ var nodefsHandler = NodeFsHandler$1;
47655
47702
  var fseventsHandler = {exports: {}};
47656
47703
 
47657
47704
  const fs$7 = require$$0__default;
47658
- const sysPath$1 = path$n;
47659
- const { promisify: promisify$1 } = require$$0$5;
47705
+ const sysPath$1 = require$$0$4;
47706
+ const { promisify: promisify$1 } = require$$0$6;
47660
47707
 
47661
47708
  let fsevents;
47662
47709
  try {
@@ -48177,10 +48224,10 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
48177
48224
  fseventsHandler.exports = FsEventsHandler$1;
48178
48225
  fseventsHandler.exports.canUse = canUse;
48179
48226
 
48180
- const { EventEmitter: EventEmitter$2 } = require$$0$4;
48227
+ const { EventEmitter: EventEmitter$2 } = require$$0$5;
48181
48228
  const fs$6 = require$$0__default;
48182
- const sysPath = path$n;
48183
- const { promisify } = require$$0$5;
48229
+ const sysPath = require$$0$4;
48230
+ const { promisify } = require$$0$6;
48184
48231
  const readdirp = readdirp_1;
48185
48232
  const anymatch = anymatch$2.exports.default;
48186
48233
  const globParent = globParent$2;
@@ -49419,7 +49466,7 @@ var windows$1 = [
49419
49466
  'webstorm64.exe'
49420
49467
  ];
49421
49468
 
49422
- const path$8 = path$n;
49469
+ const path$8 = require$$0$4;
49423
49470
  const shellQuote = shellQuote$1;
49424
49471
  const childProcess$2 = require$$2;
49425
49472
 
@@ -49507,7 +49554,7 @@ var guess = function guessEditor (specifiedEditor) {
49507
49554
  return [null]
49508
49555
  };
49509
49556
 
49510
- const path$7 = path$n;
49557
+ const path$7 = require$$0$4;
49511
49558
 
49512
49559
  // normalize file/line numbers into command line args for specific editors
49513
49560
  var getArgs = function getArgumentsForPosition (
@@ -49579,7 +49626,7 @@ var getArgs = function getArgumentsForPosition (
49579
49626
 
49580
49627
  const fs$5 = require$$0__default;
49581
49628
  const os$2 = require$$1;
49582
- const path$6 = path$n;
49629
+ const path$6 = require$$0$4;
49583
49630
  const colors = picocolors.exports;
49584
49631
  const childProcess$1 = require$$2;
49585
49632
 
@@ -49706,8 +49753,8 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
49706
49753
 
49707
49754
  var launchEditor_1 = launchEditor;
49708
49755
 
49709
- const url$2 = require$$0$8;
49710
- const path$5 = path$n;
49756
+ const url$2 = require$$0$9;
49757
+ const path$5 = require$$0$4;
49711
49758
  const launch = launchEditor_1;
49712
49759
 
49713
49760
  var launchEditorMiddleware = (specifiedEditor, srcRoot, onErrorCallback) => {
@@ -49777,7 +49824,7 @@ async function resolveHttpsConfig(https, cacheDir) {
49777
49824
  function readFileIfExists(value) {
49778
49825
  if (typeof value === 'string') {
49779
49826
  try {
49780
- return fs$l.readFileSync(path$o.resolve(value));
49827
+ return fs$l.readFileSync(path$n.resolve(value));
49781
49828
  }
49782
49829
  catch (e) {
49783
49830
  return value;
@@ -49786,7 +49833,7 @@ function readFileIfExists(value) {
49786
49833
  return value;
49787
49834
  }
49788
49835
  async function getCertificate(cacheDir) {
49789
- const cachePath = path$o.join(cacheDir, '_cert.pem');
49836
+ const cachePath = path$n.join(cacheDir, '_cert.pem');
49790
49837
  try {
49791
49838
  const [stat, content] = await Promise.all([
49792
49839
  promises$2.stat(cachePath),
@@ -49798,7 +49845,7 @@ async function getCertificate(cacheDir) {
49798
49845
  return content;
49799
49846
  }
49800
49847
  catch {
49801
- const content = (await import('./dep-39250386.js')).createCertificate();
49848
+ const content = (await import('./dep-08aefb0c.js')).createCertificate();
49802
49849
  promises$2
49803
49850
  .mkdir(cacheDir, { recursive: true })
49804
49851
  .then(() => promises$2.writeFile(cachePath, content))
@@ -50047,7 +50094,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
50047
50094
  // #3087 dynamic import vars is ignored at rewrite import path,
50048
50095
  // so here need process relative path
50049
50096
  if (dep[0] === '.') {
50050
- dep = path$o.posix.resolve(path$o.dirname(url), dep);
50097
+ dep = path$n.posix.resolve(path$n.dirname(url), dep);
50051
50098
  }
50052
50099
  return ssrImport(dep);
50053
50100
  };
@@ -50103,7 +50150,7 @@ async function nodeImport(id, importer, resolveOptions) {
50103
50150
  // Use the Vite resolver only for bare imports while skipping
50104
50151
  // any absolute paths, built-in modules and binary modules.
50105
50152
  if (!bareImportRE.test(id) ||
50106
- path$o.isAbsolute(id) ||
50153
+ path$n.isAbsolute(id) ||
50107
50154
  isBuiltin(id) ||
50108
50155
  id.endsWith('.node')) {
50109
50156
  return nodeResolve(id, parent, isMain, options);
@@ -50113,7 +50160,7 @@ async function nodeImport(id, importer, resolveOptions) {
50113
50160
  if (resolved) {
50114
50161
  // hookNodeResolve must use platform-specific path.normalize
50115
50162
  // to be compatible with dynamicImport (#6080)
50116
- resolved = path$o.normalize(resolved);
50163
+ resolved = path$n.normalize(resolved);
50117
50164
  }
50118
50165
  return resolved;
50119
50166
  }
@@ -50363,7 +50410,7 @@ class Limiter$1 {
50363
50410
 
50364
50411
  var limiter = Limiter$1;
50365
50412
 
50366
- const zlib = require$$0$a;
50413
+ const zlib = require$$0$b;
50367
50414
 
50368
50415
  const bufferUtil = bufferUtil$1.exports;
50369
50416
  const Limiter = limiter;
@@ -50999,7 +51046,7 @@ if (!process.env.WS_NO_UTF_8_VALIDATE) {
50999
51046
  }
51000
51047
  }
51001
51048
 
51002
- const { Writable: Writable$1 } = require$$0$6;
51049
+ const { Writable: Writable$1 } = require$$0$7;
51003
51050
 
51004
51051
  const PerMessageDeflate$3 = permessageDeflate;
51005
51052
  const {
@@ -52559,13 +52606,13 @@ var extension$1 = { format: format$1, parse: parse$6 };
52559
52606
 
52560
52607
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
52561
52608
 
52562
- const EventEmitter$1 = require$$0$4;
52609
+ const EventEmitter$1 = require$$0$5;
52563
52610
  const https$2 = require$$1$3;
52564
52611
  const http$3 = require$$1$2;
52565
52612
  const net = require$$3$1;
52566
52613
  const tls = require$$4;
52567
52614
  const { randomBytes, createHash: createHash$1 } = require$$5;
52568
- const { URL: URL$2 } = require$$0$8;
52615
+ const { URL: URL$2 } = require$$0$9;
52569
52616
 
52570
52617
  const PerMessageDeflate$1 = permessageDeflate;
52571
52618
  const Receiver = receiver;
@@ -53914,7 +53961,7 @@ var subprotocol$1 = { parse: parse$4 };
53914
53961
 
53915
53962
  /* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */
53916
53963
 
53917
- const EventEmitter = require$$0$4;
53964
+ const EventEmitter = require$$0$5;
53918
53965
  const http$2 = require$$1$2;
53919
53966
  const { createHash } = require$$5;
53920
53967
 
@@ -55064,8 +55111,8 @@ var requiresPort = function required(port, protocol) {
55064
55111
 
55065
55112
  (function (exports) {
55066
55113
  var common = exports,
55067
- url = require$$0$8,
55068
- extend = require$$0$5._extend,
55114
+ url = require$$0$9,
55115
+ extend = require$$0$6._extend,
55069
55116
  required = requiresPort;
55070
55117
 
55071
55118
  var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
@@ -55312,7 +55359,7 @@ var requiresPort = function required(port, protocol) {
55312
55359
  return !!~host.indexOf(':');
55313
55360
  }} (common$3));
55314
55361
 
55315
- var url$1 = require$$0$8,
55362
+ var url$1 = require$$0$9,
55316
55363
  common$2 = common$3;
55317
55364
 
55318
55365
 
@@ -55478,11 +55525,11 @@ var debug_1 = function () {
55478
55525
  debug$3.apply(null, arguments);
55479
55526
  };
55480
55527
 
55481
- var url = require$$0$8;
55528
+ var url = require$$0$9;
55482
55529
  var URL$1 = url.URL;
55483
55530
  var http$1 = require$$1$2;
55484
55531
  var https$1 = require$$1$3;
55485
- var Writable = require$$0$6.Writable;
55532
+ var Writable = require$$0$7.Writable;
55486
55533
  var assert = assert$1;
55487
55534
  var debug$2 = debug_1;
55488
55535
 
@@ -56432,8 +56479,8 @@ var wsIncoming = {
56432
56479
 
56433
56480
  (function (module) {
56434
56481
  var httpProxy = module.exports,
56435
- extend = require$$0$5._extend,
56436
- parse_url = require$$0$8.parse,
56482
+ extend = require$$0$6._extend,
56483
+ parse_url = require$$0$9.parse,
56437
56484
  EE3 = eventemitter3.exports,
56438
56485
  http = require$$1$2,
56439
56486
  https = require$$1$3,
@@ -56542,7 +56589,7 @@ var wsIncoming = {
56542
56589
 
56543
56590
  }
56544
56591
 
56545
- require$$0$5.inherits(ProxyServer, EE3);
56592
+ require$$0$6.inherits(ProxyServer, EE3);
56546
56593
 
56547
56594
  ProxyServer.prototype.onError = function (err) {
56548
56595
  //
@@ -56791,7 +56838,7 @@ var lib$1 = {exports: {}};
56791
56838
 
56792
56839
  (function (module, exports) {
56793
56840
 
56794
- var url = require$$0$8;
56841
+ var url = require$$0$9;
56795
56842
 
56796
56843
  module.exports = function historyApiFallback(options) {
56797
56844
  options = options || {};
@@ -56799,12 +56846,12 @@ var lib$1 = {exports: {}};
56799
56846
 
56800
56847
  return function(req, res, next) {
56801
56848
  var headers = req.headers;
56802
- if (req.method !== 'GET') {
56849
+ if (req.method !== 'GET' && req.method !== 'HEAD') {
56803
56850
  logger(
56804
56851
  'Not rewriting',
56805
56852
  req.method,
56806
56853
  req.url,
56807
- 'because the method is not GET.'
56854
+ 'because the method is not GET or HEAD.'
56808
56855
  );
56809
56856
  return next();
56810
56857
  } else if (!headers || typeof headers.accept !== 'string') {
@@ -56905,6 +56952,7 @@ var lib$1 = {exports: {}};
56905
56952
  if (options && options.logger) {
56906
56953
  return options.logger;
56907
56954
  } else if (options && options.verbose) {
56955
+ // eslint-disable-next-line no-console
56908
56956
  return console.log.bind(console);
56909
56957
  }
56910
56958
  return function(){};
@@ -56922,7 +56970,7 @@ function spaFallbackMiddleware(root) {
56922
56970
  from: /\/$/,
56923
56971
  to({ parsedUrl }) {
56924
56972
  const rewritten = decodeURIComponent(parsedUrl.pathname) + 'index.html';
56925
- if (fs$l.existsSync(path$o.join(root, rewritten))) {
56973
+ if (fs$l.existsSync(path$n.join(root, rewritten))) {
56926
56974
  return rewritten;
56927
56975
  }
56928
56976
  else {
@@ -56995,12 +57043,12 @@ function transformMiddleware(server) {
56995
57043
  const isSourceMap = withoutQuery.endsWith('.map');
56996
57044
  // since we generate source map references, handle those requests here
56997
57045
  if (isSourceMap) {
56998
- if (getDepsOptimizer(server.config)?.isOptimizedDepUrl(url)) {
57046
+ if (getDepsOptimizer(server.config, { ssr: false })?.isOptimizedDepUrl(url)) {
56999
57047
  // If the browser is requesting a source map for an optimized dep, it
57000
57048
  // means that the dependency has already been pre-bundled and loaded
57001
57049
  const mapFile = url.startsWith(FS_PREFIX)
57002
57050
  ? fsPathFromId(url)
57003
- : normalizePath$3(ensureVolumeInPath(path$o.resolve(root, url.slice(1))));
57051
+ : normalizePath$3(ensureVolumeInPath(path$n.resolve(root, url.slice(1))));
57004
57052
  try {
57005
57053
  const map = await promises$2.readFile(mapFile, 'utf-8');
57006
57054
  return send(req, res, map, 'json', {
@@ -57093,7 +57141,7 @@ function transformMiddleware(server) {
57093
57141
  if (result) {
57094
57142
  const type = isDirectCSSRequest(url) ? 'css' : 'js';
57095
57143
  const isDep = DEP_VERSION_RE.test(url) ||
57096
- getDepsOptimizer(server.config)?.isOptimizedDepUrl(url);
57144
+ getDepsOptimizer(server.config, { ssr: false })?.isOptimizedDepUrl(url);
57097
57145
  return send(req, res, result.code, type, {
57098
57146
  etag: result.etag,
57099
57147
  // allow browser to cache npm deps!
@@ -57151,7 +57199,7 @@ function getHtmlFilename(url, server) {
57151
57199
  return decodeURIComponent(fsPathFromId(url));
57152
57200
  }
57153
57201
  else {
57154
- return decodeURIComponent(normalizePath$3(path$o.join(server.config.root, url.slice(1))));
57202
+ return decodeURIComponent(normalizePath$3(path$n.join(server.config.root, url.slice(1))));
57155
57203
  }
57156
57204
  }
57157
57205
  const startsWithSingleSlashRE = /^\/(?!\/)/;
@@ -57172,7 +57220,7 @@ const processNodeUrl = (node, s, config, htmlPath, originalUrl, moduleGraph) =>
57172
57220
  originalUrl &&
57173
57221
  originalUrl !== '/' &&
57174
57222
  htmlPath === '/index.html') {
57175
- const replacer = (url) => path$o.posix.join(devBase, path$o.posix.relative(originalUrl, devBase), url.slice(1));
57223
+ const replacer = (url) => path$n.posix.join(devBase, path$n.posix.relative(originalUrl, devBase), url.slice(1));
57176
57224
  // #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
57177
57225
  // path will add `/a/` prefix, it will caused 404.
57178
57226
  // rewrite before `./index.js` -> `localhost:5173/a/index.js`.
@@ -57279,7 +57327,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
57279
57327
  tag: 'script',
57280
57328
  attrs: {
57281
57329
  type: 'module',
57282
- src: path$o.posix.join(base, CLIENT_PUBLIC_PATH)
57330
+ src: path$n.posix.join(base, CLIENT_PUBLIC_PATH)
57283
57331
  },
57284
57332
  injectTo: 'head-prepend'
57285
57333
  }
@@ -57329,7 +57377,10 @@ function timeMiddleware(root) {
57329
57377
  }
57330
57378
 
57331
57379
  class ModuleNode {
57332
- constructor(url) {
57380
+ /**
57381
+ * @param setIsSelfAccepting - set `false` to set `isSelfAccepting` later. e.g. #7870
57382
+ */
57383
+ constructor(url, setIsSelfAccepting = true) {
57333
57384
  /**
57334
57385
  * Resolved file system path + query
57335
57386
  */
@@ -57348,10 +57399,7 @@ class ModuleNode {
57348
57399
  this.lastInvalidationTimestamp = 0;
57349
57400
  this.url = url;
57350
57401
  this.type = isDirectCSSRequest(url) ? 'css' : 'js';
57351
- // #7870
57352
- // The `isSelfAccepting` value is set by importAnalysis, but some
57353
- // assets don't go through importAnalysis.
57354
- if (isHTMLRequest(url) || canSkipImportAnalysis(url)) {
57402
+ if (setIsSelfAccepting) {
57355
57403
  this.isSelfAccepting = false;
57356
57404
  }
57357
57405
  }
@@ -57450,11 +57498,11 @@ class ModuleGraph {
57450
57498
  mod.importedBindings = importedBindings;
57451
57499
  return noLongerImported;
57452
57500
  }
57453
- async ensureEntryFromUrl(rawUrl, ssr) {
57501
+ async ensureEntryFromUrl(rawUrl, ssr, setIsSelfAccepting = true) {
57454
57502
  const [url, resolvedId, meta] = await this.resolveUrl(rawUrl, ssr);
57455
57503
  let mod = this.urlToModuleMap.get(url);
57456
57504
  if (!mod) {
57457
- mod = new ModuleNode(url);
57505
+ mod = new ModuleNode(url, setIsSelfAccepting);
57458
57506
  if (meta)
57459
57507
  mod.meta = meta;
57460
57508
  this.urlToModuleMap.set(url, mod);
@@ -57590,7 +57638,7 @@ var defineLazyProp = (object, propertyName, fn) => {
57590
57638
  return object;
57591
57639
  };
57592
57640
 
57593
- const path$4 = path$n;
57641
+ const path$4 = require$$0$4;
57594
57642
  const childProcess = require$$2;
57595
57643
  const {promises: fs$2, constants: fsConstants} = require$$0__default;
57596
57644
  const isWsl = isWsl$2.exports;
@@ -58070,7 +58118,7 @@ const isWindows = process.platform === 'win32' ||
58070
58118
  process.env.OSTYPE === 'cygwin' ||
58071
58119
  process.env.OSTYPE === 'msys';
58072
58120
 
58073
- const path$3 = path$n;
58121
+ const path$3 = require$$0$4;
58074
58122
  const COLON = isWindows ? ';' : ':';
58075
58123
  const isexe = isexe_1;
58076
58124
 
@@ -58209,7 +58257,7 @@ pathKey$1.exports = pathKey;
58209
58257
  // TODO: Remove this for the next major release
58210
58258
  pathKey$1.exports.default = pathKey;
58211
58259
 
58212
- const path$2 = path$n;
58260
+ const path$2 = require$$0$4;
58213
58261
  const which = which_1;
58214
58262
  const getPathKey = pathKey$1.exports;
58215
58263
 
@@ -58349,7 +58397,7 @@ function readShebang$1(command) {
58349
58397
 
58350
58398
  var readShebang_1 = readShebang$1;
58351
58399
 
58352
- const path$1 = path$n;
58400
+ const path$1 = require$$0$4;
58353
58401
  const resolveCommand = resolveCommand_1;
58354
58402
  const escape$1 = _escape;
58355
58403
  const readShebang = readShebang_1;
@@ -58682,10 +58730,11 @@ async function createServer(inlineConfig = {}) {
58682
58730
  : await resolveHttpServer(serverConfig, middlewares, httpsOptions);
58683
58731
  const ws = createWebSocketServer(httpServer, config, httpsOptions);
58684
58732
  const { ignored = [], ...watchOptions } = serverConfig.watch || {};
58685
- const watcher = chokidar.watch(path$o.resolve(root), {
58733
+ const watcher = chokidar.watch(path$n.resolve(root), {
58686
58734
  ignored: [
58687
- '**/node_modules/**',
58688
58735
  '**/.git/**',
58736
+ '**/node_modules/**',
58737
+ '**/test-results/**',
58689
58738
  ...(Array.isArray(ignored) ? ignored : [ignored])
58690
58739
  ],
58691
58740
  ignoreInitial: true,
@@ -58697,6 +58746,7 @@ async function createServer(inlineConfig = {}) {
58697
58746
  const container = await createPluginContainer(config, moduleGraph, watcher);
58698
58747
  const closeHttpServer = createServerCloseFn(httpServer);
58699
58748
  let exitProcess;
58749
+ let creatingDevSsrOptimizer = null;
58700
58750
  const server = {
58701
58751
  config,
58702
58752
  middlewares,
@@ -58715,6 +58765,13 @@ async function createServer(inlineConfig = {}) {
58715
58765
  },
58716
58766
  transformIndexHtml: null,
58717
58767
  async ssrLoadModule(url, opts) {
58768
+ if (!getDepsOptimizer(config, { ssr: true })) {
58769
+ if (!creatingDevSsrOptimizer) {
58770
+ creatingDevSsrOptimizer = initDevSsrDepsOptimizer(config);
58771
+ }
58772
+ await creatingDevSsrOptimizer;
58773
+ creatingDevSsrOptimizer = null;
58774
+ }
58718
58775
  await updateCjsSsrExternals(server);
58719
58776
  return ssrLoadModule(url, server, undefined, undefined, opts?.fixStacktrace);
58720
58777
  },
@@ -58935,7 +58992,7 @@ async function startServer(server, inlinePort, isRestart = false) {
58935
58992
  profileSession.post('Profiler.stop', (err, { profile }) => {
58936
58993
  // Write profile to disk, upload, etc.
58937
58994
  if (!err) {
58938
- const outPath = path$o.resolve('./vite-profile.cpuprofile');
58995
+ const outPath = path$n.resolve('./vite-profile.cpuprofile');
58939
58996
  fs$l.writeFileSync(outPath, JSON.stringify(profile));
58940
58997
  info(picocolors.exports.yellow(` CPU profile written to ${picocolors.exports.white(picocolors.exports.dim(outPath))}\n`));
58941
58998
  }
@@ -58985,7 +59042,7 @@ function createServerCloseFn(server) {
58985
59042
  });
58986
59043
  }
58987
59044
  function resolvedAllowDir(root, dir) {
58988
- return normalizePath$3(path$o.resolve(root, dir));
59045
+ return normalizePath$3(path$n.resolve(root, dir));
58989
59046
  }
58990
59047
  function resolveServerOptions(root, raw, logger) {
58991
59048
  const server = {
@@ -59023,7 +59080,7 @@ async function restartServer(server) {
59023
59080
  let inlineConfig = server.config.inlineConfig;
59024
59081
  if (server._forceOptimizeOnRestart) {
59025
59082
  inlineConfig = mergeConfig(inlineConfig, {
59026
- server: {
59083
+ optimizeDeps: {
59027
59084
  force: true
59028
59085
  }
59029
59086
  });
@@ -59066,15 +59123,19 @@ async function restartServer(server) {
59066
59123
  }
59067
59124
  async function updateCjsSsrExternals(server) {
59068
59125
  if (!server._ssrExternals) {
59069
- // We use the non-ssr optimized deps to find known imports
59070
59126
  let knownImports = [];
59071
- const depsOptimizer = getDepsOptimizer(server.config);
59127
+ // Important! We use the non-ssr optimized deps to find known imports
59128
+ // Only the explicitly defined deps are optimized during dev SSR, so
59129
+ // we use the generated list from the scanned deps in regular dev.
59130
+ // This is part of the v2 externalization heuristics and it is kept
59131
+ // for backwards compatibility in case user needs to fallback to the
59132
+ // legacy scheme. It may be removed in a future v3 minor.
59133
+ const depsOptimizer = getDepsOptimizer(server.config, { ssr: false });
59072
59134
  if (depsOptimizer) {
59073
59135
  await depsOptimizer.scanProcessing;
59074
- const metadata = depsOptimizer.metadata({ ssr: false });
59075
59136
  knownImports = [
59076
- ...Object.keys(metadata.optimized),
59077
- ...Object.keys(metadata.discovered)
59137
+ ...Object.keys(depsOptimizer.metadata.optimized),
59138
+ ...Object.keys(depsOptimizer.metadata.discovered)
59078
59139
  ];
59079
59140
  }
59080
59141
  server._ssrExternals = cjsSsrResolveExternals(server.config, knownImports);
@@ -59234,7 +59295,7 @@ async function preview(inlineConfig = {}) {
59234
59295
  app.use(compression());
59235
59296
  const previewBase = config.base === './' || config.base === '' ? '/' : config.base;
59236
59297
  // static assets
59237
- const distDir = path$o.resolve(config.root, config.build.outDir);
59298
+ const distDir = path$n.resolve(config.root, config.build.outDir);
59238
59299
  app.use(previewBase, sirv(distDir, {
59239
59300
  etag: true,
59240
59301
  dev: true,
@@ -59304,7 +59365,7 @@ function clientInjectionsPlugin(config) {
59304
59365
  directTarget += devBase;
59305
59366
  let hmrBase = devBase;
59306
59367
  if (hmrConfig?.path) {
59307
- hmrBase = path$o.posix.join(hmrBase, hmrConfig.path);
59368
+ hmrBase = path$n.posix.join(hmrBase, hmrConfig.path);
59308
59369
  }
59309
59370
  return code
59310
59371
  .replace(`__MODE__`, JSON.stringify(config.mode))
@@ -59452,9 +59513,9 @@ async function bundleWorkerEntry(config, id, query) {
59452
59513
  : workerOutputConfig
59453
59514
  : {};
59454
59515
  const { output: [outputChunk, ...outputChunks] } = await bundle.generate({
59455
- entryFileNames: path$o.posix.join(config.build.assetsDir, '[name].[hash].js'),
59456
- chunkFileNames: path$o.posix.join(config.build.assetsDir, '[name].[hash].js'),
59457
- assetFileNames: path$o.posix.join(config.build.assetsDir, '[name].[hash].[ext]'),
59516
+ entryFileNames: path$n.posix.join(config.build.assetsDir, '[name].[hash].js'),
59517
+ chunkFileNames: path$n.posix.join(config.build.assetsDir, '[name].[hash].js'),
59518
+ assetFileNames: path$n.posix.join(config.build.assetsDir, '[name].[hash].[ext]'),
59458
59519
  ...workerConfig,
59459
59520
  format,
59460
59521
  sourcemap: config.build.sourcemap
@@ -59506,7 +59567,7 @@ function emitSourcemapForWorkerEntry(config, query, chunk) {
59506
59567
  // non-inline web workers can use a relative path
59507
59568
  const sourceMapUrl = query?.inline != null
59508
59569
  ? mapFileName
59509
- : path$o.relative(config.build.assetsDir, mapFileName);
59570
+ : path$n.relative(config.build.assetsDir, mapFileName);
59510
59571
  chunk.code += `//# sourceMappingURL=${sourceMapUrl}`;
59511
59572
  }
59512
59573
  }
@@ -59515,7 +59576,7 @@ function emitSourcemapForWorkerEntry(config, query, chunk) {
59515
59576
  }
59516
59577
  // TODO:base review why we aren't using import.meta.url here
59517
59578
  function toStaticRelativePath(filename, importer) {
59518
- let outputFilepath = path$o.posix.relative(path$o.dirname(importer), filename);
59579
+ let outputFilepath = path$n.posix.relative(path$n.dirname(importer), filename);
59519
59580
  if (!outputFilepath.startsWith('.')) {
59520
59581
  outputFilepath = './' + outputFilepath;
59521
59582
  }
@@ -59573,7 +59634,8 @@ function webWorkerPlugin(config) {
59573
59634
  }
59574
59635
  }
59575
59636
  },
59576
- async transform(raw, id) {
59637
+ async transform(raw, id, options) {
59638
+ const ssr = options?.ssr === true;
59577
59639
  const query = parseRequest(id);
59578
59640
  if (query && query[WORKER_FILE_ID] != null) {
59579
59641
  // if import worker by worker constructor will had query.type
@@ -59617,7 +59679,7 @@ function webWorkerPlugin(config) {
59617
59679
  : 'module';
59618
59680
  const workerOptions = workerType === 'classic' ? '' : ',{type: "module"}';
59619
59681
  if (isBuild) {
59620
- getDepsOptimizer(config)?.registerWorkersSource(id);
59682
+ getDepsOptimizer(config, { ssr })?.registerWorkersSource(id);
59621
59683
  if (query.inline != null) {
59622
59684
  const chunk = await bundleWorkerEntry(config, id, query);
59623
59685
  // inline as blob data url
@@ -59708,10 +59770,10 @@ function preAliasPlugin(config) {
59708
59770
  return {
59709
59771
  name: 'vite:pre-alias',
59710
59772
  async resolveId(id, importer, options) {
59711
- const ssr = options?.ssr ?? false;
59712
- const depsOptimizer = getDepsOptimizer(config);
59773
+ const ssr = options?.ssr === true;
59774
+ const depsOptimizer = getDepsOptimizer(config, { ssr });
59713
59775
  if (depsOptimizer && bareImportRE.test(id) && !options?.scan) {
59714
- return await tryOptimizedResolve(depsOptimizer, ssr, id, importer);
59776
+ return await tryOptimizedResolve(depsOptimizer, id, importer);
59715
59777
  }
59716
59778
  }
59717
59779
  };
@@ -59747,6 +59809,7 @@ function definePlugin(config) {
59747
59809
  // during dev, import.meta properties are handled by importAnalysis plugin.
59748
59810
  // ignore replace import.meta.env in lib build
59749
59811
  const importMetaKeys = {};
59812
+ const importMetaFallbackKeys = {};
59750
59813
  if (isBuild) {
59751
59814
  const env = {
59752
59815
  ...config.env,
@@ -59755,7 +59818,7 @@ function definePlugin(config) {
59755
59818
  for (const key in env) {
59756
59819
  importMetaKeys[`import.meta.env.${key}`] = JSON.stringify(env[key]);
59757
59820
  }
59758
- Object.assign(importMetaKeys, {
59821
+ Object.assign(importMetaFallbackKeys, {
59759
59822
  'import.meta.env.': `({}).`,
59760
59823
  'import.meta.env': JSON.stringify(config.env),
59761
59824
  'import.meta.hot': `false`
@@ -59765,8 +59828,9 @@ function definePlugin(config) {
59765
59828
  const replaceProcessEnv = !ssr || config.ssr?.target === 'webworker';
59766
59829
  const replacements = {
59767
59830
  ...(replaceProcessEnv ? processNodeEnv : {}),
59768
- ...userDefine,
59769
59831
  ...importMetaKeys,
59832
+ ...userDefine,
59833
+ ...importMetaFallbackKeys,
59770
59834
  ...(replaceProcessEnv ? processEnv : {})
59771
59835
  };
59772
59836
  if (isBuild && !replaceProcessEnv) {
@@ -61280,11 +61344,13 @@ function workerImportMetaUrlPlugin(config) {
61280
61344
  return {
61281
61345
  name: 'vite:worker-import-meta-url',
61282
61346
  async transform(code, id, options) {
61283
- const query = parseRequest(id);
61284
- let s;
61285
- if ((code.includes('new Worker') || code.includes('new SharedWorker')) &&
61347
+ const ssr = options?.ssr === true;
61348
+ if (!options?.ssr &&
61349
+ (code.includes('new Worker') || code.includes('new SharedWorker')) &&
61286
61350
  code.includes('new URL') &&
61287
61351
  code.includes(`import.meta.url`)) {
61352
+ const query = parseRequest(id);
61353
+ let s;
61288
61354
  const cleanString = stripLiteral(code);
61289
61355
  const workerImportMetaUrlRE = /\bnew\s+(Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/g;
61290
61356
  let match;
@@ -61294,19 +61360,16 @@ function workerImportMetaUrlPlugin(config) {
61294
61360
  const urlStart = cleanString.indexOf(emptyUrl, index);
61295
61361
  const urlEnd = urlStart + emptyUrl.length;
61296
61362
  const rawUrl = code.slice(urlStart, urlEnd);
61297
- if (options?.ssr) {
61298
- this.error(`\`new URL(url, import.meta.url)\` is not supported in SSR.`, urlIndex);
61299
- }
61300
61363
  // potential dynamic template string
61301
61364
  if (rawUrl[0] === '`' && /\$\{/.test(rawUrl)) {
61302
61365
  this.error(`\`new URL(url, import.meta.url)\` is not supported in dynamic template string.`, urlIndex);
61303
61366
  }
61304
61367
  s || (s = new MagicString(code));
61305
61368
  const workerType = getWorkerType(code, cleanString, index + allExp.length);
61306
- const file = normalizePath$3(path$o.resolve(path$o.dirname(id), rawUrl.slice(1, -1)));
61369
+ const file = normalizePath$3(path$n.resolve(path$n.dirname(id), rawUrl.slice(1, -1)));
61307
61370
  let url;
61308
61371
  if (isBuild) {
61309
- getDepsOptimizer(config)?.registerWorkersSource(id);
61372
+ getDepsOptimizer(config, { ssr })?.registerWorkersSource(id);
61310
61373
  url = await workerFileToUrl(config, file, query);
61311
61374
  }
61312
61375
  else {
@@ -61440,7 +61503,7 @@ function dynamicImportToGlob(node, sourceString) {
61440
61503
  );
61441
61504
  }
61442
61505
 
61443
- if (path$n.extname(glob) === '') {
61506
+ if (require$$0$4.extname(glob) === '') {
61444
61507
  throw new VariableDynamicImportError(
61445
61508
  `invalid import "${sourceString}". A file extension must be included in the static part of the import. ${example}`
61446
61509
  );
@@ -61609,7 +61672,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
61609
61672
  packageCache: config.packageCache,
61610
61673
  ssrConfig: config.ssr,
61611
61674
  asSrc: true,
61612
- getDepsOptimizer: () => getDepsOptimizer(config),
61675
+ getDepsOptimizer: (type) => getDepsOptimizer(config, type),
61613
61676
  shouldExternalize: isBuild && config.build.ssr && config.ssr?.format !== 'cjs'
61614
61677
  ? (id) => shouldExternalizeForSSR(id, config)
61615
61678
  : undefined
@@ -61646,7 +61709,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
61646
61709
  var main$1 = {exports: {}};
61647
61710
 
61648
61711
  const fs = require$$0__default;
61649
- const path = path$n;
61712
+ const path = require$$0$4;
61650
61713
  const os = require$$1;
61651
61714
 
61652
61715
  function log (message) {
@@ -61923,7 +61986,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
61923
61986
  }
61924
61987
  const configEnv = {
61925
61988
  mode,
61926
- command
61989
+ command,
61990
+ ssrBuild: !!config.build?.ssr
61927
61991
  };
61928
61992
  let { configFile } = config;
61929
61993
  if (configFile !== false) {
@@ -61975,7 +62039,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
61975
62039
  }
61976
62040
  }
61977
62041
  // resolve root
61978
- const resolvedRoot = normalizePath$3(config.root ? path$o.resolve(config.root) : process.cwd());
62042
+ const resolvedRoot = normalizePath$3(config.root ? path$n.resolve(config.root) : process.cwd());
61979
62043
  const clientAlias = [
61980
62044
  { find: /^[\/]?@vite\/env/, replacement: () => ENV_ENTRY },
61981
62045
  { find: /^[\/]?@vite\/client/, replacement: () => CLIENT_ENTRY }
@@ -61991,7 +62055,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
61991
62055
  };
61992
62056
  // load .env files
61993
62057
  const envDir = config.envDir
61994
- ? normalizePath$3(path$o.resolve(resolvedRoot, config.envDir))
62058
+ ? normalizePath$3(path$n.resolve(resolvedRoot, config.envDir))
61995
62059
  : resolvedRoot;
61996
62060
  const userEnv = inlineConfig.envFile !== false &&
61997
62061
  loadEnv(mode, envDir, resolveEnvPrefix(config));
@@ -62019,10 +62083,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62019
62083
  // resolve cache directory
62020
62084
  const pkgPath = lookupFile(resolvedRoot, [`package.json`], { pathOnly: true });
62021
62085
  const cacheDir = config.cacheDir
62022
- ? path$o.resolve(resolvedRoot, config.cacheDir)
62086
+ ? path$n.resolve(resolvedRoot, config.cacheDir)
62023
62087
  : pkgPath
62024
- ? path$o.join(path$o.dirname(pkgPath), `node_modules/.vite`)
62025
- : path$o.join(resolvedRoot, `.vite`);
62088
+ ? path$n.join(path$n.dirname(pkgPath), `node_modules/.vite`)
62089
+ : path$n.join(resolvedRoot, `.vite`);
62026
62090
  const assetsFilter = config.assetsInclude
62027
62091
  ? createFilter(config.assetsInclude)
62028
62092
  : () => false;
@@ -62067,7 +62131,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62067
62131
  };
62068
62132
  const { publicDir } = config;
62069
62133
  const resolvedPublicDir = publicDir !== false && publicDir !== ''
62070
- ? path$o.resolve(resolvedRoot, typeof publicDir === 'string' ? publicDir : 'public')
62134
+ ? path$n.resolve(resolvedRoot, typeof publicDir === 'string' ? publicDir : 'public')
62071
62135
  : '';
62072
62136
  const server = resolveServerOptions(resolvedRoot, config.server, logger);
62073
62137
  let ssr = resolveSSROptions(config.ssr);
@@ -62090,7 +62154,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62090
62154
  const resolved = {
62091
62155
  ...config,
62092
62156
  configFile: configFile ? normalizePath$3(configFile) : undefined,
62093
- configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$o.resolve(name))),
62157
+ configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$n.resolve(name))),
62094
62158
  inlineConfig,
62095
62159
  root: resolvedRoot,
62096
62160
  base: resolvedBase,
@@ -62136,10 +62200,16 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62136
62200
  }
62137
62201
  };
62138
62202
  if (middlewareMode === 'ssr') {
62139
- logger.warn(picocolors.exports.yellow(`server.middlewareMode 'ssr' is now deprecated, use server.middlewareMode true and appType 'custom'`));
62203
+ logger.warn(picocolors.exports.yellow(`Setting server.middlewareMode to 'ssr' is deprecated, set server.middlewareMode to \`true\`${config.appType === 'custom' ? '' : ` and appType to 'custom'`} instead`));
62140
62204
  }
62141
62205
  if (middlewareMode === 'html') {
62142
- logger.warn(picocolors.exports.yellow(`server.middlewareMode 'html' is now deprecated, use server.middlewareMode true`));
62206
+ logger.warn(picocolors.exports.yellow(`Setting server.middlewareMode to 'html' is deprecated, set server.middlewareMode to \`true\` instead`));
62207
+ }
62208
+ if (config.server?.force &&
62209
+ !isBuild &&
62210
+ config.optimizeDeps?.force === undefined) {
62211
+ resolved.optimizeDeps.force = true;
62212
+ logger.warn(picocolors.exports.yellow(`server.force is deprecated, use optimizeDeps.force instead`));
62143
62213
  }
62144
62214
  if (resolved.legacy?.buildRollupPluginCommonjs) {
62145
62215
  const optimizerDisabled = resolved.optimizeDeps.disabled;
@@ -62249,13 +62319,13 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
62249
62319
  let dependencies = [];
62250
62320
  if (configFile) {
62251
62321
  // explicit config path is always resolved from cwd
62252
- resolvedPath = path$o.resolve(configFile);
62322
+ resolvedPath = path$n.resolve(configFile);
62253
62323
  }
62254
62324
  else {
62255
62325
  // implicit config file loaded from inline root (if present)
62256
62326
  // otherwise from cwd
62257
62327
  for (const filename of DEFAULT_CONFIG_FILES) {
62258
- const filePath = path$o.resolve(configRoot, filename);
62328
+ const filePath = path$n.resolve(configRoot, filename);
62259
62329
  if (!fs$l.existsSync(filePath))
62260
62330
  continue;
62261
62331
  resolvedPath = filePath;
@@ -62355,7 +62425,7 @@ async function bundleConfigFile(fileName, isESM = false) {
62355
62425
  setup(build) {
62356
62426
  build.onResolve({ filter: /.*/ }, (args) => {
62357
62427
  const id = args.path;
62358
- if (id[0] !== '.' && !path$o.isAbsolute(id)) {
62428
+ if (id[0] !== '.' && !path$n.isAbsolute(id)) {
62359
62429
  return {
62360
62430
  external: true
62361
62431
  };
@@ -62368,7 +62438,7 @@ async function bundleConfigFile(fileName, isESM = false) {
62368
62438
  setup(build) {
62369
62439
  build.onLoad({ filter: /\.[cm]?[jt]s$/ }, async (args) => {
62370
62440
  const contents = await fs$l.promises.readFile(args.path, 'utf8');
62371
- const injectValues = `const __dirname = ${JSON.stringify(path$o.dirname(args.path))};` +
62441
+ const injectValues = `const __dirname = ${JSON.stringify(path$n.dirname(args.path))};` +
62372
62442
  `const __filename = ${JSON.stringify(args.path)};` +
62373
62443
  `const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};`;
62374
62444
  return {