vite 3.0.4 → 3.0.7

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.
@@ -7,7 +7,7 @@ import require$$0$3 from 'tty';
7
7
  import { transform as transform$2, build as build$3, formatMessages } from 'esbuild';
8
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
- import require$$0__default, { statSync as statSync$1, existsSync, readFileSync, promises as promises$1, readdirSync } from 'fs';
10
+ import require$$0__default, { existsSync, readFileSync, statSync as statSync$1, promises as promises$1, readdirSync } from 'fs';
11
11
  import require$$0$5 from 'events';
12
12
  import assert$1 from 'assert';
13
13
  import require$$0$6, { format as format$2, inspect } from 'util';
@@ -22,7 +22,7 @@ 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, OPTIMIZABLE_ENTRY_RE, VALID_ID_PREFIX, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, 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';
25
+ import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, 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
27
  import require$$0$a from 'buffer';
28
28
  import require$$0$8, { createRequire as createRequire$2 } from 'module';
@@ -33,7 +33,7 @@ import { STATUS_CODES } from 'node:http';
33
33
  import { createServer as createServer$2 } from 'node:https';
34
34
  import require$$1$1 from 'worker_threads';
35
35
  import * as qs from 'querystring';
36
- import readline from 'readline';
36
+ import readline from 'node:readline';
37
37
  import { execSync } from 'node:child_process';
38
38
  import zlib$1, { gzip } from 'node:zlib';
39
39
 
@@ -7255,7 +7255,7 @@ function isReference(node, parent) {
7255
7255
  return false;
7256
7256
  }
7257
7257
 
7258
- var version$1 = "22.0.1";
7258
+ var version$1 = "22.0.2";
7259
7259
  var peerDependencies = {
7260
7260
  rollup: "^2.68.0"
7261
7261
  };
@@ -8213,7 +8213,7 @@ function hasDefineEsmProperty(node) {
8213
8213
  });
8214
8214
  }
8215
8215
 
