vite 5.4.0 → 5.4.2

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

package/client.d.ts CHANGED
@@ -251,15 +251,6 @@ declare interface VitePreloadErrorEvent extends Event {
251
251
  payload: Error
252
252
  }
253
253
 
254
- declare interface Window {
255
- addEventListener(
256
- type: 'vite:preloadError',
257
- listener: (this: Window, ev: VitePreloadErrorEvent) => unknown,
258
- options?: boolean | AddEventListenerOptions,
259
- ): void
260
- removeEventListener(
261
- type: 'vite:preloadError',
262
- listener: (this: Window, ev: VitePreloadErrorEvent) => unknown,
263
- options?: boolean | EventListenerOptions,
264
- ): void
254
+ declare interface WindowEventMap {
255
+ 'vite:preloadError': VitePreloadErrorEvent
265
256
  }
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-NjL7WTE1.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-BzOvws4Y.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -2615,7 +2615,7 @@ types.UNIVERSAL = UNIVERSAL;
2615
2615
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
2616
2616
  function _interopRequireWildcard(obj, nodeInterop) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
2617
2617
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
2618
- function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2618
+ function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike) { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
2619
2619
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
2620
2620
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
2621
2621
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
@@ -16662,11 +16662,6 @@ function watchPackageDataPlugin(packageCache) {
16662
16662
  if (id.endsWith("/package.json")) {
16663
16663
  invalidatePackageData(packageCache, path$n.normalize(id));
16664
16664
  }
16665
- },
16666
- handleHotUpdate({ file }) {
16667
- if (file.endsWith("/package.json")) {
16668
- invalidatePackageData(packageCache, path$n.normalize(file));
16669
- }
16670
16665
  }
16671
16666
  };
16672
16667
  }
@@ -20349,7 +20344,7 @@ async function fileToUrl$1(id, config, ctx) {
20349
20344
  return fileToBuiltUrl(id, config, ctx);
20350
20345
  }
20351
20346
  }
