vite 6.3.0-beta.1 → 6.3.0-beta.2

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.
@@ -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
  /**
@@ -11179,10 +10433,27 @@ function assetPlugin(config) {
11179
10433
  }
11180
10434
  },
11181
10435
  generateBundle(_, bundle) {
10436
+ let importedFiles;
11182
10437
  for (const file in bundle) {
11183
10438
  const chunk = bundle[file];
11184
10439
  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];
10440
+ if (!importedFiles) {
10441
+ importedFiles = /* @__PURE__ */ new Set();
10442
+ for (const file2 in bundle) {
10443
+ const chunk2 = bundle[file2];
10444
+ if (chunk2.type === "chunk") {
10445
+ for (const importedFile of chunk2.imports) {
10446
+ importedFiles.add(importedFile);
10447
+ }
10448
+ for (const importedFile of chunk2.dynamicImports) {
10449
+ importedFiles.add(importedFile);
10450
+ }
10451
+ }
10452
+ }
10453
+ }
10454
+ if (!importedFiles.has(file)) {
10455
+ delete bundle[file];
10456
+ }
11186
10457
  }
11187
10458
  }
11188
10459
  if (config.command === "build" && !this.environment.config.build.emitAssets) {
@@ -11211,8 +10482,9 @@ async function fileToDevUrl(environment, id, skipBase = false) {
11211
10482
  const content = await fsp.readFile(file);
11212
10483
  return assetToDataURL(environment, file, content);
11213
10484
  }
11214
- if (svgExtRE.test(id)) {
11215
- const file = publicFile || cleanUrl(id);
10485
+ const cleanedId = cleanUrl(id);
10486
+ if (svgExtRE.test(cleanedId)) {
10487
+ const file = publicFile || cleanedId;
11216
10488
  const content = await fsp.readFile(file);
11217
10489
  if (shouldInline(environment, file, id, content, void 0, void 0)) {
11218
10490
  return assetToDataURL(environment, file, content);
@@ -11888,7 +11160,7 @@ var src$1 = {};
11888
11160
 
11889
11161
  // @ts-check
11890
11162
  const path$9 = require$$0$2;
11891
- const fs$7 = require$$0$3;
11163
+ const fs$7 = require$$0$4;
11892
11164
  const os$2 = require$$2;
11893
11165
  const url$4 = require$$0$5;
11894
11166
 
@@ -16036,7 +15308,7 @@ async function extractExportsData(environment, filePath) {
16036
15308
  const { optimizeDeps: optimizeDeps2 } = environment.config;
16037
15309
  const esbuildOptions = optimizeDeps2.esbuildOptions ?? {};
16038
15310
  if (optimizeDeps2.extensions?.some((ext) => filePath.endsWith(ext))) {
16039
- const result = await build$b({
15311
+ const result = await build$3({
16040
15312
  ...esbuildOptions,
16041
15313
  entryPoints: [filePath],
16042
15314
  write: false,
@@ -17160,7 +16432,7 @@ var version$1 = "16.4.7";
17160
16432
  var require$$4 = {
17161
16433
  version: version$1};
17162
16434
 
17163
- const fs$6 = require$$0$3;
16435
+ const fs$6 = require$$0$4;
17164
16436
  const path$8 = require$$0$2;
17165
16437
  const os$1 = require$$2;
17166
16438
  const crypto$1 = require$$3;
@@ -18190,7 +17462,7 @@ var debugExports = debug$a.exports;
18190
17462
  */
18191
17463
 
18192
17464
  (function (module, exports) {
18193
- var tty = require$$0$4;
17465
+ var tty = require$$0$3;
18194
17466
  var util = require$$1;
18195
17467
 
18196
17468
  /**
@@ -18371,7 +17643,7 @@ var debugExports = debug$a.exports;
18371
17643
  break;
18372
17644
 
18373
17645
  case 'FILE':
18374
- var fs = require$$0$3;
17646
+ var fs = require$$0$4;
18375
17647
  stream = new fs.SyncWriteStream(fd, { autoClose: false });
18376
17648
  stream._type = 'fs';
18377
17649
  break;
@@ -20400,7 +19672,7 @@ var corsMiddleware = /*@__PURE__*/getDefaultExportFromCjs(libExports);
20400
19672
 
20401
19673
  var chokidar = {};
20402
19674
 
20403
- const fs$5 = require$$0$3;
19675
+ const fs$5 = require$$0$4;
20404
19676
  const { Readable } = require$$0$8;
20405
19677
  const sysPath$3 = require$$0$2;
20406
19678
  const { promisify: promisify$3 } = require$$1;
@@ -22784,7 +22056,7 @@ var constants$1 = {};
22784
22056
  exports.isIBMi = os.type() === 'OS400';
22785
22057
  } (constants$1));
22786
22058
 
22787
- const fs$4 = require$$0$3;
22059
+ const fs$4 = require$$0$4;
22788
22060
  const sysPath$2 = require$$0$2;
22789
22061
  const { promisify: promisify$2 } = require$$1;
22790
22062
  const isBinaryPath = isBinaryPath$1;
@@ -23429,7 +22701,7 @@ var nodefsHandler = NodeFsHandler$1;
23429
22701
 
23430
22702
  var fseventsHandler = {exports: {}};
23431
22703
 
23432
- const fs$3 = require$$0$3;
22704
+ const fs$3 = require$$0$4;
23433
22705
  const sysPath$1 = require$$0$2;
23434
22706
  const { promisify: promisify$1 } = require$$1;
23435
22707
 
@@ -23958,7 +23230,7 @@ fseventsHandler.exports.canUse = canUse;
23958
23230
  var fseventsHandlerExports = fseventsHandler.exports;
23959
23231
 
23960
23232
  const { EventEmitter: EventEmitter$2 } = require$$0$7;
23961
- const fs$2 = require$$0$3;
23233
+ const fs$2 = require$$0$4;
23962
23234
  const sysPath = require$$0$2;
23963
23235
  const { promisify } = require$$1;
23964
23236
  const readdirp = readdirp_1;
@@ -25471,7 +24743,7 @@ var getArgs = function getArgumentsForPosition (
25471
24743
  * Modified by Yuxi Evan You
25472
24744
  */
25473
24745
 
25474
- const fs$1 = require$$0$3;
24746
+ const fs$1 = require$$0$4;
25475
24747
  const os = require$$2;
25476
24748
  const path$4 = require$$0$2;
25477
24749
  const colors = picocolorsExports;
@@ -27277,7 +26549,7 @@ function requireWindows () {
27277
26549
  windows = isexe;
27278
26550
  isexe.sync = sync;
27279
26551
 
27280
- var fs = require$$0$3;
26552
+ var fs = require$$0$4;
27281
26553
 
27282
26554
  function checkPathExt (path, options) {
27283
26555
  var pathext = options.pathExt !== undefined ?
@@ -27328,7 +26600,7 @@ function requireMode () {
27328
26600
  mode = isexe;
27329
26601
  isexe.sync = sync;
27330
26602
 
27331
- var fs = require$$0$3;
26603
+ var fs = require$$0$4;
27332
26604
 
27333
26605
  function isexe (path, options, cb) {
27334
26606
  fs.stat(path, function (er, stat) {
@@ -27691,7 +26963,7 @@ var shebangCommand$1 = (string = '') => {
27691
26963
  return argument ? `${binary} ${argument}` : binary;
27692
26964
  };
27693
26965
 
27694
- const fs = require$$0$3;
26966
+ const fs = require$$0$4;
27695
26967
  const shebangCommand = shebangCommand$1;
27696
26968
 
27697
26969
  function readShebang$1(command) {
@@ -35623,7 +34895,7 @@ var etag_1 = etag;
35623
34895
  */
35624
34896
 
35625
34897
  var crypto = require$$3;
35626
- var Stats = require$$0$3.Stats;
34898
+ var Stats = require$$0$4.Stats;
35627
34899
 
35628
34900
  /**
35629
34901
  * Module variables.
@@ -36211,6 +35483,7 @@ function renderRestrictedErrorHTML(msg) {
36211
35483
 
36212
35484
  const ERR_LOAD_URL = "ERR_LOAD_URL";
36213
35485
  const ERR_LOAD_PUBLIC_URL = "ERR_LOAD_PUBLIC_URL";
35486
+ const ERR_DENIED_ID = "ERR_DENIED_ID";
36214
35487
  const debugLoad = createDebugger("vite:load");
36215
35488
  const debugTransform = createDebugger("vite:transform");
36216
35489
  const debugCache$1 = createDebugger("vite:cache");
@@ -36310,6 +35583,11 @@ async function loadAndTransform(environment, id, url, options, timestamp, mod, r
36310
35583
  const { config, pluginContainer, logger } = environment;
36311
35584
  const prettyUrl = debugLoad || debugTransform ? prettifyUrl(url, config.root) : "";
36312
35585
  const moduleGraph = environment.moduleGraph;
35586
+ if (options.allowId && !options.allowId(id)) {
35587
+ const err = new Error(`Denied ID ${id}`);
35588
+ err.code = ERR_DENIED_ID;
35589
+ throw err;
35590
+ }
36313
35591
  let code = null;
36314
35592
  let map = null;
36315
35593
  const loadStart = debugLoad ? performance$1.now() : 0;
@@ -36671,8 +35949,8 @@ function polyfill() {
36671
35949
  }
36672
35950
  }
36673
35951
 
36674
- const htmlProxyRE$1 = /\?html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(?:js|css)$/;
36675
- const isHtmlProxyRE = /\?html-proxy\b/;
35952
+ const htmlProxyRE$1 = /[?&]html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(?:js|css)$/;
35953
+ const isHtmlProxyRE = /[?&]html-proxy\b/;
36676
35954
  const inlineCSSRE$1 = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g;
36677
35955
  const inlineImportRE = /(?<!(?<!\.\.)\.)\bimport\s*\(("(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*')\)/dg;
36678
35956
  const htmlLangRE = /\.(?:html|htm)$/;
@@ -37762,6 +37040,10 @@ const trailingQuerySeparatorsRE = /[?&]+$/;
37762
37040
  const urlRE = /[?&]url\b/;
37763
37041
  const rawRE = /[?&]raw\b/;
37764
37042
  const inlineRE$2 = /[?&]inline\b/;
37043
+ const svgRE = /\.svg\b/;
37044
+ function deniedServingAccessForTransform(url, server, res, next) {
37045
+ return (rawRE.test(url) || urlRE.test(url) || inlineRE$2.test(url) || svgRE.test(url)) && !ensureServingAccess(url, server, res, next);
37046
+ }
37765
37047
  function cachedTransformMiddleware(server) {
37766
37048
  return function viteCachedTransformMiddleware(req, res, next) {
37767
37049
  const environment = server.environments.client;
@@ -37851,7 +37133,7 @@ function transformMiddleware(server) {
37851
37133
  trailingQuerySeparatorsRE,
37852
37134
  ""
37853
37135
  );
37854
- if ((rawRE.test(urlWithoutTrailingQuerySeparators) || urlRE.test(urlWithoutTrailingQuerySeparators) || inlineRE$2.test(urlWithoutTrailingQuerySeparators)) && !ensureServingAccess(
37136
+ if (deniedServingAccessForTransform(
37855
37137
  urlWithoutTrailingQuerySeparators,
37856
37138
  server,
37857
37139
  res,
@@ -37874,7 +37156,10 @@ function transformMiddleware(server) {
37874
37156
  }
37875
37157
  }
37876
37158
  const result = await transformRequest(environment, url, {
37877
- html: req.headers.accept?.includes("text/html")
37159
+ html: req.headers.accept?.includes("text/html"),
37160
+ allowId(id) {
37161
+ return !deniedServingAccessForTransform(id, server, res, next);
37162
+ }
37878
37163
  });
37879
37164
  if (result) {
37880
37165
  const depsOptimizer = environment.depsOptimizer;
@@ -37926,6 +37211,9 @@ function transformMiddleware(server) {
37926
37211
  if (e?.code === ERR_LOAD_URL) {
37927
37212
  return next();
37928
37213
  }
37214
+ if (e?.code === ERR_DENIED_ID) {
37215
+ return;
37216
+ }
37929
37217
  return next(e);
37930
37218
  }
37931
37219
  next();
@@ -38931,6 +38219,17 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
38931
38219
  return searchForWorkspaceRoot(dir, root);
38932
38220
  }
38933
38221
 
38222
+ function rejectInvalidRequestMiddleware() {
38223
+ return function viteRejectInvalidRequestMiddleware(req, res, next) {
38224
+ if (req.url?.includes("#")) {
38225
+ res.writeHead(400);
38226
+ res.end();
38227
+ return;
38228
+ }
38229
+ return next();
38230
+ };
38231
+ }
38232
+
38934
38233
  function createServer(inlineConfig = {}) {
38935
38234
  return _createServer(inlineConfig, { listen: true });
38936
38235
  }
@@ -39276,6 +38575,7 @@ async function _createServer(inlineConfig = {}, options) {
39276
38575
  if (process.env.DEBUG) {
39277
38576
  middlewares.use(timeMiddleware(root));
39278
38577
  }
38578
+ middlewares.use(rejectInvalidRequestMiddleware());
39279
38579
  const { cors } = serverConfig;
39280
38580
  if (cors !== false) {
39281
38581
  middlewares.use(corsMiddleware(typeof cors === "boolean" ? {} : cors));
@@ -41375,7 +40675,7 @@ See ${colors$1.blue(
41375
40675
  if (pluginImports) {
41376
40676
  (await Promise.all(
41377
40677
  [...pluginImports].map((id) => normalizeUrl(id, 0, true))
41378
- )).forEach(([url]) => importedUrls.add(url));
40678
+ )).forEach(([url]) => importedUrls.add(stripBase(url, base)));
41379
40679
  }
41380
40680
  if (ssr && importerModule.isSelfAccepting) {
41381
40681
  isSelfAccepting = true;
@@ -41652,6 +40952,7 @@ function escapeReplacement(value) {
41652
40952
  }
41653
40953
 
41654
40954
  const wasmHelperId = "\0vite/wasm-helper.js";
40955
+ const wasmInitRE = /(?<![?#].*)\.wasm\?init/;
41655
40956
  const wasmHelper = async (opts = {}, url) => {
41656
40957
  let result;
41657
40958
  if (url.startsWith("data:")) {
@@ -41699,7 +41000,7 @@ const wasmHelperPlugin = () => {
41699
41000
  if (id === wasmHelperId) {
41700
41001
  return `export default ${wasmHelperCode}`;
41701
41002
  }
41702
- if (!id.endsWith(".wasm?init")) {
41003
+ if (!wasmInitRE.test(id)) {
41703
41004
  return;
41704
41005
  }
41705
41006
  const url = await fileToUrl$1(this, id);
@@ -42383,8 +41684,6 @@ function dynamicImportVarsPlugin(config) {
42383
41684
  };
42384
41685
  }
42385
41686
 
42386
- const FALLBACK_TRUE = 1;
42387
- const FALLBACK_FALSE = 0;
42388
41687
  function getMatcherString(glob, cwd) {
42389
41688
  if (glob.startsWith("**") || path$b.isAbsolute(glob)) {
42390
41689
  return slash$1(glob);
@@ -42429,7 +41728,7 @@ function createFilter(exclude, include) {
42429
41728
  if (include?.some((filter) => filter(input))) {
42430
41729
  return true;
42431
41730
  }
42432
- return !!include && include.length > 0 ? FALLBACK_FALSE : FALLBACK_TRUE;
41731
+ return !(include && include.length > 0);
42433
41732
  };
42434
41733
  }
42435
41734
  function normalizeFilter(filter) {
@@ -42440,7 +41739,7 @@ function normalizeFilter(filter) {
42440
41739
  }
42441
41740
  if (Array.isArray(filter)) {
42442
41741
  return {
42443
- include: arraify(filter)
41742
+ include: filter
42444
41743
  };
42445
41744
  }
42446
41745
  return {
@@ -42469,18 +41768,13 @@ function createFilterForTransform(idFilter, codeFilter, cwd) {
42469
41768
  return (id, code) => {
42470
41769
  let fallback = true;
42471
41770
  if (idFilterFn) {
42472
- const idResult = idFilterFn(id);
42473
- if (typeof idResult === "boolean") {
42474
- return idResult;
42475
- }
42476
- fallback &&= !!idResult;
41771
+ fallback &&= idFilterFn(id);
41772
+ }
41773
+ if (!fallback) {
41774
+ return false;
42477
41775
  }
42478
41776
  if (codeFilterFn) {
42479
- const codeResult = codeFilterFn(code);
42480
- if (typeof codeResult === "boolean") {
42481
- return codeResult;
42482
- }
42483
- fallback &&= !!codeResult;
41777
+ fallback &&= codeFilterFn(code);
42484
41778
  }
42485
41779
  return fallback;
42486
41780
  };
@@ -43464,7 +42758,7 @@ const cssModuleRE = new RegExp(`\\.module${CSS_LANGS_RE.source}`);
43464
42758
  const directRequestRE = /[?&]direct\b/;
43465
42759
  const htmlProxyRE = /[?&]html-proxy\b/;
43466
42760
  const htmlProxyIndexRE = /&index=(\d+)/;
43467
- const commonjsProxyRE = /\?commonjs-proxy/;
42761
+ const commonjsProxyRE = /[?&]commonjs-proxy/;
43468
42762
  const inlineRE = /[?&]inline\b/;
43469
42763
  const inlineCSSRE = /[?&]inline-css\b/;
43470
42764
  const styleAttrRE = /[?&]style-attr\b/;
@@ -43740,10 +43034,19 @@ function cssPostPlugin(config) {
43740
43034
  },
43741
43035
  async renderChunk(code, chunk, opts, meta) {
43742
43036
  let chunkCSS = "";
43743
- const renderedModules = Object.fromEntries(
43744
- Object.values(meta.chunks).flatMap(
43745
- (chunk2) => Object.entries(chunk2.modules)
43746
- )
43037
+ const renderedModules = new Proxy(
43038
+ {},
43039
+ {
43040
+ get(_target, p) {
43041
+ for (const name in meta.chunks) {
43042
+ const modules = meta.chunks[name].modules;
43043
+ const module = modules[p];
43044
+ if (module) {
43045
+ return module;
43046
+ }
43047
+ }
43048
+ }
43049
+ }
43747
43050
  );
43748
43051
  const isJsChunkEmpty = code === "" && !chunk.isEntry;
43749
43052
  let isPureCssChunk = chunk.exports.length === 0;
@@ -44105,7 +43408,7 @@ function isCssScopeToRendered(cssScopeTo, renderedModules) {
44105
43408
  return importer && (exp === void 0 || importer.renderedExports.includes(exp));
44106
43409
  }
44107
43410
  function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
44108
- const emptyChunkFiles = pureCssChunkNames.map((file) => path$b.basename(file)).join("|").replace(/\./g, "\\.");
43411
+ const emptyChunkFiles = pureCssChunkNames.map((file) => escapeRegex(path$b.basename(file))).join("|");
44109
43412
  const emptyChunkRE = new RegExp(
44110
43413
  outputFormat === "es" ? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];` : `(\\b|,\\s*)require\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\)(;|,)`,
44111
43414
  "g"
@@ -44515,8 +43818,8 @@ function createCachedImport(imp) {
44515
43818
  return cached;
44516
43819
  };
44517
43820
  }
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; }));
43821
+ const importPostcssImport = createCachedImport(() => import('./dep-BVYvZuv7.js').then(function (n) { return n.i; }));
43822
+ const importPostcssModules = createCachedImport(() => import('./dep-B8BdvHtp.js').then(function (n) { return n.i; }));
44520
43823
  const importPostcss = createCachedImport(() => import('postcss'));
44521
43824
  const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
44522
43825
  let alwaysFakeWorkerWorkerControllerCache;
@@ -47413,13 +46716,6 @@ async function fetchModule(environment, url, importer, options = {}) {
47413
46716
  const type = isFilePathESM(resolved.id, environment.config.packageCache) ? "module" : "commonjs";
47414
46717
  return { externalize: file, type };
47415
46718
  }
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
46719
  url = unwrapId$1(url);
47424
46720
  const mod = await environment.moduleGraph.ensureEntryFromUrl(url);
47425
46721
  const cached = !!mod.transformResult;
@@ -49867,7 +49163,7 @@ async function bundleConfigFile(fileName, isESM) {
49867
49163
  const dirnameVarName = "__vite_injected_original_dirname";
49868
49164
  const filenameVarName = "__vite_injected_original_filename";
49869
49165
  const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
49870
- const result = await build$b({
49166
+ const result = await build$3({
49871
49167
  absWorkingDir: process.cwd(),
49872
49168
  entryPoints: [fileName],
49873
49169
  write: false,