vite 6.0.0-alpha.0 → 6.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/client.mjs +46 -33
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-b2YSXG5U.js → dep-BD8Vf02W.js} +2 -2
- package/dist/node/chunks/{dep-DUc_OVe8.js → dep-DPzWXNBe.js} +1 -1
- package/dist/node/chunks/{dep-hQh5_mg-.js → dep-gq9_cnPm.js} +376 -211
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +34 -20
- package/dist/node/index.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +22 -12
- package/package.json +5 -4
@@ -7559,21 +7559,29 @@ class MagicString {
|
|
7559
7559
|
if (searchValue.global) {
|
7560
7560
|
const matches = matchAll(searchValue, this.original);
|
7561
7561
|
matches.forEach((match) => {
|
7562
|
-
if (match.index != null)
|
7562
|
+
if (match.index != null) {
|
7563
|
+
const replacement = getReplacement(match, this.original);
|
7564
|
+
if (replacement !== match[0]) {
|
7565
|
+
this.overwrite(
|
7566
|
+
match.index,
|
7567
|
+
match.index + match[0].length,
|
7568
|
+
replacement
|
7569
|
+
);
|
7570
|
+
}
|
7571
|
+
}
|
7572
|
+
});
|
7573
|
+
} else {
|
7574
|
+
const match = this.original.match(searchValue);
|
7575
|
+
if (match && match.index != null) {
|
7576
|
+
const replacement = getReplacement(match, this.original);
|
7577
|
+
if (replacement !== match[0]) {
|
7563
7578
|
this.overwrite(
|
7564
7579
|
match.index,
|
7565
7580
|
match.index + match[0].length,
|
7566
|
-
|
7581
|
+
replacement
|
7567
7582
|
);
|
7568
|
-
|
7569
|
-
|
7570
|
-
const match = this.original.match(searchValue);
|
7571
|
-
if (match && match.index != null)
|
7572
|
-
this.overwrite(
|
7573
|
-
match.index,
|
7574
|
-
match.index + match[0].length,
|
7575
|
-
getReplacement(match, this.original),
|
7576
|
-
);
|
7583
|
+
}
|
7584
|
+
}
|
7577
7585
|
}
|
7578
7586
|
return this;
|
7579
7587
|
}
|
@@ -7605,7 +7613,9 @@ class MagicString {
|
|
7605
7613
|
index !== -1;
|
7606
7614
|
index = original.indexOf(string, index + stringLength)
|
7607
7615
|
) {
|
7608
|
-
|
7616
|
+
const previous = original.slice(index, index + stringLength);
|
7617
|
+
if (previous !== replacement)
|
7618
|
+
this.overwrite(index, index + stringLength, replacement);
|
7609
7619
|
}
|
7610
7620
|
|
7611
7621
|
return this;
|
@@ -9998,7 +10008,7 @@ function makeUrl(scheme, user, host, port, path, query, hash) {
|
|
9998
10008
|
type: 7 /* Absolute */,
|
9999
10009
|
};
|
10000
10010
|
}
|
10001
|
-
function parseUrl$
|
10011
|
+
function parseUrl$3(input) {
|
10002
10012
|
if (isSchemeRelativeUrl(input)) {
|
10003
10013
|
const url = parseAbsoluteUrl('http:' + input);
|
10004
10014
|
url.scheme = '';
|
@@ -10112,10 +10122,10 @@ function normalizePath$4(url, type) {
|
|
10112
10122
|
function resolve$2(input, base) {
|
10113
10123
|
if (!input && !base)
|
10114
10124
|
return '';
|
10115
|
-
const url = parseUrl$
|
10125
|
+
const url = parseUrl$3(input);
|
10116
10126
|
let inputType = url.type;
|
10117
10127
|
if (base && inputType !== 7 /* Absolute */) {
|
10118
|
-
const baseUrl = parseUrl$
|
10128
|
+
const baseUrl = parseUrl$3(base);
|
10119
10129
|
const baseType = baseUrl.type;
|
10120
10130
|
switch (inputType) {
|
10121
10131
|
case 1 /* Empty */:
|
@@ -10354,6 +10364,14 @@ class TraceMap {
|
|
10354
10364
|
function cast$2(map) {
|
10355
10365
|
return map;
|
10356
10366
|
}
|
10367
|
+
/**
|
10368
|
+
* Returns the encoded (VLQ string) form of the SourceMap's mappings field.
|
10369
|
+
*/
|
10370
|
+
function encodedMappings(map) {
|
10371
|
+
var _a;
|
10372
|
+
var _b;
|
10373
|
+
return ((_a = (_b = cast$2(map))._encoded) !== null && _a !== void 0 ? _a : (_b._encoded = encode$1(cast$2(map)._decoded)));
|
10374
|
+
}
|
10357
10375
|
/**
|
10358
10376
|
* Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
|
10359
10377
|
*/
|
@@ -10402,6 +10420,32 @@ function originalPositionFor$1(map, needle) {
|
|
10402
10420
|
const { names, resolvedSources } = map;
|
10403
10421
|
return OMapping(resolvedSources[segment[SOURCES_INDEX$1]], segment[SOURCE_LINE$1] + 1, segment[SOURCE_COLUMN$1], segment.length === 5 ? names[segment[NAMES_INDEX$1]] : null);
|
10404
10422
|
}
|
10423
|
+
/**
|
10424
|
+
* Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
|
10425
|
+
* a sourcemap, or to JSON.stringify.
|
10426
|
+
*/
|
10427
|
+
function decodedMap(map) {
|
10428
|
+
return clone(map, decodedMappings(map));
|
10429
|
+
}
|
10430
|
+
/**
|
10431
|
+
* Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
|
10432
|
+
* a sourcemap, or to JSON.stringify.
|
10433
|
+
*/
|
10434
|
+
function encodedMap(map) {
|
10435
|
+
return clone(map, encodedMappings(map));
|
10436
|
+
}
|
10437
|
+
function clone(map, mappings) {
|
10438
|
+
return {
|
10439
|
+
version: map.version,
|
10440
|
+
file: map.file,
|
10441
|
+
names: map.names,
|
10442
|
+
sourceRoot: map.sourceRoot,
|
10443
|
+
sources: map.sources,
|
10444
|
+
sourcesContent: map.sourcesContent,
|
10445
|
+
mappings,
|
10446
|
+
ignoreList: map.ignoreList || map.x_google_ignoreList,
|
10447
|
+
};
|
10448
|
+
}
|
10405
10449
|
function OMapping(source, line, column, name) {
|
10406
10450
|
return { source, line, column, name };
|
10407
10451
|
}
|
@@ -19261,10 +19305,10 @@ var string$2 = {};
|
|
19261
19305
|
|
19262
19306
|
Object.defineProperty(string$2, "__esModule", { value: true });
|
19263
19307
|
string$2.isEmpty = string$2.isString = void 0;
|
19264
|
-
function isString(input) {
|
19308
|
+
function isString$1(input) {
|
19265
19309
|
return typeof input === 'string';
|
19266
19310
|
}
|
19267
|
-
string$2.isString = isString;
|
19311
|
+
string$2.isString = isString$1;
|
19268
19312
|
function isEmpty$1(input) {
|
19269
19313
|
return input === '';
|
19270
19314
|
}
|
@@ -39082,7 +39126,7 @@ var debug$d = srcExports('finalhandler');
|
|
39082
39126
|
var encodeUrl = encodeurl;
|
39083
39127
|
var escapeHtml = escapeHtml_1;
|
39084
39128
|
var onFinished = onFinishedExports;
|
39085
|
-
var parseUrl$
|
39129
|
+
var parseUrl$2 = parseurlExports;
|
39086
39130
|
var statuses = statuses$1;
|
39087
39131
|
var unpipe = unpipe_1;
|
39088
39132
|
|
@@ -39286,7 +39330,7 @@ function getErrorStatusCode (err) {
|
|
39286
39330
|
|
39287
39331
|
function getResourceName (req) {
|
39288
39332
|
try {
|
39289
|
-
return parseUrl$
|
39333
|
+
return parseUrl$2.original(req).pathname
|
39290
39334
|
} catch (e) {
|
39291
39335
|
return 'resource'
|
39292
39336
|
}
|
@@ -39445,7 +39489,7 @@ var EventEmitter$3 = require$$0$5.EventEmitter;
|
|
39445
39489
|
var finalhandler = finalhandler_1;
|
39446
39490
|
var http$4 = require$$1;
|
39447
39491
|
var merge = utilsMergeExports;
|
39448
|
-
var parseUrl = parseurlExports;
|
39492
|
+
var parseUrl$1 = parseurlExports;
|
39449
39493
|
|
39450
39494
|
/**
|
39451
39495
|
* Module exports.
|
@@ -39580,7 +39624,7 @@ proto.handle = function handle(req, res, out) {
|
|
39580
39624
|
}
|
39581
39625
|
|
39582
39626
|
// route data
|
39583
|
-
var path = parseUrl(req).pathname || '/';
|
39627
|
+
var path = parseUrl$1(req).pathname || '/';
|
39584
39628
|
var route = layer.route;
|
39585
39629
|
|
39586
39630
|
// skip this layer if the route doesn't match
|
@@ -44522,7 +44566,7 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
|
|
44522
44566
|
identifiers.push([node, parentStack.slice(0)]);
|
44523
44567
|
}
|
44524
44568
|
}
|
44525
|
-
else if (isFunction(node)) {
|
44569
|
+
else if (isFunction$1(node)) {
|
44526
44570
|
// If it is a function declaration, it could be shadowing an import
|
44527
44571
|
// Add its name to the scope so it won't get replaced
|
44528
44572
|
if (node.type === 'FunctionDeclaration') {
|
@@ -44602,7 +44646,7 @@ function isRefIdentifier(id, parent, parentStack) {
|
|
44602
44646
|
parent.id === id)) {
|
44603
44647
|
return false;
|
44604
44648
|
}
|
44605
|
-
if (isFunction(parent)) {
|
44649
|
+
if (isFunction$1(parent)) {
|
44606
44650
|
// function declaration/expression id
|
44607
44651
|
if (parent.id === id) {
|
44608
44652
|
return false;
|
@@ -44647,7 +44691,7 @@ function isRefIdentifier(id, parent, parentStack) {
|
|
44647
44691
|
const isStaticProperty = (node) => node && node.type === 'Property' && !node.computed;
|
44648
44692
|
const isStaticPropertyKey = (node, parent) => isStaticProperty(parent) && parent.key === node;
|
44649
44693
|
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
|
44650
|
-
function isFunction(node) {
|
44694
|
+
function isFunction$1(node) {
|
44651
44695
|
return functionNodeTypeRE.test(node.type);
|
44652
44696
|
}
|
44653
44697
|
const blockNodeTypeRE = /^BlockStatement$|^For(?:In|Of)?Statement$/;
|
@@ -44655,7 +44699,7 @@ function isBlock(node) {
|
|
44655
44699
|
return blockNodeTypeRE.test(node.type);
|
44656
44700
|
}
|
44657
44701
|
function findParentScope(parentStack, isVar = false) {
|
44658
|
-
return parentStack.find(isVar ? isFunction : isBlock);
|
44702
|
+
return parentStack.find(isVar ? isFunction$1 : isBlock);
|
44659
44703
|
}
|
44660
44704
|
function isInDestructuringAssignment(parent, parentStack) {
|
44661
44705
|
if (parent &&
|
@@ -44768,7 +44812,8 @@ async function ssrLoadModule(url, server, context = { global }, urlStack = [], f
|
|
44768
44812
|
return modulePromise;
|
44769
44813
|
}
|
44770
44814
|
async function instantiateModule(url, server, context = { global }, urlStack = [], fixStacktrace) {
|
44771
|
-
const
|
44815
|
+
const environment = server.environments.ssr;
|
44816
|
+
const moduleGraph = environment.moduleGraph;
|
44772
44817
|
const mod = await moduleGraph.ensureEntryFromUrl(url);
|
44773
44818
|
if (mod.ssrError) {
|
44774
44819
|
throw mod.ssrError;
|
@@ -44776,7 +44821,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
44776
44821
|
if (mod.ssrModule) {
|
44777
44822
|
return mod.ssrModule;
|
44778
44823
|
}
|
44779
|
-
const result = mod.transformResult || (await
|
44824
|
+
const result = mod.transformResult || (await environment.transformRequest(url));
|
44780
44825
|
if (!result) {
|
44781
44826
|
// TODO more info? is this even necessary?
|
44782
44827
|
throw new Error(`failed to load module for ssr: ${url}`);
|
@@ -44798,8 +44843,8 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
44798
44843
|
};
|
44799
44844
|
urlStack = urlStack.concat(url);
|
44800
44845
|
const isCircular = (url) => urlStack.includes(url);
|
44801
|
-
const { isProduction,
|
44802
|
-
const externalConditions =
|
44846
|
+
const { isProduction, root } = server.config;
|
44847
|
+
const { externalConditions, dedupe, preserveSymlinks } = environment.options.resolve;
|
44803
44848
|
const resolveOptions = {
|
44804
44849
|
mainFields: ['main'],
|
44805
44850
|
conditions: [],
|
@@ -44813,7 +44858,6 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
44813
44858
|
isBuild: false,
|
44814
44859
|
isProduction,
|
44815
44860
|
root,
|
44816
|
-
ssrConfig: ssr,
|
44817
44861
|
legacyProxySsrExternalModules: server.config.legacy?.proxySsrExternalModules,
|
44818
44862
|
packageCache: server.config.packageCache,
|
44819
44863
|
};
|
@@ -51849,6 +51893,30 @@ var Writable = require$$0$7.Writable;
|
|
51849
51893
|
var assert = require$$5;
|
51850
51894
|
var debug$a = debug_1;
|
51851
51895
|
|
51896
|
+
// Whether to use the native URL object or the legacy url module
|
51897
|
+
var useNativeURL = false;
|
51898
|
+
try {
|
51899
|
+
assert(new URL$1());
|
51900
|
+
}
|
51901
|
+
catch (error) {
|
51902
|
+
useNativeURL = error.code === "ERR_INVALID_URL";
|
51903
|
+
}
|
51904
|
+
|
51905
|
+
// URL fields to preserve in copy operations
|
51906
|
+
var preservedUrlFields = [
|
51907
|
+
"auth",
|
51908
|
+
"host",
|
51909
|
+
"hostname",
|
51910
|
+
"href",
|
51911
|
+
"path",
|
51912
|
+
"pathname",
|
51913
|
+
"port",
|
51914
|
+
"protocol",
|
51915
|
+
"query",
|
51916
|
+
"search",
|
51917
|
+
"hash",
|
51918
|
+
];
|
51919
|
+
|
51852
51920
|
// Create handlers that pass events from native requests
|
51853
51921
|
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
|
51854
51922
|
var eventHandlers = Object.create(null);
|
@@ -51859,13 +51927,19 @@ events.forEach(function (event) {
|
|
51859
51927
|
});
|
51860
51928
|
|
51861
51929
|
// Error types with codes
|
51930
|
+
var InvalidUrlError = createErrorType(
|
51931
|
+
"ERR_INVALID_URL",
|
51932
|
+
"Invalid URL",
|
51933
|
+
TypeError
|
51934
|
+
);
|
51862
51935
|
var RedirectionError = createErrorType(
|
51863
51936
|
"ERR_FR_REDIRECTION_FAILURE",
|
51864
51937
|
"Redirected request failed"
|
51865
51938
|
);
|
51866
51939
|
var TooManyRedirectsError = createErrorType(
|
51867
51940
|
"ERR_FR_TOO_MANY_REDIRECTS",
|
51868
|
-
"Maximum number of redirects exceeded"
|
51941
|
+
"Maximum number of redirects exceeded",
|
51942
|
+
RedirectionError
|
51869
51943
|
);
|
51870
51944
|
var MaxBodyLengthExceededError = createErrorType(
|
51871
51945
|
"ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
|
@@ -51876,6 +51950,9 @@ var WriteAfterEndError = createErrorType(
|
|
51876
51950
|
"write after end"
|
51877
51951
|
);
|
51878
51952
|
|
51953
|
+
// istanbul ignore next
|
51954
|
+
var destroy = Writable.prototype.destroy || noop$2;
|
51955
|
+
|
51879
51956
|
// An HTTP(S) request that can be redirected
|
51880
51957
|
function RedirectableRequest(options, responseCallback) {
|
51881
51958
|
// Initialize the request
|
@@ -51897,7 +51974,13 @@ function RedirectableRequest(options, responseCallback) {
|
|
51897
51974
|
// React to responses of native requests
|
51898
51975
|
var self = this;
|
51899
51976
|
this._onNativeResponse = function (response) {
|
51900
|
-
|
51977
|
+
try {
|
51978
|
+
self._processResponse(response);
|
51979
|
+
}
|
51980
|
+
catch (cause) {
|
51981
|
+
self.emit("error", cause instanceof RedirectionError ?
|
51982
|
+
cause : new RedirectionError({ cause: cause }));
|
51983
|
+
}
|
51901
51984
|
};
|
51902
51985
|
|
51903
51986
|
// Perform the first request
|
@@ -51906,10 +51989,17 @@ function RedirectableRequest(options, responseCallback) {
|
|
51906
51989
|
RedirectableRequest.prototype = Object.create(Writable.prototype);
|
51907
51990
|
|
51908
51991
|
RedirectableRequest.prototype.abort = function () {
|
51909
|
-
|
51992
|
+
destroyRequest(this._currentRequest);
|
51993
|
+
this._currentRequest.abort();
|
51910
51994
|
this.emit("abort");
|
51911
51995
|
};
|
51912
51996
|
|
51997
|
+
RedirectableRequest.prototype.destroy = function (error) {
|
51998
|
+
destroyRequest(this._currentRequest, error);
|
51999
|
+
destroy.call(this, error);
|
52000
|
+
return this;
|
52001
|
+
};
|
52002
|
+
|
51913
52003
|
// Writes buffered data to the current native request
|
51914
52004
|
RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
51915
52005
|
// Writing is not allowed if end has been called
|
@@ -51918,10 +52008,10 @@ RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
|
51918
52008
|
}
|
51919
52009
|
|
51920
52010
|
// Validate input and shift parameters if necessary
|
51921
|
-
if (!(
|
52011
|
+
if (!isString(data) && !isBuffer(data)) {
|
51922
52012
|
throw new TypeError("data should be a string, Buffer or Uint8Array");
|
51923
52013
|
}
|
51924
|
-
if (
|
52014
|
+
if (isFunction(encoding)) {
|
51925
52015
|
callback = encoding;
|
51926
52016
|
encoding = null;
|
51927
52017
|
}
|
@@ -51950,11 +52040,11 @@ RedirectableRequest.prototype.write = function (data, encoding, callback) {
|
|
51950
52040
|
// Ends the current native request
|
51951
52041
|
RedirectableRequest.prototype.end = function (data, encoding, callback) {
|
51952
52042
|
// Shift parameters if necessary
|
51953
|
-
if (
|
52043
|
+
if (isFunction(data)) {
|
51954
52044
|
callback = data;
|
51955
52045
|
data = encoding = null;
|
51956
52046
|
}
|
51957
|
-
else if (
|
52047
|
+
else if (isFunction(encoding)) {
|
51958
52048
|
callback = encoding;
|
51959
52049
|
encoding = null;
|
51960
52050
|
}
|
@@ -52022,6 +52112,7 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
|
52022
52112
|
self.removeListener("abort", clearTimer);
|
52023
52113
|
self.removeListener("error", clearTimer);
|
52024
52114
|
self.removeListener("response", clearTimer);
|
52115
|
+
self.removeListener("close", clearTimer);
|
52025
52116
|
if (callback) {
|
52026
52117
|
self.removeListener("timeout", callback);
|
52027
52118
|
}
|
@@ -52048,6 +52139,7 @@ RedirectableRequest.prototype.setTimeout = function (msecs, callback) {
|
|
52048
52139
|
this.on("abort", clearTimer);
|
52049
52140
|
this.on("error", clearTimer);
|
52050
52141
|
this.on("response", clearTimer);
|
52142
|
+
this.on("close", clearTimer);
|
52051
52143
|
|
52052
52144
|
return this;
|
52053
52145
|
};
|
@@ -52106,8 +52198,7 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
52106
52198
|
var protocol = this._options.protocol;
|
52107
52199
|
var nativeProtocol = this._options.nativeProtocols[protocol];
|
52108
52200
|
if (!nativeProtocol) {
|
52109
|
-
|
52110
|
-
return;
|
52201
|
+
throw new TypeError("Unsupported protocol " + protocol);
|
52111
52202
|
}
|
52112
52203
|
|
52113
52204
|
// If specified, use the agent corresponding to the protocol
|
@@ -52117,21 +52208,26 @@ RedirectableRequest.prototype._performRequest = function () {
|
|
52117
52208
|
this._options.agent = this._options.agents[scheme];
|
52118
52209
|
}
|
52119
52210
|
|
52120
|
-
// Create the native request
|
52211
|
+
// Create the native request and set up its event handlers
|
52121
52212
|
var request = this._currentRequest =
|
52122
52213
|
nativeProtocol.request(this._options, this._onNativeResponse);
|
52123
|
-
this._currentUrl = url.format(this._options);
|
52124
|
-
|
52125
|
-
// Set up event handlers
|
52126
52214
|
request._redirectable = this;
|
52127
|
-
for (var
|
52128
|
-
request.on(
|
52215
|
+
for (var event of events) {
|
52216
|
+
request.on(event, eventHandlers[event]);
|
52129
52217
|
}
|
52130
52218
|
|
52219
|
+
// RFC7230§5.3.1: When making a request directly to an origin server, […]
|
52220
|
+
// a client MUST send only the absolute path […] as the request-target.
|
52221
|
+
this._currentUrl = /^\//.test(this._options.path) ?
|
52222
|
+
url.format(this._options) :
|
52223
|
+
// When making a request to a proxy, […]
|
52224
|
+
// a client MUST send the target URI in absolute-form […].
|
52225
|
+
this._options.path;
|
52226
|
+
|
52131
52227
|
// End a redirected request
|
52132
52228
|
// (The first request must be ended explicitly with RedirectableRequest#end)
|
52133
52229
|
if (this._isRedirect) {
|
52134
|
-
// Write the request entity and end
|
52230
|
+
// Write the request entity and end
|
52135
52231
|
var i = 0;
|
52136
52232
|
var self = this;
|
52137
52233
|
var buffers = this._requestBodyBuffers;
|
@@ -52194,15 +52290,14 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
52194
52290
|
}
|
52195
52291
|
|
52196
52292
|
// The response is a redirect, so abort the current request
|
52197
|
-
|
52293
|
+
destroyRequest(this._currentRequest);
|
52198
52294
|
// Discard the remainder of the response to avoid waiting for data
|
52199
52295
|
response.destroy();
|
52200
52296
|
|
52201
52297
|
// RFC7231§6.4: A client SHOULD detect and intervene
|
52202
52298
|
// in cyclical redirections (i.e., "infinite" redirection loops).
|
52203
52299
|
if (++this._redirectCount > this._options.maxRedirects) {
|
52204
|
-
|
52205
|
-
return;
|
52300
|
+
throw new TooManyRedirectsError();
|
52206
52301
|
}
|
52207
52302
|
|
52208
52303
|
// Store the request headers if applicable
|
@@ -52236,38 +52331,28 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
52236
52331
|
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
52237
52332
|
|
52238
52333
|
// If the redirect is relative, carry over the host of the last request
|
52239
|
-
var currentUrlParts =
|
52334
|
+
var currentUrlParts = parseUrl(this._currentUrl);
|
52240
52335
|
var currentHost = currentHostHeader || currentUrlParts.host;
|
52241
52336
|
var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
|
52242
52337
|
url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
52243
52338
|
|
52244
|
-
// Determine the URL of the redirection
|
52245
|
-
var redirectUrl;
|
52246
|
-
try {
|
52247
|
-
redirectUrl = url.resolve(currentUrl, location);
|
52248
|
-
}
|
52249
|
-
catch (cause) {
|
52250
|
-
this.emit("error", new RedirectionError(cause));
|
52251
|
-
return;
|
52252
|
-
}
|
52253
|
-
|
52254
52339
|
// Create the redirected request
|
52255
|
-
|
52340
|
+
var redirectUrl = resolveUrl(location, currentUrl);
|
52341
|
+
debug$a("redirecting to", redirectUrl.href);
|
52256
52342
|
this._isRedirect = true;
|
52257
|
-
|
52258
|
-
Object.assign(this._options, redirectUrlParts);
|
52343
|
+
spreadUrlObject(redirectUrl, this._options);
|
52259
52344
|
|
52260
52345
|
// Drop confidential headers when redirecting to a less secure protocol
|
52261
52346
|
// or to a different domain that is not a superdomain
|
52262
|
-
if (
|
52263
|
-
|
52264
|
-
|
52265
|
-
!isSubdomain(
|
52266
|
-
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
52347
|
+
if (redirectUrl.protocol !== currentUrlParts.protocol &&
|
52348
|
+
redirectUrl.protocol !== "https:" ||
|
52349
|
+
redirectUrl.host !== currentHost &&
|
52350
|
+
!isSubdomain(redirectUrl.host, currentHost)) {
|
52351
|
+
removeMatchingHeaders(/^(?:(?:proxy-)?authorization|cookie)$/i, this._options.headers);
|
52267
52352
|
}
|
52268
52353
|
|
52269
52354
|
// Evaluate the beforeRedirect callback
|
52270
|
-
if (
|
52355
|
+
if (isFunction(beforeRedirect)) {
|
52271
52356
|
var responseDetails = {
|
52272
52357
|
headers: response.headers,
|
52273
52358
|
statusCode: statusCode,
|
@@ -52277,23 +52362,12 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
52277
52362
|
method: method,
|
52278
52363
|
headers: requestHeaders,
|
52279
52364
|
};
|
52280
|
-
|
52281
|
-
beforeRedirect(this._options, responseDetails, requestDetails);
|
52282
|
-
}
|
52283
|
-
catch (err) {
|
52284
|
-
this.emit("error", err);
|
52285
|
-
return;
|
52286
|
-
}
|
52365
|
+
beforeRedirect(this._options, responseDetails, requestDetails);
|
52287
52366
|
this._sanitizeOptions(this._options);
|
52288
52367
|
}
|
52289
52368
|
|
52290
52369
|
// Perform the redirected request
|
52291
|
-
|
52292
|
-
this._performRequest();
|
52293
|
-
}
|
52294
|
-
catch (cause) {
|
52295
|
-
this.emit("error", new RedirectionError(cause));
|
52296
|
-
}
|
52370
|
+
this._performRequest();
|
52297
52371
|
};
|
52298
52372
|
|
52299
52373
|
// Wraps the key/value object of protocols with redirect functionality
|
@@ -52313,26 +52387,19 @@ function wrap(protocols) {
|
|
52313
52387
|
|
52314
52388
|
// Executes a request, following redirects
|
52315
52389
|
function request(input, options, callback) {
|
52316
|
-
// Parse parameters
|
52317
|
-
if (
|
52318
|
-
|
52319
|
-
try {
|
52320
|
-
input = urlToOptions(new URL$1(urlStr));
|
52321
|
-
}
|
52322
|
-
catch (err) {
|
52323
|
-
/* istanbul ignore next */
|
52324
|
-
input = url.parse(urlStr);
|
52325
|
-
}
|
52390
|
+
// Parse parameters, ensuring that input is an object
|
52391
|
+
if (isURL(input)) {
|
52392
|
+
input = spreadUrlObject(input);
|
52326
52393
|
}
|
52327
|
-
else if (
|
52328
|
-
input =
|
52394
|
+
else if (isString(input)) {
|
52395
|
+
input = spreadUrlObject(parseUrl(input));
|
52329
52396
|
}
|
52330
52397
|
else {
|
52331
52398
|
callback = options;
|
52332
|
-
options = input;
|
52399
|
+
options = validateUrl(input);
|
52333
52400
|
input = { protocol: protocol };
|
52334
52401
|
}
|
52335
|
-
if (
|
52402
|
+
if (isFunction(options)) {
|
52336
52403
|
callback = options;
|
52337
52404
|
options = null;
|
52338
52405
|
}
|
@@ -52343,6 +52410,9 @@ function wrap(protocols) {
|
|
52343
52410
|
maxBodyLength: exports.maxBodyLength,
|
52344
52411
|
}, input, options);
|
52345
52412
|
options.nativeProtocols = nativeProtocols;
|
52413
|
+
if (!isString(options.host) && !isString(options.hostname)) {
|
52414
|
+
options.hostname = "::1";
|
52415
|
+
}
|
52346
52416
|
|
52347
52417
|
assert.equal(options.protocol, protocol, "protocol mismatch");
|
52348
52418
|
debug$a("options", options);
|
@@ -52365,27 +52435,57 @@ function wrap(protocols) {
|
|
52365
52435
|
return exports;
|
52366
52436
|
}
|
52367
52437
|
|
52368
|
-
/* istanbul ignore next */
|
52369
52438
|
function noop$2() { /* empty */ }
|
52370
52439
|
|
52371
|
-
|
52372
|
-
|
52373
|
-
|
52374
|
-
|
52375
|
-
|
52376
|
-
/* istanbul ignore next */
|
52377
|
-
urlObject.hostname.slice(1, -1) :
|
52378
|
-
urlObject.hostname,
|
52379
|
-
hash: urlObject.hash,
|
52380
|
-
search: urlObject.search,
|
52381
|
-
pathname: urlObject.pathname,
|
52382
|
-
path: urlObject.pathname + urlObject.search,
|
52383
|
-
href: urlObject.href,
|
52384
|
-
};
|
52385
|
-
if (urlObject.port !== "") {
|
52386
|
-
options.port = Number(urlObject.port);
|
52440
|
+
function parseUrl(input) {
|
52441
|
+
var parsed;
|
52442
|
+
/* istanbul ignore else */
|
52443
|
+
if (useNativeURL) {
|
52444
|
+
parsed = new URL$1(input);
|
52387
52445
|
}
|
52388
|
-
|
52446
|
+
else {
|
52447
|
+
// Ensure the URL is valid and absolute
|
52448
|
+
parsed = validateUrl(url.parse(input));
|
52449
|
+
if (!isString(parsed.protocol)) {
|
52450
|
+
throw new InvalidUrlError({ input });
|
52451
|
+
}
|
52452
|
+
}
|
52453
|
+
return parsed;
|
52454
|
+
}
|
52455
|
+
|
52456
|
+
function resolveUrl(relative, base) {
|
52457
|
+
/* istanbul ignore next */
|
52458
|
+
return useNativeURL ? new URL$1(relative, base) : parseUrl(url.resolve(base, relative));
|
52459
|
+
}
|
52460
|
+
|
52461
|
+
function validateUrl(input) {
|
52462
|
+
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
52463
|
+
throw new InvalidUrlError({ input: input.href || input });
|
52464
|
+
}
|
52465
|
+
if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
|
52466
|
+
throw new InvalidUrlError({ input: input.href || input });
|
52467
|
+
}
|
52468
|
+
return input;
|
52469
|
+
}
|
52470
|
+
|
52471
|
+
function spreadUrlObject(urlObject, target) {
|
52472
|
+
var spread = target || {};
|
52473
|
+
for (var key of preservedUrlFields) {
|
52474
|
+
spread[key] = urlObject[key];
|
52475
|
+
}
|
52476
|
+
|
52477
|
+
// Fix IPv6 hostname
|
52478
|
+
if (spread.hostname.startsWith("[")) {
|
52479
|
+
spread.hostname = spread.hostname.slice(1, -1);
|
52480
|
+
}
|
52481
|
+
// Ensure port is a number
|
52482
|
+
if (spread.port !== "") {
|
52483
|
+
spread.port = Number(spread.port);
|
52484
|
+
}
|
52485
|
+
// Concatenate path
|
52486
|
+
spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
|
52487
|
+
|
52488
|
+
return spread;
|
52389
52489
|
}
|
52390
52490
|
|
52391
52491
|
function removeMatchingHeaders(regex, headers) {
|
@@ -52400,37 +52500,60 @@ function removeMatchingHeaders(regex, headers) {
|
|
52400
52500
|
undefined : String(lastValue).trim();
|
52401
52501
|
}
|
52402
52502
|
|
52403
|
-
function createErrorType(code,
|
52404
|
-
|
52503
|
+
function createErrorType(code, message, baseClass) {
|
52504
|
+
// Create constructor
|
52505
|
+
function CustomError(properties) {
|
52405
52506
|
Error.captureStackTrace(this, this.constructor);
|
52406
|
-
|
52407
|
-
|
52408
|
-
|
52409
|
-
else {
|
52410
|
-
this.message = defaultMessage + ": " + cause.message;
|
52411
|
-
this.cause = cause;
|
52412
|
-
}
|
52507
|
+
Object.assign(this, properties || {});
|
52508
|
+
this.code = code;
|
52509
|
+
this.message = this.cause ? message + ": " + this.cause.message : message;
|
52413
52510
|
}
|
52414
|
-
|
52415
|
-
|
52416
|
-
CustomError.prototype
|
52417
|
-
CustomError.prototype
|
52511
|
+
|
52512
|
+
// Attach constructor and set default properties
|
52513
|
+
CustomError.prototype = new (baseClass || Error)();
|
52514
|
+
Object.defineProperties(CustomError.prototype, {
|
52515
|
+
constructor: {
|
52516
|
+
value: CustomError,
|
52517
|
+
enumerable: false,
|
52518
|
+
},
|
52519
|
+
name: {
|
52520
|
+
value: "Error [" + code + "]",
|
52521
|
+
enumerable: false,
|
52522
|
+
},
|
52523
|
+
});
|
52418
52524
|
return CustomError;
|
52419
52525
|
}
|
52420
52526
|
|
52421
|
-
function
|
52422
|
-
for (var
|
52423
|
-
request.removeListener(
|
52527
|
+
function destroyRequest(request, error) {
|
52528
|
+
for (var event of events) {
|
52529
|
+
request.removeListener(event, eventHandlers[event]);
|
52424
52530
|
}
|
52425
52531
|
request.on("error", noop$2);
|
52426
|
-
request.
|
52532
|
+
request.destroy(error);
|
52427
52533
|
}
|
52428
52534
|
|
52429
52535
|
function isSubdomain(subdomain, domain) {
|
52430
|
-
|
52536
|
+
assert(isString(subdomain) && isString(domain));
|
52537
|
+
var dot = subdomain.length - domain.length - 1;
|
52431
52538
|
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
52432
52539
|
}
|
52433
52540
|
|
52541
|
+
function isString(value) {
|
52542
|
+
return typeof value === "string" || value instanceof String;
|
52543
|
+
}
|
52544
|
+
|
52545
|
+
function isFunction(value) {
|
52546
|
+
return typeof value === "function";
|
52547
|
+
}
|
52548
|
+
|
52549
|
+
function isBuffer(value) {
|
52550
|
+
return typeof value === "object" && ("length" in value);
|
52551
|
+
}
|
52552
|
+
|
52553
|
+
function isURL(value) {
|
52554
|
+
return URL$1 && value instanceof URL$1;
|
52555
|
+
}
|
52556
|
+
|
52434
52557
|
// Exports
|
52435
52558
|
followRedirects$1.exports = wrap({ http: http$1, https: https$1 });
|
52436
52559
|
followRedirects$1.exports.wrap = wrap;
|
@@ -53877,7 +54000,7 @@ function transformRequest(url, server, options = {}, environment) {
|
|
53877
54000
|
// Backward compatibility
|
53878
54001
|
options = { ...options, ssr: environment.name !== 'client' };
|
53879
54002
|
}
|
53880
|
-
if (server._restartPromise &&
|
54003
|
+
if (server._restartPromise && environment?.options.dev.recoverable)
|
53881
54004
|
throwClosedServerError();
|
53882
54005
|
// We could have a cache per environment instead of the global _pendingRequests
|
53883
54006
|
const cacheKey = `${options.html ? 'html:' : ''}${environment.name}:${url}`;
|
@@ -54019,7 +54142,8 @@ async function loadAndTransform(environment, id, url, server, options, timestamp
|
|
54019
54142
|
// as string
|
54020
54143
|
// only try the fallback if access is allowed, skip for out of root url
|
54021
54144
|
// like /service-worker.js or /api/users
|
54022
|
-
if (options.
|
54145
|
+
if (environment.options.nodeCompatible ||
|
54146
|
+
isFileServingAllowed(file, server)) {
|
54023
54147
|
try {
|
54024
54148
|
code = await fsp.readFile(file, 'utf-8');
|
54025
54149
|
debugLoad?.(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
|
@@ -54078,7 +54202,7 @@ async function loadAndTransform(environment, id, url, server, options, timestamp
|
|
54078
54202
|
err.code = isPublicFile ? ERR_LOAD_PUBLIC_URL : ERR_LOAD_URL;
|
54079
54203
|
throw err;
|
54080
54204
|
}
|
54081
|
-
if (server._restartPromise &&
|
54205
|
+
if (server._restartPromise && environment.options.dev.recoverable)
|
54082
54206
|
throwClosedServerError();
|
54083
54207
|
// ensure module in graph after successful load
|
54084
54208
|
mod ??= await moduleGraph._ensureEntryFromUrl(url, undefined, resolved);
|
@@ -54132,7 +54256,7 @@ async function loadAndTransform(environment, id, url, server, options, timestamp
|
|
54132
54256
|
}
|
54133
54257
|
}
|
54134
54258
|
}
|
54135
|
-
if (server._restartPromise &&
|
54259
|
+
if (server._restartPromise && environment.options.dev.recoverable)
|
54136
54260
|
throwClosedServerError();
|
54137
54261
|
const result = ssr && !server.config.experimental.skipSsrTransform
|
54138
54262
|
? await server.ssrTransform(code, normalizedMap, url, originalCode)
|
@@ -54220,7 +54344,7 @@ async function handleModuleSoftInvalidation(environment, mod, timestamp, server)
|
|
54220
54344
|
|
54221
54345
|
// Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
|
54222
54346
|
// License: MIT.
|
54223
|
-
var Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
54347
|
+
var HashbangComment, Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
|
54224
54348
|
RegularExpressionLiteral = /\/(?![*\/])(?:\[(?:[^\]\\\n\r\u2028\u2029]+|\\.)*\]|[^\/\\\n\r\u2028\u2029]+|\\.)*(\/[$_\u200C\u200D\p{ID_Continue}]*|\\)?/yu;
|
54225
54349
|
Punctuator = /--|\+\+|=>|\.{3}|\??\.(?!\d)|(?:&&|\|\||\?\?|[+\-%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2}|\/(?![\/*]))=?|[?~,:;[\](){}]/y;
|
54226
54350
|
Identifier = /(\x23?)(?=[$_\p{ID_Start}\\])(?:[$_\u200C\u200D\p{ID_Continue}]+|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+/yu;
|
@@ -54231,6 +54355,7 @@ WhiteSpace = /[\t\v\f\ufeff\p{Zs}]+/yu;
|
|
54231
54355
|
LineTerminatorSequence = /\r?\n|[\r\u2028\u2029]/y;
|
54232
54356
|
MultiLineComment = /\/\*(?:[^*]+|\*(?!\/))*(\*\/)?/y;
|
54233
54357
|
SingleLineComment = /\/\/.*/y;
|
54358
|
+
HashbangComment = /^#!.*/;
|
54234
54359
|
JSXPunctuator = /[<>.:={}]|\/(?![\/*])/y;
|
54235
54360
|
JSXIdentifier = /[$_\p{ID_Start}][$_\u200C\u200D\p{ID_Continue}-]*/yu;
|
54236
54361
|
JSXString = /(['"])(?:[^'"]+|(?!\1)['"])*(\1)?/y;
|
@@ -54251,6 +54376,13 @@ var jsTokens_1 = function*(input, {jsx = false} = {}) {
|
|
54251
54376
|
braces = [];
|
54252
54377
|
parenNesting = 0;
|
54253
54378
|
postfixIncDec = false;
|
54379
|
+
if (match = HashbangComment.exec(input)) {
|
54380
|
+
yield ({
|
54381
|
+
type: "HashbangComment",
|
54382
|
+
value: match[0]
|
54383
|
+
});
|
54384
|
+
lastIndex = match[0].length;
|
54385
|
+
}
|
54254
54386
|
while (lastIndex < length) {
|
54255
54387
|
mode = stack[stack.length - 1];
|
54256
54388
|
switch (mode.tag) {
|
@@ -54626,6 +54758,10 @@ function stripLiteralJsTokens(code, options) {
|
|
54626
54758
|
continue;
|
54627
54759
|
}
|
54628
54760
|
if (token.type === "StringLiteral") {
|
54761
|
+
if (!token.closed) {
|
54762
|
+
result += token.value;
|
54763
|
+
continue;
|
54764
|
+
}
|
54629
54765
|
const body = token.value.slice(1, -1);
|
54630
54766
|
if (filter(body)) {
|
54631
54767
|
result += token.value[0] + FILL.repeat(body.length) + token.value[token.value.length - 1];
|
@@ -55523,7 +55659,10 @@ function injectNonceAttributeTagHook(config) {
|
|
55523
55659
|
(node.nodeName === 'link' &&
|
55524
55660
|
node.attrs.some((attr) => attr.name === 'rel' &&
|
55525
55661
|
parseRelAttr(attr.value).some((a) => processRelType.has(a))))) {
|
55526
|
-
|
55662
|
+
// if the closing of the start tag includes a `/`, the offset should be 2 so the nonce
|
55663
|
+
// is appended prior to the `/`
|
55664
|
+
const appendOffset = html[node.sourceCodeLocation.startTag.endOffset - 2] === '/' ? 2 : 1;
|
55665
|
+
s.appendRight(node.sourceCodeLocation.startTag.endOffset - appendOffset, ` nonce="${nonce}"`);
|
55527
55666
|
}
|
55528
55667
|
});
|
55529
55668
|
return s.toString();
|
@@ -56836,8 +56975,8 @@ async function fetchModule(environment, url, importer, options = {}) {
|
|
56836
56975
|
return { externalize: url, type: 'network' };
|
56837
56976
|
}
|
56838
56977
|
if (url[0] !== '.' && url[0] !== '/') {
|
56839
|
-
const { isProduction,
|
56840
|
-
const externalConditions =
|
56978
|
+
const { isProduction, root } = environment.config;
|
56979
|
+
const { externalConditions, dedupe, preserveSymlinks } = environment.options.resolve;
|
56841
56980
|
const resolveOptions = {
|
56842
56981
|
mainFields: ['main'],
|
56843
56982
|
conditions: [],
|
@@ -56851,7 +56990,6 @@ async function fetchModule(environment, url, importer, options = {}) {
|
|
56851
56990
|
isBuild: false,
|
56852
56991
|
isProduction,
|
56853
56992
|
root,
|
56854
|
-
ssrConfig: ssr,
|
56855
56993
|
packageCache: environment.config.packageCache,
|
56856
56994
|
};
|
56857
56995
|
const resolved = tryNodeResolve(url, importer, {
|
@@ -58203,20 +58341,20 @@ async function _createServer(inlineConfig = {}, options) {
|
|
58203
58341
|
// Create Environments
|
58204
58342
|
const client_createEnvironment = config.environments.client?.dev?.createEnvironment ??
|
58205
58343
|
((server, name) => new DevEnvironment(server, name, { hot: ws }));
|
58206
|
-
environments.client = client_createEnvironment(server, 'client');
|
58344
|
+
environments.client = await client_createEnvironment(server, 'client');
|
58207
58345
|
const ssr_createEnvironment = config.environments.ssr?.dev?.createEnvironment ??
|
58208
58346
|
((server, name) => createNodeDevEnvironment(server, name, { hot: ssrHotChannel }));
|
58209
|
-
environments.ssr = ssr_createEnvironment(server, 'ssr');
|
58210
|
-
Object.entries(config.environments)
|
58347
|
+
environments.ssr = await ssr_createEnvironment(server, 'ssr');
|
58348
|
+
for (const [name, EnvironmentOptions] of Object.entries(config.environments)) {
|
58211
58349
|
// TODO: move client and ssr inside the loop?
|
58212
58350
|
if (name !== 'client' && name !== 'ssr') {
|
58213
58351
|
const createEnvironment = EnvironmentOptions.dev?.createEnvironment ??
|
58214
58352
|
((server, name) => new DevEnvironment(server, name, {
|
58215
58353
|
hot: ws, // TODO: what should we use here?
|
58216
58354
|
}));
|
58217
|
-
environments[name] = createEnvironment(server, name);
|
58355
|
+
environments[name] = await createEnvironment(server, name);
|
58218
58356
|
}
|
58219
|
-
}
|
58357
|
+
}
|
58220
58358
|
if (!middlewareMode) {
|
58221
58359
|
exitProcess = async () => {
|
58222
58360
|
try {
|
@@ -59334,8 +59472,8 @@ function createIsConfiguredAsExternal(environment) {
|
|
59334
59472
|
isProduction: false,
|
59335
59473
|
isBuild: true,
|
59336
59474
|
conditions: targetConditions,
|
59337
|
-
webCompatible:
|
59338
|
-
nodeCompatible:
|
59475
|
+
webCompatible: options.webCompatible,
|
59476
|
+
nodeCompatible: options.nodeCompatible,
|
59339
59477
|
};
|
59340
59478
|
const isExternalizable = (id, importer, configuredAsExternal) => {
|
59341
59479
|
if (!bareImportRE.test(id) || id.includes('\0')) {
|
@@ -59534,6 +59672,23 @@ async function replaceDefine(code, id, define, config) {
|
|
59534
59672
|
sourcefile: id,
|
59535
59673
|
sourcemap: config.command === 'build' ? !!config.build.sourcemap : true,
|
59536
59674
|
});
|
59675
|
+
// remove esbuild's <define:...> source entries
|
59676
|
+
// since they would confuse source map remapping/collapsing which expects a single source
|
59677
|
+
if (result.map.includes('<define:')) {
|
59678
|
+
const originalMap = new TraceMap(result.map);
|
59679
|
+
if (originalMap.sources.length >= 2) {
|
59680
|
+
const sourceIndex = originalMap.sources.indexOf(id);
|
59681
|
+
const decoded = decodedMap(originalMap);
|
59682
|
+
decoded.sources = [id];
|
59683
|
+
decoded.mappings = decoded.mappings.map((segments) => segments.filter((segment) => {
|
59684
|
+
// modify and filter
|
59685
|
+
const index = segment[1];
|
59686
|
+
segment[1] = 0;
|
59687
|
+
return index === sourceIndex;
|
59688
|
+
}));
|
59689
|
+
result.map = JSON.stringify(encodedMap(new TraceMap(decoded)));
|
59690
|
+
}
|
59691
|
+
}
|
59537
59692
|
for (const marker in replacementMarkers) {
|
59538
59693
|
result.code = result.code.replaceAll(marker, replacementMarkers[marker]);
|
59539
59694
|
}
|
@@ -59989,6 +60144,7 @@ function preAliasPlugin(config) {
|
|
59989
60144
|
},
|
59990
60145
|
};
|
59991
60146
|
}
|
60147
|
+
// TODO: ?
|
59992
60148
|
function optimizeAliasReplacementForSSR(id, optimizeDeps) {
|
59993
60149
|
if (optimizeDeps.include?.includes(id)) {
|
59994
60150
|
return true;
|
@@ -60959,7 +61115,6 @@ function workerImportMetaUrlPlugin(config) {
|
|
60959
61115
|
isProduction: config.isProduction,
|
60960
61116
|
isBuild: config.command === 'build',
|
60961
61117
|
packageCache: config.packageCache,
|
60962
|
-
ssrConfig: config.ssr,
|
60963
61118
|
asSrc: true,
|
60964
61119
|
};
|
60965
61120
|
return {
|
@@ -61050,7 +61205,6 @@ function assetImportMetaUrlPlugin(config) {
|
|
61050
61205
|
isProduction: config.isProduction,
|
61051
61206
|
isBuild: config.command === 'build',
|
61052
61207
|
packageCache: config.packageCache,
|
61053
|
-
ssrConfig: config.ssr,
|
61054
61208
|
asSrc: true,
|
61055
61209
|
};
|
61056
61210
|
return {
|
@@ -62239,7 +62393,6 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
62239
62393
|
isProduction: config.isProduction,
|
62240
62394
|
isBuild,
|
62241
62395
|
packageCache: config.packageCache,
|
62242
|
-
ssrConfig: config.ssr,
|
62243
62396
|
asSrc: true,
|
62244
62397
|
fsUtils: getFsUtils(config),
|
62245
62398
|
optimizeDeps: true,
|
@@ -62813,7 +62966,7 @@ async function createPluginContainer(config, watcher, environments) {
|
|
62813
62966
|
let id = null;
|
62814
62967
|
const partial = {};
|
62815
62968
|
for (const plugin of getSortedPlugins('resolveId')) {
|
62816
|
-
if (closed &&
|
62969
|
+
if (closed && environment?.options.dev.recoverable)
|
62817
62970
|
throwClosedServerError();
|
62818
62971
|
if (!plugin.resolveId)
|
62819
62972
|
continue;
|
@@ -62864,7 +63017,7 @@ async function createPluginContainer(config, watcher, environments) {
|
|
62864
63017
|
ctx.ssr = !!ssr;
|
62865
63018
|
ctx.environment = environment;
|
62866
63019
|
for (const plugin of getSortedPlugins('load')) {
|
62867
|
-
if (closed &&
|
63020
|
+
if (closed && environment?.options.dev.recoverable)
|
62868
63021
|
throwClosedServerError();
|
62869
63022
|
if (!plugin.load)
|
62870
63023
|
continue;
|
@@ -62889,7 +63042,7 @@ async function createPluginContainer(config, watcher, environments) {
|
|
62889
63042
|
ctx.ssr = !!ssr;
|
62890
63043
|
ctx.environment = environment;
|
62891
63044
|
for (const plugin of getSortedPlugins('transform')) {
|
62892
|
-
if (closed &&
|
63045
|
+
if (closed && environment?.options.dev.recoverable)
|
62893
63046
|
throwClosedServerError();
|
62894
63047
|
if (!plugin.transform)
|
62895
63048
|
continue;
|
@@ -63494,7 +63647,6 @@ function createOptimizeDepsIncludeResolver(environment) {
|
|
63494
63647
|
asSrc: false,
|
63495
63648
|
scan: true,
|
63496
63649
|
ssrOptimizeCheck: environment.name !== 'client',
|
63497
|
-
ssrConfig: config.ssr,
|
63498
63650
|
packageCache: new Map(),
|
63499
63651
|
});
|
63500
63652
|
return async (id) => {
|
@@ -63802,9 +63954,13 @@ function runOptimizeDeps(environment, depsInfo) {
|
|
63802
63954
|
// No need to wait, we can clean up in the background because temp folders
|
63803
63955
|
// are unique per run
|
63804
63956
|
debug$2?.(colors$1.green(`removing cache dir ${processingCacheDir}`));
|
63805
|
-
|
63957
|
+
try {
|
63958
|
+
// When exiting the process, `fsp.rm` may not take effect, so we use `fs.rmSync`
|
63959
|
+
fs$l.rmSync(processingCacheDir, { recursive: true, force: true });
|
63960
|
+
}
|
63961
|
+
catch (error) {
|
63806
63962
|
// Ignore errors
|
63807
|
-
}
|
63963
|
+
}
|
63808
63964
|
}
|
63809
63965
|
};
|
63810
63966
|
const successfulResult = {
|
@@ -65830,6 +65986,7 @@ function cssPostPlugin(config) {
|
|
65830
65986
|
for (const file in bundle) {
|
65831
65987
|
const chunk = bundle[file];
|
65832
65988
|
if (chunk.type === 'chunk') {
|
65989
|
+
let chunkImportsPureCssChunk = false;
|
65833
65990
|
// remove pure css chunk from other chunk's imports,
|
65834
65991
|
// and also register the emitted CSS files under the importer
|
65835
65992
|
// chunks instead.
|
@@ -65838,11 +65995,14 @@ function cssPostPlugin(config) {
|
|
65838
65995
|
const { importedCss, importedAssets } = bundle[file].viteMetadata;
|
65839
65996
|
importedCss.forEach((file) => chunk.viteMetadata.importedCss.add(file));
|
65840
65997
|
importedAssets.forEach((file) => chunk.viteMetadata.importedAssets.add(file));
|
65998
|
+
chunkImportsPureCssChunk = true;
|
65841
65999
|
return false;
|
65842
66000
|
}
|
65843
66001
|
return true;
|
65844
66002
|
});
|
65845
|
-
|
66003
|
+
if (chunkImportsPureCssChunk) {
|
66004
|
+
chunk.code = replaceEmptyChunk(chunk.code);
|
66005
|
+
}
|
65846
66006
|
}
|
65847
66007
|
}
|
65848
66008
|
const removedPureCssFiles = removedPureCssFilesCache.get(config);
|
@@ -66245,8 +66405,8 @@ function createCachedImport(imp) {
|
|
66245
66405
|
return cached;
|
66246
66406
|
};
|
66247
66407
|
}
|
66248
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
66249
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
66408
|
+
const importPostcssImport = createCachedImport(() => import('./dep-DPzWXNBe.js').then(function (n) { return n.i; }));
|
66409
|
+
const importPostcssModules = createCachedImport(() => import('./dep-BD8Vf02W.js').then(function (n) { return n.i; }));
|
66250
66410
|
const importPostcss = createCachedImport(() => import('postcss'));
|
66251
66411
|
const preprocessorWorkerControllerCache = new WeakMap();
|
66252
66412
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -67635,13 +67795,7 @@ function buildImportAnalysisPlugin(config) {
|
|
67635
67795
|
const fileDepsCode = `[${fileDeps
|
67636
67796
|
.map((fileDep) => fileDep.runtime ? fileDep.url : JSON.stringify(fileDep.url))
|
67637
67797
|
.join(',')}]`;
|
67638
|
-
const mapDepsCode =
|
67639
|
-
function __vite__mapDeps(indexes) {
|
67640
|
-
if (!__vite__mapDeps.viteFileDeps) {
|
67641
|
-
__vite__mapDeps.viteFileDeps = ${fileDepsCode}
|
67642
|
-
}
|
67643
|
-
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
67644
|
-
}\n`;
|
67798
|
+
const mapDepsCode = `const __vite__fileDeps=${fileDepsCode},__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);\n`;
|
67645
67799
|
// inject extra code at the top or next line of hashbang
|
67646
67800
|
if (code.startsWith('#!')) {
|
67647
67801
|
s.prependLeft(code.indexOf('\n') + 1, mapDepsCode);
|
@@ -67817,37 +67971,39 @@ function completeSystemWrapPlugin() {
|
|
67817
67971
|
};
|
67818
67972
|
}
|
67819
67973
|
|
67820
|
-
function resolveBuildOptions(raw, logger, root
|
67974
|
+
function resolveBuildOptions(raw, logger, root) {
|
67975
|
+
const libMode = raw.lib ?? false;
|
67976
|
+
const buildOptions = resolveBuildEnvironmentOptions(raw, logger, root, undefined, libMode);
|
67977
|
+
return { ...buildOptions, lib: libMode };
|
67978
|
+
}
|
67979
|
+
function resolveBuildEnvironmentOptions(raw, logger, root, environmentName, libMode = false) {
|
67821
67980
|
const deprecatedPolyfillModulePreload = raw?.polyfillModulePreload;
|
67822
|
-
|
67823
|
-
|
67824
|
-
|
67825
|
-
|
67826
|
-
logger.warn('polyfillModulePreload is deprecated. Use modulePreload.polyfill instead.');
|
67827
|
-
}
|
67828
|
-
if (deprecatedPolyfillModulePreload === false &&
|
67829
|
-
raw.modulePreload === undefined) {
|
67830
|
-
raw.modulePreload = { polyfill: false };
|
67831
|
-
}
|
67981
|
+
const { polyfillModulePreload, ...rest } = raw;
|
67982
|
+
raw = rest;
|
67983
|
+
if (deprecatedPolyfillModulePreload !== undefined) {
|
67984
|
+
logger.warn('polyfillModulePreload is deprecated. Use modulePreload.polyfill instead.');
|
67832
67985
|
}
|
67833
|
-
|
67986
|
+
if (deprecatedPolyfillModulePreload === false &&
|
67987
|
+
raw.modulePreload === undefined) {
|
67988
|
+
raw.modulePreload = { polyfill: false };
|
67989
|
+
}
|
67990
|
+
const modulePreload = raw.modulePreload;
|
67834
67991
|
const defaultModulePreload = {
|
67835
67992
|
polyfill: true,
|
67836
67993
|
};
|
67837
|
-
const
|
67994
|
+
const defaultBuildEnvironmentOptions = {
|
67838
67995
|
outDir: 'dist',
|
67839
67996
|
assetsDir: 'assets',
|
67840
67997
|
assetsInlineLimit: DEFAULT_ASSETS_INLINE_LIMIT,
|
67841
|
-
cssCodeSplit: !
|
67998
|
+
cssCodeSplit: !libMode,
|
67842
67999
|
sourcemap: false,
|
67843
68000
|
rollupOptions: {},
|
67844
|
-
minify: raw
|
68001
|
+
minify: raw.ssr ? false : 'esbuild',
|
67845
68002
|
terserOptions: {},
|
67846
68003
|
write: true,
|
67847
68004
|
emptyOutDir: null,
|
67848
68005
|
copyPublicDir: true,
|
67849
68006
|
manifest: false,
|
67850
|
-
lib: false,
|
67851
68007
|
ssr: false,
|
67852
68008
|
ssrManifest: false,
|
67853
68009
|
ssrEmitAssets: false,
|
@@ -67856,23 +68012,23 @@ function resolveBuildOptions(raw, logger, root, environmentName) {
|
|
67856
68012
|
chunkSizeWarningLimit: 500,
|
67857
68013
|
watch: null,
|
67858
68014
|
};
|
67859
|
-
const
|
67860
|
-
? mergeConfig(
|
67861
|
-
:
|
68015
|
+
const userBuildEnvironmentOptions = raw
|
68016
|
+
? mergeConfig(defaultBuildEnvironmentOptions, raw)
|
68017
|
+
: defaultBuildEnvironmentOptions;
|
67862
68018
|
// @ts-expect-error Fallback options instead of merging
|
67863
68019
|
const resolved = {
|
67864
68020
|
target: 'modules',
|
67865
68021
|
cssTarget: false,
|
67866
|
-
...
|
68022
|
+
...userBuildEnvironmentOptions,
|
67867
68023
|
commonjsOptions: {
|
67868
68024
|
include: [/node_modules/],
|
67869
68025
|
extensions: ['.js', '.cjs'],
|
67870
|
-
...
|
68026
|
+
...userBuildEnvironmentOptions.commonjsOptions,
|
67871
68027
|
},
|
67872
68028
|
dynamicImportVarsOptions: {
|
67873
68029
|
warnOnError: true,
|
67874
68030
|
exclude: [/node_modules/],
|
67875
|
-
...
|
68031
|
+
...userBuildEnvironmentOptions.dynamicImportVarsOptions,
|
67876
68032
|
},
|
67877
68033
|
// Resolve to false | object
|
67878
68034
|
modulePreload: modulePreload === false
|
@@ -67950,17 +68106,27 @@ async function resolveBuildPlugins(config) {
|
|
67950
68106
|
*/
|
67951
68107
|
async function build(inlineConfig = {}) {
|
67952
68108
|
const builder = await createViteBuilder({}, { ...inlineConfig, plugins: () => inlineConfig.plugins ?? [] });
|
67953
|
-
|
67954
|
-
|
67955
|
-
|
68109
|
+
if (builder.config.build.lib) {
|
68110
|
+
// TODO: temporal workaround. Should we support `libraries: Record<string, LibraryOptions & EnvironmentOptions>`
|
68111
|
+
// to build multiple libraries and be able to target different environments (for example for a Svelte components
|
68112
|
+
// library generating both client and SSR builds)?
|
68113
|
+
return buildEnvironment(builder.config, builder.environments.client, builder.config.build.lib);
|
68114
|
+
}
|
68115
|
+
else {
|
68116
|
+
const ssr = !!builder.config.build.ssr;
|
68117
|
+
const environment = builder.environments[ssr ? 'ssr' : 'client'];
|
68118
|
+
return builder.build(environment);
|
68119
|
+
}
|
67956
68120
|
}
|
67957
68121
|
function resolveConfigToBuild(inlineConfig = {}) {
|
67958
68122
|
return resolveConfig(inlineConfig, 'build', 'production', 'production');
|
67959
68123
|
}
|
67960
|
-
|
68124
|
+
/**
|
68125
|
+
* Build an App environment, or a App library (if librayOptions is provided)
|
68126
|
+
**/
|
68127
|
+
async function buildEnvironment(config, environment, libOptions = false) {
|
67961
68128
|
const options = config.build;
|
67962
68129
|
const ssr = environment.name !== 'client';
|
67963
|
-
const libOptions = options.lib;
|
67964
68130
|
config.logger.info(colors$1.cyan(`vite v${VERSION} ${colors$1.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
|
67965
68131
|
const resolve = (p) => path$o.resolve(config.root, p);
|
67966
68132
|
const input = libOptions
|
@@ -68044,6 +68210,7 @@ async function buildEnvironment(config, environment) {
|
|
68044
68210
|
`Please use "build.sourcemap" instead.`));
|
68045
68211
|
}
|
68046
68212
|
/**
|
68213
|
+
* TODO:
|
68047
68214
|
* if (ssr.target === 'webworker') {
|
68048
68215
|
* build.rollupOptions.entryFileNames = '[name].js'
|
68049
68216
|
* build.rollupOptions.inlineDynamicImports = (typeof input === 'string' || Object.keys(input).length === 1))
|
@@ -68591,7 +68758,7 @@ async function createViteBuilder(builderOptions = {}, defaultBuilderInlineConfig
|
|
68591
68758
|
// plugins are built to handle multiple environments concurrently).
|
68592
68759
|
const environmentConfig = await resolveConfig(environmentOptions);
|
68593
68760
|
const environmentBuilder = { ...builder, config: environmentConfig };
|
68594
|
-
const environment = createEnvironment(environmentBuilder, name);
|
68761
|
+
const environment = await createEnvironment(environmentBuilder, name);
|
68595
68762
|
environments[name] = environment;
|
68596
68763
|
}
|
68597
68764
|
return builder;
|
@@ -68606,6 +68773,7 @@ var build$1 = {
|
|
68606
68773
|
createViteBuilder: createViteBuilder,
|
68607
68774
|
injectEnvironmentToHooks: injectEnvironmentToHooks,
|
68608
68775
|
onRollupWarning: onRollupWarning,
|
68776
|
+
resolveBuildEnvironmentOptions: resolveBuildEnvironmentOptions,
|
68609
68777
|
resolveBuildOptions: resolveBuildOptions,
|
68610
68778
|
resolveBuildOutputs: resolveBuildOutputs,
|
68611
68779
|
resolveBuildPlugins: resolveBuildPlugins,
|
@@ -68753,7 +68921,8 @@ function resolvePreviewOptions(preview, server) {
|
|
68753
68921
|
*/
|
68754
68922
|
async function preview(inlineConfig = {}) {
|
68755
68923
|
const config = await resolveConfig(inlineConfig, 'serve', 'production', 'production', true);
|
68756
|
-
const
|
68924
|
+
const clientOutDir = config.environments.client.build.outDir ?? config.build.outDir;
|
68925
|
+
const distDir = path$o.resolve(config.root, clientOutDir);
|
68757
68926
|
if (!fs$l.existsSync(distDir) &&
|
68758
68927
|
// error if no plugins implement `configurePreviewServer`
|
68759
68928
|
config.plugins.every((plugin) => !plugin.configurePreviewServer) &&
|
@@ -68761,7 +68930,7 @@ async function preview(inlineConfig = {}) {
|
|
68761
68930
|
// and affect file serving
|
68762
68931
|
process.argv[1]?.endsWith(path$o.normalize('bin/vite.js')) &&
|
68763
68932
|
process.argv[2] === 'preview') {
|
68764
|
-
throw new Error(`The directory "${
|
68933
|
+
throw new Error(`The directory "${clientOutDir}" does not exist. Did you build your project?`);
|
68765
68934
|
}
|
68766
68935
|
const app = connect$1();
|
68767
68936
|
const httpServer = await resolveHttpServer(config.preview, app, await resolveHttpsConfig(config.preview?.https));
|
@@ -68885,7 +69054,7 @@ const promisifiedRealpath = promisify$4(fs$l.realpath);
|
|
68885
69054
|
function defineConfig(config) {
|
68886
69055
|
return config;
|
68887
69056
|
}
|
68888
|
-
function
|
69057
|
+
function resolveDevEnvironmentOptions(dev, preserverSymlinks, environmentName) {
|
68889
69058
|
return {
|
68890
69059
|
sourcemap: dev?.sourcemap ?? { js: true },
|
68891
69060
|
sourcemapIgnoreList: dev?.sourcemapIgnoreList === false
|
@@ -68897,6 +69066,7 @@ function resolveDevOptions(dev, preserverSymlinks) {
|
|
68897
69066
|
},
|
68898
69067
|
optimizeDeps: resolveOptimizeDepsConfig(dev?.optimizeDeps, preserverSymlinks),
|
68899
69068
|
createEnvironment: dev?.createEnvironment,
|
69069
|
+
recoverable: dev?.recoverable ?? environmentName === 'client',
|
68900
69070
|
};
|
68901
69071
|
}
|
68902
69072
|
function resolveEnvironmentOptions(config, resolvedRoot, logger, environmentName) {
|
@@ -68905,8 +69075,8 @@ function resolveEnvironmentOptions(config, resolvedRoot, logger, environmentName
|
|
68905
69075
|
resolve,
|
68906
69076
|
nodeCompatible: config.nodeCompatible ?? environmentName !== 'client',
|
68907
69077
|
webCompatible: config.webCompatible ?? environmentName === 'client',
|
68908
|
-
dev:
|
68909
|
-
build:
|
69078
|
+
dev: resolveDevEnvironmentOptions(config.dev, resolve.preserveSymlinks, environmentName),
|
69079
|
+
build: resolveBuildEnvironmentOptions(config.build ?? {}, logger, resolvedRoot, environmentName),
|
68910
69080
|
};
|
68911
69081
|
}
|
68912
69082
|
function getDefaultEnvironmentOptions(config) {
|
@@ -69119,8 +69289,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
69119
69289
|
...patchedOptimizeDeps.esbuildOptions,
|
69120
69290
|
},
|
69121
69291
|
};
|
69122
|
-
|
69123
|
-
const
|
69292
|
+
// TODO: Deprecate and remove resolve, dev and build options at the root level of the resolved config
|
69293
|
+
const resolvedDevEnvironmentOptions = resolveDevEnvironmentOptions(config.dev, resolvedDefaultEnvironmentResolve.preserveSymlinks, undefined);
|
69294
|
+
const resolvedBuildOptions = resolveBuildOptions(config.build ?? {}, logger, resolvedRoot);
|
69124
69295
|
// Backward compatibility: merge config.environments.ssr back into config.ssr
|
69125
69296
|
// so ecosystem SSR plugins continue to work if only environments.ssr is configured
|
69126
69297
|
const patchedConfigSsr = {
|
@@ -69275,10 +69446,11 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
69275
69446
|
},
|
69276
69447
|
// Backward compatibility, users should use environment.config.dev.optimizeDeps
|
69277
69448
|
optimizeDeps: backwardCompatibleOptimizeDeps,
|
69449
|
+
ssr,
|
69450
|
+
// TODO: deprecate and later remove from ResolvedConfig?
|
69278
69451
|
resolve: resolvedDefaultEnvironmentResolve,
|
69279
|
-
dev:
|
69452
|
+
dev: resolvedDevEnvironmentOptions,
|
69280
69453
|
build: resolvedBuildOptions,
|
69281
|
-
ssr,
|
69282
69454
|
environments: resolvedEnvironments,
|
69283
69455
|
getSortedPlugins: undefined,
|
69284
69456
|
getSortedPluginHooks: undefined,
|
@@ -69352,13 +69524,6 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
69352
69524
|
},
|
69353
69525
|
});
|
69354
69526
|
// validate config
|
69355
|
-
if (config.build?.terserOptions &&
|
69356
|
-
config.build.minify &&
|
69357
|
-
config.build.minify !== 'terser') {
|
69358
|
-
logger.warn(colors$1.yellow(`build.terserOptions is specified but build.minify is not set to use Terser. ` +
|
69359
|
-
`Note Vite now defaults to use esbuild for minification. If you still ` +
|
69360
|
-
`prefer Terser, set build.minify to "terser".`));
|
69361
|
-
}
|
69362
69527
|
// Check if all assetFileNames have the same reference.
|
69363
69528
|
// If not, display a warn for user.
|
69364
69529
|
const outputOption = config.build?.rollupOptions?.output ?? [];
|