vite 6.3.0-beta.1 → 6.3.0

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -8,14 +8,15 @@ import { performance as performance$1 } from 'node:perf_hooks';
8
8
  import require$$0$6, { createRequire as createRequire$1, builtinModules } from 'node:module';
9
9
  import crypto$2 from 'node:crypto';
10
10
  import picomatch$2 from 'picomatch';
11
- import esbuild, { transform as transform$1, formatMessages, build as build$b } from 'esbuild';
11
+ import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
12
12
  import { CLIENT_ENTRY, wildcardHosts, loopbackHosts, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, JS_TYPES_RE, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ENV_ENTRY, DEP_VERSION_RE, DEV_PROD_CONDITION, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, defaultAllowedOrigins, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_CLIENT_CONDITIONS, DEFAULT_SERVER_CONDITIONS, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_SERVER_MAIN_FIELDS } from '../constants.js';
13
13
  import require$$0$2, { posix, isAbsolute, resolve as resolve$3, win32, relative as relative$1, join, dirname as dirname$1, extname, basename as basename$1, sep } from 'path';
14
- import require$$0$3, { statSync, existsSync, readFileSync, readdirSync } from 'fs';
14
+ import require$$0$4, { statSync, existsSync, readFileSync, readdirSync } from 'fs';
15
+ import { fdir } from 'fdir';
15
16
  import childProcess$2, { exec, execFile, execSync } from 'node:child_process';
16
17
  import { createServer as createServer$3, STATUS_CODES, get as get$2 } from 'node:http';
17
18
  import { createServer as createServer$2, get as get$1 } from 'node:https';
18
- import require$$0$4 from 'tty';
19
+ import require$$0$3 from 'tty';
19
20
  import require$$1 from 'util';
20
21
  import require$$4$1 from 'net';
21
22
  import require$$0$7 from 'events';
@@ -532,23 +533,23 @@ function ensureArray(thing) {
532
533
  }
533
534
 
534
535
  const normalizePathRegExp = new RegExp(`\\${win32.sep}`, 'g');
