vite 5.4.11 → 5.4.12
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-Ba1kN6Mp.js → dep-B0RN4094.js} +1 -1
- package/dist/node/chunks/{dep-CB_7IfJ-.js → dep-CjorC8P2.js} +174 -14
- package/dist/node/chunks/{dep-C6EFp3uH.js → dep-gXhP-2iO.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",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-CjorC8P2.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -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-gXhP-2iO.js').then(function (n) { return n.i; }));
|
36995
|
+
const importPostcssModules = createCachedImport(() => import('./dep-B0RN4094.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,100 @@ 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
|
+
const serverOriginUrl = new URL(resolvedServerOptions.origin);
|
59195
|
+
list.push(serverOriginUrl.hostname);
|
59196
|
+
}
|
59197
|
+
return list;
|
59198
|
+
}
|
59199
|
+
function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
59200
|
+
if (isFileOrExtensionProtocolRE.test(host)) {
|
59201
|
+
return true;
|
59202
|
+
}
|
59203
|
+
const trimmedHost = host.trim();
|
59204
|
+
if (trimmedHost[0] === "[") {
|
59205
|
+
const endIpv6 = trimmedHost.indexOf("]");
|
59206
|
+
if (endIpv6 < 0) {
|
59207
|
+
return false;
|
59208
|
+
}
|
59209
|
+
return net$1.isIP(trimmedHost.slice(1, endIpv6)) === 6;
|
59210
|
+
}
|
59211
|
+
const colonPos = trimmedHost.indexOf(":");
|
59212
|
+
const hostname = colonPos === -1 ? trimmedHost : trimmedHost.slice(0, colonPos);
|
59213
|
+
if (net$1.isIP(hostname) === 4) {
|
59214
|
+
return true;
|
59215
|
+
}
|
59216
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) {
|
59217
|
+
return true;
|
59218
|
+
}
|
59219
|
+
for (const additionalAllowedHost of additionalAllowedHosts) {
|
59220
|
+
if (additionalAllowedHost === hostname) {
|
59221
|
+
return true;
|
59222
|
+
}
|
59223
|
+
}
|
59224
|
+
for (const allowedHost of allowedHosts) {
|
59225
|
+
if (allowedHost === hostname) {
|
59226
|
+
return true;
|
59227
|
+
}
|
59228
|
+
if (allowedHost[0] === "." && (allowedHost.slice(1) === hostname || hostname.endsWith(allowedHost))) {
|
59229
|
+
return true;
|
59230
|
+
}
|
59231
|
+
}
|
59232
|
+
return false;
|
59233
|
+
}
|
59234
|
+
function isHostAllowed(config, host) {
|
59235
|
+
if (config.server.allowedHosts === true) {
|
59236
|
+
return true;
|
59237
|
+
}
|
59238
|
+
if (!allowedHostsCache.has(config)) {
|
59239
|
+
allowedHostsCache.set(config, /* @__PURE__ */ new Set());
|
59240
|
+
}
|
59241
|
+
const allowedHosts = allowedHostsCache.get(config);
|
59242
|
+
if (allowedHosts.has(host)) {
|
59243
|
+
return true;
|
59244
|
+
}
|
59245
|
+
const result = isHostAllowedWithoutCache(
|
59246
|
+
config.server.allowedHosts ?? [],
|
59247
|
+
config.additionalAllowedHosts,
|
59248
|
+
host
|
59249
|
+
);
|
59250
|
+
if (result) {
|
59251
|
+
allowedHosts.add(host);
|
59252
|
+
}
|
59253
|
+
return result;
|
59254
|
+
}
|
59255
|
+
function hostCheckMiddleware(config) {
|
59256
|
+
return function viteHostCheckMiddleware(req, res, next) {
|
59257
|
+
const hostHeader = req.headers.host;
|
59258
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59259
|
+
const hostname = hostHeader?.replace(/:\d+$/, "");
|
59260
|
+
const hostnameWithQuotes = JSON.stringify(hostname);
|
59261
|
+
res.writeHead(403, {
|
59262
|
+
"Content-Type": "text/plain"
|
59263
|
+
});
|
59264
|
+
res.end(
|
59265
|
+
`Blocked request. This host (${hostnameWithQuotes}) is not allowed.
|
59266
|
+
To allow this host, add ${hostnameWithQuotes} to \`server.allowedHosts\` in vite.config.js.`
|
59267
|
+
);
|
59268
|
+
return;
|
59269
|
+
}
|
59270
|
+
return next();
|
59271
|
+
};
|
59272
|
+
}
|
59273
|
+
|
59178
59274
|
const WebSocketServerRaw = process.versions.bun ? (
|
59179
59275
|
// @ts-expect-error: Bun defines `import.meta.require`
|
59180
59276
|
import.meta.require("ws").WebSocketServer
|
@@ -59189,6 +59285,19 @@ const wsServerEvents = [
|
|
59189
59285
|
];
|
59190
59286
|
function noop$1() {
|
59191
59287
|
}
|
59288
|
+
function hasValidToken(config, url) {
|
59289
|
+
const token = url.searchParams.get("token");
|
59290
|
+
if (!token) return false;
|
59291
|
+
try {
|
59292
|
+
const isValidToken = crypto$2.timingSafeEqual(
|
59293
|
+
Buffer.from(token),
|
59294
|
+
Buffer.from(config.webSocketToken)
|
59295
|
+
);
|
59296
|
+
return isValidToken;
|
59297
|
+
} catch {
|
59298
|
+
}
|
59299
|
+
return false;
|
59300
|
+
}
|
59192
59301
|
function createWebSocketServer(server, config, httpsOptions) {
|
59193
59302
|
if (config.server.ws === false) {
|
59194
59303
|
return {
|
@@ -59204,7 +59313,6 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59204
59313
|
send: noop$1
|
59205
59314
|
};
|
59206
59315
|
}
|
59207
|
-
let wss;
|
59208
59316
|
let wsHttpServer = void 0;
|
59209
59317
|
const hmr = isObject$1(config.server.hmr) && config.server.hmr;
|
59210
59318
|
const hmrServer = hmr && hmr.server;
|
@@ -59216,18 +59324,37 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59216
59324
|
const clientsMap = /* @__PURE__ */ new WeakMap();
|
59217
59325
|
const port = hmrPort || 24678;
|
59218
59326
|
const host = hmr && hmr.host || void 0;
|
59327
|
+
const shouldHandle = (req) => {
|
59328
|
+
const hostHeader = req.headers.host;
|
59329
|
+
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
59330
|
+
return false;
|
59331
|
+
}
|
59332
|
+
if (config.legacy?.skipWebSocketTokenCheck) {
|
59333
|
+
return true;
|
59334
|
+
}
|
59335
|
+
if (req.headers.origin) {
|
59336
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
59337
|
+
return hasValidToken(config, parsedUrl);
|
59338
|
+
}
|
59339
|
+
return true;
|
59340
|
+
};
|
59341
|
+
const handleUpgrade = (req, socket, head, _isPing) => {
|
59342
|
+
wss.handleUpgrade(req, socket, head, (ws) => {
|
59343
|
+
wss.emit("connection", ws, req);
|
59344
|
+
});
|
59345
|
+
};
|
59346
|
+
const wss = new WebSocketServerRaw({ noServer: true });
|
59347
|
+
wss.shouldHandle = shouldHandle;
|
59219
59348
|
if (wsServer) {
|
59220
59349
|
let hmrBase = config.base;
|
59221
59350
|
const hmrPath = hmr ? hmr.path : void 0;
|
59222
59351
|
if (hmrPath) {
|
59223
59352
|
hmrBase = path$n.posix.join(hmrBase, hmrPath);
|
59224
59353
|
}
|
59225
|
-
wss = new WebSocketServerRaw({ noServer: true });
|
59226
59354
|
hmrServerWsListener = (req, socket, head) => {
|
59227
|
-
|
59228
|
-
|
59229
|
-
|
59230
|
-
});
|
59355
|
+
const parsedUrl = new URL(`http://example.com${req.url}`);
|
59356
|
+
if (req.headers["sec-websocket-protocol"] === HMR_HEADER && parsedUrl.pathname === hmrBase) {
|
59357
|
+
handleUpgrade(req, socket, head);
|
59231
59358
|
}
|
59232
59359
|
};
|
59233
59360
|
wsServer.on("upgrade", hmrServerWsListener);
|
@@ -59248,7 +59375,23 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
59248
59375
|
} else {
|
59249
59376
|
wsHttpServer = createServer$3(route);
|
59250
59377
|
}
|
59251
|
-
|
59378
|
+
wsHttpServer.on("upgrade", (req, socket, head) => {
|
59379
|
+
handleUpgrade(req, socket, head);
|
59380
|
+
});
|
59381
|
+
wsHttpServer.on("error", (e) => {
|
59382
|
+
if (e.code === "EADDRINUSE") {
|
59383
|
+
config.logger.error(
|
59384
|
+
colors$1.red(`WebSocket server error: Port is already in use`),
|
59385
|
+
{ error: e }
|
59386
|
+
);
|
59387
|
+
} else {
|
59388
|
+
config.logger.error(
|
59389
|
+
colors$1.red(`WebSocket server error:
|
59390
|
+
${e.stack || e.message}`),
|
59391
|
+
{ error: e }
|
59392
|
+
);
|
59393
|
+
}
|
59394
|
+
});
|
59252
59395
|
}
|
59253
59396
|
wss.on("connection", (socket) => {
|
59254
59397
|
socket.on("message", (raw) => {
|
@@ -63083,9 +63226,13 @@ async function _createServer(inlineConfig = {}, options) {
|
|
63083
63226
|
middlewares.use(timeMiddleware(root));
|
63084
63227
|
}
|
63085
63228
|
const { cors } = serverConfig;
|
63086
|
-
if (cors !== false) {
|
63229
|
+
if (cors !== void 0 && cors !== false) {
|
63087
63230
|
middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
63088
63231
|
}
|
63232
|
+
const { allowedHosts } = serverConfig;
|
63233
|
+
if (allowedHosts !== true && !serverConfig.https) {
|
63234
|
+
middlewares.use(hostCheckMiddleware(config));
|
63235
|
+
}
|
63089
63236
|
middlewares.use(cachedTransformMiddleware(server));
|
63090
63237
|
const { proxy } = serverConfig;
|
63091
63238
|
if (proxy) {
|
@@ -65943,6 +66090,7 @@ function resolvePreviewOptions(preview2, server) {
|
|
65943
66090
|
port: preview2?.port,
|
65944
66091
|
strictPort: preview2?.strictPort ?? server.strictPort,
|
65945
66092
|
host: preview2?.host ?? server.host,
|
66093
|
+
allowedHosts: preview2?.allowedHosts ?? server.allowedHosts,
|
65946
66094
|
https: preview2?.https ?? server.https,
|
65947
66095
|
open: preview2?.open ?? server.open,
|
65948
66096
|
proxy: preview2?.proxy ?? server.proxy,
|
@@ -66010,9 +66158,13 @@ async function preview(inlineConfig = {}) {
|
|
66010
66158
|
postHooks.push(await hook(server));
|
66011
66159
|
}
|
66012
66160
|
const { cors } = config.preview;
|
66013
|
-
if (cors !== false) {
|
66161
|
+
if (cors !== void 0 && cors !== false) {
|
66014
66162
|
app.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
|
66015
66163
|
}
|
66164
|
+
const { allowedHosts } = config.preview;
|
66165
|
+
if (allowedHosts !== true && !config.preview.https) {
|
66166
|
+
app.use(hostCheckMiddleware(config));
|
66167
|
+
}
|
66016
66168
|
const { proxy } = config.preview;
|
66017
66169
|
if (proxy) {
|
66018
66170
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
@@ -66329,6 +66481,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66329
66481
|
rollupOptions: config.worker?.rollupOptions || {}
|
66330
66482
|
};
|
66331
66483
|
const base = withTrailingSlash(resolvedBase);
|
66484
|
+
const preview = resolvePreviewOptions(config.preview, server);
|
66332
66485
|
resolved = {
|
66333
66486
|
configFile: configFile ? normalizePath$3(configFile) : void 0,
|
66334
66487
|
configFileDependencies: configFileDependencies.map(
|
@@ -66357,7 +66510,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66357
66510
|
},
|
66358
66511
|
server,
|
66359
66512
|
build: resolvedBuildOptions,
|
66360
|
-
preview
|
66513
|
+
preview,
|
66361
66514
|
envDir,
|
66362
66515
|
env: {
|
66363
66516
|
...userEnv,
|
@@ -66387,6 +66540,13 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
66387
66540
|
hmrPartialAccept: false,
|
66388
66541
|
...config.experimental
|
66389
66542
|
},
|
66543
|
+
// random 72 bits (12 base64 chars)
|
66544
|
+
// at least 64bits is recommended
|
66545
|
+
// https://owasp.org/www-community/vulnerabilities/Insufficient_Session-ID_Length
|
66546
|
+
webSocketToken: Buffer.from(
|
66547
|
+
crypto$2.getRandomValues(new Uint8Array(9))
|
66548
|
+
).toString("base64url"),
|
66549
|
+
additionalAllowedHosts: getAdditionalAllowedHosts(server, preview),
|
66390
66550
|
getSortedPlugins: void 0,
|
66391
66551
|
getSortedPluginHooks: void 0
|
66392
66552
|
};
|
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-CjorC8P2.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-CjorC8P2.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-CjorC8P2.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-CjorC8P2.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-CjorC8P2.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-CjorC8P2.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-CjorC8P2.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
|
|