vite 4.5.7 → 4.5.9
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-9c3982ed.js → dep-3936e161.js} +40 -24
- package/dist/node/chunks/{dep-f6eb8138.js → dep-4e2b6ecb.js} +1 -1
- package/dist/node/chunks/{dep-ba729824.js → dep-8defca0d.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +6 -1
- package/dist/node/index.js +2 -2
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ import require$$2$1 from 'child_process';
|
|
|
23
23
|
import os$4 from 'node:os';
|
|
24
24
|
import { exec } from 'node:child_process';
|
|
25
25
|
import { promises } from 'node:dns';
|
|
26
|
-
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, SPECIAL_QUERY_RE, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
|
26
|
+
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, SPECIAL_QUERY_RE, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, VITE_PACKAGE_DIR, defaultAllowedOrigins, DEFAULT_DEV_PORT, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
|
27
27
|
import require$$3$1 from 'crypto';
|
|
28
28
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
29
29
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
|
@@ -38995,8 +38995,8 @@ function createCachedImport(imp) {
|
|
|
38995
38995
|
return cached;
|
|
38996
38996
|
};
|
|
38997
38997
|
}
|
|
38998
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38999
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
38998
|
+
const importPostcssImport = createCachedImport(() => import('./dep-8defca0d.js').then(function (n) { return n.i; }));
|
|
38999
|
+
const importPostcssModules = createCachedImport(() => import('./dep-4e2b6ecb.js').then(function (n) { return n.i; }));
|
|
39000
39000
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
39001
39001
|
/**
|
|
39002
39002
|
* @experimental
|
|
@@ -61749,7 +61749,8 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
|
61749
61749
|
|
|
61750
61750
|
var WebSocketServerRaw_ = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
|
61751
61751
|
|
|
61752
|
-
const
|
|
61752
|
+
const allowedHostsServerCache = new WeakMap();
|
|
61753
|
+
const allowedHostsPreviewCache = new WeakMap();
|
|
61753
61754
|
const isFileOrExtensionProtocolRE = /^(?:file|.+-extension):/i;
|
|
61754
61755
|
function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions) {
|
|
61755
61756
|
const list = [];
|
|
@@ -61770,8 +61771,13 @@ function getAdditionalAllowedHosts(resolvedServerOptions, resolvedPreviewOptions
|
|
|
61770
61771
|
// allow server origin by default as that indicates that the user is
|
|
61771
61772
|
// expecting Vite to respond on that host
|
|
61772
61773
|
if (resolvedServerOptions.origin) {
|
|
61773
|
-
|
|
61774
|
-
|
|
61774
|
+
// some frameworks may pass the origin as a placeholder, so it's not
|
|
61775
|
+
// possible to parse as URL, so use a try-catch here as a best effort
|
|
61776
|
+
try {
|
|
61777
|
+
const serverOriginUrl = new URL(resolvedServerOptions.origin);
|
|
61778
|
+
list.push(serverOriginUrl.hostname);
|
|
61779
|
+
}
|
|
61780
|
+
catch { }
|
|
61775
61781
|
}
|
|
61776
61782
|
return list;
|
|
61777
61783
|
}
|
|
@@ -61828,37 +61834,43 @@ function isHostAllowedWithoutCache(allowedHosts, additionalAllowedHosts, host) {
|
|
|
61828
61834
|
}
|
|
61829
61835
|
/**
|
|
61830
61836
|
* @param config resolved config
|
|
61837
|
+
* @param isPreview whether it's for the preview server or not
|
|
61831
61838
|
* @param host the value of host header. See [RFC 9110 7.2](https://datatracker.ietf.org/doc/html/rfc9110#name-host-and-authority).
|
|
61832
61839
|
*/
|
|
61833
|
-
function isHostAllowed(config, host) {
|
|
61834
|
-
|
|
61840
|
+
function isHostAllowed(config, isPreview, host) {
|
|
61841
|
+
const allowedHosts = isPreview
|
|
61842
|
+
? config.preview.allowedHosts
|
|
61843
|
+
: config.server.allowedHosts;
|
|
61844
|
+
if (allowedHosts === true) {
|
|
61835
61845
|
return true;
|
|
61836
61846
|
}
|
|
61837
|
-
|
|
61838
|
-
|
|
61847
|
+
const cache = isPreview ? allowedHostsPreviewCache : allowedHostsServerCache;
|
|
61848
|
+
if (!cache.has(config)) {
|
|
61849
|
+
cache.set(config, new Set());
|
|
61839
61850
|
}
|
|
61840
|
-
const
|
|
61841
|
-
if (
|
|
61851
|
+
const cachedAllowedHosts = cache.get(config);
|
|
61852
|
+
if (cachedAllowedHosts.has(host)) {
|
|
61842
61853
|
return true;
|
|
61843
61854
|
}
|
|
61844
|
-
const result = isHostAllowedWithoutCache(
|
|
61855
|
+
const result = isHostAllowedWithoutCache(allowedHosts ?? [], config.additionalAllowedHosts, host);
|
|
61845
61856
|
if (result) {
|
|
61846
|
-
|
|
61857
|
+
cachedAllowedHosts.add(host);
|
|
61847
61858
|
}
|
|
61848
61859
|
return result;
|
|
61849
61860
|
}
|
|
61850
|
-
function hostCheckMiddleware(config) {
|
|
61861
|
+
function hostCheckMiddleware(config, isPreview) {
|
|
61851
61862
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
61852
61863
|
return function viteHostCheckMiddleware(req, res, next) {
|
|
61853
61864
|
const hostHeader = req.headers.host;
|
|
61854
|
-
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
|
61865
|
+
if (!hostHeader || !isHostAllowed(config, isPreview, hostHeader)) {
|
|
61855
61866
|
const hostname = hostHeader?.replace(/:\d+$/, '');
|
|
61856
61867
|
const hostnameWithQuotes = JSON.stringify(hostname);
|
|
61868
|
+
const optionName = `${isPreview ? 'preview' : 'server'}.allowedHosts`;
|
|
61857
61869
|
res.writeHead(403, {
|
|
61858
61870
|
'Content-Type': 'text/plain',
|
|
61859
61871
|
});
|
|
61860
61872
|
res.end(`Blocked request. This host (${hostnameWithQuotes}) is not allowed.\n` +
|
|
61861
|
-
`To allow this host, add ${hostnameWithQuotes} to \`
|
|
61873
|
+
`To allow this host, add ${hostnameWithQuotes} to \`${optionName}\` in vite.config.js.`);
|
|
61862
61874
|
return;
|
|
61863
61875
|
}
|
|
61864
61876
|
return next();
|
|
@@ -61915,7 +61927,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
61915
61927
|
const host = (hmr && hmr.host) || undefined;
|
|
61916
61928
|
const shouldHandle = (req) => {
|
|
61917
61929
|
const hostHeader = req.headers.host;
|
|
61918
|
-
if (!hostHeader || !isHostAllowed(config, hostHeader)) {
|
|
61930
|
+
if (!hostHeader || !isHostAllowed(config, false, hostHeader)) {
|
|
61919
61931
|
return false;
|
|
61920
61932
|
}
|
|
61921
61933
|
if (config.legacy?.skipWebSocketTokenCheck) {
|
|
@@ -65436,14 +65448,16 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
65436
65448
|
}
|
|
65437
65449
|
// cors
|
|
65438
65450
|
const { cors } = serverConfig;
|
|
65439
|
-
if (cors !==
|
|
65440
|
-
middlewares.use(corsMiddleware(typeof cors === 'boolean'
|
|
65451
|
+
if (cors !== false) {
|
|
65452
|
+
middlewares.use(corsMiddleware(typeof cors === 'boolean'
|
|
65453
|
+
? {}
|
|
65454
|
+
: cors ?? { origin: defaultAllowedOrigins }));
|
|
65441
65455
|
}
|
|
65442
65456
|
// host check (to prevent DNS rebinding attacks)
|
|
65443
65457
|
const { allowedHosts } = serverConfig;
|
|
65444
65458
|
// no need to check for HTTPS as HTTPS is not vulnerable to DNS rebinding attacks
|
|
65445
65459
|
if (allowedHosts !== true && !serverConfig.https) {
|
|
65446
|
-
middlewares.use(hostCheckMiddleware(config));
|
|
65460
|
+
middlewares.use(hostCheckMiddleware(config, false));
|
|
65447
65461
|
}
|
|
65448
65462
|
// proxy
|
|
65449
65463
|
const { proxy } = serverConfig;
|
|
@@ -65863,14 +65877,16 @@ async function preview(inlineConfig = {}) {
|
|
|
65863
65877
|
}
|
|
65864
65878
|
// cors
|
|
65865
65879
|
const { cors } = config.preview;
|
|
65866
|
-
if (cors !==
|
|
65867
|
-
app.use(corsMiddleware(typeof cors === 'boolean'
|
|
65880
|
+
if (cors !== false) {
|
|
65881
|
+
app.use(corsMiddleware(typeof cors === 'boolean'
|
|
65882
|
+
? {}
|
|
65883
|
+
: cors ?? { origin: defaultAllowedOrigins }));
|
|
65868
65884
|
}
|
|
65869
65885
|
// host check (to prevent DNS rebinding attacks)
|
|
65870
65886
|
const { allowedHosts } = config.preview;
|
|
65871
65887
|
// no need to check for HTTPS as HTTPS is not vulnerable to DNS rebinding attacks
|
|
65872
65888
|
if (allowedHosts !== true && !config.preview.https) {
|
|
65873
|
-
app.use(hostCheckMiddleware(config));
|
|
65889
|
+
app.use(hostCheckMiddleware(config, true));
|
|
65874
65890
|
}
|
|
65875
65891
|
// proxy
|
|
65876
65892
|
const { proxy } = config.preview;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-
|
|
1
|
+
import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-3936e161.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 from 'node:fs';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-3936e161.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -759,7 +759,7 @@ cli
|
|
|
759
759
|
filterDuplicateOptions(options);
|
|
760
760
|
// output structure is preserved even after bundling so require()
|
|
761
761
|
// is ok here
|
|
762
|
-
const { createServer } = await import('./chunks/dep-
|
|
762
|
+
const { createServer } = await import('./chunks/dep-3936e161.js').then(function (n) { return n.I; });
|
|
763
763
|
try {
|
|
764
764
|
const server = await createServer({
|
|
765
765
|
root,
|
|
@@ -837,7 +837,7 @@ cli
|
|
|
837
837
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
838
838
|
.action(async (root, options) => {
|
|
839
839
|
filterDuplicateOptions(options);
|
|
840
|
-
const { build } = await import('./chunks/dep-
|
|
840
|
+
const { build } = await import('./chunks/dep-3936e161.js').then(function (n) { return n.H; });
|
|
841
841
|
const buildOptions = cleanOptions(options);
|
|
842
842
|
try {
|
|
843
843
|
await build({
|
|
@@ -865,7 +865,7 @@ cli
|
|
|
865
865
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
866
866
|
.action(async (root, options) => {
|
|
867
867
|
filterDuplicateOptions(options);
|
|
868
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
868
|
+
const { optimizeDeps } = await import('./chunks/dep-3936e161.js').then(function (n) { return n.G; });
|
|
869
869
|
try {
|
|
870
870
|
const config = await resolveConfig({
|
|
871
871
|
root,
|
|
@@ -892,7 +892,7 @@ cli
|
|
|
892
892
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
893
893
|
.action(async (root, options) => {
|
|
894
894
|
filterDuplicateOptions(options);
|
|
895
|
-
const { preview } = await import('./chunks/dep-
|
|
895
|
+
const { preview } = await import('./chunks/dep-3936e161.js').then(function (n) { return n.J; });
|
|
896
896
|
try {
|
|
897
897
|
const server = await preview({
|
|
898
898
|
root,
|
package/dist/node/constants.js
CHANGED
|
@@ -121,5 +121,10 @@ const wildcardHosts = new Set([
|
|
|
121
121
|
]);
|
|
122
122
|
const DEFAULT_DEV_PORT = 5173;
|
|
123
123
|
const DEFAULT_PREVIEW_PORT = 4173;
|
|
124
|
+
// the regex to allow loopback address origins:
|
|
125
|
+
// - localhost domains (which will always resolve to the loopback address by RFC 6761 section 6.3)
|
|
126
|
+
// - 127.0.0.1
|
|
127
|
+
// - ::1
|
|
128
|
+
const defaultAllowedOrigins = /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
|
|
124
129
|
|
|
125
|
-
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, 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, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
|
130
|
+
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, 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, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, defaultAllowedOrigins, loopbackHosts, wildcardHosts };
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as isInNodeModules } from './chunks/dep-
|
|
2
|
-
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
import { i as isInNodeModules } from './chunks/dep-3936e161.js';
|
|
2
|
+
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-3936e161.js';
|
|
3
3
|
export { VERSION as version } from './constants.js';
|
|
4
4
|
export { version as esbuildVersion } from 'esbuild';
|
|
5
5
|
export { VERSION as rollupVersion } from 'rollup';
|