vite 6.3.5 → 6.4.1

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-DBxKXgDP.js';
1
+ import { P as getDefaultExportFromCjs } from './dep-D4NMHUTW.js';
2
2
  import require$$0 from 'path';
3
3
  import { l as lib } from './dep-3RmXg9uo.js';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import * as fs$8 from 'node:fs';
2
2
  import fs__default, { promises as promises$1, existsSync as existsSync$1, readFileSync as readFileSync$1 } from 'node:fs';
3
- import path$b, { posix as posix$1, isAbsolute as isAbsolute$1, join as join$1, resolve as resolve$4, normalize, dirname as dirname$2, relative as relative$2, basename as basename$2, extname as extname$1 } from 'node:path';
3
+ import path$b, { posix as posix$1, isAbsolute as isAbsolute$1, join as join$1, resolve as resolve$4, sep as sep$1, normalize, dirname as dirname$2, relative as relative$2, basename as basename$2, extname as extname$1 } from 'node:path';
4
4
  import fsp, { constants as constants$3 } from 'node:fs/promises';
5
5
  import require$$1$1, { fileURLToPath as fileURLToPath$1, URL as URL$3, pathToFileURL as pathToFileURL$1 } from 'node:url';
6
6
  import { promisify as promisify$4, format as format$2, inspect, stripVTControlCharacters } from 'node:util';
@@ -9048,7 +9048,7 @@ class TSConfckCache {
9048
9048
  }
9049
9049
 
9050
9050
  const debug$i = createDebugger("vite:esbuild");
