vite 5.1.4 → 5.1.5

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,6 +8,7 @@ import { createRequire as createRequire$1, builtinModules } from 'node:module';
8
8
  import require$$0$3 from 'tty';
9
9
  import require$$0$4, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, sep, normalize } from 'path';
10
10
  import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
11
+ import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, SPECIAL_QUERY_RE, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, KNOWN_ASSET_TYPES, JS_TYPES_RE, METADATA_FILENAME, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
11
12
  import * as require$$0$2 from 'fs';
12
13
  import require$$0__default, { existsSync, readFileSync, statSync as statSync$1, readdirSync } from 'fs';
13
14
  import require$$0$5 from 'events';
@@ -25,7 +26,6 @@ import os$4 from 'node:os';
25
26
  import { exec } from 'node:child_process';
26
27
  import { createHash as createHash$2 } from 'node:crypto';
27
28
  import { promises } from 'node:dns';
28
- import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, SPECIAL_QUERY_RE, ENV_ENTRY, DEP_VERSION_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, KNOWN_ASSET_TYPES, JS_TYPES_RE, METADATA_FILENAME, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
29
29
  import require$$0$a from 'crypto';
30
30
  import require$$0$8, { createRequire as createRequire$2 } from 'module';
31
31
  import assert$1 from 'node:assert';
@@ -231,6 +231,61 @@ function alias$1(options = {}) {
231
231
  };
232
232
  }
233
233
 
