vite 5.2.0 → 5.2.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.
@@ -13179,11 +13179,21 @@ function displayTime(time) {
13179
13179
  return `${mins}m${seconds < 1 ? '' : ` ${seconds.toFixed(0)}s`}`;
13180
13180
  }
13181
13181
  /**
13182
- * Like `encodeURI`, but only replacing `%` as `%25`. This is useful for environments
13182
+ * Encodes the URI path portion (ignores part after ? or #)
13183
+ */
13184
+ function encodeURIPath(uri) {
13185
+ const filePath = cleanUrl(uri);
13186
+ const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
13187
+ return encodeURI(filePath) + postfix;
13188
+ }
13189
+ /**
13190
+ * Like `encodeURIPath`, but only replacing `%` as `%25`. This is useful for environments
13183
13191
  * that can handle un-encoded URIs, where `%` is the only ambiguous character.
13184
13192
  */
13185
- function partialEncodeURI(uri) {
13186
- return uri.replaceAll('%', '%25');
13193
+ function partialEncodeURIPath(uri) {
13194
+ const filePath = cleanUrl(uri);
13195
+ const postfix = filePath !== uri ? uri.slice(filePath.length) : '';
13196
+ return filePath.replaceAll('%', '%25') + postfix;
13187
13197
  }
13188
13198
 
13189
13199
  /* eslint no-console: 0 */
@@ -15828,7 +15838,7 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
15828
15838
  const filename = file + postfix;
15829
15839
  const replacement = toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
15830
15840
  const replacementString = typeof replacement === 'string'
15831
- ? JSON.stringify(encodeURI(replacement)).slice(1, -1)
15841
+ ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
15832
15842
  : `"+${replacement.runtime}+"`;
15833
15843
  s.update(match.index, match.index + full.length, replacementString);
15834
15844
  }
@@ -15841,7 +15851,7 @@ function renderAssetUrlInJS(ctx, config, chunk, opts, code) {
15841
15851
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
15842
15852
  const replacement = toOutputFilePathInJS(publicUrl, 'public', chunk.fileName, 'js', config, toRelativeRuntime);
15843
15853
  const replacementString = typeof replacement === 'string'
15844
- ? JSON.stringify(encodeURI(replacement)).slice(1, -1)
15854
+ ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
15845
15855
  : `"+${replacement.runtime}+"`;
15846
15856
  s.update(match.index, match.index + full.length, replacementString);
15847
15857
  }
@@ -15907,7 +15917,7 @@ function assetPlugin(config) {
15907
15917
  }
15908
15918
  }
15909
15919
  return {
15910
- code: `export default ${JSON.stringify(url.startsWith('data:') ? url : encodeURI(url))}`,
15920
+ code: `export default ${JSON.stringify(url.startsWith('data:') ? url : encodeURIPath(url))}`,
15911
15921
  // Force rollup to keep this module from being shared between other entry points if it's an entrypoint.
15912
15922
  // If the resulting chunk is empty, it will be removed in generateBundle.
15913
15923
  moduleSideEffects: config.command === 'build' && this.getModuleInfo(id)?.isEntry
@@ -30677,7 +30687,7 @@ function buildHtmlPlugin(config) {
30677
30687
  const isPublicFile = !!(url && checkPublicFile(url, config));
30678
30688
  if (isPublicFile) {
30679
30689
  // referencing public dir url, prefix with base
30680
- overwriteAttrValue(s, sourceCodeLocation, partialEncodeURI(toOutputPublicFilePath(url)));
30690
+ overwriteAttrValue(s, sourceCodeLocation, partialEncodeURIPath(toOutputPublicFilePath(url)));
30681
30691
  }
30682
30692
  if (isModule) {
30683
30693
  inlineModuleIndex++;
@@ -30726,7 +30736,7 @@ function buildHtmlPlugin(config) {
30726
30736
  if (!isExcludedUrl(decodedUrl)) {
30727
30737
  const result = await processAssetUrl(url);
30728
30738
  return result !== decodedUrl
30729
- ? encodeURI(result)
30739
+ ? encodeURIPath(result)
30730
30740
  : url;
30731
30741
  }
30732
30742
  return url;
@@ -30739,7 +30749,7 @@ function buildHtmlPlugin(config) {
30739
30749
  else {
30740
30750
  const url = decodeURI(p.value);
30741
30751
  if (checkPublicFile(url, config)) {
30742
- overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), partialEncodeURI(toOutputPublicFilePath(url)));
30752
+ overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), partialEncodeURIPath(toOutputPublicFilePath(url)));
30743
30753
  }
30744
30754
  else if (!isExcludedUrl(url)) {
30745
30755
  if (node.nodeName === 'link' &&
@@ -30766,7 +30776,7 @@ function buildHtmlPlugin(config) {
30766
30776
  assetUrlsPromises.push((async () => {
30767
30777
  const processedUrl = await processAssetUrl(url, shouldInline);
30768
30778
  if (processedUrl !== url) {
30769
- overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), partialEncodeURI(processedUrl));
30779
+ overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), partialEncodeURIPath(processedUrl));
30770
30780
  }
30771
30781
  })());
30772
30782
  }
