vite 5.1.3 → 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 = /[?#].*$/s;
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
@@ -12566,7 +12582,9 @@ function ensureWatchedFile(watcher, file, root) {
12566
12582
  const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
12567
12583
  const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/;
12568
12584
  function joinSrcset(ret) {
12569
- return ret.map(({ url, descriptor }) => `${url} ${descriptor}`).join(', ');
12585
+ return ret
12586
+ .map(({ url, descriptor }) => url + (descriptor ? ` ${descriptor}` : ''))
12587
+ .join(', ');
12570
12588
  }
12571
12589
  function splitSrcSetDescriptor(srcs) {
12572
12590
  return splitSrcSet(srcs)
@@ -12941,7 +12959,7 @@ const windowsDrivePathPrefixRE = /^[A-Za-z]:[/\\]/;
12941
12959
  * this function returns false for them but true for absolute paths (e.g. C:/something)
12942
12960
  */
12943
12961
  const isNonDriveRelativeAbsolutePath = (p) => {
12944
- if (!isWindows$3)
12962
+ if (!isWindows$5)
12945
12963
  return p[0] === '/';
12946
12964
  return windowsDrivePathPrefixRE.test(p);
12947
12965
  };
@@ -29592,7 +29610,7 @@ function stripLiteralDetailed(code, options) {
29592
29610
  var main$1 = {exports: {}};
29593
29611
 
29594
29612
  var name = "dotenv";
29595
- var version$2 = "16.4.2";
29613
+ var version$2 = "16.4.5";
29596
29614
  var description = "Loads environment variables from .env file";
29597
29615
  var main = "lib/main.js";
29598
29616
  var types$2 = "lib/main.d.ts";
@@ -29616,6 +29634,7 @@ var scripts = {
29616
29634
  "lint-readme": "standard-markdown",
29617
29635
  pretest: "npm run lint && npm run dts-check",
29618
29636
  test: "tap tests/*.js --100 -Rspec",
29637
+ "test:coverage": "tap --coverage-report=lcov",
29619
29638
  prerelease: "npm test",
29620
29639
  release: "standard-version"
29621
29640
  };
@@ -29876,52 +29895,59 @@ function _configVault (options) {
29876
29895
  }
29877
29896
 
29878
29897
  function configDotenv (options) {
29879
- let dotenvPath = path$9.resolve(process.cwd(), '.env');
29898
+ const dotenvPath = path$9.resolve(process.cwd(), '.env');
29880
29899
  let encoding = 'utf8';
29881
29900
  const debug = Boolean(options && options.debug);
29882
29901
 
29883
- if (options) {
29884
- if (options.path != null) {
29885
- let envPath = options.path;
29886
-
29887
- if (Array.isArray(envPath)) {
29888
- for (const filepath of options.path) {
29889
- if (fs$9.existsSync(filepath)) {
29890
- envPath = filepath;
29891
- break
29892
- }
29893
- }
29894
- }
29895
-
29896
- dotenvPath = _resolveHome(envPath);
29902
+ if (options && options.encoding) {
29903
+ encoding = options.encoding;
29904
+ } else {
29905
+ if (debug) {
29906
+ _debug('No encoding is specified. UTF-8 is used by default');
29897
29907
  }
29898
- if (options.encoding != null) {
29899
- encoding = options.encoding;
29908
+ }
29909
+
29910
+ let optionPaths = [dotenvPath]; // default, look for .env
29911
+ if (options && options.path) {
29912
+ if (!Array.isArray(options.path)) {
29913
+ optionPaths = [_resolveHome(options.path)];
29900
29914
  } else {
29901
- if (debug) {
29902
- _debug('No encoding is specified. UTF-8 is used by default');
29915
+ optionPaths = []; // reset default
29916
+ for (const filepath of options.path) {
29917
+ optionPaths.push(_resolveHome(filepath));
29903
29918
  }
29904
29919
  }
29905
29920
  }
29906
29921
 
29907
- try {
29908
- // Specifying an encoding returns a string instead of a buffer
29909
- const parsed = DotenvModule.parse(fs$9.readFileSync(dotenvPath, { encoding }));
29922
+ // Build the parsed data in a temporary object (because we need to return it). Once we have the final
29923
+ // parsed data, we will combine it with process.env (or options.processEnv if provided).
29924
+ let lastError;
29925
+ const parsedAll = {};
29926
+ for (const path of optionPaths) {
29927
+ try {
29928
+ // Specifying an encoding returns a string instead of a buffer
29929
+ const parsed = DotenvModule.parse(fs$9.readFileSync(path, { encoding }));
29910
29930
 
29911
- let processEnv = process.env;
29912
- if (options && options.processEnv != null) {
29913
- 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;
29914
29937
  }
29938
+ }
29915
29939
 
29916
- DotenvModule.populate(processEnv, parsed, options);
29940
+ let processEnv = process.env;
29941
+ if (options && options.processEnv != null) {
29942
+ processEnv = options.processEnv;
29943
+ }
29917
29944
 
29918
- return { parsed }
29919
- } catch (e) {
29920
- if (debug) {
29921
- _debug(`Failed to load ${dotenvPath} ${e.message}`);
29922
- }
29945
+ DotenvModule.populate(processEnv, parsedAll, options);
29923
29946
 
29924
- return { error: e }
29947
+ if (lastError) {
29948
+ return { parsed: parsedAll, error: lastError }
29949
+ } else {
29950
+ return { parsed: parsedAll }
29925
29951
  }
29926
29952
  }
29927
29953
 
@@ -30048,11 +30074,21 @@ function interpolate (value, processEnv, parsed) {
30048
30074
  return match.slice(1)
30049
30075
  } else {
30050
30076
  if (processEnv[key]) {
30051
- return processEnv[key]
30077
+ if (processEnv[key] === parsed[key]) {
30078
+ return processEnv[key]
30079
+ } else {
30080
+ // scenario: PASSWORD_EXPAND_NESTED=${PASSWORD_EXPAND}
30081
+ return interpolate(processEnv[key], processEnv, parsed)
30082
+ }
30052
30083
  }
30053
30084
 
30054
30085
  if (parsed[key]) {
30055
- return parsed[key]
30086
+ // avoid recursion from EXPAND_SELF=$EXPAND_SELF
30087
+ if (parsed[key] === value) {
30088
+ return parsed[key]
30089
+ } else {
30090
+ return interpolate(parsed[key], processEnv, parsed)
30091
+ }
30056
30092
  }
30057
30093
 
30058
30094
  if (defaultValue) {
@@ -30078,7 +30114,6 @@ function expand (options) {
30078
30114
  let value = options.parsed[key];
30079
30115
 
30080
30116
  const inProcessEnv = Object.prototype.hasOwnProperty.call(processEnv, key);
30081
-
30082
30117
  if (inProcessEnv) {
30083
30118
  if (processEnv[key] === options.parsed[key]) {
30084
30119
  // assume was set to processEnv from the .env file if the values match and therefore interpolate
@@ -32071,8 +32106,8 @@ function createCachedImport(imp) {
32071
32106
  return cached;
32072
32107
  };
32073
32108
  }
32074
- const importPostcssImport = createCachedImport(() => import('./dep-ZEDYRkoC.js').then(function (n) { return n.i; }));
32075
- const importPostcssModules = createCachedImport(() => import('./dep-PB-S7R_m.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; }));
32076
32111
  const importPostcss = createCachedImport(() => import('postcss'));
32077
32112
  const preprocessorWorkerControllerCache = new WeakMap();
32078
32113
  let alwaysFakeWorkerWorkerControllerCache;
@@ -39094,7 +39129,7 @@ function matchAll$1(regex, string, addition) {
39094
39129
  ...match.groups,
39095
39130
  code: match[0],
39096
39131
  start: match.index,
39097
- end: match.index + match[0].length
39132
+ end: (match.index || 0) + match[0].length
39098
39133
  });
39099
39134
  }
39100
39135
  return matches;
@@ -39599,7 +39634,6 @@ function determineSpecificType(value) {
39599
39634
 
39600
39635
  return `type ${typeof value} (${inspected})`
39601
39636
  }
39602
- pathToFileURL(process.cwd());
39603
39637
 
39604
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;
39605
39639
  const TYPE_RE = /^\s*?type\s/;
@@ -39612,8 +39646,11 @@ function findStaticImports(code) {
39612
39646
  function parseStaticImport(matched) {
39613
39647
  const cleanedImports = clearImports(matched.imports);
39614
39648
  const namedImports = {};
39615
- for (const namedImport of cleanedImports.match(/{([^}]*)}/)?.[1]?.split(",") || []) {
39616
- 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;
39617
39654
  if (source && !TYPE_RE.test(source)) {
39618
39655
  namedImports[source] = importName;
39619
39656
  }
@@ -46925,9 +46962,11 @@ function getFsUtils(config) {
46925
46962
  if (!fsUtils) {
46926
46963
  if (config.command !== 'serve' ||
46927
46964
  config.server.fs.cachedChecks === false ||
46928
- config.server.watch?.ignored) {
46965
+ config.server.watch?.ignored ||
46966
+ process.versions.pnp) {
46929
46967
  // cached fsUtils is only used in the dev server for now
46930
46968
  // it is enabled by default only when there aren't custom watcher ignored patterns configured
46969
+ // and if yarn pnp isn't used
46931
46970
  fsUtils = commonFsUtils;
46932
46971
  }
46933
46972
  else if (!config.resolve.preserveSymlinks &&
@@ -47040,6 +47079,10 @@ function createCachedFsUtils(config) {
47040
47079
  return direntCache;
47041
47080
  };
47042
47081
  function getDirentCacheFromPath(normalizedFile) {
47082
+ // path.posix.normalize may return a path either with / or without /
47083
+ if (normalizedFile[normalizedFile.length - 1] === '/') {
47084
+ normalizedFile = normalizedFile.slice(0, -1);
47085
+ }
47043
47086
  if (normalizedFile === root) {
47044
47087
  return rootCache;
47045
47088
  }
@@ -47498,7 +47541,7 @@ function resolvePlugin(resolveOptions) {
47498
47541
  }
47499
47542
  }
47500
47543
  // drive relative fs paths (only windows)
47501
- if (isWindows$3 && id[0] === '/') {
47544
+ if (isWindows$5 && id[0] === '/') {
47502
47545
  const basedir = importer ? path$o.dirname(importer) : process.cwd();
47503
47546
  const fsPath = path$o.resolve(basedir, id);
47504
47547
  if ((res = tryFsResolve(fsPath, options))) {
@@ -47609,14 +47652,16 @@ function resolveSubpathImports(id, importer, options, targetWeb) {
47609
47652
  const pkgData = findNearestPackageData(basedir, options.packageCache);
47610
47653
  if (!pkgData)
47611
47654
  return;
47612
- 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');
47613
47658
  if (importsPath?.[0] === '.') {
47614
47659
  importsPath = path$o.relative(basedir, path$o.join(pkgData.dir, importsPath));
47615
47660
  if (importsPath[0] !== '.') {
47616
47661
  importsPath = `./${importsPath}`;
47617
47662
  }
47618
47663
  }
47619
- return importsPath;
47664
+ return importsPath + postfix;
47620
47665
  }
47621
47666
  function ensureVersionQuery(resolved, id, options, depsOptimizer) {
47622
47667
  if (!options.isBuild &&
@@ -50435,7 +50480,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
50435
50480
  }
50436
50481
  async load(options) {
50437
50482
  // We may not have added this to our module graph yet, so ensure it exists
50438
- await moduleGraph?.ensureEntryFromUrl(unwrapId(options.id), this.ssr);
50483
+ await moduleGraph?.ensureEntryFromUrl(unwrapId$1(options.id), this.ssr);
50439
50484
  // Not all options passed to this function make sense in the context of loading individual files,
50440
50485
  // but we can at least update the module info properties we support
50441
50486
  updateModuleInfo(options.id, options);
@@ -50990,6 +51035,18 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
50990
51035
  return;
50991
51036
  const plugin = esbuildScanPlugin(config, container, deps, missing, entries);
50992
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
+ }
50993
51050
  return await esbuild.context({
50994
51051
  absWorkingDir: process.cwd(),
50995
51052
  write: false,
@@ -51002,6 +51059,7 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
51002
51059
  logLevel: 'silent',
51003
51060
  plugins: [...plugins, plugin],
51004
51061
  ...esbuildOptions,
51062
+ tsconfigRaw,
51005
51063
  });
51006
51064
  }
51007
51065
  function orderedDependencies(deps) {
@@ -51011,6 +51069,10 @@ function orderedDependencies(deps) {
51011
51069
  return Object.fromEntries(depsList);
51012
51070
  }
51013
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
+ }
51014
51076
  return glob(pattern, {
51015
51077
  cwd: config.root,
51016
51078
  ignore: [
@@ -52330,7 +52392,7 @@ function runOptimizeDeps(resolvedConfig, depsInfo, ssr) {
52330
52392
  // is safer than a delete-rename operation.
52331
52393
  const temporaryPath = depsCacheDir + getTempSuffix();
52332
52394
  const depsCacheDirPresent = fs$l.existsSync(depsCacheDir);
52333
- if (isWindows$3) {
52395
+ if (isWindows$5) {
52334
52396
  if (depsCacheDirPresent) {
52335
52397
  debug$7?.(colors$1.green(`renaming ${depsCacheDir} to ${temporaryPath}`));
52336
52398
  await safeRename(depsCacheDir, temporaryPath);
@@ -53312,7 +53374,7 @@ function serveRawFsMiddleware(server) {
53312
53374
  return;
53313
53375
  }
53314
53376
  let newPathname = pathname.slice(FS_PREFIX.length);
53315
- if (isWindows$3)
53377
+ if (isWindows$5)
53316
53378
  newPathname = newPathname.replace(/^[A-Z]:/i, '');
53317
53379
  url.pathname = encodeURI(newPathname);
53318
53380
  req.url = url.href.slice(url.origin.length);
@@ -53687,7 +53749,7 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, server) {
53687
53749
  }
53688
53750
  const urlWithoutTimestamp = removeTimestampQuery(rawUrl);
53689
53751
  // hmrUrl must be derived the same way as importAnalysis
53690
- const hmrUrl = unwrapId(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
53752
+ const hmrUrl = unwrapId$1(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
53691
53753
  for (const importedMod of mod.clientImportedModules) {
53692
53754
  if (importedMod.url !== hmrUrl)
53693
53755
  continue;
@@ -54561,7 +54623,7 @@ const pendingModules = new Map();
54561
54623
  const pendingImports = new Map();
54562
54624
  const importErrors = new WeakMap();
54563
54625
  async function ssrLoadModule(url, server, context = { global }, urlStack = [], fixStacktrace) {
54564
- url = unwrapId(url);
54626
+ url = unwrapId$1(url);
54565
54627
  // when we instantiate multiple dependency modules in parallel, they may
54566
54628
  // point to shared modules. We need to avoid duplicate instantiation attempts
54567
54629
  // by register every module as pending synchronously so that all subsequent
@@ -54634,7 +54696,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
54634
54696
  return await nodeImport(dep, mod.file, resolveOptions, metadata);
54635
54697
  }
54636
54698
  // convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
54637
- dep = unwrapId(dep);
54699
+ dep = unwrapId$1(dep);
54638
54700
  if (!isCircular(dep) && !pendingImports.get(dep)?.some(isCircular)) {
54639
54701
  pendingDeps.push(dep);
54640
54702
  if (pendingDeps.length === 1) {
@@ -56089,16 +56151,19 @@ const BASE_PREVIEW_SHORTCUTS = [
56089
56151
  ];
56090
56152
 
56091
56153
  function resolveChokidarOptions(config, options) {
56092
- const { ignored = [], ...otherOptions } = options ?? {};
56154
+ const { ignored: ignoredList, ...otherOptions } = options ?? {};
56155
+ const ignored = [
56156
+ '**/.git/**',
56157
+ '**/node_modules/**',
56158
+ '**/test-results/**',
56159
+ glob.escapePath(config.cacheDir) + '/**',
56160
+ ...arraify(ignoredList || []),
56161
+ ];
56162
+ if (config.build.outDir) {
56163
+ ignored.push(glob.escapePath(path$o.resolve(config.root, config.build.outDir)) + '/**');
56164
+ }
56093
56165
  const resolvedWatchOptions = {
56094
- ignored: [
56095
- '**/.git/**',
56096
- '**/node_modules/**',
56097
- '**/test-results/**',
56098
- glob.escapePath(config.cacheDir) + '/**',
56099
- glob.escapePath(path$o.resolve(config.root, config.build.outDir)) + '/**',
56100
- ...arraify(ignored),
56101
- ],
56166
+ ignored,
56102
56167
  ignoreInitial: true,
56103
56168
  ignorePermissionErrors: true,
56104
56169
  ...otherOptions,
@@ -56175,7 +56240,7 @@ async function fetchModule(server, url, importer, options = {}) {
56175
56240
  : 'commonjs';
56176
56241
  return { externalize: file, type };
56177
56242
  }
56178
- url = unwrapId(url);
56243
+ url = unwrapId$1(url);
56179
56244
  let result = await server.transformRequest(url, { ssr: true });
56180
56245
  if (!result) {
56181
56246
  throw new Error(`[vite] transform failed for module '${url}'${importer ? ` imported from '${importer}'` : ''}.`);
@@ -56193,10 +56258,6 @@ async function fetchModule(server, url, importer, options = {}) {
56193
56258
  result.code = result.code.replace(/^#!.*/, (s) => ' '.repeat(s.length));
56194
56259
  return { code: result.code, file: mod.file };
56195
56260
  }
56196
- let SOURCEMAPPING_URL = 'sourceMa';
56197
- SOURCEMAPPING_URL += 'ppingURL';
56198
- const VITE_RUNTIME_SOURCEMAPPING_SOURCE = '//# sourceMappingSource=vite-runtime';
56199
- const VITE_RUNTIME_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
56200
56261
  const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm');
56201
56262
  function inlineSourceMap(mod, result, processSourceMap) {
56202
56263
  const map = result.map;
@@ -63354,7 +63415,7 @@ function transformMiddleware(server) {
63354
63415
  url = removeImportQuery(url);
63355
63416
  // Strip valid id prefix. This is prepended to resolved Ids that are
63356
63417
  // not valid browser import specifiers by the importAnalysis plugin.
63357
- url = unwrapId(url);
63418
+ url = unwrapId$1(url);
63358
63419
  // for CSS, we differentiate between normal CSS requests and imports
63359
63420
  if (isCSSRequest(url)) {
63360
63421
  if (req.headers.accept?.includes('text/css') &&
@@ -63563,7 +63624,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
63563
63624
  // and ids are properly handled
63564
63625
  const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}`;
63565
63626
  proxyModulePath = `\0${validPath}`;
63566
- proxyModuleUrl = wrapId(proxyModulePath);
63627
+ proxyModuleUrl = wrapId$1(proxyModulePath);
63567
63628
  }
63568
63629
  const s = new MagicString(html);
63569
63630
  let inlineModuleIndex = -1;
@@ -63742,7 +63803,7 @@ function preTransformRequest(server, url, base) {
63742
63803
  return;
63743
63804
  // transform all url as non-ssr as html includes client-side assets only
63744
63805
  try {
63745
- url = unwrapId(stripBase(decodeURI(url), base));
63806
+ url = unwrapId$1(stripBase(decodeURI(url), base));
63746
63807
  }
63747
63808
  catch {
63748
63809
  // ignore
@@ -64835,6 +64896,7 @@ async function handleHMRUpdate(file, server, configOnly) {
64835
64896
  hot.send({
64836
64897
  type: 'full-reload',
64837
64898
  path: '*',
64899
+ triggeredBy: path$o.resolve(config.root, file),
64838
64900
  });
64839
64901
  return;
64840
64902
  }
@@ -64913,6 +64975,7 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
64913
64975
  config.logger.info(colors$1.green(`page reload `) + colors$1.dim(file) + reason, { clear: !afterInvalidation, timestamp: true });
64914
64976
  hot.send({
64915
64977
  type: 'full-reload',
64978
+ triggeredBy: path$o.resolve(config.root, file),
64916
64979
  });
64917
64980
  return;
64918
64981
  }
@@ -64927,7 +64990,7 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
64927
64990
  updates,
64928
64991
  });
64929
64992
  }
64930
- function populateSSRImporters(module, timestamp, seen) {
64993
+ function populateSSRImporters(module, timestamp, seen = new Set()) {
64931
64994
  module.ssrImportedModules.forEach((importer) => {
64932
64995
  if (seen.has(importer)) {
64933
64996
  return;
@@ -64941,9 +65004,7 @@ function populateSSRImporters(module, timestamp, seen) {
64941
65004
  return seen;
64942
65005
  }
64943
65006
  function getSSRInvalidatedImporters(module) {
64944
- return [
64945
- ...populateSSRImporters(module, module.lastHMRTimestamp, new Set()),
64946
- ].map((m) => m.file);
65007
+ return [...populateSSRImporters(module, module.lastHMRTimestamp)].map((m) => m.file);
64947
65008
  }
64948
65009
  async function handleFileAddUnlink(file, server, isUnlink) {
64949
65010
  const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
@@ -65253,7 +65314,7 @@ function lexAcceptedHmrExports(code, start, exportNames) {
65253
65314
  }
65254
65315
  function normalizeHmrUrl(url) {
65255
65316
  if (url[0] !== '.' && url[0] !== '/') {
65256
- url = wrapId(url);
65317
+ url = wrapId$1(url);
65257
65318
  }
65258
65319
  return url;
65259
65320
  }
@@ -65590,7 +65651,7 @@ function importAnalysisPlugin(config) {
65590
65651
  // prefix it to make it valid. We will strip this before feeding it
65591
65652
  // back into the transform pipeline
65592
65653
  if (url[0] !== '.' && url[0] !== '/') {
65593
- url = wrapId(resolved.id);
65654
+ url = wrapId$1(resolved.id);
65594
65655
  }
65595
65656
  // make the URL browser-valid if not SSR
65596
65657
  if (!ssr) {
@@ -65616,7 +65677,7 @@ function importAnalysisPlugin(config) {
65616
65677
  try {
65617
65678
  // delay setting `isSelfAccepting` until the file is actually used (#7870)
65618
65679
  // We use an internal function to avoid resolving the url again
65619
- 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);
65620
65681
  if (depModule.lastHMRTimestamp > 0) {
65621
65682
  url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
65622
65683
  }
@@ -65685,7 +65746,7 @@ function importAnalysisPlugin(config) {
65685
65746
  }
65686
65747
  // static import or valid string in dynamic import
65687
65748
  // If resolvable, let's resolve it
65688
- if (specifier) {
65749
+ if (specifier !== undefined) {
65689
65750
  // skip external / data uri
65690
65751
  if (isExternalUrl(specifier) || isDataUrl(specifier)) {
65691
65752
  return;
@@ -65762,7 +65823,7 @@ function importAnalysisPlugin(config) {
65762
65823
  }
65763
65824
  // record for HMR import chain analysis
65764
65825
  // make sure to unwrap and normalize away base
65765
- const hmrUrl = unwrapId(stripBase(url, base));
65826
+ const hmrUrl = unwrapId$1(stripBase(url, base));
65766
65827
  const isLocalImport = !isExternalUrl(hmrUrl) && !isDataUrl(hmrUrl);
65767
65828
  if (isLocalImport) {
65768
65829
  orderedImportedUrls[index] = hmrUrl;
@@ -66046,7 +66107,7 @@ function __vite__injectQuery(url, queryToInject) {
66046
66107
  return url;
66047
66108
  }
66048
66109
  // can't use pathname from URL since it may be relative like ../
66049
- const pathname = url.replace(/[?#].*$/s, '');
66110
+ const pathname = url.replace(/[?#].*$/, '');
66050
66111
  const { search, hash } = new URL(url, 'http://vitejs.dev');
66051
66112
  return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash || ''}`;
66052
66113
  }
@@ -66325,12 +66386,14 @@ function buildImportAnalysisPlugin(config) {
66325
66386
  const chunk = bundle[filename];
66326
66387
  if (chunk) {
66327
66388
  deps.add(chunk.fileName);
66328
- chunk.imports.forEach(addDeps);
66329
- // Ensure that the css imported by current chunk is loaded after the dependencies.
66330
- // So the style of current chunk won't be overwritten unexpectedly.
66331
- chunk.viteMetadata.importedCss.forEach((file) => {
66332
- deps.add(file);
66333
- });
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
+ }
66334
66397
  }
66335
66398
  else {
66336
66399
  const removedPureCssFiles = removedPureCssFilesCache.get(config);
@@ -66421,13 +66484,12 @@ function __vite__mapDeps(indexes) {
66421
66484
  }
66422
66485
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
66423
66486
  }\n`;
66424
- // inject extra code before sourcemap comment
66425
- const mapFileCommentMatch = convertSourceMap.mapFileCommentRegex.exec(code);
66426
- if (mapFileCommentMatch) {
66427
- 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);
66428
66490
  }
66429
66491
  else {
66430
- s.append(mapDepsCode);
66492
+ s.prepend(mapDepsCode);
66431
66493
  }
66432
66494
  // there may still be markers due to inlined dynamic imports, remove
66433
66495
  // all the markers regardless
@@ -68199,4 +68261,4 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
68199
68261
  }
68200
68262
  }
68201
68263
 
68202
- 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 };