vite 3.0.0-alpha.11 → 3.0.0-alpha.14
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/LICENSE.md +57 -0
- package/bin/vite.js +1 -1
- package/dist/client/client.mjs +40 -8
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-17430d09.js → dep-58d622b1.js} +5 -5
- package/dist/node/chunks/{dep-d6e255b8.js → dep-92497830.js} +4 -4
- package/dist/node/chunks/{dep-46501b7a.js → dep-dc88b587.js} +1316 -723
- package/dist/node/chunks/{dep-4e458630.js → dep-e88a0dff.js} +7 -7
- package/dist/node/chunks/dep-e8ca8d40.js +3 -3
- package/dist/node/chunks/{dep-fb927717.js → dep-f75aea7c.js} +21 -10
- package/dist/node/cli.js +24 -12
- package/dist/node/constants.js +3 -3
- package/dist/node/index.d.ts +141 -44
- package/dist/node/index.js +20 -8
- package/dist/node-cjs/publicUtils.cjs +36 -25
- package/package.json +7 -6
- package/src/client/client.ts +83 -21
- package/types/chokidar.d.ts +2 -2
- package/types/connect.d.ts +1 -1
- package/types/hot.d.ts +17 -3
- package/types/http-proxy.d.ts +5 -5
- package/types/ws.d.ts +6 -6
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import require$$0$
|
|
7
|
-
import require$$0$2 from 'tty';
|
|
1
|
+
import fs$n, { promises as promises$2 } from 'node:fs';
|
|
2
|
+
import path$q, { resolve as resolve$5, join as join$2, posix as posix$2, isAbsolute as isAbsolute$4, relative as relative$1, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
|
|
3
|
+
import { URL as URL$3, pathToFileURL, URLSearchParams, parse as parse$m } from 'node:url';
|
|
4
|
+
import { performance } from 'node:perf_hooks';
|
|
5
|
+
import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
|
6
|
+
import require$$0$3 from 'tty';
|
|
8
7
|
import { transform as transform$2, build as build$3, formatMessages } from 'esbuild';
|
|
9
|
-
import
|
|
10
|
-
import require$$
|
|
8
|
+
import path$p, { sep, resolve as resolve$4, posix as posix$1, dirname as dirname$1, extname, basename as basename$1, join as join$1, win32 as win32$1, isAbsolute as isAbsolute$3, normalize } from 'path';
|
|
9
|
+
import * as require$$0$2 from 'fs';
|
|
10
|
+
import require$$0__default, { readFileSync, existsSync, statSync as statSync$1, promises as promises$1, readdirSync } from 'fs';
|
|
11
|
+
import require$$0$4 from 'events';
|
|
12
|
+
import assert$3 from 'assert';
|
|
11
13
|
import __resolve from 'resolve';
|
|
12
|
-
import require$$0$
|
|
14
|
+
import require$$0$5, { format as format$2, inspect } from 'util';
|
|
13
15
|
import require$$3$1 from 'net';
|
|
14
|
-
import require$$
|
|
15
|
-
import require$$
|
|
16
|
+
import require$$0$9, { pathToFileURL as pathToFileURL$1 } from 'url';
|
|
17
|
+
import require$$1$3 from 'http';
|
|
18
|
+
import require$$0$6 from 'stream';
|
|
16
19
|
import require$$1 from 'os';
|
|
17
|
-
import require$$2
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
+
import require$$2 from 'child_process';
|
|
21
|
+
import os$3 from 'node:os';
|
|
22
|
+
import { createHash as createHash$2 } from 'node:crypto';
|
|
23
|
+
import { promisify as promisify$4 } from 'node:util';
|
|
24
|
+
import { promises } from 'node:dns';
|
|
20
25
|
import { CLIENT_ENTRY, DEFAULT_EXTENSIONS as DEFAULT_EXTENSIONS$1, VALID_ID_PREFIX, FS_PREFIX, wildcardHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, loopbackHosts, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, KNOWN_ASSET_TYPES, JS_TYPES_RE, CLIENT_DIR, NULL_BYTE_PLACEHOLDER, VERSION, VITE_PACKAGE_DIR, ENV_ENTRY, DEFAULT_ASSETS_RE } from '../constants.js';
|
|
21
|
-
import require$$
|
|
26
|
+
import require$$1$2 from 'crypto';
|
|
27
|
+
import require$$0$7 from 'buffer';
|
|
22
28
|
import * as qs from 'querystring';
|
|
23
|
-
import
|
|
24
|
-
import require$$
|
|
29
|
+
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
|
30
|
+
import require$$0$a from 'zlib';
|
|
31
|
+
import require$$1$4 from 'https';
|
|
25
32
|
import require$$4 from 'tls';
|
|
33
|
+
import { STATUS_CODES } from 'node:http';
|
|
34
|
+
import { createServer as createServer$2 } from 'node:https';
|
|
26
35
|
import require$$1$1 from 'worker_threads';
|
|
27
36
|
import readline from 'readline';
|
|
37
|
+
import { execSync } from 'node:child_process';
|
|
38
|
+
import zlib$1, { gzip } from 'node:zlib';
|
|
28
39
|
|
|
29
|
-
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
30
|
-
import { dirname as __cjs_dirname } from 'path';
|
|
31
|
-
import { createRequire as __cjs_createRequire } from 'module';
|
|
40
|
+
import { fileURLToPath as __cjs_fileURLToPath } from 'node:url';
|
|
41
|
+
import { dirname as __cjs_dirname } from 'node:path';
|
|
42
|
+
import { createRequire as __cjs_createRequire } from 'node:module';
|
|
32
43
|
|
|
33
44
|
const __filename = __cjs_fileURLToPath(import.meta.url);
|
|
34
45
|
const __dirname = __cjs_dirname(__filename);
|
|
@@ -57,7 +68,7 @@ function getAugmentedNamespace(n) {
|
|
|
57
68
|
|
|
58
69
|
var picocolors = {exports: {}};
|
|
59
70
|
|
|
60
|
-
let tty = require$$0$
|
|
71
|
+
let tty = require$$0$3;
|
|
61
72
|
|
|
62
73
|
let isColorSupported =
|
|
63
74
|
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
@@ -2648,8 +2659,8 @@ var old$1 = {};
|
|
|
2648
2659
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2649
2660
|
|
|
2650
2661
|
var pathModule = path$p;
|
|
2651
|
-
var isWindows$
|
|
2652
|
-
var fs$m =
|
|
2662
|
+
var isWindows$5 = process.platform === 'win32';
|
|
2663
|
+
var fs$m = require$$0__default;
|
|
2653
2664
|
|
|
2654
2665
|
// JavaScript implementation of realpath, ported from node pre-v6
|
|
2655
2666
|
|
|
@@ -2696,14 +2707,14 @@ function maybeCallback(cb) {
|
|
|
2696
2707
|
|
|
2697
2708
|
// Regexp that finds the next partion of a (partial) path
|
|
2698
2709
|
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
|
2699
|
-
if (isWindows$
|
|
2710
|
+
if (isWindows$5) {
|
|
2700
2711
|
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
|
2701
2712
|
} else {
|
|
2702
2713
|
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
|
2703
2714
|
}
|
|
2704
2715
|
|
|
2705
2716
|
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
|
2706
|
-
if (isWindows$
|
|
2717
|
+
if (isWindows$5) {
|
|
2707
2718
|
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
|
2708
2719
|
} else {
|
|
2709
2720
|
var splitRootRe = /^[\/]*/;
|
|
@@ -2741,7 +2752,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
|
2741
2752
|
previous = '';
|
|
2742
2753
|
|
|
2743
2754
|
// On windows, check that the root exists. On unix there is no need.
|
|
2744
|
-
if (isWindows$
|
|
2755
|
+
if (isWindows$5 && !knownHard[base]) {
|
|
2745
2756
|
fs$m.lstatSync(base);
|
|
2746
2757
|
knownHard[base] = true;
|
|
2747
2758
|
}
|
|
@@ -2779,7 +2790,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
|
2779
2790
|
// read the link if it wasn't read before
|
|
2780
2791
|
// dev/ino always return 0 on windows, so skip the check.
|
|
2781
2792
|
var linkTarget = null;
|
|
2782
|
-
if (!isWindows$
|
|
2793
|
+
if (!isWindows$5) {
|
|
2783
2794
|
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
|
2784
2795
|
if (seenLinks.hasOwnProperty(id)) {
|
|
2785
2796
|
linkTarget = seenLinks[id];
|
|
@@ -2792,7 +2803,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
|
2792
2803
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
|
2793
2804
|
// track this, if given a cache.
|
|
2794
2805
|
if (cache) cache[base] = resolvedLink;
|
|
2795
|
-
if (!isWindows$
|
|
2806
|
+
if (!isWindows$5) seenLinks[id] = linkTarget;
|
|
2796
2807
|
}
|
|
2797
2808
|
|
|
2798
2809
|
// resolve the link, then start over
|
|
@@ -2843,7 +2854,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
|
2843
2854
|
previous = '';
|
|
2844
2855
|
|
|
2845
2856
|
// On windows, check that the root exists. On unix there is no need.
|
|
2846
|
-
if (isWindows$
|
|
2857
|
+
if (isWindows$5 && !knownHard[base]) {
|
|
2847
2858
|
fs$m.lstat(base, function(err) {
|
|
2848
2859
|
if (err) return cb(err);
|
|
2849
2860
|
knownHard[base] = true;
|
|
@@ -2897,7 +2908,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
|
2897
2908
|
// stat & read the link if not read before
|
|
2898
2909
|
// call gotTarget as soon as the link target is known
|
|
2899
2910
|
// dev/ino always return 0 on windows, so skip the check.
|
|
2900
|
-
if (!isWindows$
|
|
2911
|
+
if (!isWindows$5) {
|
|
2901
2912
|
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
|
2902
2913
|
if (seenLinks.hasOwnProperty(id)) {
|
|
2903
2914
|
return gotTarget(null, seenLinks[id], base);
|
|
@@ -2907,7 +2918,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
|
2907
2918
|
if (err) return cb(err);
|
|
2908
2919
|
|
|
2909
2920
|
fs$m.readlink(base, function(err, target) {
|
|
2910
|
-
if (!isWindows$
|
|
2921
|
+
if (!isWindows$5) seenLinks[id] = target;
|
|
2911
2922
|
gotTarget(err, target);
|
|
2912
2923
|
});
|
|
2913
2924
|
});
|
|
@@ -2935,7 +2946,7 @@ realpath$2.realpathSync = realpathSync;
|
|
|
2935
2946
|
realpath$2.monkeypatch = monkeypatch;
|
|
2936
2947
|
realpath$2.unmonkeypatch = unmonkeypatch;
|
|
2937
2948
|
|
|
2938
|
-
var fs$l =
|
|
2949
|
+
var fs$l = require$$0__default;
|
|
2939
2950
|
var origRealpath = fs$l.realpath;
|
|
2940
2951
|
var origRealpathSync = fs$l.realpathSync;
|
|
2941
2952
|
|
|
@@ -4292,7 +4303,7 @@ function ownProp$2 (obj, field) {
|
|
|
4292
4303
|
return Object.prototype.hasOwnProperty.call(obj, field)
|
|
4293
4304
|
}
|
|
4294
4305
|
|
|
4295
|
-
var fs$k =
|
|
4306
|
+
var fs$k = require$$0__default;
|
|
4296
4307
|
var path$k = path$p;
|
|
4297
4308
|
var minimatch$2 = minimatch_1;
|
|
4298
4309
|
var isAbsolute$2 = pathIsAbsolute.exports;
|
|
@@ -4523,7 +4534,7 @@ globSync$1.GlobSync = GlobSync$1;
|
|
|
4523
4534
|
var rp$1 = fs_realpath;
|
|
4524
4535
|
var minimatch$1 = minimatch_1;
|
|
4525
4536
|
var path$j = path$p;
|
|
4526
|
-
var assert$2 =
|
|
4537
|
+
var assert$2 = assert$3;
|
|
4527
4538
|
var isAbsolute$1 = pathIsAbsolute.exports;
|
|
4528
4539
|
var common$d = common$e;
|
|
4529
4540
|
var setopts$1 = common$d.setopts;
|
|
@@ -5173,9 +5184,9 @@ var glob_1 = glob;
|
|
|
5173
5184
|
var rp = fs_realpath;
|
|
5174
5185
|
var minimatch = minimatch_1;
|
|
5175
5186
|
var inherits = inherits$1.exports;
|
|
5176
|
-
var EE = require$$0$
|
|
5187
|
+
var EE = require$$0$4.EventEmitter;
|
|
5177
5188
|
var path$i = path$p;
|
|
5178
|
-
var assert$1 =
|
|
5189
|
+
var assert$1 = assert$3;
|
|
5179
5190
|
var isAbsolute = pathIsAbsolute.exports;
|
|
5180
5191
|
var globSync = sync$c;
|
|
5181
5192
|
var common$c = common$e;
|
|
@@ -10785,8 +10796,8 @@ var node$1 = {exports: {}};
|
|
|
10785
10796
|
*/
|
|
10786
10797
|
|
|
10787
10798
|
(function (module, exports) {
|
|
10788
|
-
const tty = require$$0$
|
|
10789
|
-
const util = require$$0$
|
|
10799
|
+
const tty = require$$0$3;
|
|
10800
|
+
const util = require$$0$5;
|
|
10790
10801
|
|
|
10791
10802
|
/**
|
|
10792
10803
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -11312,17 +11323,17 @@ function testCaseInsensitiveFS() {
|
|
|
11312
11323
|
if (!CLIENT_ENTRY.endsWith('client.mjs')) {
|
|
11313
11324
|
throw new Error(`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`);
|
|
11314
11325
|
}
|
|
11315
|
-
if (!
|
|
11326
|
+
if (!fs$n.existsSync(CLIENT_ENTRY)) {
|
|
11316
11327
|
throw new Error('cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: ' +
|
|
11317
11328
|
CLIENT_ENTRY);
|
|
11318
11329
|
}
|
|
11319
|
-
return
|
|
11330
|
+
return fs$n.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
|
|
11320
11331
|
}
|
|
11321
11332
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
|
11322
|
-
const isWindows$
|
|
11333
|
+
const isWindows$4 = os$3.platform() === 'win32';
|
|
11323
11334
|
const VOLUME_RE = /^[A-Z]:/i;
|
|
11324
11335
|
function normalizePath$3(id) {
|
|
11325
|
-
return path$
|
|
11336
|
+
return path$q.posix.normalize(isWindows$4 ? slash$1(id) : id);
|
|
11326
11337
|
}
|
|
11327
11338
|
function fsPathFromId(id) {
|
|
11328
11339
|
const fsPath = normalizePath$3(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
|
|
@@ -11350,7 +11361,7 @@ function isParentDirectory(dir, file) {
|
|
|
11350
11361
|
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
|
11351
11362
|
}
|
|
11352
11363
|
function ensureVolumeInPath(file) {
|
|
11353
|
-
return isWindows$
|
|
11364
|
+
return isWindows$4 ? path$q.resolve(file) : file;
|
|
11354
11365
|
}
|
|
11355
11366
|
const queryRE = /\?.*$/s;
|
|
11356
11367
|
const hashRE = /#.*$/s;
|
|
@@ -11367,7 +11378,7 @@ const isJSRequest = (url) => {
|
|
|
11367
11378
|
if (knownJsSrcRE.test(url)) {
|
|
11368
11379
|
return true;
|
|
11369
11380
|
}
|
|
11370
|
-
if (!path$
|
|
11381
|
+
if (!path$q.extname(url) && !url.endsWith('/')) {
|
|
11371
11382
|
return true;
|
|
11372
11383
|
}
|
|
11373
11384
|
return false;
|
|
@@ -11416,9 +11427,6 @@ const timestampRE = /\bt=\d{13}&?\b/;
|
|
|
11416
11427
|
function removeTimestampQuery(url) {
|
|
11417
11428
|
return url.replace(timestampRE, '').replace(trailingSeparatorRE, '');
|
|
11418
11429
|
}
|
|
11419
|
-
function isRelativeBase(base) {
|
|
11420
|
-
return base === '' || base.startsWith('.');
|
|
11421
|
-
}
|
|
11422
11430
|
async function asyncReplace(input, re, replacer) {
|
|
11423
11431
|
let match;
|
|
11424
11432
|
let remaining = input;
|
|
@@ -11451,7 +11459,7 @@ function prettifyUrl(url, root) {
|
|
|
11451
11459
|
url = removeTimestampQuery(url);
|
|
11452
11460
|
const isAbsoluteFile = url.startsWith(root);
|
|
11453
11461
|
if (isAbsoluteFile || url.startsWith(FS_PREFIX)) {
|
|
11454
|
-
let file = path$
|
|
11462
|
+
let file = path$q.relative(root, isAbsoluteFile ? url : fsPathFromId(url));
|
|
11455
11463
|
const seg = file.split('/');
|
|
11456
11464
|
const npmIndex = seg.indexOf(`node_modules`);
|
|
11457
11465
|
const isSourceMap = file.endsWith('.map');
|
|
@@ -11476,12 +11484,12 @@ function isDefined(value) {
|
|
|
11476
11484
|
}
|
|
11477
11485
|
function lookupFile(dir, formats, options) {
|
|
11478
11486
|
for (const format of formats) {
|
|
11479
|
-
const fullPath = path$
|
|
11480
|
-
if (
|
|
11481
|
-
return options?.pathOnly ? fullPath :
|
|
11487
|
+
const fullPath = path$q.join(dir, format);
|
|
11488
|
+
if (fs$n.existsSync(fullPath) && fs$n.statSync(fullPath).isFile()) {
|
|
11489
|
+
return options?.pathOnly ? fullPath : fs$n.readFileSync(fullPath, 'utf-8');
|
|
11482
11490
|
}
|
|
11483
11491
|
}
|
|
11484
|
-
const parentDir = path$
|
|
11492
|
+
const parentDir = path$q.dirname(dir);
|
|
11485
11493
|
if (parentDir !== dir &&
|
|
11486
11494
|
(!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
|
|
11487
11495
|
return lookupFile(parentDir, formats, options);
|
|
@@ -11561,11 +11569,11 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
11561
11569
|
return res.join('\n');
|
|
11562
11570
|
}
|
|
11563
11571
|
function writeFile(filename, content) {
|
|
11564
|
-
const dir = path$
|
|
11565
|
-
if (!
|
|
11566
|
-
|
|
11572
|
+
const dir = path$q.dirname(filename);
|
|
11573
|
+
if (!fs$n.existsSync(dir)) {
|
|
11574
|
+
fs$n.mkdirSync(dir, { recursive: true });
|
|
11567
11575
|
}
|
|
11568
|
-
|
|
11576
|
+
fs$n.writeFileSync(filename, content);
|
|
11569
11577
|
}
|
|
11570
11578
|
/**
|
|
11571
11579
|
* Use fs.statSync(filename) instead of fs.existsSync(filename)
|
|
@@ -11575,7 +11583,7 @@ function writeFile(filename, content) {
|
|
|
11575
11583
|
*/
|
|
11576
11584
|
function isFileReadable(filename) {
|
|
11577
11585
|
try {
|
|
11578
|
-
const stat =
|
|
11586
|
+
const stat = fs$n.statSync(filename, { throwIfNoEntry: false });
|
|
11579
11587
|
return !!stat;
|
|
11580
11588
|
}
|
|
11581
11589
|
catch {
|
|
@@ -11587,45 +11595,45 @@ function isFileReadable(filename) {
|
|
|
11587
11595
|
* Pass an optional `skip` array to preserve files in the root directory.
|
|
11588
11596
|
*/
|
|
11589
11597
|
function emptyDir(dir, skip) {
|
|
11590
|
-
for (const file of
|
|
11598
|
+
for (const file of fs$n.readdirSync(dir)) {
|
|
11591
11599
|
if (skip?.includes(file)) {
|
|
11592
11600
|
continue;
|
|
11593
11601
|
}
|
|
11594
|
-
|
|
11602
|
+
fs$n.rmSync(path$q.resolve(dir, file), { recursive: true, force: true });
|
|
11595
11603
|
}
|
|
11596
11604
|
}
|
|
11597
11605
|
function copyDir(srcDir, destDir) {
|
|
11598
|
-
|
|
11599
|
-
for (const file of
|
|
11600
|
-
const srcFile = path$
|
|
11606
|
+
fs$n.mkdirSync(destDir, { recursive: true });
|
|
11607
|
+
for (const file of fs$n.readdirSync(srcDir)) {
|
|
11608
|
+
const srcFile = path$q.resolve(srcDir, file);
|
|
11601
11609
|
if (srcFile === destDir) {
|
|
11602
11610
|
continue;
|
|
11603
11611
|
}
|
|
11604
|
-
const destFile = path$
|
|
11605
|
-
const stat =
|
|
11612
|
+
const destFile = path$q.resolve(destDir, file);
|
|
11613
|
+
const stat = fs$n.statSync(srcFile);
|
|
11606
11614
|
if (stat.isDirectory()) {
|
|
11607
11615
|
copyDir(srcFile, destFile);
|
|
11608
11616
|
}
|
|
11609
11617
|
else {
|
|
11610
|
-
|
|
11618
|
+
fs$n.copyFileSync(srcFile, destFile);
|
|
11611
11619
|
}
|
|
11612
11620
|
}
|
|
11613
11621
|
}
|
|
11614
|
-
const removeDir = isWindows$
|
|
11622
|
+
const removeDir = isWindows$4
|
|
11615
11623
|
? promisify$4(gracefulRemoveDir)
|
|
11616
11624
|
: function removeDirSync(dir) {
|
|
11617
|
-
|
|
11625
|
+
fs$n.rmSync(dir, { recursive: true, force: true });
|
|
11618
11626
|
};
|
|
11619
|
-
const renameDir = isWindows$
|
|
11627
|
+
const renameDir = isWindows$4 ? promisify$4(gracefulRename) : fs$n.renameSync;
|
|
11620
11628
|
function ensureWatchedFile(watcher, file, root) {
|
|
11621
11629
|
if (file &&
|
|
11622
11630
|
// only need to watch if out of root
|
|
11623
11631
|
!file.startsWith(root + '/') &&
|
|
11624
11632
|
// some rollup plugins use null bytes for private resolved Ids
|
|
11625
11633
|
!file.includes('\0') &&
|
|
11626
|
-
|
|
11634
|
+
fs$n.existsSync(file)) {
|
|
11627
11635
|
// resolve file to normalized system path
|
|
11628
|
-
watcher.add(path$
|
|
11636
|
+
watcher.add(path$q.resolve(file));
|
|
11629
11637
|
}
|
|
11630
11638
|
}
|
|
11631
11639
|
const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
|
|
@@ -11744,7 +11752,23 @@ function combineSourcemaps(filename, sourcemapList, excludeContent = true) {
|
|
|
11744
11752
|
function unique(arr) {
|
|
11745
11753
|
return Array.from(new Set(arr));
|
|
11746
11754
|
}
|
|
11747
|
-
|
|
11755
|
+
/**
|
|
11756
|
+
* Returns resolved localhost address when `dns.lookup` result differs from DNS
|
|
11757
|
+
*
|
|
11758
|
+
* `dns.lookup` result is same when defaultResultOrder is `verbatim`.
|
|
11759
|
+
* Even if defaultResultOrder is `ipv4first`, `dns.lookup` result maybe same.
|
|
11760
|
+
* For example, when IPv6 is not supported on that machine/network.
|
|
11761
|
+
*/
|
|
11762
|
+
async function getLocalhostAddressIfDiffersFromDNS() {
|
|
11763
|
+
const [nodeResult, dnsResult] = await Promise.all([
|
|
11764
|
+
promises.lookup('localhost'),
|
|
11765
|
+
promises.lookup('localhost', { verbatim: true })
|
|
11766
|
+
]);
|
|
11767
|
+
const isSame = nodeResult.family === dnsResult.family &&
|
|
11768
|
+
nodeResult.address === dnsResult.address;
|
|
11769
|
+
return isSame ? undefined : nodeResult.address;
|
|
11770
|
+
}
|
|
11771
|
+
async function resolveHostname(optionsHost) {
|
|
11748
11772
|
let host;
|
|
11749
11773
|
if (optionsHost === undefined || optionsHost === false) {
|
|
11750
11774
|
// Use a secure default
|
|
@@ -11758,8 +11782,15 @@ function resolveHostname(optionsHost) {
|
|
|
11758
11782
|
host = optionsHost;
|
|
11759
11783
|
}
|
|
11760
11784
|
// Set host name to localhost when possible
|
|
11761
|
-
|
|
11762
|
-
|
|
11785
|
+
let name = host === undefined || wildcardHosts.has(host) ? 'localhost' : host;
|
|
11786
|
+
if (host === 'localhost') {
|
|
11787
|
+
// See #8647 for more details.
|
|
11788
|
+
const localhostAddr = await getLocalhostAddressIfDiffersFromDNS();
|
|
11789
|
+
if (localhostAddr) {
|
|
11790
|
+
name = localhostAddr;
|
|
11791
|
+
}
|
|
11792
|
+
}
|
|
11793
|
+
return { host, name, implicit: optionsHost === undefined };
|
|
11763
11794
|
}
|
|
11764
11795
|
function arraify(target) {
|
|
11765
11796
|
return Array.isArray(target) ? target : [target];
|
|
@@ -11767,8 +11798,8 @@ function arraify(target) {
|
|
|
11767
11798
|
function toUpperCaseDriveLetter(pathName) {
|
|
11768
11799
|
return pathName.replace(/^\w:/, (letter) => letter.toUpperCase());
|
|
11769
11800
|
}
|
|
11770
|
-
const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
|
|
11771
|
-
const singlelineCommentsRE = /\/\/.*/g;
|
|
11801
|
+
const multilineCommentsRE$1 = /\/\*(.|[\r\n])*?\*\//gm;
|
|
11802
|
+
const singlelineCommentsRE$1 = /\/\/.*/g;
|
|
11772
11803
|
const requestQuerySplitRE = /\?(?!.*[\/|\}])/;
|
|
11773
11804
|
// @ts-expect-error
|
|
11774
11805
|
const usingDynamicImport = typeof jest === 'undefined';
|
|
@@ -11815,14 +11846,14 @@ const GRACEFUL_RENAME_TIMEOUT = 5000;
|
|
|
11815
11846
|
function gracefulRename(from, to, cb) {
|
|
11816
11847
|
const start = Date.now();
|
|
11817
11848
|
let backoff = 0;
|
|
11818
|
-
|
|
11849
|
+
fs$n.rename(from, to, function CB(er) {
|
|
11819
11850
|
if (er &&
|
|
11820
11851
|
(er.code === 'EACCES' || er.code === 'EPERM') &&
|
|
11821
11852
|
Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
|
|
11822
11853
|
setTimeout(function () {
|
|
11823
|
-
|
|
11854
|
+
fs$n.stat(to, function (stater, st) {
|
|
11824
11855
|
if (stater && stater.code === 'ENOENT')
|
|
11825
|
-
|
|
11856
|
+
fs$n.rename(from, to, CB);
|
|
11826
11857
|
else
|
|
11827
11858
|
CB(er);
|
|
11828
11859
|
});
|
|
@@ -11839,14 +11870,14 @@ const GRACEFUL_REMOVE_DIR_TIMEOUT = 5000;
|
|
|
11839
11870
|
function gracefulRemoveDir(dir, cb) {
|
|
11840
11871
|
const start = Date.now();
|
|
11841
11872
|
let backoff = 0;
|
|
11842
|
-
|
|
11873
|
+
fs$n.rm(dir, { recursive: true }, function CB(er) {
|
|
11843
11874
|
if (er) {
|
|
11844
11875
|
if ((er.code === 'ENOTEMPTY' ||
|
|
11845
11876
|
er.code === 'EACCES' ||
|
|
11846
11877
|
er.code === 'EPERM') &&
|
|
11847
11878
|
Date.now() - start < GRACEFUL_REMOVE_DIR_TIMEOUT) {
|
|
11848
11879
|
setTimeout(function () {
|
|
11849
|
-
|
|
11880
|
+
fs$n.rm(dir, { recursive: true }, CB);
|
|
11850
11881
|
}, backoff);
|
|
11851
11882
|
if (backoff < 100)
|
|
11852
11883
|
backoff += 10;
|
|
@@ -11861,7 +11892,7 @@ function gracefulRemoveDir(dir, cb) {
|
|
|
11861
11892
|
});
|
|
11862
11893
|
}
|
|
11863
11894
|
function emptyCssComments(raw) {
|
|
11864
|
-
return raw.replace(multilineCommentsRE, (s) => ' '.repeat(s.length));
|
|
11895
|
+
return raw.replace(multilineCommentsRE$1, (s) => ' '.repeat(s.length));
|
|
11865
11896
|
}
|
|
11866
11897
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
11867
11898
|
const merged = { ...defaults };
|
|
@@ -11951,6 +11982,19 @@ function transformResult(s, id, config) {
|
|
|
11951
11982
|
map: needSourceMap ? s.generateMap({ hires: true, source: id }) : null
|
|
11952
11983
|
};
|
|
11953
11984
|
}
|
|
11985
|
+
async function asyncFlatten(arr) {
|
|
11986
|
+
do {
|
|
11987
|
+
arr = (await Promise.all(arr)).flat(Infinity);
|
|
11988
|
+
} while (arr.some((v) => v?.then));
|
|
11989
|
+
return arr;
|
|
11990
|
+
}
|
|
11991
|
+
// strip UTF-8 BOM
|
|
11992
|
+
function stripBomTag(content) {
|
|
11993
|
+
if (content.charCodeAt(0) === 0xfeff) {
|
|
11994
|
+
return content.slice(1);
|
|
11995
|
+
}
|
|
11996
|
+
return content;
|
|
11997
|
+
}
|
|
11954
11998
|
|
|
11955
11999
|
/* eslint no-console: 0 */
|
|
11956
12000
|
const LogLevels = {
|
|
@@ -12050,17 +12094,19 @@ function createLogger(level = 'info', options = {}) {
|
|
|
12050
12094
|
};
|
|
12051
12095
|
return logger;
|
|
12052
12096
|
}
|
|
12053
|
-
function printCommonServerUrls(server, options, config) {
|
|
12097
|
+
async function printCommonServerUrls(server, options, config) {
|
|
12054
12098
|
const address = server.address();
|
|
12055
12099
|
const isAddressInfo = (x) => x?.address;
|
|
12056
12100
|
if (isAddressInfo(address)) {
|
|
12057
|
-
const hostname = resolveHostname(options.host);
|
|
12101
|
+
const hostname = await resolveHostname(options.host);
|
|
12058
12102
|
const protocol = options.https ? 'https' : 'http';
|
|
12059
|
-
|
|
12103
|
+
const base = config.base === './' || config.base === '' ? '/' : config.base;
|
|
12104
|
+
printServerUrls(hostname, protocol, address.port, base, config.logger.info);
|
|
12060
12105
|
}
|
|
12061
12106
|
}
|
|
12062
12107
|
function printServerUrls(hostname, protocol, port, base, info) {
|
|
12063
12108
|
const urls = [];
|
|
12109
|
+
const notes = [];
|
|
12064
12110
|
if (hostname.host && loopbackHosts.has(hostname.host)) {
|
|
12065
12111
|
let hostnameName = hostname.name;
|
|
12066
12112
|
if (hostnameName === '::1' ||
|
|
@@ -12071,15 +12117,16 @@ function printServerUrls(hostname, protocol, port, base, info) {
|
|
|
12071
12117
|
label: 'Local',
|
|
12072
12118
|
url: colors$1.cyan(`${protocol}://${hostnameName}:${colors$1.bold(port)}${base}`)
|
|
12073
12119
|
});
|
|
12074
|
-
if (hostname.
|
|
12120
|
+
if (hostname.implicit) {
|
|
12075
12121
|
urls.push({
|
|
12076
12122
|
label: 'Network',
|
|
12077
|
-
url:
|
|
12123
|
+
url: `use ${colors$1.white(colors$1.bold('--host'))} to expose`,
|
|
12124
|
+
disabled: true
|
|
12078
12125
|
});
|
|
12079
12126
|
}
|
|
12080
12127
|
}
|
|
12081
12128
|
else {
|
|
12082
|
-
Object.values(
|
|
12129
|
+
Object.values(os$3.networkInterfaces())
|
|
12083
12130
|
.flatMap((nInterface) => nInterface ?? [])
|
|
12084
12131
|
.filter((detail) => detail &&
|
|
12085
12132
|
detail.address &&
|
|
@@ -12094,16 +12141,17 @@ function printServerUrls(hostname, protocol, port, base, info) {
|
|
|
12094
12141
|
urls.push({ label, url: colors$1.cyan(url) });
|
|
12095
12142
|
});
|
|
12096
12143
|
}
|
|
12097
|
-
const length = urls.
|
|
12098
|
-
const print = (iconWithColor, label, messageWithColor) => {
|
|
12099
|
-
|
|
12144
|
+
const length = Math.max(...[...urls, ...notes].map(({ label }) => label.length));
|
|
12145
|
+
const print = (iconWithColor, label, messageWithColor, disabled) => {
|
|
12146
|
+
const message = ` ${iconWithColor} ${label ? colors$1.bold(label) + ':' : ' '} ${' '.repeat(length - label.length)}${messageWithColor}`;
|
|
12147
|
+
info(disabled ? colors$1.dim(message) : message);
|
|
12100
12148
|
};
|
|
12101
|
-
urls.forEach(({ label, url: text }) => {
|
|
12102
|
-
print(colors$1.green('➜'), label, text);
|
|
12149
|
+
urls.forEach(({ label, url: text, disabled }) => {
|
|
12150
|
+
print(colors$1.green('➜'), label, text, disabled);
|
|
12151
|
+
});
|
|
12152
|
+
notes.forEach(({ label, message: text }) => {
|
|
12153
|
+
print(colors$1.white('❖'), label, text);
|
|
12103
12154
|
});
|
|
12104
|
-
if (!hostname.host || wildcardHosts.has(hostname.host)) {
|
|
12105
|
-
print(colors$1.bold(colors$1.blue('ⓘ')), 'Note', colors$1.dim('You are using a wildcard host. Ports might be overriden.'));
|
|
12106
|
-
}
|
|
12107
12155
|
}
|
|
12108
12156
|
|
|
12109
12157
|
const writeColors = {
|
|
@@ -12128,7 +12176,7 @@ function buildReporterPlugin(config) {
|
|
|
12128
12176
|
.length / 1024).toFixed(2)} KiB`;
|
|
12129
12177
|
}
|
|
12130
12178
|
function printFileInfo(filePath, content, type, maxLength, compressedSize = '') {
|
|
12131
|
-
const outDir = normalizePath$3(path$
|
|
12179
|
+
const outDir = normalizePath$3(path$q.relative(config.root, path$q.resolve(config.root, config.build.outDir))) + '/';
|
|
12132
12180
|
const kibs = content.length / 1024;
|
|
12133
12181
|
const sizeColor = kibs > chunkLimit ? colors$1.yellow : colors$1.dim;
|
|
12134
12182
|
config.logger.info(`${colors$1.gray(colors$1.white(colors$1.dim(outDir)))}${writeColors[type](filePath.padEnd(maxLength + 2))} ${sizeColor(`${kibs.toFixed(2)} KiB${compressedSize}`)}`);
|
|
@@ -12140,7 +12188,7 @@ function buildReporterPlugin(config) {
|
|
|
12140
12188
|
let transformedCount = 0;
|
|
12141
12189
|
let chunkCount = 0;
|
|
12142
12190
|
const logTransform = throttle((id) => {
|
|
12143
|
-
writeLine(`transforming (${transformedCount}) ${colors$1.dim(path$
|
|
12191
|
+
writeLine(`transforming (${transformedCount}) ${colors$1.dim(path$q.relative(config.root, id))}`);
|
|
12144
12192
|
});
|
|
12145
12193
|
return {
|
|
12146
12194
|
name: 'vite:reporter',
|
|
@@ -12321,7 +12369,7 @@ async function tsconfigInDir(dir, options) {
|
|
|
12321
12369
|
return options.tsConfigPaths.has(tsconfig) ? tsconfig : void 0;
|
|
12322
12370
|
}
|
|
12323
12371
|
try {
|
|
12324
|
-
const stat = await promises.stat(tsconfig);
|
|
12372
|
+
const stat = await promises$1.stat(tsconfig);
|
|
12325
12373
|
if (stat.isFile() || stat.isFIFO()) {
|
|
12326
12374
|
return tsconfig;
|
|
12327
12375
|
}
|
|
@@ -12342,7 +12390,7 @@ async function* findTSConfig(dir, options, visited = /* @__PURE__ */ new Set())
|
|
|
12342
12390
|
if (!visited.has(dir)) {
|
|
12343
12391
|
visited.add(dir);
|
|
12344
12392
|
try {
|
|
12345
|
-
const dirents = await promises.readdir(dir, { withFileTypes: true });
|
|
12393
|
+
const dirents = await promises$1.readdir(dir, { withFileTypes: true });
|
|
12346
12394
|
for (const dirent of dirents) {
|
|
12347
12395
|
if (dirent.isDirectory() && (!(options == null ? void 0 : options.skip) || !options.skip(dirent.name))) {
|
|
12348
12396
|
yield* findTSConfig(path$p.resolve(dir, dirent.name), options, visited);
|
|
@@ -12479,7 +12527,7 @@ async function resolveTSConfig(filename) {
|
|
|
12479
12527
|
}
|
|
12480
12528
|
const tsconfig = path$p.resolve(filename);
|
|
12481
12529
|
try {
|
|
12482
|
-
const stat = await promises.stat(tsconfig);
|
|
12530
|
+
const stat = await promises$1.stat(tsconfig);
|
|
12483
12531
|
if (stat.isFile() || stat.isFIFO()) {
|
|
12484
12532
|
return tsconfig;
|
|
12485
12533
|
}
|
|
@@ -12644,7 +12692,7 @@ async function parseFile$1(tsconfigFile, cache) {
|
|
|
12644
12692
|
return cache.get(tsconfigFile);
|
|
12645
12693
|
}
|
|
12646
12694
|
try {
|
|
12647
|
-
const tsconfigJson = await promises.readFile(tsconfigFile, "utf-8");
|
|
12695
|
+
const tsconfigJson = await promises$1.readFile(tsconfigFile, "utf-8");
|
|
12648
12696
|
const json = toJson(tsconfigJson);
|
|
12649
12697
|
const result = {
|
|
12650
12698
|
tsconfigFile,
|
|
@@ -12696,14 +12744,14 @@ async function parseExtends(result, cache) {
|
|
|
12696
12744
|
function resolveExtends(extended, from) {
|
|
12697
12745
|
let error;
|
|
12698
12746
|
try {
|
|
12699
|
-
return createRequire$
|
|
12747
|
+
return createRequire$2(from).resolve(extended);
|
|
12700
12748
|
} catch (e) {
|
|
12701
12749
|
error = e;
|
|
12702
12750
|
}
|
|
12703
12751
|
if (!path$p.isAbsolute(extended) && !extended.startsWith("./") && !extended.startsWith("../")) {
|
|
12704
12752
|
try {
|
|
12705
12753
|
const fallbackExtended = path$p.join(extended, "tsconfig.json");
|
|
12706
|
-
return createRequire$
|
|
12754
|
+
return createRequire$2(from).resolve(fallbackExtended);
|
|
12707
12755
|
} catch (e) {
|
|
12708
12756
|
error = e;
|
|
12709
12757
|
}
|
|
@@ -12798,7 +12846,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
|
|
|
12798
12846
|
if (!loader) {
|
|
12799
12847
|
// if the id ends with a valid ext, use it (e.g. vue blocks)
|
|
12800
12848
|
// otherwise, cleanup the query before checking the ext
|
|
12801
|
-
const ext = path$
|
|
12849
|
+
const ext = path$q
|
|
12802
12850
|
.extname(/\.\w+$/.test(filename) ? filename : cleanUrl(filename))
|
|
12803
12851
|
.slice(1);
|
|
12804
12852
|
if (ext === 'cjs' || ext === 'mjs') {
|
|
@@ -13040,7 +13088,7 @@ async function loadTsconfigJsonForFile(filename) {
|
|
|
13040
13088
|
function reloadOnTsconfigChange(changedFile) {
|
|
13041
13089
|
// any tsconfig.json that's added in the workspace could be closer to a code file than a previously cached one
|
|
13042
13090
|
// any json file in the tsconfig cache could have been used to compile ts
|
|
13043
|
-
if (path$
|
|
13091
|
+
if (path$q.basename(changedFile) === 'tsconfig.json' ||
|
|
13044
13092
|
(changedFile.endsWith('.json') &&
|
|
13045
13093
|
tsconfckParseOptions?.cache?.has(changedFile))) {
|
|
13046
13094
|
server.config.logger.info(`changed tsconfig file detected: ${changedFile} - Clearing cache and forcing full-reload to ensure typescript is compiled with updated config values.`, { clear: server.config.clearScreen, timestamp: true });
|
|
@@ -13228,16 +13276,16 @@ function manifestPlugin(config) {
|
|
|
13228
13276
|
generateBundle({ format }, bundle) {
|
|
13229
13277
|
function getChunkName(chunk) {
|
|
13230
13278
|
if (chunk.facadeModuleId) {
|
|
13231
|
-
let name = normalizePath$3(path$
|
|
13279
|
+
let name = normalizePath$3(path$q.relative(config.root, chunk.facadeModuleId));
|
|
13232
13280
|
if (format === 'system' && !chunk.name.includes('-legacy')) {
|
|
13233
|
-
const ext = path$
|
|
13281
|
+
const ext = path$q.extname(name);
|
|
13234
13282
|
const endPos = ext.length !== 0 ? -ext.length : undefined;
|
|
13235
13283
|
name = name.slice(0, endPos) + `-legacy` + ext;
|
|
13236
13284
|
}
|
|
13237
13285
|
return name.replace(/\0/g, '');
|
|
13238
13286
|
}
|
|
13239
13287
|
else {
|
|
13240
|
-
return `_` + path$
|
|
13288
|
+
return `_` + path$q.basename(chunk.fileName);
|
|
13241
13289
|
}
|
|
13242
13290
|
}
|
|
13243
13291
|
function getInternalImports(imports) {
|
|
@@ -13283,11 +13331,20 @@ function manifestPlugin(config) {
|
|
|
13283
13331
|
}
|
|
13284
13332
|
return manifestChunk;
|
|
13285
13333
|
}
|
|
13334
|
+
function createAsset(chunk) {
|
|
13335
|
+
return {
|
|
13336
|
+
file: chunk.fileName,
|
|
13337
|
+
src: chunk.name
|
|
13338
|
+
};
|
|
13339
|
+
}
|
|
13286
13340
|
for (const file in bundle) {
|
|
13287
13341
|
const chunk = bundle[file];
|
|
13288
13342
|
if (chunk.type === 'chunk') {
|
|
13289
13343
|
manifest[getChunkName(chunk)] = createChunk(chunk);
|
|
13290
13344
|
}
|
|
13345
|
+
else if (chunk.type === 'asset' && typeof chunk.name === 'string') {
|
|
13346
|
+
manifest[chunk.name] = createAsset(chunk);
|
|
13347
|
+
}
|
|
13291
13348
|
}
|
|
13292
13349
|
outputCount++;
|
|
13293
13350
|
const output = config.build.rollupOptions?.output;
|
|
@@ -14434,7 +14491,7 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
14434
14491
|
let sourceRoot;
|
|
14435
14492
|
try {
|
|
14436
14493
|
// The source root is undefined for virtual modules and permission errors.
|
|
14437
|
-
sourceRoot = await promises.realpath(path$
|
|
14494
|
+
sourceRoot = await promises$2.realpath(path$q.resolve(path$q.dirname(file), map.sourceRoot || ''));
|
|
14438
14495
|
}
|
|
14439
14496
|
catch { }
|
|
14440
14497
|
const missingSources = [];
|
|
@@ -14442,9 +14499,9 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
14442
14499
|
if (sourcePath && !virtualSourceRE.test(sourcePath)) {
|
|
14443
14500
|
sourcePath = decodeURI(sourcePath);
|
|
14444
14501
|
if (sourceRoot) {
|
|
14445
|
-
sourcePath = path$
|
|
14502
|
+
sourcePath = path$q.resolve(sourceRoot, sourcePath);
|
|
14446
14503
|
}
|
|
14447
|
-
return promises.readFile(sourcePath, 'utf-8').catch(() => {
|
|
14504
|
+
return promises$2.readFile(sourcePath, 'utf-8').catch(() => {
|
|
14448
14505
|
missingSources.push(sourcePath);
|
|
14449
14506
|
return null;
|
|
14450
14507
|
});
|
|
@@ -14596,7 +14653,7 @@ const debug$d = createDebugger('vite:resolve-details', {
|
|
|
14596
14653
|
});
|
|
14597
14654
|
function invalidatePackageData(packageCache, pkgPath) {
|
|
14598
14655
|
packageCache.delete(pkgPath);
|
|
14599
|
-
const pkgDir = path$
|
|
14656
|
+
const pkgDir = path$q.dirname(pkgPath);
|
|
14600
14657
|
packageCache.forEach((pkg, cacheKey) => {
|
|
14601
14658
|
if (pkg.dir === pkgDir) {
|
|
14602
14659
|
packageCache.delete(cacheKey);
|
|
@@ -14634,14 +14691,14 @@ function resolvePackageData(id, basedir, preserveSymlinks = false, packageCache)
|
|
|
14634
14691
|
}
|
|
14635
14692
|
function loadPackageData(pkgPath, preserveSymlinks, packageCache) {
|
|
14636
14693
|
if (!preserveSymlinks) {
|
|
14637
|
-
pkgPath =
|
|
14694
|
+
pkgPath = fs$n.realpathSync.native(pkgPath);
|
|
14638
14695
|
}
|
|
14639
14696
|
let cached;
|
|
14640
14697
|
if ((cached = packageCache?.get(pkgPath))) {
|
|
14641
14698
|
return cached;
|
|
14642
14699
|
}
|
|
14643
|
-
const data = JSON.parse(
|
|
14644
|
-
const pkgDir = path$
|
|
14700
|
+
const data = JSON.parse(fs$n.readFileSync(pkgPath, 'utf-8'));
|
|
14701
|
+
const pkgDir = path$q.dirname(pkgPath);
|
|
14645
14702
|
const { sideEffects } = data;
|
|
14646
14703
|
let hasSideEffects;
|
|
14647
14704
|
if (typeof sideEffects === 'boolean') {
|
|
@@ -14717,15 +14774,15 @@ const isDebug$4 = process.env.DEBUG;
|
|
|
14717
14774
|
const debug$c = createDebugger('vite:resolve-details', {
|
|
14718
14775
|
onlyWhenFocused: true
|
|
14719
14776
|
});
|
|
14720
|
-
function resolvePlugin(
|
|
14721
|
-
const { root,
|
|
14777
|
+
function resolvePlugin(resolveOptions) {
|
|
14778
|
+
const { root, isProduction, asSrc, ssrConfig, preferRelative = false } = resolveOptions;
|
|
14722
14779
|
const { target: ssrTarget, noExternal: ssrNoExternal } = ssrConfig ?? {};
|
|
14723
14780
|
return {
|
|
14724
14781
|
name: 'vite:resolve',
|
|
14725
14782
|
async resolveId(id, importer, resolveOpts) {
|
|
14726
14783
|
// We need to delay depsOptimizer until here instead of passing it as an option
|
|
14727
14784
|
// the resolvePlugin because the optimizer is created on server listen during dev
|
|
14728
|
-
const depsOptimizer =
|
|
14785
|
+
const depsOptimizer = resolveOptions.getDepsOptimizer?.();
|
|
14729
14786
|
const ssr = resolveOpts?.ssr === true;
|
|
14730
14787
|
if (id.startsWith(browserExternalId)) {
|
|
14731
14788
|
return id;
|
|
@@ -14739,8 +14796,8 @@ function resolvePlugin(baseOptions) {
|
|
|
14739
14796
|
const isRequire = resolveOpts?.custom?.['node-resolve']?.isRequire ?? false;
|
|
14740
14797
|
const options = {
|
|
14741
14798
|
isRequire,
|
|
14742
|
-
...
|
|
14743
|
-
scan: resolveOpts?.scan ??
|
|
14799
|
+
...resolveOptions,
|
|
14800
|
+
scan: resolveOpts?.scan ?? resolveOptions.scan
|
|
14744
14801
|
};
|
|
14745
14802
|
if (importer) {
|
|
14746
14803
|
if (isTsRequest(importer)) {
|
|
@@ -14758,7 +14815,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14758
14815
|
if (asSrc && depsOptimizer?.isOptimizedDepUrl(id)) {
|
|
14759
14816
|
const optimizedPath = id.startsWith(FS_PREFIX)
|
|
14760
14817
|
? fsPathFromId(id)
|
|
14761
|
-
: normalizePath$3(ensureVolumeInPath(path$
|
|
14818
|
+
: normalizePath$3(ensureVolumeInPath(path$q.resolve(root, id.slice(1))));
|
|
14762
14819
|
return optimizedPath;
|
|
14763
14820
|
}
|
|
14764
14821
|
// explicit fs paths that starts with /@fs/*
|
|
@@ -14773,7 +14830,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14773
14830
|
// URL
|
|
14774
14831
|
// /foo -> /fs-root/foo
|
|
14775
14832
|
if (asSrc && id.startsWith('/')) {
|
|
14776
|
-
const fsPath = path$
|
|
14833
|
+
const fsPath = path$q.resolve(root, id.slice(1));
|
|
14777
14834
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
14778
14835
|
isDebug$4 && debug$c(`[url] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
14779
14836
|
return res;
|
|
@@ -14783,15 +14840,15 @@ function resolvePlugin(baseOptions) {
|
|
|
14783
14840
|
if (id.startsWith('.') ||
|
|
14784
14841
|
(preferRelative && /^\w/.test(id)) ||
|
|
14785
14842
|
importer?.endsWith('.html')) {
|
|
14786
|
-
const basedir = importer ? path$
|
|
14787
|
-
const fsPath = path$
|
|
14843
|
+
const basedir = importer ? path$q.dirname(importer) : process.cwd();
|
|
14844
|
+
const fsPath = path$q.resolve(basedir, id);
|
|
14788
14845
|
// handle browser field mapping for relative imports
|
|
14789
14846
|
const normalizedFsPath = normalizePath$3(fsPath);
|
|
14790
14847
|
if (depsOptimizer?.isOptimizedDepFile(normalizedFsPath)) {
|
|
14791
14848
|
// Optimized files could not yet exist in disk, resolve to the full path
|
|
14792
14849
|
// Inject the current browserHash version if the path doesn't have one
|
|
14793
14850
|
if (!normalizedFsPath.match(DEP_VERSION_RE)) {
|
|
14794
|
-
const browserHash = optimizedDepInfoFromFile(depsOptimizer.metadata, normalizedFsPath)?.browserHash;
|
|
14851
|
+
const browserHash = optimizedDepInfoFromFile(depsOptimizer.metadata({ ssr }), normalizedFsPath)?.browserHash;
|
|
14795
14852
|
if (browserHash) {
|
|
14796
14853
|
return injectQuery(normalizedFsPath, `v=${browserHash}`);
|
|
14797
14854
|
}
|
|
@@ -14827,7 +14884,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14827
14884
|
}
|
|
14828
14885
|
}
|
|
14829
14886
|
// absolute fs paths
|
|
14830
|
-
if (path$
|
|
14887
|
+
if (path$q.isAbsolute(id) && (res = tryFsResolve(id, options))) {
|
|
14831
14888
|
isDebug$4 && debug$c(`[fs] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
14832
14889
|
return res;
|
|
14833
14890
|
}
|
|
@@ -14849,9 +14906,8 @@ function resolvePlugin(baseOptions) {
|
|
|
14849
14906
|
if (!external &&
|
|
14850
14907
|
asSrc &&
|
|
14851
14908
|
depsOptimizer &&
|
|
14852
|
-
(isBuild || !ssr) &&
|
|
14853
14909
|
!options.scan &&
|
|
14854
|
-
(res = await tryOptimizedResolve(depsOptimizer, id, importer))) {
|
|
14910
|
+
(res = await tryOptimizedResolve(depsOptimizer, ssr, id, importer))) {
|
|
14855
14911
|
return res;
|
|
14856
14912
|
}
|
|
14857
14913
|
if (targetWeb &&
|
|
@@ -14868,7 +14924,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14868
14924
|
if (ssrNoExternal === true) {
|
|
14869
14925
|
let message = `Cannot bundle Node.js built-in "${id}"`;
|
|
14870
14926
|
if (importer) {
|
|
14871
|
-
message += ` imported from "${path$
|
|
14927
|
+
message += ` imported from "${path$q.relative(process.cwd(), importer)}"`;
|
|
14872
14928
|
}
|
|
14873
14929
|
message += `. Consider disabling ssr.noExternal or remove the built-in dependency.`;
|
|
14874
14930
|
this.error(message);
|
|
@@ -14955,7 +15011,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
14955
15011
|
// works and will result in massively slow subsequent checks (which are
|
|
14956
15012
|
// unnecessary in the first place)
|
|
14957
15013
|
if (isFileReadable(file)) {
|
|
14958
|
-
if (!
|
|
15014
|
+
if (!fs$n.statSync(file).isDirectory()) {
|
|
14959
15015
|
return getRealPath(file, options.preserveSymlinks) + postfix;
|
|
14960
15016
|
}
|
|
14961
15017
|
else if (tryIndex) {
|
|
@@ -14989,13 +15045,14 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
14989
15045
|
return;
|
|
14990
15046
|
}
|
|
14991
15047
|
if (tryPrefix) {
|
|
14992
|
-
const prefixed = `${path$
|
|
15048
|
+
const prefixed = `${path$q.dirname(file)}/${tryPrefix}${path$q.basename(file)}`;
|
|
14993
15049
|
return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb);
|
|
14994
15050
|
}
|
|
14995
15051
|
}
|
|
14996
15052
|
const idToPkgMap = new Map();
|
|
14997
15053
|
function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, externalize) {
|
|
14998
15054
|
const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
|
|
15055
|
+
ssr ?? (ssr = false);
|
|
14999
15056
|
// split id by last '>' for nested selected packages, for example:
|
|
15000
15057
|
// 'foo > bar > baz' => 'foo > bar' & 'baz'
|
|
15001
15058
|
// 'foo' => '' & 'foo'
|
|
@@ -15016,7 +15073,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15016
15073
|
// first path part (since periods are sadly allowed in package names).
|
|
15017
15074
|
// At the same time, skip the first path part if it begins with "@"
|
|
15018
15075
|
// (since "@foo/bar" should be treated as the top-level path).
|
|
15019
|
-
if (possiblePkgIds.length ? path$
|
|
15076
|
+
if (possiblePkgIds.length ? path$q.extname(part) : part[0] === '@') {
|
|
15020
15077
|
continue;
|
|
15021
15078
|
}
|
|
15022
15079
|
const possiblePkgId = nestedPath.slice(0, slashIndex);
|
|
@@ -15027,9 +15084,9 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15027
15084
|
basedir = root;
|
|
15028
15085
|
}
|
|
15029
15086
|
else if (importer &&
|
|
15030
|
-
path$
|
|
15031
|
-
|
|
15032
|
-
basedir = path$
|
|
15087
|
+
path$q.isAbsolute(importer) &&
|
|
15088
|
+
fs$n.existsSync(cleanUrl(importer))) {
|
|
15089
|
+
basedir = path$q.dirname(importer);
|
|
15033
15090
|
}
|
|
15034
15091
|
else {
|
|
15035
15092
|
basedir = root;
|
|
@@ -15077,7 +15134,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15077
15134
|
if (!externalize) {
|
|
15078
15135
|
return resolved;
|
|
15079
15136
|
}
|
|
15080
|
-
const resolvedExt = path$
|
|
15137
|
+
const resolvedExt = path$q.extname(resolved.id);
|
|
15081
15138
|
let resolvedId = id;
|
|
15082
15139
|
if (isDeepImport) {
|
|
15083
15140
|
// check ext before externalizing - only externalize
|
|
@@ -15085,7 +15142,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15085
15142
|
if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) {
|
|
15086
15143
|
return;
|
|
15087
15144
|
}
|
|
15088
|
-
if (!pkg?.data.exports && path$
|
|
15145
|
+
if (!pkg?.data.exports && path$q.extname(id) !== resolvedExt) {
|
|
15089
15146
|
resolvedId += resolvedExt;
|
|
15090
15147
|
}
|
|
15091
15148
|
}
|
|
@@ -15122,7 +15179,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15122
15179
|
// otherwise we may introduce duplicated modules for externalized files
|
|
15123
15180
|
// from pre-bundled deps.
|
|
15124
15181
|
if (!isBuild) {
|
|
15125
|
-
const versionHash = depsOptimizer.metadata.browserHash;
|
|
15182
|
+
const versionHash = depsOptimizer.metadata({ ssr }).browserHash;
|
|
15126
15183
|
if (versionHash && isJsType) {
|
|
15127
15184
|
resolved = injectQuery(resolved, `v=${versionHash}`);
|
|
15128
15185
|
}
|
|
@@ -15131,7 +15188,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15131
15188
|
else {
|
|
15132
15189
|
// this is a missing import, queue optimize-deps re-run and
|
|
15133
15190
|
// get a resolved its optimized info
|
|
15134
|
-
const optimizedInfo = depsOptimizer.registerMissingImport(id, resolved);
|
|
15191
|
+
const optimizedInfo = depsOptimizer.registerMissingImport(id, resolved, ssr);
|
|
15135
15192
|
resolved = depsOptimizer.getOptimizedDepId(optimizedInfo);
|
|
15136
15193
|
}
|
|
15137
15194
|
if (isBuild) {
|
|
@@ -15146,9 +15203,13 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15146
15203
|
return { id: resolved };
|
|
15147
15204
|
}
|
|
15148
15205
|
}
|
|
15149
|
-
async function tryOptimizedResolve(depsOptimizer, id, importer) {
|
|
15206
|
+
async function tryOptimizedResolve(depsOptimizer, ssr, id, importer) {
|
|
15150
15207
|
await depsOptimizer.scanProcessing;
|
|
15151
|
-
const
|
|
15208
|
+
const metadata = depsOptimizer.metadata({ ssr });
|
|
15209
|
+
if (!metadata) {
|
|
15210
|
+
return;
|
|
15211
|
+
}
|
|
15212
|
+
const depInfo = optimizedDepInfoFromId(metadata, id);
|
|
15152
15213
|
if (depInfo) {
|
|
15153
15214
|
return depsOptimizer.getOptimizedDepId(depInfo);
|
|
15154
15215
|
}
|
|
@@ -15156,7 +15217,7 @@ async function tryOptimizedResolve(depsOptimizer, id, importer) {
|
|
|
15156
15217
|
return;
|
|
15157
15218
|
// further check if id is imported by nested dependency
|
|
15158
15219
|
let resolvedSrc;
|
|
15159
|
-
for (const optimizedData of
|
|
15220
|
+
for (const optimizedData of metadata.depInfoList) {
|
|
15160
15221
|
if (!optimizedData.src)
|
|
15161
15222
|
continue; // Ignore chunks
|
|
15162
15223
|
const pkgPath = optimizedData.id;
|
|
@@ -15170,7 +15231,7 @@ async function tryOptimizedResolve(depsOptimizer, id, importer) {
|
|
|
15170
15231
|
if (resolvedSrc == null) {
|
|
15171
15232
|
try {
|
|
15172
15233
|
// this may throw errors if unable to resolve, e.g. aliased id
|
|
15173
|
-
resolvedSrc = normalizePath$3(resolveFrom(id, path$
|
|
15234
|
+
resolvedSrc = normalizePath$3(resolveFrom(id, path$q.dirname(importer)));
|
|
15174
15235
|
}
|
|
15175
15236
|
catch {
|
|
15176
15237
|
// this is best-effort only so swallow errors
|
|
@@ -15216,9 +15277,9 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
15216
15277
|
// the heuristics here is to actually read the browser entry when
|
|
15217
15278
|
// possible and check for hints of UMD. If it is UMD, prefer "module"
|
|
15218
15279
|
// instead; Otherwise, assume it's ESM and use it.
|
|
15219
|
-
const resolvedBrowserEntry = tryFsResolve(path$
|
|
15280
|
+
const resolvedBrowserEntry = tryFsResolve(path$q.join(dir, browserEntry), options);
|
|
15220
15281
|
if (resolvedBrowserEntry) {
|
|
15221
|
-
const content =
|
|
15282
|
+
const content = fs$n.readFileSync(resolvedBrowserEntry, 'utf-8');
|
|
15222
15283
|
if ((/typeof exports\s*==/.test(content) &&
|
|
15223
15284
|
/typeof module\s*==/.test(content)) ||
|
|
15224
15285
|
/module\.exports\s*=/.test(content)) {
|
|
@@ -15249,7 +15310,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
15249
15310
|
for (let entry of entryPoints) {
|
|
15250
15311
|
// make sure we don't get scripts when looking for sass
|
|
15251
15312
|
if (options.mainFields?.[0] === 'sass' &&
|
|
15252
|
-
!options.extensions?.includes(path$
|
|
15313
|
+
!options.extensions?.includes(path$q.extname(entry))) {
|
|
15253
15314
|
entry = '';
|
|
15254
15315
|
options.skipPackageJson = true;
|
|
15255
15316
|
}
|
|
@@ -15258,7 +15319,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
15258
15319
|
if (targetWeb && isObject$2(browserField)) {
|
|
15259
15320
|
entry = mapWithBrowserField(entry, browserField) || entry;
|
|
15260
15321
|
}
|
|
15261
|
-
const entryPointPath = path$
|
|
15322
|
+
const entryPointPath = path$q.join(dir, entry);
|
|
15262
15323
|
const resolvedEntryPoint = tryFsResolve(entryPointPath, options);
|
|
15263
15324
|
if (resolvedEntryPoint) {
|
|
15264
15325
|
isDebug$4 &&
|
|
@@ -15318,7 +15379,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
15318
15379
|
}
|
|
15319
15380
|
if (!relativeId) {
|
|
15320
15381
|
throw new Error(`Package subpath '${relativeId}' is not defined by "exports" in ` +
|
|
15321
|
-
`${path$
|
|
15382
|
+
`${path$q.join(dir, 'package.json')}.`);
|
|
15322
15383
|
}
|
|
15323
15384
|
}
|
|
15324
15385
|
else if (targetWeb && isObject$2(browserField)) {
|
|
@@ -15333,7 +15394,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
15333
15394
|
}
|
|
15334
15395
|
}
|
|
15335
15396
|
if (relativeId) {
|
|
15336
|
-
const resolved = tryFsResolve(path$
|
|
15397
|
+
const resolved = tryFsResolve(path$q.join(dir, relativeId), options, !exportsField, // try index only if no exports field
|
|
15337
15398
|
targetWeb);
|
|
15338
15399
|
if (resolved) {
|
|
15339
15400
|
isDebug$4 &&
|
|
@@ -15347,10 +15408,10 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
15347
15408
|
let res;
|
|
15348
15409
|
const pkg = importer && idToPkgMap.get(importer);
|
|
15349
15410
|
if (pkg && isObject$2(pkg.data.browser)) {
|
|
15350
|
-
const mapId = isFilePath ? './' + slash$1(path$
|
|
15411
|
+
const mapId = isFilePath ? './' + slash$1(path$q.relative(pkg.dir, id)) : id;
|
|
15351
15412
|
const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser);
|
|
15352
15413
|
if (browserMappedPath) {
|
|
15353
|
-
const fsPath = path$
|
|
15414
|
+
const fsPath = path$q.join(pkg.dir, browserMappedPath);
|
|
15354
15415
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
15355
15416
|
isDebug$4 &&
|
|
15356
15417
|
debug$c(`[browser mapped] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
@@ -15376,9 +15437,9 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
15376
15437
|
* - Returning `false` means this id is explicitly externalized for browser
|
|
15377
15438
|
*/
|
|
15378
15439
|
function mapWithBrowserField(relativePathInPkgDir, map) {
|
|
15379
|
-
const normalizedPath = path$
|
|
15440
|
+
const normalizedPath = path$q.posix.normalize(relativePathInPkgDir);
|
|
15380
15441
|
for (const key in map) {
|
|
15381
|
-
const normalizedKey = path$
|
|
15442
|
+
const normalizedKey = path$q.posix.normalize(key);
|
|
15382
15443
|
if (normalizedPath === normalizedKey ||
|
|
15383
15444
|
equalWithoutSuffix(normalizedPath, normalizedKey, '.js') ||
|
|
15384
15445
|
equalWithoutSuffix(normalizedPath, normalizedKey, '/index.js')) {
|
|
@@ -15392,7 +15453,7 @@ function equalWithoutSuffix(path, key, suffix) {
|
|
|
15392
15453
|
function getRealPath(resolved, preserveSymlinks) {
|
|
15393
15454
|
resolved = ensureVolumeInPath(resolved);
|
|
15394
15455
|
if (!preserveSymlinks && browserExternalId !== resolved) {
|
|
15395
|
-
resolved =
|
|
15456
|
+
resolved = fs$n.realpathSync(resolved);
|
|
15396
15457
|
}
|
|
15397
15458
|
return normalizePath$3(resolved);
|
|
15398
15459
|
}
|
|
@@ -15438,7 +15499,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15438
15499
|
// explicit resolveDir - this is passed only during yarn pnp resolve for
|
|
15439
15500
|
// entries
|
|
15440
15501
|
if (resolveDir) {
|
|
15441
|
-
_importer = normalizePath$3(path$
|
|
15502
|
+
_importer = normalizePath$3(path$q.join(resolveDir, '*'));
|
|
15442
15503
|
}
|
|
15443
15504
|
else {
|
|
15444
15505
|
// map importer ids to file paths for correct resolution
|
|
@@ -15447,6 +15508,23 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15447
15508
|
const resolver = kind.startsWith('require') ? _resolveRequire : _resolve;
|
|
15448
15509
|
return resolver(id, _importer, undefined);
|
|
15449
15510
|
};
|
|
15511
|
+
const resolveResult = (id, resolved) => {
|
|
15512
|
+
if (resolved.startsWith(browserExternalId)) {
|
|
15513
|
+
return {
|
|
15514
|
+
path: id,
|
|
15515
|
+
namespace: 'browser-external'
|
|
15516
|
+
};
|
|
15517
|
+
}
|
|
15518
|
+
if (isExternalUrl(resolved)) {
|
|
15519
|
+
return {
|
|
15520
|
+
path: resolved,
|
|
15521
|
+
external: true
|
|
15522
|
+
};
|
|
15523
|
+
}
|
|
15524
|
+
return {
|
|
15525
|
+
path: path$q.resolve(resolved)
|
|
15526
|
+
};
|
|
15527
|
+
};
|
|
15450
15528
|
return {
|
|
15451
15529
|
name: 'vite:dep-pre-bundle',
|
|
15452
15530
|
setup(build) {
|
|
@@ -15510,21 +15588,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15510
15588
|
// use vite's own resolver
|
|
15511
15589
|
const resolved = await resolve(id, importer, kind);
|
|
15512
15590
|
if (resolved) {
|
|
15513
|
-
|
|
15514
|
-
return {
|
|
15515
|
-
path: id,
|
|
15516
|
-
namespace: 'browser-external'
|
|
15517
|
-
};
|
|
15518
|
-
}
|
|
15519
|
-
if (isExternalUrl(resolved)) {
|
|
15520
|
-
return {
|
|
15521
|
-
path: resolved,
|
|
15522
|
-
external: true
|
|
15523
|
-
};
|
|
15524
|
-
}
|
|
15525
|
-
return {
|
|
15526
|
-
path: path$p.resolve(resolved)
|
|
15527
|
-
};
|
|
15591
|
+
return resolveResult(id, resolved);
|
|
15528
15592
|
}
|
|
15529
15593
|
});
|
|
15530
15594
|
// For entry files, we'll read it ourselves and construct a proxy module
|
|
@@ -15535,10 +15599,10 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15535
15599
|
// referenced via relative imports - if we don't separate the proxy and
|
|
15536
15600
|
// the actual module, esbuild will create duplicated copies of the same
|
|
15537
15601
|
// module!
|
|
15538
|
-
const root = path$
|
|
15602
|
+
const root = path$q.resolve(config.root);
|
|
15539
15603
|
build.onLoad({ filter: /.*/, namespace: 'dep' }, ({ path: id }) => {
|
|
15540
15604
|
const entryFile = qualified[id];
|
|
15541
|
-
let relativePath = normalizePath$3(path$
|
|
15605
|
+
let relativePath = normalizePath$3(path$q.relative(root, entryFile));
|
|
15542
15606
|
if (!relativePath.startsWith('./') &&
|
|
15543
15607
|
!relativePath.startsWith('../') &&
|
|
15544
15608
|
relativePath !== '.') {
|
|
@@ -15565,24 +15629,30 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15565
15629
|
};
|
|
15566
15630
|
});
|
|
15567
15631
|
build.onLoad({ filter: /.*/, namespace: 'browser-external' }, ({ path }) => {
|
|
15568
|
-
|
|
15569
|
-
|
|
15570
|
-
|
|
15571
|
-
|
|
15572
|
-
|
|
15573
|
-
|
|
15574
|
-
|
|
15575
|
-
|
|
15576
|
-
|
|
15577
|
-
|
|
15578
|
-
|
|
15579
|
-
|
|
15580
|
-
|
|
15581
|
-
|
|
15582
|
-
|
|
15583
|
-
|
|
15584
|
-
|
|
15585
|
-
|
|
15632
|
+
if (config.isProduction) {
|
|
15633
|
+
return {
|
|
15634
|
+
contents: 'module.exports = {}'
|
|
15635
|
+
};
|
|
15636
|
+
}
|
|
15637
|
+
else {
|
|
15638
|
+
return {
|
|
15639
|
+
// Return in CJS to intercept named imports. Use `Object.create` to
|
|
15640
|
+
// create the Proxy in the prototype to workaround esbuild issue. Why?
|
|
15641
|
+
//
|
|
15642
|
+
// In short, esbuild cjs->esm flow:
|
|
15643
|
+
// 1. Create empty object using `Object.create(Object.getPrototypeOf(module.exports))`.
|
|
15644
|
+
// 2. Assign props of `module.exports` to the object.
|
|
15645
|
+
// 3. Return object for ESM use.
|
|
15646
|
+
//
|
|
15647
|
+
// If we do `module.exports = new Proxy({}, {})`, step 1 returns empty object,
|
|
15648
|
+
// step 2 does nothing as there's no props for `module.exports`. The final object
|
|
15649
|
+
// is just an empty object.
|
|
15650
|
+
//
|
|
15651
|
+
// Creating the Proxy in the prototype satisfies step 1 immediately, which means
|
|
15652
|
+
// the returned object is a Proxy that we can intercept.
|
|
15653
|
+
//
|
|
15654
|
+
// Note: Skip keys that are accessed by esbuild and browser devtools.
|
|
15655
|
+
contents: `\
|
|
15586
15656
|
module.exports = Object.create(new Proxy({}, {
|
|
15587
15657
|
get(_, key) {
|
|
15588
15658
|
if (
|
|
@@ -15595,16 +15665,21 @@ module.exports = Object.create(new Proxy({}, {
|
|
|
15595
15665
|
}
|
|
15596
15666
|
}
|
|
15597
15667
|
}))`
|
|
15598
|
-
|
|
15668
|
+
};
|
|
15669
|
+
}
|
|
15599
15670
|
});
|
|
15600
15671
|
// yarn 2 pnp compat
|
|
15601
15672
|
if (isRunningWithYarnPnp) {
|
|
15602
|
-
build.onResolve({ filter: /.*/ }, async ({ path, importer, kind, resolveDir }) =>
|
|
15673
|
+
build.onResolve({ filter: /.*/ }, async ({ path: id, importer, kind, resolveDir, namespace }) => {
|
|
15674
|
+
const resolved = await resolve(id, importer, kind,
|
|
15603
15675
|
// pass along resolveDir for entries
|
|
15604
|
-
|
|
15605
|
-
|
|
15676
|
+
namespace === 'dep' ? resolveDir : undefined);
|
|
15677
|
+
if (resolved) {
|
|
15678
|
+
return resolveResult(id, resolved);
|
|
15679
|
+
}
|
|
15680
|
+
});
|
|
15606
15681
|
build.onLoad({ filter: /.*/ }, async (args) => ({
|
|
15607
|
-
contents: await promises.readFile(args.path),
|
|
15682
|
+
contents: await promises$2.readFile(args.path),
|
|
15608
15683
|
loader: 'default'
|
|
15609
15684
|
}));
|
|
15610
15685
|
}
|
|
@@ -16377,7 +16452,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
16377
16452
|
* Licensed under the MIT License.
|
|
16378
16453
|
*/
|
|
16379
16454
|
|
|
16380
|
-
const util$2 = require$$0$
|
|
16455
|
+
const util$2 = require$$0$5;
|
|
16381
16456
|
const toRegexRange = toRegexRange_1;
|
|
16382
16457
|
|
|
16383
16458
|
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -17340,7 +17415,7 @@ braces$2.create = (input, options = {}) => {
|
|
|
17340
17415
|
|
|
17341
17416
|
var braces_1 = braces$2;
|
|
17342
17417
|
|
|
17343
|
-
const util$1 = require$$0$
|
|
17418
|
+
const util$1 = require$$0$5;
|
|
17344
17419
|
const braces$1 = braces_1;
|
|
17345
17420
|
const picomatch$2 = picomatch$3;
|
|
17346
17421
|
const utils$b = utils$k;
|
|
@@ -17984,7 +18059,7 @@ var stream$4 = {};
|
|
|
17984
18059
|
* Copyright (c) 2014-2020 Teambition
|
|
17985
18060
|
* Licensed under the MIT license.
|
|
17986
18061
|
*/
|
|
17987
|
-
const Stream = require$$0$
|
|
18062
|
+
const Stream = require$$0$6;
|
|
17988
18063
|
const PassThrough = Stream.PassThrough;
|
|
17989
18064
|
const slice = Array.prototype.slice;
|
|
17990
18065
|
|
|
@@ -18347,7 +18422,7 @@ var fs$h = {};
|
|
|
18347
18422
|
(function (exports) {
|
|
18348
18423
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18349
18424
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
18350
|
-
const fs =
|
|
18425
|
+
const fs = require$$0__default;
|
|
18351
18426
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18352
18427
|
lstat: fs.lstat,
|
|
18353
18428
|
stat: fs.stat,
|
|
@@ -18708,7 +18783,7 @@ var fs$d = {};
|
|
|
18708
18783
|
(function (exports) {
|
|
18709
18784
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18710
18785
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
18711
|
-
const fs =
|
|
18786
|
+
const fs = require$$0__default;
|
|
18712
18787
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18713
18788
|
lstat: fs.lstat,
|
|
18714
18789
|
stat: fs.stat,
|
|
@@ -19139,7 +19214,7 @@ class Reader$1 {
|
|
|
19139
19214
|
reader$1.default = Reader$1;
|
|
19140
19215
|
|
|
19141
19216
|
Object.defineProperty(async$2, "__esModule", { value: true });
|
|
19142
|
-
const events_1 = require$$0$
|
|
19217
|
+
const events_1 = require$$0$4;
|
|
19143
19218
|
const fsScandir$2 = out$1;
|
|
19144
19219
|
const fastq = queue.exports;
|
|
19145
19220
|
const common$5 = common$7;
|
|
@@ -19268,7 +19343,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
19268
19343
|
var stream$1 = {};
|
|
19269
19344
|
|
|
19270
19345
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
19271
|
-
const stream_1$5 = require$$0$
|
|
19346
|
+
const stream_1$5 = require$$0$6;
|
|
19272
19347
|
const async_1$2 = async$2;
|
|
19273
19348
|
class StreamProvider {
|
|
19274
19349
|
constructor(_root, _settings) {
|
|
@@ -19476,7 +19551,7 @@ class Reader {
|
|
|
19476
19551
|
reader.default = Reader;
|
|
19477
19552
|
|
|
19478
19553
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
19479
|
-
const stream_1$3 = require$$0$
|
|
19554
|
+
const stream_1$3 = require$$0$6;
|
|
19480
19555
|
const fsStat$1 = out$3;
|
|
19481
19556
|
const fsWalk$1 = out$2;
|
|
19482
19557
|
const reader_1$1 = reader;
|
|
@@ -19874,7 +19949,7 @@ async$6.default = ProviderAsync;
|
|
|
19874
19949
|
var stream = {};
|
|
19875
19950
|
|
|
19876
19951
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
19877
|
-
const stream_1$1 = require$$0$
|
|
19952
|
+
const stream_1$1 = require$$0$6;
|
|
19878
19953
|
const stream_2 = stream$2;
|
|
19879
19954
|
const provider_1$1 = provider;
|
|
19880
19955
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -19979,7 +20054,7 @@ var settings = {};
|
|
|
19979
20054
|
(function (exports) {
|
|
19980
20055
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19981
20056
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
19982
|
-
const fs =
|
|
20057
|
+
const fs = require$$0__default;
|
|
19983
20058
|
const os = require$$1;
|
|
19984
20059
|
/**
|
|
19985
20060
|
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
@@ -25821,10 +25896,10 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
25821
25896
|
// TODO: use import()
|
|
25822
25897
|
const _require = createRequire$1(import.meta.url);
|
|
25823
25898
|
// get rollup version
|
|
25824
|
-
const rollupPkgPath = resolve$
|
|
25899
|
+
const rollupPkgPath = resolve$5(_require.resolve('rollup'), '../../package.json');
|
|
25825
25900
|
const minimalContext = {
|
|
25826
25901
|
meta: {
|
|
25827
|
-
rollupVersion: JSON.parse(
|
|
25902
|
+
rollupVersion: JSON.parse(fs$n.readFileSync(rollupPkgPath, 'utf-8'))
|
|
25828
25903
|
.version,
|
|
25829
25904
|
watchMode: true
|
|
25830
25905
|
}
|
|
@@ -25985,7 +26060,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
25985
26060
|
if (err.loc.file) {
|
|
25986
26061
|
err.id = normalizePath$3(err.loc.file);
|
|
25987
26062
|
try {
|
|
25988
|
-
code =
|
|
26063
|
+
code = fs$n.readFileSync(err.loc.file, 'utf-8');
|
|
25989
26064
|
}
|
|
25990
26065
|
catch { }
|
|
25991
26066
|
}
|
|
@@ -26105,7 +26180,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
26105
26180
|
}
|
|
26106
26181
|
}));
|
|
26107
26182
|
},
|
|
26108
|
-
async resolveId(rawId, importer = join$
|
|
26183
|
+
async resolveId(rawId, importer = join$2(root, 'index.html'), options) {
|
|
26109
26184
|
const skip = options?.skip;
|
|
26110
26185
|
const ssr = options?.ssr;
|
|
26111
26186
|
const scan = !!options?.scan;
|
|
@@ -26229,7 +26304,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
26229
26304
|
return container;
|
|
26230
26305
|
}
|
|
26231
26306
|
|
|
26232
|
-
function
|
|
26307
|
+
function stripLiteralAcorn(code) {
|
|
26233
26308
|
const FILL = " ";
|
|
26234
26309
|
let result = "";
|
|
26235
26310
|
function fulfill(index) {
|
|
@@ -26245,26 +26320,54 @@ function stripLiteral(code, forgiving = false) {
|
|
|
26245
26320
|
});
|
|
26246
26321
|
const inter = tokens[Symbol.iterator]();
|
|
26247
26322
|
while (true) {
|
|
26248
|
-
|
|
26249
|
-
|
|
26250
|
-
|
|
26251
|
-
|
|
26252
|
-
|
|
26253
|
-
|
|
26254
|
-
|
|
26255
|
-
|
|
26256
|
-
|
|
26257
|
-
|
|
26258
|
-
result += code.slice(token.start, token.end);
|
|
26259
|
-
} catch (e) {
|
|
26260
|
-
if (!forgiving)
|
|
26261
|
-
throw e;
|
|
26262
|
-
}
|
|
26323
|
+
const { done, value: token } = inter.next();
|
|
26324
|
+
if (done)
|
|
26325
|
+
break;
|
|
26326
|
+
fulfill(token.start);
|
|
26327
|
+
if (token.type.label === "string")
|
|
26328
|
+
result += code[token.start] + FILL.repeat(token.end - token.start - 2) + code[token.end - 1];
|
|
26329
|
+
else if (token.type.label === "template")
|
|
26330
|
+
result += FILL.repeat(token.end - token.start);
|
|
26331
|
+
else
|
|
26332
|
+
result += code.slice(token.start, token.end);
|
|
26263
26333
|
}
|
|
26264
26334
|
fulfill(code.length);
|
|
26265
26335
|
return result;
|
|
26266
26336
|
}
|
|
26267
26337
|
|
|
26338
|
+
const multilineCommentsRE = /\/\*.*?\*\//gms;
|
|
26339
|
+
const singlelineCommentsRE = /\/\/.*$/gm;
|
|
26340
|
+
const templateLiteralRE = /\$\{(\s*(?:(?!\$\{).|\n|\r)*?\s*)\}/g;
|
|
26341
|
+
const quotesRE = [
|
|
26342
|
+
/(["'`])((?:\\\1|(?!\1)|.|\r)*?)\1/gm,
|
|
26343
|
+
/([`])((?:\\\1|(?!\1)|.|\n|\r)*?)\1/gm
|
|
26344
|
+
];
|
|
26345
|
+
function stripLiteralRegex(code) {
|
|
26346
|
+
code = code.replace(multilineCommentsRE, (s) => " ".repeat(s.length)).replace(singlelineCommentsRE, (s) => " ".repeat(s.length));
|
|
26347
|
+
let expanded = code;
|
|
26348
|
+
for (let i = 0; i < 16; i++) {
|
|
26349
|
+
const before = expanded;
|
|
26350
|
+
expanded = expanded.replace(templateLiteralRE, "` $1`");
|
|
26351
|
+
if (expanded === before)
|
|
26352
|
+
break;
|
|
26353
|
+
}
|
|
26354
|
+
quotesRE.forEach((re) => {
|
|
26355
|
+
expanded = expanded.replace(re, (s, quote, body, index) => {
|
|
26356
|
+
code = code.slice(0, index + 1) + " ".repeat(s.length - 2) + code.slice(index + s.length - 1);
|
|
26357
|
+
return quote + " ".repeat(s.length - 2) + quote;
|
|
26358
|
+
});
|
|
26359
|
+
});
|
|
26360
|
+
return code;
|
|
26361
|
+
}
|
|
26362
|
+
|
|
26363
|
+
function stripLiteral(code) {
|
|
26364
|
+
try {
|
|
26365
|
+
return stripLiteralAcorn(code);
|
|
26366
|
+
} catch (e) {
|
|
26367
|
+
return stripLiteralRegex(code);
|
|
26368
|
+
}
|
|
26369
|
+
}
|
|
26370
|
+
|
|
26268
26371
|
const HASH_RE = /#/g;
|
|
26269
26372
|
const AMPERSAND_RE = /&/g;
|
|
26270
26373
|
const EQUAL_RE = /=/g;
|
|
@@ -26326,7 +26429,7 @@ function importGlobPlugin(config) {
|
|
|
26326
26429
|
async transform(code, id) {
|
|
26327
26430
|
if (!code.includes('import.meta.glob'))
|
|
26328
26431
|
return;
|
|
26329
|
-
const result = await transformGlobImport(code, id, config.root, (im) => this.resolve(im, id).then((i) => i?.id || im), config.experimental
|
|
26432
|
+
const result = await transformGlobImport(code, id, config.root, (im) => this.resolve(im, id).then((i) => i?.id || im), config.experimental.importGlobRestoreExtension);
|
|
26330
26433
|
if (result) {
|
|
26331
26434
|
if (server) {
|
|
26332
26435
|
const allGlobs = result.matches.map((i) => i.globsResolved);
|
|
@@ -26504,7 +26607,7 @@ async function parseImportGlob(code, importer, root, resolveId) {
|
|
|
26504
26607
|
return (await Promise.all(tasks)).filter(Boolean);
|
|
26505
26608
|
}
|
|
26506
26609
|
const importPrefix = '__vite_glob_';
|
|
26507
|
-
const { basename, dirname, relative, join } = posix$
|
|
26610
|
+
const { basename, dirname, relative, join } = posix$2;
|
|
26508
26611
|
/**
|
|
26509
26612
|
* @param optimizeExport for dynamicImportVar plugin don't need to optimize export.
|
|
26510
26613
|
*/
|
|
@@ -26619,15 +26722,15 @@ async function toAbsoluteGlob(glob, root, importer, resolveId) {
|
|
|
26619
26722
|
}
|
|
26620
26723
|
const dir = importer ? dirname(importer) : root;
|
|
26621
26724
|
if (glob.startsWith('/'))
|
|
26622
|
-
return pre + posix$
|
|
26725
|
+
return pre + posix$2.join(root, glob.slice(1));
|
|
26623
26726
|
if (glob.startsWith('./'))
|
|
26624
|
-
return pre + posix$
|
|
26727
|
+
return pre + posix$2.join(dir, glob.slice(2));
|
|
26625
26728
|
if (glob.startsWith('../'))
|
|
26626
|
-
return pre + posix$
|
|
26729
|
+
return pre + posix$2.join(dir, glob);
|
|
26627
26730
|
if (glob.startsWith('**'))
|
|
26628
26731
|
return pre + glob;
|
|
26629
26732
|
const resolved = normalizePath$3((await resolveId(glob, importer)) || glob);
|
|
26630
|
-
if (isAbsolute$
|
|
26733
|
+
if (isAbsolute$4(resolved))
|
|
26631
26734
|
return pre + resolved;
|
|
26632
26735
|
throw new Error(`Invalid glob: "${glob}" (resolved: "${resolved}"). It must starts with '/' or './'`);
|
|
26633
26736
|
}
|
|
@@ -26637,8 +26740,8 @@ function getCommonBase(globsResolved) {
|
|
|
26637
26740
|
.map((glob) => {
|
|
26638
26741
|
let { base } = scan(glob);
|
|
26639
26742
|
// `scan('a/foo.js')` returns `base: 'a/foo.js'`
|
|
26640
|
-
if (posix$
|
|
26641
|
-
base = posix$
|
|
26743
|
+
if (posix$2.basename(base).includes('.'))
|
|
26744
|
+
base = posix$2.dirname(base);
|
|
26642
26745
|
return base;
|
|
26643
26746
|
});
|
|
26644
26747
|
if (!bases.length)
|
|
@@ -26681,7 +26784,7 @@ async function scanImports(config) {
|
|
|
26681
26784
|
entries = await globEntries(explicitEntryPatterns, config);
|
|
26682
26785
|
}
|
|
26683
26786
|
else if (buildInput) {
|
|
26684
|
-
const resolvePath = (p) => path$
|
|
26787
|
+
const resolvePath = (p) => path$q.resolve(config.root, p);
|
|
26685
26788
|
if (typeof buildInput === 'string') {
|
|
26686
26789
|
entries = [resolvePath(buildInput)];
|
|
26687
26790
|
}
|
|
@@ -26700,7 +26803,7 @@ async function scanImports(config) {
|
|
|
26700
26803
|
}
|
|
26701
26804
|
// Non-supported entry file types and virtual files should not be scanned for
|
|
26702
26805
|
// dependencies.
|
|
26703
|
-
entries = entries.filter((entry) => isScannable(entry) &&
|
|
26806
|
+
entries = entries.filter((entry) => isScannable(entry) && fs$n.existsSync(entry));
|
|
26704
26807
|
if (!entries.length) {
|
|
26705
26808
|
if (!explicitEntryPatterns && !config.optimizeDeps.include) {
|
|
26706
26809
|
config.logger.warn(colors$1.yellow('(!) Could not auto-determine entry point from rollupOptions or html files ' +
|
|
@@ -26764,7 +26867,7 @@ const contextRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
|
26764
26867
|
function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
26765
26868
|
const seen = new Map();
|
|
26766
26869
|
const resolve = async (id, importer) => {
|
|
26767
|
-
const key = id + (importer && path$
|
|
26870
|
+
const key = id + (importer && path$q.dirname(importer));
|
|
26768
26871
|
if (seen.has(key)) {
|
|
26769
26872
|
return seen.get(key);
|
|
26770
26873
|
}
|
|
@@ -26829,7 +26932,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
26829
26932
|
});
|
|
26830
26933
|
// extract scripts inside HTML-like files and treat it as a js module
|
|
26831
26934
|
build.onLoad({ filter: htmlTypesRE, namespace: 'html' }, async ({ path }) => {
|
|
26832
|
-
let raw =
|
|
26935
|
+
let raw = fs$n.readFileSync(path, 'utf-8');
|
|
26833
26936
|
// Avoid matching the content of the comment
|
|
26834
26937
|
raw = raw.replace(commentRE$1, '<!---->');
|
|
26835
26938
|
const isHtml = path.endsWith('.html');
|
|
@@ -26949,7 +27052,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
26949
27052
|
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
|
|
26950
27053
|
// linked package, keep crawling
|
|
26951
27054
|
return {
|
|
26952
|
-
path: path$
|
|
27055
|
+
path: path$q.resolve(resolved),
|
|
26953
27056
|
namespace
|
|
26954
27057
|
};
|
|
26955
27058
|
}
|
|
@@ -26991,7 +27094,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
26991
27094
|
}
|
|
26992
27095
|
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
|
|
26993
27096
|
return {
|
|
26994
|
-
path: path$
|
|
27097
|
+
path: path$q.resolve(cleanUrl(resolved)),
|
|
26995
27098
|
namespace
|
|
26996
27099
|
};
|
|
26997
27100
|
}
|
|
@@ -27004,10 +27107,10 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
27004
27107
|
// presence of import.meta.glob, since it results in import relationships
|
|
27005
27108
|
// but isn't crawled by esbuild.
|
|
27006
27109
|
build.onLoad({ filter: JS_TYPES_RE }, ({ path: id }) => {
|
|
27007
|
-
let ext = path$
|
|
27110
|
+
let ext = path$q.extname(id).slice(1);
|
|
27008
27111
|
if (ext === 'mjs')
|
|
27009
27112
|
ext = 'js';
|
|
27010
|
-
let contents =
|
|
27113
|
+
let contents = fs$n.readFileSync(id, 'utf-8');
|
|
27011
27114
|
if (ext.endsWith('x') && config.esbuild && config.esbuild.jsxInject) {
|
|
27012
27115
|
contents = config.esbuild.jsxInject + `\n` + contents;
|
|
27013
27116
|
}
|
|
@@ -27031,8 +27134,8 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
27031
27134
|
function extractImportPaths(code) {
|
|
27032
27135
|
// empty singleline & multiline comments to avoid matching comments
|
|
27033
27136
|
code = code
|
|
27034
|
-
.replace(multilineCommentsRE, '/* */')
|
|
27035
|
-
.replace(singlelineCommentsRE, '');
|
|
27137
|
+
.replace(multilineCommentsRE$1, '/* */')
|
|
27138
|
+
.replace(singlelineCommentsRE$1, '');
|
|
27036
27139
|
let js = '';
|
|
27037
27140
|
let m;
|
|
27038
27141
|
while ((m = importsRE.exec(code)) != null) {
|
|
@@ -27046,7 +27149,7 @@ function extractImportPaths(code) {
|
|
|
27046
27149
|
}
|
|
27047
27150
|
function shouldExternalizeDep(resolvedId, rawId) {
|
|
27048
27151
|
// not a valid file path
|
|
27049
|
-
if (!path$
|
|
27152
|
+
if (!path$q.isAbsolute(resolvedId)) {
|
|
27050
27153
|
return true;
|
|
27051
27154
|
}
|
|
27052
27155
|
// virtual id
|
|
@@ -27078,7 +27181,7 @@ var etag_1 = etag;
|
|
|
27078
27181
|
*/
|
|
27079
27182
|
|
|
27080
27183
|
var crypto = require$$1$2;
|
|
27081
|
-
var Stats =
|
|
27184
|
+
var Stats = require$$0__default.Stats;
|
|
27082
27185
|
|
|
27083
27186
|
/**
|
|
27084
27187
|
* Module variables.
|
|
@@ -27196,7 +27299,7 @@ var safeBuffer = {exports: {}};
|
|
|
27196
27299
|
/* eslint-disable node/no-deprecated-api */
|
|
27197
27300
|
|
|
27198
27301
|
(function (module, exports) {
|
|
27199
|
-
var buffer = require$$0$
|
|
27302
|
+
var buffer = require$$0$7;
|
|
27200
27303
|
var Buffer = buffer.Buffer;
|
|
27201
27304
|
|
|
27202
27305
|
// alternative to using Object.keys for old browsers
|
|
@@ -27260,7 +27363,7 @@ SafeBuffer.allocUnsafeSlow = function (size) {
|
|
|
27260
27363
|
}(safeBuffer, safeBuffer.exports));
|
|
27261
27364
|
|
|
27262
27365
|
(function (exports) {
|
|
27263
|
-
var fs =
|
|
27366
|
+
var fs = require$$0__default;
|
|
27264
27367
|
var path = path$p;
|
|
27265
27368
|
var SafeBuffer = safeBuffer.exports;
|
|
27266
27369
|
|
|
@@ -27836,7 +27939,6 @@ function registerCustomMime() {
|
|
|
27836
27939
|
function assetPlugin(config) {
|
|
27837
27940
|
// assetHashToFilenameMap initialization in buildStart causes getAssetFilename to return undefined
|
|
27838
27941
|
assetHashToFilenameMap.set(config, new Map());
|
|
27839
|
-
const relativeBase = isRelativeBase(config.base);
|
|
27840
27942
|
registerCustomMime();
|
|
27841
27943
|
return {
|
|
27842
27944
|
name: 'vite:asset',
|
|
@@ -27865,7 +27967,7 @@ function assetPlugin(config) {
|
|
|
27865
27967
|
if (rawRE.test(id)) {
|
|
27866
27968
|
const file = checkPublicFile(id, config) || cleanUrl(id);
|
|
27867
27969
|
// raw query, read file and return as string
|
|
27868
|
-
return `export default ${JSON.stringify(await promises.readFile(file, 'utf-8'))}`;
|
|
27970
|
+
return `export default ${JSON.stringify(await promises$2.readFile(file, 'utf-8'))}`;
|
|
27869
27971
|
}
|
|
27870
27972
|
if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
|
|
27871
27973
|
return;
|
|
@@ -27877,7 +27979,14 @@ function assetPlugin(config) {
|
|
|
27877
27979
|
renderChunk(code, chunk) {
|
|
27878
27980
|
let match;
|
|
27879
27981
|
let s;
|
|
27880
|
-
const absoluteUrlPathInterpolation = (filename) => `"+new URL(${JSON.stringify(path$
|
|
27982
|
+
const absoluteUrlPathInterpolation = (filename) => `"+new URL(${JSON.stringify(path$q.posix.relative(path$q.dirname(chunk.fileName), filename))},import.meta.url).href+"`;
|
|
27983
|
+
const toOutputFilePathInString = (filename, base) => {
|
|
27984
|
+
return base.runtime
|
|
27985
|
+
? `"+${base.runtime(JSON.stringify(filename))}+"`
|
|
27986
|
+
: base.relative && !config.build.ssr
|
|
27987
|
+
? absoluteUrlPathInterpolation(filename)
|
|
27988
|
+
: JSON.stringify((base.url ?? config.base) + filename).slice(1, -1);
|
|
27989
|
+
};
|
|
27881
27990
|
// Urls added with JS using e.g.
|
|
27882
27991
|
// imgElement.src = "__VITE_ASSET__5aa0ddc0__" are using quotes
|
|
27883
27992
|
// Urls added in CSS that is imported in JS end up like
|
|
@@ -27891,25 +28000,21 @@ function assetPlugin(config) {
|
|
|
27891
28000
|
const file = getAssetFilename(hash, config) || this.getFileName(hash);
|
|
27892
28001
|
chunk.viteMetadata.importedAssets.add(cleanUrl(file));
|
|
27893
28002
|
const filename = file + postfix;
|
|
27894
|
-
const
|
|
27895
|
-
|
|
27896
|
-
: JSON.stringify(config.base + filename).slice(1, -1);
|
|
27897
|
-
s.overwrite(match.index, match.index + full.length, outputFilepath, {
|
|
28003
|
+
const replacement = toOutputFilePathInString(filename, config.experimental.buildAdvancedBaseOptions.assets);
|
|
28004
|
+
s.overwrite(match.index, match.index + full.length, replacement, {
|
|
27898
28005
|
contentOnly: true
|
|
27899
28006
|
});
|
|
27900
28007
|
}
|
|
27901
28008
|
// Replace __VITE_PUBLIC_ASSET__5aa0ddc0__ with absolute paths
|
|
27902
|
-
|
|
27903
|
-
|
|
27904
|
-
|
|
27905
|
-
|
|
27906
|
-
|
|
27907
|
-
|
|
27908
|
-
|
|
27909
|
-
|
|
27910
|
-
|
|
27911
|
-
});
|
|
27912
|
-
}
|
|
28009
|
+
const publicAssetUrlMap = publicAssetUrlCache.get(config);
|
|
28010
|
+
while ((match = publicAssetUrlRE.exec(code))) {
|
|
28011
|
+
s = s || (s = new MagicString(code));
|
|
28012
|
+
const [full, hash] = match;
|
|
28013
|
+
const publicUrl = publicAssetUrlMap.get(hash).slice(1);
|
|
28014
|
+
const replacement = toOutputFilePathInString(publicUrl, config.experimental.buildAdvancedBaseOptions.public);
|
|
28015
|
+
s.overwrite(match.index, match.index + full.length, replacement, {
|
|
28016
|
+
contentOnly: true
|
|
28017
|
+
});
|
|
27913
28018
|
}
|
|
27914
28019
|
if (s) {
|
|
27915
28020
|
return {
|
|
@@ -27940,8 +28045,8 @@ function checkPublicFile(url, { publicDir }) {
|
|
|
27940
28045
|
if (!publicDir || !url.startsWith('/')) {
|
|
27941
28046
|
return;
|
|
27942
28047
|
}
|
|
27943
|
-
const publicFile = path$
|
|
27944
|
-
if (
|
|
28048
|
+
const publicFile = path$q.join(publicDir, cleanUrl(url));
|
|
28049
|
+
if (fs$n.existsSync(publicFile)) {
|
|
27945
28050
|
return publicFile;
|
|
27946
28051
|
}
|
|
27947
28052
|
else {
|
|
@@ -27964,19 +28069,34 @@ function fileToDevUrl(id, config) {
|
|
|
27964
28069
|
}
|
|
27965
28070
|
else if (id.startsWith(config.root)) {
|
|
27966
28071
|
// in project root, infer short public path
|
|
27967
|
-
rtn = '/' + path$
|
|
28072
|
+
rtn = '/' + path$q.posix.relative(config.root, id);
|
|
27968
28073
|
}
|
|
27969
28074
|
else {
|
|
27970
28075
|
// outside of project root, use absolute fs path
|
|
27971
28076
|
// (this is special handled by the serve static middleware
|
|
27972
|
-
rtn = path$
|
|
28077
|
+
rtn = path$q.posix.join(FS_PREFIX + id);
|
|
27973
28078
|
}
|
|
27974
28079
|
const origin = config.server?.origin ?? '';
|
|
27975
|
-
|
|
28080
|
+
const devBase = config.base;
|
|
28081
|
+
return origin + devBase + rtn.replace(/^\//, '');
|
|
27976
28082
|
}
|
|
27977
28083
|
function getAssetFilename(hash, config) {
|
|
27978
28084
|
return assetHashToFilenameMap.get(config)?.get(hash);
|
|
27979
28085
|
}
|
|
28086
|
+
function resolveAssetFileNames(config) {
|
|
28087
|
+
const output = config.build?.rollupOptions?.output;
|
|
28088
|
+
const defaultAssetFileNames = path$q.posix.join(config.build.assetsDir, '[name].[hash][extname]');
|
|
28089
|
+
// Steps to determine which assetFileNames will be actually used.
|
|
28090
|
+
// First, if output is an object or string, use assetFileNames in it.
|
|
28091
|
+
// And a default assetFileNames as fallback.
|
|
28092
|
+
let assetFileNames = (output && !Array.isArray(output) ? output.assetFileNames : undefined) ??
|
|
28093
|
+
defaultAssetFileNames;
|
|
28094
|
+
if (output && Array.isArray(output)) {
|
|
28095
|
+
// Second, if output is an array, adopt assetFileNames in the first object.
|
|
28096
|
+
assetFileNames = output[0].assetFileNames ?? assetFileNames;
|
|
28097
|
+
}
|
|
28098
|
+
return assetFileNames;
|
|
28099
|
+
}
|
|
27980
28100
|
/**
|
|
27981
28101
|
* converts the source filepath of the asset to the output filename based on the assetFileNames option. \
|
|
27982
28102
|
* this function imitates the behavior of rollup.js. \
|
|
@@ -28001,10 +28121,10 @@ function getAssetFilename(hash, config) {
|
|
|
28001
28121
|
* @returns output filename
|
|
28002
28122
|
*/
|
|
28003
28123
|
function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
|
|
28004
|
-
const basename = path$
|
|
28124
|
+
const basename = path$q.basename(file);
|
|
28005
28125
|
// placeholders for `assetFileNames`
|
|
28006
28126
|
// `hash` is slightly different from the rollup's one
|
|
28007
|
-
const extname = path$
|
|
28127
|
+
const extname = path$q.extname(basename);
|
|
28008
28128
|
const ext = extname.substring(1);
|
|
28009
28129
|
const name = basename.slice(0, -extname.length);
|
|
28010
28130
|
const hash = contentHash;
|
|
@@ -28039,7 +28159,8 @@ function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
|
|
|
28039
28159
|
const publicAssetUrlCache = new WeakMap();
|
|
28040
28160
|
const publicAssetUrlRE = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g;
|
|
28041
28161
|
function publicFileToBuiltUrl(url, config) {
|
|
28042
|
-
if (
|
|
28162
|
+
if (config.command !== 'build') {
|
|
28163
|
+
// We don't need relative base or buildAdvancedBaseOptions support during dev
|
|
28043
28164
|
return config.base + url.slice(1);
|
|
28044
28165
|
}
|
|
28045
28166
|
const hash = getHash(url);
|
|
@@ -28067,7 +28188,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
|
28067
28188
|
return cached;
|
|
28068
28189
|
}
|
|
28069
28190
|
const file = cleanUrl(id);
|
|
28070
|
-
const content = await promises.readFile(file);
|
|
28191
|
+
const content = await promises$2.readFile(file);
|
|
28071
28192
|
let url;
|
|
28072
28193
|
if (config.build.lib ||
|
|
28073
28194
|
(!file.endsWith('.svg') &&
|
|
@@ -28088,18 +28209,13 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
|
28088
28209
|
const contentHash = getHash(content);
|
|
28089
28210
|
const { search, hash } = parse$m(id);
|
|
28090
28211
|
const postfix = (search || '') + (hash || '');
|
|
28091
|
-
const
|
|
28092
|
-
const assetFileNames = (output && !Array.isArray(output) ? output.assetFileNames : undefined) ??
|
|
28093
|
-
// defaults to '<assetsDir>/[name].[hash][extname]'
|
|
28094
|
-
// slightly different from rollup's one ('assets/[name]-[hash][extname]')
|
|
28095
|
-
path$p.posix.join(config.build.assetsDir, '[name].[hash][extname]');
|
|
28096
|
-
const fileName = assetFileNamesToFileName(assetFileNames, file, contentHash, content);
|
|
28212
|
+
const fileName = assetFileNamesToFileName(resolveAssetFileNames(config), file, contentHash, content);
|
|
28097
28213
|
if (!map.has(contentHash)) {
|
|
28098
28214
|
map.set(contentHash, fileName);
|
|
28099
28215
|
}
|
|
28100
28216
|
const emittedSet = emittedHashMap.get(config);
|
|
28101
28217
|
if (!emittedSet.has(contentHash)) {
|
|
28102
|
-
const name = normalizePath$3(path$
|
|
28218
|
+
const name = normalizePath$3(path$q.relative(config.root, file));
|
|
28103
28219
|
pluginContext.emitFile({
|
|
28104
28220
|
name,
|
|
28105
28221
|
fileName,
|
|
@@ -28118,8 +28234,8 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
|
|
|
28118
28234
|
return publicFileToBuiltUrl(url, config);
|
|
28119
28235
|
}
|
|
28120
28236
|
const file = url.startsWith('/')
|
|
28121
|
-
? path$
|
|
28122
|
-
: path$
|
|
28237
|
+
? path$q.join(config.root, url)
|
|
28238
|
+
: path$q.join(path$q.dirname(importer), url);
|
|
28123
28239
|
return fileToBuiltUrl(file, config, pluginContext,
|
|
28124
28240
|
// skip public check since we just did it above
|
|
28125
28241
|
true);
|
|
@@ -28406,6 +28522,7 @@ function jsonPlugin(options = {}, isBuild) {
|
|
|
28406
28522
|
return null;
|
|
28407
28523
|
if (SPECIAL_QUERY_RE.test(id))
|
|
28408
28524
|
return null;
|
|
28525
|
+
json = stripBomTag(json);
|
|
28409
28526
|
try {
|
|
28410
28527
|
if (options.stringify) {
|
|
28411
28528
|
if (isBuild) {
|
|
@@ -28938,8 +29055,8 @@ function viaLocal(dir, isEtag, uri, extns) {
|
|
|
28938
29055
|
let abs, stats, name, headers;
|
|
28939
29056
|
for (; i < arr.length; i++) {
|
|
28940
29057
|
abs = normalize(join$1(dir, name=arr[i]));
|
|
28941
|
-
if (abs.startsWith(dir) &&
|
|
28942
|
-
stats =
|
|
29058
|
+
if (abs.startsWith(dir) && require$$0$2.existsSync(abs)) {
|
|
29059
|
+
stats = require$$0$2.statSync(abs);
|
|
28943
29060
|
if (stats.isDirectory()) continue;
|
|
28944
29061
|
headers = toHeaders(name, stats, isEtag);
|
|
28945
29062
|
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
|
|
@@ -28983,7 +29100,7 @@ function send$2(req, res, file, stats, headers) {
|
|
|
28983
29100
|
}
|
|
28984
29101
|
|
|
28985
29102
|
res.writeHead(code, headers);
|
|
28986
|
-
|
|
29103
|
+
require$$0$2.createReadStream(file, opts).pipe(res);
|
|
28987
29104
|
}
|
|
28988
29105
|
|
|
28989
29106
|
const ENCODING = {
|
|
@@ -29131,7 +29248,7 @@ function serveStaticMiddleware(dir, server) {
|
|
|
29131
29248
|
// also skip internal requests `/@fs/ /@vite-client` etc...
|
|
29132
29249
|
const cleanedUrl = cleanUrl(req.url);
|
|
29133
29250
|
if (cleanedUrl.endsWith('/') ||
|
|
29134
|
-
path$
|
|
29251
|
+
path$q.extname(cleanedUrl) === '.html' ||
|
|
29135
29252
|
isInternalRequest(req.url)) {
|
|
29136
29253
|
return next();
|
|
29137
29254
|
}
|
|
@@ -29152,7 +29269,7 @@ function serveStaticMiddleware(dir, server) {
|
|
|
29152
29269
|
}
|
|
29153
29270
|
}
|
|
29154
29271
|
const resolvedUrl = redirected || url;
|
|
29155
|
-
let fileUrl = path$
|
|
29272
|
+
let fileUrl = path$q.resolve(dir, resolvedUrl.replace(/^\//, ''));
|
|
29156
29273
|
if (resolvedUrl.endsWith('/') && !fileUrl.endsWith('/')) {
|
|
29157
29274
|
fileUrl = fileUrl + '/';
|
|
29158
29275
|
}
|
|
@@ -29176,11 +29293,11 @@ function serveRawFsMiddleware(server) {
|
|
|
29176
29293
|
// searching based from fs root.
|
|
29177
29294
|
if (url.startsWith(FS_PREFIX)) {
|
|
29178
29295
|
// restrict files outside of `fs.allow`
|
|
29179
|
-
if (!ensureServingAccess(slash$1(path$
|
|
29296
|
+
if (!ensureServingAccess(slash$1(path$q.resolve(fsPathFromId(url))), server, res, next)) {
|
|
29180
29297
|
return;
|
|
29181
29298
|
}
|
|
29182
29299
|
url = url.slice(FS_PREFIX.length);
|
|
29183
|
-
if (isWindows$
|
|
29300
|
+
if (isWindows$4)
|
|
29184
29301
|
url = url.replace(/^[A-Z]:/i, '');
|
|
29185
29302
|
req.url = url;
|
|
29186
29303
|
serveFromRoot(req, res, next);
|
|
@@ -29346,7 +29463,7 @@ async function doTransform(url, server, options, timestamp) {
|
|
|
29346
29463
|
// like /service-worker.js or /api/users
|
|
29347
29464
|
if (options.ssr || isFileServingAllowed(file, server)) {
|
|
29348
29465
|
try {
|
|
29349
|
-
code = await promises.readFile(file, 'utf-8');
|
|
29466
|
+
code = await promises$2.readFile(file, 'utf-8');
|
|
29350
29467
|
isDebug$3 && debugLoad(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
|
|
29351
29468
|
}
|
|
29352
29469
|
catch (e) {
|
|
@@ -29358,7 +29475,7 @@ async function doTransform(url, server, options, timestamp) {
|
|
|
29358
29475
|
if (code) {
|
|
29359
29476
|
try {
|
|
29360
29477
|
map = (convertSourceMap.fromSource(code) ||
|
|
29361
|
-
convertSourceMap.fromMapFileSource(code, path$
|
|
29478
|
+
convertSourceMap.fromMapFileSource(code, path$q.dirname(file)))?.toObject();
|
|
29362
29479
|
}
|
|
29363
29480
|
catch (e) {
|
|
29364
29481
|
logger.warn(`Failed to load source map for ${url}.`, {
|
|
@@ -29448,12 +29565,21 @@ function getDepsOptimizer(config) {
|
|
|
29448
29565
|
async function initDepsOptimizer(config, server) {
|
|
29449
29566
|
const { logger } = config;
|
|
29450
29567
|
const isBuild = config.command === 'build';
|
|
29451
|
-
const scan = config.command !== 'build' && config.
|
|
29568
|
+
const scan = config.command !== 'build' && config.legacy?.devDepsScanner;
|
|
29452
29569
|
const sessionTimestamp = Date.now().toString();
|
|
29453
29570
|
const cachedMetadata = loadCachedDepOptimizationMetadata(config);
|
|
29454
29571
|
let handle;
|
|
29572
|
+
let ssrServerDepsMetadata;
|
|
29573
|
+
let _metadata = cachedMetadata || initDepsOptimizerMetadata(config, sessionTimestamp);
|
|
29455
29574
|
const depsOptimizer = {
|
|
29456
|
-
metadata:
|
|
29575
|
+
metadata: (options) => {
|
|
29576
|
+
if (isBuild || !options.ssr) {
|
|
29577
|
+
return _metadata;
|
|
29578
|
+
}
|
|
29579
|
+
else {
|
|
29580
|
+
return ssrServerDepsMetadata;
|
|
29581
|
+
}
|
|
29582
|
+
},
|
|
29457
29583
|
registerMissingImport,
|
|
29458
29584
|
run: () => debouncedProcessing(0),
|
|
29459
29585
|
isOptimizedDepFile: (id) => isOptimizedDepFile(id, config),
|
|
@@ -29465,6 +29591,9 @@ async function initDepsOptimizer(config, server) {
|
|
|
29465
29591
|
options: config.optimizeDeps
|
|
29466
29592
|
};
|
|
29467
29593
|
depsOptimizerMap.set(config, depsOptimizer);
|
|
29594
|
+
if (!isBuild && config.ssr) {
|
|
29595
|
+
ssrServerDepsMetadata = await optimizeServerSsrDeps(config);
|
|
29596
|
+
}
|
|
29468
29597
|
let newDepsDiscovered = false;
|
|
29469
29598
|
let newDepsToLog = [];
|
|
29470
29599
|
let newDepsToLogHandle;
|
|
@@ -29495,7 +29624,7 @@ async function initDepsOptimizer(config, server) {
|
|
|
29495
29624
|
if (!scan) {
|
|
29496
29625
|
// Initialize discovered deps with manually added optimizeDeps.include info
|
|
29497
29626
|
const discovered = await initialProjectDependencies(config, sessionTimestamp);
|
|
29498
|
-
const
|
|
29627
|
+
const metadata = _metadata;
|
|
29499
29628
|
for (const depInfo of Object.values(discovered)) {
|
|
29500
29629
|
addOptimizedDepInfo(metadata, 'discovered', {
|
|
29501
29630
|
...depInfo,
|
|
@@ -29511,7 +29640,7 @@ async function initDepsOptimizer(config, server) {
|
|
|
29511
29640
|
setTimeout(async () => {
|
|
29512
29641
|
try {
|
|
29513
29642
|
debuggerViteDeps(colors$1.green(`scanning for dependencies...`));
|
|
29514
|
-
const
|
|
29643
|
+
const metadata = _metadata;
|
|
29515
29644
|
const discovered = await discoverProjectDependencies(config, sessionTimestamp);
|
|
29516
29645
|
// Respect the scan phase discover order to improve reproducibility
|
|
29517
29646
|
for (const depInfo of Object.values(discovered)) {
|
|
@@ -29543,7 +29672,7 @@ async function initDepsOptimizer(config, server) {
|
|
|
29543
29672
|
// Ensure that a rerun will not be issued for current discovered deps
|
|
29544
29673
|
if (handle)
|
|
29545
29674
|
clearTimeout(handle);
|
|
29546
|
-
if (Object.keys(
|
|
29675
|
+
if (Object.keys(_metadata.discovered).length === 0) {
|
|
29547
29676
|
currentlyProcessing = false;
|
|
29548
29677
|
return;
|
|
29549
29678
|
}
|
|
@@ -29551,11 +29680,11 @@ async function initDepsOptimizer(config, server) {
|
|
|
29551
29680
|
// a succesful completion of the optimizeDeps rerun will end up
|
|
29552
29681
|
// creating new bundled version of all current and discovered deps
|
|
29553
29682
|
// in the cache dir and a new metadata info object assigned
|
|
29554
|
-
// to
|
|
29555
|
-
//
|
|
29556
|
-
// if the rerun fails,
|
|
29557
|
-
//
|
|
29558
|
-
let
|
|
29683
|
+
// to _metadata. A fullReload is only issued if the previous bundled
|
|
29684
|
+
// dependencies have changed.
|
|
29685
|
+
// if the rerun fails, _metadata remains untouched, current discovered
|
|
29686
|
+
// deps are cleaned, and a fullReload is issued
|
|
29687
|
+
let metadata = _metadata;
|
|
29559
29688
|
// All deps, previous known and newly discovered are rebundled,
|
|
29560
29689
|
// respect insertion order to keep the metadata file stable
|
|
29561
29690
|
const newDeps = {};
|
|
@@ -29635,7 +29764,7 @@ async function initDepsOptimizer(config, server) {
|
|
|
29635
29764
|
if (isRerun) {
|
|
29636
29765
|
newDepsToLog.push(...Object.keys(newData.optimized).filter((dep) => !metadata.optimized[dep]));
|
|
29637
29766
|
}
|
|
29638
|
-
metadata =
|
|
29767
|
+
metadata = _metadata = newData;
|
|
29639
29768
|
resolveEnqueuedProcessingPromises();
|
|
29640
29769
|
};
|
|
29641
29770
|
if (!needsReload) {
|
|
@@ -29707,7 +29836,7 @@ async function initDepsOptimizer(config, server) {
|
|
|
29707
29836
|
// debounce time to wait for new missing deps finished, issue a new
|
|
29708
29837
|
// optimization of deps (both old and newly found) once the previous
|
|
29709
29838
|
// optimizeDeps processing is finished
|
|
29710
|
-
const deps = Object.keys(
|
|
29839
|
+
const deps = Object.keys(_metadata.discovered);
|
|
29711
29840
|
const depsString = depsLogString(deps);
|
|
29712
29841
|
debuggerViteDeps(colors$1.green(`new dependencies found: ${depsString}`));
|
|
29713
29842
|
runOptimizer();
|
|
@@ -29719,7 +29848,10 @@ async function initDepsOptimizer(config, server) {
|
|
|
29719
29848
|
if (depsOptimizer.scanProcessing) {
|
|
29720
29849
|
config.logger.error('Vite internal error: registering missing import before initial scanning is over');
|
|
29721
29850
|
}
|
|
29722
|
-
|
|
29851
|
+
if (!isBuild && ssr) {
|
|
29852
|
+
config.logger.error(`Error: ${id} is a missing dependency in SSR dev server, it needs to be added to optimizeDeps.include`);
|
|
29853
|
+
}
|
|
29854
|
+
const metadata = _metadata;
|
|
29723
29855
|
const optimized = metadata.optimized[id];
|
|
29724
29856
|
if (optimized) {
|
|
29725
29857
|
return optimized;
|
|
@@ -29737,7 +29869,7 @@ async function initDepsOptimizer(config, server) {
|
|
|
29737
29869
|
newDepsDiscovered = true;
|
|
29738
29870
|
missing = addOptimizedDepInfo(metadata, 'discovered', {
|
|
29739
29871
|
id,
|
|
29740
|
-
file: getOptimizedDepPath(id, config),
|
|
29872
|
+
file: getOptimizedDepPath(id, config, ssr),
|
|
29741
29873
|
src: resolved,
|
|
29742
29874
|
// Assing a browserHash to this missing dependency that is unique to
|
|
29743
29875
|
// the current state of known + missing deps. If its optimizeDeps run
|
|
@@ -29865,7 +29997,7 @@ const jsMapExtensionRE = /\.js\.map$/i;
|
|
|
29865
29997
|
/**
|
|
29866
29998
|
* Used by Vite CLI when running `vite optimize`
|
|
29867
29999
|
*/
|
|
29868
|
-
async function optimizeDeps(config, force = config.force, asCommand = false) {
|
|
30000
|
+
async function optimizeDeps(config, force = config.optimizeDeps.force, asCommand = false) {
|
|
29869
30001
|
const log = asCommand ? config.logger.info : debug$a;
|
|
29870
30002
|
const cachedMetadata = loadCachedDepOptimizationMetadata(config, force, asCommand);
|
|
29871
30003
|
if (cachedMetadata) {
|
|
@@ -29878,6 +30010,31 @@ async function optimizeDeps(config, force = config.force, asCommand = false) {
|
|
|
29878
30010
|
await result.commit();
|
|
29879
30011
|
return result.metadata;
|
|
29880
30012
|
}
|
|
30013
|
+
async function optimizeServerSsrDeps(config) {
|
|
30014
|
+
const cachedMetadata = loadCachedDepOptimizationMetadata(config, config.optimizeDeps.force, false, true // ssr
|
|
30015
|
+
);
|
|
30016
|
+
if (cachedMetadata) {
|
|
30017
|
+
return cachedMetadata;
|
|
30018
|
+
}
|
|
30019
|
+
let alsoInclude;
|
|
30020
|
+
let noExternalFilter;
|
|
30021
|
+
const noExternal = config.ssr?.noExternal;
|
|
30022
|
+
if (noExternal) {
|
|
30023
|
+
alsoInclude = arraify(noExternal).filter((ne) => typeof ne === 'string');
|
|
30024
|
+
noExternalFilter =
|
|
30025
|
+
noExternal === true
|
|
30026
|
+
? (dep) => false
|
|
30027
|
+
: createFilter$1(noExternal, config.optimizeDeps?.exclude, {
|
|
30028
|
+
resolve: false
|
|
30029
|
+
});
|
|
30030
|
+
}
|
|
30031
|
+
const deps = {};
|
|
30032
|
+
await addManuallyIncludedOptimizeDeps(deps, config, alsoInclude, noExternalFilter);
|
|
30033
|
+
const depsInfo = toDiscoveredDependencies(config, deps, true);
|
|
30034
|
+
const result = await runOptimizeDeps(config, depsInfo, true);
|
|
30035
|
+
await result.commit();
|
|
30036
|
+
return result.metadata;
|
|
30037
|
+
}
|
|
29881
30038
|
function initDepsOptimizerMetadata(config, timestamp) {
|
|
29882
30039
|
const hash = getDepHash(config);
|
|
29883
30040
|
return {
|
|
@@ -29898,19 +30055,19 @@ function addOptimizedDepInfo(metadata, type, depInfo) {
|
|
|
29898
30055
|
* Creates the initial dep optimization metadata, loading it from the deps cache
|
|
29899
30056
|
* if it exists and pre-bundling isn't forced
|
|
29900
30057
|
*/
|
|
29901
|
-
function loadCachedDepOptimizationMetadata(config, force = config.force, asCommand = false) {
|
|
30058
|
+
function loadCachedDepOptimizationMetadata(config, force = config.optimizeDeps.force, asCommand = false, ssr = !!config.build.ssr) {
|
|
29902
30059
|
const log = asCommand ? config.logger.info : debug$a;
|
|
29903
30060
|
// Before Vite 2.9, dependencies were cached in the root of the cacheDir
|
|
29904
30061
|
// For compat, we remove the cache if we find the old structure
|
|
29905
|
-
if (
|
|
30062
|
+
if (fs$n.existsSync(path$q.join(config.cacheDir, '_metadata.json'))) {
|
|
29906
30063
|
emptyDir(config.cacheDir);
|
|
29907
30064
|
}
|
|
29908
|
-
const depsCacheDir = getDepsCacheDir(config);
|
|
30065
|
+
const depsCacheDir = getDepsCacheDir(config, ssr);
|
|
29909
30066
|
if (!force) {
|
|
29910
30067
|
let cachedMetadata;
|
|
29911
30068
|
try {
|
|
29912
|
-
const cachedMetadataPath = path$
|
|
29913
|
-
cachedMetadata = parseDepsOptimizerMetadata(
|
|
30069
|
+
const cachedMetadataPath = path$q.join(depsCacheDir, '_metadata.json');
|
|
30070
|
+
cachedMetadata = parseDepsOptimizerMetadata(fs$n.readFileSync(cachedMetadataPath, 'utf-8'), depsCacheDir);
|
|
29914
30071
|
}
|
|
29915
30072
|
catch (e) { }
|
|
29916
30073
|
// hash is consistent, no need to re-bundle
|
|
@@ -29925,7 +30082,7 @@ function loadCachedDepOptimizationMetadata(config, force = config.force, asComma
|
|
|
29925
30082
|
config.logger.info('Forced re-optimization of dependencies');
|
|
29926
30083
|
}
|
|
29927
30084
|
// Start with a fresh cache
|
|
29928
|
-
|
|
30085
|
+
fs$n.rmSync(depsCacheDir, { recursive: true, force: true });
|
|
29929
30086
|
}
|
|
29930
30087
|
/**
|
|
29931
30088
|
* Initial optimizeDeps at server start. Perform a fast scan using esbuild to
|
|
@@ -29949,13 +30106,16 @@ async function discoverProjectDependencies(config, timestamp) {
|
|
|
29949
30106
|
async function initialProjectDependencies(config, timestamp, knownDeps) {
|
|
29950
30107
|
const deps = knownDeps ?? {};
|
|
29951
30108
|
await addManuallyIncludedOptimizeDeps(deps, config);
|
|
30109
|
+
return toDiscoveredDependencies(config, deps, !!config.build.ssr, timestamp);
|
|
30110
|
+
}
|
|
30111
|
+
function toDiscoveredDependencies(config, deps, ssr, timestamp) {
|
|
29952
30112
|
const browserHash = getOptimizedBrowserHash(getDepHash(config), deps, timestamp);
|
|
29953
30113
|
const discovered = {};
|
|
29954
30114
|
for (const id in deps) {
|
|
29955
30115
|
const src = deps[id];
|
|
29956
30116
|
discovered[id] = {
|
|
29957
30117
|
id,
|
|
29958
|
-
file: getOptimizedDepPath(id, config),
|
|
30118
|
+
file: getOptimizedDepPath(id, config, ssr),
|
|
29959
30119
|
src,
|
|
29960
30120
|
browserHash: browserHash,
|
|
29961
30121
|
exportsData: extractExportsData(src, config)
|
|
@@ -29980,25 +30140,26 @@ function depsLogString(qualifiedIds) {
|
|
|
29980
30140
|
* Internally, Vite uses this function to prepare a optimizeDeps run. When Vite starts, we can get
|
|
29981
30141
|
* the metadata and start the server without waiting for the optimizeDeps processing to be completed
|
|
29982
30142
|
*/
|
|
29983
|
-
async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
30143
|
+
async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.build.ssr) {
|
|
30144
|
+
const isBuild = resolvedConfig.command === 'build';
|
|
29984
30145
|
const config = {
|
|
29985
30146
|
...resolvedConfig,
|
|
29986
30147
|
command: 'build'
|
|
29987
30148
|
};
|
|
29988
|
-
const depsCacheDir = getDepsCacheDir(resolvedConfig);
|
|
29989
|
-
const processingCacheDir = getProcessingDepsCacheDir(resolvedConfig);
|
|
30149
|
+
const depsCacheDir = getDepsCacheDir(resolvedConfig, ssr);
|
|
30150
|
+
const processingCacheDir = getProcessingDepsCacheDir(resolvedConfig, ssr);
|
|
29990
30151
|
// Create a temporal directory so we don't need to delete optimized deps
|
|
29991
30152
|
// until they have been processed. This also avoids leaving the deps cache
|
|
29992
30153
|
// directory in a corrupted state if there is an error
|
|
29993
|
-
if (
|
|
30154
|
+
if (fs$n.existsSync(processingCacheDir)) {
|
|
29994
30155
|
emptyDir(processingCacheDir);
|
|
29995
30156
|
}
|
|
29996
30157
|
else {
|
|
29997
|
-
|
|
30158
|
+
fs$n.mkdirSync(processingCacheDir, { recursive: true });
|
|
29998
30159
|
}
|
|
29999
30160
|
// a hint for Node.js
|
|
30000
30161
|
// all files in the cache directory should be recognized as ES modules
|
|
30001
|
-
writeFile(path$
|
|
30162
|
+
writeFile(path$q.resolve(processingCacheDir, 'package.json'), JSON.stringify({ type: 'module' }));
|
|
30002
30163
|
const metadata = initDepsOptimizerMetadata(config);
|
|
30003
30164
|
metadata.browserHash = getOptimizedBrowserHash(metadata.hash, depsFromOptimizedDepInfo(depsInfo));
|
|
30004
30165
|
// We prebundle dependencies with esbuild and cache them, but there is no need
|
|
@@ -30015,7 +30176,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
30015
30176
|
await renameDir(processingCacheDir, depsCacheDir);
|
|
30016
30177
|
},
|
|
30017
30178
|
cancel() {
|
|
30018
|
-
|
|
30179
|
+
fs$n.rmSync(processingCacheDir, { recursive: true, force: true });
|
|
30019
30180
|
}
|
|
30020
30181
|
};
|
|
30021
30182
|
if (!qualifiedIds.length) {
|
|
@@ -30048,18 +30209,14 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
30048
30209
|
idToExports[id] = exportsData;
|
|
30049
30210
|
flatIdToExports[flatId] = exportsData;
|
|
30050
30211
|
}
|
|
30051
|
-
const define = {
|
|
30052
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || config.mode)
|
|
30053
|
-
};
|
|
30054
|
-
for (const key in config.define) {
|
|
30055
|
-
const value = config.define[key];
|
|
30056
|
-
define[key] = typeof value === 'string' ? value : JSON.stringify(value);
|
|
30057
|
-
}
|
|
30058
30212
|
const start = performance.now();
|
|
30059
30213
|
const result = await build$3({
|
|
30060
30214
|
absWorkingDir: process.cwd(),
|
|
30061
30215
|
entryPoints: Object.keys(flatIdDeps),
|
|
30062
30216
|
bundle: true,
|
|
30217
|
+
// Ensure resolution is handled by esbuildDepPlugin and
|
|
30218
|
+
// avoid replacing `process.env.NODE_ENV` for 'browser'
|
|
30219
|
+
platform: 'neutral',
|
|
30063
30220
|
format: 'esm',
|
|
30064
30221
|
target: config.build.target || undefined,
|
|
30065
30222
|
external: config.optimizeDeps?.exclude,
|
|
@@ -30067,9 +30224,8 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
30067
30224
|
splitting: true,
|
|
30068
30225
|
sourcemap: true,
|
|
30069
30226
|
outdir: processingCacheDir,
|
|
30070
|
-
ignoreAnnotations:
|
|
30227
|
+
ignoreAnnotations: !isBuild,
|
|
30071
30228
|
metafile: true,
|
|
30072
|
-
define,
|
|
30073
30229
|
plugins: [
|
|
30074
30230
|
...plugins,
|
|
30075
30231
|
esbuildDepPlugin(flatIdDeps, flatIdToExports, config)
|
|
@@ -30078,7 +30234,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
30078
30234
|
});
|
|
30079
30235
|
const meta = result.metafile;
|
|
30080
30236
|
// the paths in `meta.outputs` are relative to `process.cwd()`
|
|
30081
|
-
const processingCacheDirOutputPath = path$
|
|
30237
|
+
const processingCacheDirOutputPath = path$q.relative(process.cwd(), processingCacheDir);
|
|
30082
30238
|
for (const id in depsInfo) {
|
|
30083
30239
|
const output = esbuildOutputFromId(meta.outputs, id, processingCacheDir);
|
|
30084
30240
|
const { exportsData, ...info } = depsInfo[id];
|
|
@@ -30095,10 +30251,10 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
30095
30251
|
}
|
|
30096
30252
|
for (const o of Object.keys(meta.outputs)) {
|
|
30097
30253
|
if (!o.match(jsMapExtensionRE)) {
|
|
30098
|
-
const id = path$
|
|
30254
|
+
const id = path$q
|
|
30099
30255
|
.relative(processingCacheDirOutputPath, o)
|
|
30100
30256
|
.replace(jsExtensionRE, '');
|
|
30101
|
-
const file = getOptimizedDepPath(id, resolvedConfig);
|
|
30257
|
+
const file = getOptimizedDepPath(id, resolvedConfig, ssr);
|
|
30102
30258
|
if (!findOptimizedDepInfoInRecord(metadata.optimized, (depInfo) => depInfo.file === file)) {
|
|
30103
30259
|
addOptimizedDepInfo(metadata, 'chunks', {
|
|
30104
30260
|
id,
|
|
@@ -30109,7 +30265,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo) {
|
|
|
30109
30265
|
}
|
|
30110
30266
|
}
|
|
30111
30267
|
}
|
|
30112
|
-
const dataPath = path$
|
|
30268
|
+
const dataPath = path$q.join(processingCacheDir, '_metadata.json');
|
|
30113
30269
|
writeFile(dataPath, stringifyDepsOptimizerMetadata(metadata, depsCacheDir));
|
|
30114
30270
|
debug$a(`deps bundled in ${(performance.now() - start).toFixed(2)}ms`);
|
|
30115
30271
|
return processingResult;
|
|
@@ -30119,15 +30275,15 @@ async function findKnownImports(config) {
|
|
|
30119
30275
|
await addManuallyIncludedOptimizeDeps(deps, config);
|
|
30120
30276
|
return Object.keys(deps);
|
|
30121
30277
|
}
|
|
30122
|
-
async function addManuallyIncludedOptimizeDeps(deps, config) {
|
|
30123
|
-
const include = config.optimizeDeps?.include;
|
|
30278
|
+
async function addManuallyIncludedOptimizeDeps(deps, config, extra, filter) {
|
|
30279
|
+
const include = [...(config.optimizeDeps?.include ?? []), ...(extra ?? [])];
|
|
30124
30280
|
if (include) {
|
|
30125
30281
|
const resolve = config.createResolver({ asSrc: false, scan: true });
|
|
30126
30282
|
for (const id of include) {
|
|
30127
30283
|
// normalize 'foo >bar` as 'foo > bar' to prevent same id being added
|
|
30128
30284
|
// and for pretty printing
|
|
30129
30285
|
const normalizedId = normalizeId(id);
|
|
30130
|
-
if (!deps[normalizedId]) {
|
|
30286
|
+
if (!deps[normalizedId] && filter?.(normalizedId) !== false) {
|
|
30131
30287
|
const entry = await resolve(id);
|
|
30132
30288
|
if (entry) {
|
|
30133
30289
|
deps[normalizedId] = entry;
|
|
@@ -30150,35 +30306,39 @@ function newDepOptimizationProcessing() {
|
|
|
30150
30306
|
function depsFromOptimizedDepInfo(depsInfo) {
|
|
30151
30307
|
return Object.fromEntries(Object.entries(depsInfo).map((d) => [d[0], d[1].src]));
|
|
30152
30308
|
}
|
|
30153
|
-
function getOptimizedDepPath(id, config) {
|
|
30154
|
-
return normalizePath$3(path$
|
|
30309
|
+
function getOptimizedDepPath(id, config, ssr = !!config.build.ssr) {
|
|
30310
|
+
return normalizePath$3(path$q.resolve(getDepsCacheDir(config, ssr), flattenId(id) + '.js'));
|
|
30155
30311
|
}
|
|
30156
|
-
function getDepsCacheSuffix(config) {
|
|
30312
|
+
function getDepsCacheSuffix(config, ssr) {
|
|
30157
30313
|
let suffix = '';
|
|
30158
30314
|
if (config.command === 'build') {
|
|
30159
|
-
|
|
30160
|
-
|
|
30161
|
-
|
|
30162
|
-
}
|
|
30315
|
+
// Differentiate build caches depending on outDir to allow parallel builds
|
|
30316
|
+
const { outDir } = config.build;
|
|
30317
|
+
const buildId = outDir.length > 8 || outDir.includes('/') ? getHash(outDir) : outDir;
|
|
30318
|
+
suffix += `_build-${buildId}`;
|
|
30319
|
+
}
|
|
30320
|
+
if (ssr) {
|
|
30321
|
+
suffix += '_ssr';
|
|
30163
30322
|
}
|
|
30164
30323
|
return suffix;
|
|
30165
30324
|
}
|
|
30166
|
-
function getDepsCacheDir(config) {
|
|
30167
|
-
|
|
30168
|
-
|
|
30325
|
+
function getDepsCacheDir(config, ssr) {
|
|
30326
|
+
return getDepsCacheDirPrefix(config) + getDepsCacheSuffix(config, ssr);
|
|
30327
|
+
}
|
|
30328
|
+
function getProcessingDepsCacheDir(config, ssr) {
|
|
30329
|
+
return (getDepsCacheDirPrefix(config) + getDepsCacheSuffix(config, ssr) + '_temp');
|
|
30169
30330
|
}
|
|
30170
|
-
function
|
|
30171
|
-
|
|
30172
|
-
return normalizePath$3(path$p.resolve(config.cacheDir, dirName));
|
|
30331
|
+
function getDepsCacheDirPrefix(config) {
|
|
30332
|
+
return normalizePath$3(path$q.resolve(config.cacheDir, 'deps'));
|
|
30173
30333
|
}
|
|
30174
30334
|
function isOptimizedDepFile(id, config) {
|
|
30175
|
-
return id.startsWith(
|
|
30335
|
+
return id.startsWith(getDepsCacheDirPrefix(config));
|
|
30176
30336
|
}
|
|
30177
30337
|
function createIsOptimizedDepUrl(config) {
|
|
30178
30338
|
const { root } = config;
|
|
30179
|
-
const depsCacheDir =
|
|
30339
|
+
const depsCacheDir = getDepsCacheDirPrefix(config);
|
|
30180
30340
|
// determine the url prefix of files inside cache directory
|
|
30181
|
-
const depsCacheDirRelative = normalizePath$3(path$
|
|
30341
|
+
const depsCacheDirRelative = normalizePath$3(path$q.relative(root, depsCacheDir));
|
|
30182
30342
|
const depsCacheDirPrefix = depsCacheDirRelative.startsWith('../')
|
|
30183
30343
|
? // if the cache directory is outside root, the url prefix would be something
|
|
30184
30344
|
// like '/@fs/absolute/path/to/node_modules/.vite'
|
|
@@ -30195,7 +30355,7 @@ function parseDepsOptimizerMetadata(jsonMetadata, depsCacheDir) {
|
|
|
30195
30355
|
// Paths can be absolute or relative to the deps cache dir where
|
|
30196
30356
|
// the _metadata.json is located
|
|
30197
30357
|
if (key === 'file' || key === 'src') {
|
|
30198
|
-
return normalizePath$3(path$
|
|
30358
|
+
return normalizePath$3(path$q.resolve(depsCacheDir, value));
|
|
30199
30359
|
}
|
|
30200
30360
|
return value;
|
|
30201
30361
|
});
|
|
@@ -30254,14 +30414,14 @@ function stringifyDepsOptimizerMetadata(metadata, depsCacheDir) {
|
|
|
30254
30414
|
// Paths can be absolute or relative to the deps cache dir where
|
|
30255
30415
|
// the _metadata.json is located
|
|
30256
30416
|
if (key === 'file' || key === 'src') {
|
|
30257
|
-
return normalizePath$3(path$
|
|
30417
|
+
return normalizePath$3(path$q.relative(depsCacheDir, value));
|
|
30258
30418
|
}
|
|
30259
30419
|
return value;
|
|
30260
30420
|
}, 2);
|
|
30261
30421
|
}
|
|
30262
30422
|
function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
|
|
30263
30423
|
const flatId = flattenId(id) + '.js';
|
|
30264
|
-
return outputs[normalizePath$3(path$
|
|
30424
|
+
return outputs[normalizePath$3(path$q.relative(process.cwd(), path$q.join(cacheDirOutputPath, flatId)))];
|
|
30265
30425
|
}
|
|
30266
30426
|
async function extractExportsData(filePath, config) {
|
|
30267
30427
|
await init;
|
|
@@ -30285,12 +30445,12 @@ async function extractExportsData(filePath, config) {
|
|
|
30285
30445
|
}
|
|
30286
30446
|
let parseResult;
|
|
30287
30447
|
let usedJsxLoader = false;
|
|
30288
|
-
const entryContent =
|
|
30448
|
+
const entryContent = fs$n.readFileSync(filePath, 'utf-8');
|
|
30289
30449
|
try {
|
|
30290
30450
|
parseResult = parse$g(entryContent);
|
|
30291
30451
|
}
|
|
30292
30452
|
catch {
|
|
30293
|
-
const loader = esbuildOptions.loader?.[path$
|
|
30453
|
+
const loader = esbuildOptions.loader?.[path$q.extname(filePath)] || 'jsx';
|
|
30294
30454
|
debug$a(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
|
|
30295
30455
|
const transformed = await transformWithEsbuild(entryContent, filePath, {
|
|
30296
30456
|
loader
|
|
@@ -30355,7 +30515,6 @@ function getDepHash(config) {
|
|
|
30355
30515
|
content += JSON.stringify({
|
|
30356
30516
|
mode: process.env.NODE_ENV || config.mode,
|
|
30357
30517
|
root: config.root,
|
|
30358
|
-
define: config.define,
|
|
30359
30518
|
resolve: config.resolve,
|
|
30360
30519
|
buildTarget: config.build.target,
|
|
30361
30520
|
assetsInclude: config.assetsInclude,
|
|
@@ -30406,11 +30565,13 @@ var index$1 = {
|
|
|
30406
30565
|
__proto__: null,
|
|
30407
30566
|
debuggerViteDeps: debuggerViteDeps,
|
|
30408
30567
|
optimizeDeps: optimizeDeps,
|
|
30568
|
+
optimizeServerSsrDeps: optimizeServerSsrDeps,
|
|
30409
30569
|
initDepsOptimizerMetadata: initDepsOptimizerMetadata,
|
|
30410
30570
|
addOptimizedDepInfo: addOptimizedDepInfo,
|
|
30411
30571
|
loadCachedDepOptimizationMetadata: loadCachedDepOptimizationMetadata,
|
|
30412
30572
|
discoverProjectDependencies: discoverProjectDependencies,
|
|
30413
30573
|
initialProjectDependencies: initialProjectDependencies,
|
|
30574
|
+
toDiscoveredDependencies: toDiscoveredDependencies,
|
|
30414
30575
|
depsLogString: depsLogString,
|
|
30415
30576
|
runOptimizeDeps: runOptimizeDeps,
|
|
30416
30577
|
findKnownImports: findKnownImports,
|
|
@@ -30418,6 +30579,7 @@ var index$1 = {
|
|
|
30418
30579
|
depsFromOptimizedDepInfo: depsFromOptimizedDepInfo,
|
|
30419
30580
|
getOptimizedDepPath: getOptimizedDepPath,
|
|
30420
30581
|
getDepsCacheDir: getDepsCacheDir,
|
|
30582
|
+
getDepsCacheDirPrefix: getDepsCacheDirPrefix,
|
|
30421
30583
|
isOptimizedDepFile: isOptimizedDepFile,
|
|
30422
30584
|
createIsOptimizedDepUrl: createIsOptimizedDepUrl,
|
|
30423
30585
|
extractExportsData: extractExportsData,
|
|
@@ -30435,7 +30597,7 @@ var dist = {};
|
|
|
30435
30597
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30436
30598
|
exports.lilconfigSync = exports.lilconfig = exports.defaultLoaders = void 0;
|
|
30437
30599
|
const path = path$p;
|
|
30438
|
-
const fs =
|
|
30600
|
+
const fs = require$$0__default;
|
|
30439
30601
|
const os = require$$1;
|
|
30440
30602
|
const fsReadFileAsync = fs.promises.readFile;
|
|
30441
30603
|
function getDefaultSearchPlaces(name) {
|
|
@@ -37911,7 +38073,7 @@ var browser$1 = {
|
|
|
37911
38073
|
var require$$3 = /*@__PURE__*/getAugmentedNamespace(browser$1);
|
|
37912
38074
|
|
|
37913
38075
|
// eslint-disable-next-line n/no-deprecated-api
|
|
37914
|
-
const { createRequire, createRequireFromPath } = require$$0$
|
|
38076
|
+
const { createRequire, createRequireFromPath } = require$$0$8;
|
|
37915
38077
|
|
|
37916
38078
|
function req$2 (name, rootFile) {
|
|
37917
38079
|
const create = createRequire || createRequireFromPath;
|
|
@@ -38052,7 +38214,7 @@ const plugins = (config, file) => {
|
|
|
38052
38214
|
var plugins_1 = plugins;
|
|
38053
38215
|
|
|
38054
38216
|
const resolve = path$p.resolve;
|
|
38055
|
-
const url$4 = require$$0$
|
|
38217
|
+
const url$4 = require$$0$9;
|
|
38056
38218
|
|
|
38057
38219
|
const config$1 = dist;
|
|
38058
38220
|
const yaml = require$$3;
|
|
@@ -38365,7 +38527,7 @@ const assetAttrsConfig = {
|
|
|
38365
38527
|
const isAsyncScriptMap = new WeakMap();
|
|
38366
38528
|
async function traverseHtml(html, filePath, visitor) {
|
|
38367
38529
|
// lazy load compiler
|
|
38368
|
-
const { parse, transform } = await import('./dep-
|
|
38530
|
+
const { parse, transform } = await import('./dep-92497830.js').then(function (n) { return n.c; });
|
|
38369
38531
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
38370
38532
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
38371
38533
|
try {
|
|
@@ -38437,7 +38599,7 @@ function buildHtmlPlugin(config) {
|
|
|
38437
38599
|
name: 'vite:build-html',
|
|
38438
38600
|
async transform(html, id) {
|
|
38439
38601
|
if (id.endsWith('.html')) {
|
|
38440
|
-
const relativeUrlPath = slash$1(path$
|
|
38602
|
+
const relativeUrlPath = slash$1(path$q.relative(config.root, id));
|
|
38441
38603
|
const publicPath = `/${relativeUrlPath}`;
|
|
38442
38604
|
const publicBase = getPublicBase(relativeUrlPath, config);
|
|
38443
38605
|
// pre-transform
|
|
@@ -38664,31 +38826,31 @@ function buildHtmlPlugin(config) {
|
|
|
38664
38826
|
});
|
|
38665
38827
|
return chunks;
|
|
38666
38828
|
};
|
|
38667
|
-
const toScriptTag = (chunk,
|
|
38829
|
+
const toScriptTag = (chunk, assetsBase, isAsync) => ({
|
|
38668
38830
|
tag: 'script',
|
|
38669
38831
|
attrs: {
|
|
38670
38832
|
...(isAsync ? { async: true } : {}),
|
|
38671
38833
|
type: 'module',
|
|
38672
38834
|
crossorigin: true,
|
|
38673
|
-
src: toPublicPath(chunk.fileName,
|
|
38835
|
+
src: toPublicPath(chunk.fileName, assetsBase)
|
|
38674
38836
|
}
|
|
38675
38837
|
});
|
|
38676
|
-
const toPreloadTag = (chunk,
|
|
38838
|
+
const toPreloadTag = (chunk, assetsBase) => ({
|
|
38677
38839
|
tag: 'link',
|
|
38678
38840
|
attrs: {
|
|
38679
38841
|
rel: 'modulepreload',
|
|
38680
38842
|
crossorigin: true,
|
|
38681
|
-
href: toPublicPath(chunk.fileName,
|
|
38843
|
+
href: toPublicPath(chunk.fileName, assetsBase)
|
|
38682
38844
|
}
|
|
38683
38845
|
});
|
|
38684
|
-
const getCssTagsForChunk = (chunk,
|
|
38846
|
+
const getCssTagsForChunk = (chunk, assetsBase, seen = new Set()) => {
|
|
38685
38847
|
const tags = [];
|
|
38686
38848
|
if (!analyzedChunk.has(chunk)) {
|
|
38687
38849
|
analyzedChunk.set(chunk, 1);
|
|
38688
38850
|
chunk.imports.forEach((file) => {
|
|
38689
38851
|
const importee = bundle[file];
|
|
38690
38852
|
if (importee?.type === 'chunk') {
|
|
38691
|
-
tags.push(...getCssTagsForChunk(importee,
|
|
38853
|
+
tags.push(...getCssTagsForChunk(importee, assetsBase, seen));
|
|
38692
38854
|
}
|
|
38693
38855
|
});
|
|
38694
38856
|
}
|
|
@@ -38699,7 +38861,7 @@ function buildHtmlPlugin(config) {
|
|
|
38699
38861
|
tag: 'link',
|
|
38700
38862
|
attrs: {
|
|
38701
38863
|
rel: 'stylesheet',
|
|
38702
|
-
href: toPublicPath(file,
|
|
38864
|
+
href: toPublicPath(file, assetsBase)
|
|
38703
38865
|
}
|
|
38704
38866
|
});
|
|
38705
38867
|
}
|
|
@@ -38707,8 +38869,8 @@ function buildHtmlPlugin(config) {
|
|
|
38707
38869
|
return tags;
|
|
38708
38870
|
};
|
|
38709
38871
|
for (const [id, html] of processedHtml) {
|
|
38710
|
-
const relativeUrlPath = path$
|
|
38711
|
-
const
|
|
38872
|
+
const relativeUrlPath = path$q.posix.relative(config.root, id);
|
|
38873
|
+
const assetsBase = getAssetsBase(relativeUrlPath, config);
|
|
38712
38874
|
const isAsync = isAsyncScriptMap.get(config).get(id);
|
|
38713
38875
|
let result = html;
|
|
38714
38876
|
// find corresponding entry chunk
|
|
@@ -38728,12 +38890,12 @@ function buildHtmlPlugin(config) {
|
|
|
38728
38890
|
// when inlined, discard entry chunk and inject <script> for everything in post-order
|
|
38729
38891
|
const imports = getImportedChunks(chunk);
|
|
38730
38892
|
const assetTags = canInlineEntry
|
|
38731
|
-
? imports.map((chunk) => toScriptTag(chunk,
|
|
38893
|
+
? imports.map((chunk) => toScriptTag(chunk, assetsBase, isAsync))
|
|
38732
38894
|
: [
|
|
38733
|
-
toScriptTag(chunk,
|
|
38734
|
-
...imports.map((i) => toPreloadTag(i,
|
|
38895
|
+
toScriptTag(chunk, assetsBase, isAsync),
|
|
38896
|
+
...imports.map((i) => toPreloadTag(i, assetsBase))
|
|
38735
38897
|
];
|
|
38736
|
-
assetTags.push(...getCssTagsForChunk(chunk,
|
|
38898
|
+
assetTags.push(...getCssTagsForChunk(chunk, assetsBase));
|
|
38737
38899
|
result = injectToHead(result, assetTags);
|
|
38738
38900
|
}
|
|
38739
38901
|
// inject css link when cssCodeSplit is false
|
|
@@ -38745,7 +38907,7 @@ function buildHtmlPlugin(config) {
|
|
|
38745
38907
|
tag: 'link',
|
|
38746
38908
|
attrs: {
|
|
38747
38909
|
rel: 'stylesheet',
|
|
38748
|
-
href: toPublicPath(cssChunk.fileName,
|
|
38910
|
+
href: toPublicPath(cssChunk.fileName, assetsBase)
|
|
38749
38911
|
}
|
|
38750
38912
|
}
|
|
38751
38913
|
]);
|
|
@@ -38771,13 +38933,13 @@ function buildHtmlPlugin(config) {
|
|
|
38771
38933
|
});
|
|
38772
38934
|
// resolve asset url references
|
|
38773
38935
|
result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
|
38774
|
-
return
|
|
38936
|
+
return assetsBase + getAssetFilename(fileHash, config) + postfix;
|
|
38775
38937
|
});
|
|
38776
38938
|
if (chunk && canInlineEntry) {
|
|
38777
38939
|
// all imports from entry have been inlined to html, prevent rollup from outputting it
|
|
38778
38940
|
delete bundle[chunk.fileName];
|
|
38779
38941
|
}
|
|
38780
|
-
const shortEmitName = path$
|
|
38942
|
+
const shortEmitName = path$q.relative(config.root, id);
|
|
38781
38943
|
this.emitFile({
|
|
38782
38944
|
type: 'asset',
|
|
38783
38945
|
fileName: shortEmitName,
|
|
@@ -38807,10 +38969,6 @@ function resolveHtmlTransforms(plugins) {
|
|
|
38807
38969
|
return [preHooks, postHooks];
|
|
38808
38970
|
}
|
|
38809
38971
|
async function applyHtmlTransforms(html, hooks, ctx) {
|
|
38810
|
-
const headTags = [];
|
|
38811
|
-
const headPrependTags = [];
|
|
38812
|
-
const bodyTags = [];
|
|
38813
|
-
const bodyPrependTags = [];
|
|
38814
38972
|
for (const hook of hooks) {
|
|
38815
38973
|
const res = await hook(html, ctx);
|
|
38816
38974
|
if (!res) {
|
|
@@ -38828,6 +38986,10 @@ async function applyHtmlTransforms(html, hooks, ctx) {
|
|
|
38828
38986
|
html = res.html || html;
|
|
38829
38987
|
tags = res.tags;
|
|
38830
38988
|
}
|
|
38989
|
+
const headTags = [];
|
|
38990
|
+
const headPrependTags = [];
|
|
38991
|
+
const bodyTags = [];
|
|
38992
|
+
const bodyPrependTags = [];
|
|
38831
38993
|
for (const tag of tags) {
|
|
38832
38994
|
if (tag.injectTo === 'body') {
|
|
38833
38995
|
bodyTags.push(tag);
|
|
@@ -38842,21 +39004,12 @@ async function applyHtmlTransforms(html, hooks, ctx) {
|
|
|
38842
39004
|
headPrependTags.push(tag);
|
|
38843
39005
|
}
|
|
38844
39006
|
}
|
|
39007
|
+
html = injectToHead(html, headPrependTags, true);
|
|
39008
|
+
html = injectToHead(html, headTags);
|
|
39009
|
+
html = injectToBody(html, bodyPrependTags, true);
|
|
39010
|
+
html = injectToBody(html, bodyTags);
|
|
38845
39011
|
}
|
|
38846
39012
|
}
|
|
38847
|
-
// inject tags
|
|
38848
|
-
if (headPrependTags.length) {
|
|
38849
|
-
html = injectToHead(html, headPrependTags, true);
|
|
38850
|
-
}
|
|
38851
|
-
if (headTags.length) {
|
|
38852
|
-
html = injectToHead(html, headTags);
|
|
38853
|
-
}
|
|
38854
|
-
if (bodyPrependTags.length) {
|
|
38855
|
-
html = injectToBody(html, bodyPrependTags, true);
|
|
38856
|
-
}
|
|
38857
|
-
if (bodyTags.length) {
|
|
38858
|
-
html = injectToBody(html, bodyTags);
|
|
38859
|
-
}
|
|
38860
39013
|
return html;
|
|
38861
39014
|
}
|
|
38862
39015
|
const importRE = /\bimport\s*("[^"]*[^\\]"|'[^']*[^\\]');*/g;
|
|
@@ -38866,10 +39019,19 @@ function isEntirelyImport(code) {
|
|
|
38866
39019
|
// the regexes will remove too little in some exotic cases, but false-negatives are alright
|
|
38867
39020
|
return !code.replace(importRE, '').replace(commentRE, '').trim().length;
|
|
38868
39021
|
}
|
|
39022
|
+
function getBaseInHTML(urlRelativePath, baseOptions, config) {
|
|
39023
|
+
// Prefer explicit URL if defined for linking to assets and public files from HTML,
|
|
39024
|
+
// even when base relative is specified
|
|
39025
|
+
return (baseOptions.url ??
|
|
39026
|
+
(baseOptions.relative
|
|
39027
|
+
? path$q.posix.join(path$q.posix.relative(urlRelativePath, '').slice(0, -2), './')
|
|
39028
|
+
: config.base));
|
|
39029
|
+
}
|
|
38869
39030
|
function getPublicBase(urlRelativePath, config) {
|
|
38870
|
-
return
|
|
38871
|
-
|
|
38872
|
-
|
|
39031
|
+
return getBaseInHTML(urlRelativePath, config.experimental.buildAdvancedBaseOptions.public, config);
|
|
39032
|
+
}
|
|
39033
|
+
function getAssetsBase(urlRelativePath, config) {
|
|
39034
|
+
return getBaseInHTML(urlRelativePath, config.experimental.buildAdvancedBaseOptions.assets, config);
|
|
38873
39035
|
}
|
|
38874
39036
|
function toPublicPath(filename, publicBase) {
|
|
38875
39037
|
return isExternalUrl(filename) ? filename : publicBase + filename;
|
|
@@ -38885,6 +39047,8 @@ const bodyInjectRE = /([ \t]*)<\/body>/i;
|
|
|
38885
39047
|
const bodyPrependInjectRE = /([ \t]*)<body[^>]*>/i;
|
|
38886
39048
|
const doctypePrependInjectRE = /<!doctype html>/i;
|
|
38887
39049
|
function injectToHead(html, tags, prepend = false) {
|
|
39050
|
+
if (tags.length === 0)
|
|
39051
|
+
return html;
|
|
38888
39052
|
if (prepend) {
|
|
38889
39053
|
// inject as the first element of head
|
|
38890
39054
|
if (headPrependInjectRE.test(html)) {
|
|
@@ -38906,6 +39070,8 @@ function injectToHead(html, tags, prepend = false) {
|
|
|
38906
39070
|
return prependInjectFallback(html, tags);
|
|
38907
39071
|
}
|
|
38908
39072
|
function injectToBody(html, tags, prepend = false) {
|
|
39073
|
+
if (tags.length === 0)
|
|
39074
|
+
return html;
|
|
38909
39075
|
if (prepend) {
|
|
38910
39076
|
// inject after body open
|
|
38911
39077
|
if (bodyPrependInjectRE.test(html)) {
|
|
@@ -38989,6 +39155,9 @@ const isDirectRequest = (request) => directRequestRE.test(request);
|
|
|
38989
39155
|
const cssModulesCache = new WeakMap();
|
|
38990
39156
|
const removedPureCssFilesCache = new WeakMap();
|
|
38991
39157
|
const postcssConfigCache = new WeakMap();
|
|
39158
|
+
function encodePublicUrlsInCSS(config) {
|
|
39159
|
+
return config.command === 'build';
|
|
39160
|
+
}
|
|
38992
39161
|
/**
|
|
38993
39162
|
* Plugin applied before user plugins
|
|
38994
39163
|
*/
|
|
@@ -39021,7 +39190,7 @@ function cssPlugin(config) {
|
|
|
39021
39190
|
const ssr = options?.ssr === true;
|
|
39022
39191
|
const urlReplacer = async (url, importer) => {
|
|
39023
39192
|
if (checkPublicFile(url, config)) {
|
|
39024
|
-
if (
|
|
39193
|
+
if (encodePublicUrlsInCSS(config)) {
|
|
39025
39194
|
return publicFileToBuiltUrl(url, config);
|
|
39026
39195
|
}
|
|
39027
39196
|
else {
|
|
@@ -39049,6 +39218,7 @@ function cssPlugin(config) {
|
|
|
39049
39218
|
// server only logic for handling CSS @import dependency hmr
|
|
39050
39219
|
const { moduleGraph } = server;
|
|
39051
39220
|
const thisModule = moduleGraph.getModuleById(id);
|
|
39221
|
+
const devBase = config.base;
|
|
39052
39222
|
if (thisModule) {
|
|
39053
39223
|
// CSS modules cannot self-accept since it exports values
|
|
39054
39224
|
const isSelfAccepting = !modules && !inlineRE.test(id) && !htmlProxyRE.test(id);
|
|
@@ -39059,12 +39229,12 @@ function cssPlugin(config) {
|
|
|
39059
39229
|
for (const file of deps) {
|
|
39060
39230
|
depModules.add(isCSSRequest(file)
|
|
39061
39231
|
? moduleGraph.createFileOnlyEntry(file)
|
|
39062
|
-
: await moduleGraph.ensureEntryFromUrl((await fileToUrl(file, config, this)).replace((config.server?.origin ?? '') +
|
|
39232
|
+
: await moduleGraph.ensureEntryFromUrl((await fileToUrl(file, config, this)).replace((config.server?.origin ?? '') + devBase, '/'), ssr));
|
|
39063
39233
|
}
|
|
39064
|
-
moduleGraph.updateModuleInfo(thisModule, depModules,
|
|
39234
|
+
moduleGraph.updateModuleInfo(thisModule, depModules, null,
|
|
39065
39235
|
// The root CSS proxy module is self-accepting and should not
|
|
39066
39236
|
// have an explicit accept list
|
|
39067
|
-
new Set(), isSelfAccepting, ssr);
|
|
39237
|
+
new Set(), null, isSelfAccepting, ssr);
|
|
39068
39238
|
for (const file of deps) {
|
|
39069
39239
|
this.addWatchFile(file);
|
|
39070
39240
|
}
|
|
@@ -39092,7 +39262,6 @@ function cssPostPlugin(config) {
|
|
|
39092
39262
|
// since output formats have no effect on the generated CSS.
|
|
39093
39263
|
let outputToExtractedCSSMap;
|
|
39094
39264
|
let hasEmitted = false;
|
|
39095
|
-
const relativeBase = isRelativeBase(config.base);
|
|
39096
39265
|
const rollupOptionsOutput = config.build.rollupOptions.output;
|
|
39097
39266
|
const assetFileNames = (Array.isArray(rollupOptionsOutput)
|
|
39098
39267
|
? rollupOptionsOutput[0]
|
|
@@ -39102,10 +39271,10 @@ function cssPostPlugin(config) {
|
|
|
39102
39271
|
return config.build.assetsDir;
|
|
39103
39272
|
}
|
|
39104
39273
|
else if (typeof assetFileNames === 'string') {
|
|
39105
|
-
return path$
|
|
39274
|
+
return path$q.dirname(assetFileNames);
|
|
39106
39275
|
}
|
|
39107
39276
|
else {
|
|
39108
|
-
return path$
|
|
39277
|
+
return path$q.dirname(assetFileNames({
|
|
39109
39278
|
name: cssAssetName,
|
|
39110
39279
|
type: 'asset',
|
|
39111
39280
|
source: '/* vite internal call, ignore */'
|
|
@@ -39154,8 +39323,9 @@ function cssPostPlugin(config) {
|
|
|
39154
39323
|
return `export default ${JSON.stringify(css)}`;
|
|
39155
39324
|
}
|
|
39156
39325
|
const cssContent = await getContentWithSourcemap(css);
|
|
39326
|
+
const devBase = config.base;
|
|
39157
39327
|
return [
|
|
39158
|
-
`import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path$
|
|
39328
|
+
`import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path$q.posix.join(devBase, CLIENT_PUBLIC_PATH))}`,
|
|
39159
39329
|
`const __vite__id = ${JSON.stringify(id)}`,
|
|
39160
39330
|
`const __vite__css = ${JSON.stringify(cssContent)}`,
|
|
39161
39331
|
`__vite__updateStyle(__vite__id, __vite__css)`,
|
|
@@ -39221,46 +39391,61 @@ function cssPostPlugin(config) {
|
|
|
39221
39391
|
const publicAssetUrlMap = publicAssetUrlCache.get(config);
|
|
39222
39392
|
// resolve asset URL placeholders to their built file URLs
|
|
39223
39393
|
function resolveAssetUrlsInCss(chunkCSS, cssAssetName) {
|
|
39224
|
-
const
|
|
39394
|
+
const encodedPublicUrls = encodePublicUrlsInCSS(config);
|
|
39395
|
+
const { assets: assetsBase, public: publicBase } = config.experimental.buildAdvancedBaseOptions;
|
|
39396
|
+
const cssAssetDirname = encodedPublicUrls || assetsBase.relative
|
|
39225
39397
|
? getCssAssetDirname(cssAssetName)
|
|
39226
39398
|
: undefined;
|
|
39227
39399
|
// replace asset url references with resolved url.
|
|
39228
39400
|
chunkCSS = chunkCSS.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
|
39229
39401
|
const filename = getAssetFilename(fileHash, config) + postfix;
|
|
39230
39402
|
chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
|
|
39231
|
-
if (
|
|
39403
|
+
if (assetsBase.relative && !config.build.ssr) {
|
|
39232
39404
|
// relative base + extracted CSS
|
|
39233
|
-
const relativePath = path$
|
|
39405
|
+
const relativePath = path$q.posix.relative(cssAssetDirname, filename);
|
|
39234
39406
|
return relativePath.startsWith('.')
|
|
39235
39407
|
? relativePath
|
|
39236
39408
|
: './' + relativePath;
|
|
39237
39409
|
}
|
|
39238
39410
|
else {
|
|
39239
|
-
//
|
|
39240
|
-
return config.base + filename;
|
|
39411
|
+
// assetsBase.runtime has no effect for assets in CSS
|
|
39412
|
+
return (assetsBase.url ?? config.base) + filename;
|
|
39241
39413
|
}
|
|
39242
39414
|
});
|
|
39243
39415
|
// resolve public URL from CSS paths
|
|
39244
|
-
if (
|
|
39245
|
-
const relativePathToPublicFromCSS = path$
|
|
39246
|
-
chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) =>
|
|
39416
|
+
if (encodedPublicUrls) {
|
|
39417
|
+
const relativePathToPublicFromCSS = path$q.posix.relative(cssAssetDirname, '');
|
|
39418
|
+
chunkCSS = chunkCSS.replace(publicAssetUrlRE, (_, hash) => {
|
|
39419
|
+
const publicUrl = publicAssetUrlMap.get(hash);
|
|
39420
|
+
if (publicBase.relative && !config.build.ssr) {
|
|
39421
|
+
return relativePathToPublicFromCSS + publicUrl;
|
|
39422
|
+
}
|
|
39423
|
+
else {
|
|
39424
|
+
// publicBase.runtime has no effect for assets in CSS
|
|
39425
|
+
return (publicBase.url ?? config.base) + publicUrl.slice(1);
|
|
39426
|
+
}
|
|
39427
|
+
});
|
|
39247
39428
|
}
|
|
39248
39429
|
return chunkCSS;
|
|
39249
39430
|
}
|
|
39431
|
+
function ensureFileExt(name, ext) {
|
|
39432
|
+
return path$q.format({ ...path$q.parse(name), base: undefined, ext });
|
|
39433
|
+
}
|
|
39250
39434
|
if (config.build.cssCodeSplit) {
|
|
39251
39435
|
if (isPureCssChunk) {
|
|
39252
39436
|
// this is a shared CSS-only chunk that is empty.
|
|
39253
39437
|
pureCssChunks.add(chunk.fileName);
|
|
39254
39438
|
}
|
|
39255
|
-
if (opts.format === 'es' ||
|
|
39256
|
-
|
|
39257
|
-
|
|
39258
|
-
|
|
39439
|
+
if (opts.format === 'es' || opts.format === 'cjs') {
|
|
39440
|
+
const cssAssetName = ensureFileExt(chunk.facadeModuleId
|
|
39441
|
+
? normalizePath$3(path$q.relative(config.root, chunk.facadeModuleId))
|
|
39442
|
+
: chunk.name, '.css');
|
|
39259
39443
|
chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
|
|
39260
39444
|
chunkCSS = await finalizeCss(chunkCSS, true, config);
|
|
39261
39445
|
// emit corresponding css file
|
|
39262
39446
|
const fileHandle = this.emitFile({
|
|
39263
39447
|
name: cssAssetName,
|
|
39448
|
+
fileName: assetFileNamesToFileName(resolveAssetFileNames(config), cssAssetName, getHash(chunkCSS), chunkCSS),
|
|
39264
39449
|
type: 'asset',
|
|
39265
39450
|
source: chunkCSS
|
|
39266
39451
|
});
|
|
@@ -39304,10 +39489,10 @@ function cssPostPlugin(config) {
|
|
|
39304
39489
|
// remove empty css chunks and their imports
|
|
39305
39490
|
if (pureCssChunks.size) {
|
|
39306
39491
|
const emptyChunkFiles = [...pureCssChunks]
|
|
39307
|
-
.map((file) => path$
|
|
39492
|
+
.map((file) => path$q.basename(file))
|
|
39308
39493
|
.join('|')
|
|
39309
39494
|
.replace(/\./g, '\\.');
|
|
39310
|
-
const emptyChunkRE = new RegExp(opts.format === 'es'
|
|
39495
|
+
const emptyChunkRE = new RegExp(opts.format === 'es'
|
|
39311
39496
|
? `\\bimport\\s*["'][^"']*(?:${emptyChunkFiles})["'];\n?`
|
|
39312
39497
|
: `\\brequire\\(\\s*["'][^"']*(?:${emptyChunkFiles})["']\\);\n?`, 'g');
|
|
39313
39498
|
for (const file in bundle) {
|
|
@@ -39451,15 +39636,15 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39451
39636
|
const postcssOptions = (postcssConfig && postcssConfig.options) || {};
|
|
39452
39637
|
const postcssPlugins = postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [];
|
|
39453
39638
|
if (needInlineImport) {
|
|
39454
|
-
postcssPlugins.unshift((await import('./dep-
|
|
39639
|
+
postcssPlugins.unshift((await import('./dep-58d622b1.js').then(function (n) { return n.i; })).default({
|
|
39455
39640
|
async resolve(id, basedir) {
|
|
39456
39641
|
const publicFile = checkPublicFile(id, config);
|
|
39457
39642
|
if (publicFile) {
|
|
39458
39643
|
return publicFile;
|
|
39459
39644
|
}
|
|
39460
|
-
const resolved = await atImportResolvers.css(id, path$
|
|
39645
|
+
const resolved = await atImportResolvers.css(id, path$q.join(basedir, '*'));
|
|
39461
39646
|
if (resolved) {
|
|
39462
|
-
return path$
|
|
39647
|
+
return path$q.resolve(resolved);
|
|
39463
39648
|
}
|
|
39464
39649
|
return id;
|
|
39465
39650
|
}
|
|
@@ -39470,7 +39655,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39470
39655
|
logger: config.logger
|
|
39471
39656
|
}));
|
|
39472
39657
|
if (isModule) {
|
|
39473
|
-
postcssPlugins.unshift((await import('./dep-
|
|
39658
|
+
postcssPlugins.unshift((await import('./dep-e88a0dff.js').then(function (n) { return n.i; })).default({
|
|
39474
39659
|
...modulesOptions,
|
|
39475
39660
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
39476
39661
|
modules = _modules;
|
|
@@ -39482,7 +39667,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39482
39667
|
for (const key of getCssResolversKeys(atImportResolvers)) {
|
|
39483
39668
|
const resolved = await atImportResolvers[key](id);
|
|
39484
39669
|
if (resolved) {
|
|
39485
|
-
return path$
|
|
39670
|
+
return path$q.resolve(resolved);
|
|
39486
39671
|
}
|
|
39487
39672
|
}
|
|
39488
39673
|
return id;
|
|
@@ -39524,7 +39709,9 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39524
39709
|
else if (message.type === 'dir-dependency') {
|
|
39525
39710
|
// https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
|
|
39526
39711
|
const { dir, glob: globPattern = '**' } = message;
|
|
39527
|
-
const pattern = normalizePath$3(path$
|
|
39712
|
+
const pattern = out.escapePath(normalizePath$3(path$q.resolve(path$q.dirname(id), dir))) +
|
|
39713
|
+
`/` +
|
|
39714
|
+
globPattern;
|
|
39528
39715
|
const files = out.sync(pattern, {
|
|
39529
39716
|
ignore: ['**/node_modules/**']
|
|
39530
39717
|
});
|
|
@@ -39566,14 +39753,14 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39566
39753
|
};
|
|
39567
39754
|
}
|
|
39568
39755
|
async function formatPostcssSourceMap(rawMap, file) {
|
|
39569
|
-
const inputFileDir = path$
|
|
39756
|
+
const inputFileDir = path$q.dirname(file);
|
|
39570
39757
|
const sources = rawMap.sources.map((source) => {
|
|
39571
39758
|
const cleanSource = cleanUrl(decodeURIComponent(source));
|
|
39572
39759
|
// postcss returns virtual files
|
|
39573
39760
|
if (/^<.+>$/.test(cleanSource)) {
|
|
39574
39761
|
return `\0${cleanSource}`;
|
|
39575
39762
|
}
|
|
39576
|
-
return normalizePath$3(path$
|
|
39763
|
+
return normalizePath$3(path$q.resolve(inputFileDir, cleanSource));
|
|
39577
39764
|
});
|
|
39578
39765
|
return {
|
|
39579
39766
|
file,
|
|
@@ -39859,7 +40046,7 @@ const scss = async (source, root, options, resolvers) => {
|
|
|
39859
40046
|
? {
|
|
39860
40047
|
sourceMap: true,
|
|
39861
40048
|
omitSourceMapUrl: true,
|
|
39862
|
-
sourceMapRoot: path$
|
|
40049
|
+
sourceMapRoot: path$q.dirname(options.filename)
|
|
39863
40050
|
}
|
|
39864
40051
|
: {})
|
|
39865
40052
|
};
|
|
@@ -39902,14 +40089,14 @@ const sass = (source, root, options, aliasResolver) => scss(source, root, {
|
|
|
39902
40089
|
* root file as base.
|
|
39903
40090
|
*/
|
|
39904
40091
|
async function rebaseUrls(file, rootFile, alias) {
|
|
39905
|
-
file = path$
|
|
40092
|
+
file = path$q.resolve(file); // ensure os-specific flashes
|
|
39906
40093
|
// in the same dir, no need to rebase
|
|
39907
|
-
const fileDir = path$
|
|
39908
|
-
const rootDir = path$
|
|
40094
|
+
const fileDir = path$q.dirname(file);
|
|
40095
|
+
const rootDir = path$q.dirname(rootFile);
|
|
39909
40096
|
if (fileDir === rootDir) {
|
|
39910
40097
|
return { file };
|
|
39911
40098
|
}
|
|
39912
|
-
const content =
|
|
40099
|
+
const content = fs$n.readFileSync(file, 'utf-8');
|
|
39913
40100
|
// no url()
|
|
39914
40101
|
const hasUrls = cssUrlRE.test(content);
|
|
39915
40102
|
// data-uri() calls
|
|
@@ -39930,8 +40117,8 @@ async function rebaseUrls(file, rootFile, alias) {
|
|
|
39930
40117
|
return url;
|
|
39931
40118
|
}
|
|
39932
40119
|
}
|
|
39933
|
-
const absolute = path$
|
|
39934
|
-
const relative = path$
|
|
40120
|
+
const absolute = path$q.resolve(fileDir, url);
|
|
40121
|
+
const relative = path$q.relative(rootDir, absolute);
|
|
39935
40122
|
return normalizePath$3(relative);
|
|
39936
40123
|
};
|
|
39937
40124
|
// fix css imports in less such as `@import "foo.css"`
|
|
@@ -40012,7 +40199,7 @@ function createViteLessPlugin(less, rootFile, alias, resolvers) {
|
|
|
40012
40199
|
return false;
|
|
40013
40200
|
}
|
|
40014
40201
|
async loadFile(filename, dir, opts, env) {
|
|
40015
|
-
const resolved = await this.resolvers.less(filename, path$
|
|
40202
|
+
const resolved = await this.resolvers.less(filename, path$q.join(dir, '*'));
|
|
40016
40203
|
if (resolved) {
|
|
40017
40204
|
const result = await rebaseUrls(resolved, this.rootFile, this.alias);
|
|
40018
40205
|
let contents;
|
|
@@ -40020,10 +40207,10 @@ function createViteLessPlugin(less, rootFile, alias, resolvers) {
|
|
|
40020
40207
|
contents = result.contents;
|
|
40021
40208
|
}
|
|
40022
40209
|
else {
|
|
40023
|
-
contents =
|
|
40210
|
+
contents = fs$n.readFileSync(resolved, 'utf-8');
|
|
40024
40211
|
}
|
|
40025
40212
|
return {
|
|
40026
|
-
filename: path$
|
|
40213
|
+
filename: path$q.resolve(resolved),
|
|
40027
40214
|
contents
|
|
40028
40215
|
};
|
|
40029
40216
|
}
|
|
@@ -40048,7 +40235,7 @@ const styl = async (source, root, options) => {
|
|
|
40048
40235
|
const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap, '\n');
|
|
40049
40236
|
// Get preprocessor options.imports dependencies as stylus
|
|
40050
40237
|
// does not return them with its builtin `.deps()` method
|
|
40051
|
-
const importsDeps = (options.imports ?? []).map((dep) => path$
|
|
40238
|
+
const importsDeps = (options.imports ?? []).map((dep) => path$q.resolve(dep));
|
|
40052
40239
|
try {
|
|
40053
40240
|
const ref = nodeStylus(content, options);
|
|
40054
40241
|
if (options.enableSourcemap) {
|
|
@@ -40079,7 +40266,7 @@ function formatStylusSourceMap(mapBefore, root) {
|
|
|
40079
40266
|
if (!mapBefore)
|
|
40080
40267
|
return undefined;
|
|
40081
40268
|
const map = { ...mapBefore };
|
|
40082
|
-
const resolveFromRoot = (p) => normalizePath$3(path$
|
|
40269
|
+
const resolveFromRoot = (p) => normalizePath$3(path$q.resolve(root, p));
|
|
40083
40270
|
if (map.file) {
|
|
40084
40271
|
map.file = resolveFromRoot(map.file);
|
|
40085
40272
|
}
|
|
@@ -40121,15 +40308,203 @@ function isPreProcessor(lang) {
|
|
|
40121
40308
|
return lang && lang in preProcessors;
|
|
40122
40309
|
}
|
|
40123
40310
|
|
|
40311
|
+
/*---------------------------------------------------------------------------------------------
|
|
40312
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
40313
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
40314
|
+
*--------------------------------------------------------------------------------------------*/
|
|
40315
|
+
var ParseOptions;
|
|
40316
|
+
(function (ParseOptions) {
|
|
40317
|
+
ParseOptions.DEFAULT = {
|
|
40318
|
+
allowTrailingComma: false
|
|
40319
|
+
};
|
|
40320
|
+
})(ParseOptions || (ParseOptions = {}));
|
|
40321
|
+
|
|
40322
|
+
function matchAll(regex, string, addition) {
|
|
40323
|
+
const matches = [];
|
|
40324
|
+
for (const match of string.matchAll(regex)) {
|
|
40325
|
+
matches.push({
|
|
40326
|
+
...addition,
|
|
40327
|
+
...match.groups,
|
|
40328
|
+
code: match[0],
|
|
40329
|
+
start: match.index,
|
|
40330
|
+
end: match.index + match[0].length
|
|
40331
|
+
});
|
|
40332
|
+
}
|
|
40333
|
+
return matches;
|
|
40334
|
+
}
|
|
40335
|
+
|
|
40336
|
+
const ESM_STATIC_IMPORT_RE = /(?<=\s|^|;)import\s*(["'\s]*(?<imports>[\w*${}\n\r\t, /]+)from\s*)?["']\s*(?<specifier>(?<="\s*)[^"]*[^"\s](?=\s*")|(?<='\s*)[^']*[^'\s](?=\s*'))\s*["'][\s;]*/gm;
|
|
40337
|
+
function findStaticImports(code) {
|
|
40338
|
+
return matchAll(ESM_STATIC_IMPORT_RE, code, { type: "static" });
|
|
40339
|
+
}
|
|
40340
|
+
function parseStaticImport(matched) {
|
|
40341
|
+
const cleanedImports = (matched.imports || "").replace(/(\/\/[^\n]*\n|\/\*.*\*\/)/g, "").replace(/\s+/g, " ");
|
|
40342
|
+
const namedImports = {};
|
|
40343
|
+
for (const namedImport of cleanedImports.match(/\{([^}]*)\}/)?.[1]?.split(",") || []) {
|
|
40344
|
+
const [, source = namedImport.trim(), importName = source] = namedImport.match(/^\s*([^\s]*) as ([^\s]*)\s*$/) || [];
|
|
40345
|
+
if (source) {
|
|
40346
|
+
namedImports[source] = importName;
|
|
40347
|
+
}
|
|
40348
|
+
}
|
|
40349
|
+
const topLevelImports = cleanedImports.replace(/\{([^}]*)\}/, "");
|
|
40350
|
+
const namespacedImport = topLevelImports.match(/\* as \s*([^\s]*)/)?.[1];
|
|
40351
|
+
const defaultImport = topLevelImports.split(",").find((i) => !i.match(/[*{}]/))?.trim() || void 0;
|
|
40352
|
+
return {
|
|
40353
|
+
...matched,
|
|
40354
|
+
defaultImport,
|
|
40355
|
+
namespacedImport,
|
|
40356
|
+
namedImports
|
|
40357
|
+
};
|
|
40358
|
+
}
|
|
40359
|
+
|
|
40360
|
+
const isWindows$3 = process.platform === "win32";
|
|
40361
|
+
const own$1 = {}.hasOwnProperty;
|
|
40362
|
+
const messages = /* @__PURE__ */ new Map();
|
|
40363
|
+
const nodeInternalPrefix = "__node_internal_";
|
|
40364
|
+
let userStackTraceLimit;
|
|
40365
|
+
createError("ERR_INVALID_MODULE_SPECIFIER", (request, reason, base = void 0) => {
|
|
40366
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
40367
|
+
}, TypeError);
|
|
40368
|
+
createError("ERR_INVALID_PACKAGE_CONFIG", (path, base, message) => {
|
|
40369
|
+
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
40370
|
+
}, Error);
|
|
40371
|
+
createError("ERR_INVALID_PACKAGE_TARGET", (pkgPath, key, target, isImport = false, base = void 0) => {
|
|
40372
|
+
const relError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
40373
|
+
if (key === ".") {
|
|
40374
|
+
assert$3(isImport === false);
|
|
40375
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
|
|
40376
|
+
}
|
|
40377
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${pkgPath}package.json${base ? ` imported from ${base}` : ""}${relError ? '; targets must start with "./"' : ""}`;
|
|
40378
|
+
}, Error);
|
|
40379
|
+
createError("ERR_MODULE_NOT_FOUND", (path, base, type = "package") => {
|
|
40380
|
+
return `Cannot find ${type} '${path}' imported from ${base}`;
|
|
40381
|
+
}, Error);
|
|
40382
|
+
createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
|
|
40383
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
40384
|
+
}, TypeError);
|
|
40385
|
+
createError("ERR_PACKAGE_PATH_NOT_EXPORTED", (pkgPath, subpath, base = void 0) => {
|
|
40386
|
+
if (subpath === ".") {
|
|
40387
|
+
return `No "exports" main defined in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
40388
|
+
}
|
|
40389
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
40390
|
+
}, Error);
|
|
40391
|
+
createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
|
|
40392
|
+
createError("ERR_UNKNOWN_FILE_EXTENSION", 'Unknown file extension "%s" for %s', TypeError);
|
|
40393
|
+
createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
40394
|
+
let inspected = inspect(value);
|
|
40395
|
+
if (inspected.length > 128) {
|
|
40396
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
40397
|
+
}
|
|
40398
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
40399
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
40400
|
+
}, TypeError);
|
|
40401
|
+
createError("ERR_UNSUPPORTED_ESM_URL_SCHEME", (url) => {
|
|
40402
|
+
let message = "Only file and data URLs are supported by the default ESM loader";
|
|
40403
|
+
if (isWindows$3 && url.protocol.length === 2) {
|
|
40404
|
+
message += ". On Windows, absolute paths must be valid file:// URLs";
|
|
40405
|
+
}
|
|
40406
|
+
message += `. Received protocol '${url.protocol}'`;
|
|
40407
|
+
return message;
|
|
40408
|
+
}, Error);
|
|
40409
|
+
function createError(sym, value, def) {
|
|
40410
|
+
messages.set(sym, value);
|
|
40411
|
+
return makeNodeErrorWithCode(def, sym);
|
|
40412
|
+
}
|
|
40413
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
40414
|
+
return NodeError;
|
|
40415
|
+
function NodeError(...args) {
|
|
40416
|
+
const limit = Error.stackTraceLimit;
|
|
40417
|
+
if (isErrorStackTraceLimitWritable()) {
|
|
40418
|
+
Error.stackTraceLimit = 0;
|
|
40419
|
+
}
|
|
40420
|
+
const error = new Base();
|
|
40421
|
+
if (isErrorStackTraceLimitWritable()) {
|
|
40422
|
+
Error.stackTraceLimit = limit;
|
|
40423
|
+
}
|
|
40424
|
+
const message = getMessage(key, args, error);
|
|
40425
|
+
Object.defineProperty(error, "message", {
|
|
40426
|
+
value: message,
|
|
40427
|
+
enumerable: false,
|
|
40428
|
+
writable: true,
|
|
40429
|
+
configurable: true
|
|
40430
|
+
});
|
|
40431
|
+
Object.defineProperty(error, "toString", {
|
|
40432
|
+
value() {
|
|
40433
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
40434
|
+
},
|
|
40435
|
+
enumerable: false,
|
|
40436
|
+
writable: true,
|
|
40437
|
+
configurable: true
|
|
40438
|
+
});
|
|
40439
|
+
addCodeToName(error, Base.name, key);
|
|
40440
|
+
error.code = key;
|
|
40441
|
+
return error;
|
|
40442
|
+
}
|
|
40443
|
+
}
|
|
40444
|
+
const addCodeToName = hideStackFrames(function(error, name, code) {
|
|
40445
|
+
error = captureLargerStackTrace(error);
|
|
40446
|
+
error.name = `${name} [${code}]`;
|
|
40447
|
+
if (name === "SystemError") {
|
|
40448
|
+
Object.defineProperty(error, "name", {
|
|
40449
|
+
value: name,
|
|
40450
|
+
enumerable: false,
|
|
40451
|
+
writable: true,
|
|
40452
|
+
configurable: true
|
|
40453
|
+
});
|
|
40454
|
+
} else {
|
|
40455
|
+
delete error.name;
|
|
40456
|
+
}
|
|
40457
|
+
});
|
|
40458
|
+
function isErrorStackTraceLimitWritable() {
|
|
40459
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
40460
|
+
if (desc === void 0) {
|
|
40461
|
+
return Object.isExtensible(Error);
|
|
40462
|
+
}
|
|
40463
|
+
return own$1.call(desc, "writable") ? desc.writable : desc.set !== void 0;
|
|
40464
|
+
}
|
|
40465
|
+
function hideStackFrames(fn) {
|
|
40466
|
+
const hidden = nodeInternalPrefix + fn.name;
|
|
40467
|
+
Object.defineProperty(fn, "name", { value: hidden });
|
|
40468
|
+
return fn;
|
|
40469
|
+
}
|
|
40470
|
+
const captureLargerStackTrace = hideStackFrames(function(error) {
|
|
40471
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
40472
|
+
if (stackTraceLimitIsWritable) {
|
|
40473
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
40474
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
40475
|
+
}
|
|
40476
|
+
Error.captureStackTrace(error);
|
|
40477
|
+
if (stackTraceLimitIsWritable) {
|
|
40478
|
+
Error.stackTraceLimit = userStackTraceLimit;
|
|
40479
|
+
}
|
|
40480
|
+
return error;
|
|
40481
|
+
});
|
|
40482
|
+
function getMessage(key, args, self) {
|
|
40483
|
+
const message = messages.get(key);
|
|
40484
|
+
if (typeof message === "function") {
|
|
40485
|
+
assert$3(message.length <= args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${message.length}).`);
|
|
40486
|
+
return Reflect.apply(message, self, args);
|
|
40487
|
+
}
|
|
40488
|
+
const expectedLength = (message.match(/%[dfijoOs]/g) || []).length;
|
|
40489
|
+
assert$3(expectedLength === args.length, `Code: ${key}; The provided arguments length (${args.length}) does not match the required ones (${expectedLength}).`);
|
|
40490
|
+
if (args.length === 0) {
|
|
40491
|
+
return message;
|
|
40492
|
+
}
|
|
40493
|
+
args.unshift(message);
|
|
40494
|
+
return Reflect.apply(format$2, null, args);
|
|
40495
|
+
}
|
|
40496
|
+
Object.freeze(["node", "import"]);
|
|
40497
|
+
pathToFileURL$1(process.cwd());
|
|
40498
|
+
|
|
40124
40499
|
const debugHmr = createDebugger('vite:hmr');
|
|
40125
40500
|
const normalizedClientDir = normalizePath$3(CLIENT_DIR);
|
|
40126
40501
|
function getShortName(file, root) {
|
|
40127
|
-
return file.startsWith(root + '/') ? path$
|
|
40502
|
+
return file.startsWith(root + '/') ? path$q.posix.relative(root, file) : file;
|
|
40128
40503
|
}
|
|
40129
40504
|
async function handleHMRUpdate(file, server) {
|
|
40130
40505
|
const { ws, config, moduleGraph } = server;
|
|
40131
40506
|
const shortFile = getShortName(file, config.root);
|
|
40132
|
-
const fileName = path$
|
|
40507
|
+
const fileName = path$q.basename(file);
|
|
40133
40508
|
const isConfig = file === config.configFile;
|
|
40134
40509
|
const isConfigDependency = config.configFileDependencies.some((name) => file === name);
|
|
40135
40510
|
const isEnv = config.inlineConfig.envFile !== false &&
|
|
@@ -40137,7 +40512,7 @@ async function handleHMRUpdate(file, server) {
|
|
|
40137
40512
|
if (isConfig || isConfigDependency || isEnv) {
|
|
40138
40513
|
// auto restart server
|
|
40139
40514
|
debugHmr(`[config change] ${colors$1.dim(shortFile)}`);
|
|
40140
|
-
config.logger.info(colors$1.green(`${path$
|
|
40515
|
+
config.logger.info(colors$1.green(`${path$q.relative(process.cwd(), file)} changed, restarting server...`), { clear: true, timestamp: true });
|
|
40141
40516
|
try {
|
|
40142
40517
|
await server.restart();
|
|
40143
40518
|
}
|
|
@@ -40184,7 +40559,7 @@ async function handleHMRUpdate(file, server) {
|
|
|
40184
40559
|
type: 'full-reload',
|
|
40185
40560
|
path: config.server.middlewareMode
|
|
40186
40561
|
? '*'
|
|
40187
|
-
: '/' + normalizePath$3(path$
|
|
40562
|
+
: '/' + normalizePath$3(path$q.relative(config.root, file))
|
|
40188
40563
|
});
|
|
40189
40564
|
}
|
|
40190
40565
|
else {
|
|
@@ -40243,6 +40618,14 @@ async function handleFileAddUnlink(file, server) {
|
|
|
40243
40618
|
updateModules(getShortName(file, server.config.root), unique(modules), Date.now(), server);
|
|
40244
40619
|
}
|
|
40245
40620
|
}
|
|
40621
|
+
function areAllImportsAccepted(importedBindings, acceptedExports) {
|
|
40622
|
+
for (const binding of importedBindings) {
|
|
40623
|
+
if (!acceptedExports.has(binding)) {
|
|
40624
|
+
return false;
|
|
40625
|
+
}
|
|
40626
|
+
}
|
|
40627
|
+
return true;
|
|
40628
|
+
}
|
|
40246
40629
|
function propagateUpdate(node, boundaries, currentChain = [node]) {
|
|
40247
40630
|
// #7561
|
|
40248
40631
|
// if the imports of `node` have not been analyzed, then `node` has not
|
|
@@ -40264,15 +40647,28 @@ function propagateUpdate(node, boundaries, currentChain = [node]) {
|
|
|
40264
40647
|
}
|
|
40265
40648
|
return false;
|
|
40266
40649
|
}
|
|
40267
|
-
|
|
40268
|
-
|
|
40650
|
+
// A partially accepted module with no importers is considered self accepting,
|
|
40651
|
+
// because the deal is "there are parts of myself I can't self accept if they
|
|
40652
|
+
// are used outside of me".
|
|
40653
|
+
// Also, the imported module (this one) must be updated before the importers,
|
|
40654
|
+
// so that they do get the fresh imported module when/if they are reloaded.
|
|
40655
|
+
if (node.acceptedHmrExports) {
|
|
40656
|
+
boundaries.add({
|
|
40657
|
+
boundary: node,
|
|
40658
|
+
acceptedVia: node
|
|
40659
|
+
});
|
|
40269
40660
|
}
|
|
40270
|
-
|
|
40271
|
-
|
|
40272
|
-
|
|
40273
|
-
|
|
40274
|
-
|
|
40275
|
-
|
|
40661
|
+
else {
|
|
40662
|
+
if (!node.importers.size) {
|
|
40663
|
+
return true;
|
|
40664
|
+
}
|
|
40665
|
+
// #3716, #3913
|
|
40666
|
+
// For a non-CSS file, if all of its importers are CSS files (registered via
|
|
40667
|
+
// PostCSS plugins) it should be considered a dead end and force full reload.
|
|
40668
|
+
if (!isCSSRequest(node.url) &&
|
|
40669
|
+
[...node.importers].every((i) => isCSSRequest(i.url))) {
|
|
40670
|
+
return true;
|
|
40671
|
+
}
|
|
40276
40672
|
}
|
|
40277
40673
|
for (const importer of node.importers) {
|
|
40278
40674
|
const subChain = currentChain.concat(importer);
|
|
@@ -40283,6 +40679,13 @@ function propagateUpdate(node, boundaries, currentChain = [node]) {
|
|
|
40283
40679
|
});
|
|
40284
40680
|
continue;
|
|
40285
40681
|
}
|
|
40682
|
+
if (node.id && node.acceptedHmrExports && importer.importedBindings) {
|
|
40683
|
+
const importedBindingsFromNode = importer.importedBindings.get(node.id);
|
|
40684
|
+
if (importedBindingsFromNode &&
|
|
40685
|
+
areAllImportsAccepted(importedBindingsFromNode, node.acceptedHmrExports)) {
|
|
40686
|
+
continue;
|
|
40687
|
+
}
|
|
40688
|
+
}
|
|
40286
40689
|
if (currentChain.includes(importer)) {
|
|
40287
40690
|
// circular deps is considered dead end
|
|
40288
40691
|
return true;
|
|
@@ -40442,6 +40845,14 @@ function lexAcceptedHmrDeps(code, start, urls) {
|
|
|
40442
40845
|
}
|
|
40443
40846
|
return false;
|
|
40444
40847
|
}
|
|
40848
|
+
function lexAcceptedHmrExports(code, start, exportNames) {
|
|
40849
|
+
const urls = new Set();
|
|
40850
|
+
lexAcceptedHmrDeps(code, start, urls);
|
|
40851
|
+
for (const { url } of urls) {
|
|
40852
|
+
exportNames.add(url);
|
|
40853
|
+
}
|
|
40854
|
+
return urls.size > 0;
|
|
40855
|
+
}
|
|
40445
40856
|
function error$1(pos) {
|
|
40446
40857
|
const err = new Error(`import.meta.hot.accept() can only accept string literals or an ` +
|
|
40447
40858
|
`Array of string literals.`);
|
|
@@ -40452,14 +40863,14 @@ function error$1(pos) {
|
|
|
40452
40863
|
// change event and sometimes this can be too early and get an empty buffer.
|
|
40453
40864
|
// Poll until the file's modified time has changed before reading again.
|
|
40454
40865
|
async function readModifiedFile(file) {
|
|
40455
|
-
const content =
|
|
40866
|
+
const content = fs$n.readFileSync(file, 'utf-8');
|
|
40456
40867
|
if (!content) {
|
|
40457
|
-
const mtime =
|
|
40868
|
+
const mtime = fs$n.statSync(file).mtimeMs;
|
|
40458
40869
|
await new Promise((r) => {
|
|
40459
40870
|
let n = 0;
|
|
40460
40871
|
const poll = async () => {
|
|
40461
40872
|
n++;
|
|
40462
|
-
const newMtime =
|
|
40873
|
+
const newMtime = fs$n.statSync(file).mtimeMs;
|
|
40463
40874
|
if (newMtime !== mtime || n > 10) {
|
|
40464
40875
|
r(0);
|
|
40465
40876
|
}
|
|
@@ -40469,7 +40880,7 @@ async function readModifiedFile(file) {
|
|
|
40469
40880
|
};
|
|
40470
40881
|
setTimeout(poll, 10);
|
|
40471
40882
|
});
|
|
40472
|
-
return
|
|
40883
|
+
return fs$n.readFileSync(file, 'utf-8');
|
|
40473
40884
|
}
|
|
40474
40885
|
else {
|
|
40475
40886
|
return content;
|
|
@@ -40573,14 +40984,14 @@ function createIsSsrExternal(config) {
|
|
|
40573
40984
|
return processedIds.get(id);
|
|
40574
40985
|
}
|
|
40575
40986
|
const external = !id.startsWith('.') &&
|
|
40576
|
-
!path$
|
|
40987
|
+
!path$q.isAbsolute(id) &&
|
|
40577
40988
|
(isBuiltin(id) || (isConfiguredAsExternal(id) && isValidPackageEntry(id)));
|
|
40578
40989
|
processedIds.set(id, external);
|
|
40579
40990
|
return external;
|
|
40580
40991
|
};
|
|
40581
40992
|
}
|
|
40582
|
-
// When
|
|
40583
|
-
// SSR externalization heuristics
|
|
40993
|
+
// When config.experimental.buildSsrCjsExternalHeuristics is enabled, this function
|
|
40994
|
+
// is used reverting to the Vite 2.9 SSR externalization heuristics
|
|
40584
40995
|
function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logger) {
|
|
40585
40996
|
const rootPkgContent = lookupFile(root, ['package.json']);
|
|
40586
40997
|
if (!rootPkgContent) {
|
|
@@ -40619,7 +41030,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40619
41030
|
ssrExternals.add(id);
|
|
40620
41031
|
}
|
|
40621
41032
|
else {
|
|
40622
|
-
depsToTrace.add(path$
|
|
41033
|
+
depsToTrace.add(path$q.dirname(pkgPath));
|
|
40623
41034
|
}
|
|
40624
41035
|
continue;
|
|
40625
41036
|
}
|
|
@@ -40635,7 +41046,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40635
41046
|
// trace the dependencies of linked packages
|
|
40636
41047
|
else if (!esmEntry.includes('node_modules')) {
|
|
40637
41048
|
const pkgPath = resolveFrom(`${id}/package.json`, root);
|
|
40638
|
-
depsToTrace.add(path$
|
|
41049
|
+
depsToTrace.add(path$q.dirname(pkgPath));
|
|
40639
41050
|
}
|
|
40640
41051
|
// has separate esm/require entry, assume require entry is cjs
|
|
40641
41052
|
else if (esmEntry !== requireEntry) {
|
|
@@ -40646,7 +41057,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40646
41057
|
// for now, we'll just leave this as is
|
|
40647
41058
|
else if (/\.m?js$/.test(esmEntry)) {
|
|
40648
41059
|
const pkgPath = resolveFrom(`${id}/package.json`, root);
|
|
40649
|
-
const pkgContent =
|
|
41060
|
+
const pkgContent = fs$n.readFileSync(pkgPath, 'utf-8');
|
|
40650
41061
|
if (!pkgContent) {
|
|
40651
41062
|
continue;
|
|
40652
41063
|
}
|
|
@@ -40656,7 +41067,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40656
41067
|
continue;
|
|
40657
41068
|
}
|
|
40658
41069
|
// check if the entry is cjs
|
|
40659
|
-
const content =
|
|
41070
|
+
const content = fs$n.readFileSync(esmEntry, 'utf-8');
|
|
40660
41071
|
if (CJS_CONTENT_RE.test(content)) {
|
|
40661
41072
|
ssrExternals.add(id);
|
|
40662
41073
|
continue;
|
|
@@ -40678,7 +41089,7 @@ function cjsShouldExternalizeForSSR(id, externals) {
|
|
|
40678
41089
|
}
|
|
40679
41090
|
// deep imports, check ext before externalizing - only externalize
|
|
40680
41091
|
// extension-less imports and explicit .js imports
|
|
40681
|
-
if (id.startsWith(e + '/') && (!path$
|
|
41092
|
+
if (id.startsWith(e + '/') && (!path$q.extname(id) || id.endsWith('.js'))) {
|
|
40682
41093
|
return true;
|
|
40683
41094
|
}
|
|
40684
41095
|
});
|
|
@@ -40711,10 +41122,11 @@ function optimizedDepsPlugin(config) {
|
|
|
40711
41122
|
// this.load({ id }) isn't implemented in PluginContainer
|
|
40712
41123
|
// The logic to register an id to wait until it is processed
|
|
40713
41124
|
// is in importAnalysis, see call to delayDepsOptimizerUntil
|
|
40714
|
-
async load(id) {
|
|
41125
|
+
async load(id, options) {
|
|
41126
|
+
const ssr = options?.ssr ?? false;
|
|
40715
41127
|
const depsOptimizer = getDepsOptimizer(config);
|
|
40716
41128
|
if (depsOptimizer?.isOptimizedDepFile(id)) {
|
|
40717
|
-
const metadata = depsOptimizer?.metadata;
|
|
41129
|
+
const metadata = depsOptimizer?.metadata({ ssr });
|
|
40718
41130
|
if (metadata) {
|
|
40719
41131
|
const file = cleanUrl(id);
|
|
40720
41132
|
const versionMatch = id.match(DEP_VERSION_RE);
|
|
@@ -40738,7 +41150,7 @@ function optimizedDepsPlugin(config) {
|
|
|
40738
41150
|
throwProcessingError(id);
|
|
40739
41151
|
return;
|
|
40740
41152
|
}
|
|
40741
|
-
const newMetadata = depsOptimizer.metadata;
|
|
41153
|
+
const newMetadata = depsOptimizer.metadata({ ssr });
|
|
40742
41154
|
if (metadata !== newMetadata) {
|
|
40743
41155
|
const currentInfo = optimizedDepInfoFromFile(newMetadata, file);
|
|
40744
41156
|
if (info.browserHash !== currentInfo?.browserHash) {
|
|
@@ -40751,7 +41163,7 @@ function optimizedDepsPlugin(config) {
|
|
|
40751
41163
|
// load hooks to avoid race conditions, once processing is resolved,
|
|
40752
41164
|
// we are sure that the file has been properly save to disk
|
|
40753
41165
|
try {
|
|
40754
|
-
return await promises.readFile(file, 'utf-8');
|
|
41166
|
+
return await promises$2.readFile(file, 'utf-8');
|
|
40755
41167
|
}
|
|
40756
41168
|
catch (e) {
|
|
40757
41169
|
// Outdated non-entry points (CHUNK), loaded after a rerun
|
|
@@ -40780,9 +41192,10 @@ function optimizedDepsBuildPlugin(config) {
|
|
|
40780
41192
|
await this.load({ id });
|
|
40781
41193
|
});
|
|
40782
41194
|
},
|
|
40783
|
-
async load(id) {
|
|
41195
|
+
async load(id, options) {
|
|
41196
|
+
const ssr = options?.ssr ?? false;
|
|
40784
41197
|
const depsOptimizer = getDepsOptimizer(config);
|
|
40785
|
-
const metadata = depsOptimizer?.metadata;
|
|
41198
|
+
const metadata = depsOptimizer?.metadata({ ssr });
|
|
40786
41199
|
if (!metadata || !depsOptimizer?.isOptimizedDepFile(id)) {
|
|
40787
41200
|
return;
|
|
40788
41201
|
}
|
|
@@ -40811,7 +41224,7 @@ function optimizedDepsBuildPlugin(config) {
|
|
|
40811
41224
|
// load hooks to avoid race conditions, once processing is resolved,
|
|
40812
41225
|
// we are sure that the file has been properly save to disk
|
|
40813
41226
|
try {
|
|
40814
|
-
return await promises.readFile(file, 'utf-8');
|
|
41227
|
+
return await promises$2.readFile(file, 'utf-8');
|
|
40815
41228
|
}
|
|
40816
41229
|
catch (e) {
|
|
40817
41230
|
// Outdated non-entry points (CHUNK), loaded after a rerun
|
|
@@ -40853,6 +41266,40 @@ function markExplicitImport(url) {
|
|
|
40853
41266
|
}
|
|
40854
41267
|
return url;
|
|
40855
41268
|
}
|
|
41269
|
+
async function extractImportedBindings(id, source, importSpec, importedBindings) {
|
|
41270
|
+
let bindings = importedBindings.get(id);
|
|
41271
|
+
if (!bindings) {
|
|
41272
|
+
bindings = new Set();
|
|
41273
|
+
importedBindings.set(id, bindings);
|
|
41274
|
+
}
|
|
41275
|
+
const isDynamic = importSpec.d > -1;
|
|
41276
|
+
const isMeta = importSpec.d === -2;
|
|
41277
|
+
if (isDynamic || isMeta) {
|
|
41278
|
+
// this basically means the module will be impacted by any change in its dep
|
|
41279
|
+
bindings.add('*');
|
|
41280
|
+
return;
|
|
41281
|
+
}
|
|
41282
|
+
const exp = source.slice(importSpec.ss, importSpec.se);
|
|
41283
|
+
const [match0] = findStaticImports(exp);
|
|
41284
|
+
if (!match0) {
|
|
41285
|
+
return;
|
|
41286
|
+
}
|
|
41287
|
+
const parsed = parseStaticImport(match0);
|
|
41288
|
+
if (!parsed) {
|
|
41289
|
+
return;
|
|
41290
|
+
}
|
|
41291
|
+
if (parsed.namespacedImport) {
|
|
41292
|
+
bindings.add('*');
|
|
41293
|
+
}
|
|
41294
|
+
if (parsed.defaultImport) {
|
|
41295
|
+
bindings.add('default');
|
|
41296
|
+
}
|
|
41297
|
+
if (parsed.namedImports) {
|
|
41298
|
+
for (const name of Object.keys(parsed.namedImports)) {
|
|
41299
|
+
bindings.add(name);
|
|
41300
|
+
}
|
|
41301
|
+
}
|
|
41302
|
+
}
|
|
40856
41303
|
/**
|
|
40857
41304
|
* Server-only plugin that lexes, resolves, rewrites and analyzes url imports.
|
|
40858
41305
|
*
|
|
@@ -40884,7 +41331,8 @@ function markExplicitImport(url) {
|
|
|
40884
41331
|
*/
|
|
40885
41332
|
function importAnalysisPlugin(config) {
|
|
40886
41333
|
const { root, base } = config;
|
|
40887
|
-
const clientPublicPath = path$
|
|
41334
|
+
const clientPublicPath = path$q.posix.join(base, CLIENT_PUBLIC_PATH);
|
|
41335
|
+
const enablePartialAccept = config.experimental?.hmrPartialAccept;
|
|
40888
41336
|
let server;
|
|
40889
41337
|
return {
|
|
40890
41338
|
name: 'vite:import-analysis',
|
|
@@ -40906,12 +41354,10 @@ function importAnalysisPlugin(config) {
|
|
|
40906
41354
|
const start = performance.now();
|
|
40907
41355
|
await init;
|
|
40908
41356
|
let imports = [];
|
|
40909
|
-
|
|
40910
|
-
|
|
40911
|
-
source = source.slice(1);
|
|
40912
|
-
}
|
|
41357
|
+
let exports = [];
|
|
41358
|
+
source = stripBomTag(source);
|
|
40913
41359
|
try {
|
|
40914
|
-
imports = parse$g(source)
|
|
41360
|
+
[imports, exports] = parse$g(source);
|
|
40915
41361
|
}
|
|
40916
41362
|
catch (e) {
|
|
40917
41363
|
const isVue = importer.endsWith('.vue');
|
|
@@ -40920,7 +41366,7 @@ function importAnalysisPlugin(config) {
|
|
|
40920
41366
|
? `Install @vitejs/plugin-vue to handle .vue files.`
|
|
40921
41367
|
: maybeJSX
|
|
40922
41368
|
? `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
|
|
40923
|
-
: `You may need to install appropriate plugins to handle the ${path$
|
|
41369
|
+
: `You may need to install appropriate plugins to handle the ${path$q.extname(importer)} file format, or if it's an asset, add "**/*${path$q.extname(importer)}" to \`assetsInclude\` in your configuration.`;
|
|
40924
41370
|
this.error(`Failed to parse source for import analysis because the content ` +
|
|
40925
41371
|
`contains invalid JS syntax. ` +
|
|
40926
41372
|
msg, e.idx);
|
|
@@ -40952,7 +41398,12 @@ function importAnalysisPlugin(config) {
|
|
|
40952
41398
|
const importedUrls = new Set();
|
|
40953
41399
|
const staticImportedUrls = new Set();
|
|
40954
41400
|
const acceptedUrls = new Set();
|
|
40955
|
-
|
|
41401
|
+
let isPartiallySelfAccepting = false;
|
|
41402
|
+
const acceptedExports = new Set();
|
|
41403
|
+
const importedBindings = enablePartialAccept
|
|
41404
|
+
? new Map()
|
|
41405
|
+
: null;
|
|
41406
|
+
const toAbsoluteUrl = (url) => path$q.posix.resolve(path$q.posix.dirname(importerModule.url), url);
|
|
40956
41407
|
const normalizeUrl = async (url, pos) => {
|
|
40957
41408
|
if (base !== '/' && url.startsWith(base)) {
|
|
40958
41409
|
url = url.replace(base, '/');
|
|
@@ -40965,7 +41416,8 @@ function importAnalysisPlugin(config) {
|
|
|
40965
41416
|
// the dependency needs to be resolved starting from the original source location of the optimized file
|
|
40966
41417
|
// because starting from node_modules/.vite will not find the dependency if it was not hoisted
|
|
40967
41418
|
// (that is, if it is under node_modules directory in the package source of the optimized file)
|
|
40968
|
-
for (const optimizedModule of depsOptimizer.metadata
|
|
41419
|
+
for (const optimizedModule of depsOptimizer.metadata({ ssr })
|
|
41420
|
+
.depInfoList) {
|
|
40969
41421
|
if (!optimizedModule.src)
|
|
40970
41422
|
continue; // Ignore chunks
|
|
40971
41423
|
if (optimizedModule.file === importerModule.file) {
|
|
@@ -40980,7 +41432,7 @@ function importAnalysisPlugin(config) {
|
|
|
40980
41432
|
if (ssr) {
|
|
40981
41433
|
return [url, url];
|
|
40982
41434
|
}
|
|
40983
|
-
this.error(`Failed to resolve import "${url}" from "${path$
|
|
41435
|
+
this.error(`Failed to resolve import "${url}" from "${path$q.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
|
|
40984
41436
|
}
|
|
40985
41437
|
const isRelative = url.startsWith('.');
|
|
40986
41438
|
const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer);
|
|
@@ -40990,11 +41442,11 @@ function importAnalysisPlugin(config) {
|
|
|
40990
41442
|
// in root: infer short absolute path from root
|
|
40991
41443
|
url = resolved.id.slice(root.length);
|
|
40992
41444
|
}
|
|
40993
|
-
else if (resolved.id.startsWith(
|
|
40994
|
-
|
|
41445
|
+
else if (resolved.id.startsWith(getDepsCacheDirPrefix(config)) ||
|
|
41446
|
+
fs$n.existsSync(cleanUrl(resolved.id))) {
|
|
40995
41447
|
// an optimized deps may not yet exists in the filesystem, or
|
|
40996
41448
|
// a regular file exists but is out of root: rewrite to absolute /@fs/ paths
|
|
40997
|
-
url = path$
|
|
41449
|
+
url = path$q.posix.join(FS_PREFIX + resolved.id);
|
|
40998
41450
|
}
|
|
40999
41451
|
else {
|
|
41000
41452
|
url = resolved.id;
|
|
@@ -41059,7 +41511,11 @@ function importAnalysisPlugin(config) {
|
|
|
41059
41511
|
hasHMR = true;
|
|
41060
41512
|
if (source.slice(end + 4, end + 11) === '.accept') {
|
|
41061
41513
|
// further analyze accepted modules
|
|
41062
|
-
if (
|
|
41514
|
+
if (source.slice(end + 4, end + 18) === '.acceptExports') {
|
|
41515
|
+
lexAcceptedHmrExports(source, source.indexOf('(', end + 18) + 1, acceptedExports);
|
|
41516
|
+
isPartiallySelfAccepting = true;
|
|
41517
|
+
}
|
|
41518
|
+
else if (lexAcceptedHmrDeps(source, source.indexOf('(', end + 11) + 1, acceptedUrls)) {
|
|
41063
41519
|
isSelfAccepting = true;
|
|
41064
41520
|
}
|
|
41065
41521
|
}
|
|
@@ -41079,7 +41535,7 @@ function importAnalysisPlugin(config) {
|
|
|
41079
41535
|
}
|
|
41080
41536
|
// skip ssr external
|
|
41081
41537
|
if (ssr) {
|
|
41082
|
-
if (config.
|
|
41538
|
+
if (config.legacy?.buildSsrCjsExternalHeuristics) {
|
|
41083
41539
|
if (cjsShouldExternalizeForSSR(specifier, server._ssrExternals)) {
|
|
41084
41540
|
continue;
|
|
41085
41541
|
}
|
|
@@ -41117,7 +41573,7 @@ function importAnalysisPlugin(config) {
|
|
|
41117
41573
|
// The browserHash in resolvedId could be stale in which case there will be a full
|
|
41118
41574
|
// page reload. We could return a 404 in that case but it is safe to return the request
|
|
41119
41575
|
const file = cleanUrl(resolvedId); // Remove ?v={hash}
|
|
41120
|
-
const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata, file, config);
|
|
41576
|
+
const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata({ ssr }), file, config);
|
|
41121
41577
|
if (needsInterop === undefined) {
|
|
41122
41578
|
// Non-entry dynamic imports from dependencies will reach here as there isn't
|
|
41123
41579
|
// optimize info for them, but they don't need es interop. If the request isn't
|
|
@@ -41150,6 +41606,9 @@ function importAnalysisPlugin(config) {
|
|
|
41150
41606
|
// make sure to normalize away base
|
|
41151
41607
|
const urlWithoutBase = url.replace(base, '/');
|
|
41152
41608
|
importedUrls.add(urlWithoutBase);
|
|
41609
|
+
if (enablePartialAccept && importedBindings) {
|
|
41610
|
+
extractImportedBindings(resolvedId, source, imports[index], importedBindings);
|
|
41611
|
+
}
|
|
41153
41612
|
if (!isDynamicImport) {
|
|
41154
41613
|
// for pre-transforming
|
|
41155
41614
|
staticImportedUrls.add({ url: urlWithoutBase, id: resolvedId });
|
|
@@ -41199,9 +41658,11 @@ function importAnalysisPlugin(config) {
|
|
|
41199
41658
|
if (hasHMR && !ssr) {
|
|
41200
41659
|
debugHmr(`${isSelfAccepting
|
|
41201
41660
|
? `[self-accepts]`
|
|
41202
|
-
:
|
|
41203
|
-
? `[accepts-
|
|
41204
|
-
:
|
|
41661
|
+
: isPartiallySelfAccepting
|
|
41662
|
+
? `[accepts-exports]`
|
|
41663
|
+
: acceptedUrls.size
|
|
41664
|
+
? `[accepts-deps]`
|
|
41665
|
+
: `[detected api usage]`} ${prettyImporter}`);
|
|
41205
41666
|
// inject hot context
|
|
41206
41667
|
str().prepend(`import { createHotContext as __vite__createHotContext } from "${clientPublicPath}";` +
|
|
41207
41668
|
`import.meta.hot = __vite__createHotContext(${JSON.stringify(importerModule.url)});`);
|
|
@@ -41233,7 +41694,15 @@ function importAnalysisPlugin(config) {
|
|
|
41233
41694
|
if (ssr && importerModule.isSelfAccepting) {
|
|
41234
41695
|
isSelfAccepting = true;
|
|
41235
41696
|
}
|
|
41236
|
-
|
|
41697
|
+
// a partially accepted module that accepts all its exports
|
|
41698
|
+
// behaves like a self-accepted module in practice
|
|
41699
|
+
if (!isSelfAccepting &&
|
|
41700
|
+
isPartiallySelfAccepting &&
|
|
41701
|
+
acceptedExports.size >= exports.length &&
|
|
41702
|
+
exports.every((name) => acceptedExports.has(name))) {
|
|
41703
|
+
isSelfAccepting = true;
|
|
41704
|
+
}
|
|
41705
|
+
const prunedImports = await moduleGraph.updateModuleInfo(importerModule, importedUrls, importedBindings, normalizedAcceptedUrls, isPartiallySelfAccepting ? acceptedExports : null, isSelfAccepting, ssr);
|
|
41237
41706
|
if (hasHMR && prunedImports) {
|
|
41238
41707
|
handlePrunedModules(prunedImports, server);
|
|
41239
41708
|
}
|
|
@@ -41255,7 +41724,7 @@ function importAnalysisPlugin(config) {
|
|
|
41255
41724
|
// Unexpected error, log the issue but avoid an unhandled exception
|
|
41256
41725
|
config.logger.error(e.message);
|
|
41257
41726
|
});
|
|
41258
|
-
if (depsOptimizer && !config.
|
|
41727
|
+
if (depsOptimizer && !config.legacy?.devDepsScanner) {
|
|
41259
41728
|
depsOptimizer.delayDepsOptimizerUntil(id, () => request);
|
|
41260
41729
|
}
|
|
41261
41730
|
});
|
|
@@ -41372,7 +41841,6 @@ function transformCjsImport(importExp, url, rawUrl, importIndex) {
|
|
|
41372
41841
|
}
|
|
41373
41842
|
}
|
|
41374
41843
|
|
|
41375
|
-
// import fs from 'fs'
|
|
41376
41844
|
/**
|
|
41377
41845
|
* A flag for injected helpers. This flag will be set to `false` if the output
|
|
41378
41846
|
* target is not native es - so that injected helper logic can be conditionally
|
|
@@ -41444,13 +41912,16 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41444
41912
|
const ssr = !!config.build.ssr;
|
|
41445
41913
|
const isWorker = config.isWorker;
|
|
41446
41914
|
const insertPreload = !(ssr || !!config.build.lib || isWorker);
|
|
41447
|
-
const
|
|
41915
|
+
const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
|
|
41916
|
+
const relativePreloadUrls = !(assetsBase.url || assetsBase.runtime);
|
|
41448
41917
|
const scriptRel = config.build.polyfillModulePreload
|
|
41449
41918
|
? `'modulepreload'`
|
|
41450
41919
|
: `(${detectScriptRel.toString()})()`;
|
|
41451
|
-
const assetsURL =
|
|
41920
|
+
const assetsURL = relativePreloadUrls
|
|
41452
41921
|
? `function(dep,importerUrl) { return new URL(dep, importerUrl).href }`
|
|
41453
|
-
: `function(dep) { return ${
|
|
41922
|
+
: `function(dep) { return ${assetsBase.runtime
|
|
41923
|
+
? assetsBase.runtime('dep')
|
|
41924
|
+
: `${JSON.stringify(assetsBase.url ?? config.base)}+dep`}}`;
|
|
41454
41925
|
const preloadCode = `const scriptRel = ${scriptRel};const assetsURL = ${assetsURL};const seen = {};export const ${preloadMethod} = ${preload.toString()}`;
|
|
41455
41926
|
return {
|
|
41456
41927
|
name: 'vite:build-import-analysis',
|
|
@@ -41491,7 +41962,8 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41491
41962
|
// the dependency needs to be resolved starting from the original source location of the optimized file
|
|
41492
41963
|
// because starting from node_modules/.vite will not find the dependency if it was not hoisted
|
|
41493
41964
|
// (that is, if it is under node_modules directory in the package source of the optimized file)
|
|
41494
|
-
for (const optimizedModule of depsOptimizer.metadata
|
|
41965
|
+
for (const optimizedModule of depsOptimizer.metadata({ ssr })
|
|
41966
|
+
.depInfoList) {
|
|
41495
41967
|
if (!optimizedModule.src)
|
|
41496
41968
|
continue; // Ignore chunks
|
|
41497
41969
|
if (optimizedModule.file === importer) {
|
|
@@ -41506,7 +41978,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41506
41978
|
if (ssr) {
|
|
41507
41979
|
return [url, url];
|
|
41508
41980
|
}
|
|
41509
|
-
this.error(`Failed to resolve import "${url}" from "${path$
|
|
41981
|
+
this.error(`Failed to resolve import "${url}" from "${path$q.relative(process.cwd(), importerFile)}". Does the file exist?`, pos);
|
|
41510
41982
|
}
|
|
41511
41983
|
// normalize all imports into resolved URLs
|
|
41512
41984
|
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
|
|
@@ -41531,7 +42003,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41531
42003
|
if (isDynamicImport && insertPreload) {
|
|
41532
42004
|
needPreloadHelper = true;
|
|
41533
42005
|
str().prependLeft(expStart, `${preloadMethod}(() => `);
|
|
41534
|
-
str().appendRight(expEnd, `,${isModernFlag}?"${preloadMarker}":void 0${
|
|
42006
|
+
str().appendRight(expEnd, `,${isModernFlag}?"${preloadMarker}":void 0${relativePreloadUrls ? ',import.meta.url' : ''})`);
|
|
41535
42007
|
}
|
|
41536
42008
|
if (!depsOptimizer) {
|
|
41537
42009
|
continue;
|
|
@@ -41549,7 +42021,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41549
42021
|
if (depsOptimizer.isOptimizedDepFile(resolvedId) &&
|
|
41550
42022
|
!resolvedId.match(optimizedDepChunkRE)) {
|
|
41551
42023
|
const file = cleanUrl(resolvedId); // Remove ?v={hash}
|
|
41552
|
-
const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata, file, config);
|
|
42024
|
+
const needsInterop = await optimizedDepNeedsInterop(depsOptimizer.metadata({ ssr }), file, config);
|
|
41553
42025
|
let rewriteDone = false;
|
|
41554
42026
|
if (needsInterop === undefined) {
|
|
41555
42027
|
// Non-entry dynamic imports from dependencies will reach here as there isn't
|
|
@@ -41673,7 +42145,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41673
42145
|
}
|
|
41674
42146
|
}
|
|
41675
42147
|
};
|
|
41676
|
-
const normalizedFile = path$
|
|
42148
|
+
const normalizedFile = path$q.posix.join(path$q.posix.dirname(chunk.fileName), url);
|
|
41677
42149
|
addDeps(normalizedFile);
|
|
41678
42150
|
}
|
|
41679
42151
|
let markerStartPos = code.indexOf(preloadMarkerWithQuote, end);
|
|
@@ -41690,8 +42162,8 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41690
42162
|
// main chunk is removed
|
|
41691
42163
|
(hasRemovedPureCssChunk && deps.size > 0)
|
|
41692
42164
|
? `[${[...deps]
|
|
41693
|
-
.map((d) => JSON.stringify(
|
|
41694
|
-
? path$
|
|
42165
|
+
.map((d) => JSON.stringify(relativePreloadUrls
|
|
42166
|
+
? path$q.relative(path$q.dirname(file), d)
|
|
41695
42167
|
: d))
|
|
41696
42168
|
.join(',')}]`
|
|
41697
42169
|
: `[]`, { contentOnly: true });
|
|
@@ -41729,7 +42201,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41729
42201
|
function ssrManifestPlugin(config) {
|
|
41730
42202
|
// module id => preload assets mapping
|
|
41731
42203
|
const ssrManifest = {};
|
|
41732
|
-
const base = config.base;
|
|
42204
|
+
const base = config.base; // TODO:base
|
|
41733
42205
|
return {
|
|
41734
42206
|
name: 'vite:ssr-manifest',
|
|
41735
42207
|
generateBundle(_options, bundle) {
|
|
@@ -41779,14 +42251,14 @@ function ssrManifestPlugin(config) {
|
|
|
41779
42251
|
const chunk = bundle[filename];
|
|
41780
42252
|
if (chunk) {
|
|
41781
42253
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
41782
|
-
deps.push(join$
|
|
42254
|
+
deps.push(join$2(base, file)); // TODO:base
|
|
41783
42255
|
});
|
|
41784
42256
|
chunk.imports.forEach(addDeps);
|
|
41785
42257
|
}
|
|
41786
42258
|
};
|
|
41787
|
-
const normalizedFile = normalizePath$3(join$
|
|
42259
|
+
const normalizedFile = normalizePath$3(join$2(dirname$2(chunk.fileName), url.slice(1, -1)));
|
|
41788
42260
|
addDeps(normalizedFile);
|
|
41789
|
-
ssrManifest[basename$
|
|
42261
|
+
ssrManifest[basename$2(name)] = deps;
|
|
41790
42262
|
}
|
|
41791
42263
|
}
|
|
41792
42264
|
}
|
|
@@ -41847,7 +42319,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
41847
42319
|
}
|
|
41848
42320
|
}
|
|
41849
42321
|
const url = rawUrl.slice(1, -1);
|
|
41850
|
-
const file = path$
|
|
42322
|
+
const file = path$q.resolve(path$q.dirname(id), url);
|
|
41851
42323
|
// Get final asset URL. Catch error if the file does not exist,
|
|
41852
42324
|
// in which we can resort to the initial URL and let it resolve in runtime
|
|
41853
42325
|
const builtUrl = await fileToUrl(file, config, this).catch(() => {
|
|
@@ -41893,10 +42365,10 @@ function loadFallbackPlugin() {
|
|
|
41893
42365
|
async load(id) {
|
|
41894
42366
|
try {
|
|
41895
42367
|
// if we don't add `await` here, we couldn't catch the error in readFile
|
|
41896
|
-
return await promises.readFile(cleanUrl(id), 'utf-8');
|
|
42368
|
+
return await promises$2.readFile(cleanUrl(id), 'utf-8');
|
|
41897
42369
|
}
|
|
41898
42370
|
catch (e) {
|
|
41899
|
-
return promises.readFile(id, 'utf-8');
|
|
42371
|
+
return promises$2.readFile(id, 'utf-8');
|
|
41900
42372
|
}
|
|
41901
42373
|
}
|
|
41902
42374
|
};
|
|
@@ -41917,7 +42389,7 @@ function ensureWatchPlugin() {
|
|
|
41917
42389
|
};
|
|
41918
42390
|
}
|
|
41919
42391
|
|
|
41920
|
-
function resolveBuildOptions(raw) {
|
|
42392
|
+
function resolveBuildOptions(raw, isBuild, logger) {
|
|
41921
42393
|
const resolved = {
|
|
41922
42394
|
target: 'modules',
|
|
41923
42395
|
polyfillModulePreload: true,
|
|
@@ -41985,7 +42457,7 @@ function resolveBuildPlugins(config) {
|
|
|
41985
42457
|
pre: [
|
|
41986
42458
|
...(options.watch ? [ensureWatchPlugin()] : []),
|
|
41987
42459
|
watchPackageDataPlugin(config),
|
|
41988
|
-
...(
|
|
42460
|
+
...(config.legacy?.buildRollupPluginCommonjs
|
|
41989
42461
|
? [commonjs(options.commonjsOptions)]
|
|
41990
42462
|
: []),
|
|
41991
42463
|
dataURIPlugin(),
|
|
@@ -42036,7 +42508,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42036
42508
|
const ssr = !!options.ssr;
|
|
42037
42509
|
const libOptions = options.lib;
|
|
42038
42510
|
config.logger.info(colors$1.cyan(`vite v${VERSION} ${colors$1.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
|
|
42039
|
-
const resolve = (p) => path$
|
|
42511
|
+
const resolve = (p) => path$q.resolve(config.root, p);
|
|
42040
42512
|
const input = libOptions
|
|
42041
42513
|
? resolve(libOptions.entry)
|
|
42042
42514
|
: typeof options.ssr === 'string'
|
|
@@ -42054,7 +42526,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42054
42526
|
// In CJS, we can pass the externals to rollup as is. In ESM, we need to
|
|
42055
42527
|
// do it in the resolve plugin so we can add the resolved extension for
|
|
42056
42528
|
// deep node_modules imports
|
|
42057
|
-
if (ssr && config.
|
|
42529
|
+
if (ssr && config.legacy?.buildSsrCjsExternalHeuristics) {
|
|
42058
42530
|
external = await cjsSsrResolveExternal(config, userExternal);
|
|
42059
42531
|
}
|
|
42060
42532
|
if (isDepsOptimizerEnabled(config)) {
|
|
@@ -42094,9 +42566,10 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42094
42566
|
`This is deprecated and will override all Vite.js default output options. ` +
|
|
42095
42567
|
`Please use "rollupOptions.output" instead.`);
|
|
42096
42568
|
}
|
|
42569
|
+
const ssrWorkerBuild = ssr && config.ssr?.target !== 'webworker';
|
|
42097
42570
|
const cjsSsrBuild = ssr && config.ssr?.format === 'cjs';
|
|
42098
42571
|
const format = output.format || (cjsSsrBuild ? 'cjs' : 'es');
|
|
42099
|
-
const jsExt =
|
|
42572
|
+
const jsExt = ssrWorkerBuild || libOptions
|
|
42100
42573
|
? resolveOutputJsExtension(format, getPkgJson(config.root)?.type)
|
|
42101
42574
|
: 'js';
|
|
42102
42575
|
return {
|
|
@@ -42114,16 +42587,16 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42114
42587
|
? `[name].${jsExt}`
|
|
42115
42588
|
: libOptions
|
|
42116
42589
|
? resolveLibFilename(libOptions, format, config.root, jsExt)
|
|
42117
|
-
: path$
|
|
42590
|
+
: path$q.posix.join(options.assetsDir, `[name].[hash].js`),
|
|
42118
42591
|
chunkFileNames: libOptions
|
|
42119
42592
|
? `[name].[hash].${jsExt}`
|
|
42120
|
-
: path$
|
|
42593
|
+
: path$q.posix.join(options.assetsDir, `[name].[hash].js`),
|
|
42121
42594
|
assetFileNames: libOptions
|
|
42122
42595
|
? `[name].[ext]`
|
|
42123
|
-
: path$
|
|
42596
|
+
: path$q.posix.join(options.assetsDir, `[name].[hash].[ext]`),
|
|
42124
42597
|
inlineDynamicImports: output.format === 'umd' ||
|
|
42125
42598
|
output.format === 'iife' ||
|
|
42126
|
-
(
|
|
42599
|
+
(ssrWorkerBuild && typeof input === 'string'),
|
|
42127
42600
|
...output
|
|
42128
42601
|
};
|
|
42129
42602
|
};
|
|
@@ -42204,7 +42677,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42204
42677
|
}
|
|
42205
42678
|
}
|
|
42206
42679
|
function prepareOutDir(outDir, emptyOutDir, config) {
|
|
42207
|
-
if (
|
|
42680
|
+
if (fs$n.existsSync(outDir)) {
|
|
42208
42681
|
if (emptyOutDir == null &&
|
|
42209
42682
|
!normalizePath$3(outDir).startsWith(config.root + '/')) {
|
|
42210
42683
|
// warn if outDir is outside of root
|
|
@@ -42215,7 +42688,7 @@ function prepareOutDir(outDir, emptyOutDir, config) {
|
|
|
42215
42688
|
emptyDir(outDir, ['.git']);
|
|
42216
42689
|
}
|
|
42217
42690
|
}
|
|
42218
|
-
if (config.publicDir &&
|
|
42691
|
+
if (config.publicDir && fs$n.existsSync(config.publicDir)) {
|
|
42219
42692
|
copyDir(config.publicDir, outDir);
|
|
42220
42693
|
}
|
|
42221
42694
|
}
|
|
@@ -42306,9 +42779,9 @@ function onRollupWarning(warning, warn, config) {
|
|
|
42306
42779
|
async function cjsSsrResolveExternal(config, user) {
|
|
42307
42780
|
// see if we have cached deps data available
|
|
42308
42781
|
let knownImports;
|
|
42309
|
-
const dataPath = path$
|
|
42782
|
+
const dataPath = path$q.join(getDepsCacheDir(config, false), '_metadata.json');
|
|
42310
42783
|
try {
|
|
42311
|
-
const data = JSON.parse(
|
|
42784
|
+
const data = JSON.parse(fs$n.readFileSync(dataPath, 'utf-8'));
|
|
42312
42785
|
knownImports = Object.keys(data.optimized);
|
|
42313
42786
|
}
|
|
42314
42787
|
catch (e) { }
|
|
@@ -42381,6 +42854,39 @@ function wrapSsrTransform(fn) {
|
|
|
42381
42854
|
function injectSsrFlag(options) {
|
|
42382
42855
|
return { ...(options ?? {}), ssr: true };
|
|
42383
42856
|
}
|
|
42857
|
+
/**
|
|
42858
|
+
* Resolve base. Note that some users use Vite to build for non-web targets like
|
|
42859
|
+
* electron or expects to deploy
|
|
42860
|
+
*/
|
|
42861
|
+
function resolveBuildAdvancedBaseConfig(baseConfig, resolvedBase, isBuild, logger) {
|
|
42862
|
+
baseConfig ?? (baseConfig = {});
|
|
42863
|
+
const relativeBaseShortcut = resolvedBase === '' || resolvedBase === './';
|
|
42864
|
+
const resolved = {
|
|
42865
|
+
relative: baseConfig?.relative ?? relativeBaseShortcut,
|
|
42866
|
+
url: baseConfig?.url
|
|
42867
|
+
? resolveBaseUrl(baseConfig?.url, isBuild, logger, 'experimental.buildAdvancedBaseOptions.url')
|
|
42868
|
+
: undefined,
|
|
42869
|
+
runtime: baseConfig?.runtime
|
|
42870
|
+
};
|
|
42871
|
+
return {
|
|
42872
|
+
...resolved,
|
|
42873
|
+
assets: resolveBuildBaseSpecificOptions(baseConfig?.assets, resolved, isBuild, logger, 'assets'),
|
|
42874
|
+
public: resolveBuildBaseSpecificOptions(baseConfig?.public, resolved, isBuild, logger, 'public')
|
|
42875
|
+
};
|
|
42876
|
+
}
|
|
42877
|
+
function resolveBuildBaseSpecificOptions(options, parent, isBuild, logger, optionName) {
|
|
42878
|
+
const urlConfigPath = `experimental.buildAdvancedBaseOptions.${optionName}.url`;
|
|
42879
|
+
if (typeof options === 'string') {
|
|
42880
|
+
options = { url: options };
|
|
42881
|
+
}
|
|
42882
|
+
return {
|
|
42883
|
+
relative: options?.relative ?? parent.relative,
|
|
42884
|
+
url: options?.url
|
|
42885
|
+
? resolveBaseUrl(options?.url, isBuild, logger, urlConfigPath)
|
|
42886
|
+
: parent.url,
|
|
42887
|
+
runtime: options?.runtime ?? parent.runtime
|
|
42888
|
+
};
|
|
42889
|
+
}
|
|
42384
42890
|
|
|
42385
42891
|
var build$1 = {
|
|
42386
42892
|
__proto__: null,
|
|
@@ -42388,7 +42894,8 @@ var build$1 = {
|
|
|
42388
42894
|
resolveBuildPlugins: resolveBuildPlugins,
|
|
42389
42895
|
build: build,
|
|
42390
42896
|
resolveLibFilename: resolveLibFilename,
|
|
42391
|
-
onRollupWarning: onRollupWarning
|
|
42897
|
+
onRollupWarning: onRollupWarning,
|
|
42898
|
+
resolveBuildAdvancedBaseConfig: resolveBuildAdvancedBaseConfig
|
|
42392
42899
|
};
|
|
42393
42900
|
|
|
42394
42901
|
var src = {exports: {}};
|
|
@@ -42949,8 +43456,8 @@ var node = {exports: {}};
|
|
|
42949
43456
|
*/
|
|
42950
43457
|
|
|
42951
43458
|
(function (module, exports) {
|
|
42952
|
-
var tty = require$$0$
|
|
42953
|
-
var util = require$$0$
|
|
43459
|
+
var tty = require$$0$3;
|
|
43460
|
+
var util = require$$0$5;
|
|
42954
43461
|
|
|
42955
43462
|
/**
|
|
42956
43463
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -43130,7 +43637,7 @@ function createWritableStdioStream (fd) {
|
|
|
43130
43637
|
break;
|
|
43131
43638
|
|
|
43132
43639
|
case 'FILE':
|
|
43133
|
-
var fs =
|
|
43640
|
+
var fs = require$$0__default;
|
|
43134
43641
|
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
|
43135
43642
|
stream._type = 'fs';
|
|
43136
43643
|
break;
|
|
@@ -43647,7 +44154,7 @@ var parseurl$1 = {exports: {}};
|
|
|
43647
44154
|
* @private
|
|
43648
44155
|
*/
|
|
43649
44156
|
|
|
43650
|
-
var url$3 = require$$0$
|
|
44157
|
+
var url$3 = require$$0$9;
|
|
43651
44158
|
var parse$9 = url$3.parse;
|
|
43652
44159
|
var Url = url$3.Url;
|
|
43653
44160
|
|
|
@@ -44409,7 +44916,7 @@ module.exports = function(a, b){
|
|
|
44409
44916
|
*/
|
|
44410
44917
|
|
|
44411
44918
|
var debug$4 = src.exports('connect:dispatcher');
|
|
44412
|
-
var EventEmitter$3 = require$$0$
|
|
44919
|
+
var EventEmitter$3 = require$$0$4.EventEmitter;
|
|
44413
44920
|
var finalhandler = finalhandler_1;
|
|
44414
44921
|
var http$4 = require$$1$3;
|
|
44415
44922
|
var merge = utilsMerge.exports;
|
|
@@ -45155,10 +45662,10 @@ var corsMiddleware = lib$2.exports;
|
|
|
45155
45662
|
|
|
45156
45663
|
var chokidar = {};
|
|
45157
45664
|
|
|
45158
|
-
const fs$b =
|
|
45159
|
-
const { Readable } = require$$0$
|
|
45665
|
+
const fs$b = require$$0__default;
|
|
45666
|
+
const { Readable } = require$$0$6;
|
|
45160
45667
|
const sysPath$3 = path$p;
|
|
45161
|
-
const { promisify: promisify$3 } = require$$0$
|
|
45668
|
+
const { promisify: promisify$3 } = require$$0$5;
|
|
45162
45669
|
const picomatch$1 = picomatch$3;
|
|
45163
45670
|
|
|
45164
45671
|
const readdir$1 = promisify$3(fs$b.readdir);
|
|
@@ -45921,9 +46428,9 @@ exports.isLinux = platform === 'linux';
|
|
|
45921
46428
|
exports.isIBMi = os.type() === 'OS400';
|
|
45922
46429
|
}(constants$1));
|
|
45923
46430
|
|
|
45924
|
-
const fs$a =
|
|
46431
|
+
const fs$a = require$$0__default;
|
|
45925
46432
|
const sysPath$2 = path$p;
|
|
45926
|
-
const { promisify: promisify$2 } = require$$0$
|
|
46433
|
+
const { promisify: promisify$2 } = require$$0$5;
|
|
45927
46434
|
const isBinaryPath = isBinaryPath$1;
|
|
45928
46435
|
const {
|
|
45929
46436
|
isWindows: isWindows$2,
|
|
@@ -46566,9 +47073,9 @@ var nodefsHandler = NodeFsHandler$1;
|
|
|
46566
47073
|
|
|
46567
47074
|
var fseventsHandler = {exports: {}};
|
|
46568
47075
|
|
|
46569
|
-
const fs$9 =
|
|
47076
|
+
const fs$9 = require$$0__default;
|
|
46570
47077
|
const sysPath$1 = path$p;
|
|
46571
|
-
const { promisify: promisify$1 } = require$$0$
|
|
47078
|
+
const { promisify: promisify$1 } = require$$0$5;
|
|
46572
47079
|
|
|
46573
47080
|
let fsevents;
|
|
46574
47081
|
try {
|
|
@@ -47089,10 +47596,10 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
|
|
|
47089
47596
|
fseventsHandler.exports = FsEventsHandler$1;
|
|
47090
47597
|
fseventsHandler.exports.canUse = canUse;
|
|
47091
47598
|
|
|
47092
|
-
const { EventEmitter: EventEmitter$2 } = require$$0$
|
|
47093
|
-
const fs$8 =
|
|
47599
|
+
const { EventEmitter: EventEmitter$2 } = require$$0$4;
|
|
47600
|
+
const fs$8 = require$$0__default;
|
|
47094
47601
|
const sysPath = path$p;
|
|
47095
|
-
const { promisify } = require$$0$
|
|
47602
|
+
const { promisify } = require$$0$5;
|
|
47096
47603
|
const readdirp = readdirp_1;
|
|
47097
47604
|
const anymatch = anymatch$2.exports.default;
|
|
47098
47605
|
const globParent = globParent$2;
|
|
@@ -48489,7 +48996,7 @@ var getArgs = function getArgumentsForPosition (
|
|
|
48489
48996
|
* Modified by Yuxi Evan You
|
|
48490
48997
|
*/
|
|
48491
48998
|
|
|
48492
|
-
const fs$7 =
|
|
48999
|
+
const fs$7 = require$$0__default;
|
|
48493
49000
|
const os$2 = require$$1;
|
|
48494
49001
|
const path$6 = path$p;
|
|
48495
49002
|
const colors = picocolors.exports;
|
|
@@ -48618,7 +49125,7 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
|
|
|
48618
49125
|
|
|
48619
49126
|
var launchEditor_1 = launchEditor;
|
|
48620
49127
|
|
|
48621
|
-
const url$2 = require$$0$
|
|
49128
|
+
const url$2 = require$$0$9;
|
|
48622
49129
|
const path$5 = path$p;
|
|
48623
49130
|
const launch = launchEditor_1;
|
|
48624
49131
|
|
|
@@ -48689,7 +49196,7 @@ async function resolveHttpsConfig(https, cacheDir) {
|
|
|
48689
49196
|
function readFileIfExists(value) {
|
|
48690
49197
|
if (typeof value === 'string') {
|
|
48691
49198
|
try {
|
|
48692
|
-
return
|
|
49199
|
+
return fs$n.readFileSync(path$q.resolve(value));
|
|
48693
49200
|
}
|
|
48694
49201
|
catch (e) {
|
|
48695
49202
|
return value;
|
|
@@ -48698,11 +49205,11 @@ function readFileIfExists(value) {
|
|
|
48698
49205
|
return value;
|
|
48699
49206
|
}
|
|
48700
49207
|
async function getCertificate(cacheDir) {
|
|
48701
|
-
const cachePath = path$
|
|
49208
|
+
const cachePath = path$q.join(cacheDir, '_cert.pem');
|
|
48702
49209
|
try {
|
|
48703
49210
|
const [stat, content] = await Promise.all([
|
|
48704
|
-
promises.stat(cachePath),
|
|
48705
|
-
promises.readFile(cachePath, 'utf8')
|
|
49211
|
+
promises$2.stat(cachePath),
|
|
49212
|
+
promises$2.readFile(cachePath, 'utf8')
|
|
48706
49213
|
]);
|
|
48707
49214
|
if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1000) {
|
|
48708
49215
|
throw new Error('cache is outdated.');
|
|
@@ -48710,22 +49217,16 @@ async function getCertificate(cacheDir) {
|
|
|
48710
49217
|
return content;
|
|
48711
49218
|
}
|
|
48712
49219
|
catch {
|
|
48713
|
-
const content = (await import('./dep-
|
|
48714
|
-
promises
|
|
49220
|
+
const content = (await import('./dep-f75aea7c.js')).createCertificate();
|
|
49221
|
+
promises$2
|
|
48715
49222
|
.mkdir(cacheDir, { recursive: true })
|
|
48716
|
-
.then(() => promises.writeFile(cachePath, content))
|
|
49223
|
+
.then(() => promises$2.writeFile(cachePath, content))
|
|
48717
49224
|
.catch(() => { });
|
|
48718
49225
|
return content;
|
|
48719
49226
|
}
|
|
48720
49227
|
}
|
|
48721
49228
|
async function httpServerStart(httpServer, serverOptions) {
|
|
48722
49229
|
let { port, strictPort, host, logger } = serverOptions;
|
|
48723
|
-
// This could be removed when Vite only supports Node 17+ because verbatim=true is default
|
|
48724
|
-
// https://github.com/nodejs/node/pull/39987
|
|
48725
|
-
if (host === 'localhost') {
|
|
48726
|
-
const addr = await promises$1.lookup('localhost', { verbatim: true });
|
|
48727
|
-
host = addr.address;
|
|
48728
|
-
}
|
|
48729
49230
|
return new Promise((resolve, reject) => {
|
|
48730
49231
|
const onError = (e) => {
|
|
48731
49232
|
if (e.code === 'EADDRINUSE') {
|
|
@@ -48965,7 +49466,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
48965
49466
|
// #3087 dynamic import vars is ignored at rewrite import path,
|
|
48966
49467
|
// so here need process relative path
|
|
48967
49468
|
if (dep[0] === '.') {
|
|
48968
|
-
dep = path$
|
|
49469
|
+
dep = path$q.posix.resolve(path$q.dirname(url), dep);
|
|
48969
49470
|
}
|
|
48970
49471
|
return ssrImport(dep);
|
|
48971
49472
|
};
|
|
@@ -49021,7 +49522,7 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
49021
49522
|
// Use the Vite resolver only for bare imports while skipping
|
|
49022
49523
|
// any absolute paths, built-in modules and binary modules.
|
|
49023
49524
|
if (!bareImportRE.test(id) ||
|
|
49024
|
-
path$
|
|
49525
|
+
path$q.isAbsolute(id) ||
|
|
49025
49526
|
isBuiltin(id) ||
|
|
49026
49527
|
id.endsWith('.node')) {
|
|
49027
49528
|
return nodeResolve(id, parent, isMain, options);
|
|
@@ -49031,7 +49532,7 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
49031
49532
|
if (resolved) {
|
|
49032
49533
|
// hookNodeResolve must use platform-specific path.normalize
|
|
49033
49534
|
// to be compatible with dynamicImport (#6080)
|
|
49034
|
-
resolved = path$
|
|
49535
|
+
resolved = path$q.normalize(resolved);
|
|
49035
49536
|
}
|
|
49036
49537
|
return resolved;
|
|
49037
49538
|
}
|
|
@@ -49281,7 +49782,7 @@ class Limiter$1 {
|
|
|
49281
49782
|
|
|
49282
49783
|
var limiter = Limiter$1;
|
|
49283
49784
|
|
|
49284
|
-
const zlib =
|
|
49785
|
+
const zlib = require$$0$a;
|
|
49285
49786
|
|
|
49286
49787
|
const bufferUtil = bufferUtil$1.exports;
|
|
49287
49788
|
const Limiter = limiter;
|
|
@@ -49917,7 +50418,7 @@ if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
|
49917
50418
|
}
|
|
49918
50419
|
}
|
|
49919
50420
|
|
|
49920
|
-
const { Writable: Writable$1 } = require$$0$
|
|
50421
|
+
const { Writable: Writable$1 } = require$$0$6;
|
|
49921
50422
|
|
|
49922
50423
|
const PerMessageDeflate$3 = permessageDeflate;
|
|
49923
50424
|
const {
|
|
@@ -51477,13 +51978,13 @@ var extension$1 = { format: format$1, parse: parse$6 };
|
|
|
51477
51978
|
|
|
51478
51979
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
|
|
51479
51980
|
|
|
51480
|
-
const EventEmitter$1 = require$$0$
|
|
51981
|
+
const EventEmitter$1 = require$$0$4;
|
|
51481
51982
|
const https$2 = require$$1$4;
|
|
51482
51983
|
const http$3 = require$$1$3;
|
|
51483
51984
|
const net = require$$3$1;
|
|
51484
51985
|
const tls = require$$4;
|
|
51485
51986
|
const { randomBytes, createHash: createHash$1 } = require$$1$2;
|
|
51486
|
-
const { URL: URL$2 } = require$$0$
|
|
51987
|
+
const { URL: URL$2 } = require$$0$9;
|
|
51487
51988
|
|
|
51488
51989
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
51489
51990
|
const Receiver = receiver;
|
|
@@ -52832,7 +53333,7 @@ var subprotocol$1 = { parse: parse$4 };
|
|
|
52832
53333
|
|
|
52833
53334
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */
|
|
52834
53335
|
|
|
52835
|
-
const EventEmitter = require$$0$
|
|
53336
|
+
const EventEmitter = require$$0$4;
|
|
52836
53337
|
const http$2 = require$$1$3;
|
|
52837
53338
|
const { createHash } = require$$1$2;
|
|
52838
53339
|
|
|
@@ -53559,16 +54060,16 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
53559
54060
|
|
|
53560
54061
|
// this middleware is only active when (config.base !== '/')
|
|
53561
54062
|
function baseMiddleware({ config }) {
|
|
53562
|
-
const
|
|
54063
|
+
const devBase = config.base;
|
|
53563
54064
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
53564
54065
|
return function viteBaseMiddleware(req, res, next) {
|
|
53565
54066
|
const url = req.url;
|
|
53566
54067
|
const parsed = new URL(url, 'http://vitejs.dev');
|
|
53567
54068
|
const path = parsed.pathname || '/';
|
|
53568
|
-
if (path.startsWith(
|
|
54069
|
+
if (path.startsWith(devBase)) {
|
|
53569
54070
|
// rewrite url to remove base.. this ensures that other middleware does
|
|
53570
54071
|
// not need to consider base being prepended or not
|
|
53571
|
-
req.url = url.replace(
|
|
54072
|
+
req.url = url.replace(devBase, '/');
|
|
53572
54073
|
return next();
|
|
53573
54074
|
}
|
|
53574
54075
|
// skip redirect and error fallback on middleware mode, #4057
|
|
@@ -53578,18 +54079,18 @@ function baseMiddleware({ config }) {
|
|
|
53578
54079
|
if (path === '/' || path === '/index.html') {
|
|
53579
54080
|
// redirect root visit to based url with search and hash
|
|
53580
54081
|
res.writeHead(302, {
|
|
53581
|
-
Location:
|
|
54082
|
+
Location: devBase + (parsed.search || '') + (parsed.hash || '')
|
|
53582
54083
|
});
|
|
53583
54084
|
res.end();
|
|
53584
54085
|
return;
|
|
53585
54086
|
}
|
|
53586
54087
|
else if (req.headers.accept?.includes('text/html')) {
|
|
53587
54088
|
// non-based page visit
|
|
53588
|
-
const redirectPath =
|
|
54089
|
+
const redirectPath = devBase + url.slice(1);
|
|
53589
54090
|
res.writeHead(404, {
|
|
53590
54091
|
'Content-Type': 'text/html'
|
|
53591
54092
|
});
|
|
53592
|
-
res.end(`The server is configured with a public base URL of ${
|
|
54093
|
+
res.end(`The server is configured with a public base URL of ${devBase} - ` +
|
|
53593
54094
|
`did you mean to visit <a href="${redirectPath}">${redirectPath}</a> instead?`);
|
|
53594
54095
|
return;
|
|
53595
54096
|
}
|
|
@@ -53980,8 +54481,8 @@ var requiresPort = function required(port, protocol) {
|
|
|
53980
54481
|
|
|
53981
54482
|
(function (exports) {
|
|
53982
54483
|
var common = exports,
|
|
53983
|
-
url = require$$0$
|
|
53984
|
-
extend = require$$0$
|
|
54484
|
+
url = require$$0$9,
|
|
54485
|
+
extend = require$$0$5._extend,
|
|
53985
54486
|
required = requiresPort;
|
|
53986
54487
|
|
|
53987
54488
|
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
|
|
@@ -54228,7 +54729,7 @@ function hasPort(host) {
|
|
|
54228
54729
|
return !!~host.indexOf(':');
|
|
54229
54730
|
}}(common$3));
|
|
54230
54731
|
|
|
54231
|
-
var url$1 = require$$0$
|
|
54732
|
+
var url$1 = require$$0$9,
|
|
54232
54733
|
common$2 = common$3;
|
|
54233
54734
|
|
|
54234
54735
|
|
|
@@ -54394,12 +54895,12 @@ var debug_1 = function () {
|
|
|
54394
54895
|
debug$3.apply(null, arguments);
|
|
54395
54896
|
};
|
|
54396
54897
|
|
|
54397
|
-
var url = require$$0$
|
|
54898
|
+
var url = require$$0$9;
|
|
54398
54899
|
var URL$1 = url.URL;
|
|
54399
54900
|
var http$1 = require$$1$3;
|
|
54400
54901
|
var https$1 = require$$1$4;
|
|
54401
|
-
var Writable = require$$0$
|
|
54402
|
-
var assert =
|
|
54902
|
+
var Writable = require$$0$6.Writable;
|
|
54903
|
+
var assert = assert$3;
|
|
54403
54904
|
var debug$2 = debug_1;
|
|
54404
54905
|
|
|
54405
54906
|
// Create handlers that pass events from native requests
|
|
@@ -55348,8 +55849,8 @@ var wsIncoming = {
|
|
|
55348
55849
|
|
|
55349
55850
|
(function (module) {
|
|
55350
55851
|
var httpProxy = module.exports,
|
|
55351
|
-
extend = require$$0$
|
|
55352
|
-
parse_url = require$$0$
|
|
55852
|
+
extend = require$$0$5._extend,
|
|
55853
|
+
parse_url = require$$0$9.parse,
|
|
55353
55854
|
EE3 = eventemitter3.exports,
|
|
55354
55855
|
http = require$$1$3,
|
|
55355
55856
|
https = require$$1$4,
|
|
@@ -55458,7 +55959,7 @@ function ProxyServer(options) {
|
|
|
55458
55959
|
|
|
55459
55960
|
}
|
|
55460
55961
|
|
|
55461
|
-
require$$0$
|
|
55962
|
+
require$$0$5.inherits(ProxyServer, EE3);
|
|
55462
55963
|
|
|
55463
55964
|
ProxyServer.prototype.onError = function (err) {
|
|
55464
55965
|
//
|
|
@@ -55623,11 +56124,16 @@ function proxyMiddleware(httpServer, options, config) {
|
|
|
55623
56124
|
opts = { target: opts, changeOrigin: true };
|
|
55624
56125
|
}
|
|
55625
56126
|
const proxy = httpProxy.createProxyServer(opts);
|
|
55626
|
-
proxy.on('error', (err) => {
|
|
56127
|
+
proxy.on('error', (err, req, res) => {
|
|
55627
56128
|
config.logger.error(`${colors$1.red(`http proxy error:`)}\n${err.stack}`, {
|
|
55628
56129
|
timestamp: true,
|
|
55629
56130
|
error: err
|
|
55630
56131
|
});
|
|
56132
|
+
res
|
|
56133
|
+
.writeHead(500, {
|
|
56134
|
+
'Content-Type': 'text/plain'
|
|
56135
|
+
})
|
|
56136
|
+
.end();
|
|
55631
56137
|
});
|
|
55632
56138
|
if (opts.configure) {
|
|
55633
56139
|
opts.configure(proxy, opts);
|
|
@@ -55698,7 +56204,7 @@ var lib$1 = {exports: {}};
|
|
|
55698
56204
|
|
|
55699
56205
|
(function (module, exports) {
|
|
55700
56206
|
|
|
55701
|
-
var url = require$$0$
|
|
56207
|
+
var url = require$$0$9;
|
|
55702
56208
|
|
|
55703
56209
|
module.exports = function historyApiFallback(options) {
|
|
55704
56210
|
options = options || {};
|
|
@@ -55829,7 +56335,7 @@ function spaFallbackMiddleware(root) {
|
|
|
55829
56335
|
from: /\/$/,
|
|
55830
56336
|
to({ parsedUrl }) {
|
|
55831
56337
|
const rewritten = decodeURIComponent(parsedUrl.pathname) + 'index.html';
|
|
55832
|
-
if (
|
|
56338
|
+
if (fs$n.existsSync(path$q.join(root, rewritten))) {
|
|
55833
56339
|
return rewritten;
|
|
55834
56340
|
}
|
|
55835
56341
|
else {
|
|
@@ -55907,9 +56413,9 @@ function transformMiddleware(server) {
|
|
|
55907
56413
|
// means that the dependency has already been pre-bundled and loaded
|
|
55908
56414
|
const mapFile = url.startsWith(FS_PREFIX)
|
|
55909
56415
|
? fsPathFromId(url)
|
|
55910
|
-
: normalizePath$3(ensureVolumeInPath(path$
|
|
56416
|
+
: normalizePath$3(ensureVolumeInPath(path$q.resolve(root, url.slice(1))));
|
|
55911
56417
|
try {
|
|
55912
|
-
const map = await promises.readFile(mapFile, 'utf-8');
|
|
56418
|
+
const map = await promises$2.readFile(mapFile, 'utf-8');
|
|
55913
56419
|
return send(req, res, map, 'json', {
|
|
55914
56420
|
headers: server.config.server.headers
|
|
55915
56421
|
});
|
|
@@ -56058,7 +56564,7 @@ function getHtmlFilename(url, server) {
|
|
|
56058
56564
|
return decodeURIComponent(fsPathFromId(url));
|
|
56059
56565
|
}
|
|
56060
56566
|
else {
|
|
56061
|
-
return decodeURIComponent(normalizePath$3(path$
|
|
56567
|
+
return decodeURIComponent(normalizePath$3(path$q.join(server.config.root, url.slice(1))));
|
|
56062
56568
|
}
|
|
56063
56569
|
}
|
|
56064
56570
|
const startsWithSingleSlashRE = /^\/(?!\/)/;
|
|
@@ -56070,15 +56576,16 @@ const processNodeUrl = (node, s, config, htmlPath, originalUrl, moduleGraph) =>
|
|
|
56070
56576
|
url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
|
56071
56577
|
}
|
|
56072
56578
|
}
|
|
56579
|
+
const devBase = config.base;
|
|
56073
56580
|
if (startsWithSingleSlashRE.test(url)) {
|
|
56074
56581
|
// prefix with base (dev only, base is never relative)
|
|
56075
|
-
s.overwrite(node.value.loc.start.offset, node.value.loc.end.offset, `"${
|
|
56582
|
+
s.overwrite(node.value.loc.start.offset, node.value.loc.end.offset, `"${devBase + url.slice(1)}"`, { contentOnly: true });
|
|
56076
56583
|
}
|
|
56077
56584
|
else if (url.startsWith('.') &&
|
|
56078
56585
|
originalUrl &&
|
|
56079
56586
|
originalUrl !== '/' &&
|
|
56080
56587
|
htmlPath === '/index.html') {
|
|
56081
|
-
const replacer = (url) => path$
|
|
56588
|
+
const replacer = (url) => path$q.posix.join(devBase, path$q.posix.relative(originalUrl, devBase), url.slice(1));
|
|
56082
56589
|
// #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
|
|
56083
56590
|
// path will add `/a/` prefix, it will caused 404.
|
|
56084
56591
|
// rewrite before `./index.js` -> `localhost:5173/a/index.js`.
|
|
@@ -56094,7 +56601,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
56094
56601
|
let proxyModulePath;
|
|
56095
56602
|
let proxyModuleUrl;
|
|
56096
56603
|
const trailingSlash = htmlPath.endsWith('/');
|
|
56097
|
-
if (!trailingSlash &&
|
|
56604
|
+
if (!trailingSlash && fs$n.existsSync(filename)) {
|
|
56098
56605
|
proxyModulePath = htmlPath;
|
|
56099
56606
|
proxyModuleUrl = base + htmlPath.slice(1);
|
|
56100
56607
|
}
|
|
@@ -56185,7 +56692,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
56185
56692
|
tag: 'script',
|
|
56186
56693
|
attrs: {
|
|
56187
56694
|
type: 'module',
|
|
56188
|
-
src: path$
|
|
56695
|
+
src: path$q.posix.join(base, CLIENT_PUBLIC_PATH)
|
|
56189
56696
|
},
|
|
56190
56697
|
injectTo: 'head-prepend'
|
|
56191
56698
|
}
|
|
@@ -56202,9 +56709,9 @@ function indexHtmlMiddleware(server) {
|
|
|
56202
56709
|
// spa-fallback always redirects to /index.html
|
|
56203
56710
|
if (url?.endsWith('.html') && req.headers['sec-fetch-dest'] !== 'script') {
|
|
56204
56711
|
const filename = getHtmlFilename(url, server);
|
|
56205
|
-
if (
|
|
56712
|
+
if (fs$n.existsSync(filename)) {
|
|
56206
56713
|
try {
|
|
56207
|
-
let html =
|
|
56714
|
+
let html = fs$n.readFileSync(filename, 'utf-8');
|
|
56208
56715
|
html = await server.transformIndexHtml(url, html, req.originalUrl);
|
|
56209
56716
|
return send(req, res, html, 'html', {
|
|
56210
56717
|
headers: server.config.server.headers
|
|
@@ -56244,6 +56751,8 @@ class ModuleNode {
|
|
|
56244
56751
|
this.importers = new Set();
|
|
56245
56752
|
this.importedModules = new Set();
|
|
56246
56753
|
this.acceptedHmrDeps = new Set();
|
|
56754
|
+
this.acceptedHmrExports = null;
|
|
56755
|
+
this.importedBindings = null;
|
|
56247
56756
|
this.transformResult = null;
|
|
56248
56757
|
this.ssrTransformResult = null;
|
|
56249
56758
|
this.ssrModule = null;
|
|
@@ -56319,7 +56828,7 @@ class ModuleGraph {
|
|
|
56319
56828
|
* If there are dependencies that no longer have any importers, they are
|
|
56320
56829
|
* returned as a Set.
|
|
56321
56830
|
*/
|
|
56322
|
-
async updateModuleInfo(mod, importedModules, acceptedModules, isSelfAccepting, ssr) {
|
|
56831
|
+
async updateModuleInfo(mod, importedModules, importedBindings, acceptedModules, acceptedExports, isSelfAccepting, ssr) {
|
|
56323
56832
|
mod.isSelfAccepting = isSelfAccepting;
|
|
56324
56833
|
const prevImports = mod.importedModules;
|
|
56325
56834
|
const nextImports = (mod.importedModules = new Set());
|
|
@@ -56349,6 +56858,9 @@ class ModuleGraph {
|
|
|
56349
56858
|
: accepted;
|
|
56350
56859
|
deps.add(dep);
|
|
56351
56860
|
}
|
|
56861
|
+
// update accepted hmr exports
|
|
56862
|
+
mod.acceptedHmrExports = acceptedExports;
|
|
56863
|
+
mod.importedBindings = importedBindings;
|
|
56352
56864
|
return noLongerImported;
|
|
56353
56865
|
}
|
|
56354
56866
|
async ensureEntryFromUrl(rawUrl, ssr) {
|
|
@@ -56401,7 +56913,7 @@ class ModuleGraph {
|
|
|
56401
56913
|
url = removeImportQuery(removeTimestampQuery(url));
|
|
56402
56914
|
const resolved = await this.resolveId(url, !!ssr);
|
|
56403
56915
|
const resolvedId = resolved?.id || url;
|
|
56404
|
-
const ext = extname(cleanUrl(resolvedId));
|
|
56916
|
+
const ext = extname$1(cleanUrl(resolvedId));
|
|
56405
56917
|
const { pathname, search, hash } = parse$m(url);
|
|
56406
56918
|
if (ext && !pathname.endsWith(ext)) {
|
|
56407
56919
|
url = pathname + ext + (search || '') + (hash || '');
|
|
@@ -56412,7 +56924,7 @@ class ModuleGraph {
|
|
|
56412
56924
|
|
|
56413
56925
|
var isWsl$2 = {exports: {}};
|
|
56414
56926
|
|
|
56415
|
-
const fs$6 =
|
|
56927
|
+
const fs$6 = require$$0__default;
|
|
56416
56928
|
|
|
56417
56929
|
let isDocker$2;
|
|
56418
56930
|
|
|
@@ -56442,7 +56954,7 @@ var isDocker_1 = () => {
|
|
|
56442
56954
|
};
|
|
56443
56955
|
|
|
56444
56956
|
const os$1 = require$$1;
|
|
56445
|
-
const fs$5 =
|
|
56957
|
+
const fs$5 = require$$0__default;
|
|
56446
56958
|
const isDocker$1 = isDocker_1;
|
|
56447
56959
|
|
|
56448
56960
|
const isWsl$1 = () => {
|
|
@@ -56493,7 +57005,7 @@ var defineLazyProp = (object, propertyName, fn) => {
|
|
|
56493
57005
|
|
|
56494
57006
|
const path$4 = path$p;
|
|
56495
57007
|
const childProcess = require$$2;
|
|
56496
|
-
const {promises: fs$4, constants: fsConstants} =
|
|
57008
|
+
const {promises: fs$4, constants: fsConstants} = require$$0__default;
|
|
56497
57009
|
const isWsl = isWsl$2.exports;
|
|
56498
57010
|
const isDocker = isDocker_1;
|
|
56499
57011
|
const defineLazyProperty = defineLazyProp;
|
|
@@ -56812,7 +57324,7 @@ var crossSpawn = {exports: {}};
|
|
|
56812
57324
|
var windows = isexe$3;
|
|
56813
57325
|
isexe$3.sync = sync$2;
|
|
56814
57326
|
|
|
56815
|
-
var fs$3 =
|
|
57327
|
+
var fs$3 = require$$0__default;
|
|
56816
57328
|
|
|
56817
57329
|
function checkPathExt (path, options) {
|
|
56818
57330
|
var pathext = options.pathExt !== undefined ?
|
|
@@ -56855,7 +57367,7 @@ function sync$2 (path, options) {
|
|
|
56855
57367
|
var mode = isexe$2;
|
|
56856
57368
|
isexe$2.sync = sync$1;
|
|
56857
57369
|
|
|
56858
|
-
var fs$2 =
|
|
57370
|
+
var fs$2 = require$$0__default;
|
|
56859
57371
|
|
|
56860
57372
|
function isexe$2 (path, options, cb) {
|
|
56861
57373
|
fs$2.stat(path, function (er, stat) {
|
|
@@ -57212,7 +57724,7 @@ var shebangCommand$1 = (string = '') => {
|
|
|
57212
57724
|
return argument ? `${binary} ${argument}` : binary;
|
|
57213
57725
|
};
|
|
57214
57726
|
|
|
57215
|
-
const fs$1 =
|
|
57727
|
+
const fs$1 = require$$0__default;
|
|
57216
57728
|
const shebangCommand = shebangCommand$1;
|
|
57217
57729
|
|
|
57218
57730
|
function readShebang$1(command) {
|
|
@@ -57473,7 +57985,7 @@ function startBrowserProcess(browser, url) {
|
|
|
57473
57985
|
// on OS X Google Chrome with AppleScript
|
|
57474
57986
|
execSync('ps cax | grep "Google Chrome"');
|
|
57475
57987
|
execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
|
|
57476
|
-
cwd: join$
|
|
57988
|
+
cwd: join$2(VITE_PACKAGE_DIR, 'bin'),
|
|
57477
57989
|
stdio: 'ignore'
|
|
57478
57990
|
});
|
|
57479
57991
|
return true;
|
|
@@ -57517,19 +58029,19 @@ const ROOT_FILES = [
|
|
|
57517
58029
|
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
|
57518
58030
|
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
|
57519
58031
|
function hasWorkspacePackageJSON(root) {
|
|
57520
|
-
const path = join$
|
|
58032
|
+
const path = join$2(root, 'package.json');
|
|
57521
58033
|
if (!isFileReadable(path)) {
|
|
57522
58034
|
return false;
|
|
57523
58035
|
}
|
|
57524
|
-
const content = JSON.parse(
|
|
58036
|
+
const content = JSON.parse(fs$n.readFileSync(path, 'utf-8')) || {};
|
|
57525
58037
|
return !!content.workspaces;
|
|
57526
58038
|
}
|
|
57527
58039
|
function hasRootFile(root) {
|
|
57528
|
-
return ROOT_FILES.some((file) =>
|
|
58040
|
+
return ROOT_FILES.some((file) => fs$n.existsSync(join$2(root, file)));
|
|
57529
58041
|
}
|
|
57530
58042
|
function hasPackageJSON(root) {
|
|
57531
|
-
const path = join$
|
|
57532
|
-
return
|
|
58043
|
+
const path = join$2(root, 'package.json');
|
|
58044
|
+
return fs$n.existsSync(path);
|
|
57533
58045
|
}
|
|
57534
58046
|
/**
|
|
57535
58047
|
* Search up for the nearest `package.json`
|
|
@@ -57537,7 +58049,7 @@ function hasPackageJSON(root) {
|
|
|
57537
58049
|
function searchForPackageRoot(current, root = current) {
|
|
57538
58050
|
if (hasPackageJSON(current))
|
|
57539
58051
|
return current;
|
|
57540
|
-
const dir = dirname$
|
|
58052
|
+
const dir = dirname$2(current);
|
|
57541
58053
|
// reach the fs root
|
|
57542
58054
|
if (!dir || dir === current)
|
|
57543
58055
|
return root;
|
|
@@ -57551,7 +58063,7 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
57551
58063
|
return current;
|
|
57552
58064
|
if (hasWorkspacePackageJSON(current))
|
|
57553
58065
|
return current;
|
|
57554
|
-
const dir = dirname$
|
|
58066
|
+
const dir = dirname$2(current);
|
|
57555
58067
|
// reach the fs root
|
|
57556
58068
|
if (!dir || dir === current)
|
|
57557
58069
|
return root;
|
|
@@ -57562,17 +58074,14 @@ async function createServer(inlineConfig = {}) {
|
|
|
57562
58074
|
const config = await resolveConfig(inlineConfig, 'serve', 'development');
|
|
57563
58075
|
const { root, server: serverConfig } = config;
|
|
57564
58076
|
const httpsOptions = await resolveHttpsConfig(config.server.https, config.cacheDir);
|
|
57565
|
-
|
|
57566
|
-
if (middlewareMode === true) {
|
|
57567
|
-
middlewareMode = 'ssr';
|
|
57568
|
-
}
|
|
58077
|
+
const { middlewareMode } = serverConfig;
|
|
57569
58078
|
const middlewares = connect();
|
|
57570
58079
|
const httpServer = middlewareMode
|
|
57571
58080
|
? null
|
|
57572
58081
|
: await resolveHttpServer(serverConfig, middlewares, httpsOptions);
|
|
57573
58082
|
const ws = createWebSocketServer(httpServer, config, httpsOptions);
|
|
57574
58083
|
const { ignored = [], ...watchOptions } = serverConfig.watch || {};
|
|
57575
|
-
const watcher = chokidar.watch(path$
|
|
58084
|
+
const watcher = chokidar.watch(path$q.resolve(root), {
|
|
57576
58085
|
ignored: [
|
|
57577
58086
|
'**/node_modules/**',
|
|
57578
58087
|
'**/.git/**',
|
|
@@ -57634,9 +58143,9 @@ async function createServer(inlineConfig = {}) {
|
|
|
57634
58143
|
closeHttpServer()
|
|
57635
58144
|
]);
|
|
57636
58145
|
},
|
|
57637
|
-
printUrls() {
|
|
58146
|
+
async printUrls() {
|
|
57638
58147
|
if (httpServer) {
|
|
57639
|
-
printCommonServerUrls(httpServer, config.server, config);
|
|
58148
|
+
await printCommonServerUrls(httpServer, config.server, config);
|
|
57640
58149
|
}
|
|
57641
58150
|
else {
|
|
57642
58151
|
throw new Error('cannot print server URLs in middleware mode.');
|
|
@@ -57735,7 +58244,8 @@ async function createServer(inlineConfig = {}) {
|
|
|
57735
58244
|
middlewares.use(proxyMiddleware(httpServer, proxy, config));
|
|
57736
58245
|
}
|
|
57737
58246
|
// base
|
|
57738
|
-
|
|
58247
|
+
const devBase = config.base;
|
|
58248
|
+
if (devBase !== '/') {
|
|
57739
58249
|
middlewares.use(baseMiddleware(server));
|
|
57740
58250
|
}
|
|
57741
58251
|
// open in editor support
|
|
@@ -57751,20 +58261,17 @@ async function createServer(inlineConfig = {}) {
|
|
|
57751
58261
|
// serve static files
|
|
57752
58262
|
middlewares.use(serveRawFsMiddleware(server));
|
|
57753
58263
|
middlewares.use(serveStaticMiddleware(root, server));
|
|
57754
|
-
const isMiddlewareMode = middlewareMode && middlewareMode !== 'html';
|
|
57755
58264
|
// spa fallback
|
|
57756
|
-
if (config.
|
|
58265
|
+
if (config.appType === 'spa') {
|
|
57757
58266
|
middlewares.use(spaFallbackMiddleware(root));
|
|
57758
58267
|
}
|
|
57759
58268
|
// run post config hooks
|
|
57760
58269
|
// This is applied before the html middleware so that user middleware can
|
|
57761
58270
|
// serve custom content instead of index.html.
|
|
57762
58271
|
postHooks.forEach((fn) => fn && fn());
|
|
57763
|
-
if (config.spa
|
|
58272
|
+
if (config.appType === 'spa' || config.appType === 'mpa') {
|
|
57764
58273
|
// transform index.html
|
|
57765
58274
|
middlewares.use(indexHtmlMiddleware(server));
|
|
57766
|
-
}
|
|
57767
|
-
if (!isMiddlewareMode) {
|
|
57768
58275
|
// handle 404s
|
|
57769
58276
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
57770
58277
|
middlewares.use(function vite404Middleware(_, res) {
|
|
@@ -57773,7 +58280,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
57773
58280
|
});
|
|
57774
58281
|
}
|
|
57775
58282
|
// error handler
|
|
57776
|
-
middlewares.use(errorMiddleware(server,
|
|
58283
|
+
middlewares.use(errorMiddleware(server, middlewareMode));
|
|
57777
58284
|
const initOptimizer = async () => {
|
|
57778
58285
|
if (isDepsOptimizerEnabled(config)) {
|
|
57779
58286
|
await initDepsOptimizer(config, server);
|
|
@@ -57811,10 +58318,10 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
57811
58318
|
}
|
|
57812
58319
|
const options = server.config.server;
|
|
57813
58320
|
const port = inlinePort ?? options.port ?? 5173;
|
|
57814
|
-
const hostname = resolveHostname(options.host);
|
|
58321
|
+
const hostname = await resolveHostname(options.host);
|
|
57815
58322
|
const protocol = options.https ? 'https' : 'http';
|
|
57816
58323
|
const info = server.config.logger.info;
|
|
57817
|
-
const
|
|
58324
|
+
const devBase = server.config.base;
|
|
57818
58325
|
const serverPort = await httpServerStart(httpServer, {
|
|
57819
58326
|
port,
|
|
57820
58327
|
strictPort: options.strictPort,
|
|
@@ -57827,8 +58334,8 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
57827
58334
|
profileSession.post('Profiler.stop', (err, { profile }) => {
|
|
57828
58335
|
// Write profile to disk, upload, etc.
|
|
57829
58336
|
if (!err) {
|
|
57830
|
-
const outPath = path$
|
|
57831
|
-
|
|
58337
|
+
const outPath = path$q.resolve('./vite-profile.cpuprofile');
|
|
58338
|
+
fs$n.writeFileSync(outPath, JSON.stringify(profile));
|
|
57832
58339
|
info(colors$1.yellow(` CPU profile written to ${colors$1.white(colors$1.dim(outPath))}\n`));
|
|
57833
58340
|
}
|
|
57834
58341
|
else {
|
|
@@ -57837,7 +58344,7 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
57837
58344
|
});
|
|
57838
58345
|
}
|
|
57839
58346
|
if (options.open && !isRestart) {
|
|
57840
|
-
const path = typeof options.open === 'string' ? options.open :
|
|
58347
|
+
const path = typeof options.open === 'string' ? options.open : devBase;
|
|
57841
58348
|
openBrowser(path.startsWith('http')
|
|
57842
58349
|
? path
|
|
57843
58350
|
: `${protocol}://${hostname.name}:${serverPort}${path}`, true, server.config.logger);
|
|
@@ -57877,12 +58384,13 @@ function createServerCloseFn(server) {
|
|
|
57877
58384
|
});
|
|
57878
58385
|
}
|
|
57879
58386
|
function resolvedAllowDir(root, dir) {
|
|
57880
|
-
return normalizePath$3(path$
|
|
58387
|
+
return normalizePath$3(path$q.resolve(root, dir));
|
|
57881
58388
|
}
|
|
57882
58389
|
function resolveServerOptions(root, raw, logger) {
|
|
57883
58390
|
const server = {
|
|
57884
58391
|
preTransformRequests: true,
|
|
57885
|
-
...raw
|
|
58392
|
+
...raw,
|
|
58393
|
+
middlewareMode: !!raw?.middlewareMode
|
|
57886
58394
|
};
|
|
57887
58395
|
let allowDirs = server.fs?.allow;
|
|
57888
58396
|
const deny = server.fs?.deny || ['.env', '.env.*', '*.{crt,pem}'];
|
|
@@ -57957,13 +58465,15 @@ async function restartServer(server) {
|
|
|
57957
58465
|
}
|
|
57958
58466
|
async function updateCjsSsrExternals(server) {
|
|
57959
58467
|
if (!server._ssrExternals) {
|
|
58468
|
+
// We use the non-ssr optimized deps to find known imports
|
|
57960
58469
|
let knownImports = [];
|
|
57961
58470
|
const depsOptimizer = getDepsOptimizer(server.config);
|
|
57962
58471
|
if (depsOptimizer) {
|
|
57963
58472
|
await depsOptimizer.scanProcessing;
|
|
58473
|
+
const metadata = depsOptimizer.metadata({ ssr: false });
|
|
57964
58474
|
knownImports = [
|
|
57965
|
-
...Object.keys(
|
|
57966
|
-
...Object.keys(
|
|
58475
|
+
...Object.keys(metadata.optimized),
|
|
58476
|
+
...Object.keys(metadata.discovered)
|
|
57967
58477
|
];
|
|
57968
58478
|
}
|
|
57969
58479
|
server._ssrExternals = cjsSsrResolveExternals(server.config, knownImports);
|
|
@@ -58121,21 +58631,21 @@ async function preview(inlineConfig = {}) {
|
|
|
58121
58631
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
|
58122
58632
|
}
|
|
58123
58633
|
app.use(compression());
|
|
58634
|
+
const previewBase = config.base === './' || config.base === '' ? '/' : config.base;
|
|
58124
58635
|
// static assets
|
|
58125
|
-
const distDir = path$
|
|
58126
|
-
app.use(
|
|
58636
|
+
const distDir = path$q.resolve(config.root, config.build.outDir);
|
|
58637
|
+
app.use(previewBase, sirv(distDir, {
|
|
58127
58638
|
etag: true,
|
|
58128
58639
|
dev: true,
|
|
58129
|
-
single: config.spa
|
|
58640
|
+
single: config.appType === 'spa'
|
|
58130
58641
|
}));
|
|
58131
58642
|
// apply post server hooks from plugins
|
|
58132
58643
|
postHooks.forEach((fn) => fn && fn());
|
|
58133
58644
|
const options = config.preview;
|
|
58134
|
-
const hostname = resolveHostname(options.host);
|
|
58645
|
+
const hostname = await resolveHostname(options.host);
|
|
58135
58646
|
const port = options.port ?? 4173;
|
|
58136
58647
|
const protocol = options.https ? 'https' : 'http';
|
|
58137
58648
|
const logger = config.logger;
|
|
58138
|
-
const base = config.base;
|
|
58139
58649
|
const serverPort = await httpServerStart(httpServer, {
|
|
58140
58650
|
port,
|
|
58141
58651
|
strictPort: options.strictPort,
|
|
@@ -58143,7 +58653,7 @@ async function preview(inlineConfig = {}) {
|
|
|
58143
58653
|
logger
|
|
58144
58654
|
});
|
|
58145
58655
|
if (options.open) {
|
|
58146
|
-
const path = typeof options.open === 'string' ? options.open :
|
|
58656
|
+
const path = typeof options.open === 'string' ? options.open : previewBase;
|
|
58147
58657
|
openBrowser(path.startsWith('http')
|
|
58148
58658
|
? path
|
|
58149
58659
|
: `${protocol}://${hostname.name}:${serverPort}${path}`, true, logger);
|
|
@@ -58151,8 +58661,8 @@ async function preview(inlineConfig = {}) {
|
|
|
58151
58661
|
return {
|
|
58152
58662
|
config,
|
|
58153
58663
|
httpServer,
|
|
58154
|
-
printUrls() {
|
|
58155
|
-
printCommonServerUrls(httpServer, config.preview, config);
|
|
58664
|
+
async printUrls() {
|
|
58665
|
+
await printCommonServerUrls(httpServer, config.preview, config);
|
|
58156
58666
|
}
|
|
58157
58667
|
};
|
|
58158
58668
|
}
|
|
@@ -58173,38 +58683,39 @@ const normalizedEnvEntry = normalizePath$3(ENV_ENTRY);
|
|
|
58173
58683
|
function clientInjectionsPlugin(config) {
|
|
58174
58684
|
return {
|
|
58175
58685
|
name: 'vite:client-inject',
|
|
58176
|
-
transform(code, id, options) {
|
|
58686
|
+
async transform(code, id, options) {
|
|
58177
58687
|
if (id === normalizedClientEntry || id === normalizedEnvEntry) {
|
|
58178
|
-
let
|
|
58179
|
-
|
|
58180
|
-
const host =
|
|
58181
|
-
const protocol =
|
|
58182
|
-
const timeout =
|
|
58183
|
-
const overlay =
|
|
58184
|
-
|
|
58185
|
-
if (
|
|
58186
|
-
|
|
58187
|
-
|
|
58688
|
+
let hmrConfig = config.server.hmr;
|
|
58689
|
+
hmrConfig = isObject$2(hmrConfig) ? hmrConfig : undefined;
|
|
58690
|
+
const host = hmrConfig?.host || null;
|
|
58691
|
+
const protocol = hmrConfig?.protocol || null;
|
|
58692
|
+
const timeout = hmrConfig?.timeout || 30000;
|
|
58693
|
+
const overlay = hmrConfig?.overlay !== false;
|
|
58694
|
+
// hmr.clientPort -> hmr.port
|
|
58695
|
+
// -> (24678 if middleware mode) -> new URL(import.meta.url).port
|
|
58696
|
+
let port = hmrConfig
|
|
58697
|
+
? String(hmrConfig.clientPort || hmrConfig.port)
|
|
58698
|
+
: null;
|
|
58188
58699
|
if (config.server.middlewareMode) {
|
|
58189
|
-
port
|
|
58190
|
-
}
|
|
58191
|
-
else {
|
|
58192
|
-
port = String(port || options.port || config.server.port);
|
|
58193
|
-
}
|
|
58194
|
-
let hmrBase = config.base;
|
|
58195
|
-
if (options.path) {
|
|
58196
|
-
hmrBase = path$p.posix.join(hmrBase, options.path);
|
|
58700
|
+
port || (port = '24678');
|
|
58197
58701
|
}
|
|
58198
|
-
|
|
58199
|
-
|
|
58702
|
+
const devBase = config.base;
|
|
58703
|
+
let directTarget = hmrConfig?.host || (await resolveHostname(config.server.host)).name;
|
|
58704
|
+
directTarget += `:${hmrConfig?.port || config.server.port}`;
|
|
58705
|
+
directTarget += devBase;
|
|
58706
|
+
let hmrBase = devBase;
|
|
58707
|
+
if (hmrConfig?.path) {
|
|
58708
|
+
hmrBase = path$q.posix.join(hmrBase, hmrConfig.path);
|
|
58200
58709
|
}
|
|
58201
58710
|
return code
|
|
58202
58711
|
.replace(`__MODE__`, JSON.stringify(config.mode))
|
|
58203
|
-
.replace(`__BASE__`, JSON.stringify(
|
|
58712
|
+
.replace(`__BASE__`, JSON.stringify(devBase))
|
|
58204
58713
|
.replace(`__DEFINES__`, serializeDefine(config.define || {}))
|
|
58205
58714
|
.replace(`__HMR_PROTOCOL__`, JSON.stringify(protocol))
|
|
58206
58715
|
.replace(`__HMR_HOSTNAME__`, JSON.stringify(host))
|
|
58207
58716
|
.replace(`__HMR_PORT__`, JSON.stringify(port))
|
|
58717
|
+
.replace(`__HMR_DIRECT_TARGET__`, JSON.stringify(directTarget))
|
|
58718
|
+
.replace(`__HMR_BASE__`, JSON.stringify(hmrBase))
|
|
58208
58719
|
.replace(`__HMR_TIMEOUT__`, JSON.stringify(timeout))
|
|
58209
58720
|
.replace(`__HMR_ENABLE_OVERLAY__`, JSON.stringify(overlay));
|
|
58210
58721
|
}
|
|
@@ -58231,11 +58742,21 @@ const wasmHelperId = '/__vite-wasm-helper';
|
|
|
58231
58742
|
const wasmHelper = async (opts = {}, url) => {
|
|
58232
58743
|
let result;
|
|
58233
58744
|
if (url.startsWith('data:')) {
|
|
58234
|
-
|
|
58235
|
-
|
|
58236
|
-
|
|
58237
|
-
|
|
58238
|
-
|
|
58745
|
+
const urlContent = url.replace(/^data:.*?base64,/, '');
|
|
58746
|
+
let bytes;
|
|
58747
|
+
if (typeof Buffer === 'function' && typeof Buffer.from === 'function') {
|
|
58748
|
+
bytes = Buffer.from(urlContent, 'base64');
|
|
58749
|
+
}
|
|
58750
|
+
else if (typeof atob === 'function') {
|
|
58751
|
+
// @ts-ignore
|
|
58752
|
+
const binaryString = atob(urlContent);
|
|
58753
|
+
bytes = new Uint8Array(binaryString.length);
|
|
58754
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
58755
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
58756
|
+
}
|
|
58757
|
+
}
|
|
58758
|
+
else {
|
|
58759
|
+
throw new Error('Failed to decode base64-encoded data URL, Buffer and atob are not supported');
|
|
58239
58760
|
}
|
|
58240
58761
|
// @ts-ignore
|
|
58241
58762
|
result = await WebAssembly.instantiate(bytes, opts);
|
|
@@ -58332,9 +58853,9 @@ async function bundleWorkerEntry(config, id, query) {
|
|
|
58332
58853
|
: workerOutputConfig
|
|
58333
58854
|
: {};
|
|
58334
58855
|
const { output: [outputChunk, ...outputChunks] } = await bundle.generate({
|
|
58335
|
-
entryFileNames: path$
|
|
58336
|
-
chunkFileNames: path$
|
|
58337
|
-
assetFileNames: path$
|
|
58856
|
+
entryFileNames: path$q.posix.join(config.build.assetsDir, '[name].[hash].js'),
|
|
58857
|
+
chunkFileNames: path$q.posix.join(config.build.assetsDir, '[name].[hash].js'),
|
|
58858
|
+
assetFileNames: path$q.posix.join(config.build.assetsDir, '[name].[hash].[ext]'),
|
|
58338
58859
|
...workerConfig,
|
|
58339
58860
|
format,
|
|
58340
58861
|
sourcemap: config.build.sourcemap
|
|
@@ -58386,7 +58907,7 @@ function emitSourcemapForWorkerEntry(config, query, chunk) {
|
|
|
58386
58907
|
// non-inline web workers can use a relative path
|
|
58387
58908
|
const sourceMapUrl = query?.inline != null
|
|
58388
58909
|
? mapFileName
|
|
58389
|
-
: path$
|
|
58910
|
+
: path$q.relative(config.build.assetsDir, mapFileName);
|
|
58390
58911
|
chunk.code += `//# sourceMappingURL=${sourceMapUrl}`;
|
|
58391
58912
|
}
|
|
58392
58913
|
}
|
|
@@ -58415,9 +58936,10 @@ async function workerFileToUrl(config, id, query) {
|
|
|
58415
58936
|
});
|
|
58416
58937
|
workerMap.bundle.set(id, fileName);
|
|
58417
58938
|
}
|
|
58418
|
-
|
|
58939
|
+
const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
|
|
58940
|
+
return assetsBase.relative || assetsBase.runtime
|
|
58419
58941
|
? encodeWorkerAssetFileName(fileName, workerMap)
|
|
58420
|
-
: config.base + fileName;
|
|
58942
|
+
: (assetsBase.url ?? config.base) + fileName;
|
|
58421
58943
|
}
|
|
58422
58944
|
function webWorkerPlugin(config) {
|
|
58423
58945
|
const isBuild = config.command === 'build';
|
|
@@ -58546,14 +59068,28 @@ function webWorkerPlugin(config) {
|
|
|
58546
59068
|
// Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
|
|
58547
59069
|
const workerMap = workerCache.get(config.mainConfig || config);
|
|
58548
59070
|
const { fileNameHash } = workerMap;
|
|
59071
|
+
const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
|
|
58549
59072
|
while ((match = workerAssetUrlRE.exec(code))) {
|
|
58550
59073
|
const [full, hash] = match;
|
|
58551
59074
|
const filename = fileNameHash.get(hash);
|
|
58552
|
-
let
|
|
58553
|
-
if (
|
|
58554
|
-
|
|
59075
|
+
let replacement;
|
|
59076
|
+
if (assetsBase.runtime) {
|
|
59077
|
+
replacement = `"+${assetsBase.runtime(JSON.stringify(filename))}+"`;
|
|
59078
|
+
}
|
|
59079
|
+
else {
|
|
59080
|
+
// Relative base
|
|
59081
|
+
let outputFilepath;
|
|
59082
|
+
if (assetsBase.relative && !config.build.ssr) {
|
|
59083
|
+
outputFilepath = path$q.posix.relative(path$q.dirname(chunk.fileName), filename);
|
|
59084
|
+
if (!outputFilepath.startsWith('.')) {
|
|
59085
|
+
outputFilepath = './' + outputFilepath;
|
|
59086
|
+
}
|
|
59087
|
+
}
|
|
59088
|
+
else {
|
|
59089
|
+
outputFilepath = (assetsBase.url ?? config.base) + filename;
|
|
59090
|
+
}
|
|
59091
|
+
replacement = JSON.stringify(outputFilepath).slice(1, -1);
|
|
58555
59092
|
}
|
|
58556
|
-
const replacement = JSON.stringify(outputFilepath).slice(1, -1);
|
|
58557
59093
|
s.overwrite(match.index, match.index + full.length, replacement, {
|
|
58558
59094
|
contentOnly: true
|
|
58559
59095
|
});
|
|
@@ -58583,12 +59119,10 @@ function preAliasPlugin(config) {
|
|
|
58583
59119
|
return {
|
|
58584
59120
|
name: 'vite:pre-alias',
|
|
58585
59121
|
async resolveId(id, importer, options) {
|
|
59122
|
+
const ssr = options?.ssr ?? false;
|
|
58586
59123
|
const depsOptimizer = getDepsOptimizer(config);
|
|
58587
|
-
if (depsOptimizer &&
|
|
58588
|
-
|
|
58589
|
-
bareImportRE.test(id) &&
|
|
58590
|
-
!options?.scan) {
|
|
58591
|
-
return await tryOptimizedResolve(depsOptimizer, id, importer);
|
|
59124
|
+
if (depsOptimizer && bareImportRE.test(id) && !options?.scan) {
|
|
59125
|
+
return await tryOptimizedResolve(depsOptimizer, ssr, id, importer);
|
|
58592
59126
|
}
|
|
58593
59127
|
}
|
|
58594
59128
|
};
|
|
@@ -60180,7 +60714,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
60180
60714
|
}
|
|
60181
60715
|
s || (s = new MagicString(code));
|
|
60182
60716
|
const workerType = getWorkerType(code, cleanString, index + allExp.length);
|
|
60183
|
-
const file = normalizePath$3(path$
|
|
60717
|
+
const file = normalizePath$3(path$q.resolve(path$q.dirname(id), rawUrl.slice(1, -1)));
|
|
60184
60718
|
let url;
|
|
60185
60719
|
if (isBuild) {
|
|
60186
60720
|
getDepsOptimizer(config)?.registerWorkersSource(id);
|
|
@@ -60365,7 +60899,7 @@ async function transformDynamicImport(importSource, importer, resolve) {
|
|
|
60365
60899
|
if (!resolvedFileName) {
|
|
60366
60900
|
return null;
|
|
60367
60901
|
}
|
|
60368
|
-
const relativeFileName = posix$
|
|
60902
|
+
const relativeFileName = posix$2.relative(posix$2.dirname(normalizePath$3(importer)), normalizePath$3(resolvedFileName));
|
|
60369
60903
|
importSource = normalizePath$3('`' + (relativeFileName[0] === '.' ? '' : './') + relativeFileName + '`');
|
|
60370
60904
|
}
|
|
60371
60905
|
const dynamicImportPattern = parseDynamicImportPattern(importSource);
|
|
@@ -60522,7 +61056,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
60522
61056
|
|
|
60523
61057
|
var main$1 = {exports: {}};
|
|
60524
61058
|
|
|
60525
|
-
const fs =
|
|
61059
|
+
const fs = require$$0__default;
|
|
60526
61060
|
const path = path$p;
|
|
60527
61061
|
const os = require$$1;
|
|
60528
61062
|
|
|
@@ -60736,7 +61270,7 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
60736
61270
|
for (const file of envFiles) {
|
|
60737
61271
|
const path = lookupFile(envDir, [file], { pathOnly: true, rootDir: envDir });
|
|
60738
61272
|
if (path) {
|
|
60739
|
-
const parsed = dotenv.parse(
|
|
61273
|
+
const parsed = dotenv.parse(fs$n.readFileSync(path), {
|
|
60740
61274
|
debug: process.env.DEBUG?.includes('vite:dotenv') || undefined
|
|
60741
61275
|
});
|
|
60742
61276
|
// let environment variables use each other
|
|
@@ -60822,7 +61356,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60822
61356
|
mode = inlineConfig.mode || config.mode || mode;
|
|
60823
61357
|
configEnv.mode = mode;
|
|
60824
61358
|
// resolve plugins
|
|
60825
|
-
const rawUserPlugins = (config.plugins || [])
|
|
61359
|
+
const rawUserPlugins = (await asyncFlatten(config.plugins || [])).filter((p) => {
|
|
60826
61360
|
if (!p) {
|
|
60827
61361
|
return false;
|
|
60828
61362
|
}
|
|
@@ -60854,7 +61388,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60854
61388
|
}
|
|
60855
61389
|
}
|
|
60856
61390
|
// resolve root
|
|
60857
|
-
const resolvedRoot = normalizePath$3(config.root ? path$
|
|
61391
|
+
const resolvedRoot = normalizePath$3(config.root ? path$q.resolve(config.root) : process.cwd());
|
|
60858
61392
|
const clientAlias = [
|
|
60859
61393
|
{ find: /^[\/]?@vite\/env/, replacement: () => ENV_ENTRY },
|
|
60860
61394
|
{ find: /^[\/]?@vite\/client/, replacement: () => CLIENT_ENTRY }
|
|
@@ -60870,7 +61404,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60870
61404
|
};
|
|
60871
61405
|
// load .env files
|
|
60872
61406
|
const envDir = config.envDir
|
|
60873
|
-
? normalizePath$3(path$
|
|
61407
|
+
? normalizePath$3(path$q.resolve(resolvedRoot, config.envDir))
|
|
60874
61408
|
: resolvedRoot;
|
|
60875
61409
|
const userEnv = inlineConfig.envFile !== false &&
|
|
60876
61410
|
loadEnv(mode, envDir, resolveEnvPrefix(config));
|
|
@@ -60884,15 +61418,31 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60884
61418
|
process.env.NODE_ENV = 'production';
|
|
60885
61419
|
}
|
|
60886
61420
|
// resolve public base url
|
|
60887
|
-
const
|
|
61421
|
+
const isBuild = command === 'build';
|
|
61422
|
+
const relativeBaseShortcut = config.base === '' || config.base === './';
|
|
61423
|
+
// During dev, we ignore relative base and fallback to '/'
|
|
61424
|
+
// For the SSR build, relative base isn't possible by means
|
|
61425
|
+
// of import.meta.url. The user will be able to work out a setup
|
|
61426
|
+
// using experimental.buildAdvancedBaseOptions
|
|
61427
|
+
const base = relativeBaseShortcut && (!isBuild || config.build?.ssr)
|
|
61428
|
+
? '/'
|
|
61429
|
+
: config.base ?? '/';
|
|
61430
|
+
let resolvedBase = relativeBaseShortcut
|
|
61431
|
+
? base
|
|
61432
|
+
: resolveBaseUrl(base, isBuild, logger, 'base');
|
|
61433
|
+
if (config.experimental?.buildAdvancedBaseOptions?.relative &&
|
|
61434
|
+
config.base === undefined) {
|
|
61435
|
+
resolvedBase = './';
|
|
61436
|
+
}
|
|
61437
|
+
const resolvedBuildAdvancedBaseOptions = resolveBuildAdvancedBaseConfig(config.experimental?.buildAdvancedBaseOptions, resolvedBase, isBuild, logger);
|
|
60888
61438
|
const resolvedBuildOptions = resolveBuildOptions(config.build);
|
|
60889
61439
|
// resolve cache directory
|
|
60890
61440
|
const pkgPath = lookupFile(resolvedRoot, [`package.json`], { pathOnly: true });
|
|
60891
61441
|
const cacheDir = config.cacheDir
|
|
60892
|
-
? path$
|
|
61442
|
+
? path$q.resolve(resolvedRoot, config.cacheDir)
|
|
60893
61443
|
: pkgPath
|
|
60894
|
-
? path$
|
|
60895
|
-
: path$
|
|
61444
|
+
? path$q.join(path$q.dirname(pkgPath), `node_modules/.vite`)
|
|
61445
|
+
: path$q.join(resolvedRoot, `.vite`);
|
|
60896
61446
|
const assetsFilter = config.assetsInclude
|
|
60897
61447
|
? createFilter(config.assetsInclude)
|
|
60898
61448
|
: () => false;
|
|
@@ -60937,18 +61487,26 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60937
61487
|
};
|
|
60938
61488
|
const { publicDir } = config;
|
|
60939
61489
|
const resolvedPublicDir = publicDir !== false && publicDir !== ''
|
|
60940
|
-
? path$
|
|
61490
|
+
? path$q.resolve(resolvedRoot, typeof publicDir === 'string' ? publicDir : 'public')
|
|
60941
61491
|
: '';
|
|
60942
61492
|
const server = resolveServerOptions(resolvedRoot, config.server, logger);
|
|
60943
|
-
|
|
61493
|
+
let ssr = resolveSSROptions(config.ssr);
|
|
61494
|
+
if (config.legacy?.buildSsrCjsExternalHeuristics) {
|
|
61495
|
+
if (ssr)
|
|
61496
|
+
ssr.format = 'cjs';
|
|
61497
|
+
else
|
|
61498
|
+
ssr = { target: 'node', format: 'cjs' };
|
|
61499
|
+
}
|
|
61500
|
+
const middlewareMode = config?.server?.middlewareMode;
|
|
60944
61501
|
const optimizeDeps = config.optimizeDeps || {};
|
|
61502
|
+
const BASE_URL = resolvedBase;
|
|
60945
61503
|
const resolved = {
|
|
60946
61504
|
...config,
|
|
60947
61505
|
configFile: configFile ? normalizePath$3(configFile) : undefined,
|
|
60948
|
-
configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$
|
|
61506
|
+
configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$q.resolve(name))),
|
|
60949
61507
|
inlineConfig,
|
|
60950
61508
|
root: resolvedRoot,
|
|
60951
|
-
base:
|
|
61509
|
+
base: resolvedBase,
|
|
60952
61510
|
resolve: resolveOptions,
|
|
60953
61511
|
publicDir: resolvedPublicDir,
|
|
60954
61512
|
cacheDir,
|
|
@@ -60983,9 +61541,32 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60983
61541
|
}
|
|
60984
61542
|
},
|
|
60985
61543
|
worker: resolvedWorkerOptions,
|
|
60986
|
-
|
|
61544
|
+
appType: config.appType ?? middlewareMode === 'ssr' ? 'custom' : 'spa',
|
|
61545
|
+
experimental: {
|
|
61546
|
+
importGlobRestoreExtension: false,
|
|
61547
|
+
hmrPartialAccept: false,
|
|
61548
|
+
...config.experimental,
|
|
61549
|
+
buildAdvancedBaseOptions: resolvedBuildAdvancedBaseOptions
|
|
61550
|
+
}
|
|
60987
61551
|
};
|
|
60988
|
-
|
|
61552
|
+
if (middlewareMode === 'ssr') {
|
|
61553
|
+
logger.warn(colors$1.yellow(`server.middlewareMode 'ssr' is now deprecated, use server.middlewareMode true and appType 'custom'`));
|
|
61554
|
+
}
|
|
61555
|
+
if (middlewareMode === 'html') {
|
|
61556
|
+
logger.warn(colors$1.yellow(`server.middlewareMode 'html' is now deprecated, use server.middlewareMode true`));
|
|
61557
|
+
}
|
|
61558
|
+
if (resolved.legacy?.buildRollupPluginCommonjs) {
|
|
61559
|
+
const optimizerDisabled = resolved.optimizeDeps.disabled;
|
|
61560
|
+
if (!optimizerDisabled) {
|
|
61561
|
+
resolved.optimizeDeps.disabled = 'build';
|
|
61562
|
+
}
|
|
61563
|
+
else if (optimizerDisabled === 'dev') {
|
|
61564
|
+
resolved.optimizeDeps.disabled = true; // Also disabled during build
|
|
61565
|
+
}
|
|
61566
|
+
}
|
|
61567
|
+
// Some plugins that aren't intended to work in the bundling of workers (doing post-processing at build time for example).
|
|
61568
|
+
// And Plugins may also have cached that could be corrupted by being used in these extra rollup calls.
|
|
61569
|
+
// So we need to separate the worker plugin from the plugin that vite needs to run.
|
|
60989
61570
|
const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins(config.worker?.plugins);
|
|
60990
61571
|
const workerResolved = {
|
|
60991
61572
|
...resolved,
|
|
@@ -61009,19 +61590,31 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
61009
61590
|
`Note Vite now defaults to use esbuild for minification. If you still ` +
|
|
61010
61591
|
`prefer Terser, set build.minify to "terser".`));
|
|
61011
61592
|
}
|
|
61593
|
+
// Check if all assetFileNames have the same reference.
|
|
61594
|
+
// If not, display a warn for user.
|
|
61595
|
+
const outputOption = config.build?.rollupOptions?.output ?? [];
|
|
61596
|
+
// Use isArray to narrow its type to array
|
|
61597
|
+
if (Array.isArray(outputOption)) {
|
|
61598
|
+
const assetFileNamesList = outputOption.map((output) => output.assetFileNames);
|
|
61599
|
+
if (assetFileNamesList.length > 1) {
|
|
61600
|
+
const firstAssetFileNames = assetFileNamesList[0];
|
|
61601
|
+
const hasDifferentReference = assetFileNamesList.some((assetFileNames) => assetFileNames !== firstAssetFileNames);
|
|
61602
|
+
if (hasDifferentReference) {
|
|
61603
|
+
resolved.logger.warn(colors$1.yellow(`
|
|
61604
|
+
assetFileNames isn't equal for every build.rollupOptions.output. A single pattern across all outputs is supported by Vite.
|
|
61605
|
+
`));
|
|
61606
|
+
}
|
|
61607
|
+
}
|
|
61608
|
+
}
|
|
61012
61609
|
return resolved;
|
|
61013
61610
|
}
|
|
61014
61611
|
/**
|
|
61015
|
-
* Resolve base. Note that some users use Vite to build for non-web targets like
|
|
61612
|
+
* Resolve base url. Note that some users use Vite to build for non-web targets like
|
|
61016
61613
|
* electron or expects to deploy
|
|
61017
61614
|
*/
|
|
61018
|
-
function resolveBaseUrl(base = '/', isBuild, logger) {
|
|
61019
|
-
// #1669 special treatment for empty for same dir relative base
|
|
61020
|
-
if (base === '' || base === './') {
|
|
61021
|
-
return isBuild ? base : '/';
|
|
61022
|
-
}
|
|
61615
|
+
function resolveBaseUrl(base = '/', isBuild, logger, optionName) {
|
|
61023
61616
|
if (base.startsWith('.')) {
|
|
61024
|
-
logger.warn(colors$1.yellow(colors$1.bold(`(!) invalid "
|
|
61617
|
+
logger.warn(colors$1.yellow(colors$1.bold(`(!) invalid "${optionName}" option: ${base}. The value can only be an absolute ` +
|
|
61025
61618
|
`URL, ./, or an empty string.`)));
|
|
61026
61619
|
base = '/';
|
|
61027
61620
|
}
|
|
@@ -61036,13 +61629,13 @@ function resolveBaseUrl(base = '/', isBuild, logger) {
|
|
|
61036
61629
|
else {
|
|
61037
61630
|
// ensure leading slash
|
|
61038
61631
|
if (!base.startsWith('/')) {
|
|
61039
|
-
logger.warn(colors$1.yellow(colors$1.bold(`(!) "
|
|
61632
|
+
logger.warn(colors$1.yellow(colors$1.bold(`(!) "${optionName}" option should start with a slash.`)));
|
|
61040
61633
|
base = '/' + base;
|
|
61041
61634
|
}
|
|
61042
61635
|
}
|
|
61043
61636
|
// ensure ending slash
|
|
61044
61637
|
if (!base.endsWith('/')) {
|
|
61045
|
-
logger.warn(colors$1.yellow(colors$1.bold(`(!) "
|
|
61638
|
+
logger.warn(colors$1.yellow(colors$1.bold(`(!) "${optionName}" option should end with a slash.`)));
|
|
61046
61639
|
base += '/';
|
|
61047
61640
|
}
|
|
61048
61641
|
return base;
|
|
@@ -61080,7 +61673,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
61080
61673
|
catch (e) { }
|
|
61081
61674
|
if (configFile) {
|
|
61082
61675
|
// explicit config path is always resolved from cwd
|
|
61083
|
-
resolvedPath = path$
|
|
61676
|
+
resolvedPath = path$q.resolve(configFile);
|
|
61084
61677
|
isTS = configFile.endsWith('.ts');
|
|
61085
61678
|
if (configFile.endsWith('.mjs')) {
|
|
61086
61679
|
isESM = true;
|
|
@@ -61089,27 +61682,27 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
61089
61682
|
else {
|
|
61090
61683
|
// implicit config file loaded from inline root (if present)
|
|
61091
61684
|
// otherwise from cwd
|
|
61092
|
-
const jsconfigFile = path$
|
|
61093
|
-
if (
|
|
61685
|
+
const jsconfigFile = path$q.resolve(configRoot, 'vite.config.js');
|
|
61686
|
+
if (fs$n.existsSync(jsconfigFile)) {
|
|
61094
61687
|
resolvedPath = jsconfigFile;
|
|
61095
61688
|
}
|
|
61096
61689
|
if (!resolvedPath) {
|
|
61097
|
-
const mjsconfigFile = path$
|
|
61098
|
-
if (
|
|
61690
|
+
const mjsconfigFile = path$q.resolve(configRoot, 'vite.config.mjs');
|
|
61691
|
+
if (fs$n.existsSync(mjsconfigFile)) {
|
|
61099
61692
|
resolvedPath = mjsconfigFile;
|
|
61100
61693
|
isESM = true;
|
|
61101
61694
|
}
|
|
61102
61695
|
}
|
|
61103
61696
|
if (!resolvedPath) {
|
|
61104
|
-
const tsconfigFile = path$
|
|
61105
|
-
if (
|
|
61697
|
+
const tsconfigFile = path$q.resolve(configRoot, 'vite.config.ts');
|
|
61698
|
+
if (fs$n.existsSync(tsconfigFile)) {
|
|
61106
61699
|
resolvedPath = tsconfigFile;
|
|
61107
61700
|
isTS = true;
|
|
61108
61701
|
}
|
|
61109
61702
|
}
|
|
61110
61703
|
if (!resolvedPath) {
|
|
61111
|
-
const cjsConfigFile = path$
|
|
61112
|
-
if (
|
|
61704
|
+
const cjsConfigFile = path$q.resolve(configRoot, 'vite.config.cjs');
|
|
61705
|
+
if (fs$n.existsSync(cjsConfigFile)) {
|
|
61113
61706
|
resolvedPath = cjsConfigFile;
|
|
61114
61707
|
isESM = false;
|
|
61115
61708
|
}
|
|
@@ -61130,10 +61723,10 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
61130
61723
|
// with --experimental-loader themselves, we have to do a hack here:
|
|
61131
61724
|
// bundle the config file w/ ts transforms first, write it to disk,
|
|
61132
61725
|
// load it with native Node ESM, then delete the file.
|
|
61133
|
-
|
|
61726
|
+
fs$n.writeFileSync(resolvedPath + '.js', bundled.code);
|
|
61134
61727
|
userConfig = (await dynamicImport(`${fileUrl}.js?t=${Date.now()}`))
|
|
61135
61728
|
.default;
|
|
61136
|
-
|
|
61729
|
+
fs$n.unlinkSync(resolvedPath + '.js');
|
|
61137
61730
|
debug(`TS + native esm config loaded in ${getTime()}`, fileUrl);
|
|
61138
61731
|
}
|
|
61139
61732
|
else {
|
|
@@ -61189,7 +61782,7 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
61189
61782
|
setup(build) {
|
|
61190
61783
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
61191
61784
|
const id = args.path;
|
|
61192
|
-
if (id[0] !== '.' && !path$
|
|
61785
|
+
if (id[0] !== '.' && !path$q.isAbsolute(id)) {
|
|
61193
61786
|
return {
|
|
61194
61787
|
external: true
|
|
61195
61788
|
};
|
|
@@ -61201,8 +61794,8 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
61201
61794
|
name: 'inject-file-scope-variables',
|
|
61202
61795
|
setup(build) {
|
|
61203
61796
|
build.onLoad({ filter: /\.[jt]s$/ }, async (args) => {
|
|
61204
|
-
const contents = await
|
|
61205
|
-
const injectValues = `const __dirname = ${JSON.stringify(path$
|
|
61797
|
+
const contents = await fs$n.promises.readFile(args.path, 'utf8');
|
|
61798
|
+
const injectValues = `const __dirname = ${JSON.stringify(path$q.dirname(args.path))};` +
|
|
61206
61799
|
`const __filename = ${JSON.stringify(args.path)};` +
|
|
61207
61800
|
`const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};`;
|
|
61208
61801
|
return {
|
|
@@ -61222,7 +61815,7 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
61222
61815
|
}
|
|
61223
61816
|
const _require = createRequire$1(import.meta.url);
|
|
61224
61817
|
async function loadConfigFromBundledFile(fileName, bundledCode) {
|
|
61225
|
-
const realFileName =
|
|
61818
|
+
const realFileName = fs$n.realpathSync(fileName);
|
|
61226
61819
|
const defaultLoader = _require.extensions['.js'];
|
|
61227
61820
|
_require.extensions['.js'] = (module, filename) => {
|
|
61228
61821
|
if (filename === realFileName) {
|
|
@@ -61246,4 +61839,4 @@ function isDepsOptimizerEnabled(config) {
|
|
|
61246
61839
|
(command === 'serve' && optimizeDeps.disabled === 'dev'));
|
|
61247
61840
|
}
|
|
61248
61841
|
|
|
61249
|
-
export { index$1 as
|
|
61842
|
+
export { getDefaultExportFromCjs as A, index$1 as B, build$1 as C, index as D, preview$1 as E, resolvePackageData as a, build as b, createServer as c, defineConfig as d, resolveConfig as e, formatPostcssSourceMap as f, resolveBaseUrl as g, mergeAlias as h, isDepsOptimizerEnabled as i, createFilter as j, send as k, loadConfigFromFile as l, mergeConfig as m, normalizePath$3 as n, optimizeDeps as o, preview as p, createLogger as q, resolvePackageEntry as r, sortUserPlugins as s, transformWithEsbuild as t, searchForWorkspaceRoot as u, loadEnv as v, resolveEnvPrefix as w, colors$1 as x, commonjsGlobal as y, getAugmentedNamespace as z };
|