@@ -30816,10 +30826,10 @@ function buildHtmlPlugin(config) {
30816
30826
  // emit <script>import("./aaa")</script> asset
30817
30827
  for (const { start, end, url } of scriptUrls) {
30818
30828
  if (checkPublicFile(url, config)) {
30819
- s.update(start, end, partialEncodeURI(toOutputPublicFilePath(url)));
30829
+ s.update(start, end, partialEncodeURIPath(toOutputPublicFilePath(url)));
30820
30830
  }
30821
30831
  else if (!isExcludedUrl(url)) {
30822
- s.update(start, end, partialEncodeURI(await urlToBuiltUrl(url, id, config, this)));
30832
+ s.update(start, end, partialEncodeURIPath(await urlToBuiltUrl(url, id, config, this)));
30823
30833
  }
30824
30834
  }
30825
30835
  // ignore <link rel="stylesheet"> if its url can't be resolved
@@ -31010,11 +31020,11 @@ function buildHtmlPlugin(config) {
31010
31020
  if (chunk) {
31011
31021
  chunk.viteMetadata.importedAssets.add(cleanUrl(file));
31012
31022
  }
31013
- return encodeURI(toOutputAssetFilePath(file)) + postfix;
31023
+ return encodeURIPath(toOutputAssetFilePath(file)) + postfix;
31014
31024
  });
31015
31025
  result = result.replace(publicAssetUrlRE, (_, fileHash) => {
31016
31026
  const publicAssetPath = toOutputPublicAssetFilePath(getPublicAssetFilename(fileHash, config));
31017
- return encodeURI(urlCanParse(publicAssetPath)
31027
+ return encodeURIPath(urlCanParse(publicAssetPath)
31018
31028
  ? publicAssetPath
31019
31029
  : normalizePath$3(publicAssetPath));
31020
31030
  });
@@ -31687,14 +31697,14 @@ function cssPostPlugin(config) {
31687
31697
  chunkCSS = chunkCSS.replace(assetUrlRE, (_, fileHash, postfix = '') => {
31688
31698
  const filename = this.getFileName(fileHash) + postfix;
31689
31699
  chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
31690
- return encodeURI(toOutputFilePathInCss(filename, 'asset', cssAssetName, 'css', config, toRelative));
31700
+ return encodeURIPath(toOutputFilePathInCss(filename, 'asset', cssAssetName, 'css', config, toRelative));
31691
31701
  });
31692
31702
  // resolve public URL from CSS paths
31693
31703
  if (encodedPublicUrls) {
31694
31704
  const relativePathToPublicFromCSS = path$o.posix.relative(cssAssetDirname, '');
31695
31705
  chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
31696
31706
  const publicUrl = publicAssetUrlMap.get(hash).slice(1);
31697
- return encodeURI(toOutputFilePathInCss(publicUrl, 'public', cssAssetName, 'css', config, () => `${relativePathToPublicFromCSS}/${publicUrl}`));
31707
+ return encodeURIPath(toOutputFilePathInCss(publicUrl, 'public', cssAssetName, 'css', config, () => `${relativePathToPublicFromCSS}/${publicUrl}`));
31698
31708
  });
31699
31709
  }
31700
31710
  return chunkCSS;
@@ -31745,7 +31755,7 @@ function cssPostPlugin(config) {
31745
31755
  .set(referenceId, { originalName: originalFilename });
31746
31756
  const replacement = toOutputFilePathInJS(this.getFileName(referenceId), 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
31747
31757
  const replacementString = typeof replacement === 'string'
31748
- ? JSON.stringify(encodeURI(replacement)).slice(1, -1)
31758
+ ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
31749
31759
  : `"+${replacement.runtime}+"`;
31750
31760
  s.update(start, end, replacementString);
31751
31761
  }
@@ -32279,8 +32289,8 @@ function createCachedImport(imp) {
32279
32289
  return cached;
32280
32290
  };
32281
32291
  }
32282
- const importPostcssImport = createCachedImport(() => import('./dep-xS77OgV2.js').then(function (n) { return n.i; }));
32283
- const importPostcssModules = createCachedImport(() => import('./dep-t2lrdxcd.js').then(function (n) { return n.i; }));
32292
+ const importPostcssImport = createCachedImport(() => import('./dep-BDnA8AV1.js').then(function (n) { return n.i; }));
32293
+ const importPostcssModules = createCachedImport(() => import('./dep-B1nD54tQ.js').then(function (n) { return n.i; }));
32284
32294
  const importPostcss = createCachedImport(() => import('postcss'));
32285
32295
  const preprocessorWorkerControllerCache = new WeakMap();
32286
32296
  let alwaysFakeWorkerWorkerControllerCache;
