vite 5.4.11 → 5.4.13
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 +5 -1
- package/dist/node/chunks/{dep-C6EFp3uH.js → dep-CT-NxJFJ.js} +1 -1
- package/dist/node/chunks/{dep-CB_7IfJ-.js → dep-Cjmyj91f.js} +177 -14
- package/dist/node/chunks/{dep-Ba1kN6Mp.js → dep-Dzr4bp1s.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
@@ -500,6 +500,7 @@ const hmrPort = __HMR_PORT__;
|
|
500
500
|
const socketHost = `${__HMR_HOSTNAME__ || importMetaUrl.hostname}:${hmrPort || importMetaUrl.port}${__HMR_BASE__}`;
|
501
501
|
const directSocketHost = __HMR_DIRECT_TARGET__;
|
502
502
|
const base = __BASE__ || "/";
|
503
|
+
const wsToken = __WS_TOKEN__;
|
503
504
|
let socket;
|
504
505
|
try {
|
505
506
|
let fallback;
|
@@ -532,7 +533,10 @@ Check out your Vite / network configuration and https://vite.dev/config/server-o
|
|
532
533
|
console.error(`[vite] failed to connect to websocket (${error}). `);
|
533
534
|
}
|
534
535
|
function setupWebSocket(protocol, hostAndPath, onCloseWithoutOpen) {
|
535
|
-
const socket2 = new WebSocket(
|
536
|
+
const socket2 = new WebSocket(
|
537
|
+
`${protocol}://${hostAndPath}?token=${wsToken}`,
|
538
|
+
"vite-hmr"
|
539
|
+
);
|
536
540
|
let isOpened = false;
|
537
541
|
socket2.addEventListener(
|
538
542
|
"open",
|
@@ -6,6 +6,7 @@ import { fileURLToPath, URL as URL$3, parse as parse$h, pathToFileURL } from 'no
|
|
6
6
|
import { promisify as promisify$4, format as format$2, inspect } from 'node:util';
|
7
7
|
import { performance as performance$1 } from 'node:perf_hooks';
|
8
8
|
import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
9
|
+
import crypto$2, { createHash as createHash$2 } from 'node:crypto';
|
9
10
|
import require$$0$3 from 'tty';
|
10
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';
|
11
12
|
import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
|
@@ -27,7 +28,6 @@ import require$$0$6 from 'stream';
|
|
27
28
|
import require$$2 from 'os';
|
28
29
|
import require$$2$1 from 'child_process';
|
29
30
|
import os$5 from 'node:os';
|
30
|
-
import { createHash as createHash$2 } from 'node:crypto';
|
31
31
|
import { promises } from 'node:dns';
|
32
32
|
import require$$3$1 from 'crypto';
|
33
33
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
@@ -42,6 +42,7 @@ import zlib$1 from 'zlib';
|
|
42
42
|
import require$$0$a from 'buffer';
|
43
43
|
import require$$1$1 from 'https';
|
44
44
|
import require$$4$2 from 'tls';
|
45
|
+
import net$1 from 'node:net';
|
45
46
|
import require$$4$3 from 'assert';
|
46
47
|
import { gzip } from 'node:zlib';
|
47
48
|
|
@@ -36990,8 +36991,8 @@ function createCachedImport(imp) {
|
|
36990
36991
|
return cached;
|
36991
36992
|
};
|
36992
36993
|
}
|
36993
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
36994
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
36994
|
+
const importPostcssImport = createCachedImport(() => import('./dep-CT-NxJFJ.js').then(function (n) { return n.i; }));
|
36995
|
+
const importPostcssModules = createCachedImport(() => import('./dep-Dzr4bp1s.js').then(function (n) { return n.i; }));
|
36995
36996
|
const importPostcss = createCachedImport(() => import('postcss'));
|
36996
36997
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
36997
36998
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -47496,8 +47497,9 @@ function clientInjectionsPlugin(config) {
|
|
47496
47497
|
const hmrTimeoutReplacement = escapeReplacement(timeout);
|
47497
47498
|
const hmrEnableOverlayReplacement = escapeReplacement(overlay);
|
47498
47499
|
const hmrConfigNameReplacement = escapeReplacement(hmrConfigName);
|
47500
|
+
const wsTokenReplacement = escapeReplacement(config.webSocketToken);
|
47499
47501
|
injectConfigValues = (code) => {
|
47500
|
-
return code.replace(`__MODE__`, modeReplacement).replace(/__BASE__/g, baseReplacement).replace(`__DEFINES__`, definesReplacement).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);
|
47502
|
+
return code.replace(`__MODE__`, modeReplacement).replace(/__BASE__/g, baseReplacement).replace(`__DEFINES__`, definesReplacement).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);
|
47501
47503
|
};
|
47502
47504
|
},
|
47503
47505
|
async transform(code, id, options) {
|
@@ -59175,6 +59177,103 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
59175
59177
|
|
59176
59178
|
var WebSocketServerRaw_ = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
59177
59179
|
|
59180
|
+
const allowedHostsCache = /* @__PURE__ */ new WeakMap();
|
59181
|
+
const isFileOrExtensionProtocolRE = /^(?:file|.+-extension):/i;
|
59182
|
+
function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions) {
|
59183
|
+
const list = [];
|
59184
|
+
if (typeof resolvedServerOptions.host === "string" && resolvedServerOptions.host) {
|
59185
|
+
list.push(resolvedServerOptions.host);
|
59186
|
+
}
|
59187
|
+
if (typeof resolvedServerOptions.hmr === "object" && resolvedServerOptions.hmr.host) {
|
59188
|
+
list.push(resolvedServerOptions.hmr.host);
|
59189
|
+
}
|
59190
|
+
if (typeof resolvedPreviewOptions.host === "string" && resolvedPreviewOptions.host) {
|
59191
|
+
list.push(resolvedPreviewOptions.host);
|
59192
|
+
}
|
59193
|
+
if (resolvedServerOptions.origin) {
|
59194
|
+
try {
|
59195
|
+
const serverOriginUrl = new URL(resolvedServerOptions.origin);
|
59196
|
+
list.push(serverOriginUrl.hostname);
|
59197
|
+
} catch {
|
59198
|
+
}
|
59199
|
+
}
|
59200
|
+
return list;
|
59201
|
+
}
|
59202
|
+
function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
59203
|
+
if (isFileOrExtensionProtocolRE.test(host)) {
|
59204
|
+
return true;
|
59205
|
+
}
|
59206
|
+
const trimmedHost = host.trim();
|
59207
|
+
if (trimmedHost[0] === "[") {
|
59208
|
+
const endIpv6 = trimmedHost.indexOf("]");
|
59209
|
+
if (endIpv6 < 0) {
|
59210
|
+
return false;
|
59211
|
+
}
|
59212
|
+
return net$1.isIP(trimmedHost.slice(1, endIpv6)) === 6;
|
59213
|
+
}
|
59214
|
+
const colonPos = trimmedHost.indexOf(":");
|
59215
|
+
const hostname = colonPos === -1 ? trimmedHost : trimmedHost.slice(0, colonPos);
|
59216
|
+
if (net$1.isIP(hostname) === 4) {
|
59217
|
+
return true;
|
59218
|
+
}
|
59219
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) {
|
59220
|
+
return true;
|
59221
|
+
}
|
59222
|
+
for (const additionalAllowedHost of additionalAllowedHosts) {
|
59223
|
+
if (additionalAllowedHost === hostname) {
|
59224
|
+
return true;
|
59225
|
+
}
|
59226
|
+
}
|
59227
|
+
for (const allowedHost of allowedHosts) {
|
59228
|
+
if (allowedHost === hostname) {
|
59229
|
+
return true;
|
59230
|
+
}
|
59231
|
+
if (allowedHost[0] === "." && (allowedHost.slice(1) === hostname || hostname.endsWith(allowedHost))) {
|
59232
|
+
return true;
|
59233
|
+
}
|
59234
|
+
}
|
59235
|
+
return false;
|
59236
|
+
}
|
59237
|
+
function isHostAllowed(config, host) {
|
59238
|
+
if (config.server.allowedHosts === true) {
|
59239
|
+
return true;
|
59240
|
+
}
|
59241
|
+
if (!allowedHostsCache.has(config)) {
|
59242
|
+
allowedHostsCache.set(config, /* @__PURE__ */ new Set());
|
59243
|
+
}
|
59244
|
+
const allowedHosts = allowedHostsCache.get(config);
|
59245
|
+
if (allowedHosts.has(host)) {
|
59246
|
+
return true;
|
59247
|
+
}
|
59248
|
+
const result = isHostAllowedWithoutCache(
|
59249
|
+
config.server.allowedHosts ?? [],
|
59250
|
+
config.additionalAllowedHosts,
|
59251
|
+
host
|
59252
|
+
);
|
59253
|
+
if (result) {
|
59254
|
+
allowedHosts.add(host);
|
59255
|
+
}
|
59256
|
+
return result;
|
59257
|
+
}
|
59258
|
+
function hostCheckMiddleware(config) {
|
59259
|
+
return function viteHostCheckMiddleware(req, res, next) {
|
59260
|
+
const hostHeader = req.headers.host;
|
59261
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59262
|
+
const hostname = hostHeader?.replace(/:\d+$/, "");
|
59263
|
+
const hostnameWithQuotes = JSON.stringify(hostname);
|
59264
|
+
res.writeHead(403, {
|
59265
|
+
"Content-Type": "text/plain"
|
59266
|
+
});
|
59267
|
+
res.end(
|
59268
|
+
`Blocked request. This host (${hostnameWithQuotes}) is not allowed.
|
59269
|
+
To allow this host, add ${hostnameWithQuotes} to \`server.allowedHosts\` in vite.config.js.`
|
59270
|
+
);
|
59271
|
+
return;
|
59272
|
+
}
|
59273
|
+
return next();
|
59274
|
+
};
|
59275
|
+
}
|
59276
|
+
|
59178
59277
|
const WebSocketServerRaw = process.versions.bun ? (
|
59179
59278
|
// @ts-expect-error: Bun defines `import.meta.require`
|
59180
59279
|
import.meta.require("ws").WebSocketServer
|
@@ -59189,6 +59288,19 @@ const wsServerEvents = [
|
|
59189
59288
|
];
|
59190
59289
|
function noop$1() {
|
59191
59290
|
}
|
59291
|
+
function hasValidToken(config, url) {
|
59292
|
+
const token = url.searchParams.get("token");
|
59293
|
+
if (!token) return false;
|
59294
|
+
try {
|
59295
|
+
const isValidToken = crypto$2.timingSafeEqual(
|
59296
|
+
Buffer.from(token),
|
59297
|
+
Buffer.from(config.webSocketToken)
|
59298
|
+
);
|
59299
|
+
return isValidToken;
|
59300
|
+
} catch {
|
59301
|
+
}
|
59302
|
+
return false;
|
59303
|
+
}
|
59192
59304
|
function createWebSocketServer(server, config, httpsOptions) {
|
59193
59305
|
if (config.server.ws === false) {
|
59194
59306
|
return {
|
@@ -59204,7 +59316,6 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59204
59316
|
send: noop$1
|
59205
59317
|
};
|
59206
59318
|
}
|
59207
|
-
let wss;
|
59208
59319
|
let wsHttpServer = void 0;
|
59209
59320
|
const hmr = isObject$1(config.server.hmr) && config.server.hmr;
|
59210
59321
|
const hmrServer = hmr && hmr.server;
|
@@ -59216,18 +59327,37 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59216
59327
|
const clientsMap = /* @__PURE__ */ new WeakMap();
|
59217
59328
|
const port = hmrPort || 24678;
|
59218
59329
|
const host = hmr && hmr.host || void 0;
|
59330
|
+
const shouldHandle = (req) => {
|
59331
|
+
const hostHeader = req.headers.host;
|
59332
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59333
|
+
return false;
|
59334
|
+
}
|
59335
|
+
if (config.legacy?.skipWebSocketTokenCheck) {
|
59336
|
+
return true;
|
59337
|
+
}
|
59338
|
+
if (req.headers.origin) {
|
59339
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
59340
|
+
return hasValidToken(config, parsedUrl);
|
59341
|
+
}
|
59342
|
+
return true;
|
59343
|
+
};
|
59344
|
+
const handleUpgrade = (req, socket, head, _isPing) => {
|
59345
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
59346
|
+
wss.emit("connection", ws, req);
|
59347
|
+
});
|
59348
|
+
};
|
59349
|
+
const wss = new WebSocketServerRaw({ noServer: true });
|
59350
|
+
wss.shouldHandle = shouldHandle;
|
59219
59351
|
if (wsServer) {
|
59220
59352
|
let hmrBase = config.base;
|
59221
59353
|
const hmrPath = hmr ? hmr.path : void 0;
|
59222
59354
|
if (hmrPath) {
|
59223
59355
|
hmrBase = path$n.posix.join(hmrBase, hmrPath);
|
59224
59356
|
}
|
59225
|
-
wss = new WebSocketServerRaw({ noServer: true });
|
59226
59357
|
hmrServerWsListener = (req, socket, head) => {
|
59227
|
-
|
59228
|
-
|
59229
|
-
|
59230
|
-
});
|
59358
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
59359
|
+
if (req.headers["sec-websocket-protocol"] === HMR_HEADER && parsedUrl.pathname === hmrBase) {
|
59360
|
+
handleUpgrade(req, socket, head);
|
59231
59361
|
}
|
59232
59362
|
};
|
59233
59363
|
wsServer.on("upgrade", hmrServerWsListener);
|
@@ -59248,7 +59378,23 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59248
59378
|
} else {
|
59249
59379
|
wsHttpServer = createServer$3(route);
|
59250
59380
|
}
|
59251
|
-
|
59381
|
+
wsHttpServer.on("upgrade", (req, socket, head) => {
|
59382
|
+
handleUpgrade(req, socket, head);
|
59383
|
+
});
|
59384
|
+
wsHttpServer.on("error", (e) => {
|
59385
|
+
if (e.code === "EADDRINUSE") {
|
59386
|
+
config.logger.error(
|
59387
|
+
colors$1.red(`WebSocket server error: Port is already in use`),
|
59388
|
+
{ error: e }
|
59389
|
+
);
|
59390
|
+
} else {
|
59391
|
+
config.logger.error(
|
59392
|
+
colors$1.red(`WebSocket server error:
|
59393
|
+
${e.stack || e.message}`),
|
59394
|
+
{ error: e }
|
59395
|
+
);
|
59396
|
+
}
|
59397
|
+
});
|
59252
59398
|
}
|
59253
59399
|
wss.on("connection", (socket) => {
|
59254
59400
|
socket.on("message", (raw) => {
|
@@ -63083,9 +63229,13 @@ async function _createServer(inlineConfig = {}, options) {
|
|
63083
63229
|
middlewares.use(timeMiddleware(root));
|
63084
63230
|
}
|
63085
63231
|
const { cors } = serverConfig;
|
63086
|
-
if (cors !== false) {
|
63232
|
+
if (cors !== void 0 && cors !== false) {
|
63087
63233
|
middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
63088
63234
|
}
|
63235
|
+
const { allowedHosts } = serverConfig;
|
63236
|
+
if (allowedHosts !== true && !serverConfig.https) {
|
63237
|
+
middlewares.use(hostCheckMiddleware(config));
|
63238
|
+
}
|
63089
63239
|
middlewares.use(cachedTransformMiddleware(server));
|
63090
63240
|
const { proxy } = serverConfig;
|
63091
63241
|
if (proxy) {
|
@@ -65943,6 +66093,7 @@ function resolvePreviewOptions(preview2, server) {
|
|
65943
66093
|
port: preview2?.port,
|
65944
66094
|
strictPort: preview2?.strictPort ?? server.strictPort,
|
65945
66095
|
host: preview2?.host ?? server.host,
|
66096
|
+
allowedHosts: preview2?.allowedHosts ?? server.allowedHosts,
|
65946
66097
|
https: preview2?.https ?? server.https,
|
65947
66098
|
open: preview2?.open ?? server.open,
|
65948
66099
|
proxy: preview2?.proxy ?? server.proxy,
|
@@ -66010,9 +66161,13 @@ async function preview(inlineConfig = {}) {
|
|
66010
66161
|
postHooks.push(await hook(server));
|
66011
66162
|
}
|
66012
66163
|
const { cors } = config.preview;
|
66013
|
-
if (cors !== false) {
|
66164
|
+
if (cors !== void 0 && cors !== false) {
|
66014
66165
|
app.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
66015
66166
|
}
|
66167
|
+
const { allowedHosts } = config.preview;
|
66168
|
+
if (allowedHosts !== true && !config.preview.https) {
|
66169
|
+
app.use(hostCheckMiddleware(config));
|
66170
|
+
}
|
66016
66171
|
const { proxy } = config.preview;
|
66017
66172
|
if (proxy) {
|
66018
66173
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
@@ -66329,6 +66484,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66329
66484
|
rollupOptions: config.worker?.rollupOptions || {}
|
66330
66485
|
};
|
66331
66486
|
const base = withTrailingSlash(resolvedBase);
|
66487
|
+
const preview = resolvePreviewOptions(config.preview, server);
|
66332
66488
|
resolved = {
|
66333
66489
|
configFile: configFile ? normalizePath$3(configFile) : void 0,
|
66334
66490
|
configFileDependencies: configFileDependencies.map(
|
@@ -66357,7 +66513,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66357
66513
|
},
|
66358
66514
|
server,
|
66359
66515
|
build: resolvedBuildOptions,
|
66360
|
-
preview
|
66516
|
+
preview,
|
66361
66517
|
envDir,
|
66362
66518
|
env: {
|
66363
66519
|
...userEnv,
|
@@ -66387,6 +66543,13 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66387
66543
|
hmrPartialAccept: false,
|
66388
66544
|
...config.experimental
|
66389
66545
|
},
|
66546
|
+
// random 72 bits (12 base64 chars)
|
66547
|
+
// at least 64bits is recommended
|
66548
|
+
// https://owasp.org/www-community/vulnerabilities/Insufficient_Session-ID_Length
|
66549
|
+
webSocketToken: Buffer.from(
|
66550
|
+
crypto$2.getRandomValues(new Uint8Array(9))
|
66551
|
+
).toString("base64url"),
|
66552
|
+
additionalAllowedHosts: getAdditionalAllowedHosts(server, preview),
|
66390
66553
|
getSortedPlugins: void 0,
|
66391
66554
|
getSortedPluginHooks: void 0
|
66392
66555
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-Cjmyj91f.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,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 { 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-Cjmyj91f.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 'tty';
|
12
13
|
import 'path';
|
13
14
|
import 'esbuild';
|
@@ -26,7 +27,6 @@ import 'stream';
|
|
26
27
|
import 'os';
|
27
28
|
import 'child_process';
|
28
29
|
import 'node:os';
|
29
|
-
import 'node:crypto';
|
30
30
|
import 'node:dns';
|
31
31
|
import 'crypto';
|
32
32
|
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:zlib';
|
46
47
|
|
@@ -730,7 +731,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
730
731
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
731
732
|
).action(async (root, options) => {
|
732
733
|
filterDuplicateOptions(options);
|
733
|
-
const { createServer } = await import('./chunks/dep-
|
734
|
+
const { createServer } = await import('./chunks/dep-Cjmyj91f.js').then(function (n) { return n.E; });
|
734
735
|
try {
|
735
736
|
const server = await createServer({
|
736
737
|
root,
|
@@ -822,7 +823,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
822
823
|
`[boolean] force empty outDir when it's outside of root`
|
823
824
|
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
|
824
825
|
filterDuplicateOptions(options);
|
825
|
-
const { build } = await import('./chunks/dep-
|
826
|
+
const { build } = await import('./chunks/dep-Cjmyj91f.js').then(function (n) { return n.F; });
|
826
827
|
const buildOptions = cleanOptions(options);
|
827
828
|
try {
|
828
829
|
await build({
|
@@ -851,7 +852,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
|
|
851
852
|
).action(
|
852
853
|
async (root, options) => {
|
853
854
|
filterDuplicateOptions(options);
|
854
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
855
|
+
const { optimizeDeps } = await import('./chunks/dep-Cjmyj91f.js').then(function (n) { return n.D; });
|
855
856
|
try {
|
856
857
|
const config = await resolveConfig(
|
857
858
|
{
|
@@ -877,7 +878,7 @@ ${e.stack}`),
|
|
877
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(
|
878
879
|
async (root, options) => {
|
879
880
|
filterDuplicateOptions(options);
|
880
|
-
const { preview } = await import('./chunks/dep-
|
881
|
+
const { preview } = await import('./chunks/dep-Cjmyj91f.js').then(function (n) { return n.G; });
|
881
882
|
try {
|
882
883
|
const server = await preview({
|
883
884
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -669,6 +669,18 @@ interface CommonServerOptions {
|
|
669
669
|
* Set to 0.0.0.0 to listen on all addresses, including LAN and public addresses.
|
670
670
|
*/
|
671
671
|
host?: string | boolean;
|
672
|
+
/**
|
673
|
+
* The hostnames that Vite is allowed to respond to.
|
674
|
+
* `localhost` and subdomains under `.localhost` and all IP addresses are allowed by default.
|
675
|
+
* When using HTTPS, this check is skipped.
|
676
|
+
*
|
677
|
+
* If a string starts with `.`, it will allow that hostname without the `.` and all subdomains under the hostname.
|
678
|
+
* For example, `.example.com` will allow `example.com`, `foo.example.com`, and `foo.bar.example.com`.
|
679
|
+
*
|
680
|
+
* If set to `true`, the server is allowed to respond to requests for any hosts.
|
681
|
+
* This is not recommended as it will be vulnerable to DNS rebinding attacks.
|
682
|
+
*/
|
683
|
+
allowedHosts?: string[] | true;
|
672
684
|
/**
|
673
685
|
* Enable TLS + HTTP/2.
|
674
686
|
* Note: this downgrades to TLS only when the proxy option is also used.
|
@@ -704,8 +716,14 @@ interface CommonServerOptions {
|
|
704
716
|
/**
|
705
717
|
* Configure CORS for the dev server.
|
706
718
|
* Uses https://github.com/expressjs/cors.
|
719
|
+
*
|
720
|
+
* When enabling this option, **we recommend setting a specific value
|
721
|
+
* rather than `true`** to avoid exposing the source code to untrusted origins.
|
722
|
+
*
|
707
723
|
* Set to `true` to allow all methods from any origin, or configure separately
|
708
724
|
* using an object.
|
725
|
+
*
|
726
|
+
* @default false
|
709
727
|
*/
|
710
728
|
cors?: CorsOptions | boolean;
|
711
729
|
/**
|
@@ -717,6 +735,12 @@ interface CommonServerOptions {
|
|
717
735
|
* https://github.com/expressjs/cors#configuration-options
|
718
736
|
*/
|
719
737
|
interface CorsOptions {
|
738
|
+
/**
|
739
|
+
* Configures the Access-Control-Allow-Origin CORS header.
|
740
|
+
*
|
741
|
+
* **We recommend setting a specific value rather than
|
742
|
+
* `true`** to avoid exposing the source code to untrusted origins.
|
743
|
+
*/
|
720
744
|
origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
721
745
|
methods?: string | string[];
|
722
746
|
allowedHeaders?: string | string[];
|
@@ -3402,6 +3426,18 @@ interface LegacyOptions {
|
|
3402
3426
|
* https://github.com/vitejs/vite/discussions/14697.
|
3403
3427
|
*/
|
3404
3428
|
proxySsrExternalModules?: boolean;
|
3429
|
+
/**
|
3430
|
+
* In Vite 6.0.8 / 5.4.11 and below, WebSocket server was able to connect from any web pages. However,
|
3431
|
+
* that could be exploited by a malicious web page.
|
3432
|
+
*
|
3433
|
+
* In Vite 6.0.9+ / 5.4.12+, the WebSocket server now requires a token to connect from a web page.
|
3434
|
+
* But this may break some plugins and frameworks that connects to the WebSocket server
|
3435
|
+
* on their own. Enabling this option will make Vite skip the token check.
|
3436
|
+
*
|
3437
|
+
* **We do not recommend enabling this option unless you are sure that you are fine with
|
3438
|
+
* that security weakness.**
|
3439
|
+
*/
|
3440
|
+
skipWebSocketTokenCheck?: boolean;
|
3405
3441
|
}
|
3406
3442
|
interface ResolvedWorkerOptions {
|
3407
3443
|
format: 'es' | 'iife';
|
@@ -3443,6 +3479,17 @@ type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'css' | 'assetsInclu
|
|
3443
3479
|
worker: ResolvedWorkerOptions;
|
3444
3480
|
appType: AppType;
|
3445
3481
|
experimental: ExperimentalOptions;
|
3482
|
+
/**
|
3483
|
+
* The token to connect to the WebSocket server from browsers.
|
3484
|
+
*
|
3485
|
+
* We recommend using `import.meta.hot` rather than connecting
|
3486
|
+
* to the WebSocket server directly.
|
3487
|
+
* If you have a usecase that requires connecting to the WebSocket
|
3488
|
+
* server, please create an issue so that we can discuss.
|
3489
|
+
*
|
3490
|
+
* @deprecated
|
3491
|
+
*/
|
3492
|
+
webSocketToken: string;
|
3446
3493
|
} & PluginHookUtils>;
|
3447
3494
|
interface PluginHookUtils {
|
3448
3495
|
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 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-Cjmyj91f.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-Cjmyj91f.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';
|
@@ -11,6 +11,7 @@ import 'node:url';
|
|
11
11
|
import 'node:util';
|
12
12
|
import 'node:perf_hooks';
|
13
13
|
import 'node:module';
|
14
|
+
import 'node:crypto';
|
14
15
|
import 'tty';
|
15
16
|
import 'path';
|
16
17
|
import 'fs';
|
@@ -29,7 +30,6 @@ import 'stream';
|
|
29
30
|
import 'os';
|
30
31
|
import 'child_process';
|
31
32
|
import 'node:os';
|
32
|
-
import 'node:crypto';
|
33
33
|
import 'node:dns';
|
34
34
|
import 'crypto';
|
35
35
|
import 'module';
|
@@ -43,6 +43,7 @@ import 'zlib';
|
|
43
43
|
import 'buffer';
|
44
44
|
import 'https';
|
45
45
|
import 'tls';
|
46
|
+
import 'node:net';
|
46
47
|
import 'assert';
|
47
48
|
import 'node:zlib';
|
48
49
|
|