vite 5.4.19 → 5.4.21

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 { C as getDefaultExportFromCjs } from './dep-C6uTJdX2.js';
1
+ import { C as getDefaultExportFromCjs } from './dep-BK3b2jBa.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';
@@ -36991,8 +36991,8 @@ function createCachedImport(imp) {
36991
36991
  return cached;
36992
36992
  };
36993
36993
  }
36994
- const importPostcssImport = createCachedImport(() => import('./dep-COdkJwUb.js').then(function (n) { return n.i; }));
36995
- const importPostcssModules = createCachedImport(() => import('./dep-CEGXe0Sr.js').then(function (n) { return n.i; }));
36994
+ const importPostcssImport = createCachedImport(() => import('./dep-BB45zftN.js').then(function (n) { return n.i; }));
36995
+ const importPostcssModules = createCachedImport(() => import('./dep-Dnp7gl8U.js').then(function (n) { return n.i; }));
36996
36996
  const importPostcss = createCachedImport(() => import('postcss'));
36997
36997
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
36998
36998
  let alwaysFakeWorkerWorkerControllerCache;
@@ -51568,7 +51568,7 @@ function sirv (dir, opts={}) {
51568
51568
  });
51569
51569
  }
51570
51570
 
51571
- let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
51571
+ let lookup = opts.dev ? viaLocal.bind(0, dir.endsWith(sep$1) ? dir : dir + sep$1, isEtag) : viaCache.bind(0, FILES);
51572
51572
 
51573
51573
  return function (req, res, next) {
51574
51574
  let extns = [''];
@@ -51752,7 +51752,8 @@ function isUriInFilePath(uri, filePath) {
51752
51752
  function isFileLoadingAllowed(server, filePath) {
51753
51753
  const { fs } = server.config.server;
51754
51754
  if (!fs.strict) return true;
51755
- if (server._fsDenyGlob(filePath)) return false;
51755
+ const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
51756
+ if (server._fsDenyGlob(filePathWithoutTrailingSlash)) return false;
51756
51757
  if (server.moduleGraph.safeModulesPath.has(filePath)) return true;
51757
51758
  if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
51758
51759
  return false;
@@ -62470,7 +62471,22 @@ function indexHtmlMiddleware(root, server) {
62470
62471
  if (isDev && url.startsWith(FS_PREFIX)) {
62471
62472
  filePath = decodeURIComponent(fsPathFromId(url));
62472
62473
  } else {
62473
- filePath = path$n.join(root, decodeURIComponent(url));
62474
+ filePath = normalizePath$3(
62475
+ path$n.resolve(path$n.join(root, decodeURIComponent(url)))
62476
+ );
62477
+ }
62478
+ if (isDev) {
62479
+ const servingAccessResult = checkLoadingAccess(server, filePath);
62480
+ if (servingAccessResult === "denied") {
62481
+ return respondWithAccessDenied(filePath, server, res);
62482
+ }
62483
+ if (servingAccessResult === "fallback") {
62484
+ return next();
62485
+ }
62486
+ } else {
62487
+ if (!isParentDirectory(root, filePath)) {
62488
+ return next();
62489
+ }
62474
62490
  }
62475
62491
  if (fsUtils.existsSync(filePath)) {
62476
62492
  const headers = isDev ? server.config.server.headers : server.config.preview.headers;
@@ -66303,7 +66319,8 @@ async function preview(inlineConfig = {}) {
66303
66319
  }
66304
66320
  postHooks.forEach((fn) => fn && fn());
66305
66321
  if (config.appType === "spa" || config.appType === "mpa") {
66306
- app.use(indexHtmlMiddleware(distDir, server));
66322
+ const normalizedDistDir = normalizePath$3(distDir);
66323
+ app.use(indexHtmlMiddleware(normalizedDistDir, server));
66307
66324
  app.use(notFoundMiddleware());
66308
66325
  }
66309
66326
  const hostname = await resolveHostname(options.host);
@@ -1,4 +1,4 @@
1
- import { D as commonjsGlobal, C as getDefaultExportFromCjs } from './dep-C6uTJdX2.js';
1
+ import { D as commonjsGlobal, C as getDefaultExportFromCjs } from './dep-BK3b2jBa.js';
2
2
  import require$$0__default 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 { B as colors, v as createLogger, r as resolveConfig } from './chunks/dep-C6uTJdX2.js';
5
+ import { B as colors, v as createLogger, r as resolveConfig } from './chunks/dep-BK3b2jBa.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -731,7 +731,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
731
731
  `[boolean] force the optimizer to ignore the cache and re-bundle`
732
732
  ).action(async (root, options) => {
733
733
  filterDuplicateOptions(options);
734
- const { createServer } = await import('./chunks/dep-C6uTJdX2.js').then(function (n) { return n.F; });
734
+ const { createServer } = await import('./chunks/dep-BK3b2jBa.js').then(function (n) { return n.F; });
735
735
  try {
736
736
  const server = await createServer({
737
737
  root,
@@ -823,7 +823,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
823
823
  `[boolean] force empty outDir when it's outside of root`
824
824
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
825
825
  filterDuplicateOptions(options);
826
- const { build } = await import('./chunks/dep-C6uTJdX2.js').then(function (n) { return n.G; });
826
+ const { build } = await import('./chunks/dep-BK3b2jBa.js').then(function (n) { return n.G; });
827
827
  const buildOptions = cleanOptions(options);
828
828
  try {
829
829
  await build({
@@ -852,7 +852,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
852
852
  ).action(
853
853
  async (root, options) => {
854
854
  filterDuplicateOptions(options);
855
- const { optimizeDeps } = await import('./chunks/dep-C6uTJdX2.js').then(function (n) { return n.E; });
855
+ const { optimizeDeps } = await import('./chunks/dep-BK3b2jBa.js').then(function (n) { return n.E; });
856
856
  try {
857
857
  const config = await resolveConfig(
858
858
  {
@@ -878,7 +878,7 @@ ${e.stack}`),
878
878
  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(
879
879
  async (root, options) => {
880
880
  filterDuplicateOptions(options);
881
- const { preview } = await import('./chunks/dep-C6uTJdX2.js').then(function (n) { return n.H; });
881
+ const { preview } = await import('./chunks/dep-BK3b2jBa.js').then(function (n) { return n.H; });
882
882
  try {
883
883
  const server = await preview({
884
884
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-C6uTJdX2.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, y as isFileLoadingAllowed, x as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-C6uTJdX2.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-BK3b2jBa.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, y as isFileLoadingAllowed, x as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-BK3b2jBa.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';
@@ -5552,7 +5552,8 @@ function isUriInFilePath(uri, filePath) {
5552
5552
  function isFileLoadingAllowed(server, filePath) {
5553
5553
  const { fs } = server.config.server;
5554
5554
  if (!fs.strict) return true;
5555
- if (server._fsDenyGlob(filePath)) return false;
5555
+ const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
5556
+ if (server._fsDenyGlob(filePathWithoutTrailingSlash)) return false;
5556
5557
  if (server.moduleGraph.safeModulesPath.has(filePath)) return true;
5557
5558
  if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
5558
5559
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.4.19",
3
+ "version": "5.4.21",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",