9051
- const IIFE_BEGIN_RE = /(?:const|var)\s+\S+\s*=\s*function\([^()]*\)\s*\{\s*"use strict";/;
9051
+ const IIFE_BEGIN_RE = /(?:const|var)\s+\S+\s*=\s*\(?function\([^()]*\)\s*\{\s*"use strict";/;
9052
9052
  const validExtensionRE = /\.\w+$/;
9053
9053
  const jsxExtensionsRE = /\.(?:j|t)sx\b/;
9054
9054
  const defaultEsbuildSupported = {
@@ -35192,7 +35192,10 @@ function viaLocal(dir, isEtag, uri, extns, shouldServe) {
35192
35192
  let i=0, arr=toAssume(uri, extns);
35193
35193
  let abs, stats, name, headers;
35194
35194
  for (; i < arr.length; i++) {
35195
- abs = normalize(join$1(dir, name=arr[i]));
35195
+ abs = normalize(
35196
+ join$1(dir, name=arr[i])
35197
+ );
35198
+
35196
35199
  if (abs.startsWith(dir) && fs$8.existsSync(abs)) {
35197
35200
  stats = fs$8.statSync(abs);
35198
35201
  if (stats.isDirectory()) continue;
@@ -35315,7 +35318,7 @@ function sirv (dir, opts={}) {
35315
35318
  });
35316
35319
  }
35317
35320
 
35318
- let lookup = opts.dev ? viaLocal.bind(0, dir, isEtag) : viaCache.bind(0, FILES);
35321
+ let lookup = opts.dev ? viaLocal.bind(0, dir.endsWith(sep$1) ? dir : dir + sep$1, isEtag) : viaCache.bind(0, FILES);
35319
35322
 
35320
35323
  return function (req, res, next) {
35321
35324
  let extns = [''];
@@ -35506,7 +35509,8 @@ function isUriInFilePath(uri, filePath) {
35506
35509
  function isFileLoadingAllowed(config, filePath) {
35507
35510
  const { fs } = config.server;
35508
35511
  if (!fs.strict) return true;
35509
- if (config.fsDenyGlob(filePath)) return false;
35512
+ const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
35513
+ if (config.fsDenyGlob(filePathWithoutTrailingSlash)) return false;
35510
35514
  if (config.safeModulePaths.has(filePath)) return true;
35511
35515
  if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
35512
35516
  return false;
@@ -37626,7 +37630,22 @@ function indexHtmlMiddleware(root, server) {
37626
37630
  if (isDev && url.startsWith(FS_PREFIX)) {
37627
37631
  filePath = decodeURIComponent(fsPathFromId(url));
37628
37632
  } else {
37629
- filePath = path$b.join(root, decodeURIComponent(url));
37633
+ filePath = normalizePath$3(
37634
+ path$b.resolve(path$b.join(root, decodeURIComponent(url)))
37635
+ );
37636
+ }
37637
+ if (isDev) {
37638
+ const servingAccessResult = checkLoadingAccess(server.config, filePath);
37639
+ if (servingAccessResult === "denied") {
37640
+ return respondWithAccessDenied(filePath, server, res);
37641
+ }
37642
+ if (servingAccessResult === "fallback") {
37643
+ return next();
37644
+ }
37645
+ } else {
37646
+ if (!isParentDirectory(root, filePath)) {
37647
+ return next();
37648
+ }
37630
37649
  }
37631
37650
  if (fs__default.existsSync(filePath)) {
37632
37651
  const headers = isDev ? server.config.server.headers : server.config.preview.headers;
@@ -38322,11 +38341,21 @@ function rejectInvalidRequestMiddleware() {
38322
38341
  };
38323
38342
  }
38324
38343
 
38344
+ const usedConfigs = /* @__PURE__ */ new WeakSet();
38325
38345
  function createServer(inlineConfig = {}) {
38326
38346
  return _createServer(inlineConfig, { listen: true });
38327
38347
  }
38328
38348
  async function _createServer(inlineConfig = {}, options) {
38329
- const config = await resolveConfig(inlineConfig, "serve");
38349
+ const config = isResolvedConfig(inlineConfig) ? inlineConfig : await resolveConfig(inlineConfig, "serve");
38350
+ if (usedConfigs.has(config)) {
38351
+ throw new Error(`There is already a server associated with the config.`);
38352
+ }
38353
+ if (config.command !== "serve") {
38354
+ throw new Error(
38355
+ `Config was resolved for a "build", expected a "serve" command.`
38356
+ );
38357
+ }
38358
+ usedConfigs.add(config);
38330
38359
  const initPublicFilesPromise = initPublicFiles(config);
38331
38360
  const { root, server: serverConfig } = config;
38332
38361
  const httpsOptions = await resolveHttpsConfig(config.server.https);
@@ -43912,8 +43941,8 @@ function createCachedImport(imp) {
43912
43941
  return cached;
43913
43942
  };
43914
43943
  }
43915
- const importPostcssImport = createCachedImport(() => import('./dep-AiMcmC_f.js').then(function (n) { return n.i; }));
43916
- const importPostcssModules = createCachedImport(() => import('./dep-SgSik2vo.js').then(function (n) { return n.i; }));
43944
+ const importPostcssImport = createCachedImport(() => import('./dep-C9BXG1mU.js').then(function (n) { return n.i; }));
43945
+ const importPostcssModules = createCachedImport(() => import('./dep-DWMUTS1A.js').then(function (n) { return n.i; }));
43917
43946
  const importPostcss = createCachedImport(() => import('postcss'));
43918
43947
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
43919
43948
  let alwaysFakeWorkerWorkerControllerCache;
@@ -48305,7 +48334,8 @@ async function preview(inlineConfig = {}) {
48305
48334
  }
48306
48335
  postHooks.forEach((fn) => fn && fn());
48307
48336
  if (config.appType === "spa" || config.appType === "mpa") {
48308
- app.use(indexHtmlMiddleware(distDir, server));
48337
+ const normalizedDistDir = normalizePath$3(distDir);
48338
+ app.use(indexHtmlMiddleware(normalizedDistDir, server));
48309
48339
  app.use(notFoundMiddleware());
48310
48340
  }
48311
48341
  const hostname = await resolveHostname(options.host);
@@ -48408,6 +48438,7 @@ async function runnerImport(moduleId, inlineConfig) {
48408
48438
 
48409
48439
  const debug = createDebugger("vite:config", { depth: 10 });
48410
48440
  const promisifiedRealpath = promisify$4(fs__default.realpath);
48441
+ const SYMBOL_RESOLVED_CONFIG = Symbol("vite:resolved-config");
48411
48442
  function defineConfig(config) {
48412
48443
  return config;
48413
48444
  }
@@ -48698,6 +48729,9 @@ function resolveDepOptimizationOptions(optimizeDeps, preserveSymlinks, forceOpti
48698
48729
  optimizeDeps ?? {}
48699
48730
  );
48700
48731
  }
48732
+ function isResolvedConfig(inlineConfig) {
48733
+ return SYMBOL_RESOLVED_CONFIG in inlineConfig && inlineConfig[SYMBOL_RESOLVED_CONFIG];
48734
+ }
48701
48735
  async function resolveConfig(inlineConfig, command, defaultMode = "development", defaultNodeEnv = "development", isPreview = false, patchConfig = void 0, patchPlugins = void 0) {
48702
48736
  let config = inlineConfig;
48703
48737
  let configFileDependencies = [];
@@ -49066,7 +49100,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
49066
49100
  }
49067
49101
  ),
49068
49102
  safeModulePaths: /* @__PURE__ */ new Set(),
49069
- additionalAllowedHosts: getAdditionalAllowedHosts(server, preview)
49103
+ additionalAllowedHosts: getAdditionalAllowedHosts(server, preview),
49104
+ [SYMBOL_RESOLVED_CONFIG]: true
49070
49105
  };
49071
49106
  resolved = {
49072
49107
  ...config,
@@ -1,4 +1,4 @@
1
- import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-DBxKXgDP.js';
1
+ import { Q as commonjsGlobal, P as getDefaultExportFromCjs } from './dep-D4NMHUTW.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-DBxKXgDP.js';
5
+ import { O as colors, I as createLogger, r as resolveConfig } from './chunks/dep-D4NMHUTW.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -748,7 +748,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
748
748
  `[boolean] force the optimizer to ignore the cache and re-bundle`
749
749
  ).action(async (root, options) => {
750
750
  filterDuplicateOptions(options);
751
- const { createServer } = await import('./chunks/dep-DBxKXgDP.js').then(function (n) { return n.S; });
751
+ const { createServer } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.S; });
752
752
  try {
753
753
  const server = await createServer({
754
754
  root,
@@ -843,7 +843,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
843
843
  ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
844
844
  async (root, options) => {
845
845
  filterDuplicateOptions(options);
846
- const { createBuilder } = await import('./chunks/dep-DBxKXgDP.js').then(function (n) { return n.T; });
846
+ const { createBuilder } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.T; });
847
847
  const buildOptions = cleanGlobalCLIOptions(
848
848
  cleanBuilderCLIOptions(options)
849
849
  );
@@ -882,7 +882,7 @@ cli.command(
882
882
  ).action(
883
883
  async (root, options) => {
884
884
  filterDuplicateOptions(options);
885
- const { optimizeDeps } = await import('./chunks/dep-DBxKXgDP.js').then(function (n) { return n.R; });
885
+ const { optimizeDeps } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.R; });
886
886
  try {
887
887
  const config = await resolveConfig(
888
888
  {
@@ -909,7 +909,7 @@ ${e.stack}`),
909
909
  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(
910
910
  async (root, options) => {
911
911
  filterDuplicateOptions(options);
912
- const { preview } = await import('./chunks/dep-DBxKXgDP.js').then(function (n) { return n.U; });
912
+ const { preview } = await import('./chunks/dep-D4NMHUTW.js').then(function (n) { return n.U; });
913
913
  try {
914
914
  const server = await preview({
915
915
  root,
@@ -3151,7 +3151,7 @@ interface ResolvedServerUrls {
3151
3151
  local: string[];
3152
3152
  network: string[];
3153
3153
  }
3154
- declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
3154
+ declare function createServer(inlineConfig?: InlineConfig | ResolvedConfig): Promise<ViteDevServer>;
3155
3155
 
3156
3156
  interface HtmlTagDescriptor {
3157
3157
  tag: string;
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-DBxKXgDP.js';
3
- export { B as BuildEnvironment, 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-DBxKXgDP.js';
2
+ import { a as arraify, i as isInNodeModules, D as DevEnvironment } from './chunks/dep-D4NMHUTW.js';
3
+ export { B as BuildEnvironment, 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-D4NMHUTW.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';
@@ -3417,7 +3417,8 @@ function isUriInFilePath(uri, filePath) {
3417
3417
  function isFileLoadingAllowed(config, filePath) {
3418
3418
  const { fs } = config.server;
3419
3419
  if (!fs.strict) return true;
3420
- if (config.fsDenyGlob(filePath)) return false;
3420
+ const filePathWithoutTrailingSlash = filePath.endsWith("/") ? filePath.slice(0, -1) : filePath;
3421
+ if (config.fsDenyGlob(filePathWithoutTrailingSlash)) return false;
3421
3422
  if (config.safeModulePaths.has(filePath)) return true;
3422
3423
  if (fs.allow.some((uri) => isUriInFilePath(uri, filePath))) return true;
3423
3424
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.3.5",
3
+ "version": "6.4.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -131,7 +131,7 @@
131
131
  "rollup-plugin-license": "^3.6.0",
132
132
  "sass": "^1.86.3",
133
133
  "sass-embedded": "^1.86.3",
134
- "sirv": "^3.0.1",
134
+ "sirv": "^3.0.2",
135
135
  "source-map-support": "^0.5.21",
136
136
  "strip-literal": "^3.0.0",
137
137
  "terser": "^5.39.0",