vite 6.0.2 → 6.0.4
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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/bin/vite.js +4 -0
- package/dist/client/client.mjs +23 -25
- package/dist/node/chunks/{dep-A4nAWF7x.js → dep-BZMjGe_U.js} +636 -353
- package/dist/node/chunks/{dep-DFNV1bxH.js → dep-CrWUFq3l.js} +1 -1
- package/dist/node/chunks/{dep-CoVxupJ6.js → dep-pSQn2Hds.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +14 -9
- package/dist/node/index.js +4 -4
- package/dist/node/module-runner.d.ts +2 -2
- package/dist/node/module-runner.js +11 -11
- package/dist/node-cjs/publicUtils.cjs +106 -68
- package/package.json +15 -14
@@ -5,7 +5,7 @@ import path$d, { posix as posix$1, isAbsolute as isAbsolute$1, join as join$1, r
|
|
5
5
|
import require$$1$1, { fileURLToPath as fileURLToPath$1, URL as URL$3, pathToFileURL as pathToFileURL$1 } from 'node:url';
|
6
6
|
import { promisify as promisify$4, format as format$2, inspect, stripVTControlCharacters } from 'node:util';
|
7
7
|
import { performance } from 'node:perf_hooks';
|
8
|
-
import require$$0$
|
8
|
+
import require$$0$6, { createRequire as createRequire$1, builtinModules } from 'node:module';
|
9
9
|
import esbuild, { transform as transform$1, formatMessages, build as build$b } from 'esbuild';
|
10
10
|
import { CLIENT_ENTRY, OPTIMIZABLE_ENTRY_RE, wildcardHosts, loopbackHosts, FS_PREFIX, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, DEFAULT_ASSETS_INLINE_LIMIT, ENV_ENTRY, SPECIAL_QUERY_RE, DEP_VERSION_RE, DEV_PROD_CONDITION, JS_TYPES_RE, KNOWN_ASSET_TYPES, CSS_LANGS_RE, METADATA_FILENAME, ESBUILD_MODULES_TARGET, ERR_OPTIMIZE_DEPS_PROCESSING_ERROR, ERR_FILE_NOT_FOUND_IN_OPTIMIZED_DEP_DIR, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, VERSION, ROLLUP_HOOKS, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_CLIENT_MAIN_FIELDS, DEFAULT_SERVER_MAIN_FIELDS, DEFAULT_CLIENT_CONDITIONS, DEFAULT_SERVER_CONDITIONS } from '../constants.js';
|
11
11
|
import require$$0$2, { posix, win32, isAbsolute, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join, sep } from 'path';
|
@@ -17,7 +17,7 @@ import require$$0$4 from 'tty';
|
|
17
17
|
import require$$1 from 'util';
|
18
18
|
import require$$4$1 from 'net';
|
19
19
|
import require$$0$7 from 'events';
|
20
|
-
import require$$0$
|
20
|
+
import require$$0$5 from 'url';
|
21
21
|
import require$$1$2 from 'http';
|
22
22
|
import require$$0$8 from 'stream';
|
23
23
|
import require$$2 from 'os';
|
@@ -35,7 +35,7 @@ import { EventEmitter as EventEmitter$4 } from 'node:events';
|
|
35
35
|
import require$$3 from 'crypto';
|
36
36
|
import assert$1 from 'node:assert';
|
37
37
|
import v8 from 'node:v8';
|
38
|
-
import { Worker as Worker$1 } from 'node:worker_threads';
|
38
|
+
import { Worker as Worker$1, MessageChannel } from 'node:worker_threads';
|
39
39
|
import zlib$1 from 'zlib';
|
40
40
|
import require$$0$9 from 'buffer';
|
41
41
|
import require$$1$3 from 'https';
|
@@ -2544,7 +2544,7 @@ const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
|
2544
2544
|
}
|
2545
2545
|
let newScope;
|
2546
2546
|
// create new function scope
|
2547
|
-
if (
|
2547
|
+
if (node.type.includes('Function')) {
|
2548
2548
|
const func = node;
|
2549
2549
|
newScope = new Scope({
|
2550
2550
|
parent: scope,
|
@@ -2565,7 +2565,7 @@ const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
|
2565
2565
|
});
|
2566
2566
|
}
|
2567
2567
|
// create new block scope
|
2568
|
-
if (node.type === 'BlockStatement' &&
|
2568
|
+
if (node.type === 'BlockStatement' && !parent.type.includes('Function')) {
|
2569
2569
|
newScope = new Scope({
|
2570
2570
|
parent: scope,
|
2571
2571
|
block: true
|
@@ -2652,11 +2652,17 @@ const createFilter$1 = function createFilter(include, exclude, options) {
|
|
2652
2652
|
const pathId = normalizePath$6(id);
|
2653
2653
|
for (let i = 0; i < excludeMatchers.length; ++i) {
|
2654
2654
|
const matcher = excludeMatchers[i];
|
2655
|
+
if (matcher instanceof RegExp) {
|
2656
|
+
matcher.lastIndex = 0;
|
2657
|
+
}
|
2655
2658
|
if (matcher.test(pathId))
|
2656
2659
|
return false;
|
2657
2660
|
}
|
2658
2661
|
for (let i = 0; i < includeMatchers.length; ++i) {
|
2659
2662
|
const matcher = includeMatchers[i];
|
2663
|
+
if (matcher instanceof RegExp) {
|
2664
|
+
matcher.lastIndex = 0;
|
2665
|
+
}
|
2660
2666
|
if (matcher.test(pathId))
|
2661
2667
|
return true;
|
2662
2668
|
}
|
@@ -3880,7 +3886,7 @@ class Chunk {
|
|
3880
3886
|
// ' test'.trim()
|
3881
3887
|
// split -> ' ' + 'test'
|
3882
3888
|
// ✔️ edit -> '' + 'test'
|
3883
|
-
// ✖️ edit -> 'test' + ''
|
3889
|
+
// ✖️ edit -> 'test' + ''
|
3884
3890
|
// TODO is this block necessary?...
|
3885
3891
|
newChunk.edit('', false);
|
3886
3892
|
this.content = '';
|
@@ -4127,6 +4133,7 @@ class Mappings {
|
|
4127
4133
|
this.raw[this.generatedCodeLine] = this.rawSegments = [];
|
4128
4134
|
this.generatedCodeColumn = 0;
|
4129
4135
|
first = true;
|
4136
|
+
charInHiresBoundary = false;
|
4130
4137
|
} else {
|
4131
4138
|
if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
|
4132
4139
|
const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
|
@@ -4204,6 +4211,7 @@ class MagicString {
|
|
4204
4211
|
storedNames: { writable: true, value: {} },
|
4205
4212
|
indentStr: { writable: true, value: undefined },
|
4206
4213
|
ignoreList: { writable: true, value: options.ignoreList },
|
4214
|
+
offset: { writable: true, value: options.offset || 0 },
|
4207
4215
|
});
|
4208
4216
|
|
4209
4217
|
this.byStart[0] = chunk;
|
@@ -4222,6 +4230,8 @@ class MagicString {
|
|
4222
4230
|
}
|
4223
4231
|
|
4224
4232
|
appendLeft(index, content) {
|
4233
|
+
index = index + this.offset;
|
4234
|
+
|
4225
4235
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
4226
4236
|
|
4227
4237
|
this._split(index);
|
@@ -4237,6 +4247,8 @@ class MagicString {
|
|
4237
4247
|
}
|
4238
4248
|
|
4239
4249
|
appendRight(index, content) {
|
4250
|
+
index = index + this.offset;
|
4251
|
+
|
4240
4252
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
4241
4253
|
|
4242
4254
|
this._split(index);
|
@@ -4252,7 +4264,7 @@ class MagicString {
|
|
4252
4264
|
}
|
4253
4265
|
|
4254
4266
|
clone() {
|
4255
|
-
const cloned = new MagicString(this.original, { filename: this.filename });
|
4267
|
+
const cloned = new MagicString(this.original, { filename: this.filename, offset: this.offset });
|
4256
4268
|
|
4257
4269
|
let originalChunk = this.firstChunk;
|
4258
4270
|
let clonedChunk = (cloned.firstChunk = cloned.lastSearchedChunk = originalChunk.clone());
|
@@ -4450,7 +4462,7 @@ class MagicString {
|
|
4450
4462
|
if (!warned.insertLeft) {
|
4451
4463
|
console.warn(
|
4452
4464
|
'magicString.insertLeft(...) is deprecated. Use magicString.appendLeft(...) instead',
|
4453
|
-
);
|
4465
|
+
);
|
4454
4466
|
warned.insertLeft = true;
|
4455
4467
|
}
|
4456
4468
|
|
@@ -4461,7 +4473,7 @@ class MagicString {
|
|
4461
4473
|
if (!warned.insertRight) {
|
4462
4474
|
console.warn(
|
4463
4475
|
'magicString.insertRight(...) is deprecated. Use magicString.prependRight(...) instead',
|
4464
|
-
);
|
4476
|
+
);
|
4465
4477
|
warned.insertRight = true;
|
4466
4478
|
}
|
4467
4479
|
|
@@ -4469,6 +4481,10 @@ class MagicString {
|
|
4469
4481
|
}
|
4470
4482
|
|
4471
4483
|
move(start, end, index) {
|
4484
|
+
start = start + this.offset;
|
4485
|
+
end = end + this.offset;
|
4486
|
+
index = index + this.offset;
|
4487
|
+
|
4472
4488
|
if (index >= start && index <= end) throw new Error('Cannot move a selection inside itself');
|
4473
4489
|
|
4474
4490
|
this._split(start);
|
@@ -4511,6 +4527,9 @@ class MagicString {
|
|
4511
4527
|
}
|
4512
4528
|
|
4513
4529
|
update(start, end, content, options) {
|
4530
|
+
start = start + this.offset;
|
4531
|
+
end = end + this.offset;
|
4532
|
+
|
4514
4533
|
if (typeof content !== 'string') throw new TypeError('replacement content must be a string');
|
4515
4534
|
|
4516
4535
|
if (this.original.length !== 0) {
|
@@ -4531,7 +4550,7 @@ class MagicString {
|
|
4531
4550
|
if (!warned.storeName) {
|
4532
4551
|
console.warn(
|
4533
4552
|
'The final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string',
|
4534
|
-
);
|
4553
|
+
);
|
4535
4554
|
warned.storeName = true;
|
4536
4555
|
}
|
4537
4556
|
|
@@ -4582,6 +4601,8 @@ class MagicString {
|
|
4582
4601
|
}
|
4583
4602
|
|
4584
4603
|
prependLeft(index, content) {
|
4604
|
+
index = index + this.offset;
|
4605
|
+
|
4585
4606
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
4586
4607
|
|
4587
4608
|
this._split(index);
|
@@ -4597,6 +4618,8 @@ class MagicString {
|
|
4597
4618
|
}
|
4598
4619
|
|
4599
4620
|
prependRight(index, content) {
|
4621
|
+
index = index + this.offset;
|
4622
|
+
|
4600
4623
|
if (typeof content !== 'string') throw new TypeError('inserted content must be a string');
|
4601
4624
|
|
4602
4625
|
this._split(index);
|
@@ -4612,6 +4635,9 @@ class MagicString {
|
|
4612
4635
|
}
|
4613
4636
|
|
4614
4637
|
remove(start, end) {
|
4638
|
+
start = start + this.offset;
|
4639
|
+
end = end + this.offset;
|
4640
|
+
|
4615
4641
|
if (this.original.length !== 0) {
|
4616
4642
|
while (start < 0) start += this.original.length;
|
4617
4643
|
while (end < 0) end += this.original.length;
|
@@ -4638,6 +4664,9 @@ class MagicString {
|
|
4638
4664
|
}
|
4639
4665
|
|
4640
4666
|
reset(start, end) {
|
4667
|
+
start = start + this.offset;
|
4668
|
+
end = end + this.offset;
|
4669
|
+
|
4641
4670
|
if (this.original.length !== 0) {
|
4642
4671
|
while (start < 0) start += this.original.length;
|
4643
4672
|
while (end < 0) end += this.original.length;
|
@@ -4702,7 +4731,10 @@ class MagicString {
|
|
4702
4731
|
return this.intro + lineStr;
|
4703
4732
|
}
|
4704
4733
|
|
4705
|
-
slice(start = 0, end = this.original.length) {
|
4734
|
+
slice(start = 0, end = this.original.length - this.offset) {
|
4735
|
+
start = start + this.offset;
|
4736
|
+
end = end + this.offset;
|
4737
|
+
|
4706
4738
|
if (this.original.length !== 0) {
|
4707
4739
|
while (start < 0) start += this.original.length;
|
4708
4740
|
while (end < 0) end += this.original.length;
|
@@ -4938,11 +4970,7 @@ class MagicString {
|
|
4938
4970
|
if (match.index != null) {
|
4939
4971
|
const replacement = getReplacement(match, this.original);
|
4940
4972
|
if (replacement !== match[0]) {
|
4941
|
-
this.overwrite(
|
4942
|
-
match.index,
|
4943
|
-
match.index + match[0].length,
|
4944
|
-
replacement
|
4945
|
-
);
|
4973
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
4946
4974
|
}
|
4947
4975
|
}
|
4948
4976
|
});
|
@@ -4951,11 +4979,7 @@ class MagicString {
|
|
4951
4979
|
if (match && match.index != null) {
|
4952
4980
|
const replacement = getReplacement(match, this.original);
|
4953
4981
|
if (replacement !== match[0]) {
|
4954
|
-
this.overwrite(
|
4955
|
-
match.index,
|
4956
|
-
match.index + match[0].length,
|
4957
|
-
replacement
|
4958
|
-
);
|
4982
|
+
this.overwrite(match.index, match.index + match[0].length, replacement);
|
4959
4983
|
}
|
4960
4984
|
}
|
4961
4985
|
}
|
@@ -4990,8 +5014,7 @@ class MagicString {
|
|
4990
5014
|
index = original.indexOf(string, index + stringLength)
|
4991
5015
|
) {
|
4992
5016
|
const previous = original.slice(index, index + stringLength);
|
4993
|
-
if (previous !== replacement)
|
4994
|
-
this.overwrite(index, index + stringLength, replacement);
|
5017
|
+
if (previous !== replacement) this.overwrite(index, index + stringLength, replacement);
|
4995
5018
|
}
|
4996
5019
|
|
4997
5020
|
return this;
|
@@ -5042,7 +5065,7 @@ function isReference(node, parent) {
|
|
5042
5065
|
return false;
|
5043
5066
|
}
|
5044
5067
|
|
5045
|
-
var version$2 = "28.0.
|
5068
|
+
var version$2 = "28.0.2";
|
5046
5069
|
var peerDependencies = {
|
5047
5070
|
rollup: "^2.68.0||^3.0.0||^4.0.0"
|
5048
5071
|
};
|
@@ -8638,24 +8661,62 @@ function requireCommon () {
|
|
8638
8661
|
createDebug.names = [];
|
8639
8662
|
createDebug.skips = [];
|
8640
8663
|
|
8641
|
-
|
8642
|
-
|
8643
|
-
|
8664
|
+
const split = (typeof namespaces === 'string' ? namespaces : '')
|
8665
|
+
.trim()
|
8666
|
+
.replace(' ', ',')
|
8667
|
+
.split(',')
|
8668
|
+
.filter(Boolean);
|
8644
8669
|
|
8645
|
-
for (
|
8646
|
-
if (
|
8647
|
-
|
8648
|
-
|
8670
|
+
for (const ns of split) {
|
8671
|
+
if (ns[0] === '-') {
|
8672
|
+
createDebug.skips.push(ns.slice(1));
|
8673
|
+
} else {
|
8674
|
+
createDebug.names.push(ns);
|
8649
8675
|
}
|
8676
|
+
}
|
8677
|
+
}
|
8650
8678
|
|
8651
|
-
|
8652
|
-
|
8653
|
-
|
8654
|
-
|
8679
|
+
/**
|
8680
|
+
* Checks if the given string matches a namespace template, honoring
|
8681
|
+
* asterisks as wildcards.
|
8682
|
+
*
|
8683
|
+
* @param {String} search
|
8684
|
+
* @param {String} template
|
8685
|
+
* @return {Boolean}
|
8686
|
+
*/
|
8687
|
+
function matchesTemplate(search, template) {
|
8688
|
+
let searchIndex = 0;
|
8689
|
+
let templateIndex = 0;
|
8690
|
+
let starIndex = -1;
|
8691
|
+
let matchIndex = 0;
|
8692
|
+
|
8693
|
+
while (searchIndex < search.length) {
|
8694
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
8695
|
+
// Match character or proceed with wildcard
|
8696
|
+
if (template[templateIndex] === '*') {
|
8697
|
+
starIndex = templateIndex;
|
8698
|
+
matchIndex = searchIndex;
|
8699
|
+
templateIndex++; // Skip the '*'
|
8700
|
+
} else {
|
8701
|
+
searchIndex++;
|
8702
|
+
templateIndex++;
|
8703
|
+
}
|
8704
|
+
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
8705
|
+
// Backtrack to the last '*' and try to match more characters
|
8706
|
+
templateIndex = starIndex + 1;
|
8707
|
+
matchIndex++;
|
8708
|
+
searchIndex = matchIndex;
|
8655
8709
|
} else {
|
8656
|
-
|
8710
|
+
return false; // No match
|
8657
8711
|
}
|
8658
8712
|
}
|
8713
|
+
|
8714
|
+
// Handle trailing '*' in template
|
8715
|
+
while (templateIndex < template.length && template[templateIndex] === '*') {
|
8716
|
+
templateIndex++;
|
8717
|
+
}
|
8718
|
+
|
8719
|
+
return templateIndex === template.length;
|
8659
8720
|
}
|
8660
8721
|
|
8661
8722
|
/**
|
@@ -8666,8 +8727,8 @@ function requireCommon () {
|
|
8666
8727
|
*/
|
8667
8728
|
function disable() {
|
8668
8729
|
const namespaces = [
|
8669
|
-
...createDebug.names
|
8670
|
-
...createDebug.skips.map(
|
8730
|
+
...createDebug.names,
|
8731
|
+
...createDebug.skips.map(namespace => '-' + namespace)
|
8671
8732
|
].join(',');
|
8672
8733
|
createDebug.enable('');
|
8673
8734
|
return namespaces;
|
@@ -8681,21 +8742,14 @@ function requireCommon () {
|
|
8681
8742
|
* @api public
|
8682
8743
|
*/
|
8683
8744
|
function enabled(name) {
|
8684
|
-
|
8685
|
-
|
8686
|
-
}
|
8687
|
-
|
8688
|
-
let i;
|
8689
|
-
let len;
|
8690
|
-
|
8691
|
-
for (i = 0, len = createDebug.skips.length; i < len; i++) {
|
8692
|
-
if (createDebug.skips[i].test(name)) {
|
8745
|
+
for (const skip of createDebug.skips) {
|
8746
|
+
if (matchesTemplate(name, skip)) {
|
8693
8747
|
return false;
|
8694
8748
|
}
|
8695
8749
|
}
|
8696
8750
|
|
8697
|
-
for (
|
8698
|
-
if (
|
8751
|
+
for (const ns of createDebug.names) {
|
8752
|
+
if (matchesTemplate(name, ns)) {
|
8699
8753
|
return true;
|
8700
8754
|
}
|
8701
8755
|
}
|
@@ -8703,19 +8757,6 @@ function requireCommon () {
|
|
8703
8757
|
return false;
|
8704
8758
|
}
|
8705
8759
|
|
8706
|
-
/**
|
8707
|
-
* Convert regexp to namespace
|
8708
|
-
*
|
8709
|
-
* @param {RegExp} regxep
|
8710
|
-
* @return {String} namespace
|
8711
|
-
* @api private
|
8712
|
-
*/
|
8713
|
-
function toNamespace(regexp) {
|
8714
|
-
return regexp.toString()
|
8715
|
-
.substring(2, regexp.toString().length - 2)
|
8716
|
-
.replace(/\.\*\?$/, '*');
|
8717
|
-
}
|
8718
|
-
|
8719
8760
|
/**
|
8720
8761
|
* Coerce `val`.
|
8721
8762
|
*
|
@@ -8884,6 +8925,7 @@ function requireBrowser$1 () {
|
|
8884
8925
|
|
8885
8926
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
8886
8927
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
8928
|
+
// eslint-disable-next-line no-return-assign
|
8887
8929
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
8888
8930
|
// Is firebug? http://stackoverflow.com/a/398120/376773
|
8889
8931
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
@@ -10172,7 +10214,7 @@ async function resolveServerUrls(server, options, config) {
|
|
10172
10214
|
}
|
10173
10215
|
} else {
|
10174
10216
|
Object.values(os$3.networkInterfaces()).flatMap((nInterface) => nInterface ?? []).filter(
|
10175
|
-
(detail) => detail
|
10217
|
+
(detail) => detail.address && (detail.family === "IPv4" || // @ts-expect-error Node 18.0 - 18.3 returns number
|
10176
10218
|
detail.family === 4)
|
10177
10219
|
).forEach((detail) => {
|
10178
10220
|
let host = detail.address.replace("127.0.0.1", hostname.name);
|
@@ -10442,7 +10484,7 @@ function getNpmPackageName(importPath) {
|
|
10442
10484
|
}
|
10443
10485
|
}
|
10444
10486
|
function getPkgName(name) {
|
10445
|
-
return name
|
10487
|
+
return name[0] === "@" ? name.split("/")[1] : name;
|
10446
10488
|
}
|
10447
10489
|
const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
|
10448
10490
|
function escapeRegex(str) {
|
@@ -12382,8 +12424,18 @@ async function reloadOnTsconfigChange(server, changedFile) {
|
|
12382
12424
|
}
|
12383
12425
|
}
|
12384
12426
|
|
12427
|
+
// src/realWorker.ts
|
12428
|
+
|
12429
|
+
// src/utils.ts
|
12430
|
+
var AsyncFunction = async function() {
|
12431
|
+
}.constructor;
|
12432
|
+
var codeToDataUrl = (code) => `data:application/javascript,${encodeURIComponent(code + "\n//# sourceURL=[worker-eval(artichokie)]")}`;
|
12433
|
+
var viteSsrDynamicImport = "__vite_ssr_dynamic_import__";
|
12434
|
+
|
12385
12435
|
// src/realWorker.ts
|
12386
12436
|
var Worker = class {
|
12437
|
+
/** @internal */
|
12438
|
+
_isModule;
|
12387
12439
|
/** @internal */
|
12388
12440
|
_code;
|
12389
12441
|
/** @internal */
|
@@ -12397,7 +12449,12 @@ var Worker = class {
|
|
12397
12449
|
/** @internal */
|
12398
12450
|
_queue;
|
12399
12451
|
constructor(fn, options = {}) {
|
12400
|
-
this.
|
12452
|
+
this._isModule = options.type === "module";
|
12453
|
+
this._code = genWorkerCode(
|
12454
|
+
fn,
|
12455
|
+
this._isModule,
|
12456
|
+
options.parentFunctions ?? {}
|
12457
|
+
);
|
12401
12458
|
this._parentFunctions = options.parentFunctions ?? {};
|
12402
12459
|
const defaultMax = Math.max(
|
12403
12460
|
1,
|
@@ -12414,7 +12471,7 @@ var Worker = class {
|
|
12414
12471
|
return new Promise((resolve, reject) => {
|
12415
12472
|
worker.currentResolve = resolve;
|
12416
12473
|
worker.currentReject = reject;
|
12417
|
-
worker.postMessage({
|
12474
|
+
worker.postMessage({ args });
|
12418
12475
|
});
|
12419
12476
|
}
|
12420
12477
|
stop() {
|
@@ -12429,51 +12486,70 @@ var Worker = class {
|
|
12429
12486
|
this._queue = [];
|
12430
12487
|
}
|
12431
12488
|
/** @internal */
|
12489
|
+
_createWorker(parentFunctionSyncMessagePort, parentFunctionAsyncMessagePort, lockState) {
|
12490
|
+
const options = {
|
12491
|
+
workerData: [
|
12492
|
+
parentFunctionSyncMessagePort,
|
12493
|
+
parentFunctionAsyncMessagePort,
|
12494
|
+
lockState
|
12495
|
+
],
|
12496
|
+
transferList: [
|
12497
|
+
parentFunctionSyncMessagePort,
|
12498
|
+
parentFunctionAsyncMessagePort
|
12499
|
+
]
|
12500
|
+
};
|
12501
|
+
if (this._isModule) {
|
12502
|
+
return new Worker$1(
|
12503
|
+
new URL(codeToDataUrl(this._code)),
|
12504
|
+
options
|
12505
|
+
);
|
12506
|
+
}
|
12507
|
+
return new Worker$1(this._code, {
|
12508
|
+
...options,
|
12509
|
+
eval: true
|
12510
|
+
});
|
12511
|
+
}
|
12512
|
+
/** @internal */
|
12432
12513
|
async _getAvailableWorker() {
|
12433
12514
|
if (this._idlePool.length) {
|
12434
12515
|
return this._idlePool.shift();
|
12435
12516
|
}
|
12436
12517
|
if (this._pool.length < this._max) {
|
12437
|
-
const
|
12518
|
+
const parentFunctionResponder = createParentFunctionResponder(
|
12519
|
+
this._parentFunctions
|
12520
|
+
);
|
12521
|
+
const worker = this._createWorker(
|
12522
|
+
parentFunctionResponder.workerPorts.sync,
|
12523
|
+
parentFunctionResponder.workerPorts.async,
|
12524
|
+
parentFunctionResponder.lockState
|
12525
|
+
);
|
12438
12526
|
worker.on("message", async (args) => {
|
12439
|
-
if (
|
12440
|
-
|
12441
|
-
|
12442
|
-
|
12443
|
-
|
12444
|
-
|
12445
|
-
args.error.message += ". Maybe you forgot to pass the function to parentFunction?";
|
12446
|
-
}
|
12447
|
-
worker.currentReject && worker.currentReject(args.error);
|
12448
|
-
worker.currentReject = null;
|
12449
|
-
}
|
12450
|
-
this._assignDoneWorker(worker);
|
12451
|
-
} else if (args.type === "parentFunction") {
|
12452
|
-
try {
|
12453
|
-
const result = await this._parentFunctions[args.name](...args.args);
|
12454
|
-
worker.postMessage({ type: "parentFunction", id: args.id, result });
|
12455
|
-
} catch (e) {
|
12456
|
-
worker.postMessage({
|
12457
|
-
type: "parentFunction",
|
12458
|
-
id: args.id,
|
12459
|
-
error: e
|
12460
|
-
});
|
12527
|
+
if ("result" in args) {
|
12528
|
+
worker.currentResolve?.(args.result);
|
12529
|
+
worker.currentResolve = null;
|
12530
|
+
} else {
|
12531
|
+
if (args.error instanceof ReferenceError) {
|
12532
|
+
args.error.message += ". Maybe you forgot to pass the function to parentFunction?";
|
12461
12533
|
}
|
12534
|
+
worker.currentReject?.(args.error);
|
12535
|
+
worker.currentReject = null;
|
12462
12536
|
}
|
12537
|
+
this._assignDoneWorker(worker);
|
12463
12538
|
});
|
12464
12539
|
worker.on("error", (err) => {
|
12465
|
-
worker.currentReject
|
12540
|
+
worker.currentReject?.(err);
|
12466
12541
|
worker.currentReject = null;
|
12542
|
+
parentFunctionResponder.close();
|
12467
12543
|
});
|
12468
12544
|
worker.on("exit", (code) => {
|
12469
12545
|
const i = this._pool.indexOf(worker);
|
12470
|
-
if (i > -1)
|
12471
|
-
this._pool.splice(i, 1);
|
12546
|
+
if (i > -1) this._pool.splice(i, 1);
|
12472
12547
|
if (code !== 0 && worker.currentReject) {
|
12473
12548
|
worker.currentReject(
|
12474
12549
|
new Error(`Worker stopped with non-0 exit code ${code}`)
|
12475
12550
|
);
|
12476
12551
|
worker.currentReject = null;
|
12552
|
+
parentFunctionResponder.close();
|
12477
12553
|
}
|
12478
12554
|
});
|
12479
12555
|
this._pool.push(worker);
|
@@ -12498,22 +12574,99 @@ var Worker = class {
|
|
12498
12574
|
this._idlePool.push(worker);
|
12499
12575
|
}
|
12500
12576
|
};
|
12501
|
-
function
|
12502
|
-
const
|
12577
|
+
function createParentFunctionResponder(parentFunctions) {
|
12578
|
+
const lockState = new Int32Array(new SharedArrayBuffer(4));
|
12579
|
+
const unlock = () => {
|
12580
|
+
Atomics.store(lockState, 0, 0);
|
12581
|
+
Atomics.notify(lockState, 0);
|
12582
|
+
};
|
12583
|
+
const parentFunctionSyncMessageChannel = new MessageChannel();
|
12584
|
+
const parentFunctionAsyncMessageChannel = new MessageChannel();
|
12585
|
+
const parentFunctionSyncMessagePort = parentFunctionSyncMessageChannel.port1;
|
12586
|
+
const parentFunctionAsyncMessagePort = parentFunctionAsyncMessageChannel.port1;
|
12587
|
+
const syncResponse = (data) => {
|
12588
|
+
parentFunctionSyncMessagePort.postMessage(data);
|
12589
|
+
unlock();
|
12590
|
+
};
|
12591
|
+
parentFunctionSyncMessagePort.on("message", async (args) => {
|
12592
|
+
let syncResult;
|
12593
|
+
try {
|
12594
|
+
syncResult = parentFunctions[args.name](...args.args);
|
12595
|
+
} catch (error) {
|
12596
|
+
syncResponse({ id: args.id, error });
|
12597
|
+
return;
|
12598
|
+
}
|
12599
|
+
if (!(typeof syncResult === "object" && syncResult !== null && "then" in syncResult && typeof syncResult.then === "function")) {
|
12600
|
+
syncResponse({
|
12601
|
+
id: args.id,
|
12602
|
+
result: syncResult
|
12603
|
+
});
|
12604
|
+
return;
|
12605
|
+
}
|
12606
|
+
syncResponse({
|
12607
|
+
id: args.id,
|
12608
|
+
isAsync: true
|
12609
|
+
});
|
12610
|
+
try {
|
12611
|
+
const result = await syncResult;
|
12612
|
+
parentFunctionAsyncMessagePort.postMessage({ id: args.id, result });
|
12613
|
+
} catch (error) {
|
12614
|
+
parentFunctionAsyncMessagePort.postMessage({ id: args.id, error });
|
12615
|
+
}
|
12616
|
+
});
|
12617
|
+
parentFunctionSyncMessagePort.unref();
|
12618
|
+
return {
|
12619
|
+
close: () => {
|
12620
|
+
parentFunctionSyncMessagePort.close();
|
12621
|
+
parentFunctionAsyncMessagePort.close();
|
12622
|
+
},
|
12623
|
+
lockState,
|
12624
|
+
workerPorts: {
|
12625
|
+
sync: parentFunctionSyncMessageChannel.port2,
|
12626
|
+
async: parentFunctionAsyncMessageChannel.port2
|
12627
|
+
}
|
12628
|
+
};
|
12629
|
+
}
|
12630
|
+
function genWorkerCode(fn, isModule, parentFunctions) {
|
12631
|
+
const createLock = (lockState) => {
|
12632
|
+
return {
|
12633
|
+
lock: () => {
|
12634
|
+
Atomics.store(lockState, 0, 1);
|
12635
|
+
},
|
12636
|
+
waitUnlock: () => {
|
12637
|
+
const status = Atomics.wait(lockState, 0, 1, 10 * 1e3);
|
12638
|
+
if (status === "timed-out") {
|
12639
|
+
throw new Error(status);
|
12640
|
+
}
|
12641
|
+
}
|
12642
|
+
};
|
12643
|
+
};
|
12644
|
+
const createParentFunctionRequester = (syncPort, asyncPort, receive, lock) => {
|
12503
12645
|
let id = 0;
|
12504
12646
|
const resolvers = /* @__PURE__ */ new Map();
|
12505
|
-
const call = (key) =>
|
12647
|
+
const call = (key) => (...args) => {
|
12506
12648
|
id++;
|
12507
|
-
|
12508
|
-
|
12509
|
-
|
12510
|
-
|
12511
|
-
|
12512
|
-
|
12513
|
-
|
12514
|
-
|
12649
|
+
lock.lock();
|
12650
|
+
syncPort.postMessage({ id, name: key, args });
|
12651
|
+
lock.waitUnlock();
|
12652
|
+
const resArgs = receive(syncPort).message;
|
12653
|
+
if (resArgs.isAsync) {
|
12654
|
+
let resolve, reject;
|
12655
|
+
const promise = new Promise((res, rej) => {
|
12656
|
+
resolve = res;
|
12657
|
+
reject = rej;
|
12658
|
+
});
|
12659
|
+
resolvers.set(id, { resolve, reject });
|
12660
|
+
return promise;
|
12661
|
+
}
|
12662
|
+
if ("error" in resArgs) {
|
12663
|
+
throw resArgs.error;
|
12664
|
+
} else {
|
12665
|
+
return resArgs.result;
|
12666
|
+
}
|
12515
12667
|
};
|
12516
|
-
|
12668
|
+
asyncPort.on("message", (args) => {
|
12669
|
+
const id2 = args.id;
|
12517
12670
|
if (resolvers.has(id2)) {
|
12518
12671
|
const { resolve, reject } = resolvers.get(id2);
|
12519
12672
|
resolvers.delete(id2);
|
@@ -12523,48 +12676,64 @@ function genWorkerCode(fn, parentFunctions) {
|
|
12523
12676
|
reject(args.error);
|
12524
12677
|
}
|
12525
12678
|
}
|
12526
|
-
};
|
12527
|
-
return { call
|
12679
|
+
});
|
12680
|
+
return { call };
|
12528
12681
|
};
|
12682
|
+
const fnString = fn.toString().replaceAll(viteSsrDynamicImport, "import");
|
12529
12683
|
return `
|
12530
|
-
const { parentPort } = require('worker_threads')
|
12531
|
-
const
|
12684
|
+
${isModule ? "import { parentPort, receiveMessageOnPort, workerData } from 'worker_threads'" : "const { parentPort, receiveMessageOnPort, workerData } = require('worker_threads')"}
|
12685
|
+
const [parentFunctionSyncMessagePort, parentFunctionAsyncMessagePort, lockState] = workerData
|
12686
|
+
const createLock = ${createLock.toString()}
|
12687
|
+
const parentFunctionRequester = (${createParentFunctionRequester.toString()})(
|
12688
|
+
parentFunctionSyncMessagePort,
|
12689
|
+
parentFunctionAsyncMessagePort,
|
12690
|
+
receiveMessageOnPort,
|
12691
|
+
createLock(lockState)
|
12692
|
+
)
|
12532
12693
|
|
12533
|
-
const
|
12694
|
+
const doWorkPromise = (async () => {
|
12534
12695
|
${Object.keys(parentFunctions).map(
|
12535
|
-
(key) => `const ${key} =
|
12696
|
+
(key) => `const ${key} = parentFunctionRequester.call(${JSON.stringify(key)});`
|
12536
12697
|
).join("\n")}
|
12537
|
-
return (${
|
12698
|
+
return await (${fnString})()
|
12538
12699
|
})()
|
12700
|
+
let doWork
|
12539
12701
|
|
12540
12702
|
parentPort.on('message', async (args) => {
|
12541
|
-
|
12542
|
-
|
12543
|
-
|
12544
|
-
|
12545
|
-
|
12546
|
-
|
12547
|
-
}
|
12548
|
-
} else if (args.type === 'parentFunction') {
|
12549
|
-
parentFunctionCaller.receive(args.id, args)
|
12703
|
+
doWork ||= await doWorkPromise
|
12704
|
+
|
12705
|
+
try {
|
12706
|
+
const res = await doWork(...args.args)
|
12707
|
+
parentPort.postMessage({ result: res })
|
12708
|
+
} catch (e) {
|
12709
|
+
parentPort.postMessage({ error: e })
|
12550
12710
|
}
|
12551
12711
|
})
|
12552
12712
|
`;
|
12553
12713
|
}
|
12714
|
+
var importRe = /\bimport\s*\(/;
|
12715
|
+
var internalImportName = "__artichokie_local_import__";
|
12554
12716
|
var FakeWorker = class {
|
12555
12717
|
/** @internal */
|
12556
12718
|
_fn;
|
12557
12719
|
constructor(fn, options = {}) {
|
12720
|
+
const declareRequire = options.type !== "module";
|
12558
12721
|
const argsAndCode = genFakeWorkerArgsAndCode(
|
12559
12722
|
fn,
|
12723
|
+
declareRequire,
|
12560
12724
|
options.parentFunctions ?? {}
|
12561
12725
|
);
|
12562
|
-
const
|
12563
|
-
|
12726
|
+
const localImport = (specifier) => import(specifier);
|
12727
|
+
const args = [
|
12728
|
+
...declareRequire ? [createRequire$1(import.meta.url)] : [],
|
12729
|
+
localImport,
|
12730
|
+
options.parentFunctions
|
12731
|
+
];
|
12732
|
+
this._fn = new AsyncFunction(...argsAndCode)(...args);
|
12564
12733
|
}
|
12565
12734
|
async run(...args) {
|
12566
12735
|
try {
|
12567
|
-
return await this._fn(...args);
|
12736
|
+
return await (await this._fn)(...args);
|
12568
12737
|
} catch (err) {
|
12569
12738
|
if (err instanceof ReferenceError) {
|
12570
12739
|
err.message += ". Maybe you forgot to pass the function to parentFunction?";
|
@@ -12575,13 +12744,15 @@ var FakeWorker = class {
|
|
12575
12744
|
stop() {
|
12576
12745
|
}
|
12577
12746
|
};
|
12578
|
-
function genFakeWorkerArgsAndCode(fn, parentFunctions) {
|
12747
|
+
function genFakeWorkerArgsAndCode(fn, declareRequire, parentFunctions) {
|
12748
|
+
const fnString = fn.toString().replace(importRe, `${internalImportName}(`).replaceAll(viteSsrDynamicImport, internalImportName);
|
12579
12749
|
return [
|
12580
|
-
"require",
|
12750
|
+
...declareRequire ? ["require"] : [],
|
12751
|
+
internalImportName,
|
12581
12752
|
"parentFunctions",
|
12582
12753
|
`
|
12583
12754
|
${Object.keys(parentFunctions).map((key) => `const ${key} = parentFunctions[${JSON.stringify(key)}];`).join("\n")}
|
12584
|
-
return (${
|
12755
|
+
return await (${fnString})()
|
12585
12756
|
`
|
12586
12757
|
];
|
12587
12758
|
}
|
@@ -12633,12 +12804,15 @@ ${e.message}`);
|
|
12633
12804
|
};
|
12634
12805
|
function terserPlugin(config) {
|
12635
12806
|
const { maxWorkers, ...terserOptions } = config.build.terserOptions;
|
12636
|
-
const makeWorker = () => new
|
12807
|
+
const makeWorker = () => new WorkerWithFallback(
|
12637
12808
|
() => async (terserPath2, code, options) => {
|
12638
12809
|
const terser = require(terserPath2);
|
12639
12810
|
return terser.minify(code, options);
|
12640
12811
|
},
|
12641
12812
|
{
|
12813
|
+
shouldUseFake(_terserPath, _code, options) {
|
12814
|
+
return !!(typeof options.mangle === "object" && (options.mangle.nth_identifier?.get || typeof options.mangle.properties === "object" && options.mangle.properties.nth_identifier?.get) || typeof options.format?.comments === "function" || typeof options.output?.comments === "function");
|
12815
|
+
},
|
12642
12816
|
max: maxWorkers
|
12643
12817
|
}
|
12644
12818
|
);
|
@@ -13354,7 +13528,7 @@ async function fileToDevUrl(environment, id, skipBase = false) {
|
|
13354
13528
|
if (skipBase) {
|
13355
13529
|
return rtn;
|
13356
13530
|
}
|
13357
|
-
const base = joinUrlSegments(config.server
|
13531
|
+
const base = joinUrlSegments(config.server.origin ?? "", config.decodedBase);
|
13358
13532
|
return joinUrlSegments(base, removeLeadingSlash(rtn));
|
13359
13533
|
}
|
13360
13534
|
function getPublicAssetFilename(hash, config) {
|
@@ -13505,7 +13679,7 @@ function manifestPlugin() {
|
|
13505
13679
|
const { root } = this.environment.config;
|
13506
13680
|
const buildOptions = this.environment.config.build;
|
13507
13681
|
function getChunkName(chunk) {
|
13508
|
-
return getChunkOriginalFileName(chunk, root, format) ?? `_
|
13682
|
+
return getChunkOriginalFileName(chunk, root, format) ?? `_${path$d.basename(chunk.fileName)}`;
|
13509
13683
|
}
|
13510
13684
|
function getInternalImports(imports) {
|
13511
13685
|
const filteredImports = [];
|
@@ -13568,19 +13742,17 @@ function manifestPlugin() {
|
|
13568
13742
|
} catch {
|
13569
13743
|
}
|
13570
13744
|
}
|
13571
|
-
const fileNameToAsset = /* @__PURE__ */ new Map();
|
13572
13745
|
for (const file in bundle) {
|
13573
13746
|
const chunk = bundle[file];
|
13574
13747
|
if (chunk.type === "chunk") {
|
13575
13748
|
manifest[getChunkName(chunk)] = createChunk(chunk);
|
13576
13749
|
} else if (chunk.type === "asset" && chunk.names.length > 0) {
|
13577
|
-
const src = chunk.originalFileNames.length > 0 ? chunk.originalFileNames[0] :
|
13750
|
+
const src = chunk.originalFileNames.length > 0 ? chunk.originalFileNames[0] : `_${path$d.basename(chunk.fileName)}`;
|
13578
13751
|
const isEntry = entryCssAssetFileNames.has(chunk.fileName);
|
13579
13752
|
const asset = createAsset(chunk, src, isEntry);
|
13580
13753
|
const file2 = manifest[src]?.file;
|
13581
13754
|
if (!(file2 && endsWithJSRE.test(file2))) {
|
13582
13755
|
manifest[src] = asset;
|
13583
|
-
fileNameToAsset.set(chunk.fileName, asset);
|
13584
13756
|
}
|
13585
13757
|
for (const originalFileName of chunk.originalFileNames.slice(1)) {
|
13586
13758
|
const file3 = manifest[originalFileName]?.file;
|
@@ -13591,7 +13763,7 @@ function manifestPlugin() {
|
|
13591
13763
|
}
|
13592
13764
|
}
|
13593
13765
|
state.outputCount++;
|
13594
|
-
const output = buildOptions.rollupOptions
|
13766
|
+
const output = buildOptions.rollupOptions.output;
|
13595
13767
|
const outputLength = Array.isArray(output) ? output.length : 1;
|
13596
13768
|
if (state.outputCount >= outputLength) {
|
13597
13769
|
this.emitFile({
|
@@ -13609,7 +13781,7 @@ function getChunkOriginalFileName(chunk, root, format) {
|
|
13609
13781
|
if (format === "system" && !chunk.name.includes("-legacy")) {
|
13610
13782
|
const ext = path$d.extname(name);
|
13611
13783
|
const endPos = ext.length !== 0 ? -ext.length : void 0;
|
13612
|
-
name = name.slice(0, endPos)
|
13784
|
+
name = `${name.slice(0, endPos)}-legacy${ext}`;
|
13613
13785
|
}
|
13614
13786
|
return name.replace(/\0/g, "");
|
13615
13787
|
}
|
@@ -14016,6 +14188,7 @@ var src$2 = {};
|
|
14016
14188
|
const path$b = require$$0$2;
|
14017
14189
|
const fs$7 = require$$0$3;
|
14018
14190
|
const os$2 = require$$2;
|
14191
|
+
const url$4 = require$$0$5;
|
14019
14192
|
|
14020
14193
|
const fsReadFileAsync = fs$7.promises.readFile;
|
14021
14194
|
|
@@ -14054,7 +14227,8 @@ function parentDir(p) {
|
|
14054
14227
|
/** @type {import('./index').LoaderSync} */
|
14055
14228
|
const jsonLoader = (_, content) => JSON.parse(content);
|
14056
14229
|
// Use plain require in webpack context for dynamic import
|
14057
|
-
const requireFunc =
|
14230
|
+
const requireFunc =
|
14231
|
+
typeof __webpack_require__ === 'function' ? __non_webpack_require__ : __require;
|
14058
14232
|
/** @type {import('./index').LoadersSync} */
|
14059
14233
|
const defaultLoadersSync = Object.freeze({
|
14060
14234
|
'.js': requireFunc,
|
@@ -14067,7 +14241,8 @@ src$2.defaultLoadersSync = defaultLoadersSync;
|
|
14067
14241
|
/** @type {import('./index').Loader} */
|
14068
14242
|
const dynamicImport = async id => {
|
14069
14243
|
try {
|
14070
|
-
const
|
14244
|
+
const fileUrl = url$4.pathToFileURL(id).href;
|
14245
|
+
const mod = await import(/* webpackIgnore: true */ fileUrl);
|
14071
14246
|
|
14072
14247
|
return mod.default;
|
14073
14248
|
} catch (e) {
|
@@ -14471,7 +14646,7 @@ src$2.lilconfigSync = function lilconfigSync(name, options) {
|
|
14471
14646
|
};
|
14472
14647
|
|
14473
14648
|
// @ts-check
|
14474
|
-
const { createRequire } = require$$0$
|
14649
|
+
const { createRequire } = require$$0$6;
|
14475
14650
|
const { fileURLToPath, pathToFileURL } = require$$1$1;
|
14476
14651
|
|
14477
14652
|
const TS_EXT_RE = /\.[mc]?ts$/;
|
@@ -15105,7 +15280,7 @@ function alias$1(options = {}) {
|
|
15105
15280
|
};
|
15106
15281
|
}
|
15107
15282
|
|
15108
|
-
function e(e,n,r){throw new Error(r?`No known conditions for "${n}" specifier in "${e}" package`:`Missing "${n}" specifier in "${e}" package`)}function n(n,i,o,f){let s,u,l=r(n,o),c=function(e){let n=new Set(["default",...e.conditions||[]]);return e.unsafe||n.add(e.require?"require":"import"),e.unsafe||n.add(e.browser?"browser":"node"),n}(f||{}),a=i[l];if(void 0===a){let e,n,r,t;for(t in i)n&&t.length<n.length||("/"===t[t.length-1]&&l.startsWith(t)?(u=l.substring(t.length),n=t):t.length>1&&(r=t.indexOf("*",1),~r&&(e=RegExp("^"+t.substring(0,r)+"(.*)"+t.substring(1+r)).exec(l),e&&e[1]&&(u=e[1],n=t))));a=i[n];}return a||e(n,l),s=t(a,c),s||e(n,l,1),u&&function(e,n){let r,t=0,i=e.length,o=/[*]/g,f=/[/]$/;for(;t<i;t++)e[t]=o.test(r=e[t])?r.replace(o,n):f.test(r)?r+n:r;}(s,u),s}function r(e,n,r){if(e===n||"."===n)return ".";let t=e+"/",i=t.length,o=n.slice(0,i)===t,f=o?n.slice(i):n;return "#"===f[0]?f:o||!r?"./"===f.slice(0,2)?f:"./"+f:f}function t(e,n,r){if(e){if("string"==typeof e)return r&&r.add(e),[e];let i,o;if(Array.isArray(e)){for(o=r||new Set,i=0;i<e.length;i++)t(e[i],n,o);if(!r&&o.size)return [...o]}else for(i in e)if(n.has(i))return t(e[i],n,r)}}function o(e,r,t){let i,o=e.exports;if(o){if("string"==typeof o)o={".":o};else for(i in o){"."!==i[0]&&(o={".":o});break}return n(e.name,o,r||".",t)}}function f(e,r,t){if(e.imports)return n(e.name,e.imports,r,t)}
|
15283
|
+
function e(e,n,r){throw new Error(r?`No known conditions for "${n}" specifier in "${e}" package`:`Missing "${n}" specifier in "${e}" package`)}function n(n,i,o,f){let s,u,l=r(n,o),c=function(e){let n=new Set(["default",...e.conditions||[]]);return e.unsafe||n.add(e.require?"require":"import"),e.unsafe||n.add(e.browser?"browser":"node"),n}(f||{}),a=i[l];if(void 0===a){let e,n,r,t;for(t in i)n&&t.length<n.length||("/"===t[t.length-1]&&l.startsWith(t)?(u=l.substring(t.length),n=t):t.length>1&&(r=t.indexOf("*",1),~r&&(e=RegExp("^"+t.substring(0,r)+"(.*)"+t.substring(1+r)+"$").exec(l),e&&e[1]&&(u=e[1],n=t))));a=i[n];}return a||e(n,l),s=t(a,c),s||e(n,l,1),u&&function(e,n){let r,t=0,i=e.length,o=/[*]/g,f=/[/]$/;for(;t<i;t++)e[t]=o.test(r=e[t])?r.replace(o,n):f.test(r)?r+n:r;}(s,u),s}function r(e,n,r){if(e===n||"."===n)return ".";let t=e+"/",i=t.length,o=n.slice(0,i)===t,f=o?n.slice(i):n;return "#"===f[0]?f:o||!r?"./"===f.slice(0,2)?f:"./"+f:f}function t(e,n,r){if(e){if("string"==typeof e)return r&&r.add(e),[e];let i,o;if(Array.isArray(e)){for(o=r||new Set,i=0;i<e.length;i++)t(e[i],n,o);if(!r&&o.size)return [...o]}else for(i in e)if(n.has(i))return t(e[i],n,r)}}function o(e,r,t){let i,o=e.exports;if(o){if("string"==typeof o)o={".":o};else for(i in o){"."!==i[0]&&(o={".":o});break}return n(e.name,o,r||".",t)}}function f(e,r,t){if(e.imports)return n(e.name,e.imports,r,t)}
|
15109
15284
|
|
15110
15285
|
const HASH_RE = /#/g;
|
15111
15286
|
const AMPERSAND_RE = /&/g;
|
@@ -15704,7 +15879,7 @@ function createIsConfiguredAsExternal(environment) {
|
|
15704
15879
|
const { root, resolve } = config;
|
15705
15880
|
const { external, noExternal } = resolve;
|
15706
15881
|
const noExternalFilter = typeof noExternal !== "boolean" && !(Array.isArray(noExternal) && noExternal.length === 0) && createFilter(void 0, noExternal, { resolve: false });
|
15707
|
-
const targetConditions = resolve.externalConditions
|
15882
|
+
const targetConditions = resolve.externalConditions;
|
15708
15883
|
const resolveOptions = {
|
15709
15884
|
...resolve,
|
15710
15885
|
root,
|
@@ -15812,14 +15987,14 @@ function resolvePlugin(resolveOptions) {
|
|
15812
15987
|
if (id.startsWith(browserExternalId)) {
|
15813
15988
|
return id;
|
15814
15989
|
}
|
15815
|
-
const isRequire = resolveOpts
|
15990
|
+
const isRequire = resolveOpts.custom?.["node-resolve"]?.isRequire ?? false;
|
15816
15991
|
const currentEnvironmentOptions = this.environment.config;
|
15817
15992
|
const options = {
|
15818
15993
|
isRequire,
|
15819
15994
|
...currentEnvironmentOptions.resolve,
|
15820
15995
|
...resolveOptions,
|
15821
15996
|
// plugin options + resolve options overrides
|
15822
|
-
scan: resolveOpts
|
15997
|
+
scan: resolveOpts.scan ?? resolveOptions.scan
|
15823
15998
|
};
|
15824
15999
|
const resolvedImports = resolveSubpathImports(id, importer, options);
|
15825
16000
|
if (resolvedImports) {
|
@@ -15832,7 +16007,7 @@ function resolvePlugin(resolveOptions) {
|
|
15832
16007
|
if (isTsRequest(importer) || resolveOpts.custom?.depScan?.loader?.startsWith("ts")) {
|
15833
16008
|
options.isFromTsImporter = true;
|
15834
16009
|
} else {
|
15835
|
-
const moduleLang = this.getModuleInfo(importer)?.meta
|
16010
|
+
const moduleLang = this.getModuleInfo(importer)?.meta.vite?.lang;
|
15836
16011
|
options.isFromTsImporter = moduleLang && isTsRequest(`.${moduleLang}`);
|
15837
16012
|
}
|
15838
16013
|
}
|
@@ -16115,7 +16290,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
16115
16290
|
const deepMatch = deepImportRE.exec(id);
|
16116
16291
|
const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : cleanUrl(id);
|
16117
16292
|
let basedir;
|
16118
|
-
if (dedupe
|
16293
|
+
if (dedupe.includes(pkgId)) {
|
16119
16294
|
basedir = root;
|
16120
16295
|
} else if (importer && path$d.isAbsolute(importer) && // css processing appends `*` for importer
|
16121
16296
|
(importer[importer.length - 1] === "*" || fs__default.existsSync(cleanUrl(importer)))) {
|
@@ -16126,7 +16301,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
16126
16301
|
let selfPkg = null;
|
16127
16302
|
if (!isBuiltin(id) && !id.includes("\0") && bareImportRE.test(id)) {
|
16128
16303
|
const selfPackageData = findNearestPackageData(basedir, packageCache);
|
16129
|
-
selfPkg = selfPackageData?.data.exports && selfPackageData
|
16304
|
+
selfPkg = selfPackageData?.data.exports && selfPackageData.data.name === pkgId ? selfPackageData : null;
|
16130
16305
|
}
|
16131
16306
|
const pkg = selfPkg || resolvePackageData(pkgId, basedir, preserveSymlinks, packageCache);
|
16132
16307
|
if (!pkg) {
|
@@ -16158,7 +16333,7 @@ function tryNodeResolve(id, importer, options, depsOptimizer, externalize) {
|
|
16158
16333
|
return resolved2;
|
16159
16334
|
}
|
16160
16335
|
let resolvedId = id;
|
16161
|
-
if (deepMatch && !pkg
|
16336
|
+
if (deepMatch && !pkg.data.exports && path$d.extname(id) !== path$d.extname(resolved2.id)) {
|
16162
16337
|
const index = resolved2.id.indexOf(id);
|
16163
16338
|
if (index > -1) {
|
16164
16339
|
resolvedId = resolved2.id.slice(index);
|
@@ -16489,7 +16664,7 @@ const externalTypes = [
|
|
16489
16664
|
function esbuildDepPlugin(environment, qualified, external) {
|
16490
16665
|
const { isProduction } = environment.config;
|
16491
16666
|
const { extensions } = environment.config.optimizeDeps;
|
16492
|
-
const allExternalTypes = extensions ? externalTypes.filter((type) => !extensions
|
16667
|
+
const allExternalTypes = extensions ? externalTypes.filter((type) => !extensions.includes("." + type)) : externalTypes;
|
16493
16668
|
const esmPackageCache = /* @__PURE__ */ new Map();
|
16494
16669
|
const cjsPackageCache = /* @__PURE__ */ new Map();
|
16495
16670
|
const _resolve = createBackCompatIdResolver(environment.getTopLevelConfig(), {
|
@@ -17849,7 +18024,7 @@ function scanImports(environment) {
|
|
17849
18024
|
});
|
17850
18025
|
});
|
17851
18026
|
}
|
17852
|
-
if (!context || scanContext
|
18027
|
+
if (!context || scanContext.cancelled) {
|
17853
18028
|
disposeContext();
|
17854
18029
|
return { deps: {}, missing: {} };
|
17855
18030
|
}
|
@@ -17899,7 +18074,7 @@ function scanImports(environment) {
|
|
17899
18074
|
async function computeEntries(environment) {
|
17900
18075
|
let entries = [];
|
17901
18076
|
const explicitEntryPatterns = environment.config.optimizeDeps.entries;
|
17902
|
-
const buildInput = environment.config.build.rollupOptions
|
18077
|
+
const buildInput = environment.config.build.rollupOptions.input;
|
17903
18078
|
if (explicitEntryPatterns) {
|
17904
18079
|
entries = await globEntries(explicitEntryPatterns, environment);
|
17905
18080
|
} else if (buildInput) {
|
@@ -17932,7 +18107,7 @@ async function computeEntries(environment) {
|
|
17932
18107
|
return entries;
|
17933
18108
|
}
|
17934
18109
|
async function prepareEsbuildScanner(environment, entries, deps, missing, scanContext) {
|
17935
|
-
if (scanContext
|
18110
|
+
if (scanContext.cancelled) return;
|
17936
18111
|
const plugin = esbuildScanPlugin(environment, deps, missing, entries);
|
17937
18112
|
const { plugins = [], ...esbuildOptions } = environment.config.optimizeDeps.esbuildOptions ?? {};
|
17938
18113
|
let tsconfigRaw = esbuildOptions.tsconfigRaw;
|
@@ -18473,7 +18648,7 @@ function addOptimizedDepInfo(metadata, type, depInfo) {
|
|
18473
18648
|
return depInfo;
|
18474
18649
|
}
|
18475
18650
|
let firstLoadCachedDepOptimizationMetadata = true;
|
18476
|
-
async function loadCachedDepOptimizationMetadata(environment, force = environment.config.optimizeDeps
|
18651
|
+
async function loadCachedDepOptimizationMetadata(environment, force = environment.config.optimizeDeps.force ?? false, asCommand = false) {
|
18477
18652
|
const log = asCommand ? environment.logger.info : debug$c;
|
18478
18653
|
if (firstLoadCachedDepOptimizationMetadata) {
|
18479
18654
|
firstLoadCachedDepOptimizationMetadata = false;
|
@@ -18759,7 +18934,7 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
18759
18934
|
const flatIdDeps = {};
|
18760
18935
|
const idToExports = {};
|
18761
18936
|
const { optimizeDeps: optimizeDeps2 } = environment.config;
|
18762
|
-
const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps2
|
18937
|
+
const { plugins: pluginsFromConfig = [], ...esbuildOptions } = optimizeDeps2.esbuildOptions ?? {};
|
18763
18938
|
await Promise.all(
|
18764
18939
|
Object.keys(depsInfo).map(async (id) => {
|
18765
18940
|
const src = depsInfo[id].src;
|
@@ -18777,15 +18952,17 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
18777
18952
|
);
|
18778
18953
|
if (optimizerContext.cancelled) return { context: void 0, idToExports };
|
18779
18954
|
const define = {
|
18780
|
-
"process.env.NODE_ENV":
|
18781
|
-
process.env.NODE_ENV
|
18782
|
-
|
18955
|
+
"process.env.NODE_ENV": environment.config.keepProcessEnv ? (
|
18956
|
+
// define process.env.NODE_ENV even for keepProcessEnv === true
|
18957
|
+
// as esbuild will replace it automatically when `platform` is `'browser'`
|
18958
|
+
"process.env.NODE_ENV"
|
18959
|
+
) : JSON.stringify(process.env.NODE_ENV || environment.config.mode)
|
18783
18960
|
};
|
18784
18961
|
const platform = optimizeDeps2.esbuildOptions?.platform ?? // We generally don't want to use platform 'neutral', as esbuild has custom handling
|
18785
18962
|
// when the platform is 'node' or 'browser' that can't be emulated by using mainFields
|
18786
18963
|
// and conditions
|
18787
18964
|
(environment.config.consumer === "client" || environment.config.ssr.target === "webworker" ? "browser" : "node");
|
18788
|
-
const external = [...optimizeDeps2
|
18965
|
+
const external = [...optimizeDeps2.exclude ?? []];
|
18789
18966
|
const plugins = [...pluginsFromConfig];
|
18790
18967
|
if (external.length) {
|
18791
18968
|
plugins.push(esbuildCjsExternalPlugin(external, platform));
|
@@ -18823,7 +19000,7 @@ async function prepareEsbuildOptimizerRun(environment, depsInfo, processingCache
|
|
18823
19000
|
async function addManuallyIncludedOptimizeDeps(environment, deps) {
|
18824
19001
|
const { logger } = environment;
|
18825
19002
|
const { optimizeDeps: optimizeDeps2 } = environment.config;
|
18826
|
-
const optimizeDepsInclude = optimizeDeps2
|
19003
|
+
const optimizeDepsInclude = optimizeDeps2.include ?? [];
|
18827
19004
|
if (optimizeDepsInclude.length) {
|
18828
19005
|
const unableToOptimize = (id, msg) => {
|
18829
19006
|
if (optimizeDepsInclude.includes(id)) {
|
@@ -18999,7 +19176,7 @@ function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
|
|
18999
19176
|
async function extractExportsData(environment, filePath) {
|
19000
19177
|
await init;
|
19001
19178
|
const { optimizeDeps: optimizeDeps2 } = environment.config;
|
19002
|
-
const esbuildOptions = optimizeDeps2
|
19179
|
+
const esbuildOptions = optimizeDeps2.esbuildOptions ?? {};
|
19003
19180
|
if (optimizeDeps2.extensions?.some((ext) => filePath.endsWith(ext))) {
|
19004
19181
|
const result = await build$b({
|
19005
19182
|
...esbuildOptions,
|
@@ -19043,7 +19220,7 @@ async function extractExportsData(environment, filePath) {
|
|
19043
19220
|
return exportsData;
|
19044
19221
|
}
|
19045
19222
|
function needsInterop(environment, id, exportsData, output) {
|
19046
|
-
if (environment.config.optimizeDeps
|
19223
|
+
if (environment.config.optimizeDeps.needsInterop?.includes(id)) {
|
19047
19224
|
return true;
|
19048
19225
|
}
|
19049
19226
|
const { hasModuleSyntax, exports } = exportsData;
|
@@ -19052,7 +19229,7 @@ function needsInterop(environment, id, exportsData, output) {
|
|
19052
19229
|
}
|
19053
19230
|
if (output) {
|
19054
19231
|
const generatedExports = output.exports;
|
19055
|
-
if (
|
19232
|
+
if (isSingleDefaultExport(generatedExports) && !isSingleDefaultExport(exports)) {
|
19056
19233
|
return true;
|
19057
19234
|
}
|
19058
19235
|
}
|
@@ -19101,17 +19278,17 @@ function getConfigHash(environment) {
|
|
19101
19278
|
const { optimizeDeps: optimizeDeps2 } = config;
|
19102
19279
|
const content = JSON.stringify(
|
19103
19280
|
{
|
19104
|
-
|
19281
|
+
define: !config.keepProcessEnv ? process.env.NODE_ENV || config.mode : null,
|
19105
19282
|
root: config.root,
|
19106
19283
|
resolve: config.resolve,
|
19107
19284
|
assetsInclude: config.assetsInclude,
|
19108
19285
|
plugins: config.plugins.map((p) => p.name),
|
19109
19286
|
optimizeDeps: {
|
19110
|
-
include: optimizeDeps2
|
19111
|
-
exclude: optimizeDeps2
|
19287
|
+
include: optimizeDeps2.include ? unique(optimizeDeps2.include).sort() : void 0,
|
19288
|
+
exclude: optimizeDeps2.exclude ? unique(optimizeDeps2.exclude).sort() : void 0,
|
19112
19289
|
esbuildOptions: {
|
19113
|
-
...optimizeDeps2
|
19114
|
-
plugins: optimizeDeps2
|
19290
|
+
...optimizeDeps2.esbuildOptions,
|
19291
|
+
plugins: optimizeDeps2.esbuildOptions?.plugins?.map((p) => p.name)
|
19115
19292
|
}
|
19116
19293
|
}
|
19117
19294
|
},
|
@@ -19218,7 +19395,7 @@ const safeRename = promisify$4(function gracefulRename(from, to, cb) {
|
|
19218
19395
|
if (backoff < 100) backoff += 10;
|
19219
19396
|
return;
|
19220
19397
|
}
|
19221
|
-
|
19398
|
+
cb(er);
|
19222
19399
|
});
|
19223
19400
|
});
|
19224
19401
|
|
@@ -19285,9 +19462,9 @@ function jsonPlugin(options, isBuild) {
|
|
19285
19462
|
map: { mappings: "" }
|
19286
19463
|
};
|
19287
19464
|
}
|
19288
|
-
if (options.stringify === true || // use 10kB as a threshold
|
19465
|
+
if (options.stringify === true || // use 10kB as a threshold for 'auto'
|
19289
19466
|
// https://v8.dev/blog/cost-of-javascript-2019#:~:text=A%20good%20rule%20of%20thumb%20is%20to%20apply%20this%20technique%20for%20objects%20of%2010%20kB%20or%20larger
|
19290
|
-
|
19467
|
+
json.length > 10 * 1e3) {
|
19291
19468
|
if (isBuild) {
|
19292
19469
|
json = JSON.stringify(JSON.parse(json));
|
19293
19470
|
}
|
@@ -19405,7 +19582,7 @@ function throwFileNotFoundInOptimizedDep(id) {
|
|
19405
19582
|
var main$1 = {exports: {}};
|
19406
19583
|
|
19407
19584
|
var name = "dotenv";
|
19408
|
-
var version$1 = "16.4.
|
19585
|
+
var version$1 = "16.4.7";
|
19409
19586
|
var description = "Loads environment variables from .env file";
|
19410
19587
|
var main = "lib/main.js";
|
19411
19588
|
var types = "lib/main.d.ts";
|
@@ -19426,10 +19603,9 @@ var exports = {
|
|
19426
19603
|
var scripts = {
|
19427
19604
|
"dts-check": "tsc --project tests/types/tsconfig.json",
|
19428
19605
|
lint: "standard",
|
19429
|
-
"lint-readme": "standard-markdown",
|
19430
19606
|
pretest: "npm run lint && npm run dts-check",
|
19431
|
-
test: "tap
|
19432
|
-
"test:coverage": "tap --coverage-report=lcov",
|
19607
|
+
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
19608
|
+
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",
|
19433
19609
|
prerelease: "npm test",
|
19434
19610
|
release: "standard-version"
|
19435
19611
|
};
|
@@ -19450,15 +19626,12 @@ var keywords = [
|
|
19450
19626
|
var readmeFilename = "README.md";
|
19451
19627
|
var license = "BSD-2-Clause";
|
19452
19628
|
var devDependencies = {
|
19453
|
-
"@definitelytyped/dtslint": "^0.0.133",
|
19454
19629
|
"@types/node": "^18.11.3",
|
19455
|
-
decache: "^4.6.
|
19630
|
+
decache: "^4.6.2",
|
19456
19631
|
sinon: "^14.0.1",
|
19457
19632
|
standard: "^17.0.0",
|
19458
|
-
"standard-markdown": "^7.1.0",
|
19459
19633
|
"standard-version": "^9.5.0",
|
19460
|
-
tap: "^
|
19461
|
-
tar: "^6.1.11",
|
19634
|
+
tap: "^19.2.0",
|
19462
19635
|
typescript: "^4.8.4"
|
19463
19636
|
};
|
19464
19637
|
var engines = {
|
@@ -21427,7 +21600,7 @@ var parseurl$1 = {exports: {}};
|
|
21427
21600
|
* @private
|
21428
21601
|
*/
|
21429
21602
|
|
21430
|
-
var url$3 = require$$0$
|
21603
|
+
var url$3 = require$$0$5;
|
21431
21604
|
var parse$c = url$3.parse;
|
21432
21605
|
var Url = url$3.Url;
|
21433
21606
|
|
@@ -30281,7 +30454,7 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
|
|
30281
30454
|
|
30282
30455
|
var launchEditor_1 = launchEditor;
|
30283
30456
|
|
30284
|
-
const url$2 = require$$0$
|
30457
|
+
const url$2 = require$$0$5;
|
30285
30458
|
const path$3 = require$$0$2;
|
30286
30459
|
const launch = launchEditor_1;
|
30287
30460
|
|
@@ -30425,7 +30598,7 @@ function ssrRewriteStacktrace(stack, moduleGraph) {
|
|
30425
30598
|
// stacktrace's column is 1-indexed, but sourcemap's one is 0-indexed
|
30426
30599
|
column: Number(column) - 1
|
30427
30600
|
});
|
30428
|
-
if (!pos.source
|
30601
|
+
if (!pos.source) {
|
30429
30602
|
return input;
|
30430
30603
|
}
|
30431
30604
|
const trimmedVarName = varName.trim();
|
@@ -31201,7 +31374,7 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport, onStatements
|
|
31201
31374
|
scopeIds.add(name);
|
31202
31375
|
};
|
31203
31376
|
function isInScope(name, parents) {
|
31204
|
-
return parents.some((node) =>
|
31377
|
+
return parents.some((node) => scopeMap.get(node)?.has(name));
|
31205
31378
|
}
|
31206
31379
|
function handlePattern(p, parentScope) {
|
31207
31380
|
if (p.type === "Identifier") {
|
@@ -31270,12 +31443,12 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport, onStatements
|
|
31270
31443
|
}
|
31271
31444
|
walk$1(p.type === "AssignmentPattern" ? p.left : p, {
|
31272
31445
|
enter(child, parent2) {
|
31273
|
-
if (parent2?.type === "AssignmentPattern" && parent2
|
31446
|
+
if (parent2?.type === "AssignmentPattern" && parent2.right === child) {
|
31274
31447
|
return this.skip();
|
31275
31448
|
}
|
31276
31449
|
if (child.type !== "Identifier") return;
|
31277
31450
|
if (isStaticPropertyKey(child, parent2)) return;
|
31278
|
-
if (parent2?.type === "TemplateLiteral" && parent2
|
31451
|
+
if (parent2?.type === "TemplateLiteral" && parent2.expressions.includes(child) || parent2?.type === "CallExpression" && parent2.callee === child) {
|
31279
31452
|
return;
|
31280
31453
|
}
|
31281
31454
|
setScope(node, child.name);
|
@@ -31351,8 +31524,8 @@ function isRefIdentifier(id, parent, parentStack) {
|
|
31351
31524
|
}
|
31352
31525
|
return true;
|
31353
31526
|
}
|
31354
|
-
const isStaticProperty = (node) => node
|
31355
|
-
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
31527
|
+
const isStaticProperty = (node) => node.type === "Property" && !node.computed;
|
31528
|
+
const isStaticPropertyKey = (node, parent) => parent && isStaticProperty(parent) && parent.key === node;
|
31356
31529
|
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
|
31357
31530
|
function isFunction$1(node) {
|
31358
31531
|
return functionNodeTypeRE.test(node.type);
|
@@ -31365,7 +31538,7 @@ function findParentScope(parentStack, isVar = false) {
|
|
31365
31538
|
return parentStack.find(isVar ? isFunction$1 : isBlock);
|
31366
31539
|
}
|
31367
31540
|
function isInDestructuringAssignment(parent, parentStack) {
|
31368
|
-
if (parent
|
31541
|
+
if (parent.type === "Property" || parent.type === "ArrayPattern") {
|
31369
31542
|
return parentStack.some((i) => i.type === "AssignmentExpression");
|
31370
31543
|
}
|
31371
31544
|
return false;
|
@@ -35481,7 +35654,7 @@ const http$3 = require$$1$2;
|
|
35481
35654
|
const net = require$$4$1;
|
35482
35655
|
const tls = require$$4$2;
|
35483
35656
|
const { randomBytes, createHash: createHash$1 } = require$$3;
|
35484
|
-
const { URL: URL$2 } = require$$0$
|
35657
|
+
const { URL: URL$2 } = require$$0$5;
|
35485
35658
|
|
35486
35659
|
const PerMessageDeflate$1 = permessageDeflate;
|
35487
35660
|
const Receiver = receiver;
|
@@ -37488,7 +37661,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
37488
37661
|
off: noop$3,
|
37489
37662
|
setInvokeHandler: noop$3,
|
37490
37663
|
handleInvoke: async () => ({
|
37491
|
-
|
37664
|
+
error: {
|
37492
37665
|
name: "TransportError",
|
37493
37666
|
message: "handleInvoke not implemented",
|
37494
37667
|
stack: new Error().stack
|
@@ -38147,7 +38320,7 @@ var requiresPort = function required(port, protocol) {
|
|
38147
38320
|
|
38148
38321
|
(function (exports) {
|
38149
38322
|
var common = exports,
|
38150
|
-
url = require$$0$
|
38323
|
+
url = require$$0$5,
|
38151
38324
|
required = requiresPort;
|
38152
38325
|
|
38153
38326
|
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
|
@@ -38394,7 +38567,7 @@ var requiresPort = function required(port, protocol) {
|
|
38394
38567
|
return !!~host.indexOf(':');
|
38395
38568
|
}} (common$3));
|
38396
38569
|
|
38397
|
-
var url$1 = require$$0$
|
38570
|
+
var url$1 = require$$0$5,
|
38398
38571
|
common$2 = common$3;
|
38399
38572
|
|
38400
38573
|
|
@@ -38560,7 +38733,7 @@ var debug_1 = function () {
|
|
38560
38733
|
debug$7.apply(null, arguments);
|
38561
38734
|
};
|
38562
38735
|
|
38563
|
-
var url = require$$0$
|
38736
|
+
var url = require$$0$5;
|
38564
38737
|
var URL$1 = url.URL;
|
38565
38738
|
var http$1 = require$$1$2;
|
38566
38739
|
var https$1 = require$$1$3;
|
@@ -39609,7 +39782,7 @@ var wsIncoming = {
|
|
39609
39782
|
|
39610
39783
|
(function (module) {
|
39611
39784
|
var httpProxy = module.exports,
|
39612
|
-
parse_url = require$$0$
|
39785
|
+
parse_url = require$$0$5.parse,
|
39613
39786
|
EE3 = eventemitter3Exports,
|
39614
39787
|
http = require$$1$2,
|
39615
39788
|
https = require$$1$3,
|
@@ -40685,7 +40858,7 @@ const debugLoad = createDebugger("vite:load");
|
|
40685
40858
|
const debugTransform = createDebugger("vite:transform");
|
40686
40859
|
const debugCache$1 = createDebugger("vite:cache");
|
40687
40860
|
function transformRequest(environment, url, options = {}) {
|
40688
|
-
if (!options
|
40861
|
+
if (!options.ssr) {
|
40689
40862
|
options = { ...options, ssr: environment.config.consumer === "server" };
|
40690
40863
|
}
|
40691
40864
|
if (environment._closing && environment.config.dev.recoverable)
|
@@ -40761,12 +40934,16 @@ async function doTransform(environment, url, options, timestamp) {
|
|
40761
40934
|
}
|
40762
40935
|
async function getCachedTransformResult(environment, url, module, timestamp) {
|
40763
40936
|
const prettyUrl = debugCache$1 ? prettifyUrl(url, environment.config.root) : "";
|
40764
|
-
const softInvalidatedTransformResult =
|
40937
|
+
const softInvalidatedTransformResult = await handleModuleSoftInvalidation(
|
40938
|
+
environment,
|
40939
|
+
module,
|
40940
|
+
timestamp
|
40941
|
+
);
|
40765
40942
|
if (softInvalidatedTransformResult) {
|
40766
40943
|
debugCache$1?.(`[memory-hmr] ${prettyUrl}`);
|
40767
40944
|
return softInvalidatedTransformResult;
|
40768
40945
|
}
|
40769
|
-
const cached = module
|
40946
|
+
const cached = module.transformResult;
|
40770
40947
|
if (cached) {
|
40771
40948
|
debugCache$1?.(`[memory] ${prettyUrl}`);
|
40772
40949
|
return cached;
|
@@ -40849,7 +41026,7 @@ ${e}`, {
|
|
40849
41026
|
inMap: map
|
40850
41027
|
});
|
40851
41028
|
const originalCode = code;
|
40852
|
-
if (transformResult
|
41029
|
+
if (transformResult.code === originalCode) {
|
40853
41030
|
debugTransform?.(
|
40854
41031
|
timeFrom(transformStart) + colors$1.dim(` [skipped] ${prettyUrl}`)
|
40855
41032
|
);
|
@@ -40898,7 +41075,7 @@ ${e}`, {
|
|
40898
41075
|
const topLevelConfig = environment.getTopLevelConfig();
|
40899
41076
|
const result = environment.config.dev.moduleRunnerTransform ? await ssrTransform(code, normalizedMap, url, originalCode, {
|
40900
41077
|
json: {
|
40901
|
-
stringify: topLevelConfig.json
|
41078
|
+
stringify: topLevelConfig.json.stringify === true && topLevelConfig.json.namedExports !== true
|
40902
41079
|
}
|
40903
41080
|
}) : {
|
40904
41081
|
code,
|
@@ -41296,6 +41473,8 @@ function handleParseError(parserError, html, filePath) {
|
|
41296
41473
|
return;
|
41297
41474
|
case "non-void-html-element-start-tag-with-trailing-solidus":
|
41298
41475
|
return;
|
41476
|
+
case "unexpected-question-mark-instead-of-tag-name":
|
41477
|
+
return;
|
41299
41478
|
}
|
41300
41479
|
const parseError = formatParseError(parserError, filePath, html);
|
41301
41480
|
throw new Error(
|
@@ -41359,9 +41538,7 @@ function buildHtmlPlugin(config) {
|
|
41359
41538
|
let someScriptsAreAsync = false;
|
41360
41539
|
let someScriptsAreDefer = false;
|
41361
41540
|
const assetUrlsPromises = [];
|
41362
|
-
const namedOutput = Object.keys(
|
41363
|
-
config?.build?.rollupOptions?.input || {}
|
41364
|
-
);
|
41541
|
+
const namedOutput = Object.keys(config.build.rollupOptions.input || {});
|
41365
41542
|
const processAssetUrl = async (url, shouldInline) => {
|
41366
41543
|
if (url !== "" && // Empty attribute
|
41367
41544
|
!namedOutput.includes(url) && // Direct reference to named output
|
@@ -42193,7 +42370,7 @@ function cachedTransformMiddleware(server) {
|
|
42193
42370
|
const ifNoneMatch = req.headers["if-none-match"];
|
42194
42371
|
if (ifNoneMatch) {
|
42195
42372
|
const moduleByEtag = environment.moduleGraph.getModuleByEtag(ifNoneMatch);
|
42196
|
-
if (moduleByEtag?.transformResult?.etag === ifNoneMatch && moduleByEtag
|
42373
|
+
if (moduleByEtag?.transformResult?.etag === ifNoneMatch && moduleByEtag.url === req.url) {
|
42197
42374
|
const maybeMixedEtag = isCSSRequest(req.url);
|
42198
42375
|
if (!maybeMixedEtag) {
|
42199
42376
|
debugCache?.(`[304] ${prettifyUrl(req.url, server.config.root)}`);
|
@@ -42608,19 +42785,13 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
42608
42785
|
environment: server.environments.client
|
42609
42786
|
});
|
42610
42787
|
let content = "";
|
42611
|
-
if (result) {
|
42612
|
-
if (result.map
|
42613
|
-
|
42614
|
-
await injectSourcesContent(
|
42615
|
-
result.map,
|
42616
|
-
proxyModulePath,
|
42617
|
-
config.logger
|
42618
|
-
);
|
42619
|
-
}
|
42620
|
-
content = getCodeWithSourcemap("css", result.code, result.map);
|
42621
|
-
} else {
|
42622
|
-
content = result.code;
|
42788
|
+
if (result.map && "version" in result.map) {
|
42789
|
+
if (result.map.mappings) {
|
42790
|
+
await injectSourcesContent(result.map, proxyModulePath, config.logger);
|
42623
42791
|
}
|
42792
|
+
content = getCodeWithSourcemap("css", result.code, result.map);
|
42793
|
+
} else {
|
42794
|
+
content = result.code;
|
42624
42795
|
}
|
42625
42796
|
s.overwrite(start, end, content);
|
42626
42797
|
}),
|
@@ -42703,6 +42874,7 @@ function timeMiddleware(root) {
|
|
42703
42874
|
};
|
42704
42875
|
}
|
42705
42876
|
|
42877
|
+
const EMPTY_OBJECT$1 = Object.freeze({});
|
42706
42878
|
class ModuleNode {
|
42707
42879
|
_moduleGraph;
|
42708
42880
|
_clientModule;
|
@@ -42751,6 +42923,41 @@ class ModuleNode {
|
|
42751
42923
|
}
|
42752
42924
|
return importedModules;
|
42753
42925
|
}
|
42926
|
+
_getModuleInfoUnion(prop) {
|
42927
|
+
const _clientValue = this._clientModule?.[prop];
|
42928
|
+
const _ssrValue = this._ssrModule?.[prop];
|
42929
|
+
if (_clientValue == null && _ssrValue == null) return void 0;
|
42930
|
+
return new Proxy({}, {
|
42931
|
+
get: (_, key) => {
|
42932
|
+
if (key === "meta") {
|
42933
|
+
return this.meta || EMPTY_OBJECT$1;
|
42934
|
+
}
|
42935
|
+
if (_clientValue) {
|
42936
|
+
if (key in _clientValue) {
|
42937
|
+
return _clientValue[key];
|
42938
|
+
}
|
42939
|
+
}
|
42940
|
+
if (_ssrValue) {
|
42941
|
+
if (key in _ssrValue) {
|
42942
|
+
return _ssrValue[key];
|
42943
|
+
}
|
42944
|
+
}
|
42945
|
+
}
|
42946
|
+
});
|
42947
|
+
}
|
42948
|
+
_getModuleObjectUnion(prop) {
|
42949
|
+
const _clientValue = this._clientModule?.[prop];
|
42950
|
+
const _ssrValue = this._ssrModule?.[prop];
|
42951
|
+
if (_clientValue == null && _ssrValue == null) return void 0;
|
42952
|
+
const info = {};
|
42953
|
+
if (_ssrValue) {
|
42954
|
+
Object.assign(info, _ssrValue);
|
42955
|
+
}
|
42956
|
+
if (_clientValue) {
|
42957
|
+
Object.assign(info, _clientValue);
|
42958
|
+
}
|
42959
|
+
return info;
|
42960
|
+
}
|
42754
42961
|
get url() {
|
42755
42962
|
return this._get("url");
|
42756
42963
|
}
|
@@ -42772,11 +42979,13 @@ class ModuleNode {
|
|
42772
42979
|
get type() {
|
42773
42980
|
return this._get("type");
|
42774
42981
|
}
|
42982
|
+
// `info` needs special care as it's defined as a proxy in `pluginContainer`,
|
42983
|
+
// so we also merge it as a proxy too
|
42775
42984
|
get info() {
|
42776
|
-
return this.
|
42985
|
+
return this._getModuleInfoUnion("info");
|
42777
42986
|
}
|
42778
42987
|
get meta() {
|
42779
|
-
return this.
|
42988
|
+
return this._getModuleObjectUnion("meta");
|
42780
42989
|
}
|
42781
42990
|
get importers() {
|
42782
42991
|
return this._getModuleSetUnion("importers");
|
@@ -43228,7 +43437,7 @@ function createBackwardCompatibleFileToModulesMap(moduleGraph) {
|
|
43228
43437
|
}
|
43229
43438
|
}
|
43230
43439
|
if (!found) {
|
43231
|
-
modules
|
43440
|
+
modules.add(ssrModule);
|
43232
43441
|
}
|
43233
43442
|
}
|
43234
43443
|
}
|
@@ -43325,7 +43534,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
43325
43534
|
const resolvedOutDirs = getResolvedOutDirs(
|
43326
43535
|
config.root,
|
43327
43536
|
config.build.outDir,
|
43328
|
-
config.build.rollupOptions
|
43537
|
+
config.build.rollupOptions.output
|
43329
43538
|
);
|
43330
43539
|
const emptyOutDir = resolveEmptyOutDir(
|
43331
43540
|
config.build.emptyOutDir,
|
@@ -43406,7 +43615,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
43406
43615
|
ssrTransform(code, inMap, url, originalCode = code) {
|
43407
43616
|
return ssrTransform(code, inMap, url, originalCode, {
|
43408
43617
|
json: {
|
43409
|
-
stringify: config.json
|
43618
|
+
stringify: config.json.stringify === true && config.json.namedExports !== true
|
43410
43619
|
}
|
43411
43620
|
});
|
43412
43621
|
},
|
@@ -43522,6 +43731,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
43522
43731
|
server._ssrCompatModuleRunner?.close()
|
43523
43732
|
]);
|
43524
43733
|
server.resolvedUrls = null;
|
43734
|
+
server._ssrCompatModuleRunner = void 0;
|
43525
43735
|
},
|
43526
43736
|
printUrls() {
|
43527
43737
|
if (server.resolvedUrls) {
|
@@ -43933,7 +44143,7 @@ const normalizeHotChannel = (channel, enableHmr, normalizeClient = true) => {
|
|
43933
44143
|
const handleInvoke = async (payload) => {
|
43934
44144
|
if (!invokeHandlers) {
|
43935
44145
|
return {
|
43936
|
-
|
44146
|
+
error: {
|
43937
44147
|
name: "TransportError",
|
43938
44148
|
message: "invokeHandlers is not set",
|
43939
44149
|
stack: new Error().stack
|
@@ -43945,10 +44155,10 @@ const normalizeHotChannel = (channel, enableHmr, normalizeClient = true) => {
|
|
43945
44155
|
try {
|
43946
44156
|
const invokeHandler = invokeHandlers[name];
|
43947
44157
|
const result = await invokeHandler(...args);
|
43948
|
-
return {
|
44158
|
+
return { result };
|
43949
44159
|
} catch (error2) {
|
43950
44160
|
return {
|
43951
|
-
|
44161
|
+
error: {
|
43952
44162
|
name: error2.name,
|
43953
44163
|
message: error2.message,
|
43954
44164
|
stack: error2.stack,
|
@@ -44498,7 +44708,7 @@ function lexAcceptedHmrDeps(code, start, urls) {
|
|
44498
44708
|
} else {
|
44499
44709
|
return true;
|
44500
44710
|
}
|
44501
|
-
} else
|
44711
|
+
} else {
|
44502
44712
|
if (char === `]`) {
|
44503
44713
|
return false;
|
44504
44714
|
} else if (char === ",") {
|
@@ -44624,7 +44834,7 @@ function createDeprecatedHotBroadcaster(ws) {
|
|
44624
44834
|
send: ws.send,
|
44625
44835
|
setInvokeHandler: ws.setInvokeHandler,
|
44626
44836
|
handleInvoke: async () => ({
|
44627
|
-
|
44837
|
+
error: {
|
44628
44838
|
name: "TransportError",
|
44629
44839
|
message: "handleInvoke not implemented",
|
44630
44840
|
stack: new Error().stack
|
@@ -44637,9 +44847,7 @@ function createDeprecatedHotBroadcaster(ws) {
|
|
44637
44847
|
return broadcaster;
|
44638
44848
|
},
|
44639
44849
|
close() {
|
44640
|
-
return Promise.all(
|
44641
|
-
broadcaster.channels.map((channel) => channel.close?.())
|
44642
|
-
);
|
44850
|
+
return Promise.all(broadcaster.channels.map((channel) => channel.close()));
|
44643
44851
|
}
|
44644
44852
|
};
|
44645
44853
|
return broadcaster;
|
@@ -45189,7 +45397,7 @@ function preAliasPlugin(config) {
|
|
45189
45397
|
const { environment } = this;
|
45190
45398
|
const ssr = environment.config.consumer === "server";
|
45191
45399
|
const depsOptimizer = environment.mode === "dev" ? environment.depsOptimizer : void 0;
|
45192
|
-
if (importer && depsOptimizer && bareImportRE.test(id) && !options
|
45400
|
+
if (importer && depsOptimizer && bareImportRE.test(id) && !options.scan && id !== "@vite/client" && id !== "@vite/env") {
|
45193
45401
|
if (findPatterns.find((pattern) => matches(pattern, id))) {
|
45194
45402
|
const optimizedId = await tryOptimizedResolve(
|
45195
45403
|
depsOptimizer,
|
@@ -45242,9 +45450,6 @@ function matches(pattern, importee) {
|
|
45242
45450
|
return importee.startsWith(withTrailingSlash(pattern));
|
45243
45451
|
}
|
45244
45452
|
function getAliasPatterns(entries) {
|
45245
|
-
if (!entries) {
|
45246
|
-
return [];
|
45247
|
-
}
|
45248
45453
|
if (Array.isArray(entries)) {
|
45249
45454
|
return entries.map((entry) => entry.find);
|
45250
45455
|
}
|
@@ -45312,9 +45517,6 @@ function extractImportedBindings(id, source, importSpec, importedBindings) {
|
|
45312
45517
|
specifier: match.groups.specifier
|
45313
45518
|
};
|
45314
45519
|
const parsed = parseStaticImport(staticImport);
|
45315
|
-
if (!parsed) {
|
45316
|
-
return;
|
45317
|
-
}
|
45318
45520
|
if (parsed.namespacedImport) {
|
45319
45521
|
bindings.add("*");
|
45320
45522
|
}
|
@@ -45330,7 +45532,7 @@ function extractImportedBindings(id, source, importSpec, importedBindings) {
|
|
45330
45532
|
function importAnalysisPlugin(config) {
|
45331
45533
|
const { root, base } = config;
|
45332
45534
|
const clientPublicPath = path$d.posix.join(base, CLIENT_PUBLIC_PATH);
|
45333
|
-
const enablePartialAccept = config.experimental
|
45535
|
+
const enablePartialAccept = config.experimental.hmrPartialAccept;
|
45334
45536
|
const matchAlias = getAliasPatternMatcher(config.resolve.alias);
|
45335
45537
|
let _env;
|
45336
45538
|
let _ssrEnv;
|
@@ -46869,9 +47071,8 @@ class EnvironmentPluginContainer {
|
|
46869
47071
|
async hookParallel(hookName, context, args, condition) {
|
46870
47072
|
const parallelPromises = [];
|
46871
47073
|
for (const plugin of this.getSortedPlugins(hookName)) {
|
46872
|
-
const hook = plugin[hookName];
|
46873
|
-
if (!hook) continue;
|
46874
47074
|
if (condition && !condition(plugin)) continue;
|
47075
|
+
const hook = plugin[hookName];
|
46875
47076
|
const handler = getHookHandler(hook);
|
46876
47077
|
if (hook.sequential) {
|
46877
47078
|
await Promise.all(parallelPromises);
|
@@ -46912,17 +47113,23 @@ class EnvironmentPluginContainer {
|
|
46912
47113
|
await this._buildStartPromise;
|
46913
47114
|
}
|
46914
47115
|
const skip = options?.skip;
|
47116
|
+
const skipCalls = options?.skipCalls;
|
46915
47117
|
const scan = !!options?.scan;
|
46916
47118
|
const ssr = this.environment.config.consumer === "server";
|
46917
|
-
const ctx = new ResolveIdContext(this, skip, scan);
|
47119
|
+
const ctx = new ResolveIdContext(this, skip, skipCalls, scan);
|
47120
|
+
const mergedSkip = new Set(skip);
|
47121
|
+
for (const call of skipCalls ?? []) {
|
47122
|
+
if (call.id === rawId && call.importer === importer) {
|
47123
|
+
mergedSkip.add(call.plugin);
|
47124
|
+
}
|
47125
|
+
}
|
46918
47126
|
const resolveStart = debugResolve ? performance.now() : 0;
|
46919
47127
|
let id = null;
|
46920
47128
|
const partial = {};
|
46921
47129
|
for (const plugin of this.getSortedPlugins("resolveId")) {
|
46922
47130
|
if (this._closed && this.environment.config.dev.recoverable)
|
46923
47131
|
throwClosedServerError();
|
46924
|
-
if (
|
46925
|
-
if (skip?.has(plugin)) continue;
|
47132
|
+
if (mergedSkip?.has(plugin)) continue;
|
46926
47133
|
ctx._plugin = plugin;
|
46927
47134
|
const pluginResolveStart = debugPluginResolve ? performance.now() : 0;
|
46928
47135
|
const handler = getHookHandler(plugin.resolveId);
|
@@ -46974,7 +47181,6 @@ class EnvironmentPluginContainer {
|
|
46974
47181
|
for (const plugin of this.getSortedPlugins("load")) {
|
46975
47182
|
if (this._closed && this.environment.config.dev.recoverable)
|
46976
47183
|
throwClosedServerError();
|
46977
|
-
if (!plugin.load) continue;
|
46978
47184
|
ctx._plugin = plugin;
|
46979
47185
|
const handler = getHookHandler(plugin.load);
|
46980
47186
|
const result = await this.handleHookPromise(
|
@@ -47000,7 +47206,6 @@ class EnvironmentPluginContainer {
|
|
47000
47206
|
for (const plugin of this.getSortedPlugins("transform")) {
|
47001
47207
|
if (this._closed && this.environment.config.dev.recoverable)
|
47002
47208
|
throwClosedServerError();
|
47003
|
-
if (!plugin.transform) continue;
|
47004
47209
|
ctx._updateActiveInfo(plugin, id, code);
|
47005
47210
|
const start = debugPluginTransform ? performance.now() : 0;
|
47006
47211
|
let result;
|
@@ -47075,22 +47280,23 @@ class PluginContext {
|
|
47075
47280
|
_activeId = null;
|
47076
47281
|
_activeCode = null;
|
47077
47282
|
_resolveSkips;
|
47283
|
+
_resolveSkipCalls;
|
47078
47284
|
meta;
|
47079
47285
|
environment;
|
47080
47286
|
parse(code, opts) {
|
47081
47287
|
return parseAst(code, opts);
|
47082
47288
|
}
|
47083
47289
|
async resolve(id, importer, options) {
|
47084
|
-
|
47085
|
-
|
47086
|
-
|
47087
|
-
|
47088
|
-
}
|
47290
|
+
const skipCalls = options?.skipSelf === false ? this._resolveSkipCalls : [
|
47291
|
+
...this._resolveSkipCalls || [],
|
47292
|
+
{ id, importer, plugin: this._plugin }
|
47293
|
+
];
|
47089
47294
|
let out = await this._container.resolveId(id, importer, {
|
47090
47295
|
attributes: options?.attributes,
|
47091
47296
|
custom: options?.custom,
|
47092
47297
|
isEntry: !!options?.isEntry,
|
47093
|
-
skip,
|
47298
|
+
skip: this._resolveSkips,
|
47299
|
+
skipCalls,
|
47094
47300
|
scan: this._scan
|
47095
47301
|
});
|
47096
47302
|
if (typeof out === "string") out = { id: out };
|
@@ -47167,7 +47373,7 @@ class PluginContext {
|
|
47167
47373
|
if (err.pluginCode) {
|
47168
47374
|
return err;
|
47169
47375
|
}
|
47170
|
-
|
47376
|
+
err.plugin = this._plugin.name;
|
47171
47377
|
if (this._activeId && !err.id) err.id = this._activeId;
|
47172
47378
|
if (this._activeCode) {
|
47173
47379
|
err.pluginCode = this._activeCode;
|
@@ -47213,7 +47419,7 @@ ${err2.stack || err2.message}
|
|
47213
47419
|
};
|
47214
47420
|
err.frame = err.frame || generateCodeFrame(this._activeCode, err.loc);
|
47215
47421
|
}
|
47216
|
-
if (this instanceof TransformPluginContext && typeof err.loc?.line === "number" && typeof err.loc
|
47422
|
+
if (this instanceof TransformPluginContext && typeof err.loc?.line === "number" && typeof err.loc.column === "number") {
|
47217
47423
|
const rawSourceMap = this._getCombinedSourcemap();
|
47218
47424
|
if (rawSourceMap && "version" in rawSourceMap) {
|
47219
47425
|
const traced = new TraceMap(rawSourceMap);
|
@@ -47221,7 +47427,7 @@ ${err2.stack || err2.message}
|
|
47221
47427
|
line: Number(err.loc.line),
|
47222
47428
|
column: Number(err.loc.column)
|
47223
47429
|
});
|
47224
|
-
if (source
|
47430
|
+
if (source) {
|
47225
47431
|
err.loc = { file: source, line, column };
|
47226
47432
|
}
|
47227
47433
|
}
|
@@ -47259,9 +47465,10 @@ ${err2.stack || err2.message}
|
|
47259
47465
|
}
|
47260
47466
|
}
|
47261
47467
|
class ResolveIdContext extends PluginContext {
|
47262
|
-
constructor(container, skip, scan) {
|
47468
|
+
constructor(container, skip, skipCalls, scan) {
|
47263
47469
|
super(null, container);
|
47264
47470
|
this._resolveSkips = skip;
|
47471
|
+
this._resolveSkipCalls = skipCalls;
|
47265
47472
|
this._scan = scan;
|
47266
47473
|
}
|
47267
47474
|
}
|
@@ -47366,15 +47573,39 @@ class PluginContainer {
|
|
47366
47573
|
// Users should call pluginContainer.resolveId (and load/transform) passing the environment they want to work with
|
47367
47574
|
// But there is code that is going to call it without passing an environment, or with the ssr flag to get the ssr environment
|
47368
47575
|
_getEnvironment(options) {
|
47369
|
-
return options?.environment ? options.environment : this.environments
|
47576
|
+
return options?.environment ? options.environment : this.environments[options?.ssr ? "ssr" : "client"];
|
47370
47577
|
}
|
47371
47578
|
_getPluginContainer(options) {
|
47372
47579
|
return this._getEnvironment(options).pluginContainer;
|
47373
47580
|
}
|
47374
47581
|
getModuleInfo(id) {
|
47375
|
-
|
47376
|
-
|
47377
|
-
);
|
47582
|
+
const clientModuleInfo = this.environments.client.pluginContainer.getModuleInfo(id);
|
47583
|
+
const ssrModuleInfo = this.environments.ssr.pluginContainer.getModuleInfo(id);
|
47584
|
+
if (clientModuleInfo == null && ssrModuleInfo == null) return null;
|
47585
|
+
return new Proxy({}, {
|
47586
|
+
get: (_, key) => {
|
47587
|
+
if (key === "meta") {
|
47588
|
+
const meta = {};
|
47589
|
+
if (ssrModuleInfo) {
|
47590
|
+
Object.assign(meta, ssrModuleInfo.meta);
|
47591
|
+
}
|
47592
|
+
if (clientModuleInfo) {
|
47593
|
+
Object.assign(meta, clientModuleInfo.meta);
|
47594
|
+
}
|
47595
|
+
return meta;
|
47596
|
+
}
|
47597
|
+
if (clientModuleInfo) {
|
47598
|
+
if (key in clientModuleInfo) {
|
47599
|
+
return clientModuleInfo[key];
|
47600
|
+
}
|
47601
|
+
}
|
47602
|
+
if (ssrModuleInfo) {
|
47603
|
+
if (key in ssrModuleInfo) {
|
47604
|
+
return ssrModuleInfo[key];
|
47605
|
+
}
|
47606
|
+
}
|
47607
|
+
}
|
47608
|
+
});
|
47378
47609
|
}
|
47379
47610
|
get options() {
|
47380
47611
|
return this.environments.client.pluginContainer.options;
|
@@ -47521,8 +47752,9 @@ function cssPlugin(config) {
|
|
47521
47752
|
extensions: []
|
47522
47753
|
});
|
47523
47754
|
let preprocessorWorkerController;
|
47524
|
-
if (config.css
|
47525
|
-
resolvePostcssConfig(config)
|
47755
|
+
if (config.css.transformer !== "lightningcss") {
|
47756
|
+
resolvePostcssConfig(config).catch(() => {
|
47757
|
+
});
|
47526
47758
|
}
|
47527
47759
|
return {
|
47528
47760
|
name: "vite:css",
|
@@ -47697,7 +47929,7 @@ function cssPostPlugin(config) {
|
|
47697
47929
|
const modulesCode = modules && !inlined && dataToEsm(modules, { namedExports: true, preferConst: true });
|
47698
47930
|
if (config.command === "serve") {
|
47699
47931
|
const getContentWithSourcemap = async (content) => {
|
47700
|
-
if (config.css
|
47932
|
+
if (config.css.devSourcemap) {
|
47701
47933
|
const sourcemap = this.getCombinedSourcemap();
|
47702
47934
|
if (sourcemap.mappings) {
|
47703
47935
|
await injectSourcesContent(sourcemap, cleanUrl(id), config.logger);
|
@@ -48100,7 +48332,15 @@ function getEmptyChunkReplacer(pureCssChunkNames, outputFormat) {
|
|
48100
48332
|
return (code) => code.replace(
|
48101
48333
|
emptyChunkRE,
|
48102
48334
|
// remove css import while preserving source map location
|
48103
|
-
(m
|
48335
|
+
(m, p1, p2) => {
|
48336
|
+
if (outputFormat === "es") {
|
48337
|
+
return `/* empty css ${"".padEnd(m.length - 15)}*/`;
|
48338
|
+
}
|
48339
|
+
if (p2 === ";") {
|
48340
|
+
return `${p2}/* empty css ${"".padEnd(m.length - 16)}*/`;
|
48341
|
+
}
|
48342
|
+
return `${p1}/* empty css ${"".padEnd(m.length - 15 - p1.length)}*/`;
|
48343
|
+
}
|
48104
48344
|
);
|
48105
48345
|
}
|
48106
48346
|
function createCSSResolvers(config) {
|
@@ -48129,7 +48369,12 @@ function createCSSResolvers(config) {
|
|
48129
48369
|
});
|
48130
48370
|
sassResolve = async (...args) => {
|
48131
48371
|
if (args[1].startsWith("file://")) {
|
48132
|
-
args[1] = fileURLToPath$1(args[1]
|
48372
|
+
args[1] = fileURLToPath$1(args[1], {
|
48373
|
+
windows: (
|
48374
|
+
// file:///foo cannot be converted to path with windows mode
|
48375
|
+
isWindows$3 && args[1].startsWith("file:///") ? false : void 0
|
48376
|
+
)
|
48377
|
+
});
|
48133
48378
|
}
|
48134
48379
|
return resolver(...args);
|
48135
48380
|
};
|
@@ -48152,7 +48397,7 @@ function getCssResolversKeys(resolvers) {
|
|
48152
48397
|
}
|
48153
48398
|
async function compileCSSPreprocessors(environment, id, lang, code, workerController) {
|
48154
48399
|
const { config } = environment;
|
48155
|
-
const { preprocessorOptions, devSourcemap } = config.css
|
48400
|
+
const { preprocessorOptions, devSourcemap } = config.css;
|
48156
48401
|
const atImportResolvers = getAtImportResolvers(
|
48157
48402
|
environment.getTopLevelConfig()
|
48158
48403
|
);
|
@@ -48175,7 +48420,7 @@ async function compileCSSPreprocessors(environment, id, lang, code, workerContro
|
|
48175
48420
|
throw preprocessResult.error;
|
48176
48421
|
}
|
48177
48422
|
let deps;
|
48178
|
-
if (preprocessResult.deps) {
|
48423
|
+
if (preprocessResult.deps.length > 0) {
|
48179
48424
|
const normalizedFilename = normalizePath$3(opts.filename);
|
48180
48425
|
deps = new Set(
|
48181
48426
|
[...preprocessResult.deps].filter(
|
@@ -48204,10 +48449,10 @@ function getAtImportResolvers(config) {
|
|
48204
48449
|
}
|
48205
48450
|
async function compileCSS(environment, id, code, workerController, urlReplacer) {
|
48206
48451
|
const { config } = environment;
|
48207
|
-
if (config.css
|
48452
|
+
if (config.css.transformer === "lightningcss") {
|
48208
48453
|
return compileLightningCSS(id, code, environment, urlReplacer);
|
48209
48454
|
}
|
48210
|
-
const { modules: modulesOptions, devSourcemap } = config.css
|
48455
|
+
const { modules: modulesOptions, devSourcemap } = config.css;
|
48211
48456
|
const isModule = modulesOptions !== false && cssModuleRE.test(id);
|
48212
48457
|
const needInlineImport = code.includes("@import");
|
48213
48458
|
const hasUrl = cssUrlRE.test(code) || cssImageSetRE.test(code);
|
@@ -48236,8 +48481,8 @@ async function compileCSS(environment, id, code, workerController, urlReplacer)
|
|
48236
48481
|
const atImportResolvers = getAtImportResolvers(
|
48237
48482
|
environment.getTopLevelConfig()
|
48238
48483
|
);
|
48239
|
-
const postcssOptions = postcssConfig
|
48240
|
-
const postcssPlugins = postcssConfig
|
48484
|
+
const postcssOptions = postcssConfig?.options ?? {};
|
48485
|
+
const postcssPlugins = postcssConfig?.plugins.slice() ?? [];
|
48241
48486
|
if (needInlineImport) {
|
48242
48487
|
postcssPlugins.unshift(
|
48243
48488
|
(await importPostcssImport()).default({
|
@@ -48432,8 +48677,8 @@ function createCachedImport(imp) {
|
|
48432
48677
|
return cached;
|
48433
48678
|
};
|
48434
48679
|
}
|
48435
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
48436
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
48680
|
+
const importPostcssImport = createCachedImport(() => import('./dep-CrWUFq3l.js').then(function (n) { return n.i; }));
|
48681
|
+
const importPostcssModules = createCachedImport(() => import('./dep-pSQn2Hds.js').then(function (n) { return n.i; }));
|
48437
48682
|
const importPostcss = createCachedImport(() => import('postcss'));
|
48438
48683
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
48439
48684
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -48492,7 +48737,7 @@ async function resolvePostcssConfig(config) {
|
|
48492
48737
|
if (result !== void 0) {
|
48493
48738
|
return await result;
|
48494
48739
|
}
|
48495
|
-
const inlineOptions = config.css
|
48740
|
+
const inlineOptions = config.css.postcss;
|
48496
48741
|
if (isObject$2(inlineOptions)) {
|
48497
48742
|
const options = { ...inlineOptions };
|
48498
48743
|
delete options.plugins;
|
@@ -48518,9 +48763,13 @@ ${stack}`;
|
|
48518
48763
|
}
|
48519
48764
|
return null;
|
48520
48765
|
});
|
48521
|
-
result.then(
|
48522
|
-
|
48523
|
-
|
48766
|
+
result.then(
|
48767
|
+
(resolved) => {
|
48768
|
+
postcssConfigCache.set(config, resolved);
|
48769
|
+
},
|
48770
|
+
() => {
|
48771
|
+
}
|
48772
|
+
);
|
48524
48773
|
}
|
48525
48774
|
postcssConfigCache.set(config, result);
|
48526
48775
|
return result;
|
@@ -48550,14 +48799,22 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
48550
48799
|
const replacerForDeclaration = (rawUrl) => {
|
48551
48800
|
return opts.replacer(rawUrl, importer);
|
48552
48801
|
};
|
48553
|
-
|
48554
|
-
|
48555
|
-
|
48556
|
-
(url) => {
|
48802
|
+
if (isCssUrl && isCssImageSet) {
|
48803
|
+
promises.push(
|
48804
|
+
rewriteCssUrls(declaration.value, replacerForDeclaration).then((url) => rewriteCssImageSet(url, replacerForDeclaration)).then((url) => {
|
48557
48805
|
declaration.value = url;
|
48558
|
-
}
|
48559
|
-
)
|
48560
|
-
|
48806
|
+
})
|
48807
|
+
);
|
48808
|
+
} else {
|
48809
|
+
const rewriterToUse = isCssImageSet ? rewriteCssImageSet : rewriteCssUrls;
|
48810
|
+
promises.push(
|
48811
|
+
rewriterToUse(declaration.value, replacerForDeclaration).then(
|
48812
|
+
(url) => {
|
48813
|
+
declaration.value = url;
|
48814
|
+
}
|
48815
|
+
)
|
48816
|
+
);
|
48817
|
+
}
|
48561
48818
|
}
|
48562
48819
|
});
|
48563
48820
|
if (promises.length) {
|
@@ -48642,7 +48899,7 @@ async function doImportCSSReplace(rawUrl, matched, replacer) {
|
|
48642
48899
|
async function minifyCSS(css, config, inlined) {
|
48643
48900
|
if (config.build.cssMinify === "lightningcss") {
|
48644
48901
|
const { code, warnings } = (await importLightningCSS()).transform({
|
48645
|
-
...config.css
|
48902
|
+
...config.css.lightningcss,
|
48646
48903
|
targets: convertTargets(config.build.cssTarget),
|
48647
48904
|
cssModules: void 0,
|
48648
48905
|
// TODO: Pass actual filename here, which can also be passed to esbuild's
|
@@ -48774,7 +49031,7 @@ function loadSss(root) {
|
|
48774
49031
|
function cleanScssBugUrl(url) {
|
48775
49032
|
if (
|
48776
49033
|
// check bug via `window` and `location` global
|
48777
|
-
typeof window !== "undefined" && typeof location !== "undefined" && typeof location
|
49034
|
+
typeof window !== "undefined" && typeof location !== "undefined" && typeof location.href === "string"
|
48778
49035
|
) {
|
48779
49036
|
const prefix = location.href.replace(/\/$/, "");
|
48780
49037
|
return url.replace(prefix, "");
|
@@ -48822,7 +49079,7 @@ const makeScssWorker = (environment, resolvers, alias, maxWorkers, packageName)
|
|
48822
49079
|
const path2 = require("node:path");
|
48823
49080
|
const _internalImporter = (url, importer2, done) => {
|
48824
49081
|
internalImporter(url, importer2, options.filename).then(
|
48825
|
-
(data2) => done
|
49082
|
+
(data2) => done(data2)
|
48826
49083
|
);
|
48827
49084
|
};
|
48828
49085
|
const importer = [_internalImporter];
|
@@ -48906,7 +49163,15 @@ const makeModernScssWorker = (environment, resolvers, alias, maxWorkers) => {
|
|
48906
49163
|
async canonicalize(url, context) {
|
48907
49164
|
const importer = context.containingUrl ? fileURLToPath2(context.containingUrl) : options.filename;
|
48908
49165
|
const resolved = await internalCanonicalize(url, importer);
|
48909
|
-
|
49166
|
+
if (resolved && // only limit to these extensions because:
|
49167
|
+
// - for the `@import`/`@use`s written in file loaded by `load` function,
|
49168
|
+
// the `canonicalize` function of that `importer` is called first
|
49169
|
+
// - the `load` function of an importer is only called for the importer
|
49170
|
+
// that returned a non-null result from its `canonicalize` function
|
49171
|
+
(resolved.endsWith(".css") || resolved.endsWith(".scss") || resolved.endsWith(".sass"))) {
|
49172
|
+
return pathToFileURL2(resolved);
|
49173
|
+
}
|
49174
|
+
return null;
|
48910
49175
|
},
|
48911
49176
|
async load(canonicalUrl) {
|
48912
49177
|
const ext = path2.extname(canonicalUrl.pathname);
|
@@ -48967,7 +49232,10 @@ const makeModernCompilerScssWorker = (environment, resolvers, alias, _maxWorkers
|
|
48967
49232
|
url,
|
48968
49233
|
cleanScssBugUrl(importer)
|
48969
49234
|
);
|
48970
|
-
|
49235
|
+
if (resolved && (resolved.endsWith(".css") || resolved.endsWith(".scss") || resolved.endsWith(".sass"))) {
|
49236
|
+
return pathToFileURL$1(resolved);
|
49237
|
+
}
|
49238
|
+
return null;
|
48971
49239
|
},
|
48972
49240
|
async load(canonicalUrl) {
|
48973
49241
|
const ext = path$d.extname(canonicalUrl.pathname);
|
@@ -49143,13 +49411,10 @@ const makeLessWorker = (environment, resolvers, alias, maxWorkers) => {
|
|
49143
49411
|
"@",
|
49144
49412
|
resolvers.less
|
49145
49413
|
);
|
49146
|
-
|
49147
|
-
|
49148
|
-
|
49149
|
-
|
49150
|
-
};
|
49151
|
-
}
|
49152
|
-
return result;
|
49414
|
+
return {
|
49415
|
+
resolved,
|
49416
|
+
contents: "contents" in result ? result.contents : void 0
|
49417
|
+
};
|
49153
49418
|
};
|
49154
49419
|
const worker = new WorkerWithFallback(
|
49155
49420
|
() => {
|
@@ -49455,11 +49720,11 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49455
49720
|
res = styleAttrRE.test(id) ? (await importLightningCSS()).transformStyleAttribute({
|
49456
49721
|
filename,
|
49457
49722
|
code: Buffer.from(src),
|
49458
|
-
targets: config.css
|
49723
|
+
targets: config.css.lightningcss?.targets,
|
49459
49724
|
minify: config.isProduction && !!config.build.cssMinify,
|
49460
49725
|
analyzeDependencies: true
|
49461
49726
|
}) : await (await importLightningCSS()).bundleAsync({
|
49462
|
-
...config.css
|
49727
|
+
...config.css.lightningcss,
|
49463
49728
|
filename,
|
49464
49729
|
resolver: {
|
49465
49730
|
read(filePath) {
|
@@ -49490,9 +49755,9 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49490
49755
|
}
|
49491
49756
|
},
|
49492
49757
|
minify: config.isProduction && !!config.build.cssMinify,
|
49493
|
-
sourceMap: config.command === "build" ? !!config.build.sourcemap : config.css
|
49758
|
+
sourceMap: config.command === "build" ? !!config.build.sourcemap : config.css.devSourcemap,
|
49494
49759
|
analyzeDependencies: true,
|
49495
|
-
cssModules: cssModuleRE.test(id) ? config.css
|
49760
|
+
cssModules: cssModuleRE.test(id) ? config.css.lightningcss?.cssModules ?? true : void 0
|
49496
49761
|
});
|
49497
49762
|
} catch (e) {
|
49498
49763
|
e.message = `[lightningcss] ${e.message}`;
|
@@ -49507,21 +49772,24 @@ async function compileLightningCSS(id, src, environment, urlReplacer) {
|
|
49507
49772
|
let css = decoder.decode(res.code);
|
49508
49773
|
for (const dep of res.dependencies) {
|
49509
49774
|
switch (dep.type) {
|
49510
|
-
case "url":
|
49775
|
+
case "url": {
|
49776
|
+
let replaceUrl;
|
49511
49777
|
if (skipUrlReplacer(dep.url)) {
|
49512
|
-
|
49513
|
-
|
49514
|
-
|
49515
|
-
if (urlReplacer) {
|
49516
|
-
const replaceUrl = await urlReplacer(
|
49517
|
-
dep.url,
|
49518
|
-
toAbsolute(dep.loc.filePath)
|
49519
|
-
);
|
49520
|
-
css = css.replace(dep.placeholder, () => replaceUrl);
|
49778
|
+
replaceUrl = dep.url;
|
49779
|
+
} else if (urlReplacer) {
|
49780
|
+
replaceUrl = await urlReplacer(dep.url, toAbsolute(dep.loc.filePath));
|
49521
49781
|
} else {
|
49522
|
-
|
49523
|
-
}
|
49782
|
+
replaceUrl = dep.url;
|
49783
|
+
}
|
49784
|
+
css = css.replace(
|
49785
|
+
dep.placeholder,
|
49786
|
+
// lightningcss always generates `url("placeholder")`
|
49787
|
+
// (`url('placeholder')`, `url(placeholder)` is not generated)
|
49788
|
+
// so escape double quotes
|
49789
|
+
() => replaceUrl.replaceAll('"', '\\"')
|
49790
|
+
);
|
49524
49791
|
break;
|
49792
|
+
}
|
49525
49793
|
default:
|
49526
49794
|
throw new Error(`Unsupported dependency type: ${dep.type}`);
|
49527
49795
|
}
|
@@ -50105,7 +50373,7 @@ function buildImportAnalysisPlugin(config) {
|
|
50105
50373
|
);
|
50106
50374
|
chunk.code += `
|
50107
50375
|
//# sourceMappingURL=${genSourceMapUrl(map)}`;
|
50108
|
-
} else
|
50376
|
+
} else {
|
50109
50377
|
const mapAsset = bundle[chunk.fileName + ".map"];
|
50110
50378
|
if (mapAsset && mapAsset.type === "asset") {
|
50111
50379
|
mapAsset.source = map.toString();
|
@@ -50278,7 +50546,7 @@ const buildEnvironmentOptionsDefaults = Object.freeze({
|
|
50278
50546
|
// createEnvironment
|
50279
50547
|
});
|
50280
50548
|
function resolveBuildEnvironmentOptions(raw, logger, consumer) {
|
50281
|
-
const deprecatedPolyfillModulePreload = raw
|
50549
|
+
const deprecatedPolyfillModulePreload = raw.polyfillModulePreload;
|
50282
50550
|
const { polyfillModulePreload, ...rest } = raw;
|
50283
50551
|
raw = rest;
|
50284
50552
|
if (deprecatedPolyfillModulePreload !== void 0) {
|
@@ -50381,12 +50649,12 @@ async function buildEnvironment(environment) {
|
|
50381
50649
|
)
|
50382
50650
|
);
|
50383
50651
|
const resolve = (p) => path$d.resolve(root, p);
|
50384
|
-
const input = libOptions ? options.rollupOptions
|
50652
|
+
const input = libOptions ? options.rollupOptions.input || (typeof libOptions.entry === "string" ? resolve(libOptions.entry) : Array.isArray(libOptions.entry) ? libOptions.entry.map(resolve) : Object.fromEntries(
|
50385
50653
|
Object.entries(libOptions.entry).map(([alias, file]) => [
|
50386
50654
|
alias,
|
50387
50655
|
resolve(file)
|
50388
50656
|
])
|
50389
|
-
)) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rollupOptions
|
50657
|
+
)) : typeof options.ssr === "string" ? resolve(options.ssr) : options.rollupOptions.input || resolve("index.html");
|
50390
50658
|
if (ssr && typeof input === "string" && input.endsWith(".html")) {
|
50391
50659
|
throw new Error(
|
50392
50660
|
`rollupOptions.input should not be an html file when building for SSR. Please specify a dedicated SSR entry.`
|
@@ -50411,7 +50679,7 @@ async function buildEnvironment(environment) {
|
|
50411
50679
|
output: options.rollupOptions.output,
|
50412
50680
|
input,
|
50413
50681
|
plugins,
|
50414
|
-
external: options.rollupOptions
|
50682
|
+
external: options.rollupOptions.external,
|
50415
50683
|
onwarn(warning, warn) {
|
50416
50684
|
onRollupWarning(warning, warn, environment);
|
50417
50685
|
}
|
@@ -50512,7 +50780,7 @@ ${stackOnly}`;
|
|
50512
50780
|
};
|
50513
50781
|
};
|
50514
50782
|
const outputs = resolveBuildOutputs(
|
50515
|
-
options.rollupOptions
|
50783
|
+
options.rollupOptions.output,
|
50516
50784
|
libOptions,
|
50517
50785
|
logger
|
50518
50786
|
);
|
@@ -50527,7 +50795,7 @@ ${stackOnly}`;
|
|
50527
50795
|
const resolvedOutDirs = getResolvedOutDirs(
|
50528
50796
|
root,
|
50529
50797
|
options.outDir,
|
50530
|
-
options.rollupOptions
|
50798
|
+
options.rollupOptions.output
|
50531
50799
|
);
|
50532
50800
|
const emptyOutDir = resolveEmptyOutDir(
|
50533
50801
|
options.emptyOutDir,
|
@@ -50743,7 +51011,7 @@ If you do want to externalize this module explicitly add it to
|
|
50743
51011
|
warn(warnLog);
|
50744
51012
|
};
|
50745
51013
|
clearLine();
|
50746
|
-
const userOnWarn = environment.config.build.rollupOptions
|
51014
|
+
const userOnWarn = environment.config.build.rollupOptions.onwarn;
|
50747
51015
|
if (userOnWarn) {
|
50748
51016
|
userOnWarn(warning, viteWarn);
|
50749
51017
|
} else {
|
@@ -50993,7 +51261,7 @@ class BuildEnvironment extends BaseEnvironment {
|
|
50993
51261
|
if (setup?.options) {
|
50994
51262
|
options = mergeConfig(
|
50995
51263
|
options,
|
50996
|
-
setup
|
51264
|
+
setup.options
|
50997
51265
|
);
|
50998
51266
|
}
|
50999
51267
|
super(name, config, options);
|
@@ -52248,12 +52516,12 @@ class DevEnvironment extends BaseEnvironment {
|
|
52248
52516
|
}
|
52249
52517
|
async close() {
|
52250
52518
|
this._closing = true;
|
52251
|
-
this._crawlEndFinder
|
52519
|
+
this._crawlEndFinder.cancel();
|
52252
52520
|
await Promise.allSettled([
|
52253
52521
|
this.pluginContainer.close(),
|
52254
52522
|
this.depsOptimizer?.close(),
|
52255
52523
|
// WebSocketServer is independent of HotChannel and should not be closed on environment close
|
52256
|
-
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close
|
52524
|
+
isWebSocketServer in this.hot ? Promise.resolve() : this.hot.close(),
|
52257
52525
|
(async () => {
|
52258
52526
|
while (this._pendingRequests.size > 0) {
|
52259
52527
|
await Promise.allSettled(
|
@@ -52523,7 +52791,7 @@ async function preview(inlineConfig = {}) {
|
|
52523
52791
|
"production",
|
52524
52792
|
true
|
52525
52793
|
);
|
52526
|
-
const clientOutDir = config.environments.client.build.outDir
|
52794
|
+
const clientOutDir = config.environments.client.build.outDir;
|
52527
52795
|
const distDir = path$d.resolve(config.root, clientOutDir);
|
52528
52796
|
if (!fs__default.existsSync(distDir) && // error if no plugins implement `configurePreviewServer`
|
52529
52797
|
config.plugins.every((plugin) => !plugin.configurePreviewServer) && // error if called in CLI only. programmatic usage could access `httpServer`
|
@@ -52537,7 +52805,7 @@ async function preview(inlineConfig = {}) {
|
|
52537
52805
|
const httpServer = await resolveHttpServer(
|
52538
52806
|
config.preview,
|
52539
52807
|
app,
|
52540
|
-
await resolveHttpsConfig(config.preview
|
52808
|
+
await resolveHttpsConfig(config.preview.https)
|
52541
52809
|
);
|
52542
52810
|
setClientErrorHandler(httpServer, config.logger);
|
52543
52811
|
const options = config.preview;
|
@@ -52628,7 +52896,7 @@ async function preview(inlineConfig = {}) {
|
|
52628
52896
|
config
|
52629
52897
|
);
|
52630
52898
|
if (options.open) {
|
52631
|
-
const url = server.resolvedUrls
|
52899
|
+
const url = server.resolvedUrls.local[0] ?? server.resolvedUrls.network[0];
|
52632
52900
|
if (url) {
|
52633
52901
|
const path2 = typeof options.open === "string" ? new URL(options.open, url).href : url;
|
52634
52902
|
openBrowser(path2, true, logger);
|
@@ -52969,7 +53237,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
52969
53237
|
return p.apply === command;
|
52970
53238
|
}
|
52971
53239
|
};
|
52972
|
-
const rawPlugins = (await asyncFlatten(config.plugins || [])).filter(
|
53240
|
+
const rawPlugins = (await asyncFlatten(config.plugins || [])).filter(
|
53241
|
+
filterPlugin
|
53242
|
+
);
|
52973
53243
|
const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawPlugins);
|
52974
53244
|
const isBuild = command === "build";
|
52975
53245
|
const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins];
|
@@ -52995,31 +53265,35 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
52995
53265
|
let configEnvironmentsSsr = config.environments.ssr;
|
52996
53266
|
const warmupOptions = config.server?.warmup;
|
52997
53267
|
if (warmupOptions?.clientFiles) {
|
52998
|
-
configEnvironmentsClient.dev.warmup = warmupOptions
|
53268
|
+
configEnvironmentsClient.dev.warmup = warmupOptions.clientFiles;
|
52999
53269
|
}
|
53000
53270
|
if (warmupOptions?.ssrFiles) {
|
53001
53271
|
configEnvironmentsSsr ??= {};
|
53002
53272
|
configEnvironmentsSsr.dev ??= {};
|
53003
|
-
configEnvironmentsSsr.dev.warmup = warmupOptions
|
53273
|
+
configEnvironmentsSsr.dev.warmup = warmupOptions.ssrFiles;
|
53004
53274
|
}
|
53005
53275
|
if (configEnvironmentsSsr) {
|
53006
53276
|
configEnvironmentsSsr.optimizeDeps = mergeConfig(
|
53007
53277
|
deprecatedSsrOptimizeDepsConfig,
|
53008
53278
|
configEnvironmentsSsr.optimizeDeps ?? {}
|
53009
53279
|
);
|
53010
|
-
configEnvironmentsSsr.resolve
|
53011
|
-
|
53012
|
-
|
53013
|
-
|
53014
|
-
|
53015
|
-
|
53280
|
+
configEnvironmentsSsr.resolve = mergeConfig(
|
53281
|
+
{
|
53282
|
+
conditions: config.ssr?.resolve?.conditions,
|
53283
|
+
externalConditions: config.ssr?.resolve?.externalConditions,
|
53284
|
+
mainFields: config.ssr?.resolve?.mainFields,
|
53285
|
+
external: config.ssr?.external,
|
53286
|
+
noExternal: config.ssr?.noExternal
|
53287
|
+
},
|
53288
|
+
configEnvironmentsSsr.resolve ?? {}
|
53289
|
+
);
|
53016
53290
|
}
|
53017
53291
|
if (config.build?.ssrEmitAssets !== void 0) {
|
53018
53292
|
configEnvironmentsSsr ??= {};
|
53019
53293
|
configEnvironmentsSsr.build ??= {};
|
53020
53294
|
configEnvironmentsSsr.build.emitAssets = config.build.ssrEmitAssets;
|
53021
53295
|
}
|
53022
|
-
if (!config.environments
|
53296
|
+
if (!config.environments.client || !config.environments.ssr && !isBuild) {
|
53023
53297
|
throw new Error(
|
53024
53298
|
"Required environments configuration were stripped out in the config hook"
|
53025
53299
|
);
|
@@ -53055,6 +53329,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53055
53329
|
configEnv,
|
53056
53330
|
config.ssr?.target === "webworker"
|
53057
53331
|
);
|
53332
|
+
config.resolve ??= {};
|
53333
|
+
config.resolve.conditions = config.environments.client.resolve?.conditions;
|
53334
|
+
config.resolve.mainFields = config.environments.client.resolve?.mainFields;
|
53058
53335
|
const resolvedDefaultResolve = resolveResolveOptions(config.resolve, logger);
|
53059
53336
|
const resolvedEnvironments = {};
|
53060
53337
|
for (const environmentName of Object.keys(config.environments)) {
|
@@ -53109,7 +53386,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = "development",
|
|
53109
53386
|
}
|
53110
53387
|
const isProduction = process.env.NODE_ENV === "production";
|
53111
53388
|
const relativeBaseShortcut = config.base === "" || config.base === "./";
|
53112
|
-
const resolvedBase = relativeBaseShortcut ? !isBuild || config.build?.ssr ? "/" : "./" : resolveBaseUrl(config.base, isBuild, logger)
|
53389
|
+
const resolvedBase = relativeBaseShortcut ? !isBuild || config.build?.ssr ? "/" : "./" : resolveBaseUrl(config.base, isBuild, logger);
|
53113
53390
|
const pkgDir = findNearestPackageData(resolvedRoot, packageCache)?.dir;
|
53114
53391
|
const cacheDir = normalizePath$3(
|
53115
53392
|
config.cacheDir ? path$d.resolve(resolvedRoot, config.cacheDir) : pkgDir ? path$d.join(pkgDir, `node_modules/.vite`) : path$d.join(resolvedRoot, `.vite`)
|
@@ -53350,7 +53627,7 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
53350
53627
|
}
|
53351
53628
|
return resolved;
|
53352
53629
|
}
|
53353
|
-
function resolveBaseUrl(base =
|
53630
|
+
function resolveBaseUrl(base = configDefaults.base, isBuild, logger) {
|
53354
53631
|
if (base[0] === ".") {
|
53355
53632
|
logger.warn(
|
53356
53633
|
colors$1.yellow(
|
@@ -53451,6 +53728,8 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53451
53728
|
format: isESM ? "esm" : "cjs",
|
53452
53729
|
mainFields: ["main"],
|
53453
53730
|
sourcemap: "inline",
|
53731
|
+
// the last slash is needed to make the path correct
|
53732
|
+
sourceRoot: path$d.dirname(fileName) + path$d.sep,
|
53454
53733
|
metafile: true,
|
53455
53734
|
define: {
|
53456
53735
|
__dirname: dirnameVarName,
|
@@ -53487,7 +53766,7 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53487
53766
|
})?.id;
|
53488
53767
|
};
|
53489
53768
|
build2.onResolve(
|
53490
|
-
{ filter: /^[
|
53769
|
+
{ filter: /^[^.#].*/ },
|
53491
53770
|
async ({ path: id, importer, kind }) => {
|
53492
53771
|
if (kind === "entry-point" || path$d.isAbsolute(id) || isNodeBuiltin(id)) {
|
53493
53772
|
return;
|
@@ -53553,17 +53832,25 @@ async function bundleConfigFile(fileName, isESM) {
|
|
53553
53832
|
const { text } = result.outputFiles[0];
|
53554
53833
|
return {
|
53555
53834
|
code: text,
|
53556
|
-
dependencies:
|
53835
|
+
dependencies: Object.keys(result.metafile.inputs)
|
53557
53836
|
};
|
53558
53837
|
}
|
53559
53838
|
const _require = createRequire$1(import.meta.url);
|
53560
53839
|
async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
53561
53840
|
if (isESM) {
|
53562
|
-
|
53841
|
+
let nodeModulesDir = typeof process.versions.deno === "string" ? void 0 : findNearestNodeModules(path$d.dirname(fileName));
|
53563
53842
|
if (nodeModulesDir) {
|
53564
|
-
|
53565
|
-
|
53566
|
-
|
53843
|
+
try {
|
53844
|
+
await fsp.mkdir(path$d.resolve(nodeModulesDir, ".vite-temp/"), {
|
53845
|
+
recursive: true
|
53846
|
+
});
|
53847
|
+
} catch (e) {
|
53848
|
+
if (e.code === "EACCES") {
|
53849
|
+
nodeModulesDir = void 0;
|
53850
|
+
} else {
|
53851
|
+
throw e;
|
53852
|
+
}
|
53853
|
+
}
|
53567
53854
|
}
|
53568
53855
|
const hash = `timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
53569
53856
|
const tempFileName = nodeModulesDir ? path$d.resolve(
|
@@ -53600,11 +53887,9 @@ async function runConfigHook(config, plugins, configEnv) {
|
|
53600
53887
|
for (const p of getSortedPluginsByHook("config", plugins)) {
|
53601
53888
|
const hook = p.config;
|
53602
53889
|
const handler = getHookHandler(hook);
|
53603
|
-
|
53604
|
-
|
53605
|
-
|
53606
|
-
conf = mergeConfig(conf, res);
|
53607
|
-
}
|
53890
|
+
const res = await handler(conf, configEnv);
|
53891
|
+
if (res && res !== conf) {
|
53892
|
+
conf = mergeConfig(conf, res);
|
53608
53893
|
}
|
53609
53894
|
}
|
53610
53895
|
return conf;
|
@@ -53614,15 +53899,13 @@ async function runConfigEnvironmentHook(environments, plugins, configEnv, isSsrT
|
|
53614
53899
|
for (const p of getSortedPluginsByHook("configEnvironment", plugins)) {
|
53615
53900
|
const hook = p.configEnvironment;
|
53616
53901
|
const handler = getHookHandler(hook);
|
53617
|
-
|
53618
|
-
|
53619
|
-
|
53620
|
-
|
53621
|
-
|
53622
|
-
|
53623
|
-
|
53624
|
-
environments[name] = mergeConfig(environments[name], res);
|
53625
|
-
}
|
53902
|
+
for (const name of environmentNames) {
|
53903
|
+
const res = await handler(name, environments[name], {
|
53904
|
+
...configEnv,
|
53905
|
+
isSsrTargetWebworker: isSsrTargetWebworkerSet && name === "ssr"
|
53906
|
+
});
|
53907
|
+
if (res) {
|
53908
|
+
environments[name] = mergeConfig(environments[name], res);
|
53626
53909
|
}
|
53627
53910
|
}
|
53628
53911
|
}
|
@@ -53631,7 +53914,7 @@ function optimizeDepsDisabledBackwardCompatibility(resolved, optimizeDeps, optim
|
|
53631
53914
|
const optimizeDepsDisabled = optimizeDeps.disabled;
|
53632
53915
|
if (optimizeDepsDisabled !== void 0) {
|
53633
53916
|
if (optimizeDepsDisabled === true || optimizeDepsDisabled === "dev") {
|
53634
|
-
const commonjsOptionsInclude = resolved.build
|
53917
|
+
const commonjsOptionsInclude = resolved.build.commonjsOptions.include;
|
53635
53918
|
const commonjsPluginDisabled = Array.isArray(commonjsOptionsInclude) && commonjsOptionsInclude.length === 0;
|
53636
53919
|
optimizeDeps.noDiscovery = true;
|
53637
53920
|
optimizeDeps.include = void 0;
|