vite 5.4.12 → 5.4.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.
- package/dist/node/chunks/{dep-CjorC8P2.js → dep-CHZK6zbr.js} +39 -24
- package/dist/node/chunks/{dep-gXhP-2iO.js → dep-D0tGukau.js} +1 -1
- package/dist/node/chunks/{dep-B0RN4094.js → dep-DIiRB4RW.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-D0tGukau.js').then(function (n) { return n.i; }));
|
36995
|
+
const importPostcssModules = createCachedImport(() => import('./dep-DIiRB4RW.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 = [];
|
@@ -59191,8 +59192,11 @@ function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions
|
|
59191
59192
|
list.push(resolvedPreviewOptions.host);
|
59192
59193
|
}
|
59193
59194
|
if (resolvedServerOptions.origin) {
|
59194
|
-
|
59195
|
-
|
59195
|
+
try {
|
59196
|
+
const serverOriginUrl = new URL(resolvedServerOptions.origin);
|
59197
|
+
list.push(serverOriginUrl.hostname);
|
59198
|
+
} catch {
|
59199
|
+
}
|
59196
59200
|
}
|
59197
59201
|
return list;
|
59198
59202
|
}
|
@@ -59231,39 +59235,42 @@ function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
|
59231
59235
|
}
|
59232
59236
|
return false;
|
59233
59237
|
}
|
59234
|
-
function isHostAllowed(config, host) {
|
59235
|
-
|
59238
|
+
function isHostAllowed(config, isPreview, host) {
|
59239
|
+
const allowedHosts = isPreview ? config.preview.allowedHosts : config.server.allowedHosts;
|
59240
|
+
if (allowedHosts === true) {
|
59236
59241
|
return true;
|
59237
59242
|
}
|
59238
|
-
|
59239
|
-
|
59243
|
+
const cache = isPreview ? allowedHostsPreviewCache : allowedHostsServerCache;
|
59244
|
+
if (!cache.has(config)) {
|
59245
|
+
cache.set(config, /* @__PURE__ */ new Set());
|
59240
59246
|
}
|
59241
|
-
const
|
59242
|
-
if (
|
59247
|
+
const cachedAllowedHosts = cache.get(config);
|
59248
|
+
if (cachedAllowedHosts.has(host)) {
|
59243
59249
|
return true;
|
59244
59250
|
}
|
59245
59251
|
const result = isHostAllowedWithoutCache(
|
59246
|
-
|
59252
|
+
allowedHosts ?? [],
|
59247
59253
|
config.additionalAllowedHosts,
|
59248
59254
|
host
|
59249
59255
|
);
|
59250
59256
|
if (result) {
|
59251
|
-
|
59257
|
+
cachedAllowedHosts.add(host);
|
59252
59258
|
}
|
59253
59259
|
return result;
|
59254
59260
|
}
|
59255
|
-
function hostCheckMiddleware(config) {
|
59261
|
+
function hostCheckMiddleware(config, isPreview) {
|
59256
59262
|
return function viteHostCheckMiddleware(req, res, next) {
|
59257
59263
|
const hostHeader = req.headers.host;
|
59258
|
-
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59264
|
+
if (!hostHeader || !isHostAllowed(config, isPreview, hostHeader)) {
|
59259
59265
|
const hostname = hostHeader?.replace(/:\d+$/, "");
|
59260
59266
|
const hostnameWithQuotes = JSON.stringify(hostname);
|
59267
|
+
const optionName = `${isPreview ? "preview" : "server"}.allowedHosts`;
|
59261
59268
|
res.writeHead(403, {
|
59262
59269
|
"Content-Type": "text/plain"
|
59263
59270
|
});
|
59264
59271
|
res.end(
|
59265
59272
|
`Blocked request. This host (${hostnameWithQuotes}) is not allowed.
|
59266
|
-
To allow this host, add ${hostnameWithQuotes} to \`
|
59273
|
+
To allow this host, add ${hostnameWithQuotes} to \`${optionName}\` in vite.config.js.`
|
59267
59274
|
);
|
59268
59275
|
return;
|
59269
59276
|
}
|
@@ -59326,7 +59333,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59326
59333
|
const host = hmr && hmr.host || void 0;
|
59327
59334
|
const shouldHandle = (req) => {
|
59328
59335
|
const hostHeader = req.headers.host;
|
59329
|
-
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59336
|
+
if (!hostHeader || !isHostAllowed(config, false, hostHeader)) {
|
59330
59337
|
return false;
|
59331
59338
|
}
|
59332
59339
|
if (config.legacy?.skipWebSocketTokenCheck) {
|
@@ -63226,12 +63233,16 @@ async function _createServer(inlineConfig = {}, options) {
|
|
63226
63233
|
middlewares.use(timeMiddleware(root));
|
63227
63234
|
}
|
63228
63235
|
const { cors } = serverConfig;
|
63229
|
-
if (cors !==
|
63230
|
-
middlewares.use(
|
63236
|
+
if (cors !== false) {
|
63237
|
+
middlewares.use(
|
63238
|
+
corsMiddleware(
|
63239
|
+
typeof cors === "boolean" ? {} : cors ?? { origin: defaultAllowedOrigins }
|
63240
|
+
)
|
63241
|
+
);
|
63231
63242
|
}
|
63232
63243
|
const { allowedHosts } = serverConfig;
|
63233
63244
|
if (allowedHosts !== true && !serverConfig.https) {
|
63234
|
-
middlewares.use(hostCheckMiddleware(config));
|
63245
|
+
middlewares.use(hostCheckMiddleware(config, false));
|
63235
63246
|
}
|
63236
63247
|
middlewares.use(cachedTransformMiddleware(server));
|
63237
63248
|
const { proxy } = serverConfig;
|
@@ -66158,12 +66169,16 @@ async function preview(inlineConfig = {}) {
|
|
66158
66169
|
postHooks.push(await hook(server));
|
66159
66170
|
}
|
66160
66171
|
const { cors } = config.preview;
|
66161
|
-
if (cors !==
|
66162
|
-
app.use(
|
66172
|
+
if (cors !== false) {
|
66173
|
+
app.use(
|
66174
|
+
corsMiddleware(
|
66175
|
+
typeof cors === "boolean" ? {} : cors ?? { origin: defaultAllowedOrigins }
|
66176
|
+
)
|
66177
|
+
);
|
66163
66178
|
}
|
66164
66179
|
const { allowedHosts } = config.preview;
|
66165
66180
|
if (allowedHosts !== true && !config.preview.https) {
|
66166
|
-
app.use(hostCheckMiddleware(config));
|
66181
|
+
app.use(hostCheckMiddleware(config, true));
|
66167
66182
|
}
|
66168
66183
|
const { proxy } = config.preview;
|
66169
66184
|
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-CHZK6zbr.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-CHZK6zbr.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-CHZK6zbr.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-CHZK6zbr.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-CHZK6zbr.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-CHZK6zbr.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-CHZK6zbr.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-CHZK6zbr.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';
|