vite 5.4.13 → 5.4.15
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.
- package/dist/node/chunks/{dep-CT-NxJFJ.js → dep-Bhfdk6-y.js} +1 -1
- package/dist/node/chunks/{dep-Cjmyj91f.js → dep-CevzF2vT.js} +45 -23
- package/dist/node/chunks/{dep-Dzr4bp1s.js → dep-DzdyzNcV.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +2 -1
- package/dist/node/index.js +2 -2
- package/package.json +1 -1
@@ -10,7 +10,7 @@ import crypto$2, { createHash as createHash$2 } from 'node:crypto';
|
|
10
10
|
import require$$0$3 from 'tty';
|
11
11
|
import require$$0$4, { win32, posix, isAbsolute, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, sep as sep$1, normalize as normalize$1 } from 'path';
|
12
12
|
import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
|
13
|
-
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, SPECIAL_QUERY_RE, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, KNOWN_ASSET_TYPES, JS_TYPES_RE, METADATA_FILENAME, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
13
|
+
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, SPECIAL_QUERY_RE, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, KNOWN_ASSET_TYPES, JS_TYPES_RE, METADATA_FILENAME, VITE_PACKAGE_DIR, defaultAllowedOrigins, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
14
14
|
import * as require$$0$2 from 'fs';
|
15
15
|
import require$$0__default, { lstatSync, readdir as readdir$4, readdirSync, readlinkSync, realpathSync as realpathSync$1, existsSync, readFileSync, statSync as statSync$1 } from 'fs';
|
16
16
|
import { EventEmitter as EventEmitter$4 } from 'node:events';
|
@@ -36991,8 +36991,8 @@ function createCachedImport(imp) {
|
|
36991
36991
|
return cached;
|
36992
36992
|
};
|
36993
36993
|
}
|
36994
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
36995
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
36994
|
+
const importPostcssImport = createCachedImport(() => import('./dep-Bhfdk6-y.js').then(function (n) { return n.i; }));
|
36995
|
+
const importPostcssModules = createCachedImport(() => import('./dep-DzdyzNcV.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;
|
@@ -59177,7 +59177,8 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
59177
59177
|
|
59178
59178
|
var WebSocketServerRaw_ = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
59179
59179
|
|
59180
|
-
const
|
59180
|
+
const allowedHostsServerCache = /* @__PURE__ */ new WeakMap();
|
59181
|
+
const allowedHostsPreviewCache = /* @__PURE__ */ new WeakMap();
|
59181
59182
|
const isFileOrExtensionProtocolRE = /^(?:file|.+-extension):/i;
|
59182
59183
|
function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions) {
|
59183
59184
|
const list = [];
|
@@ -59234,39 +59235,42 @@ function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
|
59234
59235
|
}
|
59235
59236
|
return false;
|
59236
59237
|
}
|
59237
|
-
function isHostAllowed(config, host) {
|
59238
|
-
|
59238
|
+
function isHostAllowed(config, isPreview, host) {
|
59239
|
+
const allowedHosts = isPreview ? config.preview.allowedHosts : config.server.allowedHosts;
|
59240
|
+
if (allowedHosts === true) {
|
59239
59241
|
return true;
|
59240
59242
|
}
|
59241
|
-
|
59242
|
-
|
59243
|
+
const cache = isPreview ? allowedHostsPreviewCache : allowedHostsServerCache;
|
59244
|
+
if (!cache.has(config)) {
|
59245
|
+
cache.set(config, /* @__PURE__ */ new Set());
|
59243
59246
|
}
|
59244
|
-
const
|
59245
|
-
if (
|
59247
|
+
const cachedAllowedHosts = cache.get(config);
|
59248
|
+
if (cachedAllowedHosts.has(host)) {
|
59246
59249
|
return true;
|
59247
59250
|
}
|
59248
59251
|
const result = isHostAllowedWithoutCache(
|
59249
|
-
|
59252
|
+
allowedHosts ?? [],
|
59250
59253
|
config.additionalAllowedHosts,
|
59251
59254
|
host
|
59252
59255
|
);
|
59253
59256
|
if (result) {
|
59254
|
-
|
59257
|
+
cachedAllowedHosts.add(host);
|
59255
59258
|
}
|
59256
59259
|
return result;
|
59257
59260
|
}
|
59258
|
-
function hostCheckMiddleware(config) {
|
59261
|
+
function hostCheckMiddleware(config, isPreview) {
|
59259
59262
|
return function viteHostCheckMiddleware(req, res, next) {
|
59260
59263
|
const hostHeader = req.headers.host;
|
59261
|
-
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59264
|
+
if (!hostHeader || !isHostAllowed(config, isPreview, hostHeader)) {
|
59262
59265
|
const hostname = hostHeader?.replace(/:\d+$/, "");
|
59263
59266
|
const hostnameWithQuotes = JSON.stringify(hostname);
|
59267
|
+
const optionName = `${isPreview ? "preview" : "server"}.allowedHosts`;
|
59264
59268
|
res.writeHead(403, {
|
59265
59269
|
"Content-Type": "text/plain"
|
59266
59270
|
});
|
59267
59271
|
res.end(
|
59268
59272
|
`Blocked request. This host (${hostnameWithQuotes}) is not allowed.
|
59269
|
-
To allow this host, add ${hostnameWithQuotes} to \`
|
59273
|
+
To allow this host, add ${hostnameWithQuotes} to \`${optionName}\` in vite.config.js.`
|
59270
59274
|
);
|
59271
59275
|
return;
|
59272
59276
|
}
|
@@ -59329,7 +59333,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59329
59333
|
const host = hmr && hmr.host || void 0;
|
59330
59334
|
const shouldHandle = (req) => {
|
59331
59335
|
const hostHeader = req.headers.host;
|
59332
|
-
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59336
|
+
if (!hostHeader || !isHostAllowed(config, false, hostHeader)) {
|
59333
59337
|
return false;
|
59334
59338
|
}
|
59335
59339
|
if (config.legacy?.skipWebSocketTokenCheck) {
|
@@ -61924,6 +61928,7 @@ function send(req, res, content, type, options) {
|
|
61924
61928
|
|
61925
61929
|
const debugCache = createDebugger("vite:cache");
|
61926
61930
|
const knownIgnoreList = /* @__PURE__ */ new Set(["/", "/favicon.ico"]);
|
61931
|
+
const trailingQuerySeparatorsRE = /[?&]+$/;
|
61927
61932
|
function cachedTransformMiddleware(server) {
|
61928
61933
|
return function viteCachedTransformMiddleware(req, res, next) {
|
61929
61934
|
const ifNoneMatch = req.headers["if-none-match"];
|
@@ -62007,7 +62012,16 @@ function transformMiddleware(server) {
|
|
62007
62012
|
if (publicDirInRoot && url.startsWith(publicPath)) {
|
62008
62013
|
warnAboutExplicitPublicPathInUrl(url);
|
62009
62014
|
}
|
62010
|
-
|
62015
|
+
const urlWithoutTrailingQuerySeparators = url.replace(
|
62016
|
+
trailingQuerySeparatorsRE,
|
62017
|
+
""
|
62018
|
+
);
|
62019
|
+
if ((rawRE.test(urlWithoutTrailingQuerySeparators) || urlRE.test(urlWithoutTrailingQuerySeparators)) && !ensureServingAccess(
|
62020
|
+
urlWithoutTrailingQuerySeparators,
|
62021
|
+
server,
|
62022
|
+
res,
|
62023
|
+
next
|
62024
|
+
)) {
|
62011
62025
|
return;
|
62012
62026
|
}
|
62013
62027
|
if (isJSRequest(url) || isImportRequest(url) || isCSSRequest(url) || isHTMLProxy(url)) {
|
@@ -63229,12 +63243,16 @@ async function _createServer(inlineConfig = {}, options) {
|
|
63229
63243
|
middlewares.use(timeMiddleware(root));
|
63230
63244
|
}
|
63231
63245
|
const { cors } = serverConfig;
|
63232
|
-
if (cors !==
|
63233
|
-
middlewares.use(
|
63246
|
+
if (cors !== false) {
|
63247
|
+
middlewares.use(
|
63248
|
+
corsMiddleware(
|
63249
|
+
typeof cors === "boolean" ? {} : cors ?? { origin: defaultAllowedOrigins }
|
63250
|
+
)
|
63251
|
+
);
|
63234
63252
|
}
|
63235
63253
|
const { allowedHosts } = serverConfig;
|
63236
63254
|
if (allowedHosts !== true && !serverConfig.https) {
|
63237
|
-
middlewares.use(hostCheckMiddleware(config));
|
63255
|
+
middlewares.use(hostCheckMiddleware(config, false));
|
63238
63256
|
}
|
63239
63257
|
middlewares.use(cachedTransformMiddleware(server));
|
63240
63258
|
const { proxy } = serverConfig;
|
@@ -66161,12 +66179,16 @@ async function preview(inlineConfig = {}) {
|
|
66161
66179
|
postHooks.push(await hook(server));
|
66162
66180
|
}
|
66163
66181
|
const { cors } = config.preview;
|
66164
|
-
if (cors !==
|
66165
|
-
app.use(
|
66182
|
+
if (cors !== false) {
|
66183
|
+
app.use(
|
66184
|
+
corsMiddleware(
|
66185
|
+
typeof cors === "boolean" ? {} : cors ?? { origin: defaultAllowedOrigins }
|
66186
|
+
)
|
66187
|
+
);
|
66166
66188
|
}
|
66167
66189
|
const { allowedHosts } = config.preview;
|
66168
66190
|
if (allowedHosts !== true && !config.preview.https) {
|
66169
|
-
app.use(hostCheckMiddleware(config));
|
66191
|
+
app.use(hostCheckMiddleware(config, true));
|
66170
66192
|
}
|
66171
66193
|
const { proxy } = config.preview;
|
66172
66194
|
if (proxy) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-CevzF2vT.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 { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-CevzF2vT.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-
|
734
|
+
const { createServer } = await import('./chunks/dep-CevzF2vT.js').then(function (n) { return n.E; });
|
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-
|
826
|
+
const { build } = await import('./chunks/dep-CevzF2vT.js').then(function (n) { return n.F; });
|
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-
|
855
|
+
const { optimizeDeps } = await import('./chunks/dep-CevzF2vT.js').then(function (n) { return n.D; });
|
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-
|
881
|
+
const { preview } = await import('./chunks/dep-CevzF2vT.js').then(function (n) { return n.G; });
|
882
882
|
try {
|
883
883
|
const server = await preview({
|
884
884
|
root,
|
package/dist/node/constants.js
CHANGED
@@ -107,6 +107,7 @@ const wildcardHosts = /* @__PURE__ */ new Set([
|
|
107
107
|
const DEFAULT_DEV_PORT = 5173;
|
108
108
|
const DEFAULT_PREVIEW_PORT = 4173;
|
109
109
|
const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
|
110
|
+
const defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
110
111
|
const METADATA_FILENAME = "_metadata.json";
|
111
112
|
|
112
|
-
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
113
|
+
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, defaultAllowedOrigins, loopbackHosts, wildcardHosts };
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
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-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-CevzF2vT.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-CevzF2vT.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';
|