vite 5.1.4 → 5.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/node/chunks/{dep-jDlpJiMN.js → dep-jvB8WLp9.js} +553 -439
- package/dist/node/chunks/{dep-g6LmopN4.js → dep-pxQDj-UY.js} +1 -1
- package/dist/node/chunks/{dep-wALyWXZB.js → dep-sFlFG1c_.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/constants.js +1 -17
- package/dist/node/index.d.ts +6 -5
- package/dist/node/index.js +3 -3
- package/dist/node/runtime.d.ts +54 -3
- package/dist/node/runtime.js +934 -1527
- package/dist/node/{types.d-jgA8ss1A.d.ts → types.d-FdqQ54oU.d.ts} +24 -67
- package/dist/node-cjs/publicUtils.cjs +49 -62
- package/package.json +12 -10
- package/types/hmrPayload.d.ts +2 -0
@@ -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,69 @@ 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
|
+
|
254
|
+
const isWindows$5 = typeof process !== 'undefined' && process.platform === 'win32';
|
255
|
+
/**
|
256
|
+
* Prepend `/@id/` and replace null byte so the id is URL-safe.
|
257
|
+
* This is prepended to resolved ids that are not valid browser
|
258
|
+
* import specifiers by the importAnalysis plugin.
|
259
|
+
*/
|
260
|
+
function wrapId$1(id) {
|
261
|
+
return id.startsWith(VALID_ID_PREFIX)
|
262
|
+
? id
|
263
|
+
: VALID_ID_PREFIX + id.replace('\0', NULL_BYTE_PLACEHOLDER);
|
264
|
+
}
|
265
|
+
/**
|
266
|
+
* Undo {@link wrapId}'s `/@id/` and null byte replacements.
|
267
|
+
*/
|
268
|
+
function unwrapId$1(id) {
|
269
|
+
return id.startsWith(VALID_ID_PREFIX)
|
270
|
+
? id.slice(VALID_ID_PREFIX.length).replace(NULL_BYTE_PLACEHOLDER, '\0')
|
271
|
+
: id;
|
272
|
+
}
|
273
|
+
const windowsSlashRE = /\\/g;
|
274
|
+
function slash$1(p) {
|
275
|
+
return p.replace(windowsSlashRE, '/');
|
276
|
+
}
|
277
|
+
const postfixRE = /[?#].*$/;
|
278
|
+
function cleanUrl(url) {
|
279
|
+
return url.replace(postfixRE, '');
|
280
|
+
}
|
281
|
+
function withTrailingSlash(path) {
|
282
|
+
if (path[path.length - 1] !== '/') {
|
283
|
+
return `${path}/`;
|
284
|
+
}
|
285
|
+
return path;
|
286
|
+
}
|
287
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
288
|
+
const AsyncFunction = async function () { }.constructor;
|
289
|
+
// https://github.com/nodejs/node/issues/43047#issuecomment-1564068099
|
290
|
+
const asyncFunctionDeclarationPaddingLineCount =
|
291
|
+
/** #__PURE__ */ (() => {
|
292
|
+
const body = '/*code*/';
|
293
|
+
const source = new AsyncFunction('a', 'b', body).toString();
|
294
|
+
return source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
295
|
+
})();
|
296
|
+
|
234
297
|
// @ts-check
|
235
298
|
/** @typedef { import('estree').BaseNode} BaseNode */
|
236
299
|
|
@@ -2883,7 +2946,7 @@ var old$1 = {};
|
|
2883
2946
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2884
2947
|
|
2885
2948
|
var pathModule = require$$0$4;
|
2886
|
-
var isWindows$
|
2949
|
+
var isWindows$4 = process.platform === 'win32';
|
2887
2950
|
var fs$k = require$$0__default;
|
2888
2951
|
|
2889
2952
|
// JavaScript implementation of realpath, ported from node pre-v6
|
@@ -2931,14 +2994,14 @@ function maybeCallback(cb) {
|
|
2931
2994
|
|
2932
2995
|
// Regexp that finds the next partion of a (partial) path
|
2933
2996
|
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
2934
|
-
if (isWindows$
|
2997
|
+
if (isWindows$4) {
|
2935
2998
|
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
2936
2999
|
} else {
|
2937
3000
|
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
2938
3001
|
}
|
2939
3002
|
|
2940
3003
|
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
2941
|
-
if (isWindows$
|
3004
|
+
if (isWindows$4) {
|
2942
3005
|
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
2943
3006
|
} else {
|
2944
3007
|
var splitRootRe = /^[\/]*/;
|
@@ -2976,7 +3039,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
2976
3039
|
previous = '';
|
2977
3040
|
|
2978
3041
|
// On windows, check that the root exists. On unix there is no need.
|
2979
|
-
if (isWindows$
|
3042
|
+
if (isWindows$4 && !knownHard[base]) {
|
2980
3043
|
fs$k.lstatSync(base);
|
2981
3044
|
knownHard[base] = true;
|
2982
3045
|
}
|
@@ -3014,7 +3077,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
3014
3077
|
// read the link if it wasn't read before
|
3015
3078
|
// dev/ino always return 0 on windows, so skip the check.
|
3016
3079
|
var linkTarget = null;
|
3017
|
-
if (!isWindows$
|
3080
|
+
if (!isWindows$4) {
|
3018
3081
|
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
3019
3082
|
if (seenLinks.hasOwnProperty(id)) {
|
3020
3083
|
linkTarget = seenLinks[id];
|
@@ -3027,7 +3090,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
3027
3090
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
3028
3091
|
// track this, if given a cache.
|
3029
3092
|
if (cache) cache[base] = resolvedLink;
|
3030
|
-
if (!isWindows$
|
3093
|
+
if (!isWindows$4) seenLinks[id] = linkTarget;
|
3031
3094
|
}
|
3032
3095
|
|
3033
3096
|
// resolve the link, then start over
|
@@ -3078,7 +3141,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
3078
3141
|
previous = '';
|
3079
3142
|
|
3080
3143
|
// On windows, check that the root exists. On unix there is no need.
|
3081
|
-
if (isWindows$
|
3144
|
+
if (isWindows$4 && !knownHard[base]) {
|
3082
3145
|
fs$k.lstat(base, function(err) {
|
3083
3146
|
if (err) return cb(err);
|
3084
3147
|
knownHard[base] = true;
|
@@ -3132,7 +3195,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
3132
3195
|
// stat & read the link if not read before
|
3133
3196
|
// call gotTarget as soon as the link target is known
|
3134
3197
|
// dev/ino always return 0 on windows, so skip the check.
|
3135
|
-
if (!isWindows$
|
3198
|
+
if (!isWindows$4) {
|
3136
3199
|
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
3137
3200
|
if (seenLinks.hasOwnProperty(id)) {
|
3138
3201
|
return gotTarget(null, seenLinks[id], base);
|
@@ -3142,7 +3205,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
3142
3205
|
if (err) return cb(err);
|
3143
3206
|
|
3144
3207
|
fs$k.readlink(base, function(err, target) {
|
3145
|
-
if (!isWindows$
|
3208
|
+
if (!isWindows$4) seenLinks[id] = target;
|
3146
3209
|
gotTarget(err, target);
|
3147
3210
|
});
|
3148
3211
|
});
|
@@ -3230,10 +3293,10 @@ function unmonkeypatch () {
|
|
3230
3293
|
fs$j.realpathSync = origRealpathSync;
|
3231
3294
|
}
|
3232
3295
|
|
3233
|
-
const isWindows$
|
3296
|
+
const isWindows$3 = typeof process === 'object' &&
|
3234
3297
|
process &&
|
3235
3298
|
process.platform === 'win32';
|
3236
|
-
var path$k = isWindows$
|
3299
|
+
var path$k = isWindows$3 ? { sep: '\\' } : { sep: '/' };
|
3237
3300
|
|
3238
3301
|
var balancedMatch = balanced$1;
|
3239
3302
|
function balanced$1(a, b, str) {
|
@@ -6647,9 +6710,12 @@ class Mappings {
|
|
6647
6710
|
|
6648
6711
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
6649
6712
|
if (content.length) {
|
6713
|
+
const contentLengthMinusOne = content.length - 1;
|
6650
6714
|
let contentLineEnd = content.indexOf('\n', 0);
|
6651
6715
|
let previousContentLineEnd = -1;
|
6652
|
-
|
6716
|
+
// Loop through each line in the content and add a segment, but stop if the last line is empty,
|
6717
|
+
// else code afterwards would fill one line too many
|
6718
|
+
while (contentLineEnd >= 0 && contentLengthMinusOne > contentLineEnd) {
|
6653
6719
|
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
6654
6720
|
if (nameIndex >= 0) {
|
6655
6721
|
segment.push(nameIndex);
|
@@ -7905,8 +7971,8 @@ function normalize (path) {
|
|
7905
7971
|
}
|
7906
7972
|
|
7907
7973
|
const isWrappedId = (id, suffix) => id.endsWith(suffix);
|
7908
|
-
const wrapId
|
7909
|
-
const unwrapId
|
7974
|
+
const wrapId = (id, suffix) => `\0${id}${suffix}`;
|
7975
|
+
const unwrapId = (wrappedId, suffix) => wrappedId.slice(1, -suffix.length);
|
7910
7976
|
|
7911
7977
|
const PROXY_SUFFIX = '?commonjs-proxy';
|
7912
7978
|
const WRAPPED_SUFFIX = '?commonjs-wrapped';
|
@@ -8119,7 +8185,7 @@ function getResolveId(extensions, isPossibleCjsId) {
|
|
8119
8185
|
}
|
8120
8186
|
|
8121
8187
|
if (isWrappedId(importee, WRAPPED_SUFFIX)) {
|
8122
|
-
return unwrapId
|
8188
|
+
return unwrapId(importee, WRAPPED_SUFFIX);
|
8123
8189
|
}
|
8124
8190
|
|
8125
8191
|
if (
|
@@ -8196,7 +8262,7 @@ function getResolveId(extensions, isPossibleCjsId) {
|
|
8196
8262
|
return resolved.id + ENTRY_SUFFIX;
|
8197
8263
|
}
|
8198
8264
|
if (isCommonJS === IS_WRAPPED_COMMONJS) {
|
8199
|
-
return { id: wrapId
|
8265
|
+
return { id: wrapId(resolved.id, ES_IMPORT_SUFFIX), meta: { commonjs: { resolved } } };
|
8200
8266
|
}
|
8201
8267
|
}
|
8202
8268
|
}
|
@@ -8371,11 +8437,11 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
|
|
8371
8437
|
})) || resolveExtensions(source, parentId, extensions);
|
8372
8438
|
currentlyResolvingForParent.delete(source);
|
8373
8439
|
if (!resolved) {
|
8374
|
-
return { id: wrapId
|
8440
|
+
return { id: wrapId(source, EXTERNAL_SUFFIX), allowProxy: false };
|
8375
8441
|
}
|
8376
8442
|
const childId = resolved.id;
|
8377
8443
|
if (resolved.external) {
|
8378
|
-
return { id: wrapId
|
8444
|
+
return { id: wrapId(childId, EXTERNAL_SUFFIX), allowProxy: false };
|
8379
8445
|
}
|
8380
8446
|
parentMeta.requires.push({ resolved, isConditional });
|
8381
8447
|
await analyzeRequiredModule(parentId, resolved, isConditional, rollupContext.load);
|
@@ -8393,8 +8459,8 @@ function getRequireResolver(extensions, detectCyclesAndConditional, currentlyRes
|
|
8393
8459
|
source: sources[index].source,
|
8394
8460
|
id: allowProxy
|
8395
8461
|
? isCommonJS === IS_WRAPPED_COMMONJS
|
8396
|
-
? wrapId
|
8397
|
-
: wrapId
|
8462
|
+
? wrapId(dependencyId, WRAPPED_SUFFIX)
|
8463
|
+
: wrapId(dependencyId, PROXY_SUFFIX)
|
8398
8464
|
: dependencyId,
|
8399
8465
|
isCommonJS
|
8400
8466
|
};
|
@@ -8925,12 +8991,12 @@ function getRequireHandlers() {
|
|
8925
8991
|
}
|
8926
8992
|
if (exportMode === 'module') {
|
8927
8993
|
imports.push(
|
8928
|
-
`import { __module as ${moduleName} } from ${JSON.stringify(wrapId
|
8994
|
+
`import { __module as ${moduleName} } from ${JSON.stringify(wrapId(id, MODULE_SUFFIX))}`,
|
8929
8995
|
`var ${exportsName} = ${moduleName}.exports`
|
8930
8996
|
);
|
8931
8997
|
} else if (exportMode === 'exports') {
|
8932
8998
|
imports.push(
|
8933
|
-
`import { __exports as ${exportsName} } from ${JSON.stringify(wrapId
|
8999
|
+
`import { __exports as ${exportsName} } from ${JSON.stringify(wrapId(id, EXPORTS_SUFFIX))}`
|
8934
9000
|
);
|
8935
9001
|
}
|
8936
9002
|
const requiresBySource = collectSources(requireExpressions);
|
@@ -9797,7 +9863,7 @@ function commonjs(options = {}) {
|
|
9797
9863
|
}
|
9798
9864
|
|
9799
9865
|
if (isWrappedId(id, MODULE_SUFFIX)) {
|
9800
|
-
const name = getName(unwrapId
|
9866
|
+
const name = getName(unwrapId(id, MODULE_SUFFIX));
|
9801
9867
|
return {
|
9802
9868
|
code: `var ${name} = {exports: {}}; export {${name} as __module}`,
|
9803
9869
|
meta: { commonjs: { isCommonJS: false } }
|
@@ -9805,7 +9871,7 @@ function commonjs(options = {}) {
|
|
9805
9871
|
}
|
9806
9872
|
|
9807
9873
|
if (isWrappedId(id, EXPORTS_SUFFIX)) {
|
9808
|
-
const name = getName(unwrapId
|
9874
|
+
const name = getName(unwrapId(id, EXPORTS_SUFFIX));
|
9809
9875
|
return {
|
9810
9876
|
code: `var ${name} = {}; export {${name} as __exports}`,
|
9811
9877
|
meta: { commonjs: { isCommonJS: false } }
|
@@ -9813,7 +9879,7 @@ function commonjs(options = {}) {
|
|
9813
9879
|
}
|
9814
9880
|
|
9815
9881
|
if (isWrappedId(id, EXTERNAL_SUFFIX)) {
|
9816
|
-
const actualId = unwrapId
|
9882
|
+
const actualId = unwrapId(id, EXTERNAL_SUFFIX);
|
9817
9883
|
return getUnknownRequireProxy(
|
9818
9884
|
actualId,
|
9819
9885
|
isEsmExternal(actualId) ? getRequireReturnsDefault(actualId) : true
|
@@ -9836,7 +9902,7 @@ function commonjs(options = {}) {
|
|
9836
9902
|
}
|
9837
9903
|
|
9838
9904
|
if (isWrappedId(id, ES_IMPORT_SUFFIX)) {
|
9839
|
-
const actualId = unwrapId
|
9905
|
+
const actualId = unwrapId(id, ES_IMPORT_SUFFIX);
|
9840
9906
|
return getEsImportProxy(actualId, getDefaultIsModuleExports(actualId));
|
9841
9907
|
}
|
9842
9908
|
|
@@ -9850,7 +9916,7 @@ function commonjs(options = {}) {
|
|
9850
9916
|
}
|
9851
9917
|
|
9852
9918
|
if (isWrappedId(id, PROXY_SUFFIX)) {
|
9853
|
-
const actualId = unwrapId
|
9919
|
+
const actualId = unwrapId(id, PROXY_SUFFIX);
|
9854
9920
|
return getStaticRequireProxy(actualId, getRequireReturnsDefault(actualId), this.load);
|
9855
9921
|
}
|
9856
9922
|
|
@@ -9896,16 +9962,6 @@ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#
|
|
9896
9962
|
* 4. Hash, including "#", optional.
|
9897
9963
|
*/
|
9898
9964
|
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
9965
|
function isAbsoluteUrl(input) {
|
9910
9966
|
return schemeRegex.test(input);
|
9911
9967
|
}
|
@@ -9939,21 +9995,21 @@ function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
9939
9995
|
path,
|
9940
9996
|
query,
|
9941
9997
|
hash,
|
9942
|
-
type:
|
9998
|
+
type: 7 /* Absolute */,
|
9943
9999
|
};
|
9944
10000
|
}
|
9945
10001
|
function parseUrl$2(input) {
|
9946
10002
|
if (isSchemeRelativeUrl(input)) {
|
9947
10003
|
const url = parseAbsoluteUrl('http:' + input);
|
9948
10004
|
url.scheme = '';
|
9949
|
-
url.type =
|
10005
|
+
url.type = 6 /* SchemeRelative */;
|
9950
10006
|
return url;
|
9951
10007
|
}
|
9952
10008
|
if (isAbsolutePath(input)) {
|
9953
10009
|
const url = parseAbsoluteUrl('http://foo.com' + input);
|
9954
10010
|
url.scheme = '';
|
9955
10011
|
url.host = '';
|
9956
|
-
url.type =
|
10012
|
+
url.type = 5 /* AbsolutePath */;
|
9957
10013
|
return url;
|
9958
10014
|
}
|
9959
10015
|
if (isFileUrl(input))
|
@@ -9965,11 +10021,11 @@ function parseUrl$2(input) {
|
|
9965
10021
|
url.host = '';
|
9966
10022
|
url.type = input
|
9967
10023
|
? input.startsWith('?')
|
9968
|
-
?
|
10024
|
+
? 3 /* Query */
|
9969
10025
|
: input.startsWith('#')
|
9970
|
-
?
|
9971
|
-
:
|
9972
|
-
:
|
10026
|
+
? 2 /* Hash */
|
10027
|
+
: 4 /* RelativePath */
|
10028
|
+
: 1 /* Empty */;
|
9973
10029
|
return url;
|
9974
10030
|
}
|
9975
10031
|
function stripPathFilename(path) {
|
@@ -9997,7 +10053,7 @@ function mergePaths(url, base) {
|
|
9997
10053
|
* "foo/.". We need to normalize to a standard representation.
|
9998
10054
|
*/
|
9999
10055
|
function normalizePath$4(url, type) {
|
10000
|
-
const rel = type <=
|
10056
|
+
const rel = type <= 4 /* RelativePath */;
|
10001
10057
|
const pieces = url.path.split('/');
|
10002
10058
|
// We need to preserve the first piece always, so that we output a leading slash. The item at
|
10003
10059
|
// pieces[0] is an empty string.
|
@@ -10058,27 +10114,27 @@ function resolve$2(input, base) {
|
|
10058
10114
|
return '';
|
10059
10115
|
const url = parseUrl$2(input);
|
10060
10116
|
let inputType = url.type;
|
10061
|
-
if (base && inputType !==
|
10117
|
+
if (base && inputType !== 7 /* Absolute */) {
|
10062
10118
|
const baseUrl = parseUrl$2(base);
|
10063
10119
|
const baseType = baseUrl.type;
|
10064
10120
|
switch (inputType) {
|
10065
|
-
case
|
10121
|
+
case 1 /* Empty */:
|
10066
10122
|
url.hash = baseUrl.hash;
|
10067
10123
|
// fall through
|
10068
|
-
case
|
10124
|
+
case 2 /* Hash */:
|
10069
10125
|
url.query = baseUrl.query;
|
10070
10126
|
// fall through
|
10071
|
-
case
|
10072
|
-
case
|
10127
|
+
case 3 /* Query */:
|
10128
|
+
case 4 /* RelativePath */:
|
10073
10129
|
mergePaths(url, baseUrl);
|
10074
10130
|
// fall through
|
10075
|
-
case
|
10131
|
+
case 5 /* AbsolutePath */:
|
10076
10132
|
// The host, user, and port are joined, you can't copy one without the others.
|
10077
10133
|
url.user = baseUrl.user;
|
10078
10134
|
url.host = baseUrl.host;
|
10079
10135
|
url.port = baseUrl.port;
|
10080
10136
|
// fall through
|
10081
|
-
case
|
10137
|
+
case 6 /* SchemeRelative */:
|
10082
10138
|
// The input doesn't have a schema at least, so we need to copy at least that over.
|
10083
10139
|
url.scheme = baseUrl.scheme;
|
10084
10140
|
}
|
@@ -10090,10 +10146,10 @@ function resolve$2(input, base) {
|
|
10090
10146
|
switch (inputType) {
|
10091
10147
|
// This is impossible, because of the empty checks at the start of the function.
|
10092
10148
|
// case UrlType.Empty:
|
10093
|
-
case
|
10094
|
-
case
|
10149
|
+
case 2 /* Hash */:
|
10150
|
+
case 3 /* Query */:
|
10095
10151
|
return queryHash;
|
10096
|
-
case
|
10152
|
+
case 4 /* RelativePath */: {
|
10097
10153
|
// The first char is always a "/", and we need it to be relative.
|
10098
10154
|
const path = url.path.slice(1);
|
10099
10155
|
if (!path)
|
@@ -10106,7 +10162,7 @@ function resolve$2(input, base) {
|
|
10106
10162
|
}
|
10107
10163
|
return path + queryHash;
|
10108
10164
|
}
|
10109
|
-
case
|
10165
|
+
case 5 /* AbsolutePath */:
|
10110
10166
|
return url.path + queryHash;
|
10111
10167
|
default:
|
10112
10168
|
return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
|
@@ -10261,21 +10317,6 @@ const LINE_GTR_ZERO = '`line` must be greater than 0 (lines start at line 1)';
|
|
10261
10317
|
const COL_GTR_EQ_ZERO = '`column` must be greater than or equal to 0 (columns start at column 0)';
|
10262
10318
|
const LEAST_UPPER_BOUND = -1;
|
10263
10319
|
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
10320
|
class TraceMap {
|
10280
10321
|
constructor(map, mapUrl) {
|
10281
10322
|
const isString = typeof map === 'string';
|
@@ -10289,6 +10330,7 @@ class TraceMap {
|
|
10289
10330
|
this.sourceRoot = sourceRoot;
|
10290
10331
|
this.sources = sources;
|
10291
10332
|
this.sourcesContent = sourcesContent;
|
10333
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
10292
10334
|
const from = resolve$1(sourceRoot || '', stripFilename(mapUrl));
|
10293
10335
|
this.resolvedSources = sources.map((s) => resolve$1(s || '', from));
|
10294
10336
|
const { mappings } = parsed;
|
@@ -10305,42 +10347,61 @@ class TraceMap {
|
|
10305
10347
|
this._bySourceMemos = undefined;
|
10306
10348
|
}
|
10307
10349
|
}
|
10308
|
-
|
10309
|
-
|
10310
|
-
|
10311
|
-
|
10312
|
-
|
10313
|
-
|
10314
|
-
|
10315
|
-
|
10316
|
-
|
10317
|
-
|
10318
|
-
|
10319
|
-
|
10320
|
-
|
10321
|
-
|
10322
|
-
|
10323
|
-
|
10324
|
-
|
10325
|
-
|
10326
|
-
|
10327
|
-
|
10328
|
-
|
10329
|
-
|
10330
|
-
|
10331
|
-
|
10332
|
-
|
10333
|
-
|
10334
|
-
|
10335
|
-
|
10336
|
-
|
10337
|
-
|
10338
|
-
|
10339
|
-
|
10340
|
-
|
10341
|
-
|
10342
|
-
};
|
10343
|
-
|
10350
|
+
/**
|
10351
|
+
* Typescript doesn't allow friend access to private fields, so this just casts the map into a type
|
10352
|
+
* with public access modifiers.
|
10353
|
+
*/
|
10354
|
+
function cast$2(map) {
|
10355
|
+
return map;
|
10356
|
+
}
|
10357
|
+
/**
|
10358
|
+
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
10359
|
+
*/
|
10360
|
+
function decodedMappings(map) {
|
10361
|
+
var _a;
|
10362
|
+
return ((_a = cast$2(map))._decoded || (_a._decoded = decode(cast$2(map)._encoded)));
|
10363
|
+
}
|
10364
|
+
/**
|
10365
|
+
* A low-level API to find the segment associated with a generated line/column (think, from a
|
10366
|
+
* stack trace). Line and column here are 0-based, unlike `originalPositionFor`.
|
10367
|
+
*/
|
10368
|
+
function traceSegment(map, line, column) {
|
10369
|
+
const decoded = decodedMappings(map);
|
10370
|
+
// It's common for parent source maps to have pointers to lines that have no
|
10371
|
+
// mapping (like a "//# sourceMappingURL=") at the end of the child file.
|
10372
|
+
if (line >= decoded.length)
|
10373
|
+
return null;
|
10374
|
+
const segments = decoded[line];
|
10375
|
+
const index = traceSegmentInternal(segments, cast$2(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
|
10376
|
+
return index === -1 ? null : segments[index];
|
10377
|
+
}
|
10378
|
+
/**
|
10379
|
+
* A higher-level API to find the source/line/column associated with a generated line/column
|
10380
|
+
* (think, from a stack trace). Line is 1-based, but column is 0-based, due to legacy behavior in
|
10381
|
+
* `source-map` library.
|
10382
|
+
*/
|
10383
|
+
function originalPositionFor$1(map, needle) {
|
10384
|
+
let { line, column, bias } = needle;
|
10385
|
+
line--;
|
10386
|
+
if (line < 0)
|
10387
|
+
throw new Error(LINE_GTR_ZERO);
|
10388
|
+
if (column < 0)
|
10389
|
+
throw new Error(COL_GTR_EQ_ZERO);
|
10390
|
+
const decoded = decodedMappings(map);
|
10391
|
+
// It's common for parent source maps to have pointers to lines that have no
|
10392
|
+
// mapping (like a "//# sourceMappingURL=") at the end of the child file.
|
10393
|
+
if (line >= decoded.length)
|
10394
|
+
return OMapping(null, null, null, null);
|
10395
|
+
const segments = decoded[line];
|
10396
|
+
const index = traceSegmentInternal(segments, cast$2(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
10397
|
+
if (index === -1)
|
10398
|
+
return OMapping(null, null, null, null);
|
10399
|
+
const segment = segments[index];
|
10400
|
+
if (segment.length === 1)
|
10401
|
+
return OMapping(null, null, null, null);
|
10402
|
+
const { names, resolvedSources } = map;
|
10403
|
+
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);
|
10404
|
+
}
|
10344
10405
|
function OMapping(source, line, column, name) {
|
10345
10406
|
return { source, line, column, name };
|
10346
10407
|
}
|
@@ -10356,15 +10417,6 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
10356
10417
|
return index;
|
10357
10418
|
}
|
10358
10419
|
|
10359
|
-
/**
|
10360
|
-
* Gets the index associated with `key` in the backing array, if it is already present.
|
10361
|
-
*/
|
10362
|
-
let get;
|
10363
|
-
/**
|
10364
|
-
* Puts `key` into the backing array, if it is not already present. Returns
|
10365
|
-
* the index of the `key` in the backing array.
|
10366
|
-
*/
|
10367
|
-
let put;
|
10368
10420
|
/**
|
10369
10421
|
* SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
|
10370
10422
|
* index of the `key` in the backing array.
|
@@ -10379,17 +10431,48 @@ class SetArray {
|
|
10379
10431
|
this.array = [];
|
10380
10432
|
}
|
10381
10433
|
}
|
10382
|
-
|
10383
|
-
|
10384
|
-
|
10385
|
-
|
10386
|
-
|
10387
|
-
|
10388
|
-
|
10389
|
-
|
10390
|
-
|
10391
|
-
|
10392
|
-
|
10434
|
+
/**
|
10435
|
+
* Typescript doesn't allow friend access to private fields, so this just casts the set into a type
|
10436
|
+
* with public access modifiers.
|
10437
|
+
*/
|
10438
|
+
function cast$1(set) {
|
10439
|
+
return set;
|
10440
|
+
}
|
10441
|
+
/**
|
10442
|
+
* Gets the index associated with `key` in the backing array, if it is already present.
|
10443
|
+
*/
|
10444
|
+
function get(setarr, key) {
|
10445
|
+
return cast$1(setarr)._indexes[key];
|
10446
|
+
}
|
10447
|
+
/**
|
10448
|
+
* Puts `key` into the backing array, if it is not already present. Returns
|
10449
|
+
* the index of the `key` in the backing array.
|
10450
|
+
*/
|
10451
|
+
function put(setarr, key) {
|
10452
|
+
// The key may or may not be present. If it is present, it's a number.
|
10453
|
+
const index = get(setarr, key);
|
10454
|
+
if (index !== undefined)
|
10455
|
+
return index;
|
10456
|
+
const { array, _indexes: indexes } = cast$1(setarr);
|
10457
|
+
const length = array.push(key);
|
10458
|
+
return (indexes[key] = length - 1);
|
10459
|
+
}
|
10460
|
+
/**
|
10461
|
+
* Removes the key, if it exists in the set.
|
10462
|
+
*/
|
10463
|
+
function remove(setarr, key) {
|
10464
|
+
const index = get(setarr, key);
|
10465
|
+
if (index === undefined)
|
10466
|
+
return;
|
10467
|
+
const { array, _indexes: indexes } = cast$1(setarr);
|
10468
|
+
for (let i = index + 1; i < array.length; i++) {
|
10469
|
+
const k = array[i];
|
10470
|
+
array[i - 1] = k;
|
10471
|
+
indexes[k]--;
|
10472
|
+
}
|
10473
|
+
indexes[key] = undefined;
|
10474
|
+
array.pop();
|
10475
|
+
}
|
10393
10476
|
|
10394
10477
|
const COLUMN = 0;
|
10395
10478
|
const SOURCES_INDEX = 1;
|
@@ -10398,88 +10481,100 @@ const SOURCE_COLUMN = 3;
|
|
10398
10481
|
const NAMES_INDEX = 4;
|
10399
10482
|
|
10400
10483
|
const NO_NAME = -1;
|
10484
|
+
/**
|
10485
|
+
* Provides the state to generate a sourcemap.
|
10486
|
+
*/
|
10487
|
+
class GenMapping {
|
10488
|
+
constructor({ file, sourceRoot } = {}) {
|
10489
|
+
this._names = new SetArray();
|
10490
|
+
this._sources = new SetArray();
|
10491
|
+
this._sourcesContent = [];
|
10492
|
+
this._mappings = [];
|
10493
|
+
this.file = file;
|
10494
|
+
this.sourceRoot = sourceRoot;
|
10495
|
+
this._ignoreList = new SetArray();
|
10496
|
+
}
|
10497
|
+
}
|
10498
|
+
/**
|
10499
|
+
* Typescript doesn't allow friend access to private fields, so this just casts the map into a type
|
10500
|
+
* with public access modifiers.
|
10501
|
+
*/
|
10502
|
+
function cast(map) {
|
10503
|
+
return map;
|
10504
|
+
}
|
10401
10505
|
/**
|
10402
10506
|
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
10403
10507
|
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
10404
10508
|
* not add a segment with a lower generated line/column than one that came before.
|
10405
10509
|
*/
|
10406
|
-
|
10510
|
+
const maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
10511
|
+
return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
10512
|
+
};
|
10407
10513
|
/**
|
10408
10514
|
* Adds/removes the content of the source file to the source map.
|
10409
10515
|
*/
|
10410
|
-
|
10516
|
+
function setSourceContent(map, source, content) {
|
10517
|
+
const { _sources: sources, _sourcesContent: sourcesContent } = cast(map);
|
10518
|
+
const index = put(sources, source);
|
10519
|
+
sourcesContent[index] = content;
|
10520
|
+
}
|
10521
|
+
function setIgnore(map, source, ignore = true) {
|
10522
|
+
const { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = cast(map);
|
10523
|
+
const index = put(sources, source);
|
10524
|
+
if (index === sourcesContent.length)
|
10525
|
+
sourcesContent[index] = null;
|
10526
|
+
if (ignore)
|
10527
|
+
put(ignoreList, index);
|
10528
|
+
else
|
10529
|
+
remove(ignoreList, index);
|
10530
|
+
}
|
10411
10531
|
/**
|
10412
10532
|
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
10413
10533
|
* a sourcemap, or to JSON.stringify.
|
10414
10534
|
*/
|
10415
|
-
|
10535
|
+
function toDecodedMap(map) {
|
10536
|
+
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList, } = cast(map);
|
10537
|
+
removeEmptyFinalLines(mappings);
|
10538
|
+
return {
|
10539
|
+
version: 3,
|
10540
|
+
file: map.file || undefined,
|
10541
|
+
names: names.array,
|
10542
|
+
sourceRoot: map.sourceRoot || undefined,
|
10543
|
+
sources: sources.array,
|
10544
|
+
sourcesContent,
|
10545
|
+
mappings,
|
10546
|
+
ignoreList: ignoreList.array,
|
10547
|
+
};
|
10548
|
+
}
|
10416
10549
|
/**
|
10417
10550
|
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
10418
10551
|
* a sourcemap, or to JSON.stringify.
|
10419
10552
|
*/
|
10420
|
-
|
10553
|
+
function toEncodedMap(map) {
|
10554
|
+
const decoded = toDecodedMap(map);
|
10555
|
+
return Object.assign(Object.assign({}, decoded), { mappings: encode$1(decoded.mappings) });
|
10556
|
+
}
|
10421
10557
|
// This split declaration is only so that terser can elminiate the static initialization block.
|
10422
|
-
|
10423
|
-
|
10424
|
-
|
10425
|
-
|
10426
|
-
|
10427
|
-
|
10428
|
-
|
10429
|
-
|
10430
|
-
|
10431
|
-
|
10432
|
-
|
10433
|
-
|
10558
|
+
function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
|
10559
|
+
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = cast(map);
|
10560
|
+
const line = getLine(mappings, genLine);
|
10561
|
+
const index = getColumnIndex(line, genColumn);
|
10562
|
+
if (!source) {
|
10563
|
+
if (skipable && skipSourceless(line, index))
|
10564
|
+
return;
|
10565
|
+
return insert(line, index, [genColumn]);
|
10566
|
+
}
|
10567
|
+
const sourcesIndex = put(sources, source);
|
10568
|
+
const namesIndex = name ? put(names, name) : NO_NAME;
|
10569
|
+
if (sourcesIndex === sourcesContent.length)
|
10570
|
+
sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
|
10571
|
+
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
10572
|
+
return;
|
10434
10573
|
}
|
10574
|
+
return insert(line, index, name
|
10575
|
+
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
10576
|
+
: [genColumn, sourcesIndex, sourceLine, sourceColumn]);
|
10435
10577
|
}
|
10436
|
-
(() => {
|
10437
|
-
maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
10438
|
-
return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
10439
|
-
};
|
10440
|
-
setSourceContent = (map, source, content) => {
|
10441
|
-
const { _sources: sources, _sourcesContent: sourcesContent } = map;
|
10442
|
-
sourcesContent[put(sources, source)] = content;
|
10443
|
-
};
|
10444
|
-
toDecodedMap = (map) => {
|
10445
|
-
const { file, sourceRoot, _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
10446
|
-
removeEmptyFinalLines(mappings);
|
10447
|
-
return {
|
10448
|
-
version: 3,
|
10449
|
-
file: file || undefined,
|
10450
|
-
names: names.array,
|
10451
|
-
sourceRoot: sourceRoot || undefined,
|
10452
|
-
sources: sources.array,
|
10453
|
-
sourcesContent,
|
10454
|
-
mappings,
|
10455
|
-
};
|
10456
|
-
};
|
10457
|
-
toEncodedMap = (map) => {
|
10458
|
-
const decoded = toDecodedMap(map);
|
10459
|
-
return Object.assign(Object.assign({}, decoded), { mappings: encode$1(decoded.mappings) });
|
10460
|
-
};
|
10461
|
-
// Internal helpers
|
10462
|
-
addSegmentInternal = (skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
10463
|
-
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
10464
|
-
const line = getLine(mappings, genLine);
|
10465
|
-
const index = getColumnIndex(line, genColumn);
|
10466
|
-
if (!source) {
|
10467
|
-
if (skipable && skipSourceless(line, index))
|
10468
|
-
return;
|
10469
|
-
return insert(line, index, [genColumn]);
|
10470
|
-
}
|
10471
|
-
const sourcesIndex = put(sources, source);
|
10472
|
-
const namesIndex = name ? put(names, name) : NO_NAME;
|
10473
|
-
if (sourcesIndex === sourcesContent.length)
|
10474
|
-
sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
|
10475
|
-
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
10476
|
-
return;
|
10477
|
-
}
|
10478
|
-
return insert(line, index, name
|
10479
|
-
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
10480
|
-
: [genColumn, sourcesIndex, sourceLine, sourceColumn]);
|
10481
|
-
};
|
10482
|
-
})();
|
10483
10578
|
function getLine(mappings, index) {
|
10484
10579
|
for (let i = mappings.length; i <= index; i++) {
|
10485
10580
|
mappings[i] = [];
|
@@ -10538,17 +10633,18 @@ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIn
|
|
10538
10633
|
namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME));
|
10539
10634
|
}
|
10540
10635
|
|
10541
|
-
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null);
|
10636
|
+
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false);
|
10542
10637
|
const EMPTY_SOURCES = [];
|
10543
|
-
function SegmentObject(source, line, column, name, content) {
|
10544
|
-
return { source, line, column, name, content };
|
10638
|
+
function SegmentObject(source, line, column, name, content, ignore) {
|
10639
|
+
return { source, line, column, name, content, ignore };
|
10545
10640
|
}
|
10546
|
-
function Source(map, sources, source, content) {
|
10641
|
+
function Source(map, sources, source, content, ignore) {
|
10547
10642
|
return {
|
10548
10643
|
map,
|
10549
10644
|
sources,
|
10550
10645
|
source,
|
10551
10646
|
content,
|
10647
|
+
ignore,
|
10552
10648
|
};
|
10553
10649
|
}
|
10554
10650
|
/**
|
@@ -10556,14 +10652,14 @@ function Source(map, sources, source, content) {
|
|
10556
10652
|
* (which may themselves be SourceMapTrees).
|
10557
10653
|
*/
|
10558
10654
|
function MapSource(map, sources) {
|
10559
|
-
return Source(map, sources, '', null);
|
10655
|
+
return Source(map, sources, '', null, false);
|
10560
10656
|
}
|
10561
10657
|
/**
|
10562
10658
|
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
10563
10659
|
* segment tracing ends at the `OriginalSource`.
|
10564
10660
|
*/
|
10565
|
-
function OriginalSource(source, content) {
|
10566
|
-
return Source(null, EMPTY_SOURCES, source, content);
|
10661
|
+
function OriginalSource(source, content, ignore) {
|
10662
|
+
return Source(null, EMPTY_SOURCES, source, content, ignore);
|
10567
10663
|
}
|
10568
10664
|
/**
|
10569
10665
|
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
@@ -10592,10 +10688,12 @@ function traceMappings(tree) {
|
|
10592
10688
|
if (traced == null)
|
10593
10689
|
continue;
|
10594
10690
|
}
|
10595
|
-
const { column, line, name, content, source } = traced;
|
10691
|
+
const { column, line, name, content, source, ignore } = traced;
|
10596
10692
|
maybeAddSegment(gen, i, genCol, source, line, column, name);
|
10597
10693
|
if (source && content != null)
|
10598
10694
|
setSourceContent(gen, source, content);
|
10695
|
+
if (ignore)
|
10696
|
+
setIgnore(gen, source, true);
|
10599
10697
|
}
|
10600
10698
|
}
|
10601
10699
|
return gen;
|
@@ -10606,7 +10704,7 @@ function traceMappings(tree) {
|
|
10606
10704
|
*/
|
10607
10705
|
function originalPositionFor(source, line, column, name) {
|
10608
10706
|
if (!source.map) {
|
10609
|
-
return SegmentObject(source.source, line, column, name, source.content);
|
10707
|
+
return SegmentObject(source.source, line, column, name, source.content, source.ignore);
|
10610
10708
|
}
|
10611
10709
|
const segment = traceSegment(source.map, line, column);
|
10612
10710
|
// If we couldn't find a segment, then this doesn't exist in the sourcemap.
|
@@ -10651,7 +10749,7 @@ function buildSourceMapTree(input, loader) {
|
|
10651
10749
|
return tree;
|
10652
10750
|
}
|
10653
10751
|
function build$2(map, loader, importer, importerDepth) {
|
10654
|
-
const { resolvedSources, sourcesContent } = map;
|
10752
|
+
const { resolvedSources, sourcesContent, ignoreList } = map;
|
10655
10753
|
const depth = importerDepth + 1;
|
10656
10754
|
const children = resolvedSources.map((sourceFile, i) => {
|
10657
10755
|
// The loading context gives the loader more information about why this file is being loaded
|
@@ -10663,20 +10761,22 @@ function build$2(map, loader, importer, importerDepth) {
|
|
10663
10761
|
depth,
|
10664
10762
|
source: sourceFile || '',
|
10665
10763
|
content: undefined,
|
10764
|
+
ignore: undefined,
|
10666
10765
|
};
|
10667
10766
|
// Use the provided loader callback to retrieve the file's sourcemap.
|
10668
10767
|
// TODO: We should eventually support async loading of sourcemap files.
|
10669
10768
|
const sourceMap = loader(ctx.source, ctx);
|
10670
|
-
const { source, content } = ctx;
|
10769
|
+
const { source, content, ignore } = ctx;
|
10671
10770
|
// If there is a sourcemap, then we need to recurse into it to load its source files.
|
10672
10771
|
if (sourceMap)
|
10673
10772
|
return build$2(new TraceMap(sourceMap, source), loader, source, depth);
|
10674
|
-
// Else, it's an
|
10773
|
+
// Else, it's an unmodified source file.
|
10675
10774
|
// The contents of this unmodified source file can be overridden via the loader context,
|
10676
10775
|
// allowing it to be explicitly null or a string. If it remains undefined, we fall back to
|
10677
10776
|
// the importing sourcemap's `sourcesContent` field.
|
10678
10777
|
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
|
10679
|
-
|
10778
|
+
const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false;
|
10779
|
+
return OriginalSource(source, sourceContent, ignored);
|
10680
10780
|
});
|
10681
10781
|
return MapSource(map, children);
|
10682
10782
|
}
|
@@ -10692,6 +10792,7 @@ class SourceMap {
|
|
10692
10792
|
this.file = out.file;
|
10693
10793
|
this.mappings = out.mappings;
|
10694
10794
|
this.names = out.names;
|
10795
|
+
this.ignoreList = out.ignoreList;
|
10695
10796
|
this.sourceRoot = out.sourceRoot;
|
10696
10797
|
this.sources = out.sources;
|
10697
10798
|
if (!options.excludeContent) {
|
@@ -12000,28 +12101,6 @@ function traverseBetweenDirs(longerDir, shorterDir, cb) {
|
|
12000
12101
|
}
|
12001
12102
|
|
12002
12103
|
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
12104
|
const replaceSlashOrColonRE = /[/:]/g;
|
12026
12105
|
const replaceDotRE = /\./g;
|
12027
12106
|
const replaceNestedIdRE = /(\s*>\s*)/g;
|
@@ -12125,10 +12204,9 @@ const urlCanParse = URL$3.canParse ??
|
|
12125
12204
|
}
|
12126
12205
|
});
|
12127
12206
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
12128
|
-
const isWindows$3 = os$4.platform() === 'win32';
|
12129
12207
|
const VOLUME_RE = /^[A-Z]:/i;
|
12130
12208
|
function normalizePath$3(id) {
|
12131
|
-
return path$o.posix.normalize(isWindows$
|
12209
|
+
return path$o.posix.normalize(isWindows$5 ? slash$1(id) : id);
|
12132
12210
|
}
|
12133
12211
|
function fsPathFromId(id) {
|
12134
12212
|
const fsPath = normalizePath$3(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
|
@@ -12137,12 +12215,6 @@ function fsPathFromId(id) {
|
|
12137
12215
|
function fsPathFromUrl(url) {
|
12138
12216
|
return fsPathFromId(cleanUrl(url));
|
12139
12217
|
}
|
12140
|
-
function withTrailingSlash(path) {
|
12141
|
-
if (path[path.length - 1] !== '/') {
|
12142
|
-
return `${path}/`;
|
12143
|
-
}
|
12144
|
-
return path;
|
12145
|
-
}
|
12146
12218
|
/**
|
12147
12219
|
* Check if dir is a parent of file
|
12148
12220
|
*
|
@@ -12170,10 +12242,6 @@ function isSameFileUri(file1, file2) {
|
|
12170
12242
|
return (file1 === file2 ||
|
12171
12243
|
(isCaseInsensitiveFS && file1.toLowerCase() === file2.toLowerCase()));
|
12172
12244
|
}
|
12173
|
-
const postfixRE = /[?#].*$/;
|
12174
|
-
function cleanUrl(url) {
|
12175
|
-
return url.replace(postfixRE, '');
|
12176
|
-
}
|
12177
12245
|
const externalRE = /^(https?:)?\/\//;
|
12178
12246
|
const isExternalUrl = (url) => externalRE.test(url);
|
12179
12247
|
const dataUrlRE = /^\s*data:/i;
|
@@ -12223,7 +12291,7 @@ function injectQuery(url, queryToInject) {
|
|
12223
12291
|
const resolvedUrl = new URL$3(url.replace(replacePercentageRE, '%25'), 'relative:///');
|
12224
12292
|
const { search, hash } = resolvedUrl;
|
12225
12293
|
let pathname = cleanUrl(url);
|
12226
|
-
pathname = isWindows$
|
12294
|
+
pathname = isWindows$5 ? slash$1(pathname) : pathname;
|
12227
12295
|
return `${pathname}?${queryToInject}${search ? `&` + search.slice(1) : ''}${hash ?? ''}`;
|
12228
12296
|
}
|
12229
12297
|
const timestampRE = /\bt=\d{13}&?\b/;
|
@@ -12489,7 +12557,7 @@ async function recursiveReaddir(dir) {
|
|
12489
12557
|
// `fs.realpathSync.native` resolves differently in Windows network drive,
|
12490
12558
|
// causing file read errors. skip for now.
|
12491
12559
|
// https://github.com/nodejs/node/issues/37737
|
12492
|
-
let safeRealpathSync = isWindows$
|
12560
|
+
let safeRealpathSync = isWindows$5
|
12493
12561
|
? windowsSafeRealPathSync
|
12494
12562
|
: fs$l.realpathSync.native;
|
12495
12563
|
// Based on https://github.com/larrybahr/windows-network-drive
|
@@ -12857,7 +12925,7 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
12857
12925
|
continue;
|
12858
12926
|
}
|
12859
12927
|
if (Array.isArray(existing) || Array.isArray(value)) {
|
12860
|
-
merged[key] = [...arraify(existing
|
12928
|
+
merged[key] = [...arraify(existing), ...arraify(value)];
|
12861
12929
|
continue;
|
12862
12930
|
}
|
12863
12931
|
if (isObject$1(existing) && isObject$1(value)) {
|
@@ -12943,7 +13011,7 @@ const windowsDrivePathPrefixRE = /^[A-Za-z]:[/\\]/;
|
|
12943
13011
|
* this function returns false for them but true for absolute paths (e.g. C:/something)
|
12944
13012
|
*/
|
12945
13013
|
const isNonDriveRelativeAbsolutePath = (p) => {
|
12946
|
-
if (!isWindows$
|
13014
|
+
if (!isWindows$5)
|
12947
13015
|
return p[0] === '/';
|
12948
13016
|
return windowsDrivePathPrefixRE.test(p);
|
12949
13017
|
};
|
@@ -14004,7 +14072,7 @@ async function parse$f(filename, options) {
|
|
14004
14072
|
/** @type {Promise<import('./public.d.ts').TSConfckParseResult>}*/
|
14005
14073
|
promise
|
14006
14074
|
} = makePromise();
|
14007
|
-
cache?.setParseResult(filename, promise);
|
14075
|
+
cache?.setParseResult(filename, promise, true);
|
14008
14076
|
try {
|
14009
14077
|
let tsconfigFile =
|
14010
14078
|
(await resolveTSConfigJson(filename, cache)) || (await find(filename, options));
|
@@ -14043,7 +14111,7 @@ async function getParsedDeep(filename, cache, options) {
|
|
14043
14111
|
parseExtends(result, cache),
|
14044
14112
|
parseReferences(result, options)
|
14045
14113
|
]).then(() => result);
|
14046
|
-
cache.setParseResult(filename, promise);
|
14114
|
+
cache.setParseResult(filename, promise, true);
|
14047
14115
|
return promise;
|
14048
14116
|
}
|
14049
14117
|
return result;
|
@@ -14057,7 +14125,11 @@ async function getParsedDeep(filename, cache, options) {
|
|
14057
14125
|
* @returns {Promise<import('./public.d.ts').TSConfckParseResult>}
|
14058
14126
|
*/
|
14059
14127
|
async function parseFile$1(tsconfigFile, cache, skipCache) {
|
14060
|
-
if (
|
14128
|
+
if (
|
14129
|
+
!skipCache &&
|
14130
|
+
cache?.hasParseResult(tsconfigFile) &&
|
14131
|
+
!cache.getParseResult(tsconfigFile)._isRootFile_
|
14132
|
+
) {
|
14061
14133
|
return cache.getParseResult(tsconfigFile);
|
14062
14134
|
}
|
14063
14135
|
const promise = promises$1
|
@@ -14079,7 +14151,10 @@ async function parseFile$1(tsconfigFile, cache, skipCache) {
|
|
14079
14151
|
e
|
14080
14152
|
);
|
14081
14153
|
});
|
14082
|
-
if (
|
14154
|
+
if (
|
14155
|
+
!skipCache &&
|
14156
|
+
(!cache?.hasParseResult(tsconfigFile) || !cache.getParseResult(tsconfigFile)._isRootFile_)
|
14157
|
+
) {
|
14083
14158
|
cache?.setParseResult(tsconfigFile, promise);
|
14084
14159
|
}
|
14085
14160
|
return promise;
|
@@ -14461,9 +14536,17 @@ class TSConfckCache {
|
|
14461
14536
|
* @internal
|
14462
14537
|
* @private
|
14463
14538
|
* @param file
|
14539
|
+
* @param {boolean} isRootFile a flag to check if current file which involking the parse() api, used to distinguish the normal cache which only parsed by parseFile()
|
14464
14540
|
* @param {Promise<T>} result
|
14465
14541
|
*/
|
14466
|
-
setParseResult(file, result) {
|
14542
|
+
setParseResult(file, result, isRootFile = false) {
|
14543
|
+
// _isRootFile_ is a temporary property for Promise result, used to prevent deadlock with cache
|
14544
|
+
Object.defineProperty(result, '_isRootFile_', {
|
14545
|
+
value: isRootFile,
|
14546
|
+
writable: false,
|
14547
|
+
enumerable: false,
|
14548
|
+
configurable: false
|
14549
|
+
});
|
14467
14550
|
this.#parsed.set(file, result);
|
14468
14551
|
result
|
14469
14552
|
.then((parsed) => {
|
@@ -29594,7 +29677,7 @@ function stripLiteralDetailed(code, options) {
|
|
29594
29677
|
var main$1 = {exports: {}};
|
29595
29678
|
|
29596
29679
|
var name = "dotenv";
|
29597
|
-
var version$2 = "16.4.
|
29680
|
+
var version$2 = "16.4.5";
|
29598
29681
|
var description = "Loads environment variables from .env file";
|
29599
29682
|
var main = "lib/main.js";
|
29600
29683
|
var types$2 = "lib/main.d.ts";
|
@@ -29891,52 +29974,48 @@ function configDotenv (options) {
|
|
29891
29974
|
}
|
29892
29975
|
}
|
29893
29976
|
|
29894
|
-
let
|
29977
|
+
let optionPaths = [dotenvPath]; // default, look for .env
|
29895
29978
|
if (options && options.path) {
|
29896
29979
|
if (!Array.isArray(options.path)) {
|
29897
|
-
|
29898
|
-
optionPathsThatExist = [_resolveHome(options.path)];
|
29899
|
-
}
|
29980
|
+
optionPaths = [_resolveHome(options.path)];
|
29900
29981
|
} else {
|
29982
|
+
optionPaths = []; // reset default
|
29901
29983
|
for (const filepath of options.path) {
|
29902
|
-
|
29903
|
-
optionPathsThatExist.push(_resolveHome(filepath));
|
29904
|
-
}
|
29984
|
+
optionPaths.push(_resolveHome(filepath));
|
29905
29985
|
}
|
29906
29986
|
}
|
29907
|
-
|
29908
|
-
if (!optionPathsThatExist.length) {
|
29909
|
-
optionPathsThatExist = [dotenvPath];
|
29910
|
-
}
|
29911
29987
|
}
|
29912
29988
|
|
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
29989
|
// Build the parsed data in a temporary object (because we need to return it). Once we have the final
|
29917
29990
|
// parsed data, we will combine it with process.env (or options.processEnv if provided).
|
29918
|
-
|
29919
|
-
const
|
29920
|
-
|
29921
|
-
|
29991
|
+
let lastError;
|
29992
|
+
const parsedAll = {};
|
29993
|
+
for (const path of optionPaths) {
|
29994
|
+
try {
|
29922
29995
|
// Specifying an encoding returns a string instead of a buffer
|
29923
|
-
const
|
29924
|
-
DotenvModule.populate(parsed, singleFileParsed, options);
|
29925
|
-
}
|
29996
|
+
const parsed = DotenvModule.parse(fs$9.readFileSync(path, { encoding }));
|
29926
29997
|
|
29927
|
-
|
29928
|
-
|
29929
|
-
|
29998
|
+
DotenvModule.populate(parsedAll, parsed, options);
|
29999
|
+
} catch (e) {
|
30000
|
+
if (debug) {
|
30001
|
+
_debug(`Failed to load ${path} ${e.message}`);
|
30002
|
+
}
|
30003
|
+
lastError = e;
|
29930
30004
|
}
|
30005
|
+
}
|
29931
30006
|
|
29932
|
-
|
29933
|
-
|
29934
|
-
|
29935
|
-
|
29936
|
-
|
29937
|
-
|
30007
|
+
let processEnv = process.env;
|
30008
|
+
if (options && options.processEnv != null) {
|
30009
|
+
processEnv = options.processEnv;
|
30010
|
+
}
|
30011
|
+
|
30012
|
+
DotenvModule.populate(processEnv, parsedAll, options);
|
30013
|
+
|
30014
|
+
if (lastError) {
|
30015
|
+
return { parsed: parsedAll, error: lastError }
|
30016
|
+
} else {
|
30017
|
+
return { parsed: parsedAll }
|
29938
30018
|
}
|
29939
|
-
return { parsed }
|
29940
30019
|
}
|
29941
30020
|
|
29942
30021
|
// Populates process.env from .env file
|
@@ -32094,8 +32173,8 @@ function createCachedImport(imp) {
|
|
32094
32173
|
return cached;
|
32095
32174
|
};
|
32096
32175
|
}
|
32097
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
32098
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
32176
|
+
const importPostcssImport = createCachedImport(() => import('./dep-sFlFG1c_.js').then(function (n) { return n.i; }));
|
32177
|
+
const importPostcssModules = createCachedImport(() => import('./dep-pxQDj-UY.js').then(function (n) { return n.i; }));
|
32099
32178
|
const importPostcss = createCachedImport(() => import('postcss'));
|
32100
32179
|
const preprocessorWorkerControllerCache = new WeakMap();
|
32101
32180
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -39117,7 +39196,7 @@ function matchAll$1(regex, string, addition) {
|
|
39117
39196
|
...match.groups,
|
39118
39197
|
code: match[0],
|
39119
39198
|
start: match.index,
|
39120
|
-
end: match.index + match[0].length
|
39199
|
+
end: (match.index || 0) + match[0].length
|
39121
39200
|
});
|
39122
39201
|
}
|
39123
39202
|
return matches;
|
@@ -39622,7 +39701,6 @@ function determineSpecificType(value) {
|
|
39622
39701
|
|
39623
39702
|
return `type ${typeof value} (${inspected})`
|
39624
39703
|
}
|
39625
|
-
pathToFileURL(process.cwd());
|
39626
39704
|
|
39627
39705
|
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
39706
|
const TYPE_RE = /^\s*?type\s/;
|
@@ -39635,8 +39713,11 @@ function findStaticImports(code) {
|
|
39635
39713
|
function parseStaticImport(matched) {
|
39636
39714
|
const cleanedImports = clearImports(matched.imports);
|
39637
39715
|
const namedImports = {};
|
39638
|
-
|
39639
|
-
|
39716
|
+
const _matches = cleanedImports.match(/{([^}]*)}/)?.[1]?.split(",") || [];
|
39717
|
+
for (const namedImport of _matches) {
|
39718
|
+
const _match = namedImport.match(/^\s*(\S*) as (\S*)\s*$/);
|
39719
|
+
const source = _match?.[1] || namedImport.trim();
|
39720
|
+
const importName = _match?.[2] || source;
|
39640
39721
|
if (source && !TYPE_RE.test(source)) {
|
39641
39722
|
namedImports[source] = importName;
|
39642
39723
|
}
|
@@ -47527,7 +47608,7 @@ function resolvePlugin(resolveOptions) {
|
|
47527
47608
|
}
|
47528
47609
|
}
|
47529
47610
|
// drive relative fs paths (only windows)
|
47530
|
-
if (isWindows$
|
47611
|
+
if (isWindows$5 && id[0] === '/') {
|
47531
47612
|
const basedir = importer ? path$o.dirname(importer) : process.cwd();
|
47532
47613
|
const fsPath = path$o.resolve(basedir, id);
|
47533
47614
|
if ((res = tryFsResolve(fsPath, options))) {
|
@@ -47638,14 +47719,16 @@ function resolveSubpathImports(id, importer, options, targetWeb) {
|
|
47638
47719
|
const pkgData = findNearestPackageData(basedir, options.packageCache);
|
47639
47720
|
if (!pkgData)
|
47640
47721
|
return;
|
47641
|
-
let
|
47722
|
+
let { file: idWithoutPostfix, postfix } = splitFileAndPostfix(id.slice(1));
|
47723
|
+
idWithoutPostfix = '#' + idWithoutPostfix;
|
47724
|
+
let importsPath = resolveExportsOrImports(pkgData.data, idWithoutPostfix, options, targetWeb, 'imports');
|
47642
47725
|
if (importsPath?.[0] === '.') {
|
47643
47726
|
importsPath = path$o.relative(basedir, path$o.join(pkgData.dir, importsPath));
|
47644
47727
|
if (importsPath[0] !== '.') {
|
47645
47728
|
importsPath = `./${importsPath}`;
|
47646
47729
|
}
|
47647
47730
|
}
|
47648
|
-
return importsPath;
|
47731
|
+
return importsPath + postfix;
|
47649
47732
|
}
|
47650
47733
|
function ensureVersionQuery(resolved, id, options, depsOptimizer) {
|
47651
47734
|
if (!options.isBuild &&
|
@@ -49061,18 +49144,23 @@ const inlineRE = /[?&]inline\b/;
|
|
49061
49144
|
const WORKER_FILE_ID = 'worker_file';
|
49062
49145
|
const workerCache = new WeakMap();
|
49063
49146
|
function saveEmitWorkerAsset(config, asset) {
|
49064
|
-
const fileName = asset.fileName;
|
49065
49147
|
const workerMap = workerCache.get(config.mainConfig || config);
|
49066
|
-
workerMap.assets.set(fileName, asset);
|
49148
|
+
workerMap.assets.set(asset.fileName, asset);
|
49067
49149
|
}
|
49068
49150
|
async function bundleWorkerEntry(config, id) {
|
49151
|
+
const input = cleanUrl(id);
|
49152
|
+
const newBundleChain = [...config.bundleChain, input];
|
49153
|
+
if (config.bundleChain.includes(input)) {
|
49154
|
+
throw new Error('Circular worker imports detected. Vite does not support it. ' +
|
49155
|
+
`Import chain: ${newBundleChain.map((id) => prettifyUrl(id, config.root)).join(' -> ')}`);
|
49156
|
+
}
|
49069
49157
|
// bundle the file as entry to support imports
|
49070
49158
|
const { rollup } = await import('rollup');
|
49071
49159
|
const { plugins, rollupOptions, format } = config.worker;
|
49072
49160
|
const bundle = await rollup({
|
49073
49161
|
...rollupOptions,
|
49074
|
-
input
|
49075
|
-
plugins: await plugins(),
|
49162
|
+
input,
|
49163
|
+
plugins: await plugins(newBundleChain),
|
49076
49164
|
onwarn(warning, warn) {
|
49077
49165
|
onRollupWarning(warning, warn, config);
|
49078
49166
|
},
|
@@ -49103,7 +49191,6 @@ async function bundleWorkerEntry(config, id) {
|
|
49103
49191
|
saveEmitWorkerAsset(config, {
|
49104
49192
|
fileName: outputChunk.fileName,
|
49105
49193
|
source: outputChunk.code,
|
49106
|
-
type: 'asset',
|
49107
49194
|
});
|
49108
49195
|
}
|
49109
49196
|
});
|
@@ -49122,7 +49209,6 @@ function emitSourcemapForWorkerEntry(config, chunk) {
|
|
49122
49209
|
const mapFileName = chunk.fileName + '.map';
|
49123
49210
|
saveEmitWorkerAsset(config, {
|
49124
49211
|
fileName: mapFileName,
|
49125
|
-
type: 'asset',
|
49126
49212
|
source: data,
|
49127
49213
|
});
|
49128
49214
|
}
|
@@ -49147,7 +49233,6 @@ async function workerFileToUrl(config, id) {
|
|
49147
49233
|
saveEmitWorkerAsset(config, {
|
49148
49234
|
fileName,
|
49149
49235
|
source: outputChunk.code,
|
49150
|
-
type: 'asset',
|
49151
49236
|
});
|
49152
49237
|
workerMap.bundle.set(id, fileName);
|
49153
49238
|
}
|
@@ -49244,8 +49329,6 @@ function webWorkerPlugin(config) {
|
|
49244
49329
|
const workerMatch = workerOrSharedWorkerRE.exec(id);
|
49245
49330
|
if (!workerMatch)
|
49246
49331
|
return;
|
49247
|
-
// stringified url or `new URL(...)`
|
49248
|
-
let url;
|
49249
49332
|
const { format } = config.worker;
|
49250
49333
|
const workerConstructor = workerMatch[1] === 'sharedworker' ? 'SharedWorker' : 'Worker';
|
49251
49334
|
const workerType = isBuild
|
@@ -49257,8 +49340,12 @@ function webWorkerPlugin(config) {
|
|
49257
49340
|
${workerType === 'module' ? `type: "module",` : ''}
|
49258
49341
|
name: options?.name
|
49259
49342
|
}`;
|
49343
|
+
let urlCode;
|
49260
49344
|
if (isBuild) {
|
49261
|
-
if (
|
49345
|
+
if (isWorker && this.getModuleInfo(cleanUrl(id))?.isEntry) {
|
49346
|
+
urlCode = 'self.location.href';
|
49347
|
+
}
|
49348
|
+
else if (inlineRE.test(id)) {
|
49262
49349
|
const chunk = await bundleWorkerEntry(config, id);
|
49263
49350
|
const encodedJs = `const encodedJs = "${Buffer.from(chunk.code).toString('base64')}";`;
|
49264
49351
|
const code =
|
@@ -49309,23 +49396,24 @@ function webWorkerPlugin(config) {
|
|
49309
49396
|
};
|
49310
49397
|
}
|
49311
49398
|
else {
|
49312
|
-
|
49399
|
+
urlCode = JSON.stringify(await workerFileToUrl(config, id));
|
49313
49400
|
}
|
49314
49401
|
}
|
49315
49402
|
else {
|
49316
|
-
url = await fileToUrl$1(cleanUrl(id), config, this);
|
49403
|
+
let url = await fileToUrl$1(cleanUrl(id), config, this);
|
49317
49404
|
url = injectQuery(url, `${WORKER_FILE_ID}&type=${workerType}`);
|
49405
|
+
urlCode = JSON.stringify(url);
|
49318
49406
|
}
|
49319
49407
|
if (urlRE.test(id)) {
|
49320
49408
|
return {
|
49321
|
-
code: `export default ${
|
49409
|
+
code: `export default ${urlCode}`,
|
49322
49410
|
map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
|
49323
49411
|
};
|
49324
49412
|
}
|
49325
49413
|
return {
|
49326
49414
|
code: `export default function WorkerWrapper(options) {
|
49327
49415
|
return new ${workerConstructor}(
|
49328
|
-
${
|
49416
|
+
${urlCode},
|
49329
49417
|
${workerTypeOption}
|
49330
49418
|
);
|
49331
49419
|
}`,
|
@@ -49363,19 +49451,42 @@ function webWorkerPlugin(config) {
|
|
49363
49451
|
}
|
49364
49452
|
return result();
|
49365
49453
|
},
|
49366
|
-
generateBundle(opts) {
|
49454
|
+
generateBundle(opts, bundle) {
|
49367
49455
|
// @ts-expect-error asset emits are skipped in legacy bundle
|
49368
49456
|
if (opts.__vite_skip_asset_emit__ || isWorker) {
|
49369
49457
|
return;
|
49370
49458
|
}
|
49371
49459
|
const workerMap = workerCache.get(config);
|
49372
49460
|
workerMap.assets.forEach((asset) => {
|
49373
|
-
|
49374
|
-
|
49461
|
+
const duplicateAsset = bundle[asset.fileName];
|
49462
|
+
if (duplicateAsset) {
|
49463
|
+
const content = duplicateAsset.type === 'asset'
|
49464
|
+
? duplicateAsset.source
|
49465
|
+
: duplicateAsset.code;
|
49466
|
+
// don't emit if the file name and the content is same
|
49467
|
+
if (isSameContent(content, asset.source)) {
|
49468
|
+
return;
|
49469
|
+
}
|
49470
|
+
}
|
49471
|
+
this.emitFile({
|
49472
|
+
type: 'asset',
|
49473
|
+
fileName: asset.fileName,
|
49474
|
+
source: asset.source,
|
49475
|
+
});
|
49375
49476
|
});
|
49477
|
+
workerMap.assets.clear();
|
49376
49478
|
},
|
49377
49479
|
};
|
49378
49480
|
}
|
49481
|
+
function isSameContent(a, b) {
|
49482
|
+
if (typeof a === 'string') {
|
49483
|
+
if (typeof b === 'string') {
|
49484
|
+
return a === b;
|
49485
|
+
}
|
49486
|
+
return Buffer.from(a).equals(b);
|
49487
|
+
}
|
49488
|
+
return Buffer.from(b).equals(a);
|
49489
|
+
}
|
49379
49490
|
|
49380
49491
|
/**
|
49381
49492
|
* A plugin to avoid an aliased AND optimized dep from being aliased in src
|
@@ -49578,17 +49689,24 @@ function workerImportMetaUrlPlugin(config) {
|
|
49578
49689
|
? slash$1(path$o.join(config.publicDir, url))
|
49579
49690
|
: slash$1(path$o.resolve(path$o.dirname(id), url));
|
49580
49691
|
}
|
49581
|
-
|
49582
|
-
|
49583
|
-
|
49692
|
+
if (isBuild &&
|
49693
|
+
config.isWorker &&
|
49694
|
+
this.getModuleInfo(cleanUrl(file))?.isEntry) {
|
49695
|
+
s.update(expStart, expEnd, 'self.location.href');
|
49584
49696
|
}
|
49585
49697
|
else {
|
49586
|
-
builtUrl
|
49587
|
-
|
49698
|
+
let builtUrl;
|
49699
|
+
if (isBuild) {
|
49700
|
+
builtUrl = await workerFileToUrl(config, file);
|
49701
|
+
}
|
49702
|
+
else {
|
49703
|
+
builtUrl = await fileToUrl$1(cleanUrl(file), config, this);
|
49704
|
+
builtUrl = injectQuery(builtUrl, `${WORKER_FILE_ID}&type=${workerType}`);
|
49705
|
+
}
|
49706
|
+
s.update(expStart, expEnd,
|
49707
|
+
// add `'' +` to skip vite:asset-import-meta-url plugin
|
49708
|
+
`new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
|
49588
49709
|
}
|
49589
|
-
s.update(expStart, expEnd,
|
49590
|
-
// add `'' +` to skip vite:asset-import-meta-url plugin
|
49591
|
-
`new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
|
49592
49710
|
}
|
49593
49711
|
if (s) {
|
49594
49712
|
return transformStableResult(s, id, config);
|
@@ -49691,7 +49809,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
49691
49809
|
let builtUrl;
|
49692
49810
|
if (file) {
|
49693
49811
|
try {
|
49694
|
-
if (isParentDirectory(publicDir, file)) {
|
49812
|
+
if (publicDir && isParentDirectory(publicDir, file)) {
|
49695
49813
|
const publicPath = '/' + path$o.posix.relative(publicDir, file);
|
49696
49814
|
builtUrl = await fileToUrl$1(publicPath, config, this);
|
49697
49815
|
}
|
@@ -50464,7 +50582,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
50464
50582
|
}
|
50465
50583
|
async load(options) {
|
50466
50584
|
// We may not have added this to our module graph yet, so ensure it exists
|
50467
|
-
await moduleGraph?.ensureEntryFromUrl(unwrapId(options.id), this.ssr);
|
50585
|
+
await moduleGraph?.ensureEntryFromUrl(unwrapId$1(options.id), this.ssr);
|
50468
50586
|
// Not all options passed to this function make sense in the context of loading individual files,
|
50469
50587
|
// but we can at least update the module info properties we support
|
50470
50588
|
updateModuleInfo(options.id, options);
|
@@ -51019,6 +51137,18 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
|
|
51019
51137
|
return;
|
51020
51138
|
const plugin = esbuildScanPlugin(config, container, deps, missing, entries);
|
51021
51139
|
const { plugins = [], ...esbuildOptions } = config.optimizeDeps?.esbuildOptions ?? {};
|
51140
|
+
// The plugin pipeline automatically loads the closest tsconfig.json.
|
51141
|
+
// But esbuild doesn't support reading tsconfig.json if the plugin has resolved the path (https://github.com/evanw/esbuild/issues/2265).
|
51142
|
+
// Due to syntax incompatibilities between the experimental decorators in TypeScript and TC39 decorators,
|
51143
|
+
// we cannot simply set `"experimentalDecorators": true` or `false`. (https://github.com/vitejs/vite/pull/15206#discussion_r1417414715)
|
51144
|
+
// Therefore, we use the closest tsconfig.json from the root to make it work in most cases.
|
51145
|
+
let tsconfigRaw = esbuildOptions.tsconfigRaw;
|
51146
|
+
if (!tsconfigRaw && !esbuildOptions.tsconfig) {
|
51147
|
+
const tsconfigResult = await loadTsconfigJsonForFile(path$o.join(config.root, '_dummy.js'));
|
51148
|
+
if (tsconfigResult.compilerOptions?.experimentalDecorators) {
|
51149
|
+
tsconfigRaw = { compilerOptions: { experimentalDecorators: true } };
|
51150
|
+
}
|
51151
|
+
}
|
51022
51152
|
return await esbuild.context({
|
51023
51153
|
absWorkingDir: process.cwd(),
|
51024
51154
|
write: false,
|
@@ -51031,6 +51161,7 @@ async function prepareEsbuildScanner(config, entries, deps, missing, scanContext
|
|
51031
51161
|
logLevel: 'silent',
|
51032
51162
|
plugins: [...plugins, plugin],
|
51033
51163
|
...esbuildOptions,
|
51164
|
+
tsconfigRaw,
|
51034
51165
|
});
|
51035
51166
|
}
|
51036
51167
|
function orderedDependencies(deps) {
|
@@ -51040,6 +51171,10 @@ function orderedDependencies(deps) {
|
|
51040
51171
|
return Object.fromEntries(depsList);
|
51041
51172
|
}
|
51042
51173
|
function globEntries(pattern, config) {
|
51174
|
+
const resolvedPatterns = arraify(pattern);
|
51175
|
+
if (resolvedPatterns.every((str) => !glob.isDynamicPattern(str))) {
|
51176
|
+
return resolvedPatterns.map((p) => normalizePath$3(path$o.resolve(config.root, p)));
|
51177
|
+
}
|
51043
51178
|
return glob(pattern, {
|
51044
51179
|
cwd: config.root,
|
51045
51180
|
ignore: [
|
@@ -52359,7 +52494,7 @@ function runOptimizeDeps(resolvedConfig, depsInfo, ssr) {
|
|
52359
52494
|
// is safer than a delete-rename operation.
|
52360
52495
|
const temporaryPath = depsCacheDir + getTempSuffix();
|
52361
52496
|
const depsCacheDirPresent = fs$l.existsSync(depsCacheDir);
|
52362
|
-
if (isWindows$
|
52497
|
+
if (isWindows$5) {
|
52363
52498
|
if (depsCacheDirPresent) {
|
52364
52499
|
debug$7?.(colors$1.green(`renaming ${depsCacheDir} to ${temporaryPath}`));
|
52365
52500
|
await safeRename(depsCacheDir, temporaryPath);
|
@@ -53341,7 +53476,7 @@ function serveRawFsMiddleware(server) {
|
|
53341
53476
|
return;
|
53342
53477
|
}
|
53343
53478
|
let newPathname = pathname.slice(FS_PREFIX.length);
|
53344
|
-
if (isWindows$
|
53479
|
+
if (isWindows$5)
|
53345
53480
|
newPathname = newPathname.replace(/^[A-Z]:/i, '');
|
53346
53481
|
url.pathname = encodeURI(newPathname);
|
53347
53482
|
req.url = url.href.slice(url.origin.length);
|
@@ -53716,7 +53851,7 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, server) {
|
|
53716
53851
|
}
|
53717
53852
|
const urlWithoutTimestamp = removeTimestampQuery(rawUrl);
|
53718
53853
|
// hmrUrl must be derived the same way as importAnalysis
|
53719
|
-
const hmrUrl = unwrapId(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
|
53854
|
+
const hmrUrl = unwrapId$1(stripBase(removeImportQuery(urlWithoutTimestamp), server.config.base));
|
53720
53855
|
for (const importedMod of mod.clientImportedModules) {
|
53721
53856
|
if (importedMod.url !== hmrUrl)
|
53722
53857
|
continue;
|
@@ -53749,6 +53884,54 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, server) {
|
|
53749
53884
|
return result;
|
53750
53885
|
}
|
53751
53886
|
|
53887
|
+
/**
|
53888
|
+
* Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
|
53889
|
+
* Top-level imports and dynamic imports work slightly differently in Node.js.
|
53890
|
+
* This function normalizes the differences so it matches prod behaviour.
|
53891
|
+
*/
|
53892
|
+
function analyzeImportedModDifference(mod, rawId, moduleType, metadata) {
|
53893
|
+
// No normalization needed if the user already dynamic imports this module
|
53894
|
+
if (metadata?.isDynamicImport)
|
53895
|
+
return;
|
53896
|
+
// If file path is ESM, everything should be fine
|
53897
|
+
if (moduleType === 'module')
|
53898
|
+
return;
|
53899
|
+
// For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.
|
53900
|
+
// If the user named imports a specifier that can't be analyzed, error.
|
53901
|
+
if (metadata?.importedNames?.length) {
|
53902
|
+
const missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
53903
|
+
if (missingBindings.length) {
|
53904
|
+
const lastBinding = missingBindings[missingBindings.length - 1];
|
53905
|
+
// Copied from Node.js
|
53906
|
+
throw new SyntaxError(`\
|
53907
|
+
[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
53908
|
+
CommonJS modules can always be imported via the default export, for example using:
|
53909
|
+
|
53910
|
+
import pkg from '${rawId}';
|
53911
|
+
const {${missingBindings.join(', ')}} = pkg;
|
53912
|
+
`);
|
53913
|
+
}
|
53914
|
+
}
|
53915
|
+
}
|
53916
|
+
/**
|
53917
|
+
* Guard invalid named exports only, similar to how Node.js errors for top-level imports.
|
53918
|
+
* But since we transform as dynamic imports, we need to emulate the error manually.
|
53919
|
+
*/
|
53920
|
+
function proxyGuardOnlyEsm(mod, rawId, metadata) {
|
53921
|
+
// If the module doesn't import anything explicitly, e.g. `import 'foo'` or
|
53922
|
+
// `import * as foo from 'foo'`, we can skip the proxy guard.
|
53923
|
+
if (!metadata?.importedNames?.length)
|
53924
|
+
return mod;
|
53925
|
+
return new Proxy(mod, {
|
53926
|
+
get(mod, prop) {
|
53927
|
+
if (prop !== 'then' && !(prop in mod)) {
|
53928
|
+
throw new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
|
53929
|
+
}
|
53930
|
+
return mod[prop];
|
53931
|
+
},
|
53932
|
+
});
|
53933
|
+
}
|
53934
|
+
|
53752
53935
|
/**
|
53753
53936
|
* @param {import('estree').Node} param
|
53754
53937
|
* @returns {string[]}
|
@@ -54577,20 +54760,11 @@ function ssrFixStacktrace(e, moduleGraph) {
|
|
54577
54760
|
rewroteStacktraces.add(e);
|
54578
54761
|
}
|
54579
54762
|
|
54580
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
54581
|
-
const AsyncFunction$1 = async function () { }.constructor;
|
54582
|
-
let fnDeclarationLineCount$1 = 0;
|
54583
|
-
{
|
54584
|
-
const body = '/*code*/';
|
54585
|
-
const source = new AsyncFunction$1('a', 'b', body).toString();
|
54586
|
-
fnDeclarationLineCount$1 =
|
54587
|
-
source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
54588
|
-
}
|
54589
54763
|
const pendingModules = new Map();
|
54590
54764
|
const pendingImports = new Map();
|
54591
54765
|
const importErrors = new WeakMap();
|
54592
54766
|
async function ssrLoadModule(url, server, context = { global }, urlStack = [], fixStacktrace) {
|
54593
|
-
url = unwrapId(url);
|
54767
|
+
url = unwrapId$1(url);
|
54594
54768
|
// when we instantiate multiple dependency modules in parallel, they may
|
54595
54769
|
// point to shared modules. We need to avoid duplicate instantiation attempts
|
54596
54770
|
// by register every module as pending synchronously so that all subsequent
|
@@ -54663,7 +54837,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
54663
54837
|
return await nodeImport(dep, mod.file, resolveOptions, metadata);
|
54664
54838
|
}
|
54665
54839
|
// convert to rollup URL because `pendingImports`, `moduleGraph.urlToModuleMap` requires that
|
54666
|
-
dep = unwrapId(dep);
|
54840
|
+
dep = unwrapId$1(dep);
|
54667
54841
|
if (!isCircular(dep) && !pendingImports.get(dep)?.some(isCircular)) {
|
54668
54842
|
pendingDeps.push(dep);
|
54669
54843
|
if (pendingDeps.length === 1) {
|
@@ -54711,15 +54885,13 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
54711
54885
|
let sourceMapSuffix = '';
|
54712
54886
|
if (result.map && 'version' in result.map) {
|
54713
54887
|
const moduleSourceMap = Object.assign({}, result.map, {
|
54714
|
-
|
54715
|
-
|
54716
|
-
mappings: ';'.repeat(fnDeclarationLineCount$1) + result.map.mappings,
|
54888
|
+
mappings: ';'.repeat(asyncFunctionDeclarationPaddingLineCount) +
|
54889
|
+
result.map.mappings,
|
54717
54890
|
});
|
54718
|
-
sourceMapSuffix =
|
54719
|
-
'\n//# sourceMappingURL=' + genSourceMapUrl(moduleSourceMap);
|
54891
|
+
sourceMapSuffix = `\n//# ${SOURCEMAPPING_URL}=${genSourceMapUrl(moduleSourceMap)}`;
|
54720
54892
|
}
|
54721
54893
|
try {
|
54722
|
-
const initModule = new AsyncFunction
|
54894
|
+
const initModule = new AsyncFunction(`global`, ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, '"use strict";' +
|
54723
54895
|
result.code +
|
54724
54896
|
`\n//# sourceURL=${mod.id}${sourceMapSuffix}`);
|
54725
54897
|
await initModule(context.global, ssrModule, ssrImportMeta, ssrImport, ssrDynamicImport, ssrExportAll);
|
@@ -54765,7 +54937,9 @@ async function nodeImport(id, importer, resolveOptions, metadata) {
|
|
54765
54937
|
return proxyESM(mod);
|
54766
54938
|
}
|
54767
54939
|
else if (filePath) {
|
54768
|
-
analyzeImportedModDifference(mod,
|
54940
|
+
analyzeImportedModDifference(mod, id, isFilePathESM(filePath, resolveOptions.packageCache)
|
54941
|
+
? 'module'
|
54942
|
+
: undefined, metadata);
|
54769
54943
|
return proxyGuardOnlyEsm(mod, id);
|
54770
54944
|
}
|
54771
54945
|
else {
|
@@ -54795,53 +54969,6 @@ function proxyESM(mod) {
|
|
54795
54969
|
function isPrimitive(value) {
|
54796
54970
|
return !value || (typeof value !== 'object' && typeof value !== 'function');
|
54797
54971
|
}
|
54798
|
-
/**
|
54799
|
-
* Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
|
54800
|
-
* Top-level imports and dynamic imports work slightly differently in Node.js.
|
54801
|
-
* This function normalizes the differences so it matches prod behaviour.
|
54802
|
-
*/
|
54803
|
-
function analyzeImportedModDifference(mod, filePath, rawId, metadata, packageCache) {
|
54804
|
-
// No normalization needed if the user already dynamic imports this module
|
54805
|
-
if (metadata?.isDynamicImport)
|
54806
|
-
return;
|
54807
|
-
// If file path is ESM, everything should be fine
|
54808
|
-
if (isFilePathESM(filePath, packageCache))
|
54809
|
-
return;
|
54810
|
-
// For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.
|
54811
|
-
// If the user named imports a specifier that can't be analyzed, error.
|
54812
|
-
if (metadata?.importedNames?.length) {
|
54813
|
-
const missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
54814
|
-
if (missingBindings.length) {
|
54815
|
-
const lastBinding = missingBindings[missingBindings.length - 1];
|
54816
|
-
// Copied from Node.js
|
54817
|
-
throw new SyntaxError(`\
|
54818
|
-
[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
54819
|
-
CommonJS modules can always be imported via the default export, for example using:
|
54820
|
-
|
54821
|
-
import pkg from '${rawId}';
|
54822
|
-
const {${missingBindings.join(', ')}} = pkg;
|
54823
|
-
`);
|
54824
|
-
}
|
54825
|
-
}
|
54826
|
-
}
|
54827
|
-
/**
|
54828
|
-
* Guard invalid named exports only, similar to how Node.js errors for top-level imports.
|
54829
|
-
* But since we transform as dynamic imports, we need to emulate the error manually.
|
54830
|
-
*/
|
54831
|
-
function proxyGuardOnlyEsm(mod, rawId, metadata) {
|
54832
|
-
// If the module doesn't import anything explicitly, e.g. `import 'foo'` or
|
54833
|
-
// `import * as foo from 'foo'`, we can skip the proxy guard.
|
54834
|
-
if (!metadata?.importedNames?.length)
|
54835
|
-
return mod;
|
54836
|
-
return new Proxy(mod, {
|
54837
|
-
get(mod, prop) {
|
54838
|
-
if (prop !== 'then' && !(prop in mod)) {
|
54839
|
-
throw new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
|
54840
|
-
}
|
54841
|
-
return mod[prop];
|
54842
|
-
},
|
54843
|
-
});
|
54844
|
-
}
|
54845
54972
|
|
54846
54973
|
var isWsl$2 = {exports: {}};
|
54847
54974
|
|
@@ -56192,7 +56319,6 @@ async function fetchModule(server, url, importer, options = {}) {
|
|
56192
56319
|
isProduction,
|
56193
56320
|
root,
|
56194
56321
|
ssrConfig: ssr,
|
56195
|
-
legacyProxySsrExternalModules: server.config.legacy?.proxySsrExternalModules,
|
56196
56322
|
packageCache: server.config.packageCache,
|
56197
56323
|
};
|
56198
56324
|
const resolved = tryNodeResolve(url, importer, { ...resolveOptions, tryEsmOnly: true }, false, undefined, true);
|
@@ -56207,7 +56333,7 @@ async function fetchModule(server, url, importer, options = {}) {
|
|
56207
56333
|
: 'commonjs';
|
56208
56334
|
return { externalize: file, type };
|
56209
56335
|
}
|
56210
|
-
url = unwrapId(url);
|
56336
|
+
url = unwrapId$1(url);
|
56211
56337
|
let result = await server.transformRequest(url, { ssr: true });
|
56212
56338
|
if (!result) {
|
56213
56339
|
throw new Error(`[vite] transform failed for module '${url}'${importer ? ` imported from '${importer}'` : ''}.`);
|
@@ -56225,10 +56351,6 @@ async function fetchModule(server, url, importer, options = {}) {
|
|
56225
56351
|
result.code = result.code.replace(/^#!.*/, (s) => ' '.repeat(s.length));
|
56226
56352
|
return { code: result.code, file: mod.file };
|
56227
56353
|
}
|
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
56354
|
const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm');
|
56233
56355
|
function inlineSourceMap(mod, result, processSourceMap) {
|
56234
56356
|
const map = result.map;
|
@@ -56241,26 +56363,17 @@ function inlineSourceMap(mod, result, processSourceMap) {
|
|
56241
56363
|
OTHER_SOURCE_MAP_REGEXP.lastIndex = 0;
|
56242
56364
|
if (OTHER_SOURCE_MAP_REGEXP.test(code))
|
56243
56365
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, '');
|
56244
|
-
const sourceMap =
|
56245
|
-
result.code = `${code.trimEnd()}\n//# sourceURL=${mod.id}\n${VITE_RUNTIME_SOURCEMAPPING_SOURCE}\n//# ${
|
56366
|
+
const sourceMap = processSourceMap?.(map) || map;
|
56367
|
+
result.code = `${code.trimEnd()}\n//# sourceURL=${mod.id}\n${VITE_RUNTIME_SOURCEMAPPING_SOURCE}\n//# ${SOURCEMAPPING_URL}=${genSourceMapUrl(sourceMap)}\n`;
|
56246
56368
|
return result;
|
56247
56369
|
}
|
56248
56370
|
|
56249
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
56250
|
-
const AsyncFunction = async function () { }.constructor;
|
56251
|
-
const fnDeclarationLineCount = (() => {
|
56252
|
-
const body = '/*code*/';
|
56253
|
-
const source = new AsyncFunction('a', 'b', body).toString();
|
56254
|
-
return source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
56255
|
-
})();
|
56256
56371
|
function ssrFetchModule(server, id, importer) {
|
56257
56372
|
return fetchModule(server, id, importer, {
|
56258
56373
|
processSourceMap(map) {
|
56259
56374
|
// this assumes that "new AsyncFunction" is used to create the module
|
56260
56375
|
return Object.assign({}, map, {
|
56261
|
-
|
56262
|
-
// https://github.com/nodejs/node/issues/43047#issuecomment-1180632750
|
56263
|
-
mappings: ';'.repeat(fnDeclarationLineCount) + map.mappings,
|
56376
|
+
mappings: ';'.repeat(asyncFunctionDeclarationPaddingLineCount) + map.mappings,
|
56264
56377
|
});
|
56265
56378
|
},
|
56266
56379
|
});
|
@@ -63386,7 +63499,7 @@ function transformMiddleware(server) {
|
|
63386
63499
|
url = removeImportQuery(url);
|
63387
63500
|
// Strip valid id prefix. This is prepended to resolved Ids that are
|
63388
63501
|
// not valid browser import specifiers by the importAnalysis plugin.
|
63389
|
-
url = unwrapId(url);
|
63502
|
+
url = unwrapId$1(url);
|
63390
63503
|
// for CSS, we differentiate between normal CSS requests and imports
|
63391
63504
|
if (isCSSRequest(url)) {
|
63392
63505
|
if (req.headers.accept?.includes('text/css') &&
|
@@ -63595,7 +63708,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
63595
63708
|
// and ids are properly handled
|
63596
63709
|
const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}`;
|
63597
63710
|
proxyModulePath = `\0${validPath}`;
|
63598
|
-
proxyModuleUrl = wrapId(proxyModulePath);
|
63711
|
+
proxyModuleUrl = wrapId$1(proxyModulePath);
|
63599
63712
|
}
|
63600
63713
|
const s = new MagicString(html);
|
63601
63714
|
let inlineModuleIndex = -1;
|
@@ -63774,7 +63887,7 @@ function preTransformRequest(server, url, base) {
|
|
63774
63887
|
return;
|
63775
63888
|
// transform all url as non-ssr as html includes client-side assets only
|
63776
63889
|
try {
|
63777
|
-
url = unwrapId(stripBase(decodeURI(url), base));
|
63890
|
+
url = unwrapId$1(stripBase(decodeURI(url), base));
|
63778
63891
|
}
|
63779
63892
|
catch {
|
63780
63893
|
// ignore
|
@@ -64563,14 +64676,12 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64563
64676
|
// proxy
|
64564
64677
|
const { proxy } = serverConfig;
|
64565
64678
|
if (proxy) {
|
64566
|
-
const middlewareServer = (isObject$1(
|
64567
|
-
? serverConfig.middlewareMode.server
|
64568
|
-
: null) || httpServer;
|
64679
|
+
const middlewareServer = (isObject$1(middlewareMode) ? middlewareMode.server : null) || httpServer;
|
64569
64680
|
middlewares.use(proxyMiddleware(middlewareServer, proxy, config));
|
64570
64681
|
}
|
64571
64682
|
// base
|
64572
64683
|
if (config.base !== '/') {
|
64573
|
-
middlewares.use(baseMiddleware(config.rawBase, middlewareMode));
|
64684
|
+
middlewares.use(baseMiddleware(config.rawBase, !!middlewareMode));
|
64574
64685
|
}
|
64575
64686
|
// open in editor support
|
64576
64687
|
middlewares.use('/__open-in-editor', launchEditorMiddleware$1());
|
@@ -64610,7 +64721,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64610
64721
|
middlewares.use(notFoundMiddleware());
|
64611
64722
|
}
|
64612
64723
|
// error handler
|
64613
|
-
middlewares.use(errorMiddleware(server, middlewareMode));
|
64724
|
+
middlewares.use(errorMiddleware(server, !!middlewareMode));
|
64614
64725
|
// httpServer.listen can be called multiple times
|
64615
64726
|
// when port when using next port number
|
64616
64727
|
// this code is to avoid calling buildStart multiple times
|
@@ -64722,7 +64833,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
64722
64833
|
sourcemapIgnoreList: raw?.sourcemapIgnoreList === false
|
64723
64834
|
? () => false
|
64724
64835
|
: raw?.sourcemapIgnoreList || isInNodeModules$1,
|
64725
|
-
middlewareMode:
|
64836
|
+
middlewareMode: raw?.middlewareMode || false,
|
64726
64837
|
};
|
64727
64838
|
let allowDirs = server.fs?.allow;
|
64728
64839
|
const deny = server.fs?.deny || ['.env', '.env.*', '*.{crt,pem}'];
|
@@ -64867,6 +64978,7 @@ async function handleHMRUpdate(file, server, configOnly) {
|
|
64867
64978
|
hot.send({
|
64868
64979
|
type: 'full-reload',
|
64869
64980
|
path: '*',
|
64981
|
+
triggeredBy: path$o.resolve(config.root, file),
|
64870
64982
|
});
|
64871
64983
|
return;
|
64872
64984
|
}
|
@@ -64945,6 +65057,7 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
|
|
64945
65057
|
config.logger.info(colors$1.green(`page reload `) + colors$1.dim(file) + reason, { clear: !afterInvalidation, timestamp: true });
|
64946
65058
|
hot.send({
|
64947
65059
|
type: 'full-reload',
|
65060
|
+
triggeredBy: path$o.resolve(config.root, file),
|
64948
65061
|
});
|
64949
65062
|
return;
|
64950
65063
|
}
|
@@ -64959,7 +65072,7 @@ function updateModules(file, modules, timestamp, { config, hot, moduleGraph }, a
|
|
64959
65072
|
updates,
|
64960
65073
|
});
|
64961
65074
|
}
|
64962
|
-
function populateSSRImporters(module, timestamp, seen) {
|
65075
|
+
function populateSSRImporters(module, timestamp, seen = new Set()) {
|
64963
65076
|
module.ssrImportedModules.forEach((importer) => {
|
64964
65077
|
if (seen.has(importer)) {
|
64965
65078
|
return;
|
@@ -64973,9 +65086,7 @@ function populateSSRImporters(module, timestamp, seen) {
|
|
64973
65086
|
return seen;
|
64974
65087
|
}
|
64975
65088
|
function getSSRInvalidatedImporters(module) {
|
64976
|
-
return [
|
64977
|
-
...populateSSRImporters(module, module.lastHMRTimestamp, new Set()),
|
64978
|
-
].map((m) => m.file);
|
65089
|
+
return [...populateSSRImporters(module, module.lastHMRTimestamp)].map((m) => m.file);
|
64979
65090
|
}
|
64980
65091
|
async function handleFileAddUnlink(file, server, isUnlink) {
|
64981
65092
|
const modules = [...(server.moduleGraph.getModulesByFile(file) || [])];
|
@@ -65285,7 +65396,7 @@ function lexAcceptedHmrExports(code, start, exportNames) {
|
|
65285
65396
|
}
|
65286
65397
|
function normalizeHmrUrl(url) {
|
65287
65398
|
if (url[0] !== '.' && url[0] !== '/') {
|
65288
|
-
url = wrapId(url);
|
65399
|
+
url = wrapId$1(url);
|
65289
65400
|
}
|
65290
65401
|
return url;
|
65291
65402
|
}
|
@@ -65622,7 +65733,7 @@ function importAnalysisPlugin(config) {
|
|
65622
65733
|
// prefix it to make it valid. We will strip this before feeding it
|
65623
65734
|
// back into the transform pipeline
|
65624
65735
|
if (url[0] !== '.' && url[0] !== '/') {
|
65625
|
-
url = wrapId(resolved.id);
|
65736
|
+
url = wrapId$1(resolved.id);
|
65626
65737
|
}
|
65627
65738
|
// make the URL browser-valid if not SSR
|
65628
65739
|
if (!ssr) {
|
@@ -65648,7 +65759,7 @@ function importAnalysisPlugin(config) {
|
|
65648
65759
|
try {
|
65649
65760
|
// delay setting `isSelfAccepting` until the file is actually used (#7870)
|
65650
65761
|
// We use an internal function to avoid resolving the url again
|
65651
|
-
const depModule = await moduleGraph._ensureEntryFromUrl(unwrapId(url), ssr, canSkipImportAnalysis(url) || forceSkipImportAnalysis, resolved);
|
65762
|
+
const depModule = await moduleGraph._ensureEntryFromUrl(unwrapId$1(url), ssr, canSkipImportAnalysis(url) || forceSkipImportAnalysis, resolved);
|
65652
65763
|
if (depModule.lastHMRTimestamp > 0) {
|
65653
65764
|
url = injectQuery(url, `t=${depModule.lastHMRTimestamp}`);
|
65654
65765
|
}
|
@@ -65717,7 +65828,7 @@ function importAnalysisPlugin(config) {
|
|
65717
65828
|
}
|
65718
65829
|
// static import or valid string in dynamic import
|
65719
65830
|
// If resolvable, let's resolve it
|
65720
|
-
if (specifier) {
|
65831
|
+
if (specifier !== undefined) {
|
65721
65832
|
// skip external / data uri
|
65722
65833
|
if (isExternalUrl(specifier) || isDataUrl(specifier)) {
|
65723
65834
|
return;
|
@@ -65794,7 +65905,7 @@ function importAnalysisPlugin(config) {
|
|
65794
65905
|
}
|
65795
65906
|
// record for HMR import chain analysis
|
65796
65907
|
// make sure to unwrap and normalize away base
|
65797
|
-
const hmrUrl = unwrapId(stripBase(url, base));
|
65908
|
+
const hmrUrl = unwrapId$1(stripBase(url, base));
|
65798
65909
|
const isLocalImport = !isExternalUrl(hmrUrl) && !isDataUrl(hmrUrl);
|
65799
65910
|
if (isLocalImport) {
|
65800
65911
|
orderedImportedUrls[index] = hmrUrl;
|
@@ -65951,7 +66062,7 @@ function createParseErrorInfo(importer, source) {
|
|
65951
66062
|
};
|
65952
66063
|
}
|
65953
66064
|
// prettier-ignore
|
65954
|
-
const interopHelper = (m) => m?.__esModule ? m : { ...(typeof m === 'object' && !Array.isArray(m) ? m : {}), default: m };
|
66065
|
+
const interopHelper = (m) => m?.__esModule ? m : { ...(typeof m === 'object' && !Array.isArray(m) || typeof m === 'function' ? m : {}), default: m };
|
65955
66066
|
function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, importer, config) {
|
65956
66067
|
const source = str.original;
|
65957
66068
|
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, } = importSpecifier;
|
@@ -66357,12 +66468,14 @@ function buildImportAnalysisPlugin(config) {
|
|
66357
66468
|
const chunk = bundle[filename];
|
66358
66469
|
if (chunk) {
|
66359
66470
|
deps.add(chunk.fileName);
|
66360
|
-
chunk.
|
66361
|
-
|
66362
|
-
|
66363
|
-
|
66364
|
-
|
66365
|
-
|
66471
|
+
if (chunk.type === 'chunk') {
|
66472
|
+
chunk.imports.forEach(addDeps);
|
66473
|
+
// Ensure that the css imported by current chunk is loaded after the dependencies.
|
66474
|
+
// So the style of current chunk won't be overwritten unexpectedly.
|
66475
|
+
chunk.viteMetadata.importedCss.forEach((file) => {
|
66476
|
+
deps.add(file);
|
66477
|
+
});
|
66478
|
+
}
|
66366
66479
|
}
|
66367
66480
|
else {
|
66368
66481
|
const removedPureCssFiles = removedPureCssFilesCache.get(config);
|
@@ -66453,13 +66566,12 @@ function __vite__mapDeps(indexes) {
|
|
66453
66566
|
}
|
66454
66567
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
66455
66568
|
}\n`;
|
66456
|
-
// inject extra code
|
66457
|
-
|
66458
|
-
|
66459
|
-
s.appendRight(mapFileCommentMatch.index, mapDepsCode);
|
66569
|
+
// inject extra code at the top or next line of hashbang
|
66570
|
+
if (code.startsWith('#!')) {
|
66571
|
+
s.prependLeft(code.indexOf('\n') + 1, mapDepsCode);
|
66460
66572
|
}
|
66461
66573
|
else {
|
66462
|
-
s.
|
66574
|
+
s.prepend(mapDepsCode);
|
66463
66575
|
}
|
66464
66576
|
// there may still be markers due to inlined dynamic imports, remove
|
66465
66577
|
// all the markers regardless
|
@@ -67192,7 +67304,7 @@ function injectSsrFlag(options) {
|
|
67192
67304
|
}
|
67193
67305
|
/*
|
67194
67306
|
The following functions are copied from rollup
|
67195
|
-
https://github.com/rollup/rollup/blob/
|
67307
|
+
https://github.com/rollup/rollup/blob/ce6cb93098850a46fa242e37b74a919e99a5de28/src/ast/nodes/MetaProperty.ts#L155-L203
|
67196
67308
|
|
67197
67309
|
https://github.com/rollup/rollup
|
67198
67310
|
The MIT License (MIT)
|
@@ -67212,24 +67324,24 @@ function escapeId(id) {
|
|
67212
67324
|
const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
|
67213
67325
|
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
67214
67326
|
const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
|
67215
|
-
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
|
67327
|
+
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
|
67216
67328
|
const relativeUrlMechanisms = {
|
67217
67329
|
amd: (relativePath) => {
|
67218
67330
|
if (relativePath[0] !== '.')
|
67219
67331
|
relativePath = './' + relativePath;
|
67220
|
-
return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
|
67332
|
+
return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
|
67221
67333
|
},
|
67222
67334
|
cjs: (relativePath) => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
|
67223
|
-
es: (relativePath) => getResolveUrl(`'${relativePath}', import.meta.url`),
|
67335
|
+
es: (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', import.meta.url`),
|
67224
67336
|
iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
|
67225
67337
|
// NOTE: make sure rollup generate `module` params
|
67226
|
-
system: (relativePath) => getResolveUrl(`'${relativePath}', module.meta.url`),
|
67338
|
+
system: (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', module.meta.url`),
|
67227
67339
|
umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`,
|
67228
67340
|
};
|
67229
67341
|
/* end of copy */
|
67230
67342
|
const customRelativeUrlMechanisms = {
|
67231
67343
|
...relativeUrlMechanisms,
|
67232
|
-
'worker-iife': (relativePath) => getResolveUrl(`'${relativePath}', self.location.href`),
|
67344
|
+
'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', self.location.href`),
|
67233
67345
|
};
|
67234
67346
|
function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
|
67235
67347
|
const { renderBuiltUrl } = config.experimental;
|
@@ -67787,7 +67899,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67787
67899
|
logger.warn(colors$1.yellow(`worker.plugins is now a function that returns an array of plugins. ` +
|
67788
67900
|
`Please update your Vite config accordingly.\n`));
|
67789
67901
|
}
|
67790
|
-
const createWorkerPlugins = async function () {
|
67902
|
+
const createWorkerPlugins = async function (bundleChain) {
|
67791
67903
|
// Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
|
67792
67904
|
// And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
|
67793
67905
|
// So we need to separate the worker plugin from the plugin that vite needs to run.
|
@@ -67807,6 +67919,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67807
67919
|
...resolved,
|
67808
67920
|
isWorker: true,
|
67809
67921
|
mainConfig: resolved,
|
67922
|
+
bundleChain,
|
67810
67923
|
};
|
67811
67924
|
const resolvedWorkerPlugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
|
67812
67925
|
// run configResolved hooks
|
@@ -67835,6 +67948,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67835
67948
|
ssr,
|
67836
67949
|
isWorker: false,
|
67837
67950
|
mainConfig: null,
|
67951
|
+
bundleChain: [],
|
67838
67952
|
isProduction,
|
67839
67953
|
plugins: userPlugins,
|
67840
67954
|
css: resolveCSSOptions(config.css),
|
@@ -68231,4 +68345,4 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
68231
68345
|
}
|
68232
68346
|
}
|
68233
68347
|
|
68234
|
-
export {
|
68348
|
+
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 };
|