vite 6.0.8 → 6.0.10
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/client/client.mjs +9 -3
- package/dist/node/chunks/{dep-C-SVMOic.js → dep-BgKqB7IO.js} +1 -1
- package/dist/node/chunks/{dep-Beq30MX9.js → dep-DP_yvx5y.js} +174 -23
- package/dist/node/chunks/{dep-BthWCIj2.js → dep-a6F3bn0a.js} +1 -1
- package/dist/node/cli.js +7 -6
- package/dist/node/index.d.ts +47 -0
- package/dist/node/index.js +4 -3
- package/package.json +1 -1
package/dist/client/client.mjs
CHANGED
@@ -748,10 +748,14 @@ const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || i
|
|
748
748
|
const directSocketHost = __HMR_DIRECT_TARGET__;
|
749
749
|
const base = __BASE__ || "/";
|
750
750
|
const hmrTimeout = __HMR_TIMEOUT__;
|
751
|
+
const wsToken = __WS_TOKEN__;
|
751
752
|
const transport = normalizeModuleRunnerTransport(
|
752
753
|
(() => {
|
753
754
|
let wsTransport = createWebSocketModuleRunnerTransport({
|
754
|
-
createConnection: () => new WebSocket(
|
755
|
+
createConnection: () => new WebSocket(
|
756
|
+
`${socketProtocol}://${socketHost}?token=${wsToken}`,
|
757
|
+
"vite-hmr"
|
758
|
+
),
|
755
759
|
pingInterval: hmrTimeout
|
756
760
|
});
|
757
761
|
return {
|
@@ -762,7 +766,7 @@ const transport = normalizeModuleRunnerTransport(
|
|
762
766
|
if (!hmrPort) {
|
763
767
|
wsTransport = createWebSocketModuleRunnerTransport({
|
764
768
|
createConnection: () => new WebSocket(
|
765
|
-
`${socketProtocol}://${directSocketHost}`,
|
769
|
+
`${socketProtocol}://${directSocketHost}?token=${wsToken}`,
|
766
770
|
"vite-hmr"
|
767
771
|
),
|
768
772
|
pingInterval: hmrTimeout
|
@@ -912,7 +916,9 @@ async function handleMessage(payload) {
|
|
912
916
|
if (hasDocument && !willUnload) {
|
913
917
|
console.log(`[vite] server connection lost. Polling for restart...`);
|
914
918
|
const socket = payload.data.webSocket;
|
915
|
-
|
919
|
+
const url = new URL(socket.url);
|
920
|
+
url.search = "";
|
921
|
+
await waitForSuccessfulPing(url.href);
|
916
922
|
location.reload();
|
917
923
|
}
|
918
924
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { O as commonjsGlobal, N as getDefaultExportFromCjs } from './dep-DP_yvx5y.js';
|
2
2
|
import require$$0$2 from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -6,6 +6,7 @@ import require$$1$1, { fileURLToPath as fileURLToPath$1, URL as URL$3, pathToFil
|
|
6
6
|
import { promisify as promisify$4, format as format$2, inspect, stripVTControlCharacters } from 'node:util';
|
7
7
|
import { performance } from 'node:perf_hooks';
|
8
8
|
import require$$0$6, { createRequire as createRequire$1, builtinModules } from 'node:module';
|
9
|
+
import crypto$2 from 'node:crypto';
|
9
10
|
import esbuild, { transform as transform$1, formatMessages, build as build$b } from 'esbuild';
|
10
11
|
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEV_PROD_CONDITION, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_SERVER_MAIN_FIELDS, DEFAULT_CLIENT_CONDITIONS, DEFAULT_SERVER_CONDITIONS } from '../constants.js';
|
11
12
|
import require$$0$2, { posix, win32, isAbsolute, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join, sep } from 'path';
|
@@ -23,7 +24,6 @@ import require$$0$8 from 'stream';
|
|
23
24
|
import require$$2 from 'os';
|
24
25
|
import require$$2$1 from 'child_process';
|
25
26
|
import os$3 from 'node:os';
|
26
|
-
import crypto$2 from 'node:crypto';
|
27
27
|
import { promises } from 'node:dns';
|
28
28
|
import { ModuleRunner, ESModulesEvaluator } from 'vite/module-runner';
|
29
29
|
import { parseAstAsync, parseAst } from 'rollup/parseAst';
|
@@ -40,6 +40,7 @@ import zlib$1 from 'zlib';
|
|
40
40
|
import require$$0$9 from 'buffer';
|
41
41
|
import require$$1$3 from 'https';
|
42
42
|
import require$$4$2 from 'tls';
|
43
|
+
import net$1 from 'node:net';
|
43
44
|
import require$$4$3 from 'assert';
|
44
45
|
import * as qs from 'node:querystring';
|
45
46
|
import { gzip } from 'node:zlib';
|
@@ -37669,6 +37670,103 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
37669
37670
|
|
37670
37671
|
var WebSocketServerRaw_ = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
37671
37672
|
|
37673
|
+
const allowedHostsCache = /* @__PURE__ */ new WeakMap();
|
37674
|
+
const isFileOrExtensionProtocolRE = /^(?:file|.+-extension):/i;
|
37675
|
+
function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions) {
|
37676
|
+
const list = [];
|
37677
|
+
if (typeof resolvedServerOptions.host === "string" && resolvedServerOptions.host) {
|
37678
|
+
list.push(resolvedServerOptions.host);
|
37679
|
+
}
|
37680
|
+
if (typeof resolvedServerOptions.hmr === "object" && resolvedServerOptions.hmr.host) {
|
37681
|
+
list.push(resolvedServerOptions.hmr.host);
|
37682
|
+
}
|
37683
|
+
if (typeof resolvedPreviewOptions.host === "string" && resolvedPreviewOptions.host) {
|
37684
|
+
list.push(resolvedPreviewOptions.host);
|
37685
|
+
}
|
37686
|
+
if (resolvedServerOptions.origin) {
|
37687
|
+
try {
|
37688
|
+
const serverOriginUrl = new URL(resolvedServerOptions.origin);
|
37689
|
+
list.push(serverOriginUrl.hostname);
|
37690
|
+
} catch {
|
37691
|
+
}
|
37692
|
+
}
|
37693
|
+
return list;
|
37694
|
+
}
|
37695
|
+
function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
37696
|
+
if (isFileOrExtensionProtocolRE.test(host)) {
|
37697
|
+
return true;
|
37698
|
+
}
|
37699
|
+
const trimmedHost = host.trim();
|
37700
|
+
if (trimmedHost[0] === "[") {
|
37701
|
+
const endIpv6 = trimmedHost.indexOf("]");
|
37702
|
+
if (endIpv6 < 0) {
|
37703
|
+
return false;
|
37704
|
+
}
|
37705
|
+
return net$1.isIP(trimmedHost.slice(1, endIpv6)) === 6;
|
37706
|
+
}
|
37707
|
+
const colonPos = trimmedHost.indexOf(":");
|
37708
|
+
const hostname = colonPos === -1 ? trimmedHost : trimmedHost.slice(0, colonPos);
|
37709
|
+
if (net$1.isIP(hostname) === 4) {
|
37710
|
+
return true;
|
37711
|
+
}
|
37712
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) {
|
37713
|
+
return true;
|
37714
|
+
}
|
37715
|
+
for (const additionalAllowedHost of additionalAllowedHosts) {
|
37716
|
+
if (additionalAllowedHost === hostname) {
|
37717
|
+
return true;
|
37718
|
+
}
|
37719
|
+
}
|
37720
|
+
for (const allowedHost of allowedHosts) {
|
37721
|
+
if (allowedHost === hostname) {
|
37722
|
+
return true;
|
37723
|
+
}
|
37724
|
+
if (allowedHost[0] === "." && (allowedHost.slice(1) === hostname || hostname.endsWith(allowedHost))) {
|
37725
|
+
return true;
|
37726
|
+
}
|
37727
|
+
}
|
37728
|
+
return false;
|
37729
|
+
}
|
37730
|
+
function isHostAllowed(config, host) {
|
37731
|
+
if (config.server.allowedHosts === true) {
|
37732
|
+
return true;
|
37733
|
+
}
|
37734
|
+
if (!allowedHostsCache.has(config)) {
|
37735
|
+
allowedHostsCache.set(config, /* @__PURE__ */ new Set());
|
37736
|
+
}
|
37737
|
+
const allowedHosts = allowedHostsCache.get(config);
|
37738
|
+
if (allowedHosts.has(host)) {
|
37739
|
+
return true;
|
37740
|
+
}
|
37741
|
+
const result = isHostAllowedWithoutCache(
|
37742
|
+
config.server.allowedHosts,
|
37743
|
+
config.additionalAllowedHosts,
|
37744
|
+
host
|
37745
|
+
);
|
37746
|
+
if (result) {
|
37747
|
+
allowedHosts.add(host);
|
37748
|
+
}
|
37749
|
+
return result;
|
37750
|
+
}
|
37751
|
+
function hostCheckMiddleware(config) {
|
37752
|
+
return function viteHostCheckMiddleware(req, res, next) {
|
37753
|
+
const hostHeader = req.headers.host;
|
37754
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
37755
|
+
const hostname = hostHeader?.replace(/:\d+$/, "");
|
37756
|
+
const hostnameWithQuotes = JSON.stringify(hostname);
|
37757
|
+
res.writeHead(403, {
|
37758
|
+
"Content-Type": "text/plain"
|
37759
|
+
});
|
37760
|
+
res.end(
|
37761
|
+
`Blocked request. This host (${hostnameWithQuotes}) is not allowed.
|
37762
|
+
To allow this host, add ${hostnameWithQuotes} to \`server.allowedHosts\` in vite.config.js.`
|
37763
|
+
);
|
37764
|
+
return;
|
37765
|
+
}
|
37766
|
+
return next();
|
37767
|
+
};
|
37768
|
+
}
|
37769
|
+
|
37672
37770
|
const WebSocketServerRaw = process.versions.bun ? (
|
37673
37771
|
// @ts-expect-error: Bun defines `import.meta.require`
|
37674
37772
|
import.meta.require("ws").WebSocketServer
|
@@ -37684,6 +37782,19 @@ const wsServerEvents = [
|
|
37684
37782
|
];
|
37685
37783
|
function noop$3() {
|
37686
37784
|
}
|
37785
|
+
function hasValidToken(config, url) {
|
37786
|
+
const token = url.searchParams.get("token");
|
37787
|
+
if (!token) return false;
|
37788
|
+
try {
|
37789
|
+
const isValidToken = crypto$2.timingSafeEqual(
|
37790
|
+
Buffer.from(token),
|
37791
|
+
Buffer.from(config.webSocketToken)
|
37792
|
+
);
|
37793
|
+
return isValidToken;
|
37794
|
+
} catch {
|
37795
|
+
}
|
37796
|
+
return false;
|
37797
|
+
}
|
37687
37798
|
function createWebSocketServer(server, config, httpsOptions) {
|
37688
37799
|
if (config.server.ws === false) {
|
37689
37800
|
return {
|
@@ -37707,7 +37818,6 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
37707
37818
|
send: noop$3
|
37708
37819
|
};
|
37709
37820
|
}
|
37710
|
-
let wss;
|
37711
37821
|
let wsHttpServer = undefined;
|
37712
37822
|
const hmr = isObject$2(config.server.hmr) && config.server.hmr;
|
37713
37823
|
const hmrServer = hmr && hmr.server;
|
@@ -37719,20 +37829,47 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
37719
37829
|
const clientsMap = /* @__PURE__ */ new WeakMap();
|
37720
37830
|
const port = hmrPort || 24678;
|
37721
37831
|
const host = hmr && hmr.host || undefined;
|
37832
|
+
const shouldHandle = (req) => {
|
37833
|
+
const protocol = req.headers["sec-websocket-protocol"];
|
37834
|
+
if (protocol === "vite-ping") return true;
|
37835
|
+
const hostHeader = req.headers.host;
|
37836
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
37837
|
+
return false;
|
37838
|
+
}
|
37839
|
+
if (config.legacy?.skipWebSocketTokenCheck) {
|
37840
|
+
return true;
|
37841
|
+
}
|
37842
|
+
if (req.headers.origin) {
|
37843
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
37844
|
+
return hasValidToken(config, parsedUrl);
|
37845
|
+
}
|
37846
|
+
return true;
|
37847
|
+
};
|
37848
|
+
const handleUpgrade = (req, socket, head, isPing) => {
|
37849
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
37850
|
+
if (isPing) {
|
37851
|
+
ws.close(
|
37852
|
+
/* Normal Closure */
|
37853
|
+
1e3
|
37854
|
+
);
|
37855
|
+
return;
|
37856
|
+
}
|
37857
|
+
wss.emit("connection", ws, req);
|
37858
|
+
});
|
37859
|
+
};
|
37860
|
+
const wss = new WebSocketServerRaw({ noServer: true });
|
37861
|
+
wss.shouldHandle = shouldHandle;
|
37722
37862
|
if (wsServer) {
|
37723
37863
|
let hmrBase = config.base;
|
37724
37864
|
const hmrPath = hmr ? hmr.path : undefined;
|
37725
37865
|
if (hmrPath) {
|
37726
37866
|
hmrBase = path$d.posix.join(hmrBase, hmrPath);
|
37727
37867
|
}
|
37728
|
-
wss = new WebSocketServerRaw({ noServer: true });
|
37729
37868
|
hmrServerWsListener = (req, socket, head) => {
|
37730
|
-
|
37731
|
-
|
37732
|
-
) &&
|
37733
|
-
|
37734
|
-
wss.emit("connection", ws, req);
|
37735
|
-
});
|
37869
|
+
const protocol = req.headers["sec-websocket-protocol"];
|
37870
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
37871
|
+
if ([HMR_HEADER, "vite-ping"].includes(protocol) && parsedUrl.pathname === hmrBase) {
|
37872
|
+
handleUpgrade(req, socket, head, protocol === "vite-ping");
|
37736
37873
|
}
|
37737
37874
|
};
|
37738
37875
|
wsServer.on("upgrade", hmrServerWsListener);
|
@@ -37753,16 +37890,13 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
37753
37890
|
} else {
|
37754
37891
|
wsHttpServer = createServer$3(route);
|
37755
37892
|
}
|
37756
|
-
wss = new WebSocketServerRaw({ noServer: true });
|
37757
37893
|
wsHttpServer.on("upgrade", (req, socket, head) => {
|
37758
37894
|
const protocol = req.headers["sec-websocket-protocol"];
|
37759
37895
|
if (protocol === "vite-ping" && server && !server.listening) {
|
37760
37896
|
req.destroy();
|
37761
37897
|
return;
|
37762
37898
|
}
|
37763
|
-
|
37764
|
-
wss.emit("connection", ws, req);
|
37765
|
-
});
|
37899
|
+
handleUpgrade(req, socket, head, protocol === "vite-ping");
|
37766
37900
|
});
|
37767
37901
|
wsHttpServer.on("error", (e) => {
|
37768
37902
|
if (e.code === "EADDRINUSE") {
|
@@ -37780,9 +37914,6 @@ ${e.stack || e.message}`),
|
|
37780
37914
|
});
|
37781
37915
|
}
|
37782
37916
|
wss.on("connection", (socket) => {
|
37783
|
-
if (socket.protocol === "vite-ping") {
|
37784
|
-
return;
|
37785
|
-
}
|
37786
37917
|
socket.on("message", (raw) => {
|
37787
37918
|
if (!customListeners.size) return;
|
37788
37919
|
let parsed;
|
@@ -43900,6 +44031,10 @@ async function _createServer(inlineConfig = {}, options) {
|
|
43900
44031
|
if (cors !== false) {
|
43901
44032
|
middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
43902
44033
|
}
|
44034
|
+
const { allowedHosts } = serverConfig;
|
44035
|
+
if (allowedHosts !== true && !serverConfig.https) {
|
44036
|
+
middlewares.use(hostCheckMiddleware(config));
|
44037
|
+
}
|
43903
44038
|
middlewares.use(cachedTransformMiddleware(server));
|
43904
44039
|
const { proxy } = serverConfig;
|
43905
44040
|
if (proxy) {
|
@@ -44020,10 +44155,11 @@ const serverConfigDefaults = Object.freeze({
|
|
44020
44155
|
port: DEFAULT_DEV_PORT,
|
44021
44156
|
strictPort: false,
|
44022
44157
|
host: "localhost",
|
44158
|
+
allowedHosts: [],
|
44023
44159
|
https: undefined,
|
44024
44160
|
open: false,
|
44025
44161
|
proxy: undefined,
|
44026
|
-
cors:
|
44162
|
+
cors: false,
|
44027
44163
|
headers: {},
|
44028
44164
|
// hmr
|
44029
44165
|
// ws
|
@@ -46190,8 +46326,9 @@ function clientInjectionsPlugin(config) {
|
|
46190
46326
|
const hmrTimeoutReplacement = escapeReplacement(timeout);
|
46191
46327
|
const hmrEnableOverlayReplacement = escapeReplacement(overlay);
|
46192
46328
|
const hmrConfigNameReplacement = escapeReplacement(hmrConfigName);
|
46329
|
+
const wsTokenReplacement = escapeReplacement(config.webSocketToken);
|
46193
46330
|
injectConfigValues = (code) => {
|
46194
|
-
return code.replace(`__MODE__`, modeReplacement).replace(/__BASE__/g, baseReplacement).replace(`__SERVER_HOST__`, serverHostReplacement).replace(`__HMR_PROTOCOL__`, hmrProtocolReplacement).replace(`__HMR_HOSTNAME__`, hmrHostnameReplacement).replace(`__HMR_PORT__`, hmrPortReplacement).replace(`__HMR_DIRECT_TARGET__`, hmrDirectTargetReplacement).replace(`__HMR_BASE__`, hmrBaseReplacement).replace(`__HMR_TIMEOUT__`, hmrTimeoutReplacement).replace(`__HMR_ENABLE_OVERLAY__`, hmrEnableOverlayReplacement).replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement);
|
46331
|
+
return code.replace(`__MODE__`, modeReplacement).replace(/__BASE__/g, baseReplacement).replace(`__SERVER_HOST__`, serverHostReplacement).replace(`__HMR_PROTOCOL__`, hmrProtocolReplacement).replace(`__HMR_HOSTNAME__`, hmrHostnameReplacement).replace(`__HMR_PORT__`, hmrPortReplacement).replace(`__HMR_DIRECT_TARGET__`, hmrDirectTargetReplacement).replace(`__HMR_BASE__`, hmrBaseReplacement).replace(`__HMR_TIMEOUT__`, hmrTimeoutReplacement).replace(`__HMR_ENABLE_OVERLAY__`, hmrEnableOverlayReplacement).replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement).replace(`__WS_TOKEN__`, wsTokenReplacement);
|
46195
46332
|
};
|
46196
46333
|
},
|
46197
46334
|
async transform(code, id, options) {
|
@@ -48738,8 +48875,8 @@ function createCachedImport(imp) {
|
|
48738
48875
|
return cached;
|
48739
48876
|
};
|
48740
48877
|
}
|
48741
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
48742
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
48878
|
+
const importPostcssImport = createCachedImport(() => import('./dep-a6F3bn0a.js').then(function (n) { return n.i; }));
|
48879
|
+
const importPostcssModules = createCachedImport(() => import('./dep-BgKqB7IO.js').then(function (n) { return n.i; }));
|
48743
48880
|
const importPostcss = createCachedImport(() => import('postcss'));
|
48744
48881
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
48745
48882
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -52882,6 +53019,7 @@ function resolvePreviewOptions(preview2, server) {
|
|
52882
53019
|
port: preview2?.port ?? DEFAULT_PREVIEW_PORT,
|
52883
53020
|
strictPort: preview2?.strictPort ?? server.strictPort,
|
52884
53021
|
host: preview2?.host ?? server.host,
|
53022
|
+
allowedHosts: preview2?.allowedHosts ?? server.allowedHosts,
|
52885
53023
|
https: preview2?.https ?? server.https,
|
52886
53024
|
open: preview2?.open ?? server.open,
|
52887
53025
|
proxy: preview2?.proxy ?? server.proxy,
|
@@ -52962,6 +53100,10 @@ async function preview(inlineConfig = {}) {
|
|
52962
53100
|
if (cors !== false) {
|
52963
53101
|
app.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
52964
53102
|
}
|
53103
|
+
const { allowedHosts } = config.preview;
|
53104
|
+
if (allowedHosts !== true && !config.preview.https) {
|
53105
|
+
app.use(hostCheckMiddleware(config));
|
53106
|
+
}
|
52965
53107
|
const { proxy } = config.preview;
|
52966
53108
|
if (proxy) {
|
52967
53109
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
@@ -53122,7 +53264,8 @@ const configDefaults = Object.freeze({
|
|
53122
53264
|
removeSsrLoadModule: undefined
|
53123
53265
|
},
|
53124
53266
|
legacy: {
|
53125
|
-
proxySsrExternalModules: false
|
53267
|
+
proxySsrExternalModules: false,
|
53268
|
+
skipWebSocketTokenCheck: false
|
53126
53269
|
},
|
53127
53270
|
logLevel: "info",
|
53128
53271
|
customLogger: undefined,
|
@@ -53567,6 +53710,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53567
53710
|
rollupOptions: config.worker?.rollupOptions || {}
|
53568
53711
|
};
|
53569
53712
|
const base = withTrailingSlash(resolvedBase);
|
53713
|
+
const preview = resolvePreviewOptions(config.preview, server);
|
53570
53714
|
resolved = {
|
53571
53715
|
configFile: configFile ? normalizePath$3(configFile) : undefined,
|
53572
53716
|
configFileDependencies: configFileDependencies.map(
|
@@ -53595,7 +53739,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53595
53739
|
},
|
53596
53740
|
server,
|
53597
53741
|
builder,
|
53598
|
-
preview
|
53742
|
+
preview,
|
53599
53743
|
envDir,
|
53600
53744
|
env: {
|
53601
53745
|
...userEnv,
|
@@ -53623,6 +53767,12 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53623
53767
|
dev: resolvedDevEnvironmentOptions,
|
53624
53768
|
build: resolvedBuildOptions,
|
53625
53769
|
environments: resolvedEnvironments,
|
53770
|
+
// random 72 bits (12 base64 chars)
|
53771
|
+
// at least 64bits is recommended
|
53772
|
+
// https://owasp.org/www-community/vulnerabilities/Insufficient_Session-ID_Length
|
53773
|
+
webSocketToken: Buffer.from(
|
53774
|
+
crypto$2.getRandomValues(new Uint8Array(9))
|
53775
|
+
).toString("base64url"),
|
53626
53776
|
getSortedPlugins: undefined,
|
53627
53777
|
getSortedPluginHooks: undefined,
|
53628
53778
|
/**
|
@@ -53661,7 +53811,8 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53661
53811
|
dot: true
|
53662
53812
|
}
|
53663
53813
|
),
|
53664
|
-
safeModulePaths: /* @__PURE__ */ new Set()
|
53814
|
+
safeModulePaths: /* @__PURE__ */ new Set(),
|
53815
|
+
additionalAllowedHosts: getAdditionalAllowedHosts(server, preview)
|
53665
53816
|
};
|
53666
53817
|
resolved = {
|
53667
53818
|
...config,
|
package/dist/node/cli.js
CHANGED
@@ -2,12 +2,13 @@ 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 { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { M as colors, G as createLogger, r as resolveConfig } from './chunks/dep-DP_yvx5y.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
9
9
|
import 'node:util';
|
10
10
|
import 'node:module';
|
11
|
+
import 'node:crypto';
|
11
12
|
import 'esbuild';
|
12
13
|
import 'path';
|
13
14
|
import 'fs';
|
@@ -23,7 +24,6 @@ import 'stream';
|
|
23
24
|
import 'os';
|
24
25
|
import 'child_process';
|
25
26
|
import 'node:os';
|
26
|
-
import 'node:crypto';
|
27
27
|
import 'node:dns';
|
28
28
|
import 'vite/module-runner';
|
29
29
|
import 'rollup/parseAst';
|
@@ -40,6 +40,7 @@ import 'zlib';
|
|
40
40
|
import 'buffer';
|
41
41
|
import 'https';
|
42
42
|
import 'tls';
|
43
|
+
import 'node:net';
|
43
44
|
import 'assert';
|
44
45
|
import 'node:querystring';
|
45
46
|
import 'node:zlib';
|
@@ -740,7 +741,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
740
741
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
741
742
|
).action(async (root, options) => {
|
742
743
|
filterDuplicateOptions(options);
|
743
|
-
const { createServer } = await import('./chunks/dep-
|
744
|
+
const { createServer } = await import('./chunks/dep-DP_yvx5y.js').then(function (n) { return n.Q; });
|
744
745
|
try {
|
745
746
|
const server = await createServer({
|
746
747
|
root,
|
@@ -833,7 +834,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
833
834
|
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--app", `[boolean] same as \`builder: {}\``).action(
|
834
835
|
async (root, options) => {
|
835
836
|
filterDuplicateOptions(options);
|
836
|
-
const { createBuilder } = await import('./chunks/dep-
|
837
|
+
const { createBuilder } = await import('./chunks/dep-DP_yvx5y.js').then(function (n) { return n.R; });
|
837
838
|
const buildOptions = cleanGlobalCLIOptions(
|
838
839
|
cleanBuilderCLIOptions(options)
|
839
840
|
);
|
@@ -868,7 +869,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
|
|
868
869
|
).action(
|
869
870
|
async (root, options) => {
|
870
871
|
filterDuplicateOptions(options);
|
871
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
872
|
+
const { optimizeDeps } = await import('./chunks/dep-DP_yvx5y.js').then(function (n) { return n.P; });
|
872
873
|
try {
|
873
874
|
const config = await resolveConfig(
|
874
875
|
{
|
@@ -894,7 +895,7 @@ ${e.stack}`),
|
|
894
895
|
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(
|
895
896
|
async (root, options) => {
|
896
897
|
filterDuplicateOptions(options);
|
897
|
-
const { preview } = await import('./chunks/dep-
|
898
|
+
const { preview } = await import('./chunks/dep-DP_yvx5y.js').then(function (n) { return n.S; });
|
898
899
|
try {
|
899
900
|
const server = await preview({
|
900
901
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -674,6 +674,18 @@ interface CommonServerOptions {
|
|
674
674
|
* Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
|
675
675
|
*/
|
676
676
|
host?: string | boolean;
|
677
|
+
/**
|
678
|
+
* The hostnames that Vite is allowed to respond to.
|
679
|
+
* `localhost` and subdomains under `.localhost` and all IP addresses are allowed by default.
|
680
|
+
* When using HTTPS, this check is skipped.
|
681
|
+
*
|
682
|
+
* If a string starts with `.`, it will allow that hostname without the `.` and all subdomains under the hostname.
|
683
|
+
* For example, `.example.com` will allow `example.com`, `foo.example.com`, and `foo.bar.example.com`.
|
684
|
+
*
|
685
|
+
* If set to `true`, the server is allowed to respond to requests for any hosts.
|
686
|
+
* This is not recommended as it will be vulnerable to DNS rebinding attacks.
|
687
|
+
*/
|
688
|
+
allowedHosts?: string[] | true;
|
677
689
|
/**
|
678
690
|
* Enable TLS + HTTP/2.
|
679
691
|
* Note: this downgrades to TLS only when the proxy option is also used.
|
@@ -709,8 +721,14 @@ interface CommonServerOptions {
|
|
709
721
|
/**
|
710
722
|
* Configure CORS for the dev server.
|
711
723
|
* Uses https://github.com/expressjs/cors.
|
724
|
+
*
|
725
|
+
* When enabling this option, **we recommend setting a specific value
|
726
|
+
* rather than `true`** to avoid exposing the source code to untrusted origins.
|
727
|
+
*
|
712
728
|
* Set to `true` to allow all methods from any origin, or configure separately
|
713
729
|
* using an object.
|
730
|
+
*
|
731
|
+
* @default false
|
714
732
|
*/
|
715
733
|
cors?: CorsOptions | boolean;
|
716
734
|
/**
|
@@ -722,6 +740,12 @@ interface CommonServerOptions {
|
|
722
740
|
* https://github.com/expressjs/cors#configuration-options
|
723
741
|
*/
|
724
742
|
interface CorsOptions {
|
743
|
+
/**
|
744
|
+
* Configures the Access-Control-Allow-Origin CORS header.
|
745
|
+
*
|
746
|
+
* **We recommend setting a specific value rather than
|
747
|
+
* `true`** to avoid exposing the source code to untrusted origins.
|
748
|
+
*/
|
725
749
|
origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
726
750
|
methods?: string | string[];
|
727
751
|
allowedHeaders?: string | string[];
|
@@ -3900,6 +3924,18 @@ interface LegacyOptions {
|
|
3900
3924
|
* https://github.com/vitejs/vite/discussions/14697.
|
3901
3925
|
*/
|
3902
3926
|
proxySsrExternalModules?: boolean;
|
3927
|
+
/**
|
3928
|
+
* In Vite 6.0.8 and below, WebSocket server was able to connect from any web pages. However,
|
3929
|
+
* that could be exploited by a malicious web page.
|
3930
|
+
*
|
3931
|
+
* In Vite 6.0.9+, the WebSocket server now requires a token to connect from a web page.
|
3932
|
+
* But this may break some plugins and frameworks that connects to the WebSocket server
|
3933
|
+
* on their own. Enabling this option will make Vite skip the token check.
|
3934
|
+
*
|
3935
|
+
* **We do not recommend enabling this option unless you are sure that you are fine with
|
3936
|
+
* that security weakness.**
|
3937
|
+
*/
|
3938
|
+
skipWebSocketTokenCheck?: boolean;
|
3903
3939
|
}
|
3904
3940
|
interface ResolvedWorkerOptions {
|
3905
3941
|
format: 'es' | 'iife';
|
@@ -3946,6 +3982,17 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'json' | 'as
|
|
3946
3982
|
appType: AppType;
|
3947
3983
|
experimental: ExperimentalOptions;
|
3948
3984
|
environments: Record<string, ResolvedEnvironmentOptions>;
|
3985
|
+
/**
|
3986
|
+
* The token to connect to the WebSocket server from browsers.
|
3987
|
+
*
|
3988
|
+
* We recommend using `import.meta.hot` rather than connecting
|
3989
|
+
* to the WebSocket server directly.
|
3990
|
+
* If you have a usecase that requires connecting to the WebSocket
|
3991
|
+
* server, please create an issue so that we can discuss.
|
3992
|
+
*
|
3993
|
+
* @deprecated
|
3994
|
+
*/
|
3995
|
+
webSocketToken: string;
|
3949
3996
|
} & PluginHookUtils>;
|
3950
3997
|
interface PluginHookUtils {
|
3951
3998
|
getSortedPlugins: <K extends keyof Plugin>(hookName: K) => PluginWithRequiredHook<K>[];
|
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 BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-DP_yvx5y.js';
|
3
|
+
export { B as BuildEnvironment, D as DevEnvironment, f as build, m as buildErrorMessage, g as createBuilder, C as createFilter, h as createIdResolver, G as createLogger, n as createRunnableDevEnvironment, c as createServer, w as createServerHotChannel, v as createServerModuleRunner, d as defineConfig, u as fetchModule, j as formatPostcssSourceMap, J as isFileLoadingAllowed, I as isFileServingAllowed, q as isRunnableDevEnvironment, l as loadConfigFromFile, K as loadEnv, A as mergeAlias, z as mergeConfig, x as moduleRunnerTransform, y as normalizePath, o as optimizeDeps, p as perEnvironmentPlugin, b as perEnvironmentState, k as preprocessCSS, e as preview, r as resolveConfig, L as resolveEnvPrefix, E as rollupVersion, H as searchForWorkspaceRoot, F as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-DP_yvx5y.js';
|
4
4
|
export { 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';
|
@@ -10,6 +10,7 @@ import 'node:url';
|
|
10
10
|
import 'node:util';
|
11
11
|
import 'node:perf_hooks';
|
12
12
|
import 'node:module';
|
13
|
+
import 'node:crypto';
|
13
14
|
import 'path';
|
14
15
|
import 'fs';
|
15
16
|
import 'node:child_process';
|
@@ -25,7 +26,6 @@ import 'stream';
|
|
25
26
|
import 'os';
|
26
27
|
import 'child_process';
|
27
28
|
import 'node:os';
|
28
|
-
import 'node:crypto';
|
29
29
|
import 'node:dns';
|
30
30
|
import 'vite/module-runner';
|
31
31
|
import 'module';
|
@@ -41,6 +41,7 @@ import 'zlib';
|
|
41
41
|
import 'buffer';
|
42
42
|
import 'https';
|
43
43
|
import 'tls';
|
44
|
+
import 'node:net';
|
44
45
|
import 'assert';
|
45
46
|
import 'node:querystring';
|
46
47
|
import 'node:zlib';
|