535
- const normalizePath$6 = function normalizePath(filename) {
536
+ const normalizePath$5 = function normalizePath(filename) {
536
537
  return filename.replace(normalizePathRegExp, posix.sep);
537
538
  };
538
539
 
539
540
  function getMatcherString$1(id, resolutionBase) {
540
541
  if (resolutionBase === false || isAbsolute(id) || id.startsWith('**')) {
541
- return normalizePath$6(id);
542
+ return normalizePath$5(id);
542
543
  }
543
544
  // resolve('') is valid and will default to process.cwd()
544
- const basePath = normalizePath$6(resolve$3(resolutionBase || ''))
545
+ const basePath = normalizePath$5(resolve$3(resolutionBase || ''))
545
546
  // escape all possible (posix + win) path characters that might interfere with regex
546
547
  .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
547
548
  // Note that we use posix.join because:
548
549
  // 1. the basePath has been normalized to use /
549
550
  // 2. the incoming glob (id) matcher, also uses /
550
551
  // otherwise Node will force backslash (\) on windows
551
- return posix.join(basePath, normalizePath$6(id));
552
+ return posix.join(basePath, normalizePath$5(id));
552
553
  }
553
554
  const createFilter$2 = function createFilter(include, exclude, options) {
554
555
  const resolutionBase = options && options.resolve;
@@ -572,7 +573,7 @@ const createFilter$2 = function createFilter(include, exclude, options) {
572
573
  return false;
573
574
  if (id.includes('\0'))
574
575
  return false;
575
- const pathId = normalizePath$6(id);
576
+ const pathId = normalizePath$5(id);
576
577
  for (let i = 0; i < excludeMatchers.length; ++i) {
577
578
  const matcher = excludeMatchers[i];
578
579
  if (matcher instanceof RegExp) {
@@ -752,753 +753,6 @@ var commondir = function (basedir, relfiles) {
752
753
 
753
754
  var getCommonDir = /*@__PURE__*/getDefaultExportFromCjs(commondir);
754
755
 
755
- var dist = {};
756
-
757
- var builder = {};
758
-
759
- var apiBuilder = {};
760
-
761
- var async = {};
762
-
763
- var walker = {};
764
-
765
- var utils$4 = {};
766
-
767
- Object.defineProperty(utils$4, "__esModule", { value: true });
768
- utils$4.normalizePath = utils$4.convertSlashes = utils$4.cleanPath = void 0;
769
- const path_1$4 = require$$0$2;
770
- function cleanPath(path) {
771
- let normalized = (0, path_1$4.normalize)(path);
772
- // we have to remove the last path separator
773
- // to account for / root path
774
- if (normalized.length > 1 && normalized[normalized.length - 1] === path_1$4.sep)
775
- normalized = normalized.substring(0, normalized.length - 1);
776
- return normalized;
777
- }
778
- utils$4.cleanPath = cleanPath;
779
- const SLASHES_REGEX = /[\\/]/g;
780
- function convertSlashes(path, separator) {
781
- return path.replace(SLASHES_REGEX, separator);
782
- }
783
- utils$4.convertSlashes = convertSlashes;
784
- function normalizePath$5(path, options) {
785
- const { resolvePaths, normalizePath, pathSeparator } = options;
786
- const pathNeedsCleaning = (process.platform === "win32" && path.includes("/")) ||
787
- path.startsWith(".");
788
- if (resolvePaths)
789
- path = (0, path_1$4.resolve)(path);
790
- if (normalizePath || pathNeedsCleaning)
791
- path = cleanPath(path);
792
- if (path === ".")
793
- return "";
794
- const needsSeperator = path[path.length - 1] !== pathSeparator;
795
- return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
796
- }
797
- utils$4.normalizePath = normalizePath$5;
798
-
799
- var joinPath$2 = {};
800
-
801
- Object.defineProperty(joinPath$2, "__esModule", { value: true });
802
- joinPath$2.build = joinPath$2.joinDirectoryPath = joinPath$2.joinPathWithBasePath = void 0;
803
- const path_1$3 = require$$0$2;
804
- const utils_1$1 = utils$4;
805
- function joinPathWithBasePath(filename, directoryPath) {
806
- return directoryPath + filename;
807
- }
808
- joinPath$2.joinPathWithBasePath = joinPathWithBasePath;
809
- function joinPathWithRelativePath(root, options) {
810
- return function (filename, directoryPath) {
811
- const sameRoot = directoryPath.startsWith(root);
812
- if (sameRoot)
813
- return directoryPath.replace(root, "") + filename;
814
- else
815
- return ((0, utils_1$1.convertSlashes)((0, path_1$3.relative)(root, directoryPath), options.pathSeparator) +
816
- options.pathSeparator +
817
- filename);
818
- };
819
- }
820
- function joinPath$1(filename) {
821
- return filename;
822
- }
823
- function joinDirectoryPath(filename, directoryPath, separator) {
824
- return directoryPath + filename + separator;
825
- }
826
- joinPath$2.joinDirectoryPath = joinDirectoryPath;
827
- function build$a(root, options) {
828
- const { relativePaths, includeBasePath } = options;
829
- return relativePaths && root
830
- ? joinPathWithRelativePath(root, options)
831
- : includeBasePath
832
- ? joinPathWithBasePath
833
- : joinPath$1;
834
- }
835
- joinPath$2.build = build$a;
836
-
837
- var pushDirectory$2 = {};
838
-
839
- Object.defineProperty(pushDirectory$2, "__esModule", { value: true });
840
- pushDirectory$2.build = void 0;
841
- function pushDirectoryWithRelativePath(root) {
842
- return function (directoryPath, paths) {
843
- paths.push(directoryPath.substring(root.length) || ".");
844
- };
845
- }
846
- function pushDirectoryFilterWithRelativePath(root) {
847
- return function (directoryPath, paths, filters) {
848
- const relativePath = directoryPath.substring(root.length) || ".";
849
- if (filters.every((filter) => filter(relativePath, true))) {
850
- paths.push(relativePath);
851
- }
852
- };
853
- }
854
- const pushDirectory$1 = (directoryPath, paths) => {
855
- paths.push(directoryPath || ".");
856
- };
857
- const pushDirectoryFilter = (directoryPath, paths, filters) => {
858
- const path = directoryPath || ".";
859
- if (filters.every((filter) => filter(path, true))) {
860
- paths.push(path);
861
- }
862
- };
863
- const empty$2 = () => { };
864
- function build$9(root, options) {
865
- const { includeDirs, filters, relativePaths } = options;
866
- if (!includeDirs)
867
- return empty$2;
868
- if (relativePaths)
869
- return filters && filters.length
870
- ? pushDirectoryFilterWithRelativePath(root)
871
- : pushDirectoryWithRelativePath(root);
872
- return filters && filters.length ? pushDirectoryFilter : pushDirectory$1;
873
- }
874
- pushDirectory$2.build = build$9;
875
-
876
- var pushFile$2 = {};
877
-
878
- Object.defineProperty(pushFile$2, "__esModule", { value: true });
879
- pushFile$2.build = void 0;
880
- const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
881
- if (filters.every((filter) => filter(filename, false)))
882
- counts.files++;
883
- };
884
- const pushFileFilter = (filename, paths, _counts, filters) => {
885
- if (filters.every((filter) => filter(filename, false)))
886
- paths.push(filename);
887
- };
888
- const pushFileCount = (_filename, _paths, counts, _filters) => {
889
- counts.files++;
890
- };
891
- const pushFile$1 = (filename, paths) => {
892
- paths.push(filename);
893
- };
894
- const empty$1 = () => { };
895
- function build$8(options) {
896
- const { excludeFiles, filters, onlyCounts } = options;
897
- if (excludeFiles)
898
- return empty$1;
899
- if (filters && filters.length) {
900
- return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
901
- }
902
- else if (onlyCounts) {
903
- return pushFileCount;
904
- }
905
- else {
906
- return pushFile$1;
907
- }
908
- }
909
- pushFile$2.build = build$8;
910
-
911
- var getArray$2 = {};
912
-
913
- Object.defineProperty(getArray$2, "__esModule", { value: true });
914
- getArray$2.build = void 0;
915
- const getArray$1 = (paths) => {
916
- return paths;
917
- };
918
- const getArrayGroup = () => {
919
- return [""].slice(0, 0);
920
- };
921
- function build$7(options) {
922
- return options.group ? getArrayGroup : getArray$1;
923
- }
924
- getArray$2.build = build$7;
925
-
926
- var groupFiles$2 = {};
927
-
928
- Object.defineProperty(groupFiles$2, "__esModule", { value: true });
929
- groupFiles$2.build = void 0;
930
- const groupFiles$1 = (groups, directory, files) => {
931
- groups.push({ directory, files, dir: directory });
932
- };
933
- const empty = () => { };
934
- function build$6(options) {
935
- return options.group ? groupFiles$1 : empty;
936
- }
937
- groupFiles$2.build = build$6;
938
-
939
- var resolveSymlink$1 = {};
940
-
941
- var __importDefault$1 = (resolveSymlink$1 && resolveSymlink$1.__importDefault) || function (mod) {
942
- return (mod && mod.__esModule) ? mod : { "default": mod };
943
- };
944
- Object.defineProperty(resolveSymlink$1, "__esModule", { value: true });
945
- resolveSymlink$1.build = void 0;
946
- const fs_1$1 = __importDefault$1(require$$0$3);
947
- const path_1$2 = require$$0$2;
948
- const resolveSymlinksAsync = function (path, state, callback) {
949
- const { queue, options: { suppressErrors }, } = state;
950
- queue.enqueue();
951
- fs_1$1.default.realpath(path, (error, resolvedPath) => {
952
- if (error)
953
- return queue.dequeue(suppressErrors ? null : error, state);
954
- fs_1$1.default.stat(resolvedPath, (error, stat) => {
955
- if (error)
956
- return queue.dequeue(suppressErrors ? null : error, state);
957
- if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
958
- return queue.dequeue(null, state);
959
- callback(stat, resolvedPath);
960
- queue.dequeue(null, state);
961
- });
962
- });
963
- };
964
- const resolveSymlinks = function (path, state, callback) {
965
- const { queue, options: { suppressErrors }, } = state;
966
- queue.enqueue();
967
- try {
968
- const resolvedPath = fs_1$1.default.realpathSync(path);
969
- const stat = fs_1$1.default.statSync(resolvedPath);
970
- if (stat.isDirectory() && isRecursive(path, resolvedPath, state))
971
- return;
972
- callback(stat, resolvedPath);
973
- }
974
- catch (e) {
975
- if (!suppressErrors)
976
- throw e;
977
- }
978
- };
979
- function build$5(options, isSynchronous) {
980
- if (!options.resolveSymlinks || options.excludeSymlinks)
981
- return null;
982
- return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
983
- }
984
- resolveSymlink$1.build = build$5;
985
- function isRecursive(path, resolved, state) {
986
- if (state.options.useRealPaths)
987
- return isRecursiveUsingRealPaths(resolved, state);
988
- let parent = (0, path_1$2.dirname)(path);
989
- let depth = 1;
990
- while (parent !== state.root && depth < 2) {
991
- const resolvedPath = state.symlinks.get(parent);
992
- const isSameRoot = !!resolvedPath &&
993
- (resolvedPath === resolved ||
994
- resolvedPath.startsWith(resolved) ||
995
- resolved.startsWith(resolvedPath));
996
- if (isSameRoot)
997
- depth++;
998
- else
999
- parent = (0, path_1$2.dirname)(parent);
1000
- }
1001
- state.symlinks.set(path, resolved);
1002
- return depth > 1;
1003
- }
1004
- function isRecursiveUsingRealPaths(resolved, state) {
1005
- return state.visited.includes(resolved + state.options.pathSeparator);
1006
- }
1007
-
1008
- var invokeCallback$1 = {};
1009
-
1010
- Object.defineProperty(invokeCallback$1, "__esModule", { value: true });
1011
- invokeCallback$1.build = void 0;
1012
- const onlyCountsSync = (state) => {
1013
- return state.counts;
1014
- };
1015
- const groupsSync = (state) => {
1016
- return state.groups;
1017
- };
1018
- const defaultSync = (state) => {
1019
- return state.paths;
1020
- };
1021
- const limitFilesSync = (state) => {
1022
- return state.paths.slice(0, state.options.maxFiles);
1023
- };
1024
- const onlyCountsAsync = (state, error, callback) => {
1025
- report(error, callback, state.counts, state.options.suppressErrors);
1026
- return null;
1027
- };
1028
- const defaultAsync = (state, error, callback) => {
1029
- report(error, callback, state.paths, state.options.suppressErrors);
1030
- return null;
1031
- };
1032
- const limitFilesAsync = (state, error, callback) => {
1033
- report(error, callback, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
1034
- return null;
1035
- };
1036
- const groupsAsync = (state, error, callback) => {
1037
- report(error, callback, state.groups, state.options.suppressErrors);
1038
- return null;
1039
- };
1040
- function report(error, callback, output, suppressErrors) {
1041
- if (error && !suppressErrors)
1042
- callback(error, output);
1043
- else
1044
- callback(null, output);
1045
- }
1046
- function build$4(options, isSynchronous) {
1047
- const { onlyCounts, group, maxFiles } = options;
1048
- if (onlyCounts)
1049
- return isSynchronous
1050
- ? onlyCountsSync
1051
- : onlyCountsAsync;
1052
- else if (group)
1053
- return isSynchronous
1054
- ? groupsSync
1055
- : groupsAsync;
1056
- else if (maxFiles)
1057
- return isSynchronous
1058
- ? limitFilesSync
1059
- : limitFilesAsync;
1060
- else
1061
- return isSynchronous
1062
- ? defaultSync
1063
- : defaultAsync;
1064
- }
1065
- invokeCallback$1.build = build$4;
1066
-
1067
- var walkDirectory$1 = {};
1068
-
1069
- var __importDefault = (walkDirectory$1 && walkDirectory$1.__importDefault) || function (mod) {
1070
- return (mod && mod.__esModule) ? mod : { "default": mod };
1071
- };
1072
- Object.defineProperty(walkDirectory$1, "__esModule", { value: true });
1073
- walkDirectory$1.build = void 0;
1074
- const fs_1 = __importDefault(require$$0$3);
1075
- const readdirOpts = { withFileTypes: true };
1076
- const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback) => {
1077
- if (currentDepth < 0)
1078
- return state.queue.dequeue(null, state);
1079
- state.visited.push(crawlPath);
1080
- state.counts.directories++;
1081
- state.queue.enqueue();
1082
- // Perf: Node >= 10 introduced withFileTypes that helps us
1083
- // skip an extra fs.stat call.
1084
- fs_1.default.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
1085
- callback(entries, directoryPath, currentDepth);
1086
- state.queue.dequeue(state.options.suppressErrors ? null : error, state);
1087
- });
1088
- };
1089
- const walkSync = (state, crawlPath, directoryPath, currentDepth, callback) => {
1090
- if (currentDepth < 0)
1091
- return;
1092
- state.visited.push(crawlPath);
1093
- state.counts.directories++;
1094
- let entries = [];
1095
- try {
1096
- entries = fs_1.default.readdirSync(crawlPath || ".", readdirOpts);
1097
- }
1098
- catch (e) {
1099
- if (!state.options.suppressErrors)
1100
- throw e;
1101
- }
1102
- callback(entries, directoryPath, currentDepth);
1103
- };
1104
- function build$3(isSynchronous) {
1105
- return isSynchronous ? walkSync : walkAsync;
1106
- }
1107
- walkDirectory$1.build = build$3;
1108
-
1109
- var queue = {};
1110
-
1111
- Object.defineProperty(queue, "__esModule", { value: true });
1112
- queue.Queue = void 0;
1113
- /**
1114
- * This is a custom stateless queue to track concurrent async fs calls.
1115
- * It increments a counter whenever a call is queued and decrements it
1116
- * as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
1117
- */
1118
- class Queue {
1119
- onQueueEmpty;
1120
- count = 0;
1121
- constructor(onQueueEmpty) {
1122
- this.onQueueEmpty = onQueueEmpty;
1123
- }
1124
- enqueue() {
1125
- this.count++;
1126
- }
1127
- dequeue(error, output) {
1128
- if (--this.count <= 0 || error)
1129
- this.onQueueEmpty(error, output);
1130
- }
1131
- }
1132
- queue.Queue = Queue;
1133
-
1134
- var counter = {};
1135
-
1136
- Object.defineProperty(counter, "__esModule", { value: true });
1137
- counter.Counter = void 0;
1138
- class Counter {
1139
- _files = 0;
1140
- _directories = 0;
1141
- set files(num) {
1142
- this._files = num;
1143
- }
1144
- get files() {
1145
- return this._files;
1146
- }
1147
- set directories(num) {
1148
- this._directories = num;
1149
- }
1150
- get directories() {
1151
- return this._directories;
1152
- }
1153
- /**
1154
- * @deprecated use `directories` instead
1155
- */
1156
- /* c8 ignore next 3 */
1157
- get dirs() {
1158
- return this._directories;
1159
- }
1160
- }
1161
- counter.Counter = Counter;
1162
-
1163
- var __createBinding = (walker && walker.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1164
- if (k2 === undefined) k2 = k;
1165
- var desc = Object.getOwnPropertyDescriptor(m, k);
1166
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1167
- desc = { enumerable: true, get: function() { return m[k]; } };
1168
- }
1169
- Object.defineProperty(o, k2, desc);
1170
- }) : (function(o, m, k, k2) {
1171
- if (k2 === undefined) k2 = k;
1172
- o[k2] = m[k];
1173
- }));
1174
- var __setModuleDefault = (walker && walker.__setModuleDefault) || (Object.create ? (function(o, v) {
1175
- Object.defineProperty(o, "default", { enumerable: true, value: v });
1176
- }) : function(o, v) {
1177
- o["default"] = v;
1178
- });
1179
- var __importStar = (walker && walker.__importStar) || function (mod) {
1180
- if (mod && mod.__esModule) return mod;
1181
- var result = {};
1182
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
1183
- __setModuleDefault(result, mod);
1184
- return result;
1185
- };
1186
- Object.defineProperty(walker, "__esModule", { value: true });
1187
- walker.Walker = void 0;
1188
- const path_1$1 = require$$0$2;
1189
- const utils_1 = utils$4;
1190
- const joinPath = __importStar(joinPath$2);
1191
- const pushDirectory = __importStar(pushDirectory$2);
1192
- const pushFile = __importStar(pushFile$2);
1193
- const getArray = __importStar(getArray$2);
1194
- const groupFiles = __importStar(groupFiles$2);
1195
- const resolveSymlink = __importStar(resolveSymlink$1);
1196
- const invokeCallback = __importStar(invokeCallback$1);
1197
- const walkDirectory = __importStar(walkDirectory$1);
1198
- const queue_1 = queue;
1199
- const counter_1 = counter;
1200
- class Walker {
1201
- root;
1202
- isSynchronous;
1203
- state;
1204
- joinPath;
1205
- pushDirectory;
1206
- pushFile;
1207
- getArray;
1208
- groupFiles;
1209
- resolveSymlink;
1210
- walkDirectory;
1211
- callbackInvoker;
1212
- constructor(root, options, callback) {
1213
- this.isSynchronous = !callback;
1214
- this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
1215
- this.root = (0, utils_1.normalizePath)(root, options);
1216
- this.state = {
1217
- root: this.root.slice(0, -1),
1218
- // Perf: we explicitly tell the compiler to optimize for String arrays
1219
- paths: [""].slice(0, 0),
1220
- groups: [],
1221
- counts: new counter_1.Counter(),
1222
- options,
1223
- queue: new queue_1.Queue((error, state) => this.callbackInvoker(state, error, callback)),
1224
- symlinks: new Map(),
1225
- visited: [""].slice(0, 0),
1226
- };
1227
- /*
1228
- * Perf: We conditionally change functions according to options. This gives a slight
1229
- * performance boost. Since these functions are so small, they are automatically inlined
1230
- * by the javascript engine so there's no function call overhead (in most cases).
1231
- */
1232
- this.joinPath = joinPath.build(this.root, options);
1233
- this.pushDirectory = pushDirectory.build(this.root, options);
1234
- this.pushFile = pushFile.build(options);
1235
- this.getArray = getArray.build(options);
1236
- this.groupFiles = groupFiles.build(options);
1237
- this.resolveSymlink = resolveSymlink.build(options, this.isSynchronous);
1238
- this.walkDirectory = walkDirectory.build(this.isSynchronous);
1239
- }
1240
- start() {
1241
- this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
1242
- return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
1243
- }
1244
- walk = (entries, directoryPath, depth) => {
1245
- const { paths, options: { filters, resolveSymlinks, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator, }, } = this.state;
1246
- if ((signal && signal.aborted) || (maxFiles && paths.length > maxFiles))
1247
- return;
1248
- this.pushDirectory(directoryPath, paths, filters);
1249
- const files = this.getArray(this.state.paths);
1250
- for (let i = 0; i < entries.length; ++i) {
1251
- const entry = entries[i];
1252
- if (entry.isFile() ||
1253
- (entry.isSymbolicLink() && !resolveSymlinks && !excludeSymlinks)) {
1254
- const filename = this.joinPath(entry.name, directoryPath);
1255
- this.pushFile(filename, files, this.state.counts, filters);
1256
- }
1257
- else if (entry.isDirectory()) {
1258
- let path = joinPath.joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
1259
- if (exclude && exclude(entry.name, path))
1260
- continue;
1261
- this.walkDirectory(this.state, path, path, depth - 1, this.walk);
1262
- }
1263
- else if (entry.isSymbolicLink() && this.resolveSymlink) {
1264
- let path = joinPath.joinPathWithBasePath(entry.name, directoryPath);
1265
- this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
1266
- if (stat.isDirectory()) {
1267
- resolvedPath = (0, utils_1.normalizePath)(resolvedPath, this.state.options);
1268
- if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator))
1269
- return;
1270
- this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
1271
- }
1272
- else {
1273
- resolvedPath = useRealPaths ? resolvedPath : path;
1274
- const filename = (0, path_1$1.basename)(resolvedPath);
1275
- const directoryPath = (0, utils_1.normalizePath)((0, path_1$1.dirname)(resolvedPath), this.state.options);
1276
- resolvedPath = this.joinPath(filename, directoryPath);
1277
- this.pushFile(resolvedPath, files, this.state.counts, filters);
1278
- }
1279
- });
1280
- }
1281
- }
1282
- this.groupFiles(this.state.groups, directoryPath, files);
1283
- };
1284
- }
1285
- walker.Walker = Walker;
1286
-
1287
- Object.defineProperty(async, "__esModule", { value: true });
1288
- async.callback = async.promise = void 0;
1289
- const walker_1$1 = walker;
1290
- function promise(root, options) {
1291
- return new Promise((resolve, reject) => {
1292
- callback(root, options, (err, output) => {
1293
- if (err)
1294
- return reject(err);
1295
- resolve(output);
1296
- });
1297
- });
1298
- }
1299
- async.promise = promise;
1300
- function callback(root, options, callback) {
1301
- let walker = new walker_1$1.Walker(root, options, callback);
1302
- walker.start();
1303
- }
1304
- async.callback = callback;
1305
-
1306
- var sync$2 = {};
1307
-
1308
- Object.defineProperty(sync$2, "__esModule", { value: true });
1309
- sync$2.sync = void 0;
1310
- const walker_1 = walker;
1311
- function sync$1(root, options) {
1312
- const walker = new walker_1.Walker(root, options);
1313
- return walker.start();
1314
- }
1315
- sync$2.sync = sync$1;
1316
-
1317
- Object.defineProperty(apiBuilder, "__esModule", { value: true });
1318
- apiBuilder.APIBuilder = void 0;
1319
- const async_1 = async;
1320
- const sync_1 = sync$2;
1321
- class APIBuilder {
1322
- root;
1323
- options;
1324
- constructor(root, options) {
1325
- this.root = root;
1326
- this.options = options;
1327
- }
1328
- withPromise() {
1329
- return (0, async_1.promise)(this.root, this.options);
1330
- }
1331
- withCallback(cb) {
1332
- (0, async_1.callback)(this.root, this.options, cb);
1333
- }
1334
- sync() {
1335
- return (0, sync_1.sync)(this.root, this.options);
1336
- }
1337
- }
1338
- apiBuilder.APIBuilder = APIBuilder;
1339
-
1340
- Object.defineProperty(builder, "__esModule", { value: true });
1341
- builder.Builder = void 0;
1342
- const path_1 = require$$0$2;
1343
- const api_builder_1 = apiBuilder;
1344
- var pm = null;
1345
- /* c8 ignore next 6 */
1346
- try {
1347
- require.resolve("picomatch");
1348
- pm = require("picomatch");
1349
- }
1350
- catch (_e) {
1351
- // do nothing
1352
- }
1353
- class Builder {
1354
- globCache = {};
1355
- options = {
1356
- maxDepth: Infinity,
1357
- suppressErrors: true,
1358
- pathSeparator: path_1.sep,
1359
- filters: [],
1360
- };
1361
- globFunction;
1362
- constructor(options) {
1363
- this.options = { ...this.options, ...options };
1364
- this.globFunction = this.options.globFunction;
1365
- }
1366
- group() {
1367
- this.options.group = true;
1368
- return this;
1369
- }
1370
- withPathSeparator(separator) {
1371
- this.options.pathSeparator = separator;
1372
- return this;
1373
- }
1374
- withBasePath() {
1375
- this.options.includeBasePath = true;
1376
- return this;
1377
- }
1378
- withRelativePaths() {
1379
- this.options.relativePaths = true;
1380
- return this;
1381
- }
1382
- withDirs() {
1383
- this.options.includeDirs = true;
1384
- return this;
1385
- }
1386
- withMaxDepth(depth) {
1387
- this.options.maxDepth = depth;
1388
- return this;
1389
- }
1390
- withMaxFiles(limit) {
1391
- this.options.maxFiles = limit;
1392
- return this;
1393
- }
1394
- withFullPaths() {
1395
- this.options.resolvePaths = true;
1396
- this.options.includeBasePath = true;
1397
- return this;
1398
- }
1399
- withErrors() {
1400
- this.options.suppressErrors = false;
1401
- return this;
1402
- }
1403
- withSymlinks({ resolvePaths = true } = {}) {
1404
- this.options.resolveSymlinks = true;
1405
- this.options.useRealPaths = resolvePaths;
1406
- return this.withFullPaths();
1407
- }
1408
- withAbortSignal(signal) {
1409
- this.options.signal = signal;
1410
- return this;
1411
- }
1412
- normalize() {
1413
- this.options.normalizePath = true;
1414
- return this;
1415
- }
1416
- filter(predicate) {
1417
- this.options.filters.push(predicate);
1418
- return this;
1419
- }
1420
- onlyDirs() {
1421
- this.options.excludeFiles = true;
1422
- this.options.includeDirs = true;
1423
- return this;
1424
- }
1425
- exclude(predicate) {
1426
- this.options.exclude = predicate;
1427
- return this;
1428
- }
1429
- onlyCounts() {
1430
- this.options.onlyCounts = true;
1431
- return this;
1432
- }
1433
- crawl(root) {
1434
- return new api_builder_1.APIBuilder(root || ".", this.options);
1435
- }
1436
- withGlobFunction(fn) {
1437
- // cast this since we don't have the new type params yet
1438
- this.globFunction = fn;
1439
- return this;
1440
- }
1441
- /**
1442
- * @deprecated Pass options using the constructor instead:
1443
- * ```ts
1444
- * new fdir(options).crawl("/path/to/root");
1445
- * ```
1446
- * This method will be removed in v7.0
1447
- */
1448
- /* c8 ignore next 4 */
1449
- crawlWithOptions(root, options) {
1450
- this.options = { ...this.options, ...options };
1451
- return new api_builder_1.APIBuilder(root || ".", this.options);
1452
- }
1453
- glob(...patterns) {
1454
- if (this.globFunction) {
1455
- return this.globWithOptions(patterns);
1456
- }
1457
- return this.globWithOptions(patterns, ...[{ dot: true }]);
1458
- }
1459
- globWithOptions(patterns, ...options) {
1460
- const globFn = (this.globFunction || pm);
1461
- /* c8 ignore next 5 */
1462
- if (!globFn) {
1463
- throw new Error('Please specify a glob function to use glob matching.');
1464
- }
1465
- var isMatch = this.globCache[patterns.join("\0")];
1466
- if (!isMatch) {
1467
- isMatch = globFn(patterns, ...options);
1468
- this.globCache[patterns.join("\0")] = isMatch;
1469
- }
1470
- this.options.filters.push((path) => isMatch(path));
1471
- return this;
1472
- }
1473
- }
1474
- builder.Builder = Builder;
1475
-
1476
- var types = {};
1477
-
1478
- Object.defineProperty(types, "__esModule", { value: true });
1479
-
1480
- (function (exports) {
1481
- var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
1482
- if (k2 === undefined) k2 = k;
1483
- var desc = Object.getOwnPropertyDescriptor(m, k);
1484
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1485
- desc = { enumerable: true, get: function() { return m[k]; } };
1486
- }
1487
- Object.defineProperty(o, k2, desc);
1488
- }) : (function(o, m, k, k2) {
1489
- if (k2 === undefined) k2 = k;
1490
- o[k2] = m[k];
1491
- }));
1492
- var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
1493
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1494
- };
1495
- Object.defineProperty(exports, "__esModule", { value: true });
1496
- exports.fdir = void 0;
1497
- const builder_1 = builder;
1498
- Object.defineProperty(exports, "fdir", { enumerable: true, get: function () { return builder_1.Builder; } });
1499
- __exportStar(types, exports);
1500
- } (dist));
1501
-
1502
756
  const comma = ','.charCodeAt(0);
