vite 5.1.5 → 5.1.7
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-WMYkPWs9.js → dep-a4OR5kR_.js} +1 -1
- package/dist/node/chunks/{dep-G-px366b.js → dep-k5wXcrSr.js} +317 -228
- package/dist/node/chunks/{dep-OHeF5w5D.js → dep-qw1-Ctro.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +5 -5
- package/dist/node/index.js +2 -2
- package/dist/node/runtime.d.ts +2 -2
- package/dist/node/runtime.js +40 -37
- package/dist/node/{types.d-AKzkD8vd.d.ts → types.d-FdqQ54oU.d.ts} +18 -15
- package/dist/node-cjs/publicUtils.cjs +5 -2
- package/package.json +7 -7
@@ -250,7 +250,6 @@ const NULL_BYTE_PLACEHOLDER = `__x00__`;
|
|
250
250
|
let SOURCEMAPPING_URL = 'sourceMa';
|
251
251
|
SOURCEMAPPING_URL += 'ppingURL';
|
252
252
|
const VITE_RUNTIME_SOURCEMAPPING_SOURCE = '//# sourceMappingSource=vite-runtime';
|
253
|
-
const VITE_RUNTIME_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
|
254
253
|
|
255
254
|
const isWindows$5 = typeof process !== 'undefined' && process.platform === 'win32';
|
256
255
|
/**
|
@@ -285,6 +284,15 @@ function withTrailingSlash(path) {
|
|
285
284
|
}
|
286
285
|
return path;
|
287
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
|
+
})();
|
288
296
|
|
289
297
|
// @ts-check
|
290
298
|
/** @typedef { import('estree').BaseNode} BaseNode */
|
@@ -6702,9 +6710,12 @@ class Mappings {
|
|
6702
6710
|
|
6703
6711
|
addEdit(sourceIndex, content, loc, nameIndex) {
|
6704
6712
|
if (content.length) {
|
6713
|
+
const contentLengthMinusOne = content.length - 1;
|
6705
6714
|
let contentLineEnd = content.indexOf('\n', 0);
|
6706
6715
|
let previousContentLineEnd = -1;
|
6707
|
-
|
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) {
|
6708
6719
|
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
6709
6720
|
if (nameIndex >= 0) {
|
6710
6721
|
segment.push(nameIndex);
|
@@ -10319,6 +10330,7 @@ class TraceMap {
|
|
10319
10330
|
this.sourceRoot = sourceRoot;
|
10320
10331
|
this.sources = sources;
|
10321
10332
|
this.sourcesContent = sourcesContent;
|
10333
|
+
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
|
10322
10334
|
const from = resolve$1(sourceRoot || '', stripFilename(mapUrl));
|
10323
10335
|
this.resolvedSources = sources.map((s) => resolve$1(s || '', from));
|
10324
10336
|
const { mappings } = parsed;
|
@@ -10339,7 +10351,7 @@ class TraceMap {
|
|
10339
10351
|
* Typescript doesn't allow friend access to private fields, so this just casts the map into a type
|
10340
10352
|
* with public access modifiers.
|
10341
10353
|
*/
|
10342
|
-
function cast(map) {
|
10354
|
+
function cast$2(map) {
|
10343
10355
|
return map;
|
10344
10356
|
}
|
10345
10357
|
/**
|
@@ -10347,7 +10359,7 @@ function cast(map) {
|
|
10347
10359
|
*/
|
10348
10360
|
function decodedMappings(map) {
|
10349
10361
|
var _a;
|
10350
|
-
return ((_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded)));
|
10362
|
+
return ((_a = cast$2(map))._decoded || (_a._decoded = decode(cast$2(map)._encoded)));
|
10351
10363
|
}
|
10352
10364
|
/**
|
10353
10365
|
* A low-level API to find the segment associated with a generated line/column (think, from a
|
@@ -10360,7 +10372,7 @@ function traceSegment(map, line, column) {
|
|
10360
10372
|
if (line >= decoded.length)
|
10361
10373
|
return null;
|
10362
10374
|
const segments = decoded[line];
|
10363
|
-
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
|
10375
|
+
const index = traceSegmentInternal(segments, cast$2(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
|
10364
10376
|
return index === -1 ? null : segments[index];
|
10365
10377
|
}
|
10366
10378
|
/**
|
@@ -10381,7 +10393,7 @@ function originalPositionFor$1(map, needle) {
|
|
10381
10393
|
if (line >= decoded.length)
|
10382
10394
|
return OMapping(null, null, null, null);
|
10383
10395
|
const segments = decoded[line];
|
10384
|
-
const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
10396
|
+
const index = traceSegmentInternal(segments, cast$2(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
10385
10397
|
if (index === -1)
|
10386
10398
|
return OMapping(null, null, null, null);
|
10387
10399
|
const segment = segments[index];
|
@@ -10405,15 +10417,6 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
10405
10417
|
return index;
|
10406
10418
|
}
|
10407
10419
|
|
10408
|
-
/**
|
10409
|
-
* Gets the index associated with `key` in the backing array, if it is already present.
|
10410
|
-
*/
|
10411
|
-
let get;
|
10412
|
-
/**
|
10413
|
-
* Puts `key` into the backing array, if it is not already present. Returns
|
10414
|
-
* the index of the `key` in the backing array.
|
10415
|
-
*/
|
10416
|
-
let put;
|
10417
10420
|
/**
|
10418
10421
|
* SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
|
10419
10422
|
* index of the `key` in the backing array.
|
@@ -10428,17 +10431,48 @@ class SetArray {
|
|
10428
10431
|
this.array = [];
|
10429
10432
|
}
|
10430
10433
|
}
|
10431
|
-
|
10432
|
-
|
10433
|
-
|
10434
|
-
|
10435
|
-
|
10436
|
-
|
10437
|
-
|
10438
|
-
|
10439
|
-
|
10440
|
-
|
10441
|
-
|
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
|
+
}
|
10442
10476
|
|
10443
10477
|
const COLUMN = 0;
|
10444
10478
|
const SOURCES_INDEX = 1;
|
@@ -10447,88 +10481,100 @@ const SOURCE_COLUMN = 3;
|
|
10447
10481
|
const NAMES_INDEX = 4;
|
10448
10482
|
|
10449
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
|
+
}
|
10450
10505
|
/**
|
10451
10506
|
* Same as `addSegment`, but will only add the segment if it generates useful information in the
|
10452
10507
|
* resulting map. This only works correctly if segments are added **in order**, meaning you should
|
10453
10508
|
* not add a segment with a lower generated line/column than one that came before.
|
10454
10509
|
*/
|
10455
|
-
|
10510
|
+
const maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
10511
|
+
return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
10512
|
+
};
|
10456
10513
|
/**
|
10457
10514
|
* Adds/removes the content of the source file to the source map.
|
10458
10515
|
*/
|
10459
|
-
|
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
|
+
}
|
10460
10531
|
/**
|
10461
10532
|
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
10462
10533
|
* a sourcemap, or to JSON.stringify.
|
10463
10534
|
*/
|
10464
|
-
|
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
|
+
}
|
10465
10549
|
/**
|
10466
10550
|
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
10467
10551
|
* a sourcemap, or to JSON.stringify.
|
10468
10552
|
*/
|
10469
|
-
|
10553
|
+
function toEncodedMap(map) {
|
10554
|
+
const decoded = toDecodedMap(map);
|
10555
|
+
return Object.assign(Object.assign({}, decoded), { mappings: encode$1(decoded.mappings) });
|
10556
|
+
}
|
10470
10557
|
// This split declaration is only so that terser can elminiate the static initialization block.
|
10471
|
-
|
10472
|
-
|
10473
|
-
|
10474
|
-
|
10475
|
-
|
10476
|
-
|
10477
|
-
|
10478
|
-
|
10479
|
-
|
10480
|
-
|
10481
|
-
|
10482
|
-
|
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;
|
10483
10573
|
}
|
10574
|
+
return insert(line, index, name
|
10575
|
+
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
10576
|
+
: [genColumn, sourcesIndex, sourceLine, sourceColumn]);
|
10484
10577
|
}
|
10485
|
-
(() => {
|
10486
|
-
maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
10487
|
-
return addSegmentInternal(true, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
|
10488
|
-
};
|
10489
|
-
setSourceContent = (map, source, content) => {
|
10490
|
-
const { _sources: sources, _sourcesContent: sourcesContent } = map;
|
10491
|
-
sourcesContent[put(sources, source)] = content;
|
10492
|
-
};
|
10493
|
-
toDecodedMap = (map) => {
|
10494
|
-
const { file, sourceRoot, _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
10495
|
-
removeEmptyFinalLines(mappings);
|
10496
|
-
return {
|
10497
|
-
version: 3,
|
10498
|
-
file: file || undefined,
|
10499
|
-
names: names.array,
|
10500
|
-
sourceRoot: sourceRoot || undefined,
|
10501
|
-
sources: sources.array,
|
10502
|
-
sourcesContent,
|
10503
|
-
mappings,
|
10504
|
-
};
|
10505
|
-
};
|
10506
|
-
toEncodedMap = (map) => {
|
10507
|
-
const decoded = toDecodedMap(map);
|
10508
|
-
return Object.assign(Object.assign({}, decoded), { mappings: encode$1(decoded.mappings) });
|
10509
|
-
};
|
10510
|
-
// Internal helpers
|
10511
|
-
addSegmentInternal = (skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) => {
|
10512
|
-
const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = map;
|
10513
|
-
const line = getLine(mappings, genLine);
|
10514
|
-
const index = getColumnIndex(line, genColumn);
|
10515
|
-
if (!source) {
|
10516
|
-
if (skipable && skipSourceless(line, index))
|
10517
|
-
return;
|
10518
|
-
return insert(line, index, [genColumn]);
|
10519
|
-
}
|
10520
|
-
const sourcesIndex = put(sources, source);
|
10521
|
-
const namesIndex = name ? put(names, name) : NO_NAME;
|
10522
|
-
if (sourcesIndex === sourcesContent.length)
|
10523
|
-
sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
|
10524
|
-
if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
|
10525
|
-
return;
|
10526
|
-
}
|
10527
|
-
return insert(line, index, name
|
10528
|
-
? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
|
10529
|
-
: [genColumn, sourcesIndex, sourceLine, sourceColumn]);
|
10530
|
-
};
|
10531
|
-
})();
|
10532
10578
|
function getLine(mappings, index) {
|
10533
10579
|
for (let i = mappings.length; i <= index; i++) {
|
10534
10580
|
mappings[i] = [];
|
@@ -10587,17 +10633,18 @@ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIn
|
|
10587
10633
|
namesIndex === (prev.length === 5 ? prev[NAMES_INDEX] : NO_NAME));
|
10588
10634
|
}
|
10589
10635
|
|
10590
|
-
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null);
|
10636
|
+
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null, false);
|
10591
10637
|
const EMPTY_SOURCES = [];
|
10592
|
-
function SegmentObject(source, line, column, name, content) {
|
10593
|
-
return { source, line, column, name, content };
|
10638
|
+
function SegmentObject(source, line, column, name, content, ignore) {
|
10639
|
+
return { source, line, column, name, content, ignore };
|
10594
10640
|
}
|
10595
|
-
function Source(map, sources, source, content) {
|
10641
|
+
function Source(map, sources, source, content, ignore) {
|
10596
10642
|
return {
|
10597
10643
|
map,
|
10598
10644
|
sources,
|
10599
10645
|
source,
|
10600
10646
|
content,
|
10647
|
+
ignore,
|
10601
10648
|
};
|
10602
10649
|
}
|
10603
10650
|
/**
|
@@ -10605,14 +10652,14 @@ function Source(map, sources, source, content) {
|
|
10605
10652
|
* (which may themselves be SourceMapTrees).
|
10606
10653
|
*/
|
10607
10654
|
function MapSource(map, sources) {
|
10608
|
-
return Source(map, sources, '', null);
|
10655
|
+
return Source(map, sources, '', null, false);
|
10609
10656
|
}
|
10610
10657
|
/**
|
10611
10658
|
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
10612
10659
|
* segment tracing ends at the `OriginalSource`.
|
10613
10660
|
*/
|
10614
|
-
function OriginalSource(source, content) {
|
10615
|
-
return Source(null, EMPTY_SOURCES, source, content);
|
10661
|
+
function OriginalSource(source, content, ignore) {
|
10662
|
+
return Source(null, EMPTY_SOURCES, source, content, ignore);
|
10616
10663
|
}
|
10617
10664
|
/**
|
10618
10665
|
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
@@ -10641,10 +10688,12 @@ function traceMappings(tree) {
|
|
10641
10688
|
if (traced == null)
|
10642
10689
|
continue;
|
10643
10690
|
}
|
10644
|
-
const { column, line, name, content, source } = traced;
|
10691
|
+
const { column, line, name, content, source, ignore } = traced;
|
10645
10692
|
maybeAddSegment(gen, i, genCol, source, line, column, name);
|
10646
10693
|
if (source && content != null)
|
10647
10694
|
setSourceContent(gen, source, content);
|
10695
|
+
if (ignore)
|
10696
|
+
setIgnore(gen, source, true);
|
10648
10697
|
}
|
10649
10698
|
}
|
10650
10699
|
return gen;
|
@@ -10655,7 +10704,7 @@ function traceMappings(tree) {
|
|
10655
10704
|
*/
|
10656
10705
|
function originalPositionFor(source, line, column, name) {
|
10657
10706
|
if (!source.map) {
|
10658
|
-
return SegmentObject(source.source, line, column, name, source.content);
|
10707
|
+
return SegmentObject(source.source, line, column, name, source.content, source.ignore);
|
10659
10708
|
}
|
10660
10709
|
const segment = traceSegment(source.map, line, column);
|
10661
10710
|
// If we couldn't find a segment, then this doesn't exist in the sourcemap.
|
@@ -10700,7 +10749,7 @@ function buildSourceMapTree(input, loader) {
|
|
10700
10749
|
return tree;
|
10701
10750
|
}
|
10702
10751
|
function build$2(map, loader, importer, importerDepth) {
|
10703
|
-
const { resolvedSources, sourcesContent } = map;
|
10752
|
+
const { resolvedSources, sourcesContent, ignoreList } = map;
|
10704
10753
|
const depth = importerDepth + 1;
|
10705
10754
|
const children = resolvedSources.map((sourceFile, i) => {
|
10706
10755
|
// The loading context gives the loader more information about why this file is being loaded
|
@@ -10712,20 +10761,22 @@ function build$2(map, loader, importer, importerDepth) {
|
|
10712
10761
|
depth,
|
10713
10762
|
source: sourceFile || '',
|
10714
10763
|
content: undefined,
|
10764
|
+
ignore: undefined,
|
10715
10765
|
};
|
10716
10766
|
// Use the provided loader callback to retrieve the file's sourcemap.
|
10717
10767
|
// TODO: We should eventually support async loading of sourcemap files.
|
10718
10768
|
const sourceMap = loader(ctx.source, ctx);
|
10719
|
-
const { source, content } = ctx;
|
10769
|
+
const { source, content, ignore } = ctx;
|
10720
10770
|
// If there is a sourcemap, then we need to recurse into it to load its source files.
|
10721
10771
|
if (sourceMap)
|
10722
10772
|
return build$2(new TraceMap(sourceMap, source), loader, source, depth);
|
10723
|
-
// Else, it's an
|
10773
|
+
// Else, it's an unmodified source file.
|
10724
10774
|
// The contents of this unmodified source file can be overridden via the loader context,
|
10725
10775
|
// allowing it to be explicitly null or a string. If it remains undefined, we fall back to
|
10726
10776
|
// the importing sourcemap's `sourcesContent` field.
|
10727
10777
|
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
|
10728
|
-
|
10778
|
+
const ignored = ignore !== undefined ? ignore : ignoreList ? ignoreList.includes(i) : false;
|
10779
|
+
return OriginalSource(source, sourceContent, ignored);
|
10729
10780
|
});
|
10730
10781
|
return MapSource(map, children);
|
10731
10782
|
}
|
@@ -10741,6 +10792,7 @@ class SourceMap {
|
|
10741
10792
|
this.file = out.file;
|
10742
10793
|
this.mappings = out.mappings;
|
10743
10794
|
this.names = out.names;
|
10795
|
+
this.ignoreList = out.ignoreList;
|
10744
10796
|
this.sourceRoot = out.sourceRoot;
|
10745
10797
|
this.sources = out.sources;
|
10746
10798
|
if (!options.excludeContent) {
|
@@ -12873,7 +12925,7 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
12873
12925
|
continue;
|
12874
12926
|
}
|
12875
12927
|
if (Array.isArray(existing) || Array.isArray(value)) {
|
12876
|
-
merged[key] = [...arraify(existing
|
12928
|
+
merged[key] = [...arraify(existing), ...arraify(value)];
|
12877
12929
|
continue;
|
12878
12930
|
}
|
12879
12931
|
if (isObject$1(existing) && isObject$1(value)) {
|
@@ -14020,7 +14072,7 @@ async function parse$f(filename, options) {
|
|
14020
14072
|
/** @type {Promise<import('./public.d.ts').TSConfckParseResult>}*/
|
14021
14073
|
promise
|
14022
14074
|
} = makePromise();
|
14023
|
-
cache?.setParseResult(filename, promise);
|
14075
|
+
cache?.setParseResult(filename, promise, true);
|
14024
14076
|
try {
|
14025
14077
|
let tsconfigFile =
|
14026
14078
|
(await resolveTSConfigJson(filename, cache)) || (await find(filename, options));
|
@@ -14059,7 +14111,7 @@ async function getParsedDeep(filename, cache, options) {
|
|
14059
14111
|
parseExtends(result, cache),
|
14060
14112
|
parseReferences(result, options)
|
14061
14113
|
]).then(() => result);
|
14062
|
-
cache.setParseResult(filename, promise);
|
14114
|
+
cache.setParseResult(filename, promise, true);
|
14063
14115
|
return promise;
|
14064
14116
|
}
|
14065
14117
|
return result;
|
@@ -14073,7 +14125,11 @@ async function getParsedDeep(filename, cache, options) {
|
|
14073
14125
|
* @returns {Promise<import('./public.d.ts').TSConfckParseResult>}
|
14074
14126
|
*/
|
14075
14127
|
async function parseFile$1(tsconfigFile, cache, skipCache) {
|
14076
|
-
if (
|
14128
|
+
if (
|
14129
|
+
!skipCache &&
|
14130
|
+
cache?.hasParseResult(tsconfigFile) &&
|
14131
|
+
!cache.getParseResult(tsconfigFile)._isRootFile_
|
14132
|
+
) {
|
14077
14133
|
return cache.getParseResult(tsconfigFile);
|
14078
14134
|
}
|
14079
14135
|
const promise = promises$1
|
@@ -14095,7 +14151,10 @@ async function parseFile$1(tsconfigFile, cache, skipCache) {
|
|
14095
14151
|
e
|
14096
14152
|
);
|
14097
14153
|
});
|
14098
|
-
if (
|
14154
|
+
if (
|
14155
|
+
!skipCache &&
|
14156
|
+
(!cache?.hasParseResult(tsconfigFile) || !cache.getParseResult(tsconfigFile)._isRootFile_)
|
14157
|
+
) {
|
14099
14158
|
cache?.setParseResult(tsconfigFile, promise);
|
14100
14159
|
}
|
14101
14160
|
return promise;
|
@@ -14477,9 +14536,17 @@ class TSConfckCache {
|
|
14477
14536
|
* @internal
|
14478
14537
|
* @private
|
14479
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()
|
14480
14540
|
* @param {Promise<T>} result
|
14481
14541
|
*/
|
14482
|
-
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
|
+
});
|
14483
14550
|
this.#parsed.set(file, result);
|
14484
14551
|
result
|
14485
14552
|
.then((parsed) => {
|
@@ -32106,8 +32173,8 @@ function createCachedImport(imp) {
|
|
32106
32173
|
return cached;
|
32107
32174
|
};
|
32108
32175
|
}
|
32109
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
32110
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
32176
|
+
const importPostcssImport = createCachedImport(() => import('./dep-qw1-Ctro.js').then(function (n) { return n.i; }));
|
32177
|
+
const importPostcssModules = createCachedImport(() => import('./dep-a4OR5kR_.js').then(function (n) { return n.i; }));
|
32111
32178
|
const importPostcss = createCachedImport(() => import('postcss'));
|
32112
32179
|
const preprocessorWorkerControllerCache = new WeakMap();
|
32113
32180
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -49077,18 +49144,23 @@ const inlineRE = /[?&]inline\b/;
|
|
49077
49144
|
const WORKER_FILE_ID = 'worker_file';
|
49078
49145
|
const workerCache = new WeakMap();
|
49079
49146
|
function saveEmitWorkerAsset(config, asset) {
|
49080
|
-
const fileName = asset.fileName;
|
49081
49147
|
const workerMap = workerCache.get(config.mainConfig || config);
|
49082
|
-
workerMap.assets.set(fileName, asset);
|
49148
|
+
workerMap.assets.set(asset.fileName, asset);
|
49083
49149
|
}
|
49084
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
|
+
}
|
49085
49157
|
// bundle the file as entry to support imports
|
49086
49158
|
const { rollup } = await import('rollup');
|
49087
49159
|
const { plugins, rollupOptions, format } = config.worker;
|
49088
49160
|
const bundle = await rollup({
|
49089
49161
|
...rollupOptions,
|
49090
|
-
input
|
49091
|
-
plugins: await plugins(),
|
49162
|
+
input,
|
49163
|
+
plugins: await plugins(newBundleChain),
|
49092
49164
|
onwarn(warning, warn) {
|
49093
49165
|
onRollupWarning(warning, warn, config);
|
49094
49166
|
},
|
@@ -49119,7 +49191,6 @@ async function bundleWorkerEntry(config, id) {
|
|
49119
49191
|
saveEmitWorkerAsset(config, {
|
49120
49192
|
fileName: outputChunk.fileName,
|
49121
49193
|
source: outputChunk.code,
|
49122
|
-
type: 'asset',
|
49123
49194
|
});
|
49124
49195
|
}
|
49125
49196
|
});
|
@@ -49138,7 +49209,6 @@ function emitSourcemapForWorkerEntry(config, chunk) {
|
|
49138
49209
|
const mapFileName = chunk.fileName + '.map';
|
49139
49210
|
saveEmitWorkerAsset(config, {
|
49140
49211
|
fileName: mapFileName,
|
49141
|
-
type: 'asset',
|
49142
49212
|
source: data,
|
49143
49213
|
});
|
49144
49214
|
}
|
@@ -49163,7 +49233,6 @@ async function workerFileToUrl(config, id) {
|
|
49163
49233
|
saveEmitWorkerAsset(config, {
|
49164
49234
|
fileName,
|
49165
49235
|
source: outputChunk.code,
|
49166
|
-
type: 'asset',
|
49167
49236
|
});
|
49168
49237
|
workerMap.bundle.set(id, fileName);
|
49169
49238
|
}
|
@@ -49260,8 +49329,6 @@ function webWorkerPlugin(config) {
|
|
49260
49329
|
const workerMatch = workerOrSharedWorkerRE.exec(id);
|
49261
49330
|
if (!workerMatch)
|
49262
49331
|
return;
|
49263
|
-
// stringified url or `new URL(...)`
|
49264
|
-
let url;
|
49265
49332
|
const { format } = config.worker;
|
49266
49333
|
const workerConstructor = workerMatch[1] === 'sharedworker' ? 'SharedWorker' : 'Worker';
|
49267
49334
|
const workerType = isBuild
|
@@ -49273,8 +49340,12 @@ function webWorkerPlugin(config) {
|
|
49273
49340
|
${workerType === 'module' ? `type: "module",` : ''}
|
49274
49341
|
name: options?.name
|
49275
49342
|
}`;
|
49343
|
+
let urlCode;
|
49276
49344
|
if (isBuild) {
|
49277
|
-
if (
|
49345
|
+
if (isWorker && this.getModuleInfo(cleanUrl(id))?.isEntry) {
|
49346
|
+
urlCode = 'self.location.href';
|
49347
|
+
}
|
49348
|
+
else if (inlineRE.test(id)) {
|
49278
49349
|
const chunk = await bundleWorkerEntry(config, id);
|
49279
49350
|
const encodedJs = `const encodedJs = "${Buffer.from(chunk.code).toString('base64')}";`;
|
49280
49351
|
const code =
|
@@ -49325,23 +49396,24 @@ function webWorkerPlugin(config) {
|
|
49325
49396
|
};
|
49326
49397
|
}
|
49327
49398
|
else {
|
49328
|
-
|
49399
|
+
urlCode = JSON.stringify(await workerFileToUrl(config, id));
|
49329
49400
|
}
|
49330
49401
|
}
|
49331
49402
|
else {
|
49332
|
-
url = await fileToUrl$1(cleanUrl(id), config, this);
|
49403
|
+
let url = await fileToUrl$1(cleanUrl(id), config, this);
|
49333
49404
|
url = injectQuery(url, `${WORKER_FILE_ID}&type=${workerType}`);
|
49405
|
+
urlCode = JSON.stringify(url);
|
49334
49406
|
}
|
49335
49407
|
if (urlRE.test(id)) {
|
49336
49408
|
return {
|
49337
|
-
code: `export default ${
|
49409
|
+
code: `export default ${urlCode}`,
|
49338
49410
|
map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
|
49339
49411
|
};
|
49340
49412
|
}
|
49341
49413
|
return {
|
49342
49414
|
code: `export default function WorkerWrapper(options) {
|
49343
49415
|
return new ${workerConstructor}(
|
49344
|
-
${
|
49416
|
+
${urlCode},
|
49345
49417
|
${workerTypeOption}
|
49346
49418
|
);
|
49347
49419
|
}`,
|
@@ -49379,19 +49451,42 @@ function webWorkerPlugin(config) {
|
|
49379
49451
|
}
|
49380
49452
|
return result();
|
49381
49453
|
},
|
49382
|
-
generateBundle(opts) {
|
49454
|
+
generateBundle(opts, bundle) {
|
49383
49455
|
// @ts-expect-error asset emits are skipped in legacy bundle
|
49384
49456
|
if (opts.__vite_skip_asset_emit__ || isWorker) {
|
49385
49457
|
return;
|
49386
49458
|
}
|
49387
49459
|
const workerMap = workerCache.get(config);
|
49388
49460
|
workerMap.assets.forEach((asset) => {
|
49389
|
-
|
49390
|
-
|
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
|
+
});
|
49391
49476
|
});
|
49477
|
+
workerMap.assets.clear();
|
49392
49478
|
},
|
49393
49479
|
};
|
49394
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
|
+
}
|
49395
49490
|
|
49396
49491
|
/**
|
49397
49492
|
* A plugin to avoid an aliased AND optimized dep from being aliased in src
|
@@ -49594,17 +49689,24 @@ function workerImportMetaUrlPlugin(config) {
|
|
49594
49689
|
? slash$1(path$o.join(config.publicDir, url))
|
49595
49690
|
: slash$1(path$o.resolve(path$o.dirname(id), url));
|
49596
49691
|
}
|
49597
|
-
|
49598
|
-
|
49599
|
-
|
49692
|
+
if (isBuild &&
|
49693
|
+
config.isWorker &&
|
49694
|
+
this.getModuleInfo(cleanUrl(file))?.isEntry) {
|
49695
|
+
s.update(expStart, expEnd, 'self.location.href');
|
49600
49696
|
}
|
49601
49697
|
else {
|
49602
|
-
builtUrl
|
49603
|
-
|
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)`);
|
49604
49709
|
}
|
49605
|
-
s.update(expStart, expEnd,
|
49606
|
-
// add `'' +` to skip vite:asset-import-meta-url plugin
|
49607
|
-
`new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
|
49608
49710
|
}
|
49609
49711
|
if (s) {
|
49610
49712
|
return transformStableResult(s, id, config);
|
@@ -49707,7 +49809,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
49707
49809
|
let builtUrl;
|
49708
49810
|
if (file) {
|
49709
49811
|
try {
|
49710
|
-
if (isParentDirectory(publicDir, file)) {
|
49812
|
+
if (publicDir && isParentDirectory(publicDir, file)) {
|
49711
49813
|
const publicPath = '/' + path$o.posix.relative(publicDir, file);
|
49712
49814
|
builtUrl = await fileToUrl$1(publicPath, config, this);
|
49713
49815
|
}
|
@@ -53782,6 +53884,54 @@ async function handleModuleSoftInvalidation(mod, ssr, timestamp, server) {
|
|
53782
53884
|
return result;
|
53783
53885
|
}
|
53784
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
|
+
|
53785
53935
|
/**
|
53786
53936
|
* @param {import('estree').Node} param
|
53787
53937
|
* @returns {string[]}
|
@@ -54610,15 +54760,6 @@ function ssrFixStacktrace(e, moduleGraph) {
|
|
54610
54760
|
rewroteStacktraces.add(e);
|
54611
54761
|
}
|
54612
54762
|
|
54613
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
54614
|
-
const AsyncFunction$1 = async function () { }.constructor;
|
54615
|
-
let fnDeclarationLineCount$1 = 0;
|
54616
|
-
{
|
54617
|
-
const body = '/*code*/';
|
54618
|
-
const source = new AsyncFunction$1('a', 'b', body).toString();
|
54619
|
-
fnDeclarationLineCount$1 =
|
54620
|
-
source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
54621
|
-
}
|
54622
54763
|
const pendingModules = new Map();
|
54623
54764
|
const pendingImports = new Map();
|
54624
54765
|
const importErrors = new WeakMap();
|
@@ -54744,15 +54885,13 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
54744
54885
|
let sourceMapSuffix = '';
|
54745
54886
|
if (result.map && 'version' in result.map) {
|
54746
54887
|
const moduleSourceMap = Object.assign({}, result.map, {
|
54747
|
-
|
54748
|
-
|
54749
|
-
mappings: ';'.repeat(fnDeclarationLineCount$1) + result.map.mappings,
|
54888
|
+
mappings: ';'.repeat(asyncFunctionDeclarationPaddingLineCount) +
|
54889
|
+
result.map.mappings,
|
54750
54890
|
});
|
54751
|
-
sourceMapSuffix =
|
54752
|
-
'\n//# sourceMappingURL=' + genSourceMapUrl(moduleSourceMap);
|
54891
|
+
sourceMapSuffix = `\n//# ${SOURCEMAPPING_URL}=${genSourceMapUrl(moduleSourceMap)}`;
|
54753
54892
|
}
|
54754
54893
|
try {
|
54755
|
-
const initModule = new AsyncFunction
|
54894
|
+
const initModule = new AsyncFunction(`global`, ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, '"use strict";' +
|
54756
54895
|
result.code +
|
54757
54896
|
`\n//# sourceURL=${mod.id}${sourceMapSuffix}`);
|
54758
54897
|
await initModule(context.global, ssrModule, ssrImportMeta, ssrImport, ssrDynamicImport, ssrExportAll);
|
@@ -54798,7 +54937,9 @@ async function nodeImport(id, importer, resolveOptions, metadata) {
|
|
54798
54937
|
return proxyESM(mod);
|
54799
54938
|
}
|
54800
54939
|
else if (filePath) {
|
54801
|
-
analyzeImportedModDifference(mod,
|
54940
|
+
analyzeImportedModDifference(mod, id, isFilePathESM(filePath, resolveOptions.packageCache)
|
54941
|
+
? 'module'
|
54942
|
+
: undefined, metadata);
|
54802
54943
|
return proxyGuardOnlyEsm(mod, id);
|
54803
54944
|
}
|
54804
54945
|
else {
|
@@ -54828,53 +54969,6 @@ function proxyESM(mod) {
|
|
54828
54969
|
function isPrimitive(value) {
|
54829
54970
|
return !value || (typeof value !== 'object' && typeof value !== 'function');
|
54830
54971
|
}
|
54831
|
-
/**
|
54832
|
-
* Vite converts `import { } from 'foo'` to `const _ = __vite_ssr_import__('foo')`.
|
54833
|
-
* Top-level imports and dynamic imports work slightly differently in Node.js.
|
54834
|
-
* This function normalizes the differences so it matches prod behaviour.
|
54835
|
-
*/
|
54836
|
-
function analyzeImportedModDifference(mod, filePath, rawId, metadata, packageCache) {
|
54837
|
-
// No normalization needed if the user already dynamic imports this module
|
54838
|
-
if (metadata?.isDynamicImport)
|
54839
|
-
return;
|
54840
|
-
// If file path is ESM, everything should be fine
|
54841
|
-
if (isFilePathESM(filePath, packageCache))
|
54842
|
-
return;
|
54843
|
-
// For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.
|
54844
|
-
// If the user named imports a specifier that can't be analyzed, error.
|
54845
|
-
if (metadata?.importedNames?.length) {
|
54846
|
-
const missingBindings = metadata.importedNames.filter((s) => !(s in mod));
|
54847
|
-
if (missingBindings.length) {
|
54848
|
-
const lastBinding = missingBindings[missingBindings.length - 1];
|
54849
|
-
// Copied from Node.js
|
54850
|
-
throw new SyntaxError(`\
|
54851
|
-
[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.
|
54852
|
-
CommonJS modules can always be imported via the default export, for example using:
|
54853
|
-
|
54854
|
-
import pkg from '${rawId}';
|
54855
|
-
const {${missingBindings.join(', ')}} = pkg;
|
54856
|
-
`);
|
54857
|
-
}
|
54858
|
-
}
|
54859
|
-
}
|
54860
|
-
/**
|
54861
|
-
* Guard invalid named exports only, similar to how Node.js errors for top-level imports.
|
54862
|
-
* But since we transform as dynamic imports, we need to emulate the error manually.
|
54863
|
-
*/
|
54864
|
-
function proxyGuardOnlyEsm(mod, rawId, metadata) {
|
54865
|
-
// If the module doesn't import anything explicitly, e.g. `import 'foo'` or
|
54866
|
-
// `import * as foo from 'foo'`, we can skip the proxy guard.
|
54867
|
-
if (!metadata?.importedNames?.length)
|
54868
|
-
return mod;
|
54869
|
-
return new Proxy(mod, {
|
54870
|
-
get(mod, prop) {
|
54871
|
-
if (prop !== 'then' && !(prop in mod)) {
|
54872
|
-
throw new SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${prop.toString()}'`);
|
54873
|
-
}
|
54874
|
-
return mod[prop];
|
54875
|
-
},
|
54876
|
-
});
|
54877
|
-
}
|
54878
54972
|
|
54879
54973
|
var isWsl$2 = {exports: {}};
|
54880
54974
|
|
@@ -56225,7 +56319,6 @@ async function fetchModule(server, url, importer, options = {}) {
|
|
56225
56319
|
isProduction,
|
56226
56320
|
root,
|
56227
56321
|
ssrConfig: ssr,
|
56228
|
-
legacyProxySsrExternalModules: server.config.legacy?.proxySsrExternalModules,
|
56229
56322
|
packageCache: server.config.packageCache,
|
56230
56323
|
};
|
56231
56324
|
const resolved = tryNodeResolve(url, importer, { ...resolveOptions, tryEsmOnly: true }, false, undefined, true);
|
@@ -56270,26 +56363,17 @@ function inlineSourceMap(mod, result, processSourceMap) {
|
|
56270
56363
|
OTHER_SOURCE_MAP_REGEXP.lastIndex = 0;
|
56271
56364
|
if (OTHER_SOURCE_MAP_REGEXP.test(code))
|
56272
56365
|
code = code.replace(OTHER_SOURCE_MAP_REGEXP, '');
|
56273
|
-
const sourceMap =
|
56274
|
-
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`;
|
56275
56368
|
return result;
|
56276
56369
|
}
|
56277
56370
|
|
56278
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
56279
|
-
const AsyncFunction = async function () { }.constructor;
|
56280
|
-
const fnDeclarationLineCount = (() => {
|
56281
|
-
const body = '/*code*/';
|
56282
|
-
const source = new AsyncFunction('a', 'b', body).toString();
|
56283
|
-
return source.slice(0, source.indexOf(body)).split('\n').length - 1;
|
56284
|
-
})();
|
56285
56371
|
function ssrFetchModule(server, id, importer) {
|
56286
56372
|
return fetchModule(server, id, importer, {
|
56287
56373
|
processSourceMap(map) {
|
56288
56374
|
// this assumes that "new AsyncFunction" is used to create the module
|
56289
56375
|
return Object.assign({}, map, {
|
56290
|
-
|
56291
|
-
// https://github.com/nodejs/node/issues/43047#issuecomment-1180632750
|
56292
|
-
mappings: ';'.repeat(fnDeclarationLineCount) + map.mappings,
|
56376
|
+
mappings: ';'.repeat(asyncFunctionDeclarationPaddingLineCount) + map.mappings,
|
56293
56377
|
});
|
56294
56378
|
},
|
56295
56379
|
});
|
@@ -64477,9 +64561,14 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64477
64561
|
_importGlobMap: new Map(),
|
64478
64562
|
_forceOptimizeOnRestart: false,
|
64479
64563
|
_pendingRequests: new Map(),
|
64480
|
-
_fsDenyGlob: picomatch$4(
|
64481
|
-
|
64564
|
+
_fsDenyGlob: picomatch$4(
|
64565
|
+
// matchBase: true does not work as it's documented
|
64566
|
+
// https://github.com/micromatch/picomatch/issues/89
|
64567
|
+
// convert patterns without `/` on our side for now
|
64568
|
+
config.server.fs.deny.map((pattern) => pattern.includes('/') ? pattern : `**/${pattern}`), {
|
64569
|
+
matchBase: false,
|
64482
64570
|
nocase: true,
|
64571
|
+
dot: true,
|
64483
64572
|
}),
|
64484
64573
|
_shortcutsOptions: undefined,
|
64485
64574
|
};
|
@@ -64592,14 +64681,12 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64592
64681
|
// proxy
|
64593
64682
|
const { proxy } = serverConfig;
|
64594
64683
|
if (proxy) {
|
64595
|
-
const middlewareServer = (isObject$1(
|
64596
|
-
? serverConfig.middlewareMode.server
|
64597
|
-
: null) || httpServer;
|
64684
|
+
const middlewareServer = (isObject$1(middlewareMode) ? middlewareMode.server : null) || httpServer;
|
64598
64685
|
middlewares.use(proxyMiddleware(middlewareServer, proxy, config));
|
64599
64686
|
}
|
64600
64687
|
// base
|
64601
64688
|
if (config.base !== '/') {
|
64602
|
-
middlewares.use(baseMiddleware(config.rawBase, middlewareMode));
|
64689
|
+
middlewares.use(baseMiddleware(config.rawBase, !!middlewareMode));
|
64603
64690
|
}
|
64604
64691
|
// open in editor support
|
64605
64692
|
middlewares.use('/__open-in-editor', launchEditorMiddleware$1());
|
@@ -64639,7 +64726,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
64639
64726
|
middlewares.use(notFoundMiddleware());
|
64640
64727
|
}
|
64641
64728
|
// error handler
|
64642
|
-
middlewares.use(errorMiddleware(server, middlewareMode));
|
64729
|
+
middlewares.use(errorMiddleware(server, !!middlewareMode));
|
64643
64730
|
// httpServer.listen can be called multiple times
|
64644
64731
|
// when port when using next port number
|
64645
64732
|
// this code is to avoid calling buildStart multiple times
|
@@ -64751,7 +64838,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
64751
64838
|
sourcemapIgnoreList: raw?.sourcemapIgnoreList === false
|
64752
64839
|
? () => false
|
64753
64840
|
: raw?.sourcemapIgnoreList || isInNodeModules$1,
|
64754
|
-
middlewareMode:
|
64841
|
+
middlewareMode: raw?.middlewareMode || false,
|
64755
64842
|
};
|
64756
64843
|
let allowDirs = server.fs?.allow;
|
64757
64844
|
const deny = server.fs?.deny || ['.env', '.env.*', '*.{crt,pem}'];
|
@@ -65980,7 +66067,7 @@ function createParseErrorInfo(importer, source) {
|
|
65980
66067
|
};
|
65981
66068
|
}
|
65982
66069
|
// prettier-ignore
|
65983
|
-
const interopHelper = (m) => m?.__esModule ? m : { ...(typeof m === 'object' && !Array.isArray(m) ? m : {}), default: m };
|
66070
|
+
const interopHelper = (m) => m?.__esModule ? m : { ...(typeof m === 'object' && !Array.isArray(m) || typeof m === 'function' ? m : {}), default: m };
|
65984
66071
|
function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, importer, config) {
|
65985
66072
|
const source = str.original;
|
65986
66073
|
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, } = importSpecifier;
|
@@ -67222,7 +67309,7 @@ function injectSsrFlag(options) {
|
|
67222
67309
|
}
|
67223
67310
|
/*
|
67224
67311
|
The following functions are copied from rollup
|
67225
|
-
https://github.com/rollup/rollup/blob/
|
67312
|
+
https://github.com/rollup/rollup/blob/ce6cb93098850a46fa242e37b74a919e99a5de28/src/ast/nodes/MetaProperty.ts#L155-L203
|
67226
67313
|
|
67227
67314
|
https://github.com/rollup/rollup
|
67228
67315
|
The MIT License (MIT)
|
@@ -67242,24 +67329,24 @@ function escapeId(id) {
|
|
67242
67329
|
const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
|
67243
67330
|
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
67244
67331
|
const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
|
67245
|
-
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${path}'`);
|
67332
|
+
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
|
67246
67333
|
const relativeUrlMechanisms = {
|
67247
67334
|
amd: (relativePath) => {
|
67248
67335
|
if (relativePath[0] !== '.')
|
67249
67336
|
relativePath = './' + relativePath;
|
67250
|
-
return getResolveUrl(`require.toUrl('${relativePath}'), document.baseURI`);
|
67337
|
+
return getResolveUrl(`require.toUrl('${escapeId(relativePath)}'), document.baseURI`);
|
67251
67338
|
},
|
67252
67339
|
cjs: (relativePath) => `(typeof document === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath)})`,
|
67253
|
-
es: (relativePath) => getResolveUrl(`'${relativePath}', import.meta.url`),
|
67340
|
+
es: (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', import.meta.url`),
|
67254
67341
|
iife: (relativePath) => getRelativeUrlFromDocument(relativePath),
|
67255
67342
|
// NOTE: make sure rollup generate `module` params
|
67256
|
-
system: (relativePath) => getResolveUrl(`'${relativePath}', module.meta.url`),
|
67343
|
+
system: (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', module.meta.url`),
|
67257
67344
|
umd: (relativePath) => `(typeof document === 'undefined' && typeof location === 'undefined' ? ${getFileUrlFromRelativePath(relativePath)} : ${getRelativeUrlFromDocument(relativePath, true)})`,
|
67258
67345
|
};
|
67259
67346
|
/* end of copy */
|
67260
67347
|
const customRelativeUrlMechanisms = {
|
67261
67348
|
...relativeUrlMechanisms,
|
67262
|
-
'worker-iife': (relativePath) => getResolveUrl(`'${relativePath}', self.location.href`),
|
67349
|
+
'worker-iife': (relativePath) => getResolveUrl(`'${escapeId(relativePath)}', self.location.href`),
|
67263
67350
|
};
|
67264
67351
|
function toOutputFilePathInJS(filename, type, hostId, hostType, config, toRelative) {
|
67265
67352
|
const { renderBuiltUrl } = config.experimental;
|
@@ -67817,7 +67904,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67817
67904
|
logger.warn(colors$1.yellow(`worker.plugins is now a function that returns an array of plugins. ` +
|
67818
67905
|
`Please update your Vite config accordingly.\n`));
|
67819
67906
|
}
|
67820
|
-
const createWorkerPlugins = async function () {
|
67907
|
+
const createWorkerPlugins = async function (bundleChain) {
|
67821
67908
|
// Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
|
67822
67909
|
// And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
|
67823
67910
|
// So we need to separate the worker plugin from the plugin that vite needs to run.
|
@@ -67837,6 +67924,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67837
67924
|
...resolved,
|
67838
67925
|
isWorker: true,
|
67839
67926
|
mainConfig: resolved,
|
67927
|
+
bundleChain,
|
67840
67928
|
};
|
67841
67929
|
const resolvedWorkerPlugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
|
67842
67930
|
// run configResolved hooks
|
@@ -67865,6 +67953,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67865
67953
|
ssr,
|
67866
67954
|
isWorker: false,
|
67867
67955
|
mainConfig: null,
|
67956
|
+
bundleChain: [],
|
67868
67957
|
isProduction,
|
67869
67958
|
plugins: userPlugins,
|
67870
67959
|
css: resolveCSSOptions(config.css),
|