8216
- function wrapCode(magicString, uses, moduleName, exportsName) {
8216
+ function wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges) {
8217
8217
  const args = [];
8218
8218
  const passedArgs = [];
8219
8219
  if (uses.module) {
@@ -8226,7 +8226,7 @@ function wrapCode(magicString, uses, moduleName, exportsName) {
8226
8226
  }
8227
8227
  magicString
8228
8228
  .trim()
8229
- .indent('\t')
8229
+ .indent('\t', { exclude: indentExclusionRanges })
8230
8230
  .prepend(`(function (${args.join(', ')}) {\n`)
8231
8231
  .append(`\n} (${passedArgs.join(', ')}));`);
8232
8232
  }
@@ -8724,6 +8724,7 @@ async function transformCommonjs(
8724
8724
  const replacedGlobal = [];
8725
8725
  const replacedDynamicRequires = [];
8726
8726
  const importedVariables = new Set();
8727
+ const indentExclusionRanges = [];
8727
8728
 
8728
8729
  walk$3(ast, {
8729
8730
  enter(node, parent) {
@@ -9022,6 +9023,11 @@ async function transformCommonjs(
9022
9023
  if (!scope.parent) {
9023
9024
  topLevelDeclarations.push(node);
9024
9025
  }
9026
+ return;
9027
+ case 'TemplateElement':
9028
+ if (node.value.raw.includes('\n')) {
9029
+ indentExclusionRanges.push([node.start, node.end]);
9030
+ }
9025
9031
  }
9026
9032
  },
9027
9033
 
@@ -9154,11 +9160,13 @@ async function transformCommonjs(
9154
9160
  );
9155
9161
 
9156
9162
  if (shouldWrap) {
9157
- wrapCode(magicString, uses, moduleName, exportsName);
9163
+ wrapCode(magicString, uses, moduleName, exportsName, indentExclusionRanges);
9158
9164
  }
9159
9165
 
9160
9166
  if (usesRequireWrapper) {
9161
- magicString.trim().indent('\t');
9167
+ magicString.trim().indent('\t', {
9168
+ exclude: indentExclusionRanges
9169
+ });
9162
9170
  magicString.prepend(
9163
9171
  `var ${isRequiredName};
9164
9172
 
@@ -33300,7 +33308,7 @@ function assetPlugin(config) {
33300
33308
  const url = await fileToUrl(id, config, this);
33301
33309
  return `export default ${JSON.stringify(url)}`;
33302
33310
  },
33303
- renderChunk(code, chunk) {
33311
+ renderChunk(code, chunk, outputOptions) {
33304
33312
  let match;
33305
33313
  let s;
33306
33314
  // Urls added with JS using e.g.
@@ -33316,7 +33324,7 @@ function assetPlugin(config) {
33316
33324
  const file = getAssetFilename(hash, config) || this.getFileName(hash);
33317
33325
  chunk.viteMetadata.importedAssets.add(cleanUrl(file));
33318
33326
  const filename = file + postfix;
33319
- const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config);
33327
+ const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config, outputOptions.format);
33320
33328
  const replacementString = typeof replacement === 'string'
33321
33329
  ? JSON.stringify(replacement).slice(1, -1)
33322
33330
  : `"+${replacement.runtime}+"`;
@@ -33330,7 +33338,7 @@ function assetPlugin(config) {
33330
33338
  s = s || (s = new MagicString(code));
33331
33339
  const [full, hash] = match;
33332
33340
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
33333
- const replacement = toOutputFilePathInString(publicUrl, 'public', chunk.fileName, 'js', config);
33341
+ const replacement = toOutputFilePathInString(publicUrl, 'public', chunk.fileName, 'js', config, outputOptions.format);
33334
33342
  const replacementString = typeof replacement === 'string'
33335
33343
  ? JSON.stringify(replacement).slice(1, -1)
33336
33344
  : `"+${replacement.runtime}+"`;
@@ -33822,10 +33830,6 @@ function resolvePlugin(resolveOptions) {
33822
33830
  if (id.startsWith(browserExternalId)) {
33823
33831
  return id;
33824
33832
  }
33825
- // fast path for commonjs proxy modules
33826
- if (/\?commonjs/.test(id) || id === 'commonjsHelpers.js') {
33827
- return;
33828
- }
33829
33833
  const targetWeb = !ssr || ssrTarget === 'webworker';
33830
33834
  // this is passed by @rollup/plugin-commonjs
33831
33835
  const isRequire = resolveOpts?.custom?.['node-resolve']?.isRequire ?? false;
@@ -34180,18 +34184,20 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
34180
34184
  if (!externalize) {
34181
34185
  return resolved;
34182
34186
  }
34183
- // dont external symlink packages
34187
+ // don't external symlink packages
34184
34188
  if (!allowLinkedExternal && !resolved.id.includes('node_modules')) {
34185
34189
  return resolved;
34186
34190
  }
34187
34191
  const resolvedExt = path$n.extname(resolved.id);
34192
+ // don't external non-js imports
34193
+ if (resolvedExt &&
34194
+ resolvedExt !== '.js' &&
34195
+ resolvedExt !== '.mjs' &&
34196
+ resolvedExt !== '.cjs') {
34197
+ return resolved;
34198
+ }
34188
34199
  let resolvedId = id;
34189
34200
  if (isDeepImport) {
34190
- // check ext before externalizing - only externalize
34191
- // extension-less imports and explicit .js imports
34192
- if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) {
34193
- return resolved;
34194
- }
34195
34201
  if (!pkg?.data.exports && path$n.extname(id) !== resolvedExt) {
34196
34202
  resolvedId += resolvedExt;
34197
34203
  }
@@ -34358,6 +34364,9 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
34358
34364
  // likely UMD or CJS(!!! e.g. firebase 7.x), prefer module
34359
34365
  entryPoint = data.module;
34360
34366
  }
34367
+ else {
34368
+ entryPoint = browserEntry;
34369
+ }
34361
34370
  }
34362
34371
  }
34363
34372
  else {
@@ -35665,7 +35674,7 @@ async function transformGlobImport(code, id, root, resolveId, restoreQueryExtens
35665
35674
  }
35666
35675
  });
35667
35676
  files.forEach((i) => matchedFiles.add(i));
35668
- const replacement = `Object.assign({${objectProps.join(',')}})`;
35677
+ const replacement = `/* #__PURE__ */ Object.assign({${objectProps.join(',')}})`;
35669
35678
  s.overwrite(start, end, replacement);
35670
35679
  return staticImports;
35671
35680
  }))).flat();
@@ -35695,7 +35704,7 @@ async function toAbsoluteGlob(glob, root, importer, resolveId) {
35695
35704
  const resolved = normalizePath$3((await resolveId(glob, importer)) || glob);
35696
35705
  if (isAbsolute$2(resolved))
35697
35706
  return pre + resolved;
35698
- throw new Error(`Invalid glob: "${glob}" (resolved: "${resolved}"). It must starts with '/' or './'`);
35707
+ throw new Error(`Invalid glob: "${glob}" (resolved: "${resolved}"). It must start with '/' or './'`);
35699
35708
  }
35700
35709
  function getCommonBase(globsResolved) {
35701
35710
  const bases = globsResolved
@@ -35818,7 +35827,8 @@ function globEntries(pattern, config) {
35818
35827
  ? []
35819
35828
  : [`**/__tests__/**`, `**/coverage/**`])
35820
35829
  ],
35821
- absolute: true
35830
+ absolute: true,
35831
+ suppressErrors: true // suppress EACCES errors
35822
35832
  });
35823
35833
  }
35824
35834
  const scriptModuleRE = /(<script\b[^>]*type\s*=\s*(?:"module"|'module')[^>]*>)(.*?)<\/script>/gims;
@@ -37377,79 +37387,97 @@ function matchAll(regex, string, addition) {
37377
37387
  return matches;
37378
37388
  }
37379
37389
 
37380
- const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
37381
- function findStaticImports(code) {
37382
- return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
37383
- }
37384
- function parseStaticImport(matched) {
37385
- const cleanedImports = (matched.imports || "").replace(/(\/\/[^\n]*\n|\/\*.*\*\/)/g, "").replace(/\s+/g, " ");
37386
- const namedImports = {};
37387
- for (const namedImport of cleanedImports.match(/\{([^}]*)\}/)?.[1]?.split(",") || []) {
37388
- const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*([^\s]*) as ([^\s]*)\s*$/) || [];
37389
- if (source) {
37390
- namedImports[source] = importName;
37391
- }
37392
- }
37393
- const topLevelImports = cleanedImports.replace(/\{([^}]*)\}/, "");
37394
- const namespacedImport = topLevelImports.match(/\* as \s*([^\s]*)/)?.[1];
37395
- const defaultImport = topLevelImports.split(",").find((i) => !i.match(/[*{}]/))?.trim() || void 0;
37396
- return {
37397
- ...matched,
37398
- defaultImport,
37399
- namespacedImport,
37400
- namedImports
37401
- };
37402
- }
37403
-
37404
37390
  const isWindows$3 = process.platform === "win32";
37405
37391
  const own$1 = {}.hasOwnProperty;
37406
37392
  const messages = /* @__PURE__ */ new Map();
37407
37393
  const nodeInternalPrefix = "__node_internal_";
37408
37394
  let userStackTraceLimit;
37409
- createError("ERR_INVALID_MODULE_SPECIFIER", (request, reason, base = void 0) => {
37410
- return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
37411
- }, TypeError);
37412
- createError("ERR_INVALID_PACKAGE_CONFIG", (path, base, message) => {
37413
- return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
37414
- }, Error);
37415
- createError("ERR_INVALID_PACKAGE_TARGET", (pkgPath, key, target, isImport = false, base = void 0) => {
37416
- const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
37417
- if (key === ".") {
37418
- assert$1(isImport === false);
37419
- return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37420
- }
37421
- return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37422
- }, Error);
37423
- createError("ERR_MODULE_NOT_FOUND", (path, base, type = "package") => {
37424
- return `Cannot find ${type} '${path}' imported from ${base}`;
37425
- }, Error);
37426
- createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
37427
- return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
37428
- }, TypeError);
37429
- createError("ERR_PACKAGE_PATH_NOT_EXPORTED", (pkgPath, subpath, base = void 0) => {
37430
- if (subpath === ".") {
37431
- return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37432
- }
37433
- return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37434
- }, Error);
37435
- createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
37436
- createError("ERR_UNKNOWN_FILE_EXTENSION", 'Unknown file extension "%s" for %s', TypeError);
37437
- createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
37438
- let inspected = inspect(value);
37439
- if (inspected.length > 128) {
37440
- inspected = `${inspected.slice(0, 128)}...`;
37441
- }
37442
- const type = name.includes(".") ? "property" : "argument";
37443
- return `The ${type} '${name}' ${reason}. Received ${inspected}`;
37444
- }, TypeError);
37445
- createError("ERR_UNSUPPORTED_ESM_URL_SCHEME", (url) => {
37446
- let message = "Only file and data URLs are supported by the default ESM loader";
37447
- if (isWindows$3 && url.protocol.length === 2) {
37448
- message += ". On Windows, absolute paths must be valid file:// URLs";
37449
- }
37450
- message += `. Received protocol '${url.protocol}'`;
37451
- return message;
37452
- }, Error);
37395
+ createError(
37396
+ "ERR_INVALID_MODULE_SPECIFIER",
37397
+ (request, reason, base = void 0) => {
37398
+ return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
37399
+ },
37400
+ TypeError
37401
+ );
37402
+ createError(
37403
+ "ERR_INVALID_PACKAGE_CONFIG",
37404
+ (path, base, message) => {
37405
+ return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
37406
+ },
37407
+ Error
37408
+ );
37409
+ createError(
37410
+ "ERR_INVALID_PACKAGE_TARGET",
37411
+ (pkgPath, key, target, isImport = false, base = void 0) => {
37412
+ const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
37413
+ if (key === ".") {
37414
+ assert$1(isImport === false);
37415
+ return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37416
+ }
37417
+ return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
37418
+ target
37419
+ )} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
37420
+ },
37421
+ Error
37422
+ );
37423
+ createError(
37424
+ "ERR_MODULE_NOT_FOUND",
37425
+ (path, base, type = "package") => {
37426
+ return `Cannot find ${type} '${path}' imported from ${base}`;
37427
+ },
37428
+ Error
37429
+ );
37430
+ createError(
37431
+ "ERR_PACKAGE_IMPORT_NOT_DEFINED",
37432
+ (specifier, packagePath, base) => {
37433
+ return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
37434
+ },
37435
+ TypeError
37436
+ );
37437
+ createError(
37438
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
37439
+ (pkgPath, subpath, base = void 0) => {
37440
+ if (subpath === ".") {
37441
+ return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37442
+ }
37443
+ return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
37444
+ },
37445
+ Error
37446
+ );
37447
+ createError(
37448
+ "ERR_UNSUPPORTED_DIR_IMPORT",
37449
+ "Directory import '%s' is not supported resolving ES modules imported from %s",
37450
+ Error
37451
+ );
37452
+ createError(
37453
+ "ERR_UNKNOWN_FILE_EXTENSION",
37454
+ 'Unknown file extension "%s" for %s',
37455
+ TypeError
37456
+ );
37457
+ createError(
37458
+ "ERR_INVALID_ARG_VALUE",
37459
+ (name, value, reason = "is invalid") => {
37460
+ let inspected = inspect(value);
37461
+ if (inspected.length > 128) {
37462
+ inspected = `${inspected.slice(0, 128)}...`;
37463
+ }
37464
+ const type = name.includes(".") ? "property" : "argument";
37465
+ return `The ${type} '${name}' ${reason}. Received ${inspected}`;
37466
+ },
37467
+ TypeError
37468
+ );
37469
+ createError(
37470
+ "ERR_UNSUPPORTED_ESM_URL_SCHEME",
37471
+ (url) => {
37472
+ let message = "Only file and data URLs are supported by the default ESM loader";
37473
+ if (isWindows$3 && url.protocol.length === 2) {
37474
+ message += ". On Windows, absolute paths must be valid file:// URLs";
37475
+ }
37476
+ message += `. Received protocol '${url.protocol}'`;
37477
+ return message;
37478
+ },
37479
+ Error
37480
+ );
37453
37481
  function createError(sym, value, def) {
37454
37482
  messages.set(sym, value);
37455
37483
  return makeNodeErrorWithCode(def, sym);
@@ -37485,20 +37513,22 @@ function makeNodeErrorWithCode(Base, key) {
37485
37513
  return error;
37486
37514
  }
37487
37515
  }