20352
- function fileToDevUrl(id, config) {
20347
+ function fileToDevUrl(id, config, skipBase = false) {
20353
20348
  let rtn;
20354
20349
  if (checkPublicFile(id, config)) {
20355
20350
  rtn = id;
@@ -20358,6 +20353,9 @@ function fileToDevUrl(id, config) {
20358
20353
  } else {
20359
20354
  rtn = path$n.posix.join(FS_PREFIX, id);
20360
20355
  }
20356
+ if (skipBase) {
20357
+ return rtn;
20358
+ }
20361
20359
  const base = joinUrlSegments(config.server?.origin ?? "", config.decodedBase);
20362
20360
  return joinUrlSegments(base, removeLeadingSlash(rtn));
20363
20361
  }
@@ -20413,14 +20411,15 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
20413
20411
  } else {
20414
20412
  const { search, hash } = parse$h(id);
20415
20413
  const postfix = (search || "") + (hash || "");
20414
+ const originalFileName = normalizePath$3(path$n.relative(config.root, file));
20416
20415
  const referenceId = pluginContext.emitFile({
20416
+ type: "asset",
20417
20417
  // Ignore directory structure for asset file names
20418
20418
  name: path$n.basename(file),
20419
- type: "asset",
20419
+ originalFileName,
20420
20420
  source: content
20421
20421
  });
20422
- const originalName = normalizePath$3(path$n.relative(config.root, file));
20423
- generatedAssets.get(config).set(referenceId, { originalName });
20422
+ generatedAssets.get(config).set(referenceId, { originalFileName });
20424
20423
  url = `__VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}`;
20425
20424
  }
20426
20425
  cache.set(id, url);
@@ -20531,40 +20530,42 @@ function manifestPlugin(config) {
20531
20530
  if (isEntry) manifestChunk.isEntry = true;
20532
20531
  return manifestChunk;
20533
20532
  }
20534
- const fileNameToAssetMeta = /* @__PURE__ */ new Map();
20535
20533
  const assets = generatedAssets.get(config);
20536
- assets.forEach((asset, referenceId) => {
20537
- try {
20538
- const fileName = this.getFileName(referenceId);
20539
- fileNameToAssetMeta.set(fileName, asset);
20540
- } catch (error) {
20541
- assets.delete(referenceId);
20534
+ const entryCssAssetFileNames = /* @__PURE__ */ new Set();
20535
+ for (const [id, asset] of assets.entries()) {
20536
+ if (asset.isEntry) {
20537
+ try {
20538
+ const fileName = this.getFileName(id);
20539
+ entryCssAssetFileNames.add(fileName);
20540
+ } catch (error) {
20541
+ assets.delete(id);
20542
+ }
20542
20543
  }
20543
- });
20544
+ }
20544
20545
  const fileNameToAsset = /* @__PURE__ */ new Map();
20545
20546
  for (const file in bundle) {
20546
20547
  const chunk = bundle[file];
20547
20548
  if (chunk.type === "chunk") {
20548
20549
  manifest[getChunkName(chunk)] = createChunk(chunk);
20549
20550
  } else if (chunk.type === "asset" && typeof chunk.name === "string") {
20550
- const assetMeta = fileNameToAssetMeta.get(chunk.fileName);
20551
- const src = assetMeta?.originalName ?? chunk.name;
20552
- const asset = createAsset(chunk, src, assetMeta?.isEntry);
20551
+ const src = chunk.originalFileName ?? chunk.name;
20552
+ const isEntry = entryCssAssetFileNames.has(chunk.fileName);
20553
+ const asset = createAsset(chunk, src, isEntry);
20553
20554
  const file2 = manifest[src]?.file;
20554
20555
  if (file2 && endsWithJSRE.test(file2)) continue;
20555
20556
  manifest[src] = asset;
20556
20557
  fileNameToAsset.set(chunk.fileName, asset);
20557
20558
  }
20558
20559
  }
20559
- assets.forEach(({ originalName }, referenceId) => {
20560
- if (!manifest[originalName]) {
20560
+ for (const [referenceId, { originalFileName }] of assets.entries()) {
20561
+ if (!manifest[originalFileName]) {
20561
20562
  const fileName = this.getFileName(referenceId);
20562
20563
  const asset = fileNameToAsset.get(fileName);
20563
20564
  if (asset) {
20564
- manifest[originalName] = asset;
20565
+ manifest[originalFileName] = asset;
20565
20566
  }
20566
20567
  }
20567
- });
20568
+ }
20568
20569
  outputCount++;
20569
20570
  const output = config.build.rollupOptions?.output;
20570
20571
  const outputLength = Array.isArray(output) ? output.length : 1;
@@ -32461,9 +32462,6 @@ function getFirstKeyStartProps(prev) {
32461
32462
  break loop;
32462
32463
  }
32463
32464
  }
32464
- while (prev[++i]?.type === 'space') {
32465
- /* loop */
32466
- }
32467
32465
  return prev.splice(i, prev.length);
32468
32466
  }
32469
32467
  function fixFlowSeqItems(fc) {
@@ -35606,6 +35604,7 @@ ${js}`;
35606
35604
  );
35607
35605
  this.emitFile({
35608
35606
  type: "asset",
35607
+ originalFileName: normalizedId,
35609
35608
  fileName: shortEmitName,
35610
35609
  source: result
35611
35610
  });
@@ -36168,8 +36167,9 @@ function cssPostPlugin(config) {
36168
36167
  } else {
36169
36168
  return path$n.dirname(
36170
36169
  assetFileNames({
36171
- name: cssAssetName,
36172
36170
  type: "asset",
36171
+ name: cssAssetName,
36172
+ originalFileName: null,
36173
36173
  source: "/* vite internal call, ignore */"
36174
36174
  })
36175
36175
  );
@@ -36339,9 +36339,9 @@ function cssPostPlugin(config) {
36339
36339
  while (match = cssUrlAssetRE.exec(code)) {
36340
36340
  const [full, idHex] = match;
36341
36341
  const id = Buffer.from(idHex, "hex").toString();
36342
- const originalFilename = cleanUrl(id);
36342
+ const originalFileName = cleanUrl(id);
36343
36343
  const cssAssetName = ensureFileExt(
36344
- path$n.basename(originalFilename),
36344
+ path$n.basename(originalFileName),
36345
36345
  ".css"
36346
36346
  );
36347
36347
  if (!styles.has(id)) {
@@ -36353,7 +36353,7 @@ function cssPostPlugin(config) {
36353
36353
  cssContent = resolveAssetUrlsInCss(cssContent, cssAssetName);
36354
36354
  urlEmitTasks.push({
36355
36355
  cssAssetName,
36356
- originalFilename,
36356
+ originalFileName,
36357
36357
  content: cssContent,
36358
36358
  start: match.index,
36359
36359
  end: match.index + full.length
@@ -36375,17 +36375,18 @@ function cssPostPlugin(config) {
36375
36375
  s ||= new MagicString(code);
36376
36376
  for (const {
36377
36377
  cssAssetName,
36378
- originalFilename,
36378
+ originalFileName,
36379
36379
  content,
36380
36380
  start,
36381
36381
  end
36382
36382
  } of urlEmitTasks) {
36383
36383
  const referenceId = this.emitFile({
36384
- name: cssAssetName,
36385
36384
  type: "asset",
36385
+ name: cssAssetName,
36386
+ originalFileName,
36386
36387
  source: content
36387
36388
  });
36388
- generatedAssets.get(config).set(referenceId, { originalName: originalFilename });
36389
+ generatedAssets.get(config).set(referenceId, { originalFileName });
36389
36390
  const filename = this.getFileName(referenceId);
36390
36391
  chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
36391
36392
  const replacement = toOutputFilePathInJS(
@@ -36409,7 +36410,7 @@ function cssPostPlugin(config) {
36409
36410
  const isEntry = chunk.isEntry && isPureCssChunk;
36410
36411
  const cssFullAssetName = ensureFileExt(chunk.name, ".css");
36411
36412
  const cssAssetName = chunk.isEntry && (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId)) ? path$n.basename(cssFullAssetName) : cssFullAssetName;
36412
- const originalFilename = getChunkOriginalFileName(
36413
+ const originalFileName = getChunkOriginalFileName(
36413
36414
  chunk,
36414
36415
  config.root,
36415
36416
  opts.format
@@ -36419,11 +36420,12 @@ function cssPostPlugin(config) {
36419
36420
  return finalizeCss(chunkCSS, true, config);
36420
36421
  });
36421
36422
  const referenceId = this.emitFile({
36422
- name: cssAssetName,
36423
36423
  type: "asset",
36424
+ name: cssAssetName,
36425
+ originalFileName,
36424
36426
  source: chunkCSS
36425
36427
  });
36426
- generatedAssets.get(config).set(referenceId, { originalName: originalFilename, isEntry });
36428
+ generatedAssets.get(config).set(referenceId, { originalFileName, isEntry });
36427
36429
  chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
36428
36430
  } else if (!config.build.ssr) {
36429
36431
  chunkCSS = await finalizeCss(chunkCSS, true, config);
@@ -36573,13 +36575,14 @@ function cssAnalysisPlugin(config) {
36573
36575
  const pluginImports = this._addedImports;
36574
36576
  if (pluginImports) {
36575
36577
  const depModules = /* @__PURE__ */ new Set();
36576
- const devBase = config.base;
36577
36578
  for (const file of pluginImports) {
36578
36579
  depModules.add(
36579
36580
  isCSSRequest(file) ? moduleGraph.createFileOnlyEntry(file) : await moduleGraph.ensureEntryFromUrl(
36580
- stripBase(
36581
- await fileToUrl$1(file, config, this),
36582
- (config.server?.origin ?? "") + devBase
36581
+ fileToDevUrl(
36582
+ file,
36583
+ config,
36584
+ /* skipBase */
36585
+ true
36583
36586
  ),
36584
36587
  ssr
36585
36588
  )
@@ -36930,8 +36933,8 @@ function createCachedImport(imp) {
36930
36933
  return cached;
36931
36934
  };
36932
36935
  }
36933
- const importPostcssImport = createCachedImport(() => import('./dep-C3NStZH1.js').then(function (n) { return n.i; }));
36934
- const importPostcssModules = createCachedImport(() => import('./dep-DvdjAuZF.js').then(function (n) { return n.i; }));
36936
+ const importPostcssImport = createCachedImport(() => import('./dep-CHbHjMYU.js').then(function (n) { return n.i; }));
36937
+ const importPostcssModules = createCachedImport(() => import('./dep-B8yndt7W.js').then(function (n) { return n.i; }));
36935
36938
  const importPostcss = createCachedImport(() => import('postcss'));
36936
36939
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
36937
36940
  let alwaysFakeWorkerWorkerControllerCache;
@@ -37926,7 +37929,7 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
37926
37929
  }
37927
37930
  deps.add(dep.url);
37928
37931
  if (urlReplacer) {
37929
- const replaceUrl = await urlReplacer(dep.url, id);
37932
+ const replaceUrl = await urlReplacer(dep.url, dep.loc.filePath);
37930
37933
  css = css.replace(dep.placeholder, () => replaceUrl);
37931
37934
  } else {
37932
37935
  css = css.replace(dep.placeholder, () => dep.url);
@@ -47174,8 +47177,7 @@ function throwFileNotFoundInOptimizedDep(id) {
47174
47177
  const nonJsRe = /\.json(?:$|\?)/;
47175
47178
  const isNonJsRequest = (request) => nonJsRe.test(request);
47176
47179
  const importMetaEnvMarker = "__vite_import_meta_env__";
47177
- const bareImportMetaEnvRe = new RegExp(`${importMetaEnvMarker}(?!\\.)\\b`);
47178
- const importMetaEnvKeyRe = new RegExp(`${importMetaEnvMarker}\\..+?\\b`, "g");
47180
+ const importMetaEnvKeyReCache = /* @__PURE__ */ new Map();
47179
47181
  function definePlugin(config) {
47180
47182
  const isBuild = config.command === "build";
47181
47183
  const isBuildLib = isBuild && config.build.lib;
@@ -47231,8 +47233,6 @@ function definePlugin(config) {
47231
47233
  SSR: ssr + "",
47232
47234
  ...userDefineEnv
47233
47235
  });
47234
- const banner = `const ${importMetaEnvMarker} = ${importMetaEnvVal};
47235
- `;
47236
47236
  const patternKeys = Object.keys(userDefine);
47237
47237
  if (replaceProcessEnv && Object.keys(processEnv).length) {
47238
47238
  patternKeys.push("process.env");
@@ -47241,7 +47241,7 @@ function definePlugin(config) {
47241
47241
  patternKeys.push("import.meta.env", "import.meta.hot");
47242
47242
  }
47243
47243
  const pattern = patternKeys.length ? new RegExp(patternKeys.map(escapeRegex).join("|")) : null;
47244
- return [define, pattern, banner];
47244
+ return [define, pattern, importMetaEnvVal];
47245
47245
  }
47246
47246
  const defaultPattern = generatePattern(false);
47247
47247
  const ssrPattern = generatePattern(true);
@@ -47258,21 +47258,35 @@ function definePlugin(config) {
47258
47258
  ) {
47259
47259
  return;
47260
47260
  }
47261
- const [define, pattern, banner] = ssr ? ssrPattern : defaultPattern;
47261
+ let [define, pattern, importMetaEnvVal] = ssr ? ssrPattern : defaultPattern;
47262
47262
  if (!pattern) return;
47263
47263
  pattern.lastIndex = 0;
47264
47264
  if (!pattern.test(code)) return;
47265
+ const hasDefineImportMetaEnv = "import.meta.env" in define;
47266
+ let marker = importMetaEnvMarker;
47267
+ if (hasDefineImportMetaEnv && code.includes(marker)) {
47268
+ let i = 1;
47269
+ do {
47270
+ marker = importMetaEnvMarker + i++;
47271
+ } while (code.includes(marker));
47272
+ if (marker !== importMetaEnvMarker) {
47273
+ define = { ...define, "import.meta.env": marker };
47274
+ }
47275
+ }
47265
47276
  const result = await replaceDefine(code, id, define, config);
47266
- result.code = result.code.replaceAll(
47267
- importMetaEnvKeyRe,
47268
- (m) => "undefined".padEnd(m.length)
47269
- );
47270
- if (bareImportMetaEnvRe.test(result.code)) {
47271
- result.code = banner + result.code;
47272
- if (result.map) {
47273
- const map = JSON.parse(result.map);
47274
- map.mappings = ";" + map.mappings;
47275
- result.map = map;
47277
+ if (hasDefineImportMetaEnv) {
47278
+ result.code = result.code.replaceAll(
47279
+ getImportMetaEnvKeyRe(marker),
47280
+ (m) => "undefined".padEnd(m.length)
47281
+ );
47282
+ if (result.code.includes(marker)) {
47283
+ result.code = `const ${marker} = ${importMetaEnvVal};
47284
+ ` + result.code;
47285
+ if (result.map) {
47286
+ const map = JSON.parse(result.map);
47287
+ map.mappings = ";" + map.mappings;
47288
+ result.map = map;
47289
+ }
47276
47290
  }
47277
47291
  }
47278
47292
  return result;
@@ -47328,6 +47342,14 @@ function handleDefineValue(value) {
47328
47342
  if (typeof value === "string") return value;
47329
47343
  return JSON.stringify(value);
47330
47344
  }
47345
+ function getImportMetaEnvKeyRe(marker) {
47346
+ let re = importMetaEnvKeyReCache.get(marker);
47347
+ if (!re) {
47348
+ re = new RegExp(`${marker}\\..+?\\b`, "g");
47349
+ importMetaEnvKeyReCache.set(marker, re);
47350
+ }
47351
+ return re;
47352
+ }
47331
47353
 
47332
47354
  const normalizedClientEntry = normalizePath$3(CLIENT_ENTRY);
47333
47355
  const normalizedEnvEntry = normalizePath$3(ENV_ENTRY);
@@ -47534,6 +47556,7 @@ async function bundleWorkerEntry(config, id) {
47534
47556
  } else if (outputChunk2.type === "chunk") {
47535
47557
  saveEmitWorkerAsset(config, {
47536
47558
  fileName: outputChunk2.fileName,
47559
+ originalFileName: null,
47537
47560
  source: outputChunk2.code
47538
47561
  });
47539
47562
  }
@@ -47551,6 +47574,7 @@ function emitSourcemapForWorkerEntry(config, chunk) {
47551
47574
  const mapFileName = chunk.fileName + ".map";
47552
47575
  saveEmitWorkerAsset(config, {
47553
47576
  fileName: mapFileName,
47577
+ originalFileName: null,
47554
47578
  source: data
47555
47579
  });
47556
47580
  }
@@ -47574,6 +47598,7 @@ async function workerFileToUrl(config, id) {
47574
47598
  fileName = outputChunk.fileName;
47575
47599
  saveEmitWorkerAsset(config, {
47576
47600
  fileName,
47601
+ originalFileName: null,
47577
47602
  source: outputChunk.code
47578
47603
  });
47579
47604
  workerMap.bundle.set(id, fileName);
@@ -47671,7 +47696,7 @@ function webWorkerPlugin(config) {
47671
47696
  }`;
47672
47697
  let urlCode;
47673
47698
  if (isBuild) {
47674
- if (isWorker && this.getModuleInfo(cleanUrl(id))?.isEntry) {
47699
+ if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) {
47675
47700
  urlCode = "self.location.href";
47676
47701
  } else if (inlineRE.test(id)) {
47677
47702
  const chunk = await bundleWorkerEntry(config, id);
@@ -47798,6 +47823,7 @@ function webWorkerPlugin(config) {
47798
47823
  this.emitFile({
47799
47824
  type: "asset",
47800
47825
  fileName: asset.fileName,
47826
+ originalFileName: asset.originalFileName,
47801
47827
  source: asset.source
47802
47828
  });
47803
47829
  });
@@ -48000,7 +48026,7 @@ function workerImportMetaUrlPlugin(config) {
48000
48026
  file = await workerResolver(url, id);
48001
48027
  file ??= url[0] === "/" ? slash$1(path$n.join(config.publicDir, url)) : slash$1(path$n.resolve(path$n.dirname(id), url));
48002
48028
  }
48003
- if (isBuild && config.isWorker && this.getModuleInfo(cleanUrl(file))?.isEntry) {
48029
+ if (isBuild && config.isWorker && config.bundleChain.at(-1) === cleanUrl(file)) {
48004
48030
  s.update(expStart, expEnd, "self.location.href");
48005
48031
  } else {
48006
48032
  let builtUrl;
@@ -54228,10 +54254,10 @@ function resolveEmptyOutDir(emptyOutDir, root, outDirs, logger) {
54228
54254
  for (const outDir of outDirs) {
54229
54255
  if (!normalizePath$3(outDir).startsWith(withTrailingSlash(root))) {
54230
54256
  logger?.warn(
54231
- picocolorsExports.yellow(
54257
+ colors$1.yellow(
54232
54258
  `
54233
- ${picocolorsExports.bold(`(!)`)} outDir ${picocolorsExports.white(
54234
- picocolorsExports.dim(outDir)
54259
+ ${colors$1.bold(`(!)`)} outDir ${colors$1.white(
54260
+ colors$1.dim(outDir)
54235
54261
  )} is not inside project root and will not be emptied.
54236
54262
  Use --emptyOutDir to override.
54237
54263
  `
@@ -64465,21 +64491,13 @@ function buildImportAnalysisPlugin(config) {
64465
64491
  const ssr = !!config.build.ssr;
64466
64492
  const isWorker = config.isWorker;
64467
64493
  const insertPreload = !(ssr || !!config.build.lib || isWorker);
64468
- const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;
64469
64494
  const renderBuiltUrl = config.experimental.renderBuiltUrl;
64470
- const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
64471
64495
  const isRelativeBase = config.base === "./" || config.base === "";
64472
- const optimizeModulePreloadRelativePaths = isRelativeBase && !customModulePreloadPaths;
64473
64496
  const { modulePreload } = config.build;
64474
64497
  const scriptRel2 = modulePreload && modulePreload.polyfill ? `'modulepreload'` : `(${detectScriptRel.toString()})()`;
64475
- const assetsURL2 = customModulePreloadPaths ? (
64476
- // If `experimental.renderBuiltUrl` or `build.modulePreload.resolveDependencies` are used
64477
- // the dependencies are already resolved. To avoid the need for `new URL(dep, import.meta.url)`
64478
- // a helper `__vitePreloadRelativeDep` is used to resolve from relative paths which can be minimized.
64479
- `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
64480
- ) : optimizeModulePreloadRelativePaths ? (
64481
- // If there isn't custom resolvers affecting the deps list, deps in the list are relative
64482
- // to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
64498
+ const assetsURL2 = renderBuiltUrl || isRelativeBase ? (
64499
+ // If `experimental.renderBuiltUrl` is used, the dependencies might be relative to the current chunk.
64500
+ // If relative base is used, the dependencies are relative to the current chunk.
64483
64501
  // The importerUrl is passed as third parameter to __vitePreload in this case
64484
64502
  `function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
64485
64503
  ) : (
@@ -64573,7 +64591,7 @@ function buildImportAnalysisPlugin(config) {
64573
64591
  }
64574
64592
  str().appendRight(
64575
64593
  expEnd,
64576
- `,${isModernFlag}?${preloadMarker}:void 0${optimizeModulePreloadRelativePaths || customModulePreloadPaths ? ",import.meta.url" : ""})`
64594
+ `,${isModernFlag}?${preloadMarker}:void 0${renderBuiltUrl || isRelativeBase ? ",import.meta.url" : ""})`
64577
64595
  );
64578
64596
  }
64579
64597
  }
@@ -64754,34 +64772,30 @@ function buildImportAnalysisPlugin(config) {
64754
64772
  markerStartPos2 = indexOfMatchInSlice(code, preloadMarkerRE);
64755
64773
  }
64756
64774
  if (markerStartPos2 > 0) {
64757
- const depsArray = deps.size > 1 || // main chunk is removed
64775
+ let depsArray = deps.size > 1 || // main chunk is removed
64758
64776
  hasRemovedPureCssChunk && deps.size > 0 ? modulePreload === false ? (
64759
64777
  // CSS deps use the same mechanism as module preloads, so even if disabled,
64760
64778
  // we still need to pass these deps to the preload helper in dynamic imports.
64761
64779
  [...deps].filter((d) => d.endsWith(".css"))
64762
64780
  ) : [...deps] : [];
64763
- let renderedDeps;
64764
- if (normalizedFile && customModulePreloadPaths) {
64765
- const { modulePreload: modulePreload2 } = config.build;
64766
- const resolveDependencies = modulePreload2 ? modulePreload2.resolveDependencies : void 0;
64767
- let resolvedDeps;
64768
- if (resolveDependencies) {
64769
- const cssDeps = [];
64770
- const otherDeps = [];
64771
- for (const dep of depsArray) {
64772
- (dep.endsWith(".css") ? cssDeps : otherDeps).push(dep);
64773
- }
64774
- resolvedDeps = [
64775
- ...resolveDependencies(normalizedFile, otherDeps, {
64776
- hostId: file,
64777
- hostType: "js"
64778
- }),
64779
- ...cssDeps
64780
- ];
64781
- } else {
64782
- resolvedDeps = depsArray;
64781
+ const resolveDependencies = modulePreload ? modulePreload.resolveDependencies : void 0;
64782
+ if (resolveDependencies && normalizedFile) {
64783
+ const cssDeps = [];
64784
+ const otherDeps = [];
64785
+ for (const dep of depsArray) {
64786
+ (dep.endsWith(".css") ? cssDeps : otherDeps).push(dep);
64783
64787
  }
64784
- renderedDeps = resolvedDeps.map((dep) => {
64788
+ depsArray = [
64789
+ ...resolveDependencies(normalizedFile, otherDeps, {
64790
+ hostId: file,
64791
+ hostType: "js"
64792
+ }),
64793
+ ...cssDeps
64794
+ ];
64795
+ }
64796
+ let renderedDeps;
64797
+ if (renderBuiltUrl) {
64798
+ renderedDeps = depsArray.map((dep) => {
64785
64799
  const replacement = toOutputFilePathInJS(
64786
64800
  dep,
64787
64801
  "asset",
@@ -64800,7 +64814,7 @@ function buildImportAnalysisPlugin(config) {
64800
64814
  (d) => (
64801
64815
  // Don't include the assets dir if the default asset file names
64802
64816
  // are used, the path will be reconstructed by the import preload helper
64803
- optimizeModulePreloadRelativePaths ? addFileDep(toRelativePath(d, file)) : addFileDep(d)
64817
+ isRelativeBase ? addFileDep(toRelativePath(d, file)) : addFileDep(d)
64804
64818
  )
64805
64819
  );
64806
64820
  }
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-NjL7WTE1.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-BzOvws4Y.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-IQS-Za7F.js';
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs__default from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-NjL7WTE1.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-BzOvws4Y.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -730,7 +730,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
730
730
  `[boolean] force the optimizer to ignore the cache and re-bundle`
731
731
  ).action(async (root, options) => {
732
732
  filterDuplicateOptions(options);
733
- const { createServer } = await import('./chunks/dep-NjL7WTE1.js').then(function (n) { return n.E; });
733
+ const { createServer } = await import('./chunks/dep-BzOvws4Y.js').then(function (n) { return n.E; });
734
734
  try {
735
735
  const server = await createServer({
736
736
  root,
@@ -822,7 +822,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
822
822
  `[boolean] force empty outDir when it's outside of root`
823
823
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
824
824
  filterDuplicateOptions(options);
825
- const { build } = await import('./chunks/dep-NjL7WTE1.js').then(function (n) { return n.F; });
825
+ const { build } = await import('./chunks/dep-BzOvws4Y.js').then(function (n) { return n.F; });
826
826
  const buildOptions = cleanOptions(options);
827
827
  try {
828
828
  await build({
@@ -851,7 +851,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
851
851
  ).action(
852
852
  async (root, options) => {
853
853
  filterDuplicateOptions(options);
854
- const { optimizeDeps } = await import('./chunks/dep-NjL7WTE1.js').then(function (n) { return n.D; });
854
+ const { optimizeDeps } = await import('./chunks/dep-BzOvws4Y.js').then(function (n) { return n.D; });
855
855
  try {
856
856
  const config = await resolveConfig(
857
857
  {
@@ -877,7 +877,7 @@ ${e.stack}`),
877
877
  cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
878
878
  async (root, options) => {
879
879
  filterDuplicateOptions(options);
880
- const { preview } = await import('./chunks/dep-NjL7WTE1.js').then(function (n) { return n.G; });
880
+ const { preview } = await import('./chunks/dep-BzOvws4Y.js').then(function (n) { return n.G; });
881
881
  try {
882
882
  const server = await preview({
883
883
  root,
@@ -717,7 +717,7 @@ interface CommonServerOptions {
717
717
  * https://github.com/expressjs/cors#configuration-options
718
718
  */
719
719
  interface CorsOptions {
720
- origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
720
+ origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
721
721
  methods?: string | string[];
722
722
  allowedHeaders?: string | string[];
723
723
  exposedHeaders?: string | string[];
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-NjL7WTE1.js';
3
- export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-NjL7WTE1.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BzOvws4Y.js';
3
+ export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BzOvws4Y.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import { existsSync, readFileSync } from 'node:fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.4.0",
3
+ "version": "5.4.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,8 +73,8 @@
73
73
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
74
74
  "dependencies": {
75
75
  "esbuild": "^0.21.3",
76
- "postcss": "^8.4.40",
77
- "rollup": "^4.13.0"
76
+ "postcss": "^8.4.41",
77
+ "rollup": "^4.20.0"
78
78
  },
79
79
  "optionalDependencies": {
80
80
  "fsevents": "~2.3.3"
@@ -110,7 +110,7 @@
110
110
  "fast-glob": "^3.3.2",
111
111
  "http-proxy": "^1.18.1",
112
112
  "launch-editor-middleware": "^2.8.1",
113
- "lightningcss": "^1.25.1",
113
+ "lightningcss": "^1.26.0",
114
114
  "magic-string": "^0.30.11",
115
115
  "micromatch": "^4.0.7",
116
116
  "mlly": "^1.7.1",