vite 6.2.4 → 6.2.6

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.
@@ -1,4 +1,4 @@
1
- import { P as getDefaultExportFromCjs } from './dep-DrOo5SEf.js';
1
+ import { P as getDefaultExportFromCjs } from './dep-Bid9ssRr.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4
 
@@ -13591,8 +13591,9 @@ async function fileToDevUrl(environment, id, skipBase = false) {
13591
13591
  const content = await fsp.readFile(file);
13592
13592
  return assetToDataURL(environment, file, content);
13593
13593
  }
13594
- if (svgExtRE.test(id)) {
13595
- const file = publicFile || cleanUrl(id);
13594
+ const cleanedId = cleanUrl(id);
13595
+ if (svgExtRE.test(cleanedId)) {
13596
+ const file = publicFile || cleanedId;
13596
13597
  const content = await fsp.readFile(file);
13597
13598
  if (shouldInline(environment, file, id, content, void 0, void 0)) {
13598
13599
  return assetToDataURL(environment, file, content);
@@ -41149,6 +41150,7 @@ function renderRestrictedErrorHTML(msg) {
41149
41150
 
41150
41151
  const ERR_LOAD_URL = "ERR_LOAD_URL";
41151
41152
  const ERR_LOAD_PUBLIC_URL = "ERR_LOAD_PUBLIC_URL";
41153
+ const ERR_DENIED_ID = "ERR_DENIED_ID";
41152
41154
  const debugLoad = createDebugger("vite:load");
41153
41155
  const debugTransform = createDebugger("vite:transform");
41154
41156
  const debugCache$1 = createDebugger("vite:cache");
@@ -41248,6 +41250,11 @@ async function loadAndTransform(environment, id, url, options, timestamp, mod, r
41248
41250
  const { config, pluginContainer, logger } = environment;
41249
41251
  const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url, config.root) : "";
41250
41252
  const moduleGraph = environment.moduleGraph;
41253
+ if (options.allowId && !options.allowId(id)) {
41254
+ const err = new Error(`Denied ID ${id}`);
41255
+ err.code = ERR_DENIED_ID;
41256
+ throw err;
41257
+ }
41251
41258
  let code = null;
41252
41259
  let map = null;
41253
41260
  const loadStart = debugLoad ? performance$1.now() : 0;
@@ -42682,6 +42689,10 @@ const trailingQuerySeparatorsRE = /[?&]+$/;
42682
42689
  const urlRE = /[?&]url\b/;
42683
42690
  const rawRE = /[?&]raw\b/;
42684
42691
  const inlineRE$2 = /[?&]inline\b/;
42692
+ const svgRE = /\.svg\b/;
42693
+ function deniedServingAccessForTransform(url, server, res, next) {
42694
+ return (rawRE.test(url) || urlRE.test(url) || inlineRE$2.test(url) || svgRE.test(url)) && !ensureServingAccess(url, server, res, next);
42695
+ }
42685
42696
  function cachedTransformMiddleware(server) {
42686
42697
  return function viteCachedTransformMiddleware(req, res, next) {
42687
42698
  const environment = server.environments.client;
@@ -42771,7 +42782,7 @@ function transformMiddleware(server) {
42771
42782
  trailingQuerySeparatorsRE,
42772
42783
  ""
42773
42784
  );
42774
- if ((rawRE.test(urlWithoutTrailingQuerySeparators) || urlRE.test(urlWithoutTrailingQuerySeparators) || inlineRE$2.test(urlWithoutTrailingQuerySeparators)) && !ensureServingAccess(
42785
+ if (deniedServingAccessForTransform(
42775
42786
  urlWithoutTrailingQuerySeparators,
42776
42787
  server,
42777
42788
  res,
@@ -42794,7 +42805,10 @@ function transformMiddleware(server) {
42794
42805
  }
42795
42806
  }
42796
42807
  const result = await transformRequest(environment, url, {
42797
- html: req.headers.accept?.includes("text/html")
42808
+ html: req.headers.accept?.includes("text/html"),
42809
+ allowId(id) {
42810
+ return !deniedServingAccessForTransform(id, server, res, next);
42811
+ }
42798
42812
  });
42799
42813
  if (result) {
42800
42814
  const depsOptimizer = environment.depsOptimizer;
@@ -42846,6 +42860,9 @@ function transformMiddleware(server) {
42846
42860
  if (e?.code === ERR_LOAD_URL) {
42847
42861
  return next();
42848
42862
  }
42863
+ if (e?.code === ERR_DENIED_ID) {
42864
+ return;
42865
+ }
42849
42866
  return next(e);
42850
42867
  }
42851
42868
  next();
@@ -43851,6 +43868,17 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
43851
43868
  return searchForWorkspaceRoot(dir, root);
43852
43869
  }
43853
43870
 
43871
+ function rejectInvalidRequestMiddleware() {
43872
+ return function viteRejectInvalidRequestMiddleware(req, res, next) {
43873
+ if (req.url?.includes("#")) {
43874
+ res.writeHead(400);
43875
+ res.end();
43876
+ return;
43877
+ }
43878
+ return next();
43879
+ };
43880
+ }
43881
+
43854
43882
  function createServer(inlineConfig = {}) {
43855
43883
  return _createServer(inlineConfig, { listen: true });
43856
43884
  }
@@ -44196,6 +44224,7 @@ async function _createServer(inlineConfig = {}, options) {
44196
44224
  if (process.env.DEBUG) {
44197
44225
  middlewares.use(timeMiddleware(root));
44198
44226
  }
44227
+ middlewares.use(rejectInvalidRequestMiddleware());
44199
44228
  const { cors } = serverConfig;
44200
44229
  if (cors !== false) {
44201
44230
  middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
@@ -46566,6 +46595,7 @@ function escapeReplacement(value) {
46566
46595
  }
46567
46596
 
46568
46597
  const wasmHelperId = "\0vite/wasm-helper.js";
46598
+ const wasmInitRE = /(?<![?#].*)\.wasm\?init/;
46569
46599
  const wasmHelper = async (opts = {}, url) => {
46570
46600
  let result;
46571
46601
  if (url.startsWith("data:")) {
@@ -46610,7 +46640,7 @@ const wasmHelperPlugin = () => {
46610
46640
  if (id === wasmHelperId) {
46611
46641
  return `export default ${wasmHelperCode}`;
46612
46642
  }
46613
- if (!id.endsWith(".wasm?init")) {
46643
+ if (!wasmInitRE.test(id)) {
46614
46644
  return;
46615
46645
  }
46616
46646
  const url = await fileToUrl$1(this, id);
@@ -49243,8 +49273,8 @@ function createCachedImport(imp) {
49243
49273
  return cached;
49244
49274
  };
49245
49275
  }
49246
- const importPostcssImport = createCachedImport(() => import('./dep-DZlHsecg.js').then(function (n) { return n.i; }));
49247
- const importPostcssModules = createCachedImport(() => import('./dep-DfJZxycY.js').then(function (n) { return n.i; }));
49276
+ const importPostcssImport = createCachedImport(() => import('./dep-BXMtZB7a.js').then(function (n) { return n.i; }));
49277
+ const importPostcssModules = createCachedImport(() => import('./dep-CEj2138F.js').then(function (n) { return n.i; }));
49248
49278
  const importPostcss = createCachedImport(() => import('postcss'));
49249
49279
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
49250
49280
  let alwaysFakeWorkerWorkerControllerCache;
@@ -1,4 +1,4 @@
1
- import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-DrOo5SEf.js';
1
+ import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-Bid9ssRr.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 { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-DrOo5SEf.js';
5
+ import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-Bid9ssRr.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -745,7 +745,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
745
745
  `[boolean] force the optimizer to ignore the cache and re-bundle`
746
746
  ).action(async (root, options) => {
747
747
  filterDuplicateOptions(options);
748
- const { createServer } = await import('./chunks/dep-DrOo5SEf.js').then(function (n) { return n.S; });
748
+ const { createServer } = await import('./chunks/dep-Bid9ssRr.js').then(function (n) { return n.S; });
749
749
  try {
750
750
  const server = await createServer({
751
751
  root,
@@ -840,7 +840,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
840
840
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
841
841
  async (root, options) => {
842
842
  filterDuplicateOptions(options);
843
- const { createBuilder } = await import('./chunks/dep-DrOo5SEf.js').then(function (n) { return n.T; });
843
+ const { createBuilder } = await import('./chunks/dep-Bid9ssRr.js').then(function (n) { return n.T; });
844
844
  const buildOptions = cleanGlobalCLIOptions(
845
845
  cleanBuilderCLIOptions(options)
846
846
  );
@@ -879,7 +879,7 @@ cli.command(
879
879
  ).action(
880
880
  async (root, options) => {
881
881
  filterDuplicateOptions(options);
882
- const { optimizeDeps } = await import('./chunks/dep-DrOo5SEf.js').then(function (n) { return n.R; });
882
+ const { optimizeDeps } = await import('./chunks/dep-Bid9ssRr.js').then(function (n) { return n.R; });
883
883
  try {
884
884
  const config = await resolveConfig(
885
885
  {
@@ -906,7 +906,7 @@ ${e.stack}`),
906
906
  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(
907
907
  async (root, options) => {
908
908
  filterDuplicateOptions(options);
909
- const { preview } = await import('./chunks/dep-DrOo5SEf.js').then(function (n) { return n.U; });
909
+ const { preview } = await import('./chunks/dep-Bid9ssRr.js').then(function (n) { return n.U; });
910
910
  try {
911
911
  const server = await preview({
912
912
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { a as arraify, i as isInNodeModules } from './chunks/dep-DrOo5SEf.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-DrOo5SEf.js';
2
+ import { a as arraify, i as isInNodeModules } from './chunks/dep-Bid9ssRr.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, F as createFilter, h as createIdResolver, I as createLogger, n as createRunnableDevEnvironment, c as createServer, y as createServerHotChannel, w as createServerModuleRunner, x as createServerModuleRunnerTransport, d as defineConfig, v as fetchModule, j as formatPostcssSourceMap, L as isFileLoadingAllowed, K as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, M as loadEnv, E as mergeAlias, C as mergeConfig, z as moduleRunnerTransform, A as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, N as resolveEnvPrefix, G as rollupVersion, u as runnerImport, J as searchForWorkspaceRoot, H as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-Bid9ssRr.js';
4
4
  export { defaultAllowedOrigins, 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.2.4",
3
+ "version": "6.2.6",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",