vite 6.0.12 → 6.0.14

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.
@@ -9749,10 +9749,10 @@ function removeImportQuery(url) {
9749
9749
  function removeDirectQuery(url) {
9750
9750
  return url.replace(directRequestRE$1, "$1").replace(trailingSeparatorRE, "");
9751
9751
  }
9752
- const urlRE = /(\?|&)url(?:&|$)/;
9753
- const rawRE = /(\?|&)raw(?:&|$)/;
9752
+ const urlRE$1 = /(\?|&)url(?:&|$)/;
9753
+ const rawRE$1 = /(\?|&)raw(?:&|$)/;
9754
9754
  function removeUrlQuery(url) {
9755
- return url.replace(urlRE, "$1").replace(trailingSeparatorRE, "");
9755
+ return url.replace(urlRE$1, "$1").replace(trailingSeparatorRE, "");
9756
9756
  }
9757
9757
  function injectQuery(url, queryToInject) {
9758
9758
  const { file, postfix } = splitFileAndPostfix(url);
@@ -13379,7 +13379,7 @@ function checkPublicFile(url, config) {
13379
13379
  const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g;
13380
13380
  const jsSourceMapRE = /\.[cm]?js\.map$/;
13381
13381
  const noInlineRE = /[?&]no-inline\b/;
13382
- const inlineRE$2 = /[?&]inline\b/;
13382
+ const inlineRE$3 = /[?&]inline\b/;
13383
13383
  const svgExtRE = /\.svg(?:$|\?)/;
13384
13384
  const assetCache = /* @__PURE__ */ new WeakMap();
13385
13385
  const cssEntriesMap = /* @__PURE__ */ new WeakMap();
@@ -13446,7 +13446,7 @@ function assetPlugin(config) {
13446
13446
  cssEntriesMap.set(this.environment, /* @__PURE__ */ new Set());
13447
13447
  },
13448
13448
  resolveId(id) {
13449
- if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
13449
+ if (!config.assetsInclude(cleanUrl(id)) && !urlRE$1.test(id)) {
13450
13450
  return;
13451
13451
  }
13452
13452
  const publicFile = checkPublicFile(id, config);
@@ -13458,14 +13458,14 @@ function assetPlugin(config) {
13458
13458
  if (id[0] === "\0") {
13459
13459
  return;
13460
13460
  }
13461
- if (rawRE.test(id)) {
13461
+ if (rawRE$1.test(id)) {
13462
13462
  const file = checkPublicFile(id, config) || cleanUrl(id);
13463
13463
  this.addWatchFile(file);
13464
13464
  return `export default ${JSON.stringify(
13465
13465
  await fsp.readFile(file, "utf-8")
13466
13466
  )}`;
13467
13467
  }
13468
- if (!urlRE.test(id) && !config.assetsInclude(cleanUrl(id))) {
13468
+ if (!urlRE$1.test(id) && !config.assetsInclude(cleanUrl(id))) {
13469
13469
  return;
13470
13470
  }
13471
13471
  id = removeUrlQuery(id);
@@ -13523,13 +13523,14 @@ async function fileToUrl$1(pluginContext, id) {
13523
13523
  async function fileToDevUrl(environment, id, skipBase = false) {
13524
13524
  const config = environment.getTopLevelConfig();
13525
13525
  const publicFile = checkPublicFile(id, config);
13526
- if (inlineRE$2.test(id)) {
13526
+ if (inlineRE$3.test(id)) {
13527
13527
  const file = publicFile || cleanUrl(id);
13528
13528
  const content = await fsp.readFile(file);
13529
13529
  return assetToDataURL(environment, file, content);
13530
13530
  }
13531
- if (svgExtRE.test(id)) {
13532
- const file = publicFile || cleanUrl(id);
13531
+ const cleanedId = cleanUrl(id);
13532
+ if (svgExtRE.test(cleanedId)) {
13533
+ const file = publicFile || cleanedId;
13533
13534
  const content = await fsp.readFile(file);
13534
13535
  if (shouldInline(environment, file, id, content, undefined, undefined)) {
13535
13536
  return assetToDataURL(environment, file, content);
@@ -13580,7 +13581,7 @@ async function fileToBuiltUrl(pluginContext, id, skipPublicCheck = false, forceI
13580
13581
  if (!skipPublicCheck) {
13581
13582
  const publicFile = checkPublicFile(id, topLevelConfig);
13582
13583
  if (publicFile) {
13583
- if (inlineRE$2.test(id)) {
13584
+ if (inlineRE$3.test(id)) {
13584
13585
  id = publicFile;
13585
13586
  } else {
13586
13587
  return publicFileToBuiltUrl(id, topLevelConfig);
@@ -13629,7 +13630,7 @@ async function urlToBuiltUrl(pluginContext, url, importer, forceInline) {
13629
13630
  }
13630
13631
  function shouldInline(environment, file, id, content, buildPluginContext, forceInline) {
13631
13632
  if (noInlineRE.test(id)) return false;
13632
- if (inlineRE$2.test(id)) return true;
13633
+ if (inlineRE$3.test(id)) return true;
13633
13634
  if (buildPluginContext) {
13634
13635
  if (environment.config.build.lib) return true;
13635
13636
  if (buildPluginContext.getModuleInfo(id)?.isEntry) return false;
@@ -40894,7 +40895,7 @@ function servePublicMiddleware(server, publicFiles) {
40894
40895
  };
40895
40896
  return function viteServePublicMiddleware(req, res, next) {
40896
40897
  if (publicFiles && !publicFiles.has(toFilePath(req.url)) || isImportRequest(req.url) || isInternalRequest(req.url) || // for `/public-file.js?url` to be transformed
40897
- urlRE.test(req.url)) {
40898
+ urlRE$1.test(req.url)) {
40898
40899
  return next();
40899
40900
  }
40900
40901
  serve(req, res, next);
@@ -41027,6 +41028,7 @@ function renderRestrictedErrorHTML(msg) {
41027
41028
 
41028
41029
  const ERR_LOAD_URL = "ERR_LOAD_URL";
41029
41030
  const ERR_LOAD_PUBLIC_URL = "ERR_LOAD_PUBLIC_URL";
41031
+ const ERR_DENIED_ID = "ERR_DENIED_ID";
41030
41032
  const debugLoad = createDebugger("vite:load");
41031
41033
  const debugTransform = createDebugger("vite:transform");
41032
41034
  const debugCache$1 = createDebugger("vite:cache");
@@ -41126,6 +41128,11 @@ async function loadAndTransform(environment, id, url, options, timestamp, mod, r
41126
41128
  const { config, pluginContainer, logger } = environment;
41127
41129
  const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url, config.root) : "";
41128
41130
  const moduleGraph = environment.moduleGraph;
41131
+ if (options.allowId && !options.allowId(id)) {
41132
+ const err = new Error(`Denied ID ${id}`);
41133
+ err.code = ERR_DENIED_ID;
41134
+ throw err;
41135
+ }
41129
41136
  let code = null;
41130
41137
  let map = null;
41131
41138
  const loadStart = debugLoad ? performance.now() : 0;
@@ -42538,6 +42545,13 @@ function incrementIndent(indent = "") {
42538
42545
  const debugCache = createDebugger("vite:cache");
42539
42546
  const knownIgnoreList = /* @__PURE__ */ new Set(["/", "/favicon.ico"]);
42540
42547
  const trailingQuerySeparatorsRE = /[?&]+$/;
42548
+ const urlRE = /[?&]url\b/;
42549
+ const rawRE = /[?&]raw\b/;
42550
+ const inlineRE$2 = /[?&]inline\b/;
42551
+ const svgRE = /\.svg\b/;
42552
+ function deniedServingAccessForTransform(url, server, res, next) {
42553
+ return (rawRE.test(url) || urlRE.test(url) || inlineRE$2.test(url) || svgRE.test(url)) && !ensureServingAccess(url, server, res, next);
42554
+ }
42541
42555
  function cachedTransformMiddleware(server) {
42542
42556
  return function viteCachedTransformMiddleware(req, res, next) {
42543
42557
  const environment = server.environments.client;
@@ -42627,7 +42641,7 @@ function transformMiddleware(server) {
42627
42641
  trailingQuerySeparatorsRE,
42628
42642
  ""
42629
42643
  );
42630
- if ((rawRE.test(urlWithoutTrailingQuerySeparators) || urlRE.test(urlWithoutTrailingQuerySeparators)) && !ensureServingAccess(
42644
+ if (deniedServingAccessForTransform(
42631
42645
  urlWithoutTrailingQuerySeparators,
42632
42646
  server,
42633
42647
  res,
@@ -42650,7 +42664,10 @@ function transformMiddleware(server) {
42650
42664
  }
42651
42665
  }
42652
42666
  const result = await transformRequest(environment, url, {
42653
- html: req.headers.accept?.includes("text/html")
42667
+ html: req.headers.accept?.includes("text/html"),
42668
+ allowId(id) {
42669
+ return !deniedServingAccessForTransform(id, server, res, next);
42670
+ }
42654
42671
  });
42655
42672
  if (result) {
42656
42673
  const depsOptimizer = environment.depsOptimizer;
@@ -42702,6 +42719,9 @@ function transformMiddleware(server) {
42702
42719
  if (e?.code === ERR_LOAD_URL) {
42703
42720
  return next();
42704
42721
  }
42722
+ if (e?.code === ERR_DENIED_ID) {
42723
+ return;
42724
+ }
42705
42725
  return next(e);
42706
42726
  }
42707
42727
  next();
@@ -45494,7 +45514,7 @@ function webWorkerPlugin(config) {
45494
45514
  url = injectQuery(url, `${WORKER_FILE_ID}&type=${workerType}`);
45495
45515
  urlCode = JSON.stringify(url);
45496
45516
  }
45497
- if (urlRE.test(id)) {
45517
+ if (urlRE$1.test(id)) {
45498
45518
  return {
45499
45519
  code: `export default ${urlCode}`,
45500
45520
  map: { mappings: "" }
@@ -45936,7 +45956,7 @@ function importAnalysisPlugin(config) {
45936
45956
  if (specifier === clientPublicPath) {
45937
45957
  return;
45938
45958
  }
45939
- if (specifier[0] === "/" && !(config.assetsInclude(cleanUrl(specifier)) || urlRE.test(specifier)) && checkPublicFile(specifier, config)) {
45959
+ if (specifier[0] === "/" && !(config.assetsInclude(cleanUrl(specifier)) || urlRE$1.test(specifier)) && checkPublicFile(specifier, config)) {
45940
45960
  throw new Error(
45941
45961
  `Cannot import non-asset file ${specifier} which is inside /public. JS/CSS files inside /public are copied as-is on build and can only be referenced via <script src> or <link href> in html. If you want to get the URL of that file, use ${injectQuery(
45942
45962
  specifier,
@@ -46367,6 +46387,7 @@ function escapeReplacement(value) {
46367
46387
  }
46368
46388
 
46369
46389
  const wasmHelperId = "\0vite/wasm-helper.js";
46390
+ const wasmInitRE = /(?<![?#].*)\.wasm\?init/;
46370
46391
  const wasmHelper = async (opts = {}, url) => {
46371
46392
  let result;
46372
46393
  if (url.startsWith("data:")) {
@@ -46411,7 +46432,7 @@ const wasmHelperPlugin = () => {
46411
46432
  if (id === wasmHelperId) {
46412
46433
  return `export default ${wasmHelperCode}`;
46413
46434
  }
46414
- if (!id.endsWith(".wasm?init")) {
46435
+ if (!wasmInitRE.test(id)) {
46415
46436
  return;
46416
46437
  }
46417
46438
  const url = await fileToUrl$1(this, id);
@@ -46879,7 +46900,7 @@ function parseDynamicImportPattern(strings) {
46879
46900
  let globParams = null;
46880
46901
  if (search) {
46881
46902
  search = "?" + search;
46882
- if (workerOrSharedWorkerRE.test(search) || urlRE.test(search) || rawRE.test(search)) {
46903
+ if (workerOrSharedWorkerRE.test(search) || urlRE$1.test(search) || rawRE$1.test(search)) {
46883
46904
  globParams = {
46884
46905
  query: search,
46885
46906
  import: "*"
@@ -47987,7 +48008,7 @@ function cssPlugin(config) {
47987
48008
  },
47988
48009
  async load(id) {
47989
48010
  if (!isCSSRequest(id)) return;
47990
- if (urlRE.test(id)) {
48011
+ if (urlRE$1.test(id)) {
47991
48012
  if (isModuleCSSRequest(id)) {
47992
48013
  throw new Error(
47993
48014
  `?url is not supported with CSS modules. (tried to import ${JSON.stringify(
@@ -48889,8 +48910,8 @@ function createCachedImport(imp) {
48889
48910
  return cached;
48890
48911
  };
48891
48912
  }
48892
- const importPostcssImport = createCachedImport(() => import('./dep-C1bPwvxG.js').then(function (n) { return n.i; }));
48893
- const importPostcssModules = createCachedImport(() => import('./dep-B_t-fquM.js').then(function (n) { return n.i; }));
48913
+ const importPostcssImport = createCachedImport(() => import('./dep-CXwiT2Hf.js').then(function (n) { return n.i; }));
48914
+ const importPostcssModules = createCachedImport(() => import('./dep-DSU-v1Zt.js').then(function (n) { return n.i; }));
48894
48915
  const importPostcss = createCachedImport(() => import('postcss'));
48895
48916
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
48896
48917
  let alwaysFakeWorkerWorkerControllerCache;
@@ -1,4 +1,4 @@
1
- import { N as getDefaultExportFromCjs } from './dep-BzsM_vHB.js';
1
+ import { N as getDefaultExportFromCjs } from './dep-CJqJlo1l.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-BzsM_vHB.js';
1
+ import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-CJqJlo1l.js';
2
2
  import require$$0$2 from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
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 { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-BzsM_vHB.js';
5
+ import { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-CJqJlo1l.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -741,7 +741,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
741
741
  `[boolean] force the optimizer to ignore the cache and re-bundle`
742
742
  ).action(async (root, options) => {
743
743
  filterDuplicateOptions(options);
744
- const { createServer } = await import('./chunks/dep-BzsM_vHB.js').then(function (n) { return n.Q; });
744
+ const { createServer } = await import('./chunks/dep-CJqJlo1l.js').then(function (n) { return n.Q; });
745
745
  try {
746
746
  const server = await createServer({
747
747
  root,
@@ -834,7 +834,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
834
834
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
835
835
  async (root, options) => {
836
836
  filterDuplicateOptions(options);
837
- const { createBuilder } = await import('./chunks/dep-BzsM_vHB.js').then(function (n) { return n.R; });
837
+ const { createBuilder } = await import('./chunks/dep-CJqJlo1l.js').then(function (n) { return n.R; });
838
838
  const buildOptions = cleanGlobalCLIOptions(
839
839
  cleanBuilderCLIOptions(options)
840
840
  );
@@ -869,7 +869,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
869
869
  ).action(
870
870
  async (root, options) => {
871
871
  filterDuplicateOptions(options);
872
- const { optimizeDeps } = await import('./chunks/dep-BzsM_vHB.js').then(function (n) { return n.P; });
872
+ const { optimizeDeps } = await import('./chunks/dep-CJqJlo1l.js').then(function (n) { return n.P; });
873
873
  try {
874
874
  const config = await resolveConfig(
875
875
  {
@@ -895,7 +895,7 @@ ${e.stack}`),
895
895
  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(
896
896
  async (root, options) => {
897
897
  filterDuplicateOptions(options);
898
- const { preview } = await import('./chunks/dep-BzsM_vHB.js').then(function (n) { return n.S; });
898
+ const { preview } = await import('./chunks/dep-CJqJlo1l.js').then(function (n) { return n.S; });
899
899
  try {
900
900
  const server = await preview({
901
901
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-BzsM_vHB.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BzsM_vHB.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-CJqJlo1l.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-CJqJlo1l.js';
4
4
  export { DEFAULT_CLIENT_CONDITIONS as defaultClientConditions, DEFAULT_CLIENT_MAIN_FIELDS as defaultClientMainFields, DEFAULT_SERVER_CONDITIONS as defaultServerConditions, DEFAULT_SERVER_MAIN_FIELDS as defaultServerMainFields, VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  import 'node:fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.12",
3
+ "version": "6.0.14",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",