vite 5.4.1 → 5.4.3

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.

@@ -18326,8 +18326,8 @@ function pattern2regex(resolvedPattern, allowJs) {
18326
18326
  function replaceTokens(tsconfig, configDir) {
18327
18327
  return JSON.parse(
18328
18328
  JSON.stringify(tsconfig)
18329
- // replace ${configDir}, accounting for rebaseRelative emitted ../${configDir}
18330
- .replaceAll(/"(?:\.\.\/)*\${configDir}/g, `"${native2posix(configDir)}`)
18329
+ // replace ${configDir}
18330
+ .replaceAll(/"\${configDir}/g, `"${native2posix(configDir)}`)
18331
18331
  );
18332
18332
  }
18333
18333
 
@@ -18921,7 +18921,7 @@ function rebaseRelative(key, value, prependPath) {
18921
18921
  * @returns {string}
18922
18922
  */
18923
18923
  function rebasePath(value, prependPath) {
18924
- if (path$n.isAbsolute(value)) {
18924
+ if (path$n.isAbsolute(value) || value.startsWith('${configDir}')) {
18925
18925
  return value;
18926
18926
  } else {
18927
18927
  // relative paths use posix syntax in tsconfig
@@ -20306,7 +20306,8 @@ function assetPlugin(config) {
20306
20306
  code: `export default ${JSON.stringify(encodeURIPath(url))}`,
20307
20307
  // Force rollup to keep this module from being shared between other entry points if it's an entrypoint.
20308
20308
  // If the resulting chunk is empty, it will be removed in generateBundle.
20309
- moduleSideEffects: config.command === "build" && this.getModuleInfo(id)?.isEntry ? "no-treeshake" : false
20309
+ moduleSideEffects: config.command === "build" && this.getModuleInfo(id)?.isEntry ? "no-treeshake" : false,
20310
+ meta: config.command === "build" ? { "vite:asset": true } : void 0
20310
20311
  };
20311
20312
  },
20312
20313
  renderChunk(code, chunk, opts) {
@@ -20323,7 +20324,7 @@ function assetPlugin(config) {
20323
20324
  generateBundle(_, bundle) {
20324
20325
  for (const file in bundle) {
20325
20326
  const chunk = bundle[file];
20326
- if (chunk.type === "chunk" && chunk.isEntry && chunk.moduleIds.length === 1 && config.assetsInclude(chunk.moduleIds[0])) {
20327
+ if (chunk.type === "chunk" && chunk.isEntry && chunk.moduleIds.length === 1 && config.assetsInclude(chunk.moduleIds[0]) && this.getModuleInfo(chunk.moduleIds[0])?.meta["vite:asset"]) {
20327
20328
  delete bundle[file];
20328
20329
  }
20329
20330
  }
@@ -20344,7 +20345,7 @@ async function fileToUrl$1(id, config, ctx) {
20344
20345
  return fileToBuiltUrl(id, config, ctx);
20345
20346
  }
20346
20347
  }
20347
- function fileToDevUrl(id, config) {
20348
+ function fileToDevUrl(id, config, skipBase = false) {
20348
20349
  let rtn;
20349
20350
  if (checkPublicFile(id, config)) {
20350
20351
  rtn = id;
@@ -20353,6 +20354,9 @@ function fileToDevUrl(id, config) {
20353
20354
  } else {
20354
20355
  rtn = path$n.posix.join(FS_PREFIX, id);
20355
20356
  }
20357
+ if (skipBase) {
20358
+ return rtn;
20359
+ }
20356
20360
  const base = joinUrlSegments(config.server?.origin ?? "", config.decodedBase);
20357
20361
  return joinUrlSegments(base, removeLeadingSlash(rtn));
20358
20362
  }
@@ -20408,14 +20412,15 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
20408
20412
  } else {
20409
20413
  const { search, hash } = parse$h(id);
20410
20414
  const postfix = (search || "") + (hash || "");
20415
+ const originalFileName = normalizePath$3(path$n.relative(config.root, file));
20411
20416
  const referenceId = pluginContext.emitFile({
20417
+ type: "asset",
20412
20418
  // Ignore directory structure for asset file names
20413
20419
  name: path$n.basename(file),
20414
- type: "asset",
20420
+ originalFileName,
20415
20421
  source: content
20416
20422
  });
20417
- const originalName = normalizePath$3(path$n.relative(config.root, file));
20418
- generatedAssets.get(config).set(referenceId, { originalName });
20423
+ generatedAssets.get(config).set(referenceId, { originalFileName });
20419
20424
  url = `__VITE_ASSET__${referenceId}__${postfix ? `$_${postfix}__` : ``}`;
20420
20425
  }
20421
20426
  cache.set(id, url);
@@ -20526,40 +20531,42 @@ function manifestPlugin(config) {
20526
20531
  if (isEntry) manifestChunk.isEntry = true;
20527
20532
  return manifestChunk;
20528
20533
  }
20529
- const fileNameToAssetMeta = /* @__PURE__ */ new Map();
20530
20534
  const assets = generatedAssets.get(config);
20531
- assets.forEach((asset, referenceId) => {
20532
- try {
20533
- const fileName = this.getFileName(referenceId);
20534
- fileNameToAssetMeta.set(fileName, asset);
20535
- } catch (error) {
20536
- assets.delete(referenceId);
20535
+ const entryCssAssetFileNames = /* @__PURE__ */ new Set();
20536
+ for (const [id, asset] of assets.entries()) {
20537
+ if (asset.isEntry) {
20538
+ try {
20539
+ const fileName = this.getFileName(id);
20540
+ entryCssAssetFileNames.add(fileName);
20541
+ } catch (error) {
20542
+ assets.delete(id);
20543
+ }
20537
20544
  }
20538
- });
20545
+ }
20539
20546
  const fileNameToAsset = /* @__PURE__ */ new Map();
20540
20547
  for (const file in bundle) {
20541
20548
  const chunk = bundle[file];
20542
20549
  if (chunk.type === "chunk") {
20543
20550
  manifest[getChunkName(chunk)] = createChunk(chunk);
20544
20551
  } else if (chunk.type === "asset" && typeof chunk.name === "string") {
20545
- const assetMeta = fileNameToAssetMeta.get(chunk.fileName);
20546
- const src = assetMeta?.originalName ?? chunk.name;
20547
- const asset = createAsset(chunk, src, assetMeta?.isEntry);
20552
+ const src = chunk.originalFileName ?? chunk.name;
20553
+ const isEntry = entryCssAssetFileNames.has(chunk.fileName);
20554
+ const asset = createAsset(chunk, src, isEntry);
20548
20555
  const file2 = manifest[src]?.file;
20549
20556
  if (file2 && endsWithJSRE.test(file2)) continue;
20550
20557
  manifest[src] = asset;
20551
20558
  fileNameToAsset.set(chunk.fileName, asset);
20552
20559
  }
20553
20560
  }
20554
- assets.forEach(({ originalName }, referenceId) => {
20555
- if (!manifest[originalName]) {
20561
+ for (const [referenceId, { originalFileName }] of assets.entries()) {
20562
+ if (!manifest[originalFileName]) {
20556
20563
  const fileName = this.getFileName(referenceId);
20557
20564
  const asset = fileNameToAsset.get(fileName);
20558
20565
  if (asset) {
20559
- manifest[originalName] = asset;
20566
+ manifest[originalFileName] = asset;
20560
20567
  }
20561
20568
  }
20562
- });
20569
+ }
20563
20570
  outputCount++;
20564
20571
  const output = config.build.rollupOptions?.output;
20565
20572
  const outputLength = Array.isArray(output) ? output.length : 1;
@@ -22762,7 +22769,12 @@ const util = require$$0$5;
22762
22769
  const braces$1 = braces_1;
22763
22770
  const picomatch$2 = picomatch$3;
22764
22771
  const utils$b = utils$k;
22765
- const isEmptyString = val => val === '' || val === './';
22772
+
22773
+ const isEmptyString = v => v === '' || v === './';
22774
+ const hasBraces = v => {
22775
+ const index = v.indexOf('{');
22776
+ return index > -1 && v.indexOf('}', index) > -1;
22777
+ };
22766
22778
 
22767
22779
  /**
22768
22780
  * Returns an array of strings that match one or more glob patterns.
@@ -23203,7 +23215,7 @@ micromatch$1.parse = (patterns, options) => {
23203
23215
 
23204
23216
  micromatch$1.braces = (pattern, options) => {
23205
23217
  if (typeof pattern !== 'string') throw new TypeError('Expected a string');
23206
- if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
23218
+ if ((options && options.nobrace === true) || !hasBraces(pattern)) {
23207
23219
  return [pattern];
23208
23220
  }
23209
23221
  return braces$1(pattern, options);
@@ -23222,6 +23234,8 @@ micromatch$1.braceExpand = (pattern, options) => {
23222
23234
  * Expose micromatch
23223
23235
  */
23224
23236
 
23237
+ // exposed for tests
23238
+ micromatch$1.hasBraces = hasBraces;
23225
23239
  var micromatch_1 = micromatch$1;
23226
23240
 
23227
23241
  var micromatch$2 = /*@__PURE__*/getDefaultExportFromCjs(micromatch_1);
@@ -32456,9 +32470,6 @@ function getFirstKeyStartProps(prev) {
32456
32470
  break loop;
32457
32471
  }
32458
32472
  }
32459
- while (prev[++i]?.type === 'space') {
32460
- /* loop */
32461
- }
32462
32473
  return prev.splice(i, prev.length);
32463
32474
  }
32464
32475
  function fixFlowSeqItems(fc) {
@@ -35038,6 +35049,9 @@ function nodeIsElement(node) {
35038
35049
  return node.nodeName[0] !== "#";
35039
35050
  }
35040
35051
  function traverseNodes(node, visitor) {
35052
+ if (node.nodeName === "template") {
35053
+ node = node.content;
35054
+ }
35041
35055
  visitor(node);
35042
35056
  if (nodeIsElement(node) || node.nodeName === "#document" || node.nodeName === "#document-fragment") {
35043
35057
  node.childNodes.forEach((childNode) => traverseNodes(childNode, visitor));
@@ -35601,6 +35615,7 @@ ${js}`;
35601
35615
  );
35602
35616
  this.emitFile({
35603
35617
  type: "asset",
35618
+ originalFileName: normalizedId,
35604
35619
  fileName: shortEmitName,
35605
35620
  source: result
35606
35621
  });
@@ -36163,8 +36178,9 @@ function cssPostPlugin(config) {
36163
36178
  } else {
36164
36179
  return path$n.dirname(
36165
36180
  assetFileNames({
36166
- name: cssAssetName,
36167
36181
  type: "asset",
36182
+ name: cssAssetName,
36183
+ originalFileName: null,
36168
36184
  source: "/* vite internal call, ignore */"
36169
36185
  })
36170
36186
  );
@@ -36334,9 +36350,9 @@ function cssPostPlugin(config) {
36334
36350
  while (match = cssUrlAssetRE.exec(code)) {
36335
36351
  const [full, idHex] = match;
36336
36352
  const id = Buffer.from(idHex, "hex").toString();
36337
- const originalFilename = cleanUrl(id);
36353
+ const originalFileName = cleanUrl(id);
36338
36354
  const cssAssetName = ensureFileExt(
36339
- path$n.basename(originalFilename),
36355
+ path$n.basename(originalFileName),
36340
36356
  ".css"
36341
36357
  );
36342
36358
  if (!styles.has(id)) {
@@ -36348,7 +36364,7 @@ function cssPostPlugin(config) {
36348
36364
  cssContent = resolveAssetUrlsInCss(cssContent, cssAssetName);
36349
36365
  urlEmitTasks.push({
36350
36366
  cssAssetName,
36351
- originalFilename,
36367
+ originalFileName,
36352
36368
  content: cssContent,
36353
36369
  start: match.index,
36354
36370
  end: match.index + full.length
@@ -36370,17 +36386,18 @@ function cssPostPlugin(config) {
36370
36386
  s ||= new MagicString(code);
36371
36387
  for (const {
36372
36388
  cssAssetName,
36373
- originalFilename,
36389
+ originalFileName,
36374
36390
  content,
36375
36391
  start,
36376
36392
  end
36377
36393
  } of urlEmitTasks) {
36378
36394
  const referenceId = this.emitFile({
36379
- name: cssAssetName,
36380
36395
  type: "asset",
36396
+ name: cssAssetName,
36397
+ originalFileName,
36381
36398
  source: content
36382
36399
  });
36383
- generatedAssets.get(config).set(referenceId, { originalName: originalFilename });
36400
+ generatedAssets.get(config).set(referenceId, { originalFileName });
36384
36401
  const filename = this.getFileName(referenceId);
36385
36402
  chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
36386
36403
  const replacement = toOutputFilePathInJS(
@@ -36404,7 +36421,7 @@ function cssPostPlugin(config) {
36404
36421
  const isEntry = chunk.isEntry && isPureCssChunk;
36405
36422
  const cssFullAssetName = ensureFileExt(chunk.name, ".css");
36406
36423
  const cssAssetName = chunk.isEntry && (!chunk.facadeModuleId || !isCSSRequest(chunk.facadeModuleId)) ? path$n.basename(cssFullAssetName) : cssFullAssetName;
36407
- const originalFilename = getChunkOriginalFileName(
36424
+ const originalFileName = getChunkOriginalFileName(
36408
36425
  chunk,
36409
36426
  config.root,
36410
36427
  opts.format
@@ -36414,11 +36431,12 @@ function cssPostPlugin(config) {
36414
36431
  return finalizeCss(chunkCSS, true, config);
36415
36432
  });
36416
36433
  const referenceId = this.emitFile({
36417
- name: cssAssetName,
36418
36434
  type: "asset",
36435
+ name: cssAssetName,
36436
+ originalFileName,
36419
36437
  source: chunkCSS
36420
36438
  });
36421
- generatedAssets.get(config).set(referenceId, { originalName: originalFilename, isEntry });
36439
+ generatedAssets.get(config).set(referenceId, { originalFileName, isEntry });
36422
36440
  chunk.viteMetadata.importedCss.add(this.getFileName(referenceId));
36423
36441
  } else if (!config.build.ssr) {
36424
36442
  chunkCSS = await finalizeCss(chunkCSS, true, config);
@@ -36568,13 +36586,14 @@ function cssAnalysisPlugin(config) {
36568
36586
  const pluginImports = this._addedImports;
36569
36587
  if (pluginImports) {
36570
36588
  const depModules = /* @__PURE__ */ new Set();
36571
- const devBase = config.base;
36572
36589
  for (const file of pluginImports) {
36573
36590
  depModules.add(
36574
36591
  isCSSRequest(file) ? moduleGraph.createFileOnlyEntry(file) : await moduleGraph.ensureEntryFromUrl(
36575
- stripBase(
36576
- await fileToUrl$1(file, config, this),
36577
- (config.server?.origin ?? "") + devBase
36592
+ fileToDevUrl(
36593
+ file,
36594
+ config,
36595
+ /* skipBase */
36596
+ true
36578
36597
  ),
36579
36598
  ssr
36580
36599
  )
@@ -36625,14 +36644,23 @@ function createCSSResolvers(config) {
36625
36644
  }));
36626
36645
  },
36627
36646
  get sass() {
36628
- return sassResolve || (sassResolve = config.createResolver({
36629
- extensions: [".scss", ".sass", ".css"],
36630
- mainFields: ["sass", "style"],
36631
- conditions: ["sass", "style"],
36632
- tryIndex: true,
36633
- tryPrefix: "_",
36634
- preferRelative: true
36635
- }));
36647
+ if (!sassResolve) {
36648
+ const resolver = config.createResolver({
36649
+ extensions: [".scss", ".sass", ".css"],
36650
+ mainFields: ["sass", "style"],
36651
+ conditions: ["sass", "style"],
36652
+ tryIndex: true,
36653
+ tryPrefix: "_",
36654
+ preferRelative: true
36655
+ });
36656
+ sassResolve = async (...args) => {
36657
+ if (args[0].startsWith("file://")) {
36658
+ args[0] = fileURLToPath(args[0]);
36659
+ }
36660
+ return resolver(...args);
36661
+ };
36662
+ }
36663
+ return sassResolve;
36636
36664
  },
36637
36665
  get less() {
36638
36666
  return lessResolve || (lessResolve = config.createResolver({
@@ -36925,8 +36953,8 @@ function createCachedImport(imp) {
36925
36953
  return cached;
36926
36954
  };
36927
36955
  }
36928
- const importPostcssImport = createCachedImport(() => import('./dep-SDtFYyy1.js').then(function (n) { return n.i; }));
36929
- const importPostcssModules = createCachedImport(() => import('./dep-BkYu-SNl.js').then(function (n) { return n.i; }));
36956
+ const importPostcssImport = createCachedImport(() => import('./dep-DmgIY-c5.js').then(function (n) { return n.i; }));
36957
+ const importPostcssModules = createCachedImport(() => import('./dep-DlM3pmpg.js').then(function (n) { return n.i; }));
36930
36958
  const importPostcss = createCachedImport(() => import('postcss'));
36931
36959
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
36932
36960
  let alwaysFakeWorkerWorkerControllerCache;
@@ -37273,7 +37301,7 @@ function fixScssBugImportValue(data) {
37273
37301
  }
37274
37302
  return data;
37275
37303
  }
37276
- const makeScssWorker = (resolvers, alias, maxWorkers) => {
37304
+ const makeScssWorker = (resolvers, alias, maxWorkers, packageName) => {
37277
37305
  const internalImporter = async (url, importer, filename) => {
37278
37306
  importer = cleanScssBugUrl(importer);
37279
37307
  const resolved = await resolvers.sass(url, importer);
@@ -37286,6 +37314,9 @@ const makeScssWorker = (resolvers, alias, maxWorkers) => {
37286
37314
  "$",
37287
37315
  resolvers.sass
37288
37316
  );
37317
+ if (packageName === "sass-embedded") {
37318
+ return data;
37319
+ }
37289
37320
  return fixScssBugImportValue(data);
37290
37321
  } catch (data) {
37291
37322
  return data;
@@ -37482,7 +37513,12 @@ const scssProcessor = (maxWorkers) => {
37482
37513
  if (!workerMap.has(options.alias)) {
37483
37514
  workerMap.set(
37484
37515
  options.alias,
37485
- api === "modern-compiler" ? makeModernCompilerScssWorker(resolvers, options.alias) : api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker(resolvers, options.alias, maxWorkers)
37516
+ api === "modern-compiler" ? makeModernCompilerScssWorker(resolvers, options.alias) : api === "modern" ? makeModernScssWorker(resolvers, options.alias, maxWorkers) : makeScssWorker(
37517
+ resolvers,
37518
+ options.alias,
37519
+ maxWorkers,
37520
+ sassPackage.name
37521
+ )
37486
37522
  );
37487
37523
  }
37488
37524
  const worker = workerMap.get(options.alias);
@@ -37504,6 +37540,11 @@ const scssProcessor = (maxWorkers) => {
37504
37540
  );
37505
37541
  const deps = result.stats.includedFiles.map((f) => cleanScssBugUrl(f));
37506
37542
  const map2 = result.map ? JSON.parse(result.map.toString()) : void 0;
37543
+ if (map2) {
37544
+ map2.sources = map2.sources.map(
37545
+ (url) => url.startsWith("file://") ? normalizePath$3(fileURLToPath(url)) : url
37546
+ );
37547
+ }
37507
37548
  return {
37508
37549
  code: result.css.toString(),
37509
37550
  map: map2,
@@ -47548,6 +47589,7 @@ async function bundleWorkerEntry(config, id) {
47548
47589
  } else if (outputChunk2.type === "chunk") {
47549
47590
  saveEmitWorkerAsset(config, {
47550
47591
  fileName: outputChunk2.fileName,
47592
+ originalFileName: null,
47551
47593
  source: outputChunk2.code
47552
47594
  });
47553
47595
  }
@@ -47565,6 +47607,7 @@ function emitSourcemapForWorkerEntry(config, chunk) {
47565
47607
  const mapFileName = chunk.fileName + ".map";
47566
47608
  saveEmitWorkerAsset(config, {
47567
47609
  fileName: mapFileName,
47610
+ originalFileName: null,
47568
47611
  source: data
47569
47612
  });
47570
47613
  }
@@ -47588,6 +47631,7 @@ async function workerFileToUrl(config, id) {
47588
47631
  fileName = outputChunk.fileName;
47589
47632
  saveEmitWorkerAsset(config, {
47590
47633
  fileName,
47634
+ originalFileName: null,
47591
47635
  source: outputChunk.code
47592
47636
  });
47593
47637
  workerMap.bundle.set(id, fileName);
@@ -47812,6 +47856,7 @@ function webWorkerPlugin(config) {
47812
47856
  this.emitFile({
47813
47857
  type: "asset",
47814
47858
  fileName: asset.fileName,
47859
+ originalFileName: asset.originalFileName,
47815
47860
  source: asset.source
47816
47861
  });
47817
47862
  });
@@ -51519,7 +51564,8 @@ function servePublicMiddleware(server, publicFiles) {
51519
51564
  return normalizePath$3(filePath);
51520
51565
  };
51521
51566
  return function viteServePublicMiddleware(req, res, next) {
51522
- if (publicFiles && !publicFiles.has(toFilePath(req.url)) || isImportRequest(req.url) || isInternalRequest(req.url)) {
51567
+ if (publicFiles && !publicFiles.has(toFilePath(req.url)) || isImportRequest(req.url) || isInternalRequest(req.url) || // for `/public-file.js?url` to be transformed
51568
+ urlRE.test(req.url)) {
51523
51569
  return next();
51524
51570
  }
51525
51571
  serve(req, res, next);
@@ -54256,14 +54302,14 @@ Use --emptyOutDir to override.
54256
54302
  }
54257
54303
  return true;
54258
54304
  }
54259
- function resolveChokidarOptions(config, options, resolvedOutDirs, emptyOutDir) {
54305
+ function resolveChokidarOptions(options, resolvedOutDirs, emptyOutDir, cacheDir) {
54260
54306
  const { ignored: ignoredList, ...otherOptions } = options ?? {};
54261
54307
  const ignored = [
54262
54308
  "**/.git/**",
54263
54309
  "**/node_modules/**",
54264
54310
  "**/test-results/**",
54265
54311
  // Playwright
54266
- glob.escapePath(config.cacheDir) + "/**",
54312
+ glob.escapePath(cacheDir) + "/**",
54267
54313
  ...arraify(ignoredList || [])
54268
54314
  ];
54269
54315
  if (emptyOutDir) {
@@ -62654,13 +62700,13 @@ async function _createServer(inlineConfig = {}, options) {
62654
62700
  resolvedOutDirs
62655
62701
  );
62656
62702
  const resolvedWatchOptions = resolveChokidarOptions(
62657
- config,
62658
62703
  {
62659
62704
  disableGlobbing: true,
62660
62705
  ...serverConfig.watch
62661
62706
  },
62662
62707
  resolvedOutDirs,
62663
- emptyOutDir
62708
+ emptyOutDir,
62709
+ config.cacheDir
62664
62710
  );
62665
62711
  const middlewares = connect$1();
62666
62712
  const httpServer = middlewareMode ? null : await resolveHttpServer(serverConfig, middlewares, httpsOptions);
@@ -63234,14 +63280,14 @@ function setupOnCrawlEnd(onCrawlEnd) {
63234
63280
  if (ignoredId) {
63235
63281
  seenIds.add(ignoredId);
63236
63282
  markIdAsDone(ignoredId);
63283
+ } else {
63284
+ checkIfCrawlEndAfterTimeout();
63237
63285
  }
63238
63286
  return onCrawlEndPromiseWithResolvers.promise;
63239
63287
  }
63240
63288
  function markIdAsDone(id) {
63241
- if (registeredIds.has(id)) {
63242
- registeredIds.delete(id);
63243
- checkIfCrawlEndAfterTimeout();
63244
- }
63289
+ registeredIds.delete(id);
63290
+ checkIfCrawlEndAfterTimeout();
63245
63291
  }
63246
63292
  function checkIfCrawlEndAfterTimeout() {
63247
63293
  if (cancelled || registeredIds.size > 0) return;
@@ -64445,8 +64491,8 @@ function preload(baseModule, deps, importerUrl) {
64445
64491
  link.rel = isCss ? "stylesheet" : scriptRel;
64446
64492
  if (!isCss) {
64447
64493
  link.as = "script";
64448
- link.crossOrigin = "";
64449
64494
  }
64495
+ link.crossOrigin = "";
64450
64496
  link.href = dep;
64451
64497
  if (cspNonce) {
64452
64498
  link.setAttribute("nonce", cspNonce);
@@ -64481,17 +64527,11 @@ function buildImportAnalysisPlugin(config) {
64481
64527
  const insertPreload = !(ssr || !!config.build.lib || isWorker);
64482
64528
  const renderBuiltUrl = config.experimental.renderBuiltUrl;
64483
64529
  const isRelativeBase = config.base === "./" || config.base === "";
64484
- const optimizeModulePreloadRelativePaths = isRelativeBase && !renderBuiltUrl;
64485
64530
  const { modulePreload } = config.build;
64486
64531
  const scriptRel2 = modulePreload && modulePreload.polyfill ? `'modulepreload'` : `(${detectScriptRel.toString()})()`;
64487
- const assetsURL2 = renderBuiltUrl ? (
64488
- // If `experimental.renderBuiltUrl` is used, the dependencies are already resolved.
64489
- // To avoid the need for `new URL(dep, import.meta.url)`, a helper `__vitePreloadRelativeDep` is
64490
- // used to resolve from relative paths which can be minimized.
64491
- `function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
64492
- ) : optimizeModulePreloadRelativePaths ? (
64493
- // If there isn't custom resolvers affecting the deps list, deps in the list are relative
64494
- // to the current chunk and are resolved to absolute URL by the __vitePreload helper itself.
64532
+ const assetsURL2 = renderBuiltUrl || isRelativeBase ? (
64533
+ // If `experimental.renderBuiltUrl` is used, the dependencies might be relative to the current chunk.
64534
+ // If relative base is used, the dependencies are relative to the current chunk.
64495
64535
  // The importerUrl is passed as third parameter to __vitePreload in this case
64496
64536
  `function(dep, importerUrl) { return new URL(dep, importerUrl).href }`
64497
64537
  ) : (
@@ -64585,7 +64625,7 @@ function buildImportAnalysisPlugin(config) {
64585
64625
  }
64586
64626
  str().appendRight(
64587
64627
  expEnd,
64588
- `,${isModernFlag}?${preloadMarker}:void 0${optimizeModulePreloadRelativePaths || renderBuiltUrl ? ",import.meta.url" : ""})`
64628
+ `,${isModernFlag}?${preloadMarker}:void 0${renderBuiltUrl || isRelativeBase ? ",import.meta.url" : ""})`
64589
64629
  );
64590
64630
  }
64591
64631
  }
@@ -64808,7 +64848,7 @@ function buildImportAnalysisPlugin(config) {
64808
64848
  (d) => (
64809
64849
  // Don't include the assets dir if the default asset file names
64810
64850
  // are used, the path will be reconstructed by the import preload helper
64811
- optimizeModulePreloadRelativePaths ? addFileDep(toRelativePath(d, file)) : addFileDep(d)
64851
+ isRelativeBase ? addFileDep(toRelativePath(d, file)) : addFileDep(d)
64812
64852
  )
64813
64853
  );
64814
64854
  }
@@ -65123,7 +65163,7 @@ async function build(inlineConfig = {}) {
65123
65163
  "production"
65124
65164
  );
65125
65165
  const options = config.build;
65126
- const { logger } = config;
65166
+ const { root, logger, packageCache } = config;
65127
65167
  const ssr = !!options.ssr;
65128
65168
  const libOptions = options.lib;
65129
65169
  logger.info(
@@ -65133,7 +65173,7 @@ async function build(inlineConfig = {}) {
65133
65173
  )}`
65134
65174
  )
65135
65175
  );
65136
- const resolve = (p) => path$n.resolve(config.root, p);
65176
+ const resolve = (p) => path$n.resolve(root, p);
65137
65177
  const input = libOptions ? options.rollupOptions?.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries(
65138
65178
  Object.entries(libOptions.entry).map(([alias, file]) => [
65139
65179
  alias,
@@ -65234,7 +65274,7 @@ ${stackOnly}`;
65234
65274
  const format = output.format || "es";
65235
65275
  const jsExt = ssrNodeBuild || libOptions ? resolveOutputJsExtension(
65236
65276
  format,
65237
- findNearestPackageData(config.root, config.packageCache)?.data.type
65277
+ findNearestPackageData(root, packageCache)?.data.type
65238
65278
  ) : "js";
65239
65279
  return {
65240
65280
  dir: outDir,
@@ -65252,9 +65292,9 @@ ${stackOnly}`;
65252
65292
  libOptions,
65253
65293
  format,
65254
65294
  name,
65255
- config.root,
65295
+ root,
65256
65296
  jsExt,
65257
- config.packageCache
65297
+ packageCache
65258
65298
  ) : path$n.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
65259
65299
  chunkFileNames: libOptions ? `[name]-[hash].${jsExt}` : path$n.posix.join(options.assetsDir, `[name]-[hash].${jsExt}`),
65260
65300
  assetFileNames: libOptions ? `[name].[ext]` : path$n.posix.join(options.assetsDir, `[name]-[hash].[ext]`),
@@ -65276,13 +65316,13 @@ ${stackOnly}`;
65276
65316
  normalizedOutputs.push(buildOutputOptions(outputs));
65277
65317
  }
65278
65318
  const resolvedOutDirs = getResolvedOutDirs(
65279
- config.root,
65319
+ root,
65280
65320
  options.outDir,
65281
65321
  options.rollupOptions?.output
65282
65322
  );
65283
65323
  const emptyOutDir = resolveEmptyOutDir(
65284
65324
  options.emptyOutDir,
65285
- config.root,
65325
+ root,
65286
65326
  resolvedOutDirs,
65287
65327
  logger
65288
65328
  );
@@ -65290,10 +65330,10 @@ ${stackOnly}`;
65290
65330
  logger.info(colors$1.cyan(`
65291
65331
  watching for file changes...`));
65292
65332
  const resolvedChokidarOptions = resolveChokidarOptions(
65293
- config,
65294
65333
  config.build.watch.chokidar,
65295
65334
  resolvedOutDirs,
65296
- emptyOutDir
65335
+ emptyOutDir,
65336
+ config.cacheDir
65297
65337
  );
65298
65338
  const { watch } = await import('rollup');
65299
65339
  const watcher = watch({
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-Cy9twKMn.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-BaOMuo4I.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); } }
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-Cy9twKMn.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-BaOMuo4I.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-Cy9twKMn.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-BaOMuo4I.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-Cy9twKMn.js').then(function (n) { return n.E; });
733
+ const { createServer } = await import('./chunks/dep-BaOMuo4I.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-Cy9twKMn.js').then(function (n) { return n.F; });
825
+ const { build } = await import('./chunks/dep-BaOMuo4I.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-Cy9twKMn.js').then(function (n) { return n.D; });
854
+ const { optimizeDeps } = await import('./chunks/dep-BaOMuo4I.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-Cy9twKMn.js').then(function (n) { return n.G; });
880
+ const { preview } = await import('./chunks/dep-BaOMuo4I.js').then(function (n) { return n.G; });
881
881
  try {
882
882
  const server = await preview({
883
883
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-Cy9twKMn.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-Cy9twKMn.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BaOMuo4I.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-BaOMuo4I.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/index.cjs CHANGED
@@ -25,11 +25,36 @@ asyncFunctions.forEach((name) => {
25
25
 
26
26
  function warnCjsUsage() {
27
27
  if (process.env.VITE_CJS_IGNORE_WARNING) return
28
+ const logLevelIndex = process.argv.findIndex((arg) =>
29
+ /^(?:-l|--logLevel)/.test(arg),
30
+ )
31
+ if (logLevelIndex > 0) {
32
+ const logLevelValue = process.argv[logLevelIndex + 1]
33
+ if (logLevelValue === 'silent' || logLevelValue === 'error') {
34
+ return
35
+ }
36
+ if (/silent|error/.test(process.argv[logLevelIndex])) {
37
+ return
38
+ }
39
+ }
28
40
  const yellow = (str) => `\u001b[33m${str}\u001b[39m`
29
- const log = process.env.VITE_CJS_TRACE ? console.trace : console.warn
30
- log(
41
+ console.warn(
31
42
  yellow(
32
43
  `The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.`,
33
44
  ),
34
45
  )
46
+ if (process.env.VITE_CJS_TRACE) {
47
+ const e = {}
48
+ const stackTraceLimit = Error.stackTraceLimit
49
+ Error.stackTraceLimit = 100
50
+ Error.captureStackTrace(e)
51
+ Error.stackTraceLimit = stackTraceLimit
52
+ console.log(
53
+ e.stack
54
+ .split('\n')
55
+ .slice(1)
56
+ .filter((line) => !line.includes('(node:'))
57
+ .join('\n'),
58
+ )
59
+ }
35
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.4.1",
3
+ "version": "5.4.3",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -73,15 +73,15 @@
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.41",
77
- "rollup": "^4.13.0"
76
+ "postcss": "^8.4.43",
77
+ "rollup": "^4.20.0"
78
78
  },
79
79
  "optionalDependencies": {
80
80
  "fsevents": "~2.3.3"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@ampproject/remapping": "^2.3.0",
84
- "@babel/parser": "^7.25.3",
84
+ "@babel/parser": "^7.25.6",
85
85
  "@jridgewell/trace-mapping": "^0.3.25",
86
86
  "@polka/compression": "^1.0.0-next.25",
87
87
  "@rollup/plugin-alias": "^5.1.0",
@@ -112,7 +112,7 @@
112
112
  "launch-editor-middleware": "^2.8.1",
113
113
  "lightningcss": "^1.26.0",
114
114
  "magic-string": "^0.30.11",
115
- "micromatch": "^4.0.7",
115
+ "micromatch": "^4.0.8",
116
116
  "mlly": "^1.7.1",
117
117
  "mrmime": "^2.0.0",
118
118
  "open": "^8.4.2",
@@ -134,8 +134,8 @@
134
134
  "source-map-support": "^0.5.21",
135
135
  "strip-ansi": "^7.1.0",
136
136
  "strip-literal": "^2.1.0",
137
- "tsconfck": "^3.1.1",
138
- "tslib": "^2.6.3",
137
+ "tsconfck": "^3.1.3",
138
+ "tslib": "^2.7.0",
139
139
  "types": "link:./types",
140
140
  "ufo": "^1.5.4",
141
141
  "ws": "^8.18.0"