@@ -49575,7 +49585,7 @@ function webWorkerPlugin(config) {
49575
49585
  const filename = fileNameHash.get(hash);
49576
49586
  const replacement = toOutputFilePathInJS(filename, 'asset', chunk.fileName, 'js', config, toRelativeRuntime);
49577
49587
  const replacementString = typeof replacement === 'string'
49578
- ? JSON.stringify(encodeURI(replacement)).slice(1, -1)
49588
+ ? JSON.stringify(encodeURIPath(replacement)).slice(1, -1)
49579
49589
  : `"+${replacement.runtime}+"`;
49580
49590
  s.update(match.index, match.index + full.length, replacementString);
49581
49591
  }
@@ -66081,7 +66091,7 @@ function importAnalysisPlugin(config) {
66081
66091
  rewriteDone = true;
66082
66092
  }
66083
66093
  if (!rewriteDone) {
66084
- const rewrittenUrl = JSON.stringify(partialEncodeURI(url));
66094
+ const rewrittenUrl = JSON.stringify(ssr ? url : partialEncodeURIPath(url));
66085
66095
  const s = isDynamicImport ? start : start - 1;
66086
66096
  const e = isDynamicImport ? end : end + 1;
66087
66097
  str().overwrite(s, e, rewrittenUrl, {
@@ -67516,7 +67526,7 @@ function escapeId(id) {
67516
67526
  return id.replace(backSlashRegEx, '\\\\').replace(quoteNewlineRegEx, '\\$1');
67517
67527
  }
67518
67528
  const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
67519
- const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
67529
+ const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
67520
67530
  const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
67521
67531
  const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
67522
67532
  const relativeUrlMechanisms = {
@@ -67526,16 +67536,16 @@ const relativeUrlMechanisms = {
67526
67536
  return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
67527
67537
  },
67528
67538
  cjs: (relativePath) => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
67529
- es: (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', import.meta.url`),
67539
+ es: (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', import.meta.url`),
67530
67540
  iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
67531
67541
  // NOTE: make sure rollup generate `module` params
67532
- system: (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', module.meta.url`),
67542
+ system: (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', module.meta.url`),
67533
67543
  umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`,
67534
67544
  };
67535
67545
  /* end of copy */
67536
67546
  const customRelativeUrlMechanisms = {
67537
67547
  ...relativeUrlMechanisms,
67538
- 'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURI(relativePath))}', self.location.href`),
67548
+ 'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(partialEncodeURIPath(relativePath))}', self.location.href`),
67539
67549
  };
67540
67550
  function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
67541
67551
  const { renderBuiltUrl } = config.experimental;
@@ -1,4 +1,4 @@
1
- import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-B8QpfTwU.js';
1
+ import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-B-u6xNiR.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { B as getDefaultExportFromCjs } from './dep-B8QpfTwU.js';
1
+ import { B as getDefaultExportFromCjs } from './dep-B-u6xNiR.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 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-B8QpfTwU.js';
5
+ import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-B-u6xNiR.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -757,7 +757,7 @@ cli
757
757
  filterDuplicateOptions(options);
758
758
  // output structure is preserved even after bundling so require()
759
759
  // is ok here
760
- const { createServer } = await import('./chunks/dep-B8QpfTwU.js').then(function (n) { return n.E; });
760
+ const { createServer } = await import('./chunks/dep-B-u6xNiR.js').then(function (n) { return n.E; });
761
761
  try {
762
762
  const server = await createServer({
763
763
  root,
@@ -836,7 +836,7 @@ cli
836
836
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
837
837
  .action(async (root, options) => {
838
838
  filterDuplicateOptions(options);
839
- const { build } = await import('./chunks/dep-B8QpfTwU.js').then(function (n) { return n.F; });
839
+ const { build } = await import('./chunks/dep-B-u6xNiR.js').then(function (n) { return n.F; });
840
840
  const buildOptions = cleanOptions(options);
841
841
  try {
842
842
  await build({
@@ -863,7 +863,7 @@ cli
863
863
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
864
864
  .action(async (root, options) => {
865
865
  filterDuplicateOptions(options);
866
- const { optimizeDeps } = await import('./chunks/dep-B8QpfTwU.js').then(function (n) { return n.D; });
866
+ const { optimizeDeps } = await import('./chunks/dep-B-u6xNiR.js').then(function (n) { return n.D; });
867
867
  try {
868
868
  const config = await resolveConfig({
869
869
  root,
@@ -889,7 +889,7 @@ cli
889
889
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
890
890
  .action(async (root, options) => {
891
891
  filterDuplicateOptions(options);
892
- const { preview } = await import('./chunks/dep-B8QpfTwU.js').then(function (n) { return n.G; });
892
+ const { preview } = await import('./chunks/dep-B-u6xNiR.js').then(function (n) { return n.G; });
893
893
  try {
894
894
  const server = await preview({
895
895
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-B8QpfTwU.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-B8QpfTwU.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-B-u6xNiR.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-B-u6xNiR.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.2.0",
3
+ "version": "5.2.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",