1503
757
  const semicolon = ';'.charCodeAt(0);
1504
758
  const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
@@ -3156,7 +2410,7 @@ function getDynamicRequireModules(patterns, dynamicRequireRoot) {
3156
2410
  ? dynamicRequireModules.delete(targetPath)
3157
2411
  : dynamicRequireModules.set(targetPath, resolvedPath);
3158
2412
  // eslint-disable-next-line new-cap
3159
- for (const path of new dist.fdir()
2413
+ for (const path of new fdir()
3160
2414
  .withBasePath()
3161
2415
  .withDirs()
3162
2416
  .glob(isNegated ? pattern.substr(1) : pattern)
@@ -6714,7 +5968,7 @@ function requireCommon () {
6714
5968
  */
6715
5969
 
6716
5970
  (function (module, exports) {
6717
- const tty = require$$0$4;
5971
+ const tty = require$$0$3;
6718
5972
  const util = require$$1;
6719
5973
 
6720
5974
  /**
@@ -8256,6 +7510,15 @@ const teardownSIGTERMListener = (callback) => {
8256
7510
  }
8257
7511
  }
8258
7512
  };
7513
+ function getServerUrlByHost(server, host) {
7514
+ if (typeof host !== "string") {
7515
+ return server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
7516
+ }
7517
+ return [
7518
+ ...server.resolvedUrls?.local ?? [],
7519
+ ...server.resolvedUrls?.network ?? []
7520
+ ].find((url) => url.includes(host));
7521
+ }
8259
7522
 
8260
7523
  const LogLevels = {
8261
7524
  silent: 0,
@@ -11179,10 +10442,27 @@ function assetPlugin(config) {
11179
10442
  }
11180
10443
  },
11181
10444
  generateBundle(_, bundle) {
10445
+ let importedFiles;
11182
10446
  for (const file in bundle) {
11183
10447
  const chunk = bundle[file];
11184
10448
  if (chunk.type === "chunk" && chunk.isEntry && chunk.moduleIds.length === 1 && config.assetsInclude(chunk.moduleIds[0]) && this.getModuleInfo(chunk.moduleIds[0])?.meta["vite:asset"]) {
11185
- delete bundle[file];
10449
+ if (!importedFiles) {
10450
+ importedFiles = /* @__PURE__ */ new Set();
10451
+ for (const file2 in bundle) {
10452
+ const chunk2 = bundle[file2];
10453
+ if (chunk2.type === "chunk") {
10454
+ for (const importedFile of chunk2.imports) {
10455
+ importedFiles.add(importedFile);
10456
+ }
10457
+ for (const importedFile of chunk2.dynamicImports) {
10458
+ importedFiles.add(importedFile);
10459
+ }
10460
+ }
10461
+ }
10462
+ }
10463
+ if (!importedFiles.has(file)) {
10464
+ delete bundle[file];
10465
+ }
11186
10466
  }
11187
10467
  }
11188
10468
  if (config.command === "build" && !this.environment.config.build.emitAssets) {
@@ -11211,8 +10491,9 @@ async function fileToDevUrl(environment, id, skipBase = false) {
11211
10491
  const content = await fsp.readFile(file);
11212
10492
  return assetToDataURL(environment, file, content);
11213
10493
  }
11214
- if (svgExtRE.test(id)) {
11215
- const file = publicFile || cleanUrl(id);
10494
+ const cleanedId = cleanUrl(id);
10495
+ if (svgExtRE.test(cleanedId)) {
10496
+ const file = publicFile || cleanedId;
11216
10497
  const content = await fsp.readFile(file);
11217
10498
  if (shouldInline(environment, file, id, content, void 0, void 0)) {
11218
10499
  return assetToDataURL(environment, file, content);
@@ -11888,7 +11169,7 @@ var src$1 = {};
11888
11169
 
11889
11170
  // @ts-check
11890
11171
  const path$9 = require$$0$2;
11891
- const fs$7 = require$$0$3;
11172
+ const fs$7 = require$$0$4;
11892
11173
  const os$2 = require$$2;
11893
11174
  const url$4 = require$$0$5;
11894
11175
 
@@ -16036,7 +15317,7 @@ async function extractExportsData(environment, filePath) {
16036
15317
  const { optimizeDeps: optimizeDeps2 } = environment.config;
16037
15318
  const esbuildOptions = optimizeDeps2.esbuildOptions ?? {};
16038
15319
  if (optimizeDeps2.extensions?.some((ext) => filePath.endsWith(ext))) {
16039
- const result = await build$b({
15320
+ const result = await build$3({
16040
15321
  ...esbuildOptions,
16041
15322
  entryPoints: [filePath],
16042
15323
  write: false,
@@ -17160,7 +16441,7 @@ var version$1 = "16.4.7";
17160
16441
  var require$$4 = {
17161
16442
  version: version$1};
17162
16443
 
17163
- const fs$6 = require$$0$3;
16444
+ const fs$6 = require$$0$4;
17164
16445
  const path$8 = require$$0$2;
17165
16446
  const os$1 = require$$2;
17166
16447
  const crypto$1 = require$$3;
@@ -18190,7 +17471,7 @@ var debugExports = debug$a.exports;
18190
17471
  */
18191
17472
 
18192
17473
  (function (module, exports) {
18193
- var tty = require$$0$4;
17474
+ var tty = require$$0$3;
18194
17475
  var util = require$$1;
18195
17476
 
18196
17477
  /**
@@ -18371,7 +17652,7 @@ var debugExports = debug$a.exports;
18371
17652
  break;
18372
17653
 
18373
17654
  case 'FILE':
18374
- var fs = require$$0$3;
17655
+ var fs = require$$0$4;
18375
17656
  stream = new fs.SyncWriteStream(fd, { autoClose: false });
18376
17657
  stream._type = 'fs';
18377
17658
  break;
@@ -20400,7 +19681,7 @@ var corsMiddleware = /*@__PURE__*/getDefaultExportFromCjs(libExports);
20400
19681
 
20401
19682
  var chokidar = {};
20402
19683
 
20403
- const fs$5 = require$$0$3;
19684
+ const fs$5 = require$$0$4;
20404
19685
  const { Readable } = require$$0$8;
20405
19686
  const sysPath$3 = require$$0$2;
20406
19687
  const { promisify: promisify$3 } = require$$1;
@@ -22784,7 +22065,7 @@ var constants$1 = {};
22784
22065
  exports.isIBMi = os.type() === 'OS400';
22785
22066
  } (constants$1));
22786
22067
 
22787
- const fs$4 = require$$0$3;
22068
+ const fs$4 = require$$0$4;
22788
22069
  const sysPath$2 = require$$0$2;
22789
22070
  const { promisify: promisify$2 } = require$$1;
22790
22071
  const isBinaryPath = isBinaryPath$1;
@@ -23429,7 +22710,7 @@ var nodefsHandler = NodeFsHandler$1;
23429
22710
 
23430
22711
  var fseventsHandler = {exports: {}};
23431
22712
 
23432
- const fs$3 = require$$0$3;
22713
+ const fs$3 = require$$0$4;
23433
22714
  const sysPath$1 = require$$0$2;
23434
22715
  const { promisify: promisify$1 } = require$$1;
23435
22716
 
@@ -23958,7 +23239,7 @@ fseventsHandler.exports.canUse = canUse;
23958
23239
  var fseventsHandlerExports = fseventsHandler.exports;
23959
23240
 
23960
23241
  const { EventEmitter: EventEmitter$2 } = require$$0$7;
23961
- const fs$2 = require$$0$3;
23242
+ const fs$2 = require$$0$4;
23962
23243
  const sysPath = require$$0$2;
23963
23244
  const { promisify } = require$$1;
23964
23245
  const readdirp = readdirp_1;
@@ -25471,7 +24752,7 @@ var getArgs = function getArgumentsForPosition (
25471
24752
  * Modified by Yuxi Evan You
25472
24753
  */
25473
24754
 
25474
- const fs$1 = require$$0$3;
24755
+ const fs$1 = require$$0$4;
25475
24756
  const os = require$$2;
25476
24757
  const path$4 = require$$0$2;
25477
24758
  const colors = picocolorsExports;
@@ -27277,7 +26558,7 @@ function requireWindows () {
27277
26558
  windows = isexe;
27278
26559
  isexe.sync = sync;
27279
26560
 
27280
- var fs = require$$0$3;
26561
+ var fs = require$$0$4;
27281
26562
 
27282
26563
  function checkPathExt (path, options) {
27283
26564
  var pathext = options.pathExt !== undefined ?
@@ -27328,7 +26609,7 @@ function requireMode () {
27328
26609
  mode = isexe;
27329
26610
  isexe.sync = sync;
27330
26611
 
27331
- var fs = require$$0$3;
26612
+ var fs = require$$0$4;
27332
26613
 
27333
26614
  function isexe (path, options, cb) {
27334
26615
  fs.stat(path, function (er, stat) {
@@ -27691,7 +26972,7 @@ var shebangCommand$1 = (string = '') => {
27691
26972
  return argument ? `${binary} ${argument}` : binary;
27692
26973
  };
27693
26974
 
27694
- const fs = require$$0$3;
26975
+ const fs = require$$0$4;
27695
26976
  const shebangCommand = shebangCommand$1;
27696
26977
 
27697
26978
  function readShebang$1(command) {
@@ -35623,7 +34904,7 @@ var etag_1 = etag;
35623
34904
  */
35624
34905
 
35625
34906
  var crypto = require$$3;
35626
- var Stats = require$$0$3.Stats;
34907
+ var Stats = require$$0$4.Stats;
35627
34908
 
35628
34909
  /**
35629
34910
  * Module variables.
@@ -36211,6 +35492,7 @@ function renderRestrictedErrorHTML(msg) {
36211
35492
 
36212
35493
  const ERR_LOAD_URL = "ERR_LOAD_URL";
36213
35494
  const ERR_LOAD_PUBLIC_URL = "ERR_LOAD_PUBLIC_URL";
35495
+ const ERR_DENIED_ID = "ERR_DENIED_ID";
36214
35496
  const debugLoad = createDebugger("vite:load");
36215
35497
  const debugTransform = createDebugger("vite:transform");
36216
35498
  const debugCache$1 = createDebugger("vite:cache");
@@ -36310,6 +35592,11 @@ async function loadAndTransform(environment, id, url, options, timestamp, mod, r
36310
35592
  const { config, pluginContainer, logger } = environment;
36311
35593
  const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url, config.root) : "";
36312
35594
  const moduleGraph = environment.moduleGraph;
35595
+ if (options.allowId && !options.allowId(id)) {
35596
+ const err = new Error(`Denied ID ${id}`);
35597
+ err.code = ERR_DENIED_ID;
35598
+ throw err;
35599
+ }
36313
35600
  let code = null;
36314
35601
  let map = null;
36315
35602
  const loadStart = debugLoad ? performance$1.now() : 0;
@@ -36671,8 +35958,8 @@ function polyfill() {
36671
35958
  }
36672
35959
  }
36673
35960
 
36674
- const htmlProxyRE$1 = /\?html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(?:js|css)$/;
36675
- const isHtmlProxyRE = /\?html-proxy\b/;
35961
+ const htmlProxyRE$1 = /[?&]html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(?:js|css)$/;
35962
+ const isHtmlProxyRE = /[?&]html-proxy\b/;
36676
35963
  const inlineCSSRE$1 = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g;
36677
35964
  const inlineImportRE = /(?<!(?<!\.\.)\.)\bimport\s*\(("(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*')\)/dg;
36678
35965
  const htmlLangRE = /\.(?:html|htm)$/;
@@ -37762,6 +37049,10 @@ const trailingQuerySeparatorsRE = /[?&]+$/;
37762
37049
  const urlRE = /[?&]url\b/;
37763
37050
  const rawRE = /[?&]raw\b/;
37764
37051
  const inlineRE$2 = /[?&]inline\b/;
37052
+ const svgRE = /\.svg\b/;
37053
+ function deniedServingAccessForTransform(url, server, res, next) {
37054
+ return (rawRE.test(url) || urlRE.test(url) || inlineRE$2.test(url) || svgRE.test(url)) && !ensureServingAccess(url, server, res, next);
37055
+ }
37765
37056
  function cachedTransformMiddleware(server) {
37766
37057
  return function viteCachedTransformMiddleware(req, res, next) {
37767
37058
  const environment = server.environments.client;
@@ -37851,7 +37142,7 @@ function transformMiddleware(server) {
37851
37142
  trailingQuerySeparatorsRE,
37852
37143
  ""
37853
37144
  );
37854
- if ((rawRE.test(urlWithoutTrailingQuerySeparators) || urlRE.test(urlWithoutTrailingQuerySeparators) || inlineRE$2.test(urlWithoutTrailingQuerySeparators)) && !ensureServingAccess(
37145
+ if (deniedServingAccessForTransform(
37855
37146
  urlWithoutTrailingQuerySeparators,
37856
37147
  server,
37857
37148
  res,
@@ -37874,7 +37165,10 @@ function transformMiddleware(server) {
37874
37165
  }
37875
37166
  }
37876
37167
  const result = await transformRequest(environment, url, {
37877
- html: req.headers.accept?.includes("text/html")
37168
+ html: req.headers.accept?.includes("text/html"),
37169
+ allowId(id) {
37170
+ return !deniedServingAccessForTransform(id, server, res, next);
37171
+ }
37878
37172
  });
37879
37173
  if (result) {
37880
37174
  const depsOptimizer = environment.depsOptimizer;
@@ -37926,6 +37220,9 @@ function transformMiddleware(server) {
37926
37220
  if (e?.code === ERR_LOAD_URL) {
37927
37221
  return next();
37928
37222
  }
37223
+ if (e?.code === ERR_DENIED_ID) {
37224
+ return;
37225
+ }
37929
37226
  return next(e);
37930
37227
  }
37931
37228
  next();
@@ -38931,6 +38228,17 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
38931
38228
  return searchForWorkspaceRoot(dir, root);
38932
38229
  }
38933
38230
 
38231
+ function rejectInvalidRequestMiddleware() {
38232
+ return function viteRejectInvalidRequestMiddleware(req, res, next) {
38233
+ if (req.url?.includes("#")) {
38234
+ res.writeHead(400);
38235
+ res.end();
38236
+ return;
38237
+ }
38238
+ return next();
38239
+ };
38240
+ }
38241
+
38934
38242
  function createServer(inlineConfig = {}) {
38935
38243
  return _createServer(inlineConfig, { listen: true });
38936
38244
  }
@@ -39117,15 +38425,7 @@ async function _createServer(inlineConfig = {}, options) {
39117
38425
  },
39118
38426
  openBrowser() {
39119
38427
  const options2 = server.config.server;
39120
- const host = options2.host;
39121
- let url;
39122
- if (typeof host === "string") {
39123
- url = [
39124
- ...server.resolvedUrls?.local ?? [],
39125
- ...server.resolvedUrls?.network ?? []
39126
- ].find((url2) => url2.includes(host));
39127
- }
39128
- url ??= server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
38428
+ const url = getServerUrlByHost(server, options2.host);
39129
38429
  if (url) {
39130
38430
  const path2 = typeof options2.open === "string" ? new URL(options2.open, url).href : url;
39131
38431
  if (server.config.server.preTransformRequests) {
@@ -39276,6 +38576,7 @@ async function _createServer(inlineConfig = {}, options) {
39276
38576
  if (process.env.DEBUG) {
39277
38577
  middlewares.use(timeMiddleware(root));
39278
38578
  }
38579
+ middlewares.use(rejectInvalidRequestMiddleware());
39279
38580
  const { cors } = serverConfig;
39280
38581
  if (cors !== false) {
39281
38582
  middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
@@ -39922,7 +39223,7 @@ async function handleHMRUpdate(type, file, server) {
39922
39223
  });
39923
39224
  await hotUpdateEnvironments(server, hmr);
39924
39225
  }
39925
- function updateModules(environment, file, modules, timestamp, afterInvalidation) {
39226
+ function updateModules(environment, file, modules, timestamp, firstInvalidatedBy) {
39926
39227
  const { hot } = environment;
39927
39228
  const updates = [];
39928
39229
  const invalidatedModules = /* @__PURE__ */ new Set();
@@ -39944,6 +39245,12 @@ function updateModules(environment, file, modules, timestamp, afterInvalidation)
39944
39245
  needFullReload = hasDeadEnd;
39945
39246
  continue;
39946
39247
  }
39248
+ if (firstInvalidatedBy && boundaries.some(
39249
+ ({ acceptedVia }) => normalizeHmrUrl(acceptedVia.url) === firstInvalidatedBy
39250
+ )) {
39251
+ needFullReload = "circular import invalidate";
39252
+ continue;
39253
+ }
39947
39254
  updates.push(
39948
39255
  ...boundaries.map(
39949
39256
  ({ boundary, acceptedVia, isWithinCircularImport }) => ({
@@ -39952,7 +39259,8 @@ function updateModules(environment, file, modules, timestamp, afterInvalidation)
39952
39259
  path: normalizeHmrUrl(boundary.url),
39953
39260
  acceptedPath: normalizeHmrUrl(acceptedVia.url),
39954
39261
  explicitImportRequired: boundary.type === "js" ? isExplicitImportRequired(acceptedVia.url) : false,
39955
- isWithinCircularImport
39262
+ isWithinCircularImport,
39263
+ firstInvalidatedBy
39956
39264
  })
39957
39265
  )
39958
39266
  );
@@ -39961,7 +39269,7 @@ function updateModules(environment, file, modules, timestamp, afterInvalidation)
39961
39269
  const reason = typeof needFullReload === "string" ? colors$1.dim(` (${needFullReload})`) : "";
39962
39270
  environment.logger.info(
39963
39271
  colors$1.green(`page reload `) + colors$1.dim(file) + reason,
39964
- { clear: !afterInvalidation, timestamp: true }
39272
+ { clear: !firstInvalidatedBy, timestamp: true }
39965
39273
  );
39966
39274
  hot.send({
39967
39275
  type: "full-reload",
@@ -39975,7 +39283,7 @@ function updateModules(environment, file, modules, timestamp, afterInvalidation)
39975
39283
  }
39976
39284
  environment.logger.info(
39977
39285
  colors$1.green(`hmr update `) + colors$1.dim([...new Set(updates.map((u) => u.path))].join(", ")),
39978
- { clear: !afterInvalidation, timestamp: true }
39286
+ { clear: !firstInvalidatedBy, timestamp: true }
39979
39287
  );
39980
39288
  hot.send({
39981
39289
  type: "update",
@@ -41375,7 +40683,7 @@ See ${colors$1.blue(
41375
40683
  if (pluginImports) {
41376
40684
  (await Promise.all(
41377
40685
  [...pluginImports].map((id) => normalizeUrl(id, 0, true))
41378
- )).forEach(([url]) => importedUrls.add(url));
40686
+ )).forEach(([url]) => importedUrls.add(stripBase(url, base)));
41379
40687
  }
41380
40688
  if (ssr && importerModule.isSelfAccepting) {
41381
40689
  isSelfAccepting = true;
@@ -41652,6 +40960,7 @@ function escapeReplacement(value) {
41652
40960
  }
41653
40961
 
41654
40962
  const wasmHelperId = "\0vite/wasm-helper.js";
40963
+ const wasmInitRE = /(?<![?#].*)\.wasm\?init/;
41655
40964
  const wasmHelper = async (opts = {}, url) => {
41656
40965
  let result;
41657
40966
  if (url.startsWith("data:")) {
@@ -41699,7 +41008,7 @@ const wasmHelperPlugin = () => {
41699
41008
  if (id === wasmHelperId) {
41700
41009
  return `export default ${wasmHelperCode}`;
41701
41010
  }
41702
- if (!id.endsWith(".wasm?init")) {
41011
+ if (!wasmInitRE.test(id)) {
41703
41012
  return;
41704
41013
  }
41705
41014
  const url = await fileToUrl$1(this, id);
@@ -42383,8 +41692,6 @@ function dynamicImportVarsPlugin(config) {
42383
41692
  };
42384
41693
  }
42385
41694
 
42386
- const FALLBACK_TRUE = 1;
42387
- const FALLBACK_FALSE = 0;
42388
41695
  function getMatcherString(glob, cwd) {
42389
41696
  if (glob.startsWith("**") || path$b.isAbsolute(glob)) {
42390
41697
  return slash$1(glob);
@@ -42429,7 +41736,7 @@ function createFilter(exclude, include) {
42429
41736
  if (include?.some((filter) => filter(input))) {
42430
41737
  return true;
42431
41738
  }
42432
- return !!include && include.length > 0 ? FALLBACK_FALSE : FALLBACK_TRUE;
41739
+ return !(include && include.length > 0);
42433
41740
  };
42434
41741
  }
42435
41742
  function normalizeFilter(filter) {
@@ -42440,7 +41747,7 @@ function normalizeFilter(filter) {
42440
41747
  }
42441
41748
  if (Array.isArray(filter)) {
42442
41749
  return {
42443
- include: arraify(filter)
41750
+ include: filter
42444
41751
  };
42445
41752
  }
42446
41753
  return {
@@ -42469,18 +41776,13 @@ function createFilterForTransform(idFilter, codeFilter, cwd) {
42469
41776
  return (id, code) => {
42470
41777
  let fallback = true;
42471
41778
  if (idFilterFn) {
42472
- const idResult = idFilterFn(id);
42473
- if (typeof idResult === "boolean") {
42474
- return idResult;
42475
- }
42476
- fallback &&= !!idResult;
41779
+ fallback &&= idFilterFn(id);
41780
+ }
41781
+ if (!fallback) {
41782
+ return false;
42477
41783
  }
42478
41784
  if (codeFilterFn) {
42479
- const codeResult = codeFilterFn(code);
42480
- if (typeof codeResult === "boolean") {
42481
- return codeResult;
42482
- }
42483
- fallback &&= !!codeResult;
41785
+ fallback &&= codeFilterFn(code);
42484
41786
  }
42485
41787
  return fallback;
42486
41788
  };
@@ -43464,7 +42766,7 @@ const cssModuleRE = new RegExp(`\\.module${CSS_LANGS_RE.source}`);
43464
42766
  const directRequestRE = /[?&]direct\b/;
43465
42767
  const htmlProxyRE = /[?&]html-proxy\b/;
43466
42768
  const htmlProxyIndexRE = /&index=(\d+)/;
43467
- const commonjsProxyRE = /\?commonjs-proxy/;
42769
+ const commonjsProxyRE = /[?&]commonjs-proxy/;
43468
42770
  const inlineRE = /[?&]inline\b/;
43469
42771
  const inlineCSSRE = /[?&]inline-css\b/;
43470
42772
  const styleAttrRE = /[?&]style-attr\b/;
@@ -43740,10 +43042,19 @@ function cssPostPlugin(config) {
43740
43042
  },
43741
43043
  async renderChunk(code, chunk, opts, meta) {
43742
43044
  let chunkCSS = "";
43743
- const renderedModules = Object.fromEntries(
43744
- Object.values(meta.chunks).flatMap(
43745
- (chunk2) => Object.entries(chunk2.modules)
43746
- )
43045
+ const renderedModules = new Proxy(
43046
+ {},
43047
+ {
43048
+ get(_target, p) {
43049
+ for (const name in meta.chunks) {
43050
+ const modules = meta.chunks[name].modules;
43051
+ const module = modules[p];
43052
+ if (module) {
43053
+ return module;
43054
+ }
43055
+ }
43056
+ }
43057
+ }
43747
43058
  );
43748
43059
  const isJsChunkEmpty = code === "" && !chunk.isEntry;
43749
43060
  let isPureCssChunk = chunk.exports.length === 0;
@@ -44105,7 +43416,7 @@ function isCssScopeToRendered(cssScopeTo, renderedModules) {
44105
43416
  return importer && (exp === void 0 || importer.renderedExports.includes(exp));
44106
43417
  }
44107
43418
  function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
44108
- const emptyChunkFiles = pureCssChunkNames.map((file) => path$b.basename(file)).join("|").replace(/\./g, "\\.");
43419
+ const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex(path$b.basename(file))).join("|");
44109
43420
  const emptyChunkRE = new RegExp(
44110
43421
  outputFormat === "es" ? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];` : `(\\b|,\\s*)require\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\)(;|,)`,
44111
43422
  "g"
@@ -44515,8 +43826,8 @@ function createCachedImport(imp) {
44515
43826
  return cached;
44516
43827
  };
44517
43828
  }
44518
- const importPostcssImport = createCachedImport(() => import('./dep-W4lxOTyg.js').then(function (n) { return n.i; }));
44519
- const importPostcssModules = createCachedImport(() => import('./dep-DPsCJVuU.js').then(function (n) { return n.i; }));
43829
+ const importPostcssImport = createCachedImport(() => import('./dep-KUFMcaC7.js').then(function (n) { return n.i; }));
43830
+ const importPostcssModules = createCachedImport(() => import('./dep-CQ6IcQaf.js').then(function (n) { return n.i; }));
44520
43831
  const importPostcss = createCachedImport(() => import('postcss'));
44521
43832
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
44522
43833
  let alwaysFakeWorkerWorkerControllerCache;
@@ -47413,13 +46724,6 @@ async function fetchModule(environment, url, importer, options = {}) {
47413
46724
  const type = isFilePathESM(resolved.id, environment.config.packageCache) ? "module" : "commonjs";
47414
46725
  return { externalize: file, type };
47415
46726
  }
47416
- if (isFileUrl || !importer) {
47417
- const resolved = await environment.pluginContainer.resolveId(url);
47418
- if (!resolved) {
47419
- throw new Error(`[vite] cannot find entry point module '${url}'.`);
47420
- }
47421
- url = normalizeResolvedIdToUrl(environment, url, resolved);
47422
- }
47423
46727
  url = unwrapId$1(url);
47424
46728
  const mod = await environment.moduleGraph.ensureEntryFromUrl(url);
47425
46729
  const cached = !!mod.transformResult;
@@ -48458,12 +47762,16 @@ class DevEnvironment extends BaseEnvironment {
48458
47762
  return this.fetchModule(id, importer, options2);
48459
47763
  }
48460
47764
  });
48461
- this.hot.on("vite:invalidate", async ({ path, message }) => {
48462
- invalidateModule(this, {
48463
- path,
48464
- message
48465
- });
48466
- });
47765
+ this.hot.on(
47766
+ "vite:invalidate",
47767
+ async ({ path, message, firstInvalidatedBy }) => {
47768
+ invalidateModule(this, {
47769
+ path,
47770
+ message,
47771
+ firstInvalidatedBy
47772
+ });
47773
+ }
47774
+ );
48467
47775
  const { optimizeDeps } = this.config;
48468
47776
  if (context.depsOptimizer) {
48469
47777
  this.depsOptimizer = context.depsOptimizer;
@@ -48577,7 +47885,7 @@ function invalidateModule(environment, m) {
48577
47885
  file,
48578
47886
  [...mod.importers],
48579
47887
  mod.lastHMRTimestamp,
48580
- true
47888
+ m.firstInvalidatedBy
48581
47889
  );
48582
47890
  }
48583
47891
  }
@@ -48918,7 +48226,7 @@ async function preview(inlineConfig = {}) {
48918
48226
  config
48919
48227
  );
48920
48228
  if (options.open) {
48921
- const url = server.resolvedUrls.local[0] ?? server.resolvedUrls.network[0];
48229
+ const url = getServerUrlByHost(server, options.host);
48922
48230
  if (url) {
48923
48231
  const path2 = typeof options.open === "string" ? new URL(options.open, url).href : url;
48924
48232
  openBrowser(path2, true, logger);
@@ -49867,7 +49175,7 @@ async function bundleConfigFile(fileName, isESM) {
49867
49175
  const dirnameVarName = "__vite_injected_original_dirname";
49868
49176
  const filenameVarName = "__vite_injected_original_filename";
49869
49177
  const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
49870
- const result = await build$b({
49178
+ const result = await build$3({
49871
49179
  absWorkingDir: process.cwd(),
49872
49180
  entryPoints: [fileName],
49873
49181
  write: false,