37488
- const addCodeToName = hideStackFrames(function(error, name, code) {
37489
- error = captureLargerStackTrace(error);
37490
- error.name = `${name} [${code}]`;
37491
- if (name === "SystemError") {
37492
- Object.defineProperty(error, "name", {
37493
- value: name,
37494
- enumerable: false,
37495
- writable: true,
37496
- configurable: true
37497
- });
37498
- } else {
37499
- delete error.name;
37516
+ const addCodeToName = hideStackFrames(
37517
+ function(error, name, code) {
37518
+ error = captureLargerStackTrace(error);
37519
+ error.name = `${name} [${code}]`;
37520
+ if (name === "SystemError") {
37521
+ Object.defineProperty(error, "name", {
37522
+ value: name,
37523
+ enumerable: false,
37524
+ writable: true,
37525
+ configurable: true
37526
+ });
37527
+ } else {
37528
+ delete error.name;
37529
+ }
37500
37530
  }
37501
- });
37531
+ );
37502
37532
  function isErrorStackTraceLimitWritable() {
37503
37533
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
37504
37534
  if (desc === void 0) {
@@ -37511,26 +37541,34 @@ function hideStackFrames(fn) {
37511
37541
  Object.defineProperty(fn, "name", { value: hidden });
37512
37542
  return fn;
37513
37543
  }
37514
- const captureLargerStackTrace = hideStackFrames(function(error) {
37515
- const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
37516
- if (stackTraceLimitIsWritable) {
37517
- userStackTraceLimit = Error.stackTraceLimit;
37518
- Error.stackTraceLimit = Number.POSITIVE_INFINITY;
37519
- }
37520
- Error.captureStackTrace(error);
37521
- if (stackTraceLimitIsWritable) {
37522
- Error.stackTraceLimit = userStackTraceLimit;
37544
+ const captureLargerStackTrace = hideStackFrames(
37545
+ function(error) {
37546
+ const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
37547
+ if (stackTraceLimitIsWritable) {
37548
+ userStackTraceLimit = Error.stackTraceLimit;
37549
+ Error.stackTraceLimit = Number.POSITIVE_INFINITY;
37550
+ }
37551
+ Error.captureStackTrace(error);
37552
+ if (stackTraceLimitIsWritable) {
37553
+ Error.stackTraceLimit = userStackTraceLimit;
37554
+ }
37555
+ return error;
37523
37556
  }
37524
- return error;
37525
- });
37557
+ );
37526
37558
  function getMessage(key, args, self) {
37527
37559
  const message = messages.get(key);
37528
37560
  if (typeof message === "function") {
37529
- assert$1(message.length <= args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`);
37561
+ assert$1(
37562
+ message.length <= args.length,
37563
+ `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`
37564
+ );
37530
37565
  return Reflect.apply(message, self, args);
37531
37566
  }
37532
37567
  const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
37533
- assert$1(expectedLength === args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`);
37568
+ assert$1(
37569
+ expectedLength === args.length,
37570
+ `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`
37571
+ );
37534
37572
  if (args.length === 0) {
37535
37573
  return message;
37536
37574
  }
@@ -37540,6 +37578,30 @@ function getMessage(key, args, self) {
37540
37578
  Object.freeze(["node", "import"]);
37541
37579
  pathToFileURL$1(process.cwd());
37542
37580
 
37581
+ const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
37582
+ function findStaticImports(code) {
37583
+ return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
37584
+ }
37585
+ function parseStaticImport(matched) {
37586
+ const cleanedImports = (matched.imports || "").replace(/(\/\/[^\n]*\n|\/\*.*\*\/)/g, "").replace(/\s+/g, " ");
37587
+ const namedImports = {};
37588
+ for (const namedImport of cleanedImports.match(/\{([^}]*)\}/)?.[1]?.split(",") || []) {
37589
+ const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*([^\s]*) as ([^\s]*)\s*$/) || [];
37590
+ if (source) {
37591
+ namedImports[source] = importName;
37592
+ }
37593
+ }
37594
+ const topLevelImports = cleanedImports.replace(/\{([^}]*)\}/, "");
37595
+ const namespacedImport = topLevelImports.match(/\* as \s*([^\s]*)/)?.[1];
37596
+ const defaultImport = topLevelImports.split(",").find((i) => !i.match(/[*{}]/))?.trim() || void 0;
37597
+ return {
37598
+ ...matched,
37599
+ defaultImport,
37600
+ namespacedImport,
37601
+ namedImports
37602
+ };
37603
+ }
37604
+
37543
37605
  const debugHmr = createDebugger('vite:hmr');
37544
37606
  const normalizedClientDir = normalizePath$3(CLIENT_DIR);
37545
37607
  function getShortName(file, root) {
@@ -37678,6 +37740,7 @@ function propagateUpdate(node, boundaries, currentChain = [node]) {
37678
37740
  // if the imports of `node` have not been analyzed, then `node` has not
37679
37741
  // been loaded in the browser and we should stop propagation.
37680
37742
  if (node.id && node.isSelfAccepting === undefined) {
37743
+ debugHmr(`[propagate update] stop propagation because not analyzed: ${picocolors.exports.dim(node.id)}`);
37681
37744
  return false;
37682
37745
  }
37683
37746
  if (node.isSelfAccepting) {
@@ -38019,6 +38082,7 @@ function createIsConfiguredAsSsrExternal(config) {
38019
38082
  !!configuredAsExternal)?.external;
38020
38083
  }
38021
38084
  catch (e) {
38085
+ debug$9(`Failed to node resolve "${id}". Skipping externalizing it by default.`);
38022
38086
  // may be an invalid import that's resolved by a plugin
38023
38087
  return false;
38024
38088
  }
@@ -38885,7 +38949,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38885
38949
  function defineImport(node, source) {
38886
38950
  deps.add(source);
38887
38951
  const importId = `__vite_ssr_import_${uid++}__`;
38888
- s.appendLeft(node.start, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`);
38952
+ s.appendRight(node.start, `const ${importId} = await ${ssrImportKey}(${JSON.stringify(source)});\n`);
38889
38953
  return importId;
38890
38954
  }
38891
38955
  function defineExport(position, name, local = name) {
@@ -38898,6 +38962,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38898
38962
  // import { baz } from 'foo' --> baz -> __import_foo__.baz
38899
38963
  // import * as ok from 'foo' --> ok -> __import_foo__
38900
38964
  if (node.type === 'ImportDeclaration') {
38965
+ s.remove(node.start, node.end);
38901
38966
  const importId = defineImport(node, node.source.value);
38902
38967
  for (const spec of node.specifiers) {
38903
38968
  if (spec.type === 'ImportSpecifier') {
@@ -38911,7 +38976,6 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38911
38976
  idToImportMap.set(spec.local.name, importId);
38912
38977
  }
38913
38978
  }
38914
- s.remove(node.start, node.end);
38915
38979
  }
38916
38980
  }
38917
38981
  // 2. check all export statements and define exports
@@ -38975,14 +39039,12 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38975
39039
  }
38976
39040
  // export * from './foo'
38977
39041
  if (node.type === 'ExportAllDeclaration') {
39042
+ s.remove(node.start, node.end);
39043
+ const importId = defineImport(node, node.source.value);
38978
39044
  if (node.exported) {
38979
- const importId = defineImport(node, node.source.value);
38980
- s.remove(node.start, node.end);
38981
39045
  defineExport(node.end, node.exported.name, `${importId}`);
38982
39046
  }
38983
39047
  else {
38984
- const importId = defineImport(node, node.source.value);
38985
- s.remove(node.start, node.end);
38986
39048
  s.appendLeft(node.end, `${ssrExportAllKey}(${importId});`);
38987
39049
  }
38988
39050
  }
@@ -38999,7 +39061,7 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
38999
39061
  // let binding used in a property shorthand
39000
39062
  // { foo } -> { foo: __import_x__.foo }
39001
39063
  // skip for destructuring patterns
39002
- if (!isNodeInPatternWeakMap.get(parent) ||
39064
+ if (!isNodeInPattern(parent) ||
39003
39065
  isInDestructuringAssignment(parent, parentStack)) {
39004
39066
  s.appendLeft(id.end, `: ${binding}`);
39005
39067
  }
@@ -39054,7 +39116,9 @@ async function ssrTransformScript(code, inMap, url, originalCode) {
39054
39116
  dynamicDeps: [...dynamicDeps]
39055
39117
  };
39056
39118
  }
39057
- const isNodeInPatternWeakMap = new WeakMap();
39119
+ const isNodeInPatternWeakSet = new WeakSet();
39120
+ const setIsNodeInPattern = (node) => isNodeInPatternWeakSet.add(node);
39121
+ const isNodeInPattern = (node) => isNodeInPatternWeakSet.has(node);
39058
39122
  /**
39059
39123
  * Same logic from \@vue/compiler-core & \@vue/compiler-sfc
39060
39124
  * Except this is using acorn AST
@@ -39169,7 +39233,7 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
39169
39233
  }
39170
39234
  else if (node.type === 'Property' && parent.type === 'ObjectPattern') {
39171
39235
  // mark property in destructuring pattern
39172
- isNodeInPatternWeakMap.set(node, true);
39236
+ setIsNodeInPattern(node);
39173
39237
  }
39174
39238
  else if (node.type === 'VariableDeclarator') {
39175
39239
  const parentFunction = findParentFunction(parentStack);
@@ -39212,8 +39276,11 @@ function isRefIdentifier(id, parent, parentStack) {
39212
39276
  return false;
39213
39277
  }
39214
39278
  // property key
39215
- // this also covers object destructuring pattern
39216
- if (isStaticPropertyKey(id, parent) || isNodeInPatternWeakMap.get(parent)) {
39279
+ if (isStaticPropertyKey(id, parent)) {
39280
+ return false;
39281
+ }
39282
+ // object destructuring pattern
39283
+ if (isNodeInPattern(parent) && parent.value === id) {
39217
39284
  return false;
39218
39285
  }
39219
39286
  // non-assignment array destructuring pattern
@@ -39999,7 +40066,7 @@ function throwOutdatedRequest(id) {
39999
40066
  const isDebug$1 = !!process.env.DEBUG;
40000
40067
  const debug$7 = createDebugger('vite:import-analysis');
40001
40068
  const clientDir = normalizePath$3(CLIENT_DIR);
40002
- const skipRE = /\.(map|json)$/;
40069
+ const skipRE = /\.(map|json)($|\?)/;
40003
40070
  const canSkipImportAnalysis = (id) => skipRE.test(id) || isDirectCSSRequest(id);
40004
40071
  const optimizedDepChunkRE$1 = /\/chunk-[A-Z0-9]{8}\.js/;
40005
40072
  const optimizedDepDynamicRE$1 = /-[A-Z0-9]{8}\.js/;
@@ -40854,7 +40921,7 @@ function buildImportAnalysisPlugin(config) {
40854
40921
  // dynamic import to constant json may get inlined.
40855
40922
  if (chunk.type === 'chunk' && chunk.code.indexOf(preloadMarker) > -1) {
40856
40923
  const code = chunk.code;
40857
- let imports;
40924
+ let imports = [];
40858
40925
  try {
40859
40926
  imports = parse$b(code)[0].filter((i) => i.d > -1);
40860
40927
  }
@@ -40981,8 +41048,7 @@ function modulePreloadPolyfillPlugin(config) {
40981
41048
  return '';
40982
41049
  }
40983
41050
  if (!polyfillString) {
40984
- polyfillString =
40985
- `const p = ${polyfill.toString()};` + `${isModernFlag}&&p();`;
41051
+ polyfillString = `${isModernFlag}&&(${polyfill.toString()}());`;
40986
41052
  }
40987
41053
  return polyfillString;
40988
41054
  }
@@ -41099,7 +41165,7 @@ const assetAttrsConfig = {
41099
41165
  const isAsyncScriptMap = new WeakMap();
41100
41166
  async function traverseHtml(html, filePath, visitor) {
41101
41167
  // lazy load compiler
41102
- const { parse, transform } = await import('./dep-f135d593.js').then(function (n) { return n.c; });
41168
+ const { parse, transform } = await import('./dep-af83bc3e.js').then(function (n) { return n.c; });
41103
41169
  // @vue/compiler-core doesn't like lowercase doctypes
41104
41170
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
41105
41171
  try {
@@ -41529,7 +41595,7 @@ function buildHtmlPlugin(config) {
41529
41595
  // all imports from entry have been inlined to html, prevent rollup from outputting it
41530
41596
  delete bundle[chunk.fileName];
41531
41597
  }
41532
- const shortEmitName = path$n.relative(config.root, id);
41598
+ const shortEmitName = normalizePath$3(path$n.relative(config.root, id));
41533
41599
  this.emitFile({
41534
41600
  type: 'asset',
41535
41601
  fileName: shortEmitName,
@@ -41783,7 +41849,7 @@ function cssPlugin(config) {
41783
41849
  }
41784
41850
  return url;
41785
41851
  };
41786
- const { code: css, modules, deps, map } = await compileCSS(id, raw, config, urlReplacer, atImportResolvers, server);
41852
+ const { code: css, modules, deps, map } = await compileCSS(id, raw, config, urlReplacer, atImportResolvers);
41787
41853
  if (modules) {
41788
41854
  moduleCache.set(id, modules);
41789
41855
  }
@@ -42218,7 +42284,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
42218
42284
  const postcssOptions = (postcssConfig && postcssConfig.options) || {};
42219
42285
  const postcssPlugins = postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [];
42220
42286
  if (needInlineImport) {
42221
- postcssPlugins.unshift((await import('./dep-41eb528c.js').then(function (n) { return n.i; })).default({
42287
+ postcssPlugins.unshift((await import('./dep-94c1417a.js').then(function (n) { return n.i; })).default({
42222
42288
  async resolve(id, basedir) {
42223
42289
  const publicFile = checkPublicFile(id, config);
42224
42290
  if (publicFile) {
@@ -42237,7 +42303,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
42237
42303
  logger: config.logger
42238
42304
  }));
42239
42305
  if (isModule) {
42240
- postcssPlugins.unshift((await import('./dep-3811dadb.js').then(function (n) { return n.i; })).default({
42306
+ postcssPlugins.unshift((await import('./dep-efa53ee5.js').then(function (n) { return n.i; })).default({
42241
42307
  ...modulesOptions,
42242
42308
  getJSON(cssFileName, _modules, outputFileName) {
42243
42309
  modules = _modules;
@@ -43707,7 +43773,32 @@ function wrapSsrTransform(fn) {
43707
43773
  function injectSsrFlag(options) {
43708
43774
  return { ...(options ?? {}), ssr: true };
43709
43775
  }
43710
- function toOutputFilePathInString(filename, type, hostId, hostType, config, toRelative = toImportMetaURLBasedRelativePath) {
43776
+ /*
43777
+ The following functions are copied from rollup
43778
+ https://github.com/rollup/rollup/blob/c5269747cd3dd14c4b306e8cea36f248d9c1aa01/src/ast/nodes/MetaProperty.ts#L189-L232
43779
+
43780
+ https://github.com/rollup/rollup
43781
+ The MIT License (MIT)
43782
+ Copyright (c) 2017 [these people](https://github.com/rollup/rollup/graphs/contributors)
43783
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
43784
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
43785
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43786
+ */
43787
+ const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
43788
+ const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${relativePath}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
43789
+ const relativeUrlMechanisms = {
43790
+ amd: (relativePath) => {
43791
+ if (relativePath[0] !== '.')
43792
+ relativePath = './' + relativePath;
43793
+ return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
43794
+ },
43795
+ cjs: (relativePath) => `(typeof document === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath)})`,
43796
+ es: (relativePath) => getResolveUrl(`'${relativePath}', import.meta.url`),
43797
+ iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
43798
+ system: (relativePath) => getResolveUrl(`'${relativePath}', module.meta.url`),
43799
+ umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getResolveUrl(`'file:' + __dirname + '/${relativePath}'`, `(require('u' + 'rl').URL)`)} : ${getRelativeUrlFromDocument(relativePath, true)})`
43800
+ };
43801
+ function toOutputFilePathInString(filename, type, hostId, hostType, config, format, toRelative = getToImportMetaURLBasedRelativePath(format)) {
43711
43802
  const { renderBuiltUrl } = config.experimental;
43712
43803
  let relative = config.base === '' || config.base === './';
43713
43804
  if (renderBuiltUrl) {
@@ -43734,10 +43825,11 @@ function toOutputFilePathInString(filename, type, hostId, hostType, config, toRe
43734
43825
  }
43735
43826
  return config.base + filename;
43736
43827
  }
43737
- function toImportMetaURLBasedRelativePath(filename, importer) {
43738
- return {
43739
- runtime: `new URL(${JSON.stringify(path$n.posix.relative(path$n.dirname(importer), filename))},import.meta.url).href`
43740
- };
43828
+ function getToImportMetaURLBasedRelativePath(format) {
43829
+ const toRelativePath = relativeUrlMechanisms[format];
43830
+ return (filename, importer) => ({
43831
+ runtime: toRelativePath(path$n.posix.relative(path$n.dirname(importer), filename))
43832
+ });
43741
43833
  }
43742
43834
  function toOutputFilePathWithoutRuntime(filename, type, hostId, hostType, config, toRelative) {
43743
43835
  const { renderBuiltUrl } = config.experimental;
@@ -49783,30 +49875,44 @@ var guess = function guessEditor (specifiedEditor) {
49783
49875
  try {
49784
49876
  if (process.platform === 'darwin') {
49785
49877
  const output = childProcess$2
49786
- .execSync('ps x', {
49878
+ .execSync('ps x -o comm=', {
49787
49879
  stdio: ['pipe', 'pipe', 'ignore']
49788
49880
  })
49789
49881
  .toString();
49790
49882
  const processNames = Object.keys(COMMON_EDITORS_OSX);
49883
+ const processList = output.split('\n');
49791
49884
  for (let i = 0; i < processNames.length; i++) {
49792
49885
  const processName = processNames[i];
49886
+ // Find editor by exact match.
49793
49887
  if (output.indexOf(processName) !== -1) {
49794
49888
  return [COMMON_EDITORS_OSX[processName]]
49795
49889
  }
49890
+ const processNameWithoutApplications = processName.replace('/Applications', '');
49891
+ // Find editor installation not in /Applications.
49892
+ if (output.indexOf(processNameWithoutApplications) !== -1) {
49893
+ // Use the CLI command if one is specified
49894
+ if (processName !== COMMON_EDITORS_OSX[processName]) {
49895
+ return [COMMON_EDITORS_OSX[processName]]
49896
+ }
49897
+ // Use a partial match to find the running process path. If one is found, use the
49898
+ // existing path since it can be running from anywhere.
49899
+ const runningProcess = processList.find((procName) => procName.endsWith(processNameWithoutApplications));
49900
+ if (runningProcess !== undefined) {
49901
+ return [runningProcess]
49902
+ }
49903
+ }
49796
49904
  }
49797
49905
  } else if (process.platform === 'win32') {
49798
49906
  const output = childProcess$2
49799
- .execSync('powershell -Command "Get-Process | Select-Object Path"', {
49800
- stdio: ['pipe', 'pipe', 'ignore']
49801
- })
49907
+ .execSync(
49908
+ 'powershell -NoProfile -Command "Get-CimInstance -Query \\"select executablepath from win32_process where executablepath is not null\\" | % { $_.ExecutablePath }"',
49909
+ {
49910
+ stdio: ['pipe', 'pipe', 'ignore']
49911
+ }
49912
+ )
49802
49913
  .toString();
49803
49914
  const runningProcesses = output.split('\r\n');
49804
49915
  for (let i = 0; i < runningProcesses.length; i++) {
49805
- // `Get-Process` sometimes returns empty lines
49806
- if (!runningProcesses[i]) {
49807
- continue
49808
- }
49809
-
49810
49916
  const fullProcessPath = runningProcesses[i].trim();
49811
49917
  const shortProcessName = path$8.basename(fullProcessPath);
49812
49918
 
@@ -49882,6 +49988,7 @@ var getArgs = function getArgumentsForPosition (
49882
49988
  case 'code':
49883
49989
  case 'code-insiders':
49884
49990
  case 'Code':
49991
+ case 'codium':
49885
49992
  return ['-r', '-g', `${fileName}:${lineNumber}:${columnNumber}`]
49886
49993
  case 'appcode':
49887
49994
  case 'clion':
@@ -49896,7 +50003,7 @@ var getArgs = function getArgumentsForPosition (
49896
50003
  case 'rubymine64':
49897
50004
  case 'webstorm':
49898
50005
  case 'webstorm64':
49899
- return ['--line', lineNumber, fileName]
50006
+ return ['--line', lineNumber, '--column', columnNumber, fileName]
49900
50007
  }
49901
50008
 
49902
50009
  // For all others, drop the lineNumber until we have
@@ -50075,16 +50182,16 @@ var launchEditorMiddleware = (specifiedEditor, srcRoot, onErrorCallback) => {
50075
50182
 
50076
50183
  async function resolveHttpServer({ proxy }, app, httpsOptions) {
50077
50184
  if (!httpsOptions) {
50078
- const { createServer } = await import('http');
50185
+ const { createServer } = await import('node:http');
50079
50186
  return createServer(app);
50080
50187
  }
50081
50188
  // #484 fallback to http1 when proxy is needed.
50082
50189
  if (proxy) {
50083
- const { createServer } = await import('https');
50190
+ const { createServer } = await import('node:https');
50084
50191
  return createServer(httpsOptions, app);
50085
50192
  }
50086
50193
  else {
50087
- const { createSecureServer } = await import('http2');
50194
+ const { createSecureServer } = await import('node:http2');
50088
50195
  return createSecureServer({
50089
50196
  // Manually increase the session memory to prevent 502 ENHANCE_YOUR_CALM
50090
50197
  // errors on large numbers of requests
@@ -50146,6 +50253,14 @@ async function httpServerStart(httpServer, serverOptions) {
50146
50253
  });
50147
50254
  });
50148
50255
  }
50256
+ function setClientErrorHandler(server, logger) {
50257
+ server.on('clientError', (err, socket) => {
50258
+ if (err.code === 'HPE_HEADER_OVERFLOW') {
50259
+ logger.warn(picocolors.exports.yellow('Server responded with status code 431. ' +
50260
+ 'See https://vitejs.dev/guide/troubleshooting.html#_431-request-header-fields-too-large.'));
50261
+ }
50262
+ });
50263
+ }
50149
50264
 
50150
50265
  /**
50151
50266
  * This plugin hooks into Node's module resolution algorithm at runtime,
@@ -50182,7 +50297,7 @@ function ssrRequireHookPlugin(config) {
50182
50297
  /** Respect the `resolve.dedupe` option in production SSR. */
50183
50298
  function dedupeRequire(dedupe) {
50184
50299
  // eslint-disable-next-line no-restricted-globals
50185
- const Module = require('module');
50300
+ const Module = require('node:module');
50186
50301
  const resolveFilename = Module._resolveFilename;
50187
50302
  Module._resolveFilename = function (request, parent, isMain, options) {
50188
50303
  if (request[0] !== '.' && request[0] !== '/') {
@@ -59024,6 +59139,9 @@ async function createServer(inlineConfig = {}) {
59024
59139
  ? null
59025
59140
  : await resolveHttpServer(serverConfig, middlewares, httpsOptions);
59026
59141
  const ws = createWebSocketServer(httpServer, config, httpsOptions);
59142
+ if (httpServer) {
59143
+ setClientErrorHandler(httpServer, config.logger);
59144
+ }
59027
59145
  const { ignored = [], ...watchOptions } = serverConfig.watch || {};
59028
59146
  const watcher = chokidar.watch(path$n.resolve(root), {
59029
59147
  ignored: [
@@ -59582,6 +59700,7 @@ async function preview(inlineConfig = {}) {
59582
59700
  const config = await resolveConfig(inlineConfig, 'serve', 'production');
59583
59701
  const app = connect();
59584
59702
  const httpServer = await resolveHttpServer(config.preview, app, await resolveHttpsConfig(config.preview?.https));
59703
+ setClientErrorHandler(httpServer, config.logger);
59585
59704
  // apply server hooks from plugins
59586
59705
  const postHooks = [];
59587
59706
  for (const plugin of config.plugins) {
@@ -60025,7 +60144,7 @@ function webWorkerPlugin(config) {
60025
60144
  map: { mappings: '' } // Empty sourcemap to suppress Rollup warning
60026
60145
  };
60027
60146
  },
60028
- renderChunk(code, chunk) {
60147
+ renderChunk(code, chunk, outputOptions) {
60029
60148
  let s;
60030
60149
  const result = () => {
60031
60150
  return (s && {
@@ -60042,7 +60161,7 @@ function webWorkerPlugin(config) {
60042
60161
  while ((match = workerAssetUrlRE.exec(code))) {
60043
60162
  const [full, hash] = match;
60044
60163
  const filename = fileNameHash.get(hash);
60045
- const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config);
60164
+ const replacement = toOutputFilePathInString(filename, 'asset', chunk.fileName, 'js', config, outputOptions.format);
60046
60165
  const replacementString = typeof replacement === 'string'
60047
60166
  ? JSON.stringify(replacement).slice(1, -1)
60048
60167
  : `"+${replacement.runtime}+"`;
@@ -60050,20 +60169,19 @@ function webWorkerPlugin(config) {
60050
60169
  contentOnly: true
60051
60170
  });
60052
60171
  }
60053
- // TODO: check if this should be removed
60054
- if (config.isWorker) {
60055
- s = s.replace('import.meta.url', 'self.location.href');
60056
- return result();
60057
- }
60058
- }
60059
- if (!isWorker) {
60060
- const workerMap = workerCache.get(config);
60061
- workerMap.assets.forEach((asset) => {
60062
- this.emitFile(asset);
60063
- workerMap.assets.delete(asset.fileName);
60064
- });
60065
60172
  }
60066
60173
  return result();
60174
+ },
60175
+ generateBundle(opts) {
60176
+ // @ts-ignore asset emits are skipped in legacy bundle
60177
+ if (opts.__vite_skip_asset_emit__ || isWorker) {
60178
+ return;
60179
+ }
60180
+ const workerMap = workerCache.get(config);
60181
+ workerMap.assets.forEach((asset) => {
60182
+ this.emitFile(asset);
60183
+ workerMap.assets.delete(asset.fileName);
60184
+ });
60067
60185
  }
60068
60186
  };
60069
60187
  }
@@ -61842,11 +61960,28 @@ function expressionToGlob(node) {
61842
61960
  }
61843
61961
  }
61844
61962
 
61963
+ const defaultProtocol = 'file:';
61964
+ const ignoredProtocols = ['data:', 'http:', 'https:'];
61965
+
61966
+ function shouldIgnore(glob) {
61967
+ const containsAsterisk = glob.includes('*');
61968
+
61969
+ const globURL = new URL(glob, defaultProtocol);
61970
+
61971
+ const containsIgnoredProtocol = ignoredProtocols.some(
61972
+ (ignoredProtocol) => ignoredProtocol === globURL.protocol
61973
+ );
61974
+
61975
+ return !containsAsterisk || containsIgnoredProtocol;
61976
+ }
61977
+
61845
61978
  function dynamicImportToGlob(node, sourceString) {
61846
61979
  let glob = expressionToGlob(node);
61847
- if (!glob.includes('*') || glob.startsWith('data:')) {
61980
+
61981
+ if (shouldIgnore(glob)) {
61848
61982
  return null;
61849
61983
  }
61984
+
61850
61985
  glob = glob.replace(/\*\*/g, '*');
61851
61986
 
61852
61987
  if (glob.startsWith('*')) {
@@ -62663,7 +62798,11 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
62663
62798
  if (process.env.DEBUG) {
62664
62799
  debug(`using resolved config: %O`, {
62665
62800
  ...resolved,
62666
- plugins: resolved.plugins.map((p) => p.name)
62801
+ plugins: resolved.plugins.map((p) => p.name),
62802
+ worker: {
62803
+ ...resolved.worker,
62804
+ plugins: resolved.worker.plugins.map((p) => p.name)
62805
+ }
62667
62806
  });
62668
62807
  }
62669
62808
  if (config.build?.terserOptions && config.build.minify !== 'terser') {
@@ -62805,6 +62944,7 @@ async function bundleConfigFile(fileName, isESM) {
62805
62944
  entryPoints: [fileName],
62806
62945
  outfile: 'out.js',
62807
62946
  write: false,
62947
+ target: ['node14.18', 'node16'],
62808
62948
  platform: 'node',
62809
62949
  bundle: true,
62810
62950
  format: isESM ? 'esm' : 'cjs',
@@ -62848,7 +62988,7 @@ async function bundleConfigFile(fileName, isESM) {
62848
62988
  if (path$n.relative(idPkgDir, fileName).startsWith('..')) {
62849
62989
  return {
62850
62990
  // normalize actual import after bundled as a single vite config
62851
- path: idFsPath,
62991
+ path: isESM ? pathToFileURL(idFsPath).href : idFsPath,
62852
62992
  external: true
62853
62993
  };
62854
62994
  }
@@ -62893,7 +63033,12 @@ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
62893
63033
  return (await dynamicImport(fileUrl)).default;
62894
63034
  }
62895
63035
  finally {
62896
- fs$l.unlinkSync(fileNameTmp);
63036
+ try {
63037
+ fs$l.unlinkSync(fileNameTmp);
63038
+ }
63039
+ catch {
63040
+ // already removed if this function is called twice simultaneously
63041
+ }
62897
63042
  }
62898
63043
  }
62899
63044
  // for cjs, we can register a custom loader via `_require.extensions`