234
+ /**
235
+ * Prefix for resolved Ids that are not valid browser import specifiers
236
+ */
237
+ const VALID_ID_PREFIX = `/@id/`;
238
+ /**
239
+ * Plugins that use 'virtual modules' (e.g. for helper functions), prefix the
240
+ * module ID with `\0`, a convention from the rollup ecosystem.
241
+ * This prevents other plugins from trying to process the id (like node resolution),
242
+ * and core features like sourcemaps can use this info to differentiate between
243
+ * virtual modules and regular files.
244
+ * `\0` is not a permitted char in import URLs so we have to replace them during
245
+ * import analysis. The id will be decoded back before entering the plugins pipeline.
246
+ * These encoded virtual ids are also prefixed by the VALID_ID_PREFIX, so virtual
247
+ * modules in the browser end up encoded as `/@id/__x00__{id}`
248
+ */
249
+ const NULL_BYTE_PLACEHOLDER = `__x00__`;
250
+ let SOURCEMAPPING_URL = 'sourceMa';
251
+ SOURCEMAPPING_URL += 'ppingURL';
252
+ const VITE_RUNTIME_SOURCEMAPPING_SOURCE = '//# sourceMappingSource=vite-runtime';
253
+ const VITE_RUNTIME_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
254
+
255
+ const isWindows$5 = typeof process !== 'undefined' && process.platform === 'win32';
256
+ /**
257
+ * Prepend `/@id/` and replace null byte so the id is URL-safe.
258
+ * This is prepended to resolved ids that are not valid browser
259
+ * import specifiers by the importAnalysis plugin.
260
+ */
261
+ function wrapId$1(id) {
262
+ return id.startsWith(VALID_ID_PREFIX)
263
+ ? id
264
+ : VALID_ID_PREFIX + id.replace('\0', NULL_BYTE_PLACEHOLDER);
265
+ }
266
+ /**
267
+ * Undo {@link wrapId}'s `/@id/` and null byte replacements.
268
+ */
269
+ function unwrapId$1(id) {
270
+ return id.startsWith(VALID_ID_PREFIX)
271
+ ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, '\0')
272
+ : id;
273
+ }
274
+ const windowsSlashRE = /\\/g;
275
+ function slash$1(p) {
276
+ return p.replace(windowsSlashRE, '/');
277
+ }
278
+ const postfixRE = /[?#].*$/;
279
+ function cleanUrl(url) {
280
+ return url.replace(postfixRE, '');
281
+ }
282
+ function withTrailingSlash(path) {
283
+ if (path[path.length - 1] !== '/') {
284
+ return `${path}/`;
285
+ }
286
+ return path;
287
+ }
288
+
234
289
  // @ts-check
235
290
  /** @typedef { import('estree').BaseNode} BaseNode */
236
291
 
@@ -2883,7 +2938,7 @@ var old$1 = {};
2883
2938
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
2884
2939
 
2885
2940
  var pathModule = require$$0$4;
2886
- var isWindows$5 = process.platform === 'win32';
2941
+ var isWindows$4 = process.platform === 'win32';
2887
2942
  var fs$k = require$$0__default;
2888
2943
 
2889
2944
  // JavaScript implementation of realpath, ported from node pre-v6
@@ -2931,14 +2986,14 @@ function maybeCallback(cb) {
2931
2986
 
2932
2987
  // Regexp that finds the next partion of a (partial) path
2933
2988
  // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
2934
- if (isWindows$5) {
2989
+ if (isWindows$4) {
2935
2990
  var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
2936
2991
  } else {
2937
2992
  var nextPartRe = /(.*?)(?:[\/]+|$)/g;
2938
2993
  }
2939
2994
 
2940
2995
  // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
2941
- if (isWindows$5) {
2996
+ if (isWindows$4) {
2942
2997
  var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
2943
2998
  } else {
2944
2999
  var splitRootRe = /^[\/]*/;
@@ -2976,7 +3031,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
2976
3031
  previous = '';
2977
3032
 
2978
3033
  // On windows, check that the root exists. On unix there is no need.
2979
- if (isWindows$5 && !knownHard[base]) {
3034
+ if (isWindows$4 && !knownHard[base]) {
2980
3035
  fs$k.lstatSync(base);
2981
3036
  knownHard[base] = true;
2982
3037
  }
@@ -3014,7 +3069,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
3014
3069
  // read the link if it wasn't read before
3015
3070
  // dev/ino always return 0 on windows, so skip the check.
3016
3071
  var linkTarget = null;
3017
- if (!isWindows$5) {
3072
+ if (!isWindows$4) {
3018
3073
  var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
3019
3074
  if (seenLinks.hasOwnProperty(id)) {
3020
3075
  linkTarget = seenLinks[id];
@@ -3027,7 +3082,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
3027
3082
  resolvedLink = pathModule.resolve(previous, linkTarget);
3028
3083
  // track this, if given a cache.
3029
3084
  if (cache) cache[base] = resolvedLink;
3030
- if (!isWindows$5) seenLinks[id] = linkTarget;
3085
+ if (!isWindows$4) seenLinks[id] = linkTarget;
3031
3086
  }
3032
3087
 
3033
3088
  // resolve the link, then start over
@@ -3078,7 +3133,7 @@ old$1.realpath = function realpath(p, cache, cb) {
3078
3133
  previous = '';
3079
3134
 
3080
3135
  // On windows, check that the root exists. On unix there is no need.
3081
- if (isWindows$5 && !knownHard[base]) {
3136
+ if (isWindows$4 && !knownHard[base]) {
3082
3137
  fs$k.lstat(base, function(err) {
3083
3138
  if (err) return cb(err);
3084
3139
  knownHard[base] = true;
@@ -3132,7 +3187,7 @@ old$1.realpath = function realpath(p, cache, cb) {
3132
3187
  // stat & read the link if not read before
3133
3188
  // call gotTarget as soon as the link target is known
3134
3189
  // dev/ino always return 0 on windows, so skip the check.
3135
- if (!isWindows$5) {
3190
+ if (!isWindows$4) {
3136
3191
  var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
3137
3192
  if (seenLinks.hasOwnProperty(id)) {
3138
3193
  return gotTarget(null, seenLinks[id], base);
@@ -3142,7 +3197,7 @@ old$1.realpath = function realpath(p, cache, cb) {
3142
3197
  if (err) return cb(err);
3143
3198
 
3144
3199
  fs$k.readlink(base, function(err, target) {
3145
- if (!isWindows$5) seenLinks[id] = target;
3200
+ if (!isWindows$4) seenLinks[id] = target;
3146
3201
  gotTarget(err, target);
3147
3202
  });
3148
3203
  });
@@ -3230,10 +3285,10 @@ function unmonkeypatch () {
3230
3285
  fs$j.realpathSync = origRealpathSync;
3231
3286
  }
3232
3287
 
3233
- const isWindows$4 = typeof process === 'object' &&
3288
+ const isWindows$3 = typeof process === 'object' &&
3234
3289
  process &&
3235
3290
  process.platform === 'win32';
3236
- var path$k = isWindows$4 ? { sep: '\\' } : { sep: '/' };
3291
+ var path$k = isWindows$3 ? { sep: '\\' } : { sep: '/' };
3237
3292
 
3238
3293
  var balancedMatch = balanced$1;
3239
3294
  function balanced$1(a, b, str) {
@@ -7905,8 +7960,8 @@ function normalize (path) {
7905
7960
  }
7906
7961
 
7907
7962
  const isWrappedId = (id, suffix) => id.endsWith(suffix);
7908
- const wrapId$1 = (id, suffix) => `\0${id}${suffix}`;
7909
- const unwrapId$1 = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
7963
+ const wrapId = (id, suffix) => `\0${id}${suffix}`;
7964
+ const unwrapId = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
7910
7965
 
7911
7966
  const PROXY_SUFFIX = '?commonjs-proxy';
7912
7967
  const WRAPPED_SUFFIX = '?commonjs-wrapped';
@@ -8119,7 +8174,7 @@ function getResolveId(extensions, isPossibleCjsId) {
8119
8174
  }
8120
8175
 
8121
8176
  if (isWrappedId(importee, WRAPPED_SUFFIX)) {
8122
- return unwrapId$1(importee, WRAPPED_SUFFIX);
8177
+ return unwrapId(importee, WRAPPED_SUFFIX);
8123
8178
  }
8124
8179
 
8125
8180
  if (
@@ -8196,7 +8251,7 @@ function getResolveId(extensions, isPossibleCjsId) {
8196
8251
  return resolved.id + ENTRY_SUFFIX;
8197
8252
  }
8198
8253
  if (isCommonJS === IS_WRAPPED_COMMONJS) {
8199
- return { id: wrapId$1(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } };
8254
+ return { id: wrapId(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } };
8200
8255
  }
8201
8256
  }
8202
8257
  }
@@ -8371,11 +8426,11 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
8371
8426
  })) || resolveExtensions(source, parentId, extensions);
8372
8427
  currentlyResolvingForParent.delete(source);
8373
8428
  if (!resolved) {
8374
- return { id: wrapId$1(source, EXTERNAL_SUFFIX), allowProxy: false };
8429
+ return { id: wrapId(source, EXTERNAL_SUFFIX), allowProxy: false };
8375
8430
  }
8376
8431
  const childId = resolved.id;
8377
8432
  if (resolved.external) {
8378
- return { id: wrapId$1(childId, EXTERNAL_SUFFIX), allowProxy: false };
8433
+ return { id: wrapId(childId, EXTERNAL_SUFFIX), allowProxy: false };
8379
8434
  }
8380
8435
  parentMeta.requires.push({ resolved, isConditional });
8381
8436
  await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
@@ -8393,8 +8448,8 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
8393
8448
  source: sources[index].source,
8394
8449
  id: allowProxy
8395
8450
  ? isCommonJS === IS_WRAPPED_COMMONJS
8396
- ? wrapId$1(dependencyId, WRAPPED_SUFFIX)
8397
- : wrapId$1(dependencyId, PROXY_SUFFIX)
8451
+ ? wrapId(dependencyId, WRAPPED_SUFFIX)
8452
+ : wrapId(dependencyId, PROXY_SUFFIX)
8398
8453
  : dependencyId,
8399
8454
  isCommonJS
8400
8455
  };
@@ -8925,12 +8980,12 @@ function getRequireHandlers() {
8925
8980
  }
8926
8981
  if (exportMode === 'module') {
8927
8982
  imports.push(
8928
- `import { __module as ${moduleName} } from ${JSON.stringify(wrapId$1(id, MODULE_SUFFIX))}`,
8983
+ `import { __module as ${moduleName} } from ${JSON.stringify(wrapId(id, MODULE_SUFFIX))}`,
8929
8984
  `var ${exportsName} = ${moduleName}.exports`
8930
8985
  );
8931
8986
  } else if (exportMode === 'exports') {
8932
8987
  imports.push(
8933
- `import { __exports as ${exportsName} } from ${JSON.stringify(wrapId$1(id, EXPORTS_SUFFIX))}`
8988
+ `import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}`
8934
8989
  );
8935
8990
  }
8936
8991
  const requiresBySource = collectSources(requireExpressions);
@@ -9797,7 +9852,7 @@ function commonjs(options = {}) {
9797
9852
  }
9798
9853
 
9799
9854
  if (isWrappedId(id, MODULE_SUFFIX)) {
9800
- const name = getName(unwrapId$1(id, MODULE_SUFFIX));
9855
+ const name = getName(unwrapId(id, MODULE_SUFFIX));
9801
9856
  return {
9802
9857
  code: `var ${name} = {exports: {}}; export {${name} as __module}`,
9803
9858
  meta: { commonjs: { isCommonJS: false } }
@@ -9805,7 +9860,7 @@ function commonjs(options = {}) {
9805
9860
  }
9806
9861
 
9807
9862
  if (isWrappedId(id, EXPORTS_SUFFIX)) {
9808
- const name = getName(unwrapId$1(id, EXPORTS_SUFFIX));
9863
+ const name = getName(unwrapId(id, EXPORTS_SUFFIX));
9809
9864
  return {
9810
9865
  code: `var ${name} = {}; export {${name} as __exports}`,
9811
9866
  meta: { commonjs: { isCommonJS: false } }
@@ -9813,7 +9868,7 @@ function commonjs(options = {}) {
9813
9868
  }
9814
9869
 
9815
9870
  if (isWrappedId(id, EXTERNAL_SUFFIX)) {
9816
- const actualId = unwrapId$1(id, EXTERNAL_SUFFIX);
9871
+ const actualId = unwrapId(id, EXTERNAL_SUFFIX);
9817
9872
  return getUnknownRequireProxy(
9818
9873
  actualId,
9819
9874
  isEsmExternal(actualId) ? getRequireReturnsDefault(actualId) : true
@@ -9836,7 +9891,7 @@ function commonjs(options = {}) {
9836
9891
  }
9837
9892
 
9838
9893
  if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
9839
- const actualId = unwrapId$1(id, ES_IMPORT_SUFFIX);
9894
+ const actualId = unwrapId(id, ES_IMPORT_SUFFIX);
9840
9895
  return getEsImportProxy(actualId, getDefaultIsModuleExports(actualId));
9841
9896
  }
9842
9897
 
@@ -9850,7 +9905,7 @@ function commonjs(options = {}) {
9850
9905
  }
9851
9906
 
9852
9907
  if (isWrappedId(id, PROXY_SUFFIX)) {
9853
- const actualId = unwrapId$1(id, PROXY_SUFFIX);
9908
+ const actualId = unwrapId(id, PROXY_SUFFIX);
9854
9909
  return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load);
9855
9910
  }
9856
9911
 
@@ -9896,16 +9951,6 @@ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#
9896
9951
  * 4. Hash, including "#", optional.
9897
9952
  */
9898
9953
  const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
9899
- var UrlType;
9900
- (function (UrlType) {
9901
- UrlType[UrlType["Empty"] = 1] = "Empty";
9902
- UrlType[UrlType["Hash"] = 2] = "Hash";
9903
- UrlType[UrlType["Query"] = 3] = "Query";
9904
- UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
9905
- UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
9906
- UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
9907
- UrlType[UrlType["Absolute"] = 7] = "Absolute";
9908
- })(UrlType || (UrlType = {}));
9909
9954
  function isAbsoluteUrl(input) {
9910
9955
  return schemeRegex.test(input);
9911
9956
  }
@@ -9939,21 +9984,21 @@ function makeUrl(scheme, user, host, port, path, query, hash) {
9939
9984
  path,
9940
9985
  query,
9941
9986
  hash,
9942
- type: UrlType.Absolute,
9987
+ type: 7 /* Absolute */,
9943
9988
  };
9944
9989
  }
9945
9990
  function parseUrl$2(input) {
9946
9991
  if (isSchemeRelativeUrl(input)) {
9947
9992
  const url = parseAbsoluteUrl('http:' + input);
9948
9993
  url.scheme = '';
9949
- url.type = UrlType.SchemeRelative;
9994
+ url.type = 6 /* SchemeRelative */;
9950
9995
  return url;
9951
9996
  }
9952
9997
  if (isAbsolutePath(input)) {
9953
9998
  const url = parseAbsoluteUrl('http://foo.com' + input);
9954
9999
  url.scheme = '';
9955
10000
  url.host = '';
9956
- url.type = UrlType.AbsolutePath;
10001
+ url.type = 5 /* AbsolutePath */;
9957
10002
  return url;
9958
10003
  }
9959
10004
  if (isFileUrl(input))
@@ -9965,11 +10010,11 @@ function parseUrl$2(input) {
9965
10010
  url.host = '';
9966
10011
  url.type = input
9967
10012
  ? input.startsWith('?')
9968
- ? UrlType.Query
10013
+ ? 3 /* Query */
9969
10014
  : input.startsWith('#')
9970
- ? UrlType.Hash
9971
- : UrlType.RelativePath
9972
- : UrlType.Empty;
10015
+ ? 2 /* Hash */
10016
+ : 4 /* RelativePath */
10017
+ : 1 /* Empty */;
9973
10018
  return url;
9974
10019
  }
9975
10020
  function stripPathFilename(path) {
@@ -9997,7 +10042,7 @@ function mergePaths(url, base) {
9997
10042
  * "foo/.". We need to normalize to a standard representation.
9998
10043
  */
9999
10044
  function normalizePath$4(url, type) {
10000
- const rel = type <= UrlType.RelativePath;
10045
+ const rel = type <= 4 /* RelativePath */;
10001
10046
  const pieces = url.path.split('/');
10002
10047
  // We need to preserve the first piece always, so that we output a leading slash. The item at
10003
10048
  // pieces[0] is an empty string.
@@ -10058,27 +10103,27 @@ function resolve$2(input, base) {
10058
10103
  return '';
10059
10104
  const url = parseUrl$2(input);
10060
10105
  let inputType = url.type;
10061
- if (base && inputType !== UrlType.Absolute) {
10106
+ if (base && inputType !== 7 /* Absolute */) {
10062
10107
  const baseUrl = parseUrl$2(base);
10063
10108
  const baseType = baseUrl.type;
10064
10109
  switch (inputType) {
10065
- case UrlType.Empty:
10110
+ case 1 /* Empty */:
10066
10111
  url.hash = baseUrl.hash;
10067
10112
  // fall through
10068
- case UrlType.Hash:
10113
+ case 2 /* Hash */:
10069
10114
  url.query = baseUrl.query;
10070
10115
  // fall through
10071
- case UrlType.Query:
10072
- case UrlType.RelativePath:
10116
+ case 3 /* Query */:
10117
+ case 4 /* RelativePath */:
10073
10118
  mergePaths(url, baseUrl);
10074
10119
  // fall through
10075
- case UrlType.AbsolutePath:
10120
+ case 5 /* AbsolutePath */:
10076
10121
  // The host, user, and port are joined, you can't copy one without the others.
10077
10122
  url.user = baseUrl.user;
10078
10123
  url.host = baseUrl.host;
10079
10124
  url.port = baseUrl.port;
10080
10125
  // fall through
10081
- case UrlType.SchemeRelative:
10126
+ case 6 /* SchemeRelative */:
10082
10127
  // The input doesn't have a schema at least, so we need to copy at least that over.
10083
10128
  url.scheme = baseUrl.scheme;
10084
10129
  }
@@ -10090,10 +10135,10 @@ function resolve$2(input, base) {
10090
10135
  switch (inputType) {
10091
10136
  // This is impossible, because of the empty checks at the start of the function.
10092
10137
  // case UrlType.Empty:
10093
- case UrlType.Hash:
10094
- case UrlType.Query:
10138
+ case 2 /* Hash */:
10139
+ case 3 /* Query */:
10095
10140
  return queryHash;
10096
- case UrlType.RelativePath: {
10141
+ case 4 /* RelativePath */: {
10097
10142
  // The first char is always a "/", and we need it to be relative.
10098
10143
  const path = url.path.slice(1);
10099
10144
  if (!path)
@@ -10106,7 +10151,7 @@ function resolve$2(input, base) {
10106
10151
  }
10107
10152
  return path + queryHash;
10108
10153
  }
10109
- case UrlType.AbsolutePath:
10154
+ case 5 /* AbsolutePath */:
10110
10155
  return url.path + queryHash;
10111
10156
  default:
10112
10157
  return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
@@ -10261,21 +10306,6 @@ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
10261
10306
  const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
10262
10307
  const LEAST_UPPER_BOUND = -1;
10263
10308
  const GREATEST_LOWER_BOUND = 1;
10264
- /**
10265
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
10266
- */
10267
- let decodedMappings;
10268
- /**
10269
- * A low-level API to find the segment associated with a generated line/column (think, from a
10270
- * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
10271
- */
10272
- let traceSegment;
10273
- /**
10274
- * A higher-level API to find the source/line/column associated with a generated line/column
10275
- * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
10276
- * `source-map` library.
10277
- */
10278
- let originalPositionFor$1;
10279
10309
  class TraceMap {
10280
10310
  constructor(map, mapUrl) {
10281
10311
  const isString = typeof map === 'string';
@@ -10305,42 +10335,61 @@ class TraceMap {
10305
10335
  this._bySourceMemos = undefined;
10306
10336
  }
10307
10337
  }
10308
- (() => {
10309
- decodedMappings = (map) => {
10310
- return (map._decoded || (map._decoded = decode(map._encoded)));
10311
- };
10312
- traceSegment = (map, line, column) => {
10313
- const decoded = decodedMappings(map);
10314
- // It's common for parent source maps to have pointers to lines that have no
10315
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
10316
- if (line >= decoded.length)
10317
- return null;
10318
- const segments = decoded[line];
10319
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, GREATEST_LOWER_BOUND);
10320
- return index === -1 ? null : segments[index];
10321
- };
10322
- originalPositionFor$1 = (map, { line, column, bias }) => {
10323
- line--;
10324
- if (line < 0)
10325
- throw new Error(LINE_GTR_ZERO);
10326
- if (column < 0)
10327
- throw new Error(COL_GTR_EQ_ZERO);
10328
- const decoded = decodedMappings(map);
10329
- // It's common for parent source maps to have pointers to lines that have no
10330
- // mapping (like a "//# sourceMappingURL=") at the end of the child file.
10331
- if (line >= decoded.length)
10332
- return OMapping(null, null, null, null);
10333
- const segments = decoded[line];
10334
- const index = traceSegmentInternal(segments, map._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
10335
- if (index === -1)
10336
- return OMapping(null, null, null, null);
10337
- const segment = segments[index];
10338
- if (segment.length === 1)
10339
- return OMapping(null, null, null, null);
10340
- const { names, resolvedSources } = map;
10341
- return OMapping(resolvedSources[segment[SOURCES_INDEX$1]], segment[SOURCE_LINE$1] + 1, segment[SOURCE_COLUMN$1], segment.length === 5 ? names[segment[NAMES_INDEX$1]] : null);
10342
- };
10343
- })();
10338
+ /**
10339
+ * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
10340
+ * with public access modifiers.
10341
+ */
10342
+ function cast(map) {
10343
+ return map;
10344
+ }
10345
+ /**
10346
+ * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
10347
+ */
10348
+ function decodedMappings(map) {
10349
+ var _a;
10350
+ return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
10351
+ }
10352
+ /**
10353
+ * A low-level API to find the segment associated with a generated line/column (think, from a
10354
+ * stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
10355
+ */
10356
+ function traceSegment(map, line, column) {
10357
+ const decoded = decodedMappings(map);
10358
+ // It's common for parent source maps to have pointers to lines that have no
10359
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
10360
+ if (line >= decoded.length)
10361
+ return null;
10362
+ const segments = decoded[line];
10363
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
10364
+ return index === -1 ? null : segments[index];
10365
+ }
10366
+ /**
10367
+ * A higher-level API to find the source/line/column associated with a generated line/column
10368
+ * (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
10369
+ * `source-map` library.
10370
+ */
10371
+ function originalPositionFor$1(map, needle) {
10372
+ let { line, column, bias } = needle;
10373
+ line--;
10374
+ if (line < 0)
10375
+ throw new Error(LINE_GTR_ZERO);
10376
+ if (column < 0)
10377
+ throw new Error(COL_GTR_EQ_ZERO);
10378
+ const decoded = decodedMappings(map);
10379
+ // It's common for parent source maps to have pointers to lines that have no
10380
+ // mapping (like a "//# sourceMappingURL=") at the end of the child file.
10381
+ if (line >= decoded.length)
10382
+ return OMapping(null, null, null, null);
10383
+ const segments = decoded[line];
10384
+ const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
10385
+ if (index === -1)
10386
+ return OMapping(null, null, null, null);
10387
+ const segment = segments[index];
10388
+ if (segment.length === 1)
10389
+ return OMapping(null, null, null, null);
10390
+ const { names, resolvedSources } = map;
10391
+ return OMapping(resolvedSources[segment[SOURCES_INDEX$1]], segment[SOURCE_LINE$1] + 1, segment[SOURCE_COLUMN$1], segment.length === 5 ? names[segment[NAMES_INDEX$1]] : null);
10392
+ }
10344
10393
  function OMapping(source, line, column, name) {
10345
10394
  return { source, line, column, name };
10346
10395
  }
@@ -12000,28 +12049,6 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
12000
12049
  }
12001
12050
 
12002
12051
  const createFilter = createFilter$1;
12003
- const windowsSlashRE = /\\/g;
12004
- function slash$1(p) {
12005
- return p.replace(windowsSlashRE, '/');
12006
- }
12007
- /**
12008
- * Prepend `/@id/` and replace null byte so the id is URL-safe.
12009
- * This is prepended to resolved ids that are not valid browser
12010
- * import specifiers by the importAnalysis plugin.
12011
- */
12012
- function wrapId(id) {
12013
- return id.startsWith(VALID_ID_PREFIX)
12014
- ? id
12015
- : VALID_ID_PREFIX + id.replace('\0', NULL_BYTE_PLACEHOLDER);
12016
- }
12017
- /**
12018
- * Undo {@link wrapId}'s `/@id/` and null byte replacements.
12019
- */
12020
- function unwrapId(id) {
12021
- return id.startsWith(VALID_ID_PREFIX)
12022
- ? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, '\0')
12023
- : id;
12024
- }
12025
12052
  const replaceSlashOrColonRE = /[/:]/g;
12026
12053
  const replaceDotRE = /\./g;
12027
12054
  const replaceNestedIdRE = /(\s*>\s*)/g;
@@ -12125,10 +12152,9 @@ const urlCanParse = URL$3.canParse ??
12125
12152
  }
12126
12153
  });
12127
12154
  const isCaseInsensitiveFS = testCaseInsensitiveFS();
12128
- const isWindows$3 = os$4.platform() === 'win32';
12129
12155
  const VOLUME_RE = /^[A-Z]:/i;
12130
12156
  function normalizePath$3(id) {
12131
- return path$o.posix.normalize(isWindows$3 ? slash$1(id) : id);
12157
+ return path$o.posix.normalize(isWindows$5 ? slash$1(id) : id);
12132
12158
  }
12133
12159
  function fsPathFromId(id) {
12134
12160
  const fsPath = normalizePath$3(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
@@ -12137,12 +12163,6 @@ function fsPathFromId(id) {
12137
12163
  function fsPathFromUrl(url) {
12138
12164
  return fsPathFromId(cleanUrl(url));
12139
12165
  }
12140
- function withTrailingSlash(path) {
12141
- if (path[path.length - 1] !== '/') {
12142
- return `${path}/`;
12143
- }
12144
- return path;
12145
- }
12146
12166
  /**
12147
12167
  * Check if dir is a parent of file
12148
12168
  *
@@ -12170,10 +12190,6 @@ function isSameFileUri(file1, file2) {
12170
12190
  return (file1 === file2 ||
12171
12191
  (isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase()));
12172
12192
  }
12173
- const postfixRE = /[?#].*$/;
12174
- function cleanUrl(url) {
12175
- return url.replace(postfixRE, '');
12176
- }
12177
12193
  const externalRE = /^(https?:)?\/\//;
12178
12194
  const isExternalUrl = (url) => externalRE.test(url);
12179
12195
  const dataUrlRE = /^\s*data:/i;
@@ -12223,7 +12239,7 @@ function injectQuery(url, queryToInject) {
12223
12239
  const resolvedUrl = new URL$3(url.replace(replacePercentageRE, '%25'), 'relative:///');
12224
12240
  const { search, hash } = resolvedUrl;
12225
12241
  let pathname = cleanUrl(url);
12226
- pathname = isWindows$3 ? slash$1(pathname) : pathname;
12242
+ pathname = isWindows$5 ? slash$1(pathname) : pathname;
12227
12243
  return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash ?? ''}`;
12228
12244
  }
12229
12245
  const timestampRE = /\bt=\d{13}&?\b/;
@@ -12489,7 +12505,7 @@ async function recursiveReaddir(dir) {
12489
12505
  // `fs.realpathSync.native` resolves differently in Windows network drive,
12490
12506
  // causing file read errors. skip for now.
12491
12507
  // https://github.com/nodejs/node/issues/37737
12492
- let safeRealpathSync = isWindows$3
12508
+ let safeRealpathSync = isWindows$5
12493
12509
  ? windowsSafeRealPathSync
12494
12510
  : fs$l.realpathSync.native;
12495
12511
  // Based on https://github.com/larrybahr/windows-network-drive
@@ -12943,7 +12959,7 @@ const windowsDrivePathPrefixRE = /^[A-Za-z]:[/\\]/;
12943
12959
  * this function returns false for them but true for absolute paths (e.g. C:/something)
12944
12960
  */
12945
12961
  const isNonDriveRelativeAbsolutePath = (p) => {
12946
- if (!isWindows$3)
12962
+ if (!isWindows$5)
12947
12963
  return p[0] === '/';
12948
12964
  return windowsDrivePathPrefixRE.test(p);
12949
12965
  };
@@ -29594,7 +29610,7 @@ function stripLiteralDetailed(code, options) {
29594
29610
  var main$1 = {exports: {}};
29595
29611
 
29596
29612
  var name = "dotenv";
29597
- var version$2 = "16.4.4";
29613
+ var version$2 = "16.4.5";
29598
29614
  var description = "Loads environment variables from .env file";
29599
29615
  var main = "lib/main.js";
29600
29616
  var types$2 = "lib/main.d.ts";
@@ -29891,52 +29907,48 @@ function configDotenv (options) {
29891
29907
  }
29892
29908
  }
29893
29909
 
29894
- let optionPathsThatExist = [];
29910
+ let optionPaths = [dotenvPath]; // default, look for .env
29895
29911
  if (options && options.path) {
29896
29912
  if (!Array.isArray(options.path)) {
29897
- if (fs$9.existsSync(options.path)) {
29898
- optionPathsThatExist = [_resolveHome(options.path)];
29899
- }
29913
+ optionPaths = [_resolveHome(options.path)];
29900
29914
  } else {
29915
+ optionPaths = []; // reset default
29901
29916
  for (const filepath of options.path) {
29902
- if (fs$9.existsSync(filepath)) {
29903
- optionPathsThatExist.push(_resolveHome(filepath));
29904
- }
29917
+ optionPaths.push(_resolveHome(filepath));
29905
29918
  }
29906
29919
  }
29907
-
29908
- if (!optionPathsThatExist.length) {
29909
- optionPathsThatExist = [dotenvPath];
29910
- }
29911
29920
  }
29912
29921
 
29913
- // If we have options.path, and it had valid paths, use them. Else fall back to .env
29914
- const pathsToProcess = optionPathsThatExist.length ? optionPathsThatExist : [dotenvPath];
29915
-
29916
29922
  // Build the parsed data in a temporary object (because we need to return it). Once we have the final
29917
29923
  // parsed data, we will combine it with process.env (or options.processEnv if provided).
29918
-
29919
- const parsed = {};
29920
- try {
29921
- for (const path of pathsToProcess) {
29924
+ let lastError;
29925
+ const parsedAll = {};
29926
+ for (const path of optionPaths) {
29927
+ try {
29922
29928
  // Specifying an encoding returns a string instead of a buffer
29923
- const singleFileParsed = DotenvModule.parse(fs$9.readFileSync(path, { encoding }));
29924
- DotenvModule.populate(parsed, singleFileParsed, options);
29925
- }
29929
+ const parsed = DotenvModule.parse(fs$9.readFileSync(path, { encoding }));
29926
29930
 
29927
- let processEnv = process.env;
29928
- if (options && options.processEnv != null) {
29929
- processEnv = options.processEnv;
29931
+ DotenvModule.populate(parsedAll, parsed, options);
29932
+ } catch (e) {
29933
+ if (debug) {
29934
+ _debug(`Failed to load ${path} ${e.message}`);
29935
+ }
29936
+ lastError = e;
29930
29937
  }
29938
+ }
29931
29939
 
29932
- DotenvModule.populate(processEnv, parsed, options);
29933
- } catch (e) {
29934
- if (debug) {
29935
- _debug(`Failed to load ${pathsToProcess} ${e.message}`);
29936
- }
29937
- return { error: e }
29940
+ let processEnv = process.env;
29941
+ if (options && options.processEnv != null) {
29942
+ processEnv = options.processEnv;
29943
+ }
29944
+
29945
+ DotenvModule.populate(processEnv, parsedAll, options);
29946
+
29947
+ if (lastError) {
29948
+ return { parsed: parsedAll, error: lastError }
29949
+ } else {
29950
+ return { parsed: parsedAll }
29938
29951
  }
29939
- return { parsed }
29940
29952
  }
29941
29953
 
29942
29954
  // Populates process.env from .env file
@@ -32094,8 +32106,8 @@ function createCachedImport(imp) {
32094
32106
  return cached;
32095
32107
  };
32096
32108
  }
32097
- const importPostcssImport = createCachedImport(() => import('./dep-wALyWXZB.js').then(function (n) { return n.i; }));
32098
- const importPostcssModules = createCachedImport(() => import('./dep-g6LmopN4.js').then(function (n) { return n.i; }));
32109
+ const importPostcssImport = createCachedImport(() => import('./dep-OHeF5w5D.js').then(function (n) { return n.i; }));
32110
+ const importPostcssModules = createCachedImport(() => import('./dep-WMYkPWs9.js').then(function (n) { return n.i; }));
32099
32111
  const importPostcss = createCachedImport(() => import('postcss'));
32100
32112
  const preprocessorWorkerControllerCache = new WeakMap();
32101
32113
  let alwaysFakeWorkerWorkerControllerCache;
@@ -39117,7 +39129,7 @@ function matchAll$1(regex, string, addition) {
39117
39129
  ...match.groups,
39118
39130
  code: match[0],
39119
39131
  start: match.index,
39120
- end: match.index + match[0].length
39132
+ end: (match.index || 0) + match[0].length
39121
39133
  });
39122
39134
  }
39123
39135
  return matches;
@@ -39622,7 +39634,6 @@ function determineSpecificType(value) {
39622
39634
 
39623
39635
  return `type ${typeof value} (${inspected})`
39624
39636
  }
39625
- pathToFileURL(process.cwd());
39626
39637
 
39627
39638
  const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;|\})import\s*([\s"']*(?<imports>[\p{L}\p{M}\w\t\n\r $*,/{}@.]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^\s"](?=\s*")|(?<='\s*)[^']*[^\s'](?=\s*'))\s*["'][\s;]*/gmu;
39628
39639
  const TYPE_RE = /^\s*?type\s/;
@@ -39635,8 +39646,11 @@ function findStaticImports(code) {
39635
39646
  function parseStaticImport(matched) {
39636
39647
  const cleanedImports = clearImports(matched.imports);
39637
39648
  const namedImports = {};
39638
- for (const namedImport of cleanedImports.match(/{([^}]*)}/)?.[1]?.split(",") || []) {
39639
- const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*(\S*) as (\S*)\s*$/) || [];
39649
+ const _matches = cleanedImports.match(/{([^}]*)}/)?.[1]?.split(",") || [];
39650
+ for (const namedImport of _matches) {
39651
+ const _match = namedImport.match(/^\s*(\S*) as (\S*)\s*$/);
39652
+ const source = _match?.[1] || namedImport.trim();
39653
+ const importName = _match?.[2] || source;
39640
39654
  if (source && !TYPE_RE.test(source)) {
39641
39655
  namedImports[source] = importName;
39642
39656
  }
@@ -47527,7 +47541,7 @@ function resolvePlugin(resolveOptions) {
47527
47541
  }
47528
47542
  }
47529
47543
  // drive relative fs paths (only windows)
47530
- if (isWindows$3 && id[0] === '/') {
47544
+ if (isWindows$5 && id[0] === '/') {
47531
47545
  const basedir = importer ? path$o.dirname(importer) : process.cwd();
47532
47546
  const fsPath = path$o.resolve(basedir, id);
47533
47547
  if ((res = tryFsResolve(fsPath, options))) {
@@ -47638,14 +47652,16 @@ function resolveSubpathImports(id, importer, options, targetWeb) {
47638
47652
  const pkgData = findNearestPackageData(basedir, options.packageCache);
47639
47653
  if (!pkgData)
47640
47654
  return;
47641
- let importsPath = resolveExportsOrImports(pkgData.data, id, options, targetWeb, 'imports');
47655
+ let { file: idWithoutPostfix, postfix } = splitFileAndPostfix(id.slice(1));
47656
+ idWithoutPostfix = '#' + idWithoutPostfix;
47657
+ let importsPath = resolveExportsOrImports(pkgData.data, idWithoutPostfix, options, targetWeb, 'imports');
47642
47658
  if (importsPath?.[0] === '.') {
47643
47659
  importsPath = path$o.relative(basedir, path$o.join(pkgData.dir, importsPath));
47644
47660
  if (importsPath[0] !== '.') {
47645
47661
  importsPath = `./${importsPath}`;
47646
47662
  }
47647
47663
  }
47648
- return importsPath;
47664
+ return importsPath + postfix;
47649
47665
  }
47650
47666
  function ensureVersionQuery(resolved, id, options, depsOptimizer) {
47651
47667
  if (!options.isBuild &&
@@ -50464,7 +50480,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
50464
50480
  }
50465
50481
  async load(options) {
50466
50482
  // We may not have added this to our module graph yet, so ensure it exists
50467
- await moduleGraph?.ensureEntryFromUrl(unwrapId(options.id), this.ssr);
50483
+ await moduleGraph?.ensureEntryFromUrl(unwrapId$1(options.id), this.ssr);
50468
50484
  // Not all options passed to this function make sense in the context of loading individual files,
50469
50485
  // but we can at least update the module info properties we support
50470
50486
  updateModuleInfo(options.id, options);
@@ -51019,6 +51035,18 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
51019
51035
  return;
51020
51036
  const plugin = esbuildScanPlugin(config, container, deps, missing, entries);
51021
51037
  const { plugins = [], ...esbuildOptions } = config.optimizeDeps?.esbuildOptions ?? {};
51038
+ // The plugin pipeline automatically loads the closest tsconfig.json.
51039
+ // But esbuild doesn't support reading tsconfig.json if the plugin has resolved the path (https://github.com/evanw/esbuild/issues/2265).
51040
+ // Due to syntax incompatibilities between the experimental decorators in TypeScript and TC39 decorators,
51041
+ // we cannot simply set `"experimentalDecorators": true` or `false`. (https://github.com/vitejs/vite/pull/15206#discussion_r1417414715)
51042
+ // Therefore, we use the closest tsconfig.json from the root to make it work in most cases.
51043
+ let tsconfigRaw = esbuildOptions.tsconfigRaw;
51044
+ if (!tsconfigRaw && !esbuildOptions.tsconfig) {
51045
+ const tsconfigResult = await loadTsconfigJsonForFile(path$o.join(config.root, '_dummy.js'));
51046
+ if (tsconfigResult.compilerOptions?.experimentalDecorators) {
51047
+ tsconfigRaw = { compilerOptions: { experimentalDecorators: true } };
51048
+ }
51049
+ }
51022
51050
  return await esbuild.context({
51023
51051
  absWorkingDir: process.cwd(),
51024
51052
  write: false,
@@ -51031,6 +51059,7 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
51031
51059
  logLevel: 'silent',
51032
51060
  plugins: [...plugins, plugin],
51033
51061
  ...esbuildOptions,
51062
+ tsconfigRaw,
51034
51063
  });
51035
51064
  }
51036
51065
  function orderedDependencies(deps) {
@@ -51040,6 +51069,10 @@ function orderedDependencies(deps) {
51040
51069
  return Object.fromEntries(depsList);
51041
51070
  }
51042
51071
  function globEntries(pattern, config) {
51072
+ const resolvedPatterns = arraify(pattern);
51073
+ if (resolvedPatterns.every((str) => !glob.isDynamicPattern(str))) {
51074
+ return resolvedPatterns.map((p) => normalizePath$3(path$o.resolve(config.root, p)));
51075
+ }
51043
51076
  return glob(pattern, {
51044
51077
  cwd: config.root,
51045
51078
  ignore: [
@@ -52359,7 +52392,7 @@ function runOptimizeDeps(resolvedConfig, depsInfo, ssr) {
52359
52392
  // is safer than a delete-rename operation.
52360
52393
  const temporaryPath = depsCacheDir + getTempSuffix();
52361
52394
  const depsCacheDirPresent = fs$l.existsSync(depsCacheDir);
52362
- if (isWindows$3) {
52395
+ if (isWindows$5) {
52363
52396
  if (depsCacheDirPresent) {
52364
52397
  debug$7?.(colors$1.green(`renaming ${depsCacheDir} to ${temporaryPath}`));
52365
52398
  await safeRename(depsCacheDir, temporaryPath);
@@ -53341,7 +53374,7 @@ function serveRawFsMiddleware(server) {
53341
53374
  return;
53342
53375
  }
53343
53376
  let newPathname = pathname.slice(FS_PREFIX.length);
53344
- if (isWindows$3)
53377
+ if (isWindows$5)
53345
53378
  newPathname = newPathname.replace(/^[A-Z]:/i, '');
53346
53379
  url.pathname = encodeURI(newPathname);
53347
53380
  req.url = url.href.slice(url.origin.length);
@@ -53716,7 +53749,7 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, server) {
53716
53749
  }
53717
53750
  const urlWithoutTimestamp = removeTimestampQuery(rawUrl);
53718
53751
  // hmrUrl must be derived the same way as importAnalysis
53719
- const hmrUrl = unwrapId(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
53752
+ const hmrUrl = unwrapId$1(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
53720
53753
  for (const importedMod of mod.clientImportedModules) {
53721
53754
  if (importedMod.url !== hmrUrl)
53722
53755
  continue;
@@ -54590,7 +54623,7 @@ const pendingModules = new Map();
54590
54623
  const pendingImports = new Map();
54591
54624
  const importErrors = new WeakMap();
54592
54625
  async function ssrLoadModule(url, server, context = { global }, urlStack = [], fixStacktrace) {
54593
- url = unwrapId(url);
54626
+ url = unwrapId$1(url);
54594
54627
  // when we instantiate multiple dependency modules in parallel, they may
54595
54628
  // point to shared modules. We need to avoid duplicate instantiation attempts
54596
54629
  // by register every module as pending synchronously so that all subsequent
@@ -54663,7 +54696,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
54663
54696
  return await nodeImport(dep, mod.file, resolveOptions, metadata);
54664
54697
  }
54665
54698
  // convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
54666
- dep = unwrapId(dep);
54699
+ dep = unwrapId$1(dep);
54667
54700
  if (!isCircular(dep) && !pendingImports.get(dep)?.some(isCircular)) {
54668
54701
  pendingDeps.push(dep);
54669
54702
  if (pendingDeps.length === 1) {
@@ -56207,7 +56240,7 @@ async function fetchModule(server, url, importer, options = {}) {
56207
56240
  : 'commonjs';
56208
56241
  return { externalize: file, type };
56209
56242
  }
56210
- url = unwrapId(url);
56243
+ url = unwrapId$1(url);
56211
56244
  let result = await server.transformRequest(url, { ssr: true });
56212
56245
  if (!result) {
56213
56246
  throw new Error(`[vite] transform failed for module '${url}'${importer ? ` imported from '${importer}'` : ''}.`);
@@ -56225,10 +56258,6 @@ async function fetchModule(server, url, importer, options = {}) {
56225
56258
  result.code = result.code.replace(/^#!.*/, (s) => ' '.repeat(s.length));
56226
56259
  return { code: result.code, file: mod.file };
56227
56260
  }
56228
- let SOURCEMAPPING_URL = 'sourceMa';
56229
- SOURCEMAPPING_URL += 'ppingURL';
56230
- const VITE_RUNTIME_SOURCEMAPPING_SOURCE = '//# sourceMappingSource=vite-runtime';
56231
- const VITE_RUNTIME_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
56232
56261
  const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm');
56233
56262
  function inlineSourceMap(mod, result, processSourceMap) {
56234
56263
  const map = result.map;
@@ -63386,7 +63415,7 @@ function transformMiddleware(server) {
63386
63415
  url = removeImportQuery(url);
63387
63416
  // Strip valid id prefix. This is prepended to resolved Ids that are
63388
63417
  // not valid browser import specifiers by the importAnalysis plugin.
63389
- url = unwrapId(url);
63418
+ url = unwrapId$1(url);
63390
63419
  // for CSS, we differentiate between normal CSS requests and imports
63391
63420
  if (isCSSRequest(url)) {
63392
63421
  if (req.headers.accept?.includes('text/css') &&
@@ -63595,7 +63624,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
63595
63624
  // and ids are properly handled
63596
63625
  const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}`;
63597
63626
  proxyModulePath = `\0${validPath}`;
63598
- proxyModuleUrl = wrapId(proxyModulePath);
63627
+ proxyModuleUrl = wrapId$1(proxyModulePath);
63599
63628
  }
63600
63629
  const s = new MagicString(html);
63601
63630
  let inlineModuleIndex = -1;
@@ -63774,7 +63803,7 @@ function preTransformRequest(server, url, base) {
63774
63803
  return;
63775
63804
  // transform all url as non-ssr as html includes client-side assets only
63776
63805
  try {
63777
- url = unwrapId(stripBase(decodeURI(url), base));
63806
+ url = unwrapId$1(stripBase(decodeURI(url), base));
63778
63807
  }
63779
63808
  catch {
63780
63809
  // ignore
@@ -64867,6 +64896,7 @@ async function handleHMRUpdate(file, server, configOnly) {
64867
64896
  hot.send({
64868
64897
  type: 'full-reload',
64869
64898
  path: '*',
64899
+ triggeredBy: path$o.resolve(config.root, file),
64870
64900
  });
64871
64901
  return;
64872
64902
  }
@@ -64945,6 +64975,7 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
64945
64975
  config.logger.info(colors$1.green(`page reload `) + colors$1.dim(file) + reason, { clear: !afterInvalidation, timestamp: true });
64946
64976
  hot.send({
64947
64977
  type: 'full-reload',
64978
+ triggeredBy: path$o.resolve(config.root, file),
64948
64979
  });
64949
64980
  return;
64950
64981
  }
@@ -64959,7 +64990,7 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
64959
64990
  updates,
64960
64991
  });
64961
64992
  }
64962
- function populateSSRImporters(module, timestamp, seen) {
64993
+ function populateSSRImporters(module, timestamp, seen = new Set()) {
64963
64994
  module.ssrImportedModules.forEach((importer) => {
64964
64995
  if (seen.has(importer)) {
64965
64996
  return;
@@ -64973,9 +65004,7 @@ function populateSSRImporters(module, timestamp, seen) {
64973
65004
  return seen;
64974
65005
  }
64975
65006
  function getSSRInvalidatedImporters(module) {
64976
- return [
64977
- ...populateSSRImporters(module, module.lastHMRTimestamp, new Set()),
64978
- ].map((m) => m.file);
65007
+ return [...populateSSRImporters(module, module.lastHMRTimestamp)].map((m) => m.file);
64979
65008
  }
64980
65009
  async function handleFileAddUnlink(file, server, isUnlink) {
64981
65010
  const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
@@ -65285,7 +65314,7 @@ function lexAcceptedHmrExports(code, start, exportNames) {
65285
65314
  }
65286
65315
  function normalizeHmrUrl(url) {
65287
65316
  if (url[0] !== '.' && url[0] !== '/') {
65288
- url = wrapId(url);
65317
+ url = wrapId$1(url);
65289
65318
  }
65290
65319
  return url;
65291
65320
  }
@@ -65622,7 +65651,7 @@ function importAnalysisPlugin(config) {
65622
65651
  // prefix it to make it valid. We will strip this before feeding it
65623
65652
  // back into the transform pipeline
65624
65653
  if (url[0] !== '.' && url[0] !== '/') {
65625
- url = wrapId(resolved.id);
65654
+ url = wrapId$1(resolved.id);
65626
65655
  }
65627
65656
  // make the URL browser-valid if not SSR
65628
65657
  if (!ssr) {
@@ -65648,7 +65677,7 @@ function importAnalysisPlugin(config) {
65648
65677
  try {
65649
65678
  // delay setting `isSelfAccepting` until the file is actually used (#7870)
65650
65679
  // We use an internal function to avoid resolving the url again
65651
- const depModule = await moduleGraph._ensureEntryFromUrl(unwrapId(url), ssr, canSkipImportAnalysis(url) || forceSkipImportAnalysis, resolved);
65680
+ const depModule = await moduleGraph._ensureEntryFromUrl(unwrapId$1(url), ssr, canSkipImportAnalysis(url) || forceSkipImportAnalysis, resolved);
65652
65681
  if (depModule.lastHMRTimestamp > 0) {
65653
65682
  url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
65654
65683
  }
@@ -65717,7 +65746,7 @@ function importAnalysisPlugin(config) {
65717
65746
  }
65718
65747
  // static import or valid string in dynamic import
65719
65748
  // If resolvable, let's resolve it
65720
- if (specifier) {
65749
+ if (specifier !== undefined) {
65721
65750
  // skip external / data uri
65722
65751
  if (isExternalUrl(specifier) || isDataUrl(specifier)) {
65723
65752
  return;
@@ -65794,7 +65823,7 @@ function importAnalysisPlugin(config) {
65794
65823
  }
65795
65824
  // record for HMR import chain analysis
65796
65825
  // make sure to unwrap and normalize away base
65797
- const hmrUrl = unwrapId(stripBase(url, base));
65826
+ const hmrUrl = unwrapId$1(stripBase(url, base));
65798
65827
  const isLocalImport = !isExternalUrl(hmrUrl) && !isDataUrl(hmrUrl);
65799
65828
  if (isLocalImport) {
65800
65829
  orderedImportedUrls[index] = hmrUrl;
@@ -66357,12 +66386,14 @@ function buildImportAnalysisPlugin(config) {
66357
66386
  const chunk = bundle[filename];
66358
66387
  if (chunk) {
66359
66388
  deps.add(chunk.fileName);
66360
- chunk.imports.forEach(addDeps);
66361
- // Ensure that the css imported by current chunk is loaded after the dependencies.
66362
- // So the style of current chunk won't be overwritten unexpectedly.
66363
- chunk.viteMetadata.importedCss.forEach((file) => {
66364
- deps.add(file);
66365
- });
66389
+ if (chunk.type === 'chunk') {
66390
+ chunk.imports.forEach(addDeps);
66391
+ // Ensure that the css imported by current chunk is loaded after the dependencies.
66392
+ // So the style of current chunk won't be overwritten unexpectedly.
66393
+ chunk.viteMetadata.importedCss.forEach((file) => {
66394
+ deps.add(file);
66395
+ });
66396
+ }
66366
66397
  }
66367
66398
  else {
66368
66399
  const removedPureCssFiles = removedPureCssFilesCache.get(config);
@@ -66453,13 +66484,12 @@ function __vite__mapDeps(indexes) {
66453
66484
  }
66454
66485
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
66455
66486
  }\n`;
66456
- // inject extra code before sourcemap comment
66457
- const mapFileCommentMatch = convertSourceMap.mapFileCommentRegex.exec(code);
66458
- if (mapFileCommentMatch) {
66459
- s.appendRight(mapFileCommentMatch.index, mapDepsCode);
66487
+ // inject extra code at the top or next line of hashbang
66488
+ if (code.startsWith('#!')) {
66489
+ s.prependLeft(code.indexOf('\n') + 1, mapDepsCode);
66460
66490
  }
66461
66491
  else {
66462
- s.append(mapDepsCode);
66492
+ s.prepend(mapDepsCode);
66463
66493
  }
66464
66494
  // there may still be markers due to inlined dynamic imports, remove
66465
66495
  // all the markers regardless
@@ -68231,4 +68261,4 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
68231
68261
  }
68232
68262
  }
68233
68263
 
68234
- export { resolveEnvPrefix as A, getDefaultExportFromCjs as B, commonjsGlobal as C, index$1 as D, index as E, build$1 as F, preview$1 as G, createLogger as a, arraify as b, colors$1 as c, defineConfig as d, createServer as e, build as f, formatPostcssSourceMap as g, preprocessCSS as h, isInNodeModules$1 as i, buildErrorMessage as j, fetchModule as k, loadConfigFromFile as l, mergeConfig as m, normalizePath$3 as n, optimizeDeps as o, preview as p, mergeAlias as q, resolveConfig as r, sortUserPlugins as s, transformWithEsbuild as t, createFilter as u, rollupVersion as v, send as w, searchForWorkspaceRoot as x, isFileServingAllowed as y, loadEnv as z };
68264
+ export { colors$1 as A, getDefaultExportFromCjs as B, commonjsGlobal as C, index$1 as D, index as E, build$1 as F, preview$1 as G, arraify as a, build as b, createServer as c, defineConfig as d, preprocessCSS as e, formatPostcssSourceMap as f, buildErrorMessage as g, fetchModule as h, isInNodeModules$1 as i, mergeAlias as j, createFilter as k, loadConfigFromFile as l, mergeConfig as m, normalizePath$3 as n, optimizeDeps as o, preview as p, rollupVersion as q, resolveConfig as r, sortUserPlugins as s, transformWithEsbuild as t, send as u, createLogger as v, searchForWorkspaceRoot as w, isFileServingAllowed as x, loadEnv as y, resolveEnvPrefix as z };