vite 3.0.0-alpha.13 → 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-dab76395.js → dep-92497830.js} +4 -4
- package/dist/node/chunks/{dep-5d9a8c71.js → dep-dc88b587.js} +992 -542
- package/dist/node/chunks/{dep-0115731f.js → dep-e88a0dff.js} +7 -7
- package/dist/node/chunks/dep-e8ca8d40.js +3 -3
- package/dist/node/chunks/{dep-4cea16ce.js → dep-f75aea7c.js} +21 -9
- package/dist/node/cli.js +22 -10
- package/dist/node/constants.js +3 -3
- package/dist/node/index.d.ts +80 -23
- package/dist/node/index.js +20 -7
- package/dist/node-cjs/publicUtils.cjs +36 -25
- package/package.json +5 -4
- 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,33 +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
|
|
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';
|
|
19
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';
|
|
20
|
-
import require$$
|
|
26
|
+
import require$$1$2 from 'crypto';
|
|
27
|
+
import require$$0$7 from 'buffer';
|
|
21
28
|
import * as qs from 'querystring';
|
|
22
|
-
import
|
|
23
|
-
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';
|
|
24
32
|
import require$$4 from 'tls';
|
|
33
|
+
import { STATUS_CODES } from 'node:http';
|
|
34
|
+
import { createServer as createServer$2 } from 'node:https';
|
|
25
35
|
import require$$1$1 from 'worker_threads';
|
|
26
36
|
import readline from 'readline';
|
|
37
|
+
import { execSync } from 'node:child_process';
|
|
38
|
+
import zlib$1, { gzip } from 'node:zlib';
|
|
27
39
|
|
|
28
|
-
import { fileURLToPath as __cjs_fileURLToPath } from 'url';
|
|
29
|
-
import { dirname as __cjs_dirname } from 'path';
|
|
30
|
-
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';
|
|
31
43
|
|
|
32
44
|
const __filename = __cjs_fileURLToPath(import.meta.url);
|
|
33
45
|
const __dirname = __cjs_dirname(__filename);
|
|
@@ -56,7 +68,7 @@ function getAugmentedNamespace(n) {
|
|
|
56
68
|
|
|
57
69
|
var picocolors = {exports: {}};
|
|
58
70
|
|
|
59
|
-
let tty = require$$0$
|
|
71
|
+
let tty = require$$0$3;
|
|
60
72
|
|
|
61
73
|
let isColorSupported =
|
|
62
74
|
!("NO_COLOR" in process.env || process.argv.includes("--no-color")) &&
|
|
@@ -2647,8 +2659,8 @@ var old$1 = {};
|
|
|
2647
2659
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
2648
2660
|
|
|
2649
2661
|
var pathModule = path$p;
|
|
2650
|
-
var isWindows$
|
|
2651
|
-
var fs$m =
|
|
2662
|
+
var isWindows$5 = process.platform === 'win32';
|
|
2663
|
+
var fs$m = require$$0__default;
|
|
2652
2664
|
|
|
2653
2665
|
// JavaScript implementation of realpath, ported from node pre-v6
|
|
2654
2666
|
|
|
@@ -2695,14 +2707,14 @@ function maybeCallback(cb) {
|
|
|
2695
2707
|
|
|
2696
2708
|
// Regexp that finds the next partion of a (partial) path
|
|
2697
2709
|
// result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
|
|
2698
|
-
if (isWindows$
|
|
2710
|
+
if (isWindows$5) {
|
|
2699
2711
|
var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
|
|
2700
2712
|
} else {
|
|
2701
2713
|
var nextPartRe = /(.*?)(?:[\/]+|$)/g;
|
|
2702
2714
|
}
|
|
2703
2715
|
|
|
2704
2716
|
// Regex to find the device root, including trailing slash. E.g. 'c:\\'.
|
|
2705
|
-
if (isWindows$
|
|
2717
|
+
if (isWindows$5) {
|
|
2706
2718
|
var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
|
|
2707
2719
|
} else {
|
|
2708
2720
|
var splitRootRe = /^[\/]*/;
|
|
@@ -2740,7 +2752,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
|
2740
2752
|
previous = '';
|
|
2741
2753
|
|
|
2742
2754
|
// On windows, check that the root exists. On unix there is no need.
|
|
2743
|
-
if (isWindows$
|
|
2755
|
+
if (isWindows$5 && !knownHard[base]) {
|
|
2744
2756
|
fs$m.lstatSync(base);
|
|
2745
2757
|
knownHard[base] = true;
|
|
2746
2758
|
}
|
|
@@ -2778,7 +2790,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
|
2778
2790
|
// read the link if it wasn't read before
|
|
2779
2791
|
// dev/ino always return 0 on windows, so skip the check.
|
|
2780
2792
|
var linkTarget = null;
|
|
2781
|
-
if (!isWindows$
|
|
2793
|
+
if (!isWindows$5) {
|
|
2782
2794
|
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
|
2783
2795
|
if (seenLinks.hasOwnProperty(id)) {
|
|
2784
2796
|
linkTarget = seenLinks[id];
|
|
@@ -2791,7 +2803,7 @@ old$1.realpathSync = function realpathSync(p, cache) {
|
|
|
2791
2803
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
|
2792
2804
|
// track this, if given a cache.
|
|
2793
2805
|
if (cache) cache[base] = resolvedLink;
|
|
2794
|
-
if (!isWindows$
|
|
2806
|
+
if (!isWindows$5) seenLinks[id] = linkTarget;
|
|
2795
2807
|
}
|
|
2796
2808
|
|
|
2797
2809
|
// resolve the link, then start over
|
|
@@ -2842,7 +2854,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
|
2842
2854
|
previous = '';
|
|
2843
2855
|
|
|
2844
2856
|
// On windows, check that the root exists. On unix there is no need.
|
|
2845
|
-
if (isWindows$
|
|
2857
|
+
if (isWindows$5 && !knownHard[base]) {
|
|
2846
2858
|
fs$m.lstat(base, function(err) {
|
|
2847
2859
|
if (err) return cb(err);
|
|
2848
2860
|
knownHard[base] = true;
|
|
@@ -2896,7 +2908,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
|
2896
2908
|
// stat & read the link if not read before
|
|
2897
2909
|
// call gotTarget as soon as the link target is known
|
|
2898
2910
|
// dev/ino always return 0 on windows, so skip the check.
|
|
2899
|
-
if (!isWindows$
|
|
2911
|
+
if (!isWindows$5) {
|
|
2900
2912
|
var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
|
|
2901
2913
|
if (seenLinks.hasOwnProperty(id)) {
|
|
2902
2914
|
return gotTarget(null, seenLinks[id], base);
|
|
@@ -2906,7 +2918,7 @@ old$1.realpath = function realpath(p, cache, cb) {
|
|
|
2906
2918
|
if (err) return cb(err);
|
|
2907
2919
|
|
|
2908
2920
|
fs$m.readlink(base, function(err, target) {
|
|
2909
|
-
if (!isWindows$
|
|
2921
|
+
if (!isWindows$5) seenLinks[id] = target;
|
|
2910
2922
|
gotTarget(err, target);
|
|
2911
2923
|
});
|
|
2912
2924
|
});
|
|
@@ -2934,7 +2946,7 @@ realpath$2.realpathSync = realpathSync;
|
|
|
2934
2946
|
realpath$2.monkeypatch = monkeypatch;
|
|
2935
2947
|
realpath$2.unmonkeypatch = unmonkeypatch;
|
|
2936
2948
|
|
|
2937
|
-
var fs$l =
|
|
2949
|
+
var fs$l = require$$0__default;
|
|
2938
2950
|
var origRealpath = fs$l.realpath;
|
|
2939
2951
|
var origRealpathSync = fs$l.realpathSync;
|
|
2940
2952
|
|
|
@@ -4291,7 +4303,7 @@ function ownProp$2 (obj, field) {
|
|
|
4291
4303
|
return Object.prototype.hasOwnProperty.call(obj, field)
|
|
4292
4304
|
}
|
|
4293
4305
|
|
|
4294
|
-
var fs$k =
|
|
4306
|
+
var fs$k = require$$0__default;
|
|
4295
4307
|
var path$k = path$p;
|
|
4296
4308
|
var minimatch$2 = minimatch_1;
|
|
4297
4309
|
var isAbsolute$2 = pathIsAbsolute.exports;
|
|
@@ -4522,7 +4534,7 @@ globSync$1.GlobSync = GlobSync$1;
|
|
|
4522
4534
|
var rp$1 = fs_realpath;
|
|
4523
4535
|
var minimatch$1 = minimatch_1;
|
|
4524
4536
|
var path$j = path$p;
|
|
4525
|
-
var assert$2 =
|
|
4537
|
+
var assert$2 = assert$3;
|
|
4526
4538
|
var isAbsolute$1 = pathIsAbsolute.exports;
|
|
4527
4539
|
var common$d = common$e;
|
|
4528
4540
|
var setopts$1 = common$d.setopts;
|
|
@@ -5172,9 +5184,9 @@ var glob_1 = glob;
|
|
|
5172
5184
|
var rp = fs_realpath;
|
|
5173
5185
|
var minimatch = minimatch_1;
|
|
5174
5186
|
var inherits = inherits$1.exports;
|
|
5175
|
-
var EE = require$$0$
|
|
5187
|
+
var EE = require$$0$4.EventEmitter;
|
|
5176
5188
|
var path$i = path$p;
|
|
5177
|
-
var assert$1 =
|
|
5189
|
+
var assert$1 = assert$3;
|
|
5178
5190
|
var isAbsolute = pathIsAbsolute.exports;
|
|
5179
5191
|
var globSync = sync$c;
|
|
5180
5192
|
var common$c = common$e;
|
|
@@ -10784,8 +10796,8 @@ var node$1 = {exports: {}};
|
|
|
10784
10796
|
*/
|
|
10785
10797
|
|
|
10786
10798
|
(function (module, exports) {
|
|
10787
|
-
const tty = require$$0$
|
|
10788
|
-
const util = require$$0$
|
|
10799
|
+
const tty = require$$0$3;
|
|
10800
|
+
const util = require$$0$5;
|
|
10789
10801
|
|
|
10790
10802
|
/**
|
|
10791
10803
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -11311,17 +11323,17 @@ function testCaseInsensitiveFS() {
|
|
|
11311
11323
|
if (!CLIENT_ENTRY.endsWith('client.mjs')) {
|
|
11312
11324
|
throw new Error(`cannot test case insensitive FS, CLIENT_ENTRY const doesn't contain client.mjs`);
|
|
11313
11325
|
}
|
|
11314
|
-
if (!
|
|
11326
|
+
if (!fs$n.existsSync(CLIENT_ENTRY)) {
|
|
11315
11327
|
throw new Error('cannot test case insensitive FS, CLIENT_ENTRY does not point to an existing file: ' +
|
|
11316
11328
|
CLIENT_ENTRY);
|
|
11317
11329
|
}
|
|
11318
|
-
return
|
|
11330
|
+
return fs$n.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs'));
|
|
11319
11331
|
}
|
|
11320
11332
|
const isCaseInsensitiveFS = testCaseInsensitiveFS();
|
|
11321
|
-
const isWindows$
|
|
11333
|
+
const isWindows$4 = os$3.platform() === 'win32';
|
|
11322
11334
|
const VOLUME_RE = /^[A-Z]:/i;
|
|
11323
11335
|
function normalizePath$3(id) {
|
|
11324
|
-
return path$
|
|
11336
|
+
return path$q.posix.normalize(isWindows$4 ? slash$1(id) : id);
|
|
11325
11337
|
}
|
|
11326
11338
|
function fsPathFromId(id) {
|
|
11327
11339
|
const fsPath = normalizePath$3(id.startsWith(FS_PREFIX) ? id.slice(FS_PREFIX.length) : id);
|
|
@@ -11349,7 +11361,7 @@ function isParentDirectory(dir, file) {
|
|
|
11349
11361
|
(isCaseInsensitiveFS && file.toLowerCase().startsWith(dir.toLowerCase())));
|
|
11350
11362
|
}
|
|
11351
11363
|
function ensureVolumeInPath(file) {
|
|
11352
|
-
return isWindows$
|
|
11364
|
+
return isWindows$4 ? path$q.resolve(file) : file;
|
|
11353
11365
|
}
|
|
11354
11366
|
const queryRE = /\?.*$/s;
|
|
11355
11367
|
const hashRE = /#.*$/s;
|
|
@@ -11366,7 +11378,7 @@ const isJSRequest = (url) => {
|
|
|
11366
11378
|
if (knownJsSrcRE.test(url)) {
|
|
11367
11379
|
return true;
|
|
11368
11380
|
}
|
|
11369
|
-
if (!path$
|
|
11381
|
+
if (!path$q.extname(url) && !url.endsWith('/')) {
|
|
11370
11382
|
return true;
|
|
11371
11383
|
}
|
|
11372
11384
|
return false;
|
|
@@ -11415,9 +11427,6 @@ const timestampRE = /\bt=\d{13}&?\b/;
|
|
|
11415
11427
|
function removeTimestampQuery(url) {
|
|
11416
11428
|
return url.replace(timestampRE, '').replace(trailingSeparatorRE, '');
|
|
11417
11429
|
}
|
|
11418
|
-
function isRelativeBase(base) {
|
|
11419
|
-
return base === '' || base.startsWith('.');
|
|
11420
|
-
}
|
|
11421
11430
|
async function asyncReplace(input, re, replacer) {
|
|
11422
11431
|
let match;
|
|
11423
11432
|
let remaining = input;
|
|
@@ -11450,7 +11459,7 @@ function prettifyUrl(url, root) {
|
|
|
11450
11459
|
url = removeTimestampQuery(url);
|
|
11451
11460
|
const isAbsoluteFile = url.startsWith(root);
|
|
11452
11461
|
if (isAbsoluteFile || url.startsWith(FS_PREFIX)) {
|
|
11453
|
-
let file = path$
|
|
11462
|
+
let file = path$q.relative(root, isAbsoluteFile ? url : fsPathFromId(url));
|
|
11454
11463
|
const seg = file.split('/');
|
|
11455
11464
|
const npmIndex = seg.indexOf(`node_modules`);
|
|
11456
11465
|
const isSourceMap = file.endsWith('.map');
|
|
@@ -11475,12 +11484,12 @@ function isDefined(value) {
|
|
|
11475
11484
|
}
|
|
11476
11485
|
function lookupFile(dir, formats, options) {
|
|
11477
11486
|
for (const format of formats) {
|
|
11478
|
-
const fullPath = path$
|
|
11479
|
-
if (
|
|
11480
|
-
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');
|
|
11481
11490
|
}
|
|
11482
11491
|
}
|
|
11483
|
-
const parentDir = path$
|
|
11492
|
+
const parentDir = path$q.dirname(dir);
|
|
11484
11493
|
if (parentDir !== dir &&
|
|
11485
11494
|
(!options?.rootDir || parentDir.startsWith(options?.rootDir))) {
|
|
11486
11495
|
return lookupFile(parentDir, formats, options);
|
|
@@ -11560,11 +11569,11 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
11560
11569
|
return res.join('\n');
|
|
11561
11570
|
}
|
|
11562
11571
|
function writeFile(filename, content) {
|
|
11563
|
-
const dir = path$
|
|
11564
|
-
if (!
|
|
11565
|
-
|
|
11572
|
+
const dir = path$q.dirname(filename);
|
|
11573
|
+
if (!fs$n.existsSync(dir)) {
|
|
11574
|
+
fs$n.mkdirSync(dir, { recursive: true });
|
|
11566
11575
|
}
|
|
11567
|
-
|
|
11576
|
+
fs$n.writeFileSync(filename, content);
|
|
11568
11577
|
}
|
|
11569
11578
|
/**
|
|
11570
11579
|
* Use fs.statSync(filename) instead of fs.existsSync(filename)
|
|
@@ -11574,7 +11583,7 @@ function writeFile(filename, content) {
|
|
|
11574
11583
|
*/
|
|
11575
11584
|
function isFileReadable(filename) {
|
|
11576
11585
|
try {
|
|
11577
|
-
const stat =
|
|
11586
|
+
const stat = fs$n.statSync(filename, { throwIfNoEntry: false });
|
|
11578
11587
|
return !!stat;
|
|
11579
11588
|
}
|
|
11580
11589
|
catch {
|
|
@@ -11586,45 +11595,45 @@ function isFileReadable(filename) {
|
|
|
11586
11595
|
* Pass an optional `skip` array to preserve files in the root directory.
|
|
11587
11596
|
*/
|
|
11588
11597
|
function emptyDir(dir, skip) {
|
|
11589
|
-
for (const file of
|
|
11598
|
+
for (const file of fs$n.readdirSync(dir)) {
|
|
11590
11599
|
if (skip?.includes(file)) {
|
|
11591
11600
|
continue;
|
|
11592
11601
|
}
|
|
11593
|
-
|
|
11602
|
+
fs$n.rmSync(path$q.resolve(dir, file), { recursive: true, force: true });
|
|
11594
11603
|
}
|
|
11595
11604
|
}
|
|
11596
11605
|
function copyDir(srcDir, destDir) {
|
|
11597
|
-
|
|
11598
|
-
for (const file of
|
|
11599
|
-
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);
|
|
11600
11609
|
if (srcFile === destDir) {
|
|
11601
11610
|
continue;
|
|
11602
11611
|
}
|
|
11603
|
-
const destFile = path$
|
|
11604
|
-
const stat =
|
|
11612
|
+
const destFile = path$q.resolve(destDir, file);
|
|
11613
|
+
const stat = fs$n.statSync(srcFile);
|
|
11605
11614
|
if (stat.isDirectory()) {
|
|
11606
11615
|
copyDir(srcFile, destFile);
|
|
11607
11616
|
}
|
|
11608
11617
|
else {
|
|
11609
|
-
|
|
11618
|
+
fs$n.copyFileSync(srcFile, destFile);
|
|
11610
11619
|
}
|
|
11611
11620
|
}
|
|
11612
11621
|
}
|
|
11613
|
-
const removeDir = isWindows$
|
|
11622
|
+
const removeDir = isWindows$4
|
|
11614
11623
|
? promisify$4(gracefulRemoveDir)
|
|
11615
11624
|
: function removeDirSync(dir) {
|
|
11616
|
-
|
|
11625
|
+
fs$n.rmSync(dir, { recursive: true, force: true });
|
|
11617
11626
|
};
|
|
11618
|
-
const renameDir = isWindows$
|
|
11627
|
+
const renameDir = isWindows$4 ? promisify$4(gracefulRename) : fs$n.renameSync;
|
|
11619
11628
|
function ensureWatchedFile(watcher, file, root) {
|
|
11620
11629
|
if (file &&
|
|
11621
11630
|
// only need to watch if out of root
|
|
11622
11631
|
!file.startsWith(root + '/') &&
|
|
11623
11632
|
// some rollup plugins use null bytes for private resolved Ids
|
|
11624
11633
|
!file.includes('\0') &&
|
|
11625
|
-
|
|
11634
|
+
fs$n.existsSync(file)) {
|
|
11626
11635
|
// resolve file to normalized system path
|
|
11627
|
-
watcher.add(path$
|
|
11636
|
+
watcher.add(path$q.resolve(file));
|
|
11628
11637
|
}
|
|
11629
11638
|
}
|
|
11630
11639
|
const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
|
|
@@ -11743,7 +11752,23 @@ function combineSourcemaps(filename, sourcemapList, excludeContent = true) {
|
|
|
11743
11752
|
function unique(arr) {
|
|
11744
11753
|
return Array.from(new Set(arr));
|
|
11745
11754
|
}
|
|
11746
|
-
|
|
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) {
|
|
11747
11772
|
let host;
|
|
11748
11773
|
if (optionsHost === undefined || optionsHost === false) {
|
|
11749
11774
|
// Use a secure default
|
|
@@ -11757,8 +11782,15 @@ function resolveHostname(optionsHost) {
|
|
|
11757
11782
|
host = optionsHost;
|
|
11758
11783
|
}
|
|
11759
11784
|
// Set host name to localhost when possible
|
|
11760
|
-
|
|
11761
|
-
|
|
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 };
|
|
11762
11794
|
}
|
|
11763
11795
|
function arraify(target) {
|
|
11764
11796
|
return Array.isArray(target) ? target : [target];
|
|
@@ -11766,8 +11798,8 @@ function arraify(target) {
|
|
|
11766
11798
|
function toUpperCaseDriveLetter(pathName) {
|
|
11767
11799
|
return pathName.replace(/^\w:/, (letter) => letter.toUpperCase());
|
|
11768
11800
|
}
|
|
11769
|
-
const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
|
|
11770
|
-
const singlelineCommentsRE = /\/\/.*/g;
|
|
11801
|
+
const multilineCommentsRE$1 = /\/\*(.|[\r\n])*?\*\//gm;
|
|
11802
|
+
const singlelineCommentsRE$1 = /\/\/.*/g;
|
|
11771
11803
|
const requestQuerySplitRE = /\?(?!.*[\/|\}])/;
|
|
11772
11804
|
// @ts-expect-error
|
|
11773
11805
|
const usingDynamicImport = typeof jest === 'undefined';
|
|
@@ -11814,14 +11846,14 @@ const GRACEFUL_RENAME_TIMEOUT = 5000;
|
|
|
11814
11846
|
function gracefulRename(from, to, cb) {
|
|
11815
11847
|
const start = Date.now();
|
|
11816
11848
|
let backoff = 0;
|
|
11817
|
-
|
|
11849
|
+
fs$n.rename(from, to, function CB(er) {
|
|
11818
11850
|
if (er &&
|
|
11819
11851
|
(er.code === 'EACCES' || er.code === 'EPERM') &&
|
|
11820
11852
|
Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
|
|
11821
11853
|
setTimeout(function () {
|
|
11822
|
-
|
|
11854
|
+
fs$n.stat(to, function (stater, st) {
|
|
11823
11855
|
if (stater && stater.code === 'ENOENT')
|
|
11824
|
-
|
|
11856
|
+
fs$n.rename(from, to, CB);
|
|
11825
11857
|
else
|
|
11826
11858
|
CB(er);
|
|
11827
11859
|
});
|
|
@@ -11838,14 +11870,14 @@ const GRACEFUL_REMOVE_DIR_TIMEOUT = 5000;
|
|
|
11838
11870
|
function gracefulRemoveDir(dir, cb) {
|
|
11839
11871
|
const start = Date.now();
|
|
11840
11872
|
let backoff = 0;
|
|
11841
|
-
|
|
11873
|
+
fs$n.rm(dir, { recursive: true }, function CB(er) {
|
|
11842
11874
|
if (er) {
|
|
11843
11875
|
if ((er.code === 'ENOTEMPTY' ||
|
|
11844
11876
|
er.code === 'EACCES' ||
|
|
11845
11877
|
er.code === 'EPERM') &&
|
|
11846
11878
|
Date.now() - start < GRACEFUL_REMOVE_DIR_TIMEOUT) {
|
|
11847
11879
|
setTimeout(function () {
|
|
11848
|
-
|
|
11880
|
+
fs$n.rm(dir, { recursive: true }, CB);
|
|
11849
11881
|
}, backoff);
|
|
11850
11882
|
if (backoff < 100)
|
|
11851
11883
|
backoff += 10;
|
|
@@ -11860,7 +11892,7 @@ function gracefulRemoveDir(dir, cb) {
|
|
|
11860
11892
|
});
|
|
11861
11893
|
}
|
|
11862
11894
|
function emptyCssComments(raw) {
|
|
11863
|
-
return raw.replace(multilineCommentsRE, (s) => ' '.repeat(s.length));
|
|
11895
|
+
return raw.replace(multilineCommentsRE$1, (s) => ' '.repeat(s.length));
|
|
11864
11896
|
}
|
|
11865
11897
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
11866
11898
|
const merged = { ...defaults };
|
|
@@ -12062,13 +12094,14 @@ function createLogger(level = 'info', options = {}) {
|
|
|
12062
12094
|
};
|
|
12063
12095
|
return logger;
|
|
12064
12096
|
}
|
|
12065
|
-
function printCommonServerUrls(server, options, config) {
|
|
12097
|
+
async function printCommonServerUrls(server, options, config) {
|
|
12066
12098
|
const address = server.address();
|
|
12067
12099
|
const isAddressInfo = (x) => x?.address;
|
|
12068
12100
|
if (isAddressInfo(address)) {
|
|
12069
|
-
const hostname = resolveHostname(options.host);
|
|
12101
|
+
const hostname = await resolveHostname(options.host);
|
|
12070
12102
|
const protocol = options.https ? 'https' : 'http';
|
|
12071
|
-
|
|
12103
|
+
const base = config.base === './' || config.base === '' ? '/' : config.base;
|
|
12104
|
+
printServerUrls(hostname, protocol, address.port, base, config.logger.info);
|
|
12072
12105
|
}
|
|
12073
12106
|
}
|
|
12074
12107
|
function printServerUrls(hostname, protocol, port, base, info) {
|
|
@@ -12084,7 +12117,7 @@ function printServerUrls(hostname, protocol, port, base, info) {
|
|
|
12084
12117
|
label: 'Local',
|
|
12085
12118
|
url: colors$1.cyan(`${protocol}://${hostnameName}:${colors$1.bold(port)}${base}`)
|
|
12086
12119
|
});
|
|
12087
|
-
if (hostname.
|
|
12120
|
+
if (hostname.implicit) {
|
|
12088
12121
|
urls.push({
|
|
12089
12122
|
label: 'Network',
|
|
12090
12123
|
url: `use ${colors$1.white(colors$1.bold('--host'))} to expose`,
|
|
@@ -12093,7 +12126,7 @@ function printServerUrls(hostname, protocol, port, base, info) {
|
|
|
12093
12126
|
}
|
|
12094
12127
|
}
|
|
12095
12128
|
else {
|
|
12096
|
-
Object.values(
|
|
12129
|
+
Object.values(os$3.networkInterfaces())
|
|
12097
12130
|
.flatMap((nInterface) => nInterface ?? [])
|
|
12098
12131
|
.filter((detail) => detail &&
|
|
12099
12132
|
detail.address &&
|
|
@@ -12143,7 +12176,7 @@ function buildReporterPlugin(config) {
|
|
|
12143
12176
|
.length / 1024).toFixed(2)} KiB`;
|
|
12144
12177
|
}
|
|
12145
12178
|
function printFileInfo(filePath, content, type, maxLength, compressedSize = '') {
|
|
12146
|
-
const outDir = normalizePath$3(path$
|
|
12179
|
+
const outDir = normalizePath$3(path$q.relative(config.root, path$q.resolve(config.root, config.build.outDir))) + '/';
|
|
12147
12180
|
const kibs = content.length / 1024;
|
|
12148
12181
|
const sizeColor = kibs > chunkLimit ? colors$1.yellow : colors$1.dim;
|
|
12149
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}`)}`);
|
|
@@ -12155,7 +12188,7 @@ function buildReporterPlugin(config) {
|
|
|
12155
12188
|
let transformedCount = 0;
|
|
12156
12189
|
let chunkCount = 0;
|
|
12157
12190
|
const logTransform = throttle((id) => {
|
|
12158
|
-
writeLine(`transforming (${transformedCount}) ${colors$1.dim(path$
|
|
12191
|
+
writeLine(`transforming (${transformedCount}) ${colors$1.dim(path$q.relative(config.root, id))}`);
|
|
12159
12192
|
});
|
|
12160
12193
|
return {
|
|
12161
12194
|
name: 'vite:reporter',
|
|
@@ -12336,7 +12369,7 @@ async function tsconfigInDir(dir, options) {
|
|
|
12336
12369
|
return options.tsConfigPaths.has(tsconfig) ? tsconfig : void 0;
|
|
12337
12370
|
}
|
|
12338
12371
|
try {
|
|
12339
|
-
const stat = await promises.stat(tsconfig);
|
|
12372
|
+
const stat = await promises$1.stat(tsconfig);
|
|
12340
12373
|
if (stat.isFile() || stat.isFIFO()) {
|
|
12341
12374
|
return tsconfig;
|
|
12342
12375
|
}
|
|
@@ -12357,7 +12390,7 @@ async function* findTSConfig(dir, options, visited = /* @__PURE__ */ new Set())
|
|
|
12357
12390
|
if (!visited.has(dir)) {
|
|
12358
12391
|
visited.add(dir);
|
|
12359
12392
|
try {
|
|
12360
|
-
const dirents = await promises.readdir(dir, { withFileTypes: true });
|
|
12393
|
+
const dirents = await promises$1.readdir(dir, { withFileTypes: true });
|
|
12361
12394
|
for (const dirent of dirents) {
|
|
12362
12395
|
if (dirent.isDirectory() && (!(options == null ? void 0 : options.skip) || !options.skip(dirent.name))) {
|
|
12363
12396
|
yield* findTSConfig(path$p.resolve(dir, dirent.name), options, visited);
|
|
@@ -12494,7 +12527,7 @@ async function resolveTSConfig(filename) {
|
|
|
12494
12527
|
}
|
|
12495
12528
|
const tsconfig = path$p.resolve(filename);
|
|
12496
12529
|
try {
|
|
12497
|
-
const stat = await promises.stat(tsconfig);
|
|
12530
|
+
const stat = await promises$1.stat(tsconfig);
|
|
12498
12531
|
if (stat.isFile() || stat.isFIFO()) {
|
|
12499
12532
|
return tsconfig;
|
|
12500
12533
|
}
|
|
@@ -12659,7 +12692,7 @@ async function parseFile$1(tsconfigFile, cache) {
|
|
|
12659
12692
|
return cache.get(tsconfigFile);
|
|
12660
12693
|
}
|
|
12661
12694
|
try {
|
|
12662
|
-
const tsconfigJson = await promises.readFile(tsconfigFile, "utf-8");
|
|
12695
|
+
const tsconfigJson = await promises$1.readFile(tsconfigFile, "utf-8");
|
|
12663
12696
|
const json = toJson(tsconfigJson);
|
|
12664
12697
|
const result = {
|
|
12665
12698
|
tsconfigFile,
|
|
@@ -12711,14 +12744,14 @@ async function parseExtends(result, cache) {
|
|
|
12711
12744
|
function resolveExtends(extended, from) {
|
|
12712
12745
|
let error;
|
|
12713
12746
|
try {
|
|
12714
|
-
return createRequire$
|
|
12747
|
+
return createRequire$2(from).resolve(extended);
|
|
12715
12748
|
} catch (e) {
|
|
12716
12749
|
error = e;
|
|
12717
12750
|
}
|
|
12718
12751
|
if (!path$p.isAbsolute(extended) && !extended.startsWith("./") && !extended.startsWith("../")) {
|
|
12719
12752
|
try {
|
|
12720
12753
|
const fallbackExtended = path$p.join(extended, "tsconfig.json");
|
|
12721
|
-
return createRequire$
|
|
12754
|
+
return createRequire$2(from).resolve(fallbackExtended);
|
|
12722
12755
|
} catch (e) {
|
|
12723
12756
|
error = e;
|
|
12724
12757
|
}
|
|
@@ -12813,7 +12846,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
|
|
|
12813
12846
|
if (!loader) {
|
|
12814
12847
|
// if the id ends with a valid ext, use it (e.g. vue blocks)
|
|
12815
12848
|
// otherwise, cleanup the query before checking the ext
|
|
12816
|
-
const ext = path$
|
|
12849
|
+
const ext = path$q
|
|
12817
12850
|
.extname(/\.\w+$/.test(filename) ? filename : cleanUrl(filename))
|
|
12818
12851
|
.slice(1);
|
|
12819
12852
|
if (ext === 'cjs' || ext === 'mjs') {
|
|
@@ -13055,7 +13088,7 @@ async function loadTsconfigJsonForFile(filename) {
|
|
|
13055
13088
|
function reloadOnTsconfigChange(changedFile) {
|
|
13056
13089
|
// any tsconfig.json that's added in the workspace could be closer to a code file than a previously cached one
|
|
13057
13090
|
// any json file in the tsconfig cache could have been used to compile ts
|
|
13058
|
-
if (path$
|
|
13091
|
+
if (path$q.basename(changedFile) === 'tsconfig.json' ||
|
|
13059
13092
|
(changedFile.endsWith('.json') &&
|
|
13060
13093
|
tsconfckParseOptions?.cache?.has(changedFile))) {
|
|
13061
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 });
|
|
@@ -13243,16 +13276,16 @@ function manifestPlugin(config) {
|
|
|
13243
13276
|
generateBundle({ format }, bundle) {
|
|
13244
13277
|
function getChunkName(chunk) {
|
|
13245
13278
|
if (chunk.facadeModuleId) {
|
|
13246
|
-
let name = normalizePath$3(path$
|
|
13279
|
+
let name = normalizePath$3(path$q.relative(config.root, chunk.facadeModuleId));
|
|
13247
13280
|
if (format === 'system' && !chunk.name.includes('-legacy')) {
|
|
13248
|
-
const ext = path$
|
|
13281
|
+
const ext = path$q.extname(name);
|
|
13249
13282
|
const endPos = ext.length !== 0 ? -ext.length : undefined;
|
|
13250
13283
|
name = name.slice(0, endPos) + `-legacy` + ext;
|
|
13251
13284
|
}
|
|
13252
13285
|
return name.replace(/\0/g, '');
|
|
13253
13286
|
}
|
|
13254
13287
|
else {
|
|
13255
|
-
return `_` + path$
|
|
13288
|
+
return `_` + path$q.basename(chunk.fileName);
|
|
13256
13289
|
}
|
|
13257
13290
|
}
|
|
13258
13291
|
function getInternalImports(imports) {
|
|
@@ -14458,7 +14491,7 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
14458
14491
|
let sourceRoot;
|
|
14459
14492
|
try {
|
|
14460
14493
|
// The source root is undefined for virtual modules and permission errors.
|
|
14461
|
-
sourceRoot = await promises.realpath(path$
|
|
14494
|
+
sourceRoot = await promises$2.realpath(path$q.resolve(path$q.dirname(file), map.sourceRoot || ''));
|
|
14462
14495
|
}
|
|
14463
14496
|
catch { }
|
|
14464
14497
|
const missingSources = [];
|
|
@@ -14466,9 +14499,9 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
14466
14499
|
if (sourcePath && !virtualSourceRE.test(sourcePath)) {
|
|
14467
14500
|
sourcePath = decodeURI(sourcePath);
|
|
14468
14501
|
if (sourceRoot) {
|
|
14469
|
-
sourcePath = path$
|
|
14502
|
+
sourcePath = path$q.resolve(sourceRoot, sourcePath);
|
|
14470
14503
|
}
|
|
14471
|
-
return promises.readFile(sourcePath, 'utf-8').catch(() => {
|
|
14504
|
+
return promises$2.readFile(sourcePath, 'utf-8').catch(() => {
|
|
14472
14505
|
missingSources.push(sourcePath);
|
|
14473
14506
|
return null;
|
|
14474
14507
|
});
|
|
@@ -14620,7 +14653,7 @@ const debug$d = createDebugger('vite:resolve-details', {
|
|
|
14620
14653
|
});
|
|
14621
14654
|
function invalidatePackageData(packageCache, pkgPath) {
|
|
14622
14655
|
packageCache.delete(pkgPath);
|
|
14623
|
-
const pkgDir = path$
|
|
14656
|
+
const pkgDir = path$q.dirname(pkgPath);
|
|
14624
14657
|
packageCache.forEach((pkg, cacheKey) => {
|
|
14625
14658
|
if (pkg.dir === pkgDir) {
|
|
14626
14659
|
packageCache.delete(cacheKey);
|
|
@@ -14658,14 +14691,14 @@ function resolvePackageData(id, basedir, preserveSymlinks = false, packageCache)
|
|
|
14658
14691
|
}
|
|
14659
14692
|
function loadPackageData(pkgPath, preserveSymlinks, packageCache) {
|
|
14660
14693
|
if (!preserveSymlinks) {
|
|
14661
|
-
pkgPath =
|
|
14694
|
+
pkgPath = fs$n.realpathSync.native(pkgPath);
|
|
14662
14695
|
}
|
|
14663
14696
|
let cached;
|
|
14664
14697
|
if ((cached = packageCache?.get(pkgPath))) {
|
|
14665
14698
|
return cached;
|
|
14666
14699
|
}
|
|
14667
|
-
const data = JSON.parse(
|
|
14668
|
-
const pkgDir = path$
|
|
14700
|
+
const data = JSON.parse(fs$n.readFileSync(pkgPath, 'utf-8'));
|
|
14701
|
+
const pkgDir = path$q.dirname(pkgPath);
|
|
14669
14702
|
const { sideEffects } = data;
|
|
14670
14703
|
let hasSideEffects;
|
|
14671
14704
|
if (typeof sideEffects === 'boolean') {
|
|
@@ -14741,15 +14774,15 @@ const isDebug$4 = process.env.DEBUG;
|
|
|
14741
14774
|
const debug$c = createDebugger('vite:resolve-details', {
|
|
14742
14775
|
onlyWhenFocused: true
|
|
14743
14776
|
});
|
|
14744
|
-
function resolvePlugin(
|
|
14745
|
-
const { root, isProduction, asSrc, ssrConfig, preferRelative = false } =
|
|
14777
|
+
function resolvePlugin(resolveOptions) {
|
|
14778
|
+
const { root, isProduction, asSrc, ssrConfig, preferRelative = false } = resolveOptions;
|
|
14746
14779
|
const { target: ssrTarget, noExternal: ssrNoExternal } = ssrConfig ?? {};
|
|
14747
14780
|
return {
|
|
14748
14781
|
name: 'vite:resolve',
|
|
14749
14782
|
async resolveId(id, importer, resolveOpts) {
|
|
14750
14783
|
// We need to delay depsOptimizer until here instead of passing it as an option
|
|
14751
14784
|
// the resolvePlugin because the optimizer is created on server listen during dev
|
|
14752
|
-
const depsOptimizer =
|
|
14785
|
+
const depsOptimizer = resolveOptions.getDepsOptimizer?.();
|
|
14753
14786
|
const ssr = resolveOpts?.ssr === true;
|
|
14754
14787
|
if (id.startsWith(browserExternalId)) {
|
|
14755
14788
|
return id;
|
|
@@ -14763,8 +14796,8 @@ function resolvePlugin(baseOptions) {
|
|
|
14763
14796
|
const isRequire = resolveOpts?.custom?.['node-resolve']?.isRequire ?? false;
|
|
14764
14797
|
const options = {
|
|
14765
14798
|
isRequire,
|
|
14766
|
-
...
|
|
14767
|
-
scan: resolveOpts?.scan ??
|
|
14799
|
+
...resolveOptions,
|
|
14800
|
+
scan: resolveOpts?.scan ?? resolveOptions.scan
|
|
14768
14801
|
};
|
|
14769
14802
|
if (importer) {
|
|
14770
14803
|
if (isTsRequest(importer)) {
|
|
@@ -14782,7 +14815,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14782
14815
|
if (asSrc && depsOptimizer?.isOptimizedDepUrl(id)) {
|
|
14783
14816
|
const optimizedPath = id.startsWith(FS_PREFIX)
|
|
14784
14817
|
? fsPathFromId(id)
|
|
14785
|
-
: normalizePath$3(ensureVolumeInPath(path$
|
|
14818
|
+
: normalizePath$3(ensureVolumeInPath(path$q.resolve(root, id.slice(1))));
|
|
14786
14819
|
return optimizedPath;
|
|
14787
14820
|
}
|
|
14788
14821
|
// explicit fs paths that starts with /@fs/*
|
|
@@ -14797,7 +14830,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14797
14830
|
// URL
|
|
14798
14831
|
// /foo -> /fs-root/foo
|
|
14799
14832
|
if (asSrc && id.startsWith('/')) {
|
|
14800
|
-
const fsPath = path$
|
|
14833
|
+
const fsPath = path$q.resolve(root, id.slice(1));
|
|
14801
14834
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
14802
14835
|
isDebug$4 && debug$c(`[url] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
14803
14836
|
return res;
|
|
@@ -14807,8 +14840,8 @@ function resolvePlugin(baseOptions) {
|
|
|
14807
14840
|
if (id.startsWith('.') ||
|
|
14808
14841
|
(preferRelative && /^\w/.test(id)) ||
|
|
14809
14842
|
importer?.endsWith('.html')) {
|
|
14810
|
-
const basedir = importer ? path$
|
|
14811
|
-
const fsPath = path$
|
|
14843
|
+
const basedir = importer ? path$q.dirname(importer) : process.cwd();
|
|
14844
|
+
const fsPath = path$q.resolve(basedir, id);
|
|
14812
14845
|
// handle browser field mapping for relative imports
|
|
14813
14846
|
const normalizedFsPath = normalizePath$3(fsPath);
|
|
14814
14847
|
if (depsOptimizer?.isOptimizedDepFile(normalizedFsPath)) {
|
|
@@ -14851,7 +14884,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14851
14884
|
}
|
|
14852
14885
|
}
|
|
14853
14886
|
// absolute fs paths
|
|
14854
|
-
if (path$
|
|
14887
|
+
if (path$q.isAbsolute(id) && (res = tryFsResolve(id, options))) {
|
|
14855
14888
|
isDebug$4 && debug$c(`[fs] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
14856
14889
|
return res;
|
|
14857
14890
|
}
|
|
@@ -14891,7 +14924,7 @@ function resolvePlugin(baseOptions) {
|
|
|
14891
14924
|
if (ssrNoExternal === true) {
|
|
14892
14925
|
let message = `Cannot bundle Node.js built-in "${id}"`;
|
|
14893
14926
|
if (importer) {
|
|
14894
|
-
message += ` imported from "${path$
|
|
14927
|
+
message += ` imported from "${path$q.relative(process.cwd(), importer)}"`;
|
|
14895
14928
|
}
|
|
14896
14929
|
message += `. Consider disabling ssr.noExternal or remove the built-in dependency.`;
|
|
14897
14930
|
this.error(message);
|
|
@@ -14978,7 +15011,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
14978
15011
|
// works and will result in massively slow subsequent checks (which are
|
|
14979
15012
|
// unnecessary in the first place)
|
|
14980
15013
|
if (isFileReadable(file)) {
|
|
14981
|
-
if (!
|
|
15014
|
+
if (!fs$n.statSync(file).isDirectory()) {
|
|
14982
15015
|
return getRealPath(file, options.preserveSymlinks) + postfix;
|
|
14983
15016
|
}
|
|
14984
15017
|
else if (tryIndex) {
|
|
@@ -15012,7 +15045,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
15012
15045
|
return;
|
|
15013
15046
|
}
|
|
15014
15047
|
if (tryPrefix) {
|
|
15015
|
-
const prefixed = `${path$
|
|
15048
|
+
const prefixed = `${path$q.dirname(file)}/${tryPrefix}${path$q.basename(file)}`;
|
|
15016
15049
|
return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb);
|
|
15017
15050
|
}
|
|
15018
15051
|
}
|
|
@@ -15040,7 +15073,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15040
15073
|
// first path part (since periods are sadly allowed in package names).
|
|
15041
15074
|
// At the same time, skip the first path part if it begins with "@"
|
|
15042
15075
|
// (since "@foo/bar" should be treated as the top-level path).
|
|
15043
|
-
if (possiblePkgIds.length ? path$
|
|
15076
|
+
if (possiblePkgIds.length ? path$q.extname(part) : part[0] === '@') {
|
|
15044
15077
|
continue;
|
|
15045
15078
|
}
|
|
15046
15079
|
const possiblePkgId = nestedPath.slice(0, slashIndex);
|
|
@@ -15051,9 +15084,9 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15051
15084
|
basedir = root;
|
|
15052
15085
|
}
|
|
15053
15086
|
else if (importer &&
|
|
15054
|
-
path$
|
|
15055
|
-
|
|
15056
|
-
basedir = path$
|
|
15087
|
+
path$q.isAbsolute(importer) &&
|
|
15088
|
+
fs$n.existsSync(cleanUrl(importer))) {
|
|
15089
|
+
basedir = path$q.dirname(importer);
|
|
15057
15090
|
}
|
|
15058
15091
|
else {
|
|
15059
15092
|
basedir = root;
|
|
@@ -15101,7 +15134,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15101
15134
|
if (!externalize) {
|
|
15102
15135
|
return resolved;
|
|
15103
15136
|
}
|
|
15104
|
-
const resolvedExt = path$
|
|
15137
|
+
const resolvedExt = path$q.extname(resolved.id);
|
|
15105
15138
|
let resolvedId = id;
|
|
15106
15139
|
if (isDeepImport) {
|
|
15107
15140
|
// check ext before externalizing - only externalize
|
|
@@ -15109,7 +15142,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr, ex
|
|
|
15109
15142
|
if (resolvedExt && !resolved.id.match(/(.js|.mjs|.cjs)$/)) {
|
|
15110
15143
|
return;
|
|
15111
15144
|
}
|
|
15112
|
-
if (!pkg?.data.exports && path$
|
|
15145
|
+
if (!pkg?.data.exports && path$q.extname(id) !== resolvedExt) {
|
|
15113
15146
|
resolvedId += resolvedExt;
|
|
15114
15147
|
}
|
|
15115
15148
|
}
|
|
@@ -15198,7 +15231,7 @@ async function tryOptimizedResolve(depsOptimizer, ssr, id, importer) {
|
|
|
15198
15231
|
if (resolvedSrc == null) {
|
|
15199
15232
|
try {
|
|
15200
15233
|
// this may throw errors if unable to resolve, e.g. aliased id
|
|
15201
|
-
resolvedSrc = normalizePath$3(resolveFrom(id, path$
|
|
15234
|
+
resolvedSrc = normalizePath$3(resolveFrom(id, path$q.dirname(importer)));
|
|
15202
15235
|
}
|
|
15203
15236
|
catch {
|
|
15204
15237
|
// this is best-effort only so swallow errors
|
|
@@ -15244,9 +15277,9 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
15244
15277
|
// the heuristics here is to actually read the browser entry when
|
|
15245
15278
|
// possible and check for hints of UMD. If it is UMD, prefer "module"
|
|
15246
15279
|
// instead; Otherwise, assume it's ESM and use it.
|
|
15247
|
-
const resolvedBrowserEntry = tryFsResolve(path$
|
|
15280
|
+
const resolvedBrowserEntry = tryFsResolve(path$q.join(dir, browserEntry), options);
|
|
15248
15281
|
if (resolvedBrowserEntry) {
|
|
15249
|
-
const content =
|
|
15282
|
+
const content = fs$n.readFileSync(resolvedBrowserEntry, 'utf-8');
|
|
15250
15283
|
if ((/typeof exports\s*==/.test(content) &&
|
|
15251
15284
|
/typeof module\s*==/.test(content)) ||
|
|
15252
15285
|
/module\.exports\s*=/.test(content)) {
|
|
@@ -15277,7 +15310,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
15277
15310
|
for (let entry of entryPoints) {
|
|
15278
15311
|
// make sure we don't get scripts when looking for sass
|
|
15279
15312
|
if (options.mainFields?.[0] === 'sass' &&
|
|
15280
|
-
!options.extensions?.includes(path$
|
|
15313
|
+
!options.extensions?.includes(path$q.extname(entry))) {
|
|
15281
15314
|
entry = '';
|
|
15282
15315
|
options.skipPackageJson = true;
|
|
15283
15316
|
}
|
|
@@ -15286,7 +15319,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
15286
15319
|
if (targetWeb && isObject$2(browserField)) {
|
|
15287
15320
|
entry = mapWithBrowserField(entry, browserField) || entry;
|
|
15288
15321
|
}
|
|
15289
|
-
const entryPointPath = path$
|
|
15322
|
+
const entryPointPath = path$q.join(dir, entry);
|
|
15290
15323
|
const resolvedEntryPoint = tryFsResolve(entryPointPath, options);
|
|
15291
15324
|
if (resolvedEntryPoint) {
|
|
15292
15325
|
isDebug$4 &&
|
|
@@ -15346,7 +15379,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
15346
15379
|
}
|
|
15347
15380
|
if (!relativeId) {
|
|
15348
15381
|
throw new Error(`Package subpath '${relativeId}' is not defined by "exports" in ` +
|
|
15349
|
-
`${path$
|
|
15382
|
+
`${path$q.join(dir, 'package.json')}.`);
|
|
15350
15383
|
}
|
|
15351
15384
|
}
|
|
15352
15385
|
else if (targetWeb && isObject$2(browserField)) {
|
|
@@ -15361,7 +15394,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
15361
15394
|
}
|
|
15362
15395
|
}
|
|
15363
15396
|
if (relativeId) {
|
|
15364
|
-
const resolved = tryFsResolve(path$
|
|
15397
|
+
const resolved = tryFsResolve(path$q.join(dir, relativeId), options, !exportsField, // try index only if no exports field
|
|
15365
15398
|
targetWeb);
|
|
15366
15399
|
if (resolved) {
|
|
15367
15400
|
isDebug$4 &&
|
|
@@ -15375,10 +15408,10 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
15375
15408
|
let res;
|
|
15376
15409
|
const pkg = importer && idToPkgMap.get(importer);
|
|
15377
15410
|
if (pkg && isObject$2(pkg.data.browser)) {
|
|
15378
|
-
const mapId = isFilePath ? './' + slash$1(path$
|
|
15411
|
+
const mapId = isFilePath ? './' + slash$1(path$q.relative(pkg.dir, id)) : id;
|
|
15379
15412
|
const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser);
|
|
15380
15413
|
if (browserMappedPath) {
|
|
15381
|
-
const fsPath = path$
|
|
15414
|
+
const fsPath = path$q.join(pkg.dir, browserMappedPath);
|
|
15382
15415
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
15383
15416
|
isDebug$4 &&
|
|
15384
15417
|
debug$c(`[browser mapped] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
@@ -15404,9 +15437,9 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
15404
15437
|
* - Returning `false` means this id is explicitly externalized for browser
|
|
15405
15438
|
*/
|
|
15406
15439
|
function mapWithBrowserField(relativePathInPkgDir, map) {
|
|
15407
|
-
const normalizedPath = path$
|
|
15440
|
+
const normalizedPath = path$q.posix.normalize(relativePathInPkgDir);
|
|
15408
15441
|
for (const key in map) {
|
|
15409
|
-
const normalizedKey = path$
|
|
15442
|
+
const normalizedKey = path$q.posix.normalize(key);
|
|
15410
15443
|
if (normalizedPath === normalizedKey ||
|
|
15411
15444
|
equalWithoutSuffix(normalizedPath, normalizedKey, '.js') ||
|
|
15412
15445
|
equalWithoutSuffix(normalizedPath, normalizedKey, '/index.js')) {
|
|
@@ -15420,7 +15453,7 @@ function equalWithoutSuffix(path, key, suffix) {
|
|
|
15420
15453
|
function getRealPath(resolved, preserveSymlinks) {
|
|
15421
15454
|
resolved = ensureVolumeInPath(resolved);
|
|
15422
15455
|
if (!preserveSymlinks && browserExternalId !== resolved) {
|
|
15423
|
-
resolved =
|
|
15456
|
+
resolved = fs$n.realpathSync(resolved);
|
|
15424
15457
|
}
|
|
15425
15458
|
return normalizePath$3(resolved);
|
|
15426
15459
|
}
|
|
@@ -15466,7 +15499,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15466
15499
|
// explicit resolveDir - this is passed only during yarn pnp resolve for
|
|
15467
15500
|
// entries
|
|
15468
15501
|
if (resolveDir) {
|
|
15469
|
-
_importer = normalizePath$3(path$
|
|
15502
|
+
_importer = normalizePath$3(path$q.join(resolveDir, '*'));
|
|
15470
15503
|
}
|
|
15471
15504
|
else {
|
|
15472
15505
|
// map importer ids to file paths for correct resolution
|
|
@@ -15489,7 +15522,7 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15489
15522
|
};
|
|
15490
15523
|
}
|
|
15491
15524
|
return {
|
|
15492
|
-
path: path$
|
|
15525
|
+
path: path$q.resolve(resolved)
|
|
15493
15526
|
};
|
|
15494
15527
|
};
|
|
15495
15528
|
return {
|
|
@@ -15566,10 +15599,10 @@ function esbuildDepPlugin(qualified, exportsData, config) {
|
|
|
15566
15599
|
// referenced via relative imports - if we don't separate the proxy and
|
|
15567
15600
|
// the actual module, esbuild will create duplicated copies of the same
|
|
15568
15601
|
// module!
|
|
15569
|
-
const root = path$
|
|
15602
|
+
const root = path$q.resolve(config.root);
|
|
15570
15603
|
build.onLoad({ filter: /.*/, namespace: 'dep' }, ({ path: id }) => {
|
|
15571
15604
|
const entryFile = qualified[id];
|
|
15572
|
-
let relativePath = normalizePath$3(path$
|
|
15605
|
+
let relativePath = normalizePath$3(path$q.relative(root, entryFile));
|
|
15573
15606
|
if (!relativePath.startsWith('./') &&
|
|
15574
15607
|
!relativePath.startsWith('../') &&
|
|
15575
15608
|
relativePath !== '.') {
|
|
@@ -15646,7 +15679,7 @@ module.exports = Object.create(new Proxy({}, {
|
|
|
15646
15679
|
}
|
|
15647
15680
|
});
|
|
15648
15681
|
build.onLoad({ filter: /.*/ }, async (args) => ({
|
|
15649
|
-
contents: await promises.readFile(args.path),
|
|
15682
|
+
contents: await promises$2.readFile(args.path),
|
|
15650
15683
|
loader: 'default'
|
|
15651
15684
|
}));
|
|
15652
15685
|
}
|
|
@@ -16419,7 +16452,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
16419
16452
|
* Licensed under the MIT License.
|
|
16420
16453
|
*/
|
|
16421
16454
|
|
|
16422
|
-
const util$2 = require$$0$
|
|
16455
|
+
const util$2 = require$$0$5;
|
|
16423
16456
|
const toRegexRange = toRegexRange_1;
|
|
16424
16457
|
|
|
16425
16458
|
const isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -17382,7 +17415,7 @@ braces$2.create = (input, options = {}) => {
|
|
|
17382
17415
|
|
|
17383
17416
|
var braces_1 = braces$2;
|
|
17384
17417
|
|
|
17385
|
-
const util$1 = require$$0$
|
|
17418
|
+
const util$1 = require$$0$5;
|
|
17386
17419
|
const braces$1 = braces_1;
|
|
17387
17420
|
const picomatch$2 = picomatch$3;
|
|
17388
17421
|
const utils$b = utils$k;
|
|
@@ -18026,7 +18059,7 @@ var stream$4 = {};
|
|
|
18026
18059
|
* Copyright (c) 2014-2020 Teambition
|
|
18027
18060
|
* Licensed under the MIT license.
|
|
18028
18061
|
*/
|
|
18029
|
-
const Stream = require$$0$
|
|
18062
|
+
const Stream = require$$0$6;
|
|
18030
18063
|
const PassThrough = Stream.PassThrough;
|
|
18031
18064
|
const slice = Array.prototype.slice;
|
|
18032
18065
|
|
|
@@ -18389,7 +18422,7 @@ var fs$h = {};
|
|
|
18389
18422
|
(function (exports) {
|
|
18390
18423
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18391
18424
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
18392
|
-
const fs =
|
|
18425
|
+
const fs = require$$0__default;
|
|
18393
18426
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18394
18427
|
lstat: fs.lstat,
|
|
18395
18428
|
stat: fs.stat,
|
|
@@ -18750,7 +18783,7 @@ var fs$d = {};
|
|
|
18750
18783
|
(function (exports) {
|
|
18751
18784
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18752
18785
|
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
18753
|
-
const fs =
|
|
18786
|
+
const fs = require$$0__default;
|
|
18754
18787
|
exports.FILE_SYSTEM_ADAPTER = {
|
|
18755
18788
|
lstat: fs.lstat,
|
|
18756
18789
|
stat: fs.stat,
|
|
@@ -19181,7 +19214,7 @@ class Reader$1 {
|
|
|
19181
19214
|
reader$1.default = Reader$1;
|
|
19182
19215
|
|
|
19183
19216
|
Object.defineProperty(async$2, "__esModule", { value: true });
|
|
19184
|
-
const events_1 = require$$0$
|
|
19217
|
+
const events_1 = require$$0$4;
|
|
19185
19218
|
const fsScandir$2 = out$1;
|
|
19186
19219
|
const fastq = queue.exports;
|
|
19187
19220
|
const common$5 = common$7;
|
|
@@ -19310,7 +19343,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
19310
19343
|
var stream$1 = {};
|
|
19311
19344
|
|
|
19312
19345
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
19313
|
-
const stream_1$5 = require$$0$
|
|
19346
|
+
const stream_1$5 = require$$0$6;
|
|
19314
19347
|
const async_1$2 = async$2;
|
|
19315
19348
|
class StreamProvider {
|
|
19316
19349
|
constructor(_root, _settings) {
|
|
@@ -19518,7 +19551,7 @@ class Reader {
|
|
|
19518
19551
|
reader.default = Reader;
|
|
19519
19552
|
|
|
19520
19553
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
19521
|
-
const stream_1$3 = require$$0$
|
|
19554
|
+
const stream_1$3 = require$$0$6;
|
|
19522
19555
|
const fsStat$1 = out$3;
|
|
19523
19556
|
const fsWalk$1 = out$2;
|
|
19524
19557
|
const reader_1$1 = reader;
|
|
@@ -19916,7 +19949,7 @@ async$6.default = ProviderAsync;
|
|
|
19916
19949
|
var stream = {};
|
|
19917
19950
|
|
|
19918
19951
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
19919
|
-
const stream_1$1 = require$$0$
|
|
19952
|
+
const stream_1$1 = require$$0$6;
|
|
19920
19953
|
const stream_2 = stream$2;
|
|
19921
19954
|
const provider_1$1 = provider;
|
|
19922
19955
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -20021,7 +20054,7 @@ var settings = {};
|
|
|
20021
20054
|
(function (exports) {
|
|
20022
20055
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20023
20056
|
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
20024
|
-
const fs =
|
|
20057
|
+
const fs = require$$0__default;
|
|
20025
20058
|
const os = require$$1;
|
|
20026
20059
|
/**
|
|
20027
20060
|
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
@@ -25863,10 +25896,10 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
25863
25896
|
// TODO: use import()
|
|
25864
25897
|
const _require = createRequire$1(import.meta.url);
|
|
25865
25898
|
// get rollup version
|
|
25866
|
-
const rollupPkgPath = resolve$
|
|
25899
|
+
const rollupPkgPath = resolve$5(_require.resolve('rollup'), '../../package.json');
|
|
25867
25900
|
const minimalContext = {
|
|
25868
25901
|
meta: {
|
|
25869
|
-
rollupVersion: JSON.parse(
|
|
25902
|
+
rollupVersion: JSON.parse(fs$n.readFileSync(rollupPkgPath, 'utf-8'))
|
|
25870
25903
|
.version,
|
|
25871
25904
|
watchMode: true
|
|
25872
25905
|
}
|
|
@@ -26027,7 +26060,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
26027
26060
|
if (err.loc.file) {
|
|
26028
26061
|
err.id = normalizePath$3(err.loc.file);
|
|
26029
26062
|
try {
|
|
26030
|
-
code =
|
|
26063
|
+
code = fs$n.readFileSync(err.loc.file, 'utf-8');
|
|
26031
26064
|
}
|
|
26032
26065
|
catch { }
|
|
26033
26066
|
}
|
|
@@ -26147,7 +26180,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
26147
26180
|
}
|
|
26148
26181
|
}));
|
|
26149
26182
|
},
|
|
26150
|
-
async resolveId(rawId, importer = join$
|
|
26183
|
+
async resolveId(rawId, importer = join$2(root, 'index.html'), options) {
|
|
26151
26184
|
const skip = options?.skip;
|
|
26152
26185
|
const ssr = options?.ssr;
|
|
26153
26186
|
const scan = !!options?.scan;
|
|
@@ -26271,7 +26304,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
26271
26304
|
return container;
|
|
26272
26305
|
}
|
|
26273
26306
|
|
|
26274
|
-
function
|
|
26307
|
+
function stripLiteralAcorn(code) {
|
|
26275
26308
|
const FILL = " ";
|
|
26276
26309
|
let result = "";
|
|
26277
26310
|
function fulfill(index) {
|
|
@@ -26287,26 +26320,54 @@ function stripLiteral(code, forgiving = false) {
|
|
|
26287
26320
|
});
|
|
26288
26321
|
const inter = tokens[Symbol.iterator]();
|
|
26289
26322
|
while (true) {
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
|
|
26293
|
-
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
|
|
26300
|
-
result += code.slice(token.start, token.end);
|
|
26301
|
-
} catch (e) {
|
|
26302
|
-
if (!forgiving)
|
|
26303
|
-
throw e;
|
|
26304
|
-
}
|
|
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);
|
|
26305
26333
|
}
|
|
26306
26334
|
fulfill(code.length);
|
|
26307
26335
|
return result;
|
|
26308
26336
|
}
|
|
26309
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
|
+
|
|
26310
26371
|
const HASH_RE = /#/g;
|
|
26311
26372
|
const AMPERSAND_RE = /&/g;
|
|
26312
26373
|
const EQUAL_RE = /=/g;
|
|
@@ -26368,7 +26429,7 @@ function importGlobPlugin(config) {
|
|
|
26368
26429
|
async transform(code, id) {
|
|
26369
26430
|
if (!code.includes('import.meta.glob'))
|
|
26370
26431
|
return;
|
|
26371
|
-
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);
|
|
26372
26433
|
if (result) {
|
|
26373
26434
|
if (server) {
|
|
26374
26435
|
const allGlobs = result.matches.map((i) => i.globsResolved);
|
|
@@ -26546,7 +26607,7 @@ async function parseImportGlob(code, importer, root, resolveId) {
|
|
|
26546
26607
|
return (await Promise.all(tasks)).filter(Boolean);
|
|
26547
26608
|
}
|
|
26548
26609
|
const importPrefix = '__vite_glob_';
|
|
26549
|
-
const { basename, dirname, relative, join } = posix$
|
|
26610
|
+
const { basename, dirname, relative, join } = posix$2;
|
|
26550
26611
|
/**
|
|
26551
26612
|
* @param optimizeExport for dynamicImportVar plugin don't need to optimize export.
|
|
26552
26613
|
*/
|
|
@@ -26661,15 +26722,15 @@ async function toAbsoluteGlob(glob, root, importer, resolveId) {
|
|
|
26661
26722
|
}
|
|
26662
26723
|
const dir = importer ? dirname(importer) : root;
|
|
26663
26724
|
if (glob.startsWith('/'))
|
|
26664
|
-
return pre + posix$
|
|
26725
|
+
return pre + posix$2.join(root, glob.slice(1));
|
|
26665
26726
|
if (glob.startsWith('./'))
|
|
26666
|
-
return pre + posix$
|
|
26727
|
+
return pre + posix$2.join(dir, glob.slice(2));
|
|
26667
26728
|
if (glob.startsWith('../'))
|
|
26668
|
-
return pre + posix$
|
|
26729
|
+
return pre + posix$2.join(dir, glob);
|
|
26669
26730
|
if (glob.startsWith('**'))
|
|
26670
26731
|
return pre + glob;
|
|
26671
26732
|
const resolved = normalizePath$3((await resolveId(glob, importer)) || glob);
|
|
26672
|
-
if (isAbsolute$
|
|
26733
|
+
if (isAbsolute$4(resolved))
|
|
26673
26734
|
return pre + resolved;
|
|
26674
26735
|
throw new Error(`Invalid glob: "${glob}" (resolved: "${resolved}"). It must starts with '/' or './'`);
|
|
26675
26736
|
}
|
|
@@ -26679,8 +26740,8 @@ function getCommonBase(globsResolved) {
|
|
|
26679
26740
|
.map((glob) => {
|
|
26680
26741
|
let { base } = scan(glob);
|
|
26681
26742
|
// `scan('a/foo.js')` returns `base: 'a/foo.js'`
|
|
26682
|
-
if (posix$
|
|
26683
|
-
base = posix$
|
|
26743
|
+
if (posix$2.basename(base).includes('.'))
|
|
26744
|
+
base = posix$2.dirname(base);
|
|
26684
26745
|
return base;
|
|
26685
26746
|
});
|
|
26686
26747
|
if (!bases.length)
|
|
@@ -26723,7 +26784,7 @@ async function scanImports(config) {
|
|
|
26723
26784
|
entries = await globEntries(explicitEntryPatterns, config);
|
|
26724
26785
|
}
|
|
26725
26786
|
else if (buildInput) {
|
|
26726
|
-
const resolvePath = (p) => path$
|
|
26787
|
+
const resolvePath = (p) => path$q.resolve(config.root, p);
|
|
26727
26788
|
if (typeof buildInput === 'string') {
|
|
26728
26789
|
entries = [resolvePath(buildInput)];
|
|
26729
26790
|
}
|
|
@@ -26742,7 +26803,7 @@ async function scanImports(config) {
|
|
|
26742
26803
|
}
|
|
26743
26804
|
// Non-supported entry file types and virtual files should not be scanned for
|
|
26744
26805
|
// dependencies.
|
|
26745
|
-
entries = entries.filter((entry) => isScannable(entry) &&
|
|
26806
|
+
entries = entries.filter((entry) => isScannable(entry) && fs$n.existsSync(entry));
|
|
26746
26807
|
if (!entries.length) {
|
|
26747
26808
|
if (!explicitEntryPatterns && !config.optimizeDeps.include) {
|
|
26748
26809
|
config.logger.warn(colors$1.yellow('(!) Could not auto-determine entry point from rollupOptions or html files ' +
|
|
@@ -26806,7 +26867,7 @@ const contextRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
|
26806
26867
|
function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
26807
26868
|
const seen = new Map();
|
|
26808
26869
|
const resolve = async (id, importer) => {
|
|
26809
|
-
const key = id + (importer && path$
|
|
26870
|
+
const key = id + (importer && path$q.dirname(importer));
|
|
26810
26871
|
if (seen.has(key)) {
|
|
26811
26872
|
return seen.get(key);
|
|
26812
26873
|
}
|
|
@@ -26871,7 +26932,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
26871
26932
|
});
|
|
26872
26933
|
// extract scripts inside HTML-like files and treat it as a js module
|
|
26873
26934
|
build.onLoad({ filter: htmlTypesRE, namespace: 'html' }, async ({ path }) => {
|
|
26874
|
-
let raw =
|
|
26935
|
+
let raw = fs$n.readFileSync(path, 'utf-8');
|
|
26875
26936
|
// Avoid matching the content of the comment
|
|
26876
26937
|
raw = raw.replace(commentRE$1, '<!---->');
|
|
26877
26938
|
const isHtml = path.endsWith('.html');
|
|
@@ -26991,7 +27052,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
26991
27052
|
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
|
|
26992
27053
|
// linked package, keep crawling
|
|
26993
27054
|
return {
|
|
26994
|
-
path: path$
|
|
27055
|
+
path: path$q.resolve(resolved),
|
|
26995
27056
|
namespace
|
|
26996
27057
|
};
|
|
26997
27058
|
}
|
|
@@ -27033,7 +27094,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
27033
27094
|
}
|
|
27034
27095
|
const namespace = htmlTypesRE.test(resolved) ? 'html' : undefined;
|
|
27035
27096
|
return {
|
|
27036
|
-
path: path$
|
|
27097
|
+
path: path$q.resolve(cleanUrl(resolved)),
|
|
27037
27098
|
namespace
|
|
27038
27099
|
};
|
|
27039
27100
|
}
|
|
@@ -27046,10 +27107,10 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
27046
27107
|
// presence of import.meta.glob, since it results in import relationships
|
|
27047
27108
|
// but isn't crawled by esbuild.
|
|
27048
27109
|
build.onLoad({ filter: JS_TYPES_RE }, ({ path: id }) => {
|
|
27049
|
-
let ext = path$
|
|
27110
|
+
let ext = path$q.extname(id).slice(1);
|
|
27050
27111
|
if (ext === 'mjs')
|
|
27051
27112
|
ext = 'js';
|
|
27052
|
-
let contents =
|
|
27113
|
+
let contents = fs$n.readFileSync(id, 'utf-8');
|
|
27053
27114
|
if (ext.endsWith('x') && config.esbuild && config.esbuild.jsxInject) {
|
|
27054
27115
|
contents = config.esbuild.jsxInject + `\n` + contents;
|
|
27055
27116
|
}
|
|
@@ -27073,8 +27134,8 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
27073
27134
|
function extractImportPaths(code) {
|
|
27074
27135
|
// empty singleline & multiline comments to avoid matching comments
|
|
27075
27136
|
code = code
|
|
27076
|
-
.replace(multilineCommentsRE, '/* */')
|
|
27077
|
-
.replace(singlelineCommentsRE, '');
|
|
27137
|
+
.replace(multilineCommentsRE$1, '/* */')
|
|
27138
|
+
.replace(singlelineCommentsRE$1, '');
|
|
27078
27139
|
let js = '';
|
|
27079
27140
|
let m;
|
|
27080
27141
|
while ((m = importsRE.exec(code)) != null) {
|
|
@@ -27088,7 +27149,7 @@ function extractImportPaths(code) {
|
|
|
27088
27149
|
}
|
|
27089
27150
|
function shouldExternalizeDep(resolvedId, rawId) {
|
|
27090
27151
|
// not a valid file path
|
|
27091
|
-
if (!path$
|
|
27152
|
+
if (!path$q.isAbsolute(resolvedId)) {
|
|
27092
27153
|
return true;
|
|
27093
27154
|
}
|
|
27094
27155
|
// virtual id
|
|
@@ -27120,7 +27181,7 @@ var etag_1 = etag;
|
|
|
27120
27181
|
*/
|
|
27121
27182
|
|
|
27122
27183
|
var crypto = require$$1$2;
|
|
27123
|
-
var Stats =
|
|
27184
|
+
var Stats = require$$0__default.Stats;
|
|
27124
27185
|
|
|
27125
27186
|
/**
|
|
27126
27187
|
* Module variables.
|
|
@@ -27238,7 +27299,7 @@ var safeBuffer = {exports: {}};
|
|
|
27238
27299
|
/* eslint-disable node/no-deprecated-api */
|
|
27239
27300
|
|
|
27240
27301
|
(function (module, exports) {
|
|
27241
|
-
var buffer = require$$0$
|
|
27302
|
+
var buffer = require$$0$7;
|
|
27242
27303
|
var Buffer = buffer.Buffer;
|
|
27243
27304
|
|
|
27244
27305
|
// alternative to using Object.keys for old browsers
|
|
@@ -27302,7 +27363,7 @@ SafeBuffer.allocUnsafeSlow = function (size) {
|
|
|
27302
27363
|
}(safeBuffer, safeBuffer.exports));
|
|
27303
27364
|
|
|
27304
27365
|
(function (exports) {
|
|
27305
|
-
var fs =
|
|
27366
|
+
var fs = require$$0__default;
|
|
27306
27367
|
var path = path$p;
|
|
27307
27368
|
var SafeBuffer = safeBuffer.exports;
|
|
27308
27369
|
|
|
@@ -27878,7 +27939,6 @@ function registerCustomMime() {
|
|
|
27878
27939
|
function assetPlugin(config) {
|
|
27879
27940
|
// assetHashToFilenameMap initialization in buildStart causes getAssetFilename to return undefined
|
|
27880
27941
|
assetHashToFilenameMap.set(config, new Map());
|
|
27881
|
-
const relativeBase = isRelativeBase(config.base);
|
|
27882
27942
|
registerCustomMime();
|
|
27883
27943
|
return {
|
|
27884
27944
|
name: 'vite:asset',
|
|
@@ -27907,7 +27967,7 @@ function assetPlugin(config) {
|
|
|
27907
27967
|
if (rawRE.test(id)) {
|
|
27908
27968
|
const file = checkPublicFile(id, config) || cleanUrl(id);
|
|
27909
27969
|
// raw query, read file and return as string
|
|
27910
|
-
return `export default ${JSON.stringify(await promises.readFile(file, 'utf-8'))}`;
|
|
27970
|
+
return `export default ${JSON.stringify(await promises$2.readFile(file, 'utf-8'))}`;
|
|
27911
27971
|
}
|
|
27912
27972
|
if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
|
|
27913
27973
|
return;
|
|
@@ -27919,7 +27979,14 @@ function assetPlugin(config) {
|
|
|
27919
27979
|
renderChunk(code, chunk) {
|
|
27920
27980
|
let match;
|
|
27921
27981
|
let s;
|
|
27922
|
-
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
|
+
};
|
|
27923
27990
|
// Urls added with JS using e.g.
|
|
27924
27991
|
// imgElement.src = "__VITE_ASSET__5aa0ddc0__" are using quotes
|
|
27925
27992
|
// Urls added in CSS that is imported in JS end up like
|
|
@@ -27933,25 +28000,21 @@ function assetPlugin(config) {
|
|
|
27933
28000
|
const file = getAssetFilename(hash, config) || this.getFileName(hash);
|
|
27934
28001
|
chunk.viteMetadata.importedAssets.add(cleanUrl(file));
|
|
27935
28002
|
const filename = file + postfix;
|
|
27936
|
-
const
|
|
27937
|
-
|
|
27938
|
-
: JSON.stringify(config.base + filename).slice(1, -1);
|
|
27939
|
-
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, {
|
|
27940
28005
|
contentOnly: true
|
|
27941
28006
|
});
|
|
27942
28007
|
}
|
|
27943
28008
|
// Replace __VITE_PUBLIC_ASSET__5aa0ddc0__ with absolute paths
|
|
27944
|
-
|
|
27945
|
-
|
|
27946
|
-
|
|
27947
|
-
|
|
27948
|
-
|
|
27949
|
-
|
|
27950
|
-
|
|
27951
|
-
|
|
27952
|
-
|
|
27953
|
-
});
|
|
27954
|
-
}
|
|
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
|
+
});
|
|
27955
28018
|
}
|
|
27956
28019
|
if (s) {
|
|
27957
28020
|
return {
|
|
@@ -27982,8 +28045,8 @@ function checkPublicFile(url, { publicDir }) {
|
|
|
27982
28045
|
if (!publicDir || !url.startsWith('/')) {
|
|
27983
28046
|
return;
|
|
27984
28047
|
}
|
|
27985
|
-
const publicFile = path$
|
|
27986
|
-
if (
|
|
28048
|
+
const publicFile = path$q.join(publicDir, cleanUrl(url));
|
|
28049
|
+
if (fs$n.existsSync(publicFile)) {
|
|
27987
28050
|
return publicFile;
|
|
27988
28051
|
}
|
|
27989
28052
|
else {
|
|
@@ -28006,22 +28069,23 @@ function fileToDevUrl(id, config) {
|
|
|
28006
28069
|
}
|
|
28007
28070
|
else if (id.startsWith(config.root)) {
|
|
28008
28071
|
// in project root, infer short public path
|
|
28009
|
-
rtn = '/' + path$
|
|
28072
|
+
rtn = '/' + path$q.posix.relative(config.root, id);
|
|
28010
28073
|
}
|
|
28011
28074
|
else {
|
|
28012
28075
|
// outside of project root, use absolute fs path
|
|
28013
28076
|
// (this is special handled by the serve static middleware
|
|
28014
|
-
rtn = path$
|
|
28077
|
+
rtn = path$q.posix.join(FS_PREFIX + id);
|
|
28015
28078
|
}
|
|
28016
28079
|
const origin = config.server?.origin ?? '';
|
|
28017
|
-
|
|
28080
|
+
const devBase = config.base;
|
|
28081
|
+
return origin + devBase + rtn.replace(/^\//, '');
|
|
28018
28082
|
}
|
|
28019
28083
|
function getAssetFilename(hash, config) {
|
|
28020
28084
|
return assetHashToFilenameMap.get(config)?.get(hash);
|
|
28021
28085
|
}
|
|
28022
28086
|
function resolveAssetFileNames(config) {
|
|
28023
28087
|
const output = config.build?.rollupOptions?.output;
|
|
28024
|
-
const defaultAssetFileNames = path$
|
|
28088
|
+
const defaultAssetFileNames = path$q.posix.join(config.build.assetsDir, '[name].[hash][extname]');
|
|
28025
28089
|
// Steps to determine which assetFileNames will be actually used.
|
|
28026
28090
|
// First, if output is an object or string, use assetFileNames in it.
|
|
28027
28091
|
// And a default assetFileNames as fallback.
|
|
@@ -28057,10 +28121,10 @@ function resolveAssetFileNames(config) {
|
|
|
28057
28121
|
* @returns output filename
|
|
28058
28122
|
*/
|
|
28059
28123
|
function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
|
|
28060
|
-
const basename = path$
|
|
28124
|
+
const basename = path$q.basename(file);
|
|
28061
28125
|
// placeholders for `assetFileNames`
|
|
28062
28126
|
// `hash` is slightly different from the rollup's one
|
|
28063
|
-
const extname = path$
|
|
28127
|
+
const extname = path$q.extname(basename);
|
|
28064
28128
|
const ext = extname.substring(1);
|
|
28065
28129
|
const name = basename.slice(0, -extname.length);
|
|
28066
28130
|
const hash = contentHash;
|
|
@@ -28095,7 +28159,8 @@ function assetFileNamesToFileName(assetFileNames, file, contentHash, content) {
|
|
|
28095
28159
|
const publicAssetUrlCache = new WeakMap();
|
|
28096
28160
|
const publicAssetUrlRE = /__VITE_PUBLIC_ASSET__([a-z\d]{8})__/g;
|
|
28097
28161
|
function publicFileToBuiltUrl(url, config) {
|
|
28098
|
-
if (
|
|
28162
|
+
if (config.command !== 'build') {
|
|
28163
|
+
// We don't need relative base or buildAdvancedBaseOptions support during dev
|
|
28099
28164
|
return config.base + url.slice(1);
|
|
28100
28165
|
}
|
|
28101
28166
|
const hash = getHash(url);
|
|
@@ -28123,7 +28188,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
|
28123
28188
|
return cached;
|
|
28124
28189
|
}
|
|
28125
28190
|
const file = cleanUrl(id);
|
|
28126
|
-
const content = await promises.readFile(file);
|
|
28191
|
+
const content = await promises$2.readFile(file);
|
|
28127
28192
|
let url;
|
|
28128
28193
|
if (config.build.lib ||
|
|
28129
28194
|
(!file.endsWith('.svg') &&
|
|
@@ -28150,7 +28215,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
|
28150
28215
|
}
|
|
28151
28216
|
const emittedSet = emittedHashMap.get(config);
|
|
28152
28217
|
if (!emittedSet.has(contentHash)) {
|
|
28153
|
-
const name = normalizePath$3(path$
|
|
28218
|
+
const name = normalizePath$3(path$q.relative(config.root, file));
|
|
28154
28219
|
pluginContext.emitFile({
|
|
28155
28220
|
name,
|
|
28156
28221
|
fileName,
|
|
@@ -28169,8 +28234,8 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
|
|
|
28169
28234
|
return publicFileToBuiltUrl(url, config);
|
|
28170
28235
|
}
|
|
28171
28236
|
const file = url.startsWith('/')
|
|
28172
|
-
? path$
|
|
28173
|
-
: path$
|
|
28237
|
+
? path$q.join(config.root, url)
|
|
28238
|
+
: path$q.join(path$q.dirname(importer), url);
|
|
28174
28239
|
return fileToBuiltUrl(file, config, pluginContext,
|
|
28175
28240
|
// skip public check since we just did it above
|
|
28176
28241
|
true);
|
|
@@ -28990,8 +29055,8 @@ function viaLocal(dir, isEtag, uri, extns) {
|
|
|
28990
29055
|
let abs, stats, name, headers;
|
|
28991
29056
|
for (; i < arr.length; i++) {
|
|
28992
29057
|
abs = normalize(join$1(dir, name=arr[i]));
|
|
28993
|
-
if (abs.startsWith(dir) &&
|
|
28994
|
-
stats =
|
|
29058
|
+
if (abs.startsWith(dir) && require$$0$2.existsSync(abs)) {
|
|
29059
|
+
stats = require$$0$2.statSync(abs);
|
|
28995
29060
|
if (stats.isDirectory()) continue;
|
|
28996
29061
|
headers = toHeaders(name, stats, isEtag);
|
|
28997
29062
|
headers['Cache-Control'] = isEtag ? 'no-cache' : 'no-store';
|
|
@@ -29035,7 +29100,7 @@ function send$2(req, res, file, stats, headers) {
|
|
|
29035
29100
|
}
|
|
29036
29101
|
|
|
29037
29102
|
res.writeHead(code, headers);
|
|
29038
|
-
|
|
29103
|
+
require$$0$2.createReadStream(file, opts).pipe(res);
|
|
29039
29104
|
}
|
|
29040
29105
|
|
|
29041
29106
|
const ENCODING = {
|
|
@@ -29183,7 +29248,7 @@ function serveStaticMiddleware(dir, server) {
|
|
|
29183
29248
|
// also skip internal requests `/@fs/ /@vite-client` etc...
|
|
29184
29249
|
const cleanedUrl = cleanUrl(req.url);
|
|
29185
29250
|
if (cleanedUrl.endsWith('/') ||
|
|
29186
|
-
path$
|
|
29251
|
+
path$q.extname(cleanedUrl) === '.html' ||
|
|
29187
29252
|
isInternalRequest(req.url)) {
|
|
29188
29253
|
return next();
|
|
29189
29254
|
}
|
|
@@ -29204,7 +29269,7 @@ function serveStaticMiddleware(dir, server) {
|
|
|
29204
29269
|
}
|
|
29205
29270
|
}
|
|
29206
29271
|
const resolvedUrl = redirected || url;
|
|
29207
|
-
let fileUrl = path$
|
|
29272
|
+
let fileUrl = path$q.resolve(dir, resolvedUrl.replace(/^\//, ''));
|
|
29208
29273
|
if (resolvedUrl.endsWith('/') && !fileUrl.endsWith('/')) {
|
|
29209
29274
|
fileUrl = fileUrl + '/';
|
|
29210
29275
|
}
|
|
@@ -29228,11 +29293,11 @@ function serveRawFsMiddleware(server) {
|
|
|
29228
29293
|
// searching based from fs root.
|
|
29229
29294
|
if (url.startsWith(FS_PREFIX)) {
|
|
29230
29295
|
// restrict files outside of `fs.allow`
|
|
29231
|
-
if (!ensureServingAccess(slash$1(path$
|
|
29296
|
+
if (!ensureServingAccess(slash$1(path$q.resolve(fsPathFromId(url))), server, res, next)) {
|
|
29232
29297
|
return;
|
|
29233
29298
|
}
|
|
29234
29299
|
url = url.slice(FS_PREFIX.length);
|
|
29235
|
-
if (isWindows$
|
|
29300
|
+
if (isWindows$4)
|
|
29236
29301
|
url = url.replace(/^[A-Z]:/i, '');
|
|
29237
29302
|
req.url = url;
|
|
29238
29303
|
serveFromRoot(req, res, next);
|
|
@@ -29398,7 +29463,7 @@ async function doTransform(url, server, options, timestamp) {
|
|
|
29398
29463
|
// like /service-worker.js or /api/users
|
|
29399
29464
|
if (options.ssr || isFileServingAllowed(file, server)) {
|
|
29400
29465
|
try {
|
|
29401
|
-
code = await promises.readFile(file, 'utf-8');
|
|
29466
|
+
code = await promises$2.readFile(file, 'utf-8');
|
|
29402
29467
|
isDebug$3 && debugLoad(`${timeFrom(loadStart)} [fs] ${prettyUrl}`);
|
|
29403
29468
|
}
|
|
29404
29469
|
catch (e) {
|
|
@@ -29410,7 +29475,7 @@ async function doTransform(url, server, options, timestamp) {
|
|
|
29410
29475
|
if (code) {
|
|
29411
29476
|
try {
|
|
29412
29477
|
map = (convertSourceMap.fromSource(code) ||
|
|
29413
|
-
convertSourceMap.fromMapFileSource(code, path$
|
|
29478
|
+
convertSourceMap.fromMapFileSource(code, path$q.dirname(file)))?.toObject();
|
|
29414
29479
|
}
|
|
29415
29480
|
catch (e) {
|
|
29416
29481
|
logger.warn(`Failed to load source map for ${url}.`, {
|
|
@@ -29994,15 +30059,15 @@ function loadCachedDepOptimizationMetadata(config, force = config.optimizeDeps.f
|
|
|
29994
30059
|
const log = asCommand ? config.logger.info : debug$a;
|
|
29995
30060
|
// Before Vite 2.9, dependencies were cached in the root of the cacheDir
|
|
29996
30061
|
// For compat, we remove the cache if we find the old structure
|
|
29997
|
-
if (
|
|
30062
|
+
if (fs$n.existsSync(path$q.join(config.cacheDir, '_metadata.json'))) {
|
|
29998
30063
|
emptyDir(config.cacheDir);
|
|
29999
30064
|
}
|
|
30000
30065
|
const depsCacheDir = getDepsCacheDir(config, ssr);
|
|
30001
30066
|
if (!force) {
|
|
30002
30067
|
let cachedMetadata;
|
|
30003
30068
|
try {
|
|
30004
|
-
const cachedMetadataPath = path$
|
|
30005
|
-
cachedMetadata = parseDepsOptimizerMetadata(
|
|
30069
|
+
const cachedMetadataPath = path$q.join(depsCacheDir, '_metadata.json');
|
|
30070
|
+
cachedMetadata = parseDepsOptimizerMetadata(fs$n.readFileSync(cachedMetadataPath, 'utf-8'), depsCacheDir);
|
|
30006
30071
|
}
|
|
30007
30072
|
catch (e) { }
|
|
30008
30073
|
// hash is consistent, no need to re-bundle
|
|
@@ -30017,7 +30082,7 @@ function loadCachedDepOptimizationMetadata(config, force = config.optimizeDeps.f
|
|
|
30017
30082
|
config.logger.info('Forced re-optimization of dependencies');
|
|
30018
30083
|
}
|
|
30019
30084
|
// Start with a fresh cache
|
|
30020
|
-
|
|
30085
|
+
fs$n.rmSync(depsCacheDir, { recursive: true, force: true });
|
|
30021
30086
|
}
|
|
30022
30087
|
/**
|
|
30023
30088
|
* Initial optimizeDeps at server start. Perform a fast scan using esbuild to
|
|
@@ -30086,15 +30151,15 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
|
|
|
30086
30151
|
// Create a temporal directory so we don't need to delete optimized deps
|
|
30087
30152
|
// until they have been processed. This also avoids leaving the deps cache
|
|
30088
30153
|
// directory in a corrupted state if there is an error
|
|
30089
|
-
if (
|
|
30154
|
+
if (fs$n.existsSync(processingCacheDir)) {
|
|
30090
30155
|
emptyDir(processingCacheDir);
|
|
30091
30156
|
}
|
|
30092
30157
|
else {
|
|
30093
|
-
|
|
30158
|
+
fs$n.mkdirSync(processingCacheDir, { recursive: true });
|
|
30094
30159
|
}
|
|
30095
30160
|
// a hint for Node.js
|
|
30096
30161
|
// all files in the cache directory should be recognized as ES modules
|
|
30097
|
-
writeFile(path$
|
|
30162
|
+
writeFile(path$q.resolve(processingCacheDir, 'package.json'), JSON.stringify({ type: 'module' }));
|
|
30098
30163
|
const metadata = initDepsOptimizerMetadata(config);
|
|
30099
30164
|
metadata.browserHash = getOptimizedBrowserHash(metadata.hash, depsFromOptimizedDepInfo(depsInfo));
|
|
30100
30165
|
// We prebundle dependencies with esbuild and cache them, but there is no need
|
|
@@ -30111,7 +30176,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
|
|
|
30111
30176
|
await renameDir(processingCacheDir, depsCacheDir);
|
|
30112
30177
|
},
|
|
30113
30178
|
cancel() {
|
|
30114
|
-
|
|
30179
|
+
fs$n.rmSync(processingCacheDir, { recursive: true, force: true });
|
|
30115
30180
|
}
|
|
30116
30181
|
};
|
|
30117
30182
|
if (!qualifiedIds.length) {
|
|
@@ -30169,7 +30234,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
|
|
|
30169
30234
|
});
|
|
30170
30235
|
const meta = result.metafile;
|
|
30171
30236
|
// the paths in `meta.outputs` are relative to `process.cwd()`
|
|
30172
|
-
const processingCacheDirOutputPath = path$
|
|
30237
|
+
const processingCacheDirOutputPath = path$q.relative(process.cwd(), processingCacheDir);
|
|
30173
30238
|
for (const id in depsInfo) {
|
|
30174
30239
|
const output = esbuildOutputFromId(meta.outputs, id, processingCacheDir);
|
|
30175
30240
|
const { exportsData, ...info } = depsInfo[id];
|
|
@@ -30186,7 +30251,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
|
|
|
30186
30251
|
}
|
|
30187
30252
|
for (const o of Object.keys(meta.outputs)) {
|
|
30188
30253
|
if (!o.match(jsMapExtensionRE)) {
|
|
30189
|
-
const id = path$
|
|
30254
|
+
const id = path$q
|
|
30190
30255
|
.relative(processingCacheDirOutputPath, o)
|
|
30191
30256
|
.replace(jsExtensionRE, '');
|
|
30192
30257
|
const file = getOptimizedDepPath(id, resolvedConfig, ssr);
|
|
@@ -30200,7 +30265,7 @@ async function runOptimizeDeps(resolvedConfig, depsInfo, ssr = !!resolvedConfig.
|
|
|
30200
30265
|
}
|
|
30201
30266
|
}
|
|
30202
30267
|
}
|
|
30203
|
-
const dataPath = path$
|
|
30268
|
+
const dataPath = path$q.join(processingCacheDir, '_metadata.json');
|
|
30204
30269
|
writeFile(dataPath, stringifyDepsOptimizerMetadata(metadata, depsCacheDir));
|
|
30205
30270
|
debug$a(`deps bundled in ${(performance.now() - start).toFixed(2)}ms`);
|
|
30206
30271
|
return processingResult;
|
|
@@ -30242,7 +30307,7 @@ function depsFromOptimizedDepInfo(depsInfo) {
|
|
|
30242
30307
|
return Object.fromEntries(Object.entries(depsInfo).map((d) => [d[0], d[1].src]));
|
|
30243
30308
|
}
|
|
30244
30309
|
function getOptimizedDepPath(id, config, ssr = !!config.build.ssr) {
|
|
30245
|
-
return normalizePath$3(path$
|
|
30310
|
+
return normalizePath$3(path$q.resolve(getDepsCacheDir(config, ssr), flattenId(id) + '.js'));
|
|
30246
30311
|
}
|
|
30247
30312
|
function getDepsCacheSuffix(config, ssr) {
|
|
30248
30313
|
let suffix = '';
|
|
@@ -30264,7 +30329,7 @@ function getProcessingDepsCacheDir(config, ssr) {
|
|
|
30264
30329
|
return (getDepsCacheDirPrefix(config) + getDepsCacheSuffix(config, ssr) + '_temp');
|
|
30265
30330
|
}
|
|
30266
30331
|
function getDepsCacheDirPrefix(config) {
|
|
30267
|
-
return normalizePath$3(path$
|
|
30332
|
+
return normalizePath$3(path$q.resolve(config.cacheDir, 'deps'));
|
|
30268
30333
|
}
|
|
30269
30334
|
function isOptimizedDepFile(id, config) {
|
|
30270
30335
|
return id.startsWith(getDepsCacheDirPrefix(config));
|
|
@@ -30273,7 +30338,7 @@ function createIsOptimizedDepUrl(config) {
|
|
|
30273
30338
|
const { root } = config;
|
|
30274
30339
|
const depsCacheDir = getDepsCacheDirPrefix(config);
|
|
30275
30340
|
// determine the url prefix of files inside cache directory
|
|
30276
|
-
const depsCacheDirRelative = normalizePath$3(path$
|
|
30341
|
+
const depsCacheDirRelative = normalizePath$3(path$q.relative(root, depsCacheDir));
|
|
30277
30342
|
const depsCacheDirPrefix = depsCacheDirRelative.startsWith('../')
|
|
30278
30343
|
? // if the cache directory is outside root, the url prefix would be something
|
|
30279
30344
|
// like '/@fs/absolute/path/to/node_modules/.vite'
|
|
@@ -30290,7 +30355,7 @@ function parseDepsOptimizerMetadata(jsonMetadata, depsCacheDir) {
|
|
|
30290
30355
|
// Paths can be absolute or relative to the deps cache dir where
|
|
30291
30356
|
// the _metadata.json is located
|
|
30292
30357
|
if (key === 'file' || key === 'src') {
|
|
30293
|
-
return normalizePath$3(path$
|
|
30358
|
+
return normalizePath$3(path$q.resolve(depsCacheDir, value));
|
|
30294
30359
|
}
|
|
30295
30360
|
return value;
|
|
30296
30361
|
});
|
|
@@ -30349,14 +30414,14 @@ function stringifyDepsOptimizerMetadata(metadata, depsCacheDir) {
|
|
|
30349
30414
|
// Paths can be absolute or relative to the deps cache dir where
|
|
30350
30415
|
// the _metadata.json is located
|
|
30351
30416
|
if (key === 'file' || key === 'src') {
|
|
30352
|
-
return normalizePath$3(path$
|
|
30417
|
+
return normalizePath$3(path$q.relative(depsCacheDir, value));
|
|
30353
30418
|
}
|
|
30354
30419
|
return value;
|
|
30355
30420
|
}, 2);
|
|
30356
30421
|
}
|
|
30357
30422
|
function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
|
|
30358
30423
|
const flatId = flattenId(id) + '.js';
|
|
30359
|
-
return outputs[normalizePath$3(path$
|
|
30424
|
+
return outputs[normalizePath$3(path$q.relative(process.cwd(), path$q.join(cacheDirOutputPath, flatId)))];
|
|
30360
30425
|
}
|
|
30361
30426
|
async function extractExportsData(filePath, config) {
|
|
30362
30427
|
await init;
|
|
@@ -30380,12 +30445,12 @@ async function extractExportsData(filePath, config) {
|
|
|
30380
30445
|
}
|
|
30381
30446
|
let parseResult;
|
|
30382
30447
|
let usedJsxLoader = false;
|
|
30383
|
-
const entryContent =
|
|
30448
|
+
const entryContent = fs$n.readFileSync(filePath, 'utf-8');
|
|
30384
30449
|
try {
|
|
30385
30450
|
parseResult = parse$g(entryContent);
|
|
30386
30451
|
}
|
|
30387
30452
|
catch {
|
|
30388
|
-
const loader = esbuildOptions.loader?.[path$
|
|
30453
|
+
const loader = esbuildOptions.loader?.[path$q.extname(filePath)] || 'jsx';
|
|
30389
30454
|
debug$a(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
|
|
30390
30455
|
const transformed = await transformWithEsbuild(entryContent, filePath, {
|
|
30391
30456
|
loader
|
|
@@ -30532,7 +30597,7 @@ var dist = {};
|
|
|
30532
30597
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30533
30598
|
exports.lilconfigSync = exports.lilconfig = exports.defaultLoaders = void 0;
|
|
30534
30599
|
const path = path$p;
|
|
30535
|
-
const fs =
|
|
30600
|
+
const fs = require$$0__default;
|
|
30536
30601
|
const os = require$$1;
|
|
30537
30602
|
const fsReadFileAsync = fs.promises.readFile;
|
|
30538
30603
|
function getDefaultSearchPlaces(name) {
|
|
@@ -38008,7 +38073,7 @@ var browser$1 = {
|
|
|
38008
38073
|
var require$$3 = /*@__PURE__*/getAugmentedNamespace(browser$1);
|
|
38009
38074
|
|
|
38010
38075
|
// eslint-disable-next-line n/no-deprecated-api
|
|
38011
|
-
const { createRequire, createRequireFromPath } = require$$0$
|
|
38076
|
+
const { createRequire, createRequireFromPath } = require$$0$8;
|
|
38012
38077
|
|
|
38013
38078
|
function req$2 (name, rootFile) {
|
|
38014
38079
|
const create = createRequire || createRequireFromPath;
|
|
@@ -38149,7 +38214,7 @@ const plugins = (config, file) => {
|
|
|
38149
38214
|
var plugins_1 = plugins;
|
|
38150
38215
|
|
|
38151
38216
|
const resolve = path$p.resolve;
|
|
38152
|
-
const url$4 = require$$0$
|
|
38217
|
+
const url$4 = require$$0$9;
|
|
38153
38218
|
|
|
38154
38219
|
const config$1 = dist;
|
|
38155
38220
|
const yaml = require$$3;
|
|
@@ -38462,7 +38527,7 @@ const assetAttrsConfig = {
|
|
|
38462
38527
|
const isAsyncScriptMap = new WeakMap();
|
|
38463
38528
|
async function traverseHtml(html, filePath, visitor) {
|
|
38464
38529
|
// lazy load compiler
|
|
38465
|
-
const { parse, transform } = await import('./dep-
|
|
38530
|
+
const { parse, transform } = await import('./dep-92497830.js').then(function (n) { return n.c; });
|
|
38466
38531
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
38467
38532
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
38468
38533
|
try {
|
|
@@ -38534,7 +38599,7 @@ function buildHtmlPlugin(config) {
|
|
|
38534
38599
|
name: 'vite:build-html',
|
|
38535
38600
|
async transform(html, id) {
|
|
38536
38601
|
if (id.endsWith('.html')) {
|
|
38537
|
-
const relativeUrlPath = slash$1(path$
|
|
38602
|
+
const relativeUrlPath = slash$1(path$q.relative(config.root, id));
|
|
38538
38603
|
const publicPath = `/${relativeUrlPath}`;
|
|
38539
38604
|
const publicBase = getPublicBase(relativeUrlPath, config);
|
|
38540
38605
|
// pre-transform
|
|
@@ -38761,31 +38826,31 @@ function buildHtmlPlugin(config) {
|
|
|
38761
38826
|
});
|
|
38762
38827
|
return chunks;
|
|
38763
38828
|
};
|
|
38764
|
-
const toScriptTag = (chunk,
|
|
38829
|
+
const toScriptTag = (chunk, assetsBase, isAsync) => ({
|
|
38765
38830
|
tag: 'script',
|
|
38766
38831
|
attrs: {
|
|
38767
38832
|
...(isAsync ? { async: true } : {}),
|
|
38768
38833
|
type: 'module',
|
|
38769
38834
|
crossorigin: true,
|
|
38770
|
-
src: toPublicPath(chunk.fileName,
|
|
38835
|
+
src: toPublicPath(chunk.fileName, assetsBase)
|
|
38771
38836
|
}
|
|
38772
38837
|
});
|
|
38773
|
-
const toPreloadTag = (chunk,
|
|
38838
|
+
const toPreloadTag = (chunk, assetsBase) => ({
|
|
38774
38839
|
tag: 'link',
|
|
38775
38840
|
attrs: {
|
|
38776
38841
|
rel: 'modulepreload',
|
|
38777
38842
|
crossorigin: true,
|
|
38778
|
-
href: toPublicPath(chunk.fileName,
|
|
38843
|
+
href: toPublicPath(chunk.fileName, assetsBase)
|
|
38779
38844
|
}
|
|
38780
38845
|
});
|
|
38781
|
-
const getCssTagsForChunk = (chunk,
|
|
38846
|
+
const getCssTagsForChunk = (chunk, assetsBase, seen = new Set()) => {
|
|
38782
38847
|
const tags = [];
|
|
38783
38848
|
if (!analyzedChunk.has(chunk)) {
|
|
38784
38849
|
analyzedChunk.set(chunk, 1);
|
|
38785
38850
|
chunk.imports.forEach((file) => {
|
|
38786
38851
|
const importee = bundle[file];
|
|
38787
38852
|
if (importee?.type === 'chunk') {
|
|
38788
|
-
tags.push(...getCssTagsForChunk(importee,
|
|
38853
|
+
tags.push(...getCssTagsForChunk(importee, assetsBase, seen));
|
|
38789
38854
|
}
|
|
38790
38855
|
});
|
|
38791
38856
|
}
|
|
@@ -38796,7 +38861,7 @@ function buildHtmlPlugin(config) {
|
|
|
38796
38861
|
tag: 'link',
|
|
38797
38862
|
attrs: {
|
|
38798
38863
|
rel: 'stylesheet',
|
|
38799
|
-
href: toPublicPath(file,
|
|
38864
|
+
href: toPublicPath(file, assetsBase)
|
|
38800
38865
|
}
|
|
38801
38866
|
});
|
|
38802
38867
|
}
|
|
@@ -38804,8 +38869,8 @@ function buildHtmlPlugin(config) {
|
|
|
38804
38869
|
return tags;
|
|
38805
38870
|
};
|
|
38806
38871
|
for (const [id, html] of processedHtml) {
|
|
38807
|
-
const relativeUrlPath = path$
|
|
38808
|
-
const
|
|
38872
|
+
const relativeUrlPath = path$q.posix.relative(config.root, id);
|
|
38873
|
+
const assetsBase = getAssetsBase(relativeUrlPath, config);
|
|
38809
38874
|
const isAsync = isAsyncScriptMap.get(config).get(id);
|
|
38810
38875
|
let result = html;
|
|
38811
38876
|
// find corresponding entry chunk
|
|
@@ -38825,12 +38890,12 @@ function buildHtmlPlugin(config) {
|
|
|
38825
38890
|
// when inlined, discard entry chunk and inject <script> for everything in post-order
|
|
38826
38891
|
const imports = getImportedChunks(chunk);
|
|
38827
38892
|
const assetTags = canInlineEntry
|
|
38828
|
-
? imports.map((chunk) => toScriptTag(chunk,
|
|
38893
|
+
? imports.map((chunk) => toScriptTag(chunk, assetsBase, isAsync))
|
|
38829
38894
|
: [
|
|
38830
|
-
toScriptTag(chunk,
|
|
38831
|
-
...imports.map((i) => toPreloadTag(i,
|
|
38895
|
+
toScriptTag(chunk, assetsBase, isAsync),
|
|
38896
|
+
...imports.map((i) => toPreloadTag(i, assetsBase))
|
|
38832
38897
|
];
|
|
38833
|
-
assetTags.push(...getCssTagsForChunk(chunk,
|
|
38898
|
+
assetTags.push(...getCssTagsForChunk(chunk, assetsBase));
|
|
38834
38899
|
result = injectToHead(result, assetTags);
|
|
38835
38900
|
}
|
|
38836
38901
|
// inject css link when cssCodeSplit is false
|
|
@@ -38842,7 +38907,7 @@ function buildHtmlPlugin(config) {
|
|
|
38842
38907
|
tag: 'link',
|
|
38843
38908
|
attrs: {
|
|
38844
38909
|
rel: 'stylesheet',
|
|
38845
|
-
href: toPublicPath(cssChunk.fileName,
|
|
38910
|
+
href: toPublicPath(cssChunk.fileName, assetsBase)
|
|
38846
38911
|
}
|
|
38847
38912
|
}
|
|
38848
38913
|
]);
|
|
@@ -38868,13 +38933,13 @@ function buildHtmlPlugin(config) {
|
|
|
38868
38933
|
});
|
|
38869
38934
|
// resolve asset url references
|
|
38870
38935
|
result = result.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
|
38871
|
-
return
|
|
38936
|
+
return assetsBase + getAssetFilename(fileHash, config) + postfix;
|
|
38872
38937
|
});
|
|
38873
38938
|
if (chunk && canInlineEntry) {
|
|
38874
38939
|
// all imports from entry have been inlined to html, prevent rollup from outputting it
|
|
38875
38940
|
delete bundle[chunk.fileName];
|
|
38876
38941
|
}
|
|
38877
|
-
const shortEmitName = path$
|
|
38942
|
+
const shortEmitName = path$q.relative(config.root, id);
|
|
38878
38943
|
this.emitFile({
|
|
38879
38944
|
type: 'asset',
|
|
38880
38945
|
fileName: shortEmitName,
|
|
@@ -38954,10 +39019,19 @@ function isEntirelyImport(code) {
|
|
|
38954
39019
|
// the regexes will remove too little in some exotic cases, but false-negatives are alright
|
|
38955
39020
|
return !code.replace(importRE, '').replace(commentRE, '').trim().length;
|
|
38956
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
|
+
}
|
|
38957
39030
|
function getPublicBase(urlRelativePath, config) {
|
|
38958
|
-
return
|
|
38959
|
-
|
|
38960
|
-
|
|
39031
|
+
return getBaseInHTML(urlRelativePath, config.experimental.buildAdvancedBaseOptions.public, config);
|
|
39032
|
+
}
|
|
39033
|
+
function getAssetsBase(urlRelativePath, config) {
|
|
39034
|
+
return getBaseInHTML(urlRelativePath, config.experimental.buildAdvancedBaseOptions.assets, config);
|
|
38961
39035
|
}
|
|
38962
39036
|
function toPublicPath(filename, publicBase) {
|
|
38963
39037
|
return isExternalUrl(filename) ? filename : publicBase + filename;
|
|
@@ -39081,6 +39155,9 @@ const isDirectRequest = (request) => directRequestRE.test(request);
|
|
|
39081
39155
|
const cssModulesCache = new WeakMap();
|
|
39082
39156
|
const removedPureCssFilesCache = new WeakMap();
|
|
39083
39157
|
const postcssConfigCache = new WeakMap();
|
|
39158
|
+
function encodePublicUrlsInCSS(config) {
|
|
39159
|
+
return config.command === 'build';
|
|
39160
|
+
}
|
|
39084
39161
|
/**
|
|
39085
39162
|
* Plugin applied before user plugins
|
|
39086
39163
|
*/
|
|
@@ -39113,7 +39190,7 @@ function cssPlugin(config) {
|
|
|
39113
39190
|
const ssr = options?.ssr === true;
|
|
39114
39191
|
const urlReplacer = async (url, importer) => {
|
|
39115
39192
|
if (checkPublicFile(url, config)) {
|
|
39116
|
-
if (
|
|
39193
|
+
if (encodePublicUrlsInCSS(config)) {
|
|
39117
39194
|
return publicFileToBuiltUrl(url, config);
|
|
39118
39195
|
}
|
|
39119
39196
|
else {
|
|
@@ -39141,6 +39218,7 @@ function cssPlugin(config) {
|
|
|
39141
39218
|
// server only logic for handling CSS @import dependency hmr
|
|
39142
39219
|
const { moduleGraph } = server;
|
|
39143
39220
|
const thisModule = moduleGraph.getModuleById(id);
|
|
39221
|
+
const devBase = config.base;
|
|
39144
39222
|
if (thisModule) {
|
|
39145
39223
|
// CSS modules cannot self-accept since it exports values
|
|
39146
39224
|
const isSelfAccepting = !modules && !inlineRE.test(id) && !htmlProxyRE.test(id);
|
|
@@ -39151,12 +39229,12 @@ function cssPlugin(config) {
|
|
|
39151
39229
|
for (const file of deps) {
|
|
39152
39230
|
depModules.add(isCSSRequest(file)
|
|
39153
39231
|
? moduleGraph.createFileOnlyEntry(file)
|
|
39154
|
-
: 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));
|
|
39155
39233
|
}
|
|
39156
|
-
moduleGraph.updateModuleInfo(thisModule, depModules,
|
|
39234
|
+
moduleGraph.updateModuleInfo(thisModule, depModules, null,
|
|
39157
39235
|
// The root CSS proxy module is self-accepting and should not
|
|
39158
39236
|
// have an explicit accept list
|
|
39159
|
-
new Set(), isSelfAccepting, ssr);
|
|
39237
|
+
new Set(), null, isSelfAccepting, ssr);
|
|
39160
39238
|
for (const file of deps) {
|
|
39161
39239
|
this.addWatchFile(file);
|
|
39162
39240
|
}
|
|
@@ -39184,7 +39262,6 @@ function cssPostPlugin(config) {
|
|
|
39184
39262
|
// since output formats have no effect on the generated CSS.
|
|
39185
39263
|
let outputToExtractedCSSMap;
|
|
39186
39264
|
let hasEmitted = false;
|
|
39187
|
-
const relativeBase = isRelativeBase(config.base);
|
|
39188
39265
|
const rollupOptionsOutput = config.build.rollupOptions.output;
|
|
39189
39266
|
const assetFileNames = (Array.isArray(rollupOptionsOutput)
|
|
39190
39267
|
? rollupOptionsOutput[0]
|
|
@@ -39194,10 +39271,10 @@ function cssPostPlugin(config) {
|
|
|
39194
39271
|
return config.build.assetsDir;
|
|
39195
39272
|
}
|
|
39196
39273
|
else if (typeof assetFileNames === 'string') {
|
|
39197
|
-
return path$
|
|
39274
|
+
return path$q.dirname(assetFileNames);
|
|
39198
39275
|
}
|
|
39199
39276
|
else {
|
|
39200
|
-
return path$
|
|
39277
|
+
return path$q.dirname(assetFileNames({
|
|
39201
39278
|
name: cssAssetName,
|
|
39202
39279
|
type: 'asset',
|
|
39203
39280
|
source: '/* vite internal call, ignore */'
|
|
@@ -39246,8 +39323,9 @@ function cssPostPlugin(config) {
|
|
|
39246
39323
|
return `export default ${JSON.stringify(css)}`;
|
|
39247
39324
|
}
|
|
39248
39325
|
const cssContent = await getContentWithSourcemap(css);
|
|
39326
|
+
const devBase = config.base;
|
|
39249
39327
|
return [
|
|
39250
|
-
`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))}`,
|
|
39251
39329
|
`const __vite__id = ${JSON.stringify(id)}`,
|
|
39252
39330
|
`const __vite__css = ${JSON.stringify(cssContent)}`,
|
|
39253
39331
|
`__vite__updateStyle(__vite__id, __vite__css)`,
|
|
@@ -39313,34 +39391,45 @@ function cssPostPlugin(config) {
|
|
|
39313
39391
|
const publicAssetUrlMap = publicAssetUrlCache.get(config);
|
|
39314
39392
|
// resolve asset URL placeholders to their built file URLs
|
|
39315
39393
|
function resolveAssetUrlsInCss(chunkCSS, cssAssetName) {
|
|
39316
|
-
const
|
|
39394
|
+
const encodedPublicUrls = encodePublicUrlsInCSS(config);
|
|
39395
|
+
const { assets: assetsBase, public: publicBase } = config.experimental.buildAdvancedBaseOptions;
|
|
39396
|
+
const cssAssetDirname = encodedPublicUrls || assetsBase.relative
|
|
39317
39397
|
? getCssAssetDirname(cssAssetName)
|
|
39318
39398
|
: undefined;
|
|
39319
39399
|
// replace asset url references with resolved url.
|
|
39320
39400
|
chunkCSS = chunkCSS.replace(assetUrlRE, (_, fileHash, postfix = '') => {
|
|
39321
39401
|
const filename = getAssetFilename(fileHash, config) + postfix;
|
|
39322
39402
|
chunk.viteMetadata.importedAssets.add(cleanUrl(filename));
|
|
39323
|
-
if (
|
|
39403
|
+
if (assetsBase.relative && !config.build.ssr) {
|
|
39324
39404
|
// relative base + extracted CSS
|
|
39325
|
-
const relativePath = path$
|
|
39405
|
+
const relativePath = path$q.posix.relative(cssAssetDirname, filename);
|
|
39326
39406
|
return relativePath.startsWith('.')
|
|
39327
39407
|
? relativePath
|
|
39328
39408
|
: './' + relativePath;
|
|
39329
39409
|
}
|
|
39330
39410
|
else {
|
|
39331
|
-
//
|
|
39332
|
-
return config.base + filename;
|
|
39411
|
+
// assetsBase.runtime has no effect for assets in CSS
|
|
39412
|
+
return (assetsBase.url ?? config.base) + filename;
|
|
39333
39413
|
}
|
|
39334
39414
|
});
|
|
39335
39415
|
// resolve public URL from CSS paths
|
|
39336
|
-
if (
|
|
39337
|
-
const relativePathToPublicFromCSS = path$
|
|
39338
|
-
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
|
+
});
|
|
39339
39428
|
}
|
|
39340
39429
|
return chunkCSS;
|
|
39341
39430
|
}
|
|
39342
39431
|
function ensureFileExt(name, ext) {
|
|
39343
|
-
return path$
|
|
39432
|
+
return path$q.format({ ...path$q.parse(name), base: undefined, ext });
|
|
39344
39433
|
}
|
|
39345
39434
|
if (config.build.cssCodeSplit) {
|
|
39346
39435
|
if (isPureCssChunk) {
|
|
@@ -39349,7 +39438,7 @@ function cssPostPlugin(config) {
|
|
|
39349
39438
|
}
|
|
39350
39439
|
if (opts.format === 'es' || opts.format === 'cjs') {
|
|
39351
39440
|
const cssAssetName = ensureFileExt(chunk.facadeModuleId
|
|
39352
|
-
? normalizePath$3(path$
|
|
39441
|
+
? normalizePath$3(path$q.relative(config.root, chunk.facadeModuleId))
|
|
39353
39442
|
: chunk.name, '.css');
|
|
39354
39443
|
chunkCSS = resolveAssetUrlsInCss(chunkCSS, cssAssetName);
|
|
39355
39444
|
chunkCSS = await finalizeCss(chunkCSS, true, config);
|
|
@@ -39400,7 +39489,7 @@ function cssPostPlugin(config) {
|
|
|
39400
39489
|
// remove empty css chunks and their imports
|
|
39401
39490
|
if (pureCssChunks.size) {
|
|
39402
39491
|
const emptyChunkFiles = [...pureCssChunks]
|
|
39403
|
-
.map((file) => path$
|
|
39492
|
+
.map((file) => path$q.basename(file))
|
|
39404
39493
|
.join('|')
|
|
39405
39494
|
.replace(/\./g, '\\.');
|
|
39406
39495
|
const emptyChunkRE = new RegExp(opts.format === 'es'
|
|
@@ -39547,15 +39636,15 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39547
39636
|
const postcssOptions = (postcssConfig && postcssConfig.options) || {};
|
|
39548
39637
|
const postcssPlugins = postcssConfig && postcssConfig.plugins ? postcssConfig.plugins.slice() : [];
|
|
39549
39638
|
if (needInlineImport) {
|
|
39550
|
-
postcssPlugins.unshift((await import('./dep-
|
|
39639
|
+
postcssPlugins.unshift((await import('./dep-58d622b1.js').then(function (n) { return n.i; })).default({
|
|
39551
39640
|
async resolve(id, basedir) {
|
|
39552
39641
|
const publicFile = checkPublicFile(id, config);
|
|
39553
39642
|
if (publicFile) {
|
|
39554
39643
|
return publicFile;
|
|
39555
39644
|
}
|
|
39556
|
-
const resolved = await atImportResolvers.css(id, path$
|
|
39645
|
+
const resolved = await atImportResolvers.css(id, path$q.join(basedir, '*'));
|
|
39557
39646
|
if (resolved) {
|
|
39558
|
-
return path$
|
|
39647
|
+
return path$q.resolve(resolved);
|
|
39559
39648
|
}
|
|
39560
39649
|
return id;
|
|
39561
39650
|
}
|
|
@@ -39566,7 +39655,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39566
39655
|
logger: config.logger
|
|
39567
39656
|
}));
|
|
39568
39657
|
if (isModule) {
|
|
39569
|
-
postcssPlugins.unshift((await import('./dep-
|
|
39658
|
+
postcssPlugins.unshift((await import('./dep-e88a0dff.js').then(function (n) { return n.i; })).default({
|
|
39570
39659
|
...modulesOptions,
|
|
39571
39660
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
39572
39661
|
modules = _modules;
|
|
@@ -39578,7 +39667,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39578
39667
|
for (const key of getCssResolversKeys(atImportResolvers)) {
|
|
39579
39668
|
const resolved = await atImportResolvers[key](id);
|
|
39580
39669
|
if (resolved) {
|
|
39581
|
-
return path$
|
|
39670
|
+
return path$q.resolve(resolved);
|
|
39582
39671
|
}
|
|
39583
39672
|
}
|
|
39584
39673
|
return id;
|
|
@@ -39620,7 +39709,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39620
39709
|
else if (message.type === 'dir-dependency') {
|
|
39621
39710
|
// https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
|
|
39622
39711
|
const { dir, glob: globPattern = '**' } = message;
|
|
39623
|
-
const pattern = out.escapePath(normalizePath$3(path$
|
|
39712
|
+
const pattern = out.escapePath(normalizePath$3(path$q.resolve(path$q.dirname(id), dir))) +
|
|
39624
39713
|
`/` +
|
|
39625
39714
|
globPattern;
|
|
39626
39715
|
const files = out.sync(pattern, {
|
|
@@ -39664,14 +39753,14 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
39664
39753
|
};
|
|
39665
39754
|
}
|
|
39666
39755
|
async function formatPostcssSourceMap(rawMap, file) {
|
|
39667
|
-
const inputFileDir = path$
|
|
39756
|
+
const inputFileDir = path$q.dirname(file);
|
|
39668
39757
|
const sources = rawMap.sources.map((source) => {
|
|
39669
39758
|
const cleanSource = cleanUrl(decodeURIComponent(source));
|
|
39670
39759
|
// postcss returns virtual files
|
|
39671
39760
|
if (/^<.+>$/.test(cleanSource)) {
|
|
39672
39761
|
return `\0${cleanSource}`;
|
|
39673
39762
|
}
|
|
39674
|
-
return normalizePath$3(path$
|
|
39763
|
+
return normalizePath$3(path$q.resolve(inputFileDir, cleanSource));
|
|
39675
39764
|
});
|
|
39676
39765
|
return {
|
|
39677
39766
|
file,
|
|
@@ -39957,7 +40046,7 @@ const scss = async (source, root, options, resolvers) => {
|
|
|
39957
40046
|
? {
|
|
39958
40047
|
sourceMap: true,
|
|
39959
40048
|
omitSourceMapUrl: true,
|
|
39960
|
-
sourceMapRoot: path$
|
|
40049
|
+
sourceMapRoot: path$q.dirname(options.filename)
|
|
39961
40050
|
}
|
|
39962
40051
|
: {})
|
|
39963
40052
|
};
|
|
@@ -40000,14 +40089,14 @@ const sass = (source, root, options, aliasResolver) => scss(source, root, {
|
|
|
40000
40089
|
* root file as base.
|
|
40001
40090
|
*/
|
|
40002
40091
|
async function rebaseUrls(file, rootFile, alias) {
|
|
40003
|
-
file = path$
|
|
40092
|
+
file = path$q.resolve(file); // ensure os-specific flashes
|
|
40004
40093
|
// in the same dir, no need to rebase
|
|
40005
|
-
const fileDir = path$
|
|
40006
|
-
const rootDir = path$
|
|
40094
|
+
const fileDir = path$q.dirname(file);
|
|
40095
|
+
const rootDir = path$q.dirname(rootFile);
|
|
40007
40096
|
if (fileDir === rootDir) {
|
|
40008
40097
|
return { file };
|
|
40009
40098
|
}
|
|
40010
|
-
const content =
|
|
40099
|
+
const content = fs$n.readFileSync(file, 'utf-8');
|
|
40011
40100
|
// no url()
|
|
40012
40101
|
const hasUrls = cssUrlRE.test(content);
|
|
40013
40102
|
// data-uri() calls
|
|
@@ -40028,8 +40117,8 @@ async function rebaseUrls(file, rootFile, alias) {
|
|
|
40028
40117
|
return url;
|
|
40029
40118
|
}
|
|
40030
40119
|
}
|
|
40031
|
-
const absolute = path$
|
|
40032
|
-
const relative = path$
|
|
40120
|
+
const absolute = path$q.resolve(fileDir, url);
|
|
40121
|
+
const relative = path$q.relative(rootDir, absolute);
|
|
40033
40122
|
return normalizePath$3(relative);
|
|
40034
40123
|
};
|
|
40035
40124
|
// fix css imports in less such as `@import "foo.css"`
|
|
@@ -40110,7 +40199,7 @@ function createViteLessPlugin(less, rootFile, alias, resolvers) {
|
|
|
40110
40199
|
return false;
|
|
40111
40200
|
}
|
|
40112
40201
|
async loadFile(filename, dir, opts, env) {
|
|
40113
|
-
const resolved = await this.resolvers.less(filename, path$
|
|
40202
|
+
const resolved = await this.resolvers.less(filename, path$q.join(dir, '*'));
|
|
40114
40203
|
if (resolved) {
|
|
40115
40204
|
const result = await rebaseUrls(resolved, this.rootFile, this.alias);
|
|
40116
40205
|
let contents;
|
|
@@ -40118,10 +40207,10 @@ function createViteLessPlugin(less, rootFile, alias, resolvers) {
|
|
|
40118
40207
|
contents = result.contents;
|
|
40119
40208
|
}
|
|
40120
40209
|
else {
|
|
40121
|
-
contents =
|
|
40210
|
+
contents = fs$n.readFileSync(resolved, 'utf-8');
|
|
40122
40211
|
}
|
|
40123
40212
|
return {
|
|
40124
|
-
filename: path$
|
|
40213
|
+
filename: path$q.resolve(resolved),
|
|
40125
40214
|
contents
|
|
40126
40215
|
};
|
|
40127
40216
|
}
|
|
@@ -40146,7 +40235,7 @@ const styl = async (source, root, options) => {
|
|
|
40146
40235
|
const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap, '\n');
|
|
40147
40236
|
// Get preprocessor options.imports dependencies as stylus
|
|
40148
40237
|
// does not return them with its builtin `.deps()` method
|
|
40149
|
-
const importsDeps = (options.imports ?? []).map((dep) => path$
|
|
40238
|
+
const importsDeps = (options.imports ?? []).map((dep) => path$q.resolve(dep));
|
|
40150
40239
|
try {
|
|
40151
40240
|
const ref = nodeStylus(content, options);
|
|
40152
40241
|
if (options.enableSourcemap) {
|
|
@@ -40177,7 +40266,7 @@ function formatStylusSourceMap(mapBefore, root) {
|
|
|
40177
40266
|
if (!mapBefore)
|
|
40178
40267
|
return undefined;
|
|
40179
40268
|
const map = { ...mapBefore };
|
|
40180
|
-
const resolveFromRoot = (p) => normalizePath$3(path$
|
|
40269
|
+
const resolveFromRoot = (p) => normalizePath$3(path$q.resolve(root, p));
|
|
40181
40270
|
if (map.file) {
|
|
40182
40271
|
map.file = resolveFromRoot(map.file);
|
|
40183
40272
|
}
|
|
@@ -40219,15 +40308,203 @@ function isPreProcessor(lang) {
|
|
|
40219
40308
|
return lang && lang in preProcessors;
|
|
40220
40309
|
}
|
|
40221
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
|
+
|
|
40222
40499
|
const debugHmr = createDebugger('vite:hmr');
|
|
40223
40500
|
const normalizedClientDir = normalizePath$3(CLIENT_DIR);
|
|
40224
40501
|
function getShortName(file, root) {
|
|
40225
|
-
return file.startsWith(root + '/') ? path$
|
|
40502
|
+
return file.startsWith(root + '/') ? path$q.posix.relative(root, file) : file;
|
|
40226
40503
|
}
|
|
40227
40504
|
async function handleHMRUpdate(file, server) {
|
|
40228
40505
|
const { ws, config, moduleGraph } = server;
|
|
40229
40506
|
const shortFile = getShortName(file, config.root);
|
|
40230
|
-
const fileName = path$
|
|
40507
|
+
const fileName = path$q.basename(file);
|
|
40231
40508
|
const isConfig = file === config.configFile;
|
|
40232
40509
|
const isConfigDependency = config.configFileDependencies.some((name) => file === name);
|
|
40233
40510
|
const isEnv = config.inlineConfig.envFile !== false &&
|
|
@@ -40235,7 +40512,7 @@ async function handleHMRUpdate(file, server) {
|
|
|
40235
40512
|
if (isConfig || isConfigDependency || isEnv) {
|
|
40236
40513
|
// auto restart server
|
|
40237
40514
|
debugHmr(`[config change] ${colors$1.dim(shortFile)}`);
|
|
40238
|
-
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 });
|
|
40239
40516
|
try {
|
|
40240
40517
|
await server.restart();
|
|
40241
40518
|
}
|
|
@@ -40282,7 +40559,7 @@ async function handleHMRUpdate(file, server) {
|
|
|
40282
40559
|
type: 'full-reload',
|
|
40283
40560
|
path: config.server.middlewareMode
|
|
40284
40561
|
? '*'
|
|
40285
|
-
: '/' + normalizePath$3(path$
|
|
40562
|
+
: '/' + normalizePath$3(path$q.relative(config.root, file))
|
|
40286
40563
|
});
|
|
40287
40564
|
}
|
|
40288
40565
|
else {
|
|
@@ -40341,6 +40618,14 @@ async function handleFileAddUnlink(file, server) {
|
|
|
40341
40618
|
updateModules(getShortName(file, server.config.root), unique(modules), Date.now(), server);
|
|
40342
40619
|
}
|
|
40343
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
|
+
}
|
|
40344
40629
|
function propagateUpdate(node, boundaries, currentChain = [node]) {
|
|
40345
40630
|
// #7561
|
|
40346
40631
|
// if the imports of `node` have not been analyzed, then `node` has not
|
|
@@ -40362,15 +40647,28 @@ function propagateUpdate(node, boundaries, currentChain = [node]) {
|
|
|
40362
40647
|
}
|
|
40363
40648
|
return false;
|
|
40364
40649
|
}
|
|
40365
|
-
|
|
40366
|
-
|
|
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
|
+
});
|
|
40367
40660
|
}
|
|
40368
|
-
|
|
40369
|
-
|
|
40370
|
-
|
|
40371
|
-
|
|
40372
|
-
|
|
40373
|
-
|
|
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
|
+
}
|
|
40374
40672
|
}
|
|
40375
40673
|
for (const importer of node.importers) {
|
|
40376
40674
|
const subChain = currentChain.concat(importer);
|
|
@@ -40381,6 +40679,13 @@ function propagateUpdate(node, boundaries, currentChain = [node]) {
|
|
|
40381
40679
|
});
|
|
40382
40680
|
continue;
|
|
40383
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
|
+
}
|
|
40384
40689
|
if (currentChain.includes(importer)) {
|
|
40385
40690
|
// circular deps is considered dead end
|
|
40386
40691
|
return true;
|
|
@@ -40540,6 +40845,14 @@ function lexAcceptedHmrDeps(code, start, urls) {
|
|
|
40540
40845
|
}
|
|
40541
40846
|
return false;
|
|
40542
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
|
+
}
|
|
40543
40856
|
function error$1(pos) {
|
|
40544
40857
|
const err = new Error(`import.meta.hot.accept() can only accept string literals or an ` +
|
|
40545
40858
|
`Array of string literals.`);
|
|
@@ -40550,14 +40863,14 @@ function error$1(pos) {
|
|
|
40550
40863
|
// change event and sometimes this can be too early and get an empty buffer.
|
|
40551
40864
|
// Poll until the file's modified time has changed before reading again.
|
|
40552
40865
|
async function readModifiedFile(file) {
|
|
40553
|
-
const content =
|
|
40866
|
+
const content = fs$n.readFileSync(file, 'utf-8');
|
|
40554
40867
|
if (!content) {
|
|
40555
|
-
const mtime =
|
|
40868
|
+
const mtime = fs$n.statSync(file).mtimeMs;
|
|
40556
40869
|
await new Promise((r) => {
|
|
40557
40870
|
let n = 0;
|
|
40558
40871
|
const poll = async () => {
|
|
40559
40872
|
n++;
|
|
40560
|
-
const newMtime =
|
|
40873
|
+
const newMtime = fs$n.statSync(file).mtimeMs;
|
|
40561
40874
|
if (newMtime !== mtime || n > 10) {
|
|
40562
40875
|
r(0);
|
|
40563
40876
|
}
|
|
@@ -40567,7 +40880,7 @@ async function readModifiedFile(file) {
|
|
|
40567
40880
|
};
|
|
40568
40881
|
setTimeout(poll, 10);
|
|
40569
40882
|
});
|
|
40570
|
-
return
|
|
40883
|
+
return fs$n.readFileSync(file, 'utf-8');
|
|
40571
40884
|
}
|
|
40572
40885
|
else {
|
|
40573
40886
|
return content;
|
|
@@ -40671,7 +40984,7 @@ function createIsSsrExternal(config) {
|
|
|
40671
40984
|
return processedIds.get(id);
|
|
40672
40985
|
}
|
|
40673
40986
|
const external = !id.startsWith('.') &&
|
|
40674
|
-
!path$
|
|
40987
|
+
!path$q.isAbsolute(id) &&
|
|
40675
40988
|
(isBuiltin(id) || (isConfiguredAsExternal(id) && isValidPackageEntry(id)));
|
|
40676
40989
|
processedIds.set(id, external);
|
|
40677
40990
|
return external;
|
|
@@ -40717,7 +41030,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40717
41030
|
ssrExternals.add(id);
|
|
40718
41031
|
}
|
|
40719
41032
|
else {
|
|
40720
|
-
depsToTrace.add(path$
|
|
41033
|
+
depsToTrace.add(path$q.dirname(pkgPath));
|
|
40721
41034
|
}
|
|
40722
41035
|
continue;
|
|
40723
41036
|
}
|
|
@@ -40733,7 +41046,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40733
41046
|
// trace the dependencies of linked packages
|
|
40734
41047
|
else if (!esmEntry.includes('node_modules')) {
|
|
40735
41048
|
const pkgPath = resolveFrom(`${id}/package.json`, root);
|
|
40736
|
-
depsToTrace.add(path$
|
|
41049
|
+
depsToTrace.add(path$q.dirname(pkgPath));
|
|
40737
41050
|
}
|
|
40738
41051
|
// has separate esm/require entry, assume require entry is cjs
|
|
40739
41052
|
else if (esmEntry !== requireEntry) {
|
|
@@ -40744,7 +41057,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40744
41057
|
// for now, we'll just leave this as is
|
|
40745
41058
|
else if (/\.m?js$/.test(esmEntry)) {
|
|
40746
41059
|
const pkgPath = resolveFrom(`${id}/package.json`, root);
|
|
40747
|
-
const pkgContent =
|
|
41060
|
+
const pkgContent = fs$n.readFileSync(pkgPath, 'utf-8');
|
|
40748
41061
|
if (!pkgContent) {
|
|
40749
41062
|
continue;
|
|
40750
41063
|
}
|
|
@@ -40754,7 +41067,7 @@ function cjsSsrCollectExternals(root, preserveSymlinks, ssrExternals, seen, logg
|
|
|
40754
41067
|
continue;
|
|
40755
41068
|
}
|
|
40756
41069
|
// check if the entry is cjs
|
|
40757
|
-
const content =
|
|
41070
|
+
const content = fs$n.readFileSync(esmEntry, 'utf-8');
|
|
40758
41071
|
if (CJS_CONTENT_RE.test(content)) {
|
|
40759
41072
|
ssrExternals.add(id);
|
|
40760
41073
|
continue;
|
|
@@ -40776,7 +41089,7 @@ function cjsShouldExternalizeForSSR(id, externals) {
|
|
|
40776
41089
|
}
|
|
40777
41090
|
// deep imports, check ext before externalizing - only externalize
|
|
40778
41091
|
// extension-less imports and explicit .js imports
|
|
40779
|
-
if (id.startsWith(e + '/') && (!path$
|
|
41092
|
+
if (id.startsWith(e + '/') && (!path$q.extname(id) || id.endsWith('.js'))) {
|
|
40780
41093
|
return true;
|
|
40781
41094
|
}
|
|
40782
41095
|
});
|
|
@@ -40850,7 +41163,7 @@ function optimizedDepsPlugin(config) {
|
|
|
40850
41163
|
// load hooks to avoid race conditions, once processing is resolved,
|
|
40851
41164
|
// we are sure that the file has been properly save to disk
|
|
40852
41165
|
try {
|
|
40853
|
-
return await promises.readFile(file, 'utf-8');
|
|
41166
|
+
return await promises$2.readFile(file, 'utf-8');
|
|
40854
41167
|
}
|
|
40855
41168
|
catch (e) {
|
|
40856
41169
|
// Outdated non-entry points (CHUNK), loaded after a rerun
|
|
@@ -40911,7 +41224,7 @@ function optimizedDepsBuildPlugin(config) {
|
|
|
40911
41224
|
// load hooks to avoid race conditions, once processing is resolved,
|
|
40912
41225
|
// we are sure that the file has been properly save to disk
|
|
40913
41226
|
try {
|
|
40914
|
-
return await promises.readFile(file, 'utf-8');
|
|
41227
|
+
return await promises$2.readFile(file, 'utf-8');
|
|
40915
41228
|
}
|
|
40916
41229
|
catch (e) {
|
|
40917
41230
|
// Outdated non-entry points (CHUNK), loaded after a rerun
|
|
@@ -40953,6 +41266,40 @@ function markExplicitImport(url) {
|
|
|
40953
41266
|
}
|
|
40954
41267
|
return url;
|
|
40955
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
|
+
}
|
|
40956
41303
|
/**
|
|
40957
41304
|
* Server-only plugin that lexes, resolves, rewrites and analyzes url imports.
|
|
40958
41305
|
*
|
|
@@ -40984,7 +41331,8 @@ function markExplicitImport(url) {
|
|
|
40984
41331
|
*/
|
|
40985
41332
|
function importAnalysisPlugin(config) {
|
|
40986
41333
|
const { root, base } = config;
|
|
40987
|
-
const clientPublicPath = path$
|
|
41334
|
+
const clientPublicPath = path$q.posix.join(base, CLIENT_PUBLIC_PATH);
|
|
41335
|
+
const enablePartialAccept = config.experimental?.hmrPartialAccept;
|
|
40988
41336
|
let server;
|
|
40989
41337
|
return {
|
|
40990
41338
|
name: 'vite:import-analysis',
|
|
@@ -41006,9 +41354,10 @@ function importAnalysisPlugin(config) {
|
|
|
41006
41354
|
const start = performance.now();
|
|
41007
41355
|
await init;
|
|
41008
41356
|
let imports = [];
|
|
41357
|
+
let exports = [];
|
|
41009
41358
|
source = stripBomTag(source);
|
|
41010
41359
|
try {
|
|
41011
|
-
imports = parse$g(source)
|
|
41360
|
+
[imports, exports] = parse$g(source);
|
|
41012
41361
|
}
|
|
41013
41362
|
catch (e) {
|
|
41014
41363
|
const isVue = importer.endsWith('.vue');
|
|
@@ -41017,7 +41366,7 @@ function importAnalysisPlugin(config) {
|
|
|
41017
41366
|
? `Install @vitejs/plugin-vue to handle .vue files.`
|
|
41018
41367
|
: maybeJSX
|
|
41019
41368
|
? `If you are using JSX, make sure to name the file with the .jsx or .tsx extension.`
|
|
41020
|
-
: `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.`;
|
|
41021
41370
|
this.error(`Failed to parse source for import analysis because the content ` +
|
|
41022
41371
|
`contains invalid JS syntax. ` +
|
|
41023
41372
|
msg, e.idx);
|
|
@@ -41049,7 +41398,12 @@ function importAnalysisPlugin(config) {
|
|
|
41049
41398
|
const importedUrls = new Set();
|
|
41050
41399
|
const staticImportedUrls = new Set();
|
|
41051
41400
|
const acceptedUrls = new Set();
|
|
41052
|
-
|
|
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);
|
|
41053
41407
|
const normalizeUrl = async (url, pos) => {
|
|
41054
41408
|
if (base !== '/' && url.startsWith(base)) {
|
|
41055
41409
|
url = url.replace(base, '/');
|
|
@@ -41078,7 +41432,7 @@ function importAnalysisPlugin(config) {
|
|
|
41078
41432
|
if (ssr) {
|
|
41079
41433
|
return [url, url];
|
|
41080
41434
|
}
|
|
41081
|
-
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);
|
|
41082
41436
|
}
|
|
41083
41437
|
const isRelative = url.startsWith('.');
|
|
41084
41438
|
const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer);
|
|
@@ -41089,10 +41443,10 @@ function importAnalysisPlugin(config) {
|
|
|
41089
41443
|
url = resolved.id.slice(root.length);
|
|
41090
41444
|
}
|
|
41091
41445
|
else if (resolved.id.startsWith(getDepsCacheDirPrefix(config)) ||
|
|
41092
|
-
|
|
41446
|
+
fs$n.existsSync(cleanUrl(resolved.id))) {
|
|
41093
41447
|
// an optimized deps may not yet exists in the filesystem, or
|
|
41094
41448
|
// a regular file exists but is out of root: rewrite to absolute /@fs/ paths
|
|
41095
|
-
url = path$
|
|
41449
|
+
url = path$q.posix.join(FS_PREFIX + resolved.id);
|
|
41096
41450
|
}
|
|
41097
41451
|
else {
|
|
41098
41452
|
url = resolved.id;
|
|
@@ -41157,7 +41511,11 @@ function importAnalysisPlugin(config) {
|
|
|
41157
41511
|
hasHMR = true;
|
|
41158
41512
|
if (source.slice(end + 4, end + 11) === '.accept') {
|
|
41159
41513
|
// further analyze accepted modules
|
|
41160
|
-
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)) {
|
|
41161
41519
|
isSelfAccepting = true;
|
|
41162
41520
|
}
|
|
41163
41521
|
}
|
|
@@ -41248,6 +41606,9 @@ function importAnalysisPlugin(config) {
|
|
|
41248
41606
|
// make sure to normalize away base
|
|
41249
41607
|
const urlWithoutBase = url.replace(base, '/');
|
|
41250
41608
|
importedUrls.add(urlWithoutBase);
|
|
41609
|
+
if (enablePartialAccept && importedBindings) {
|
|
41610
|
+
extractImportedBindings(resolvedId, source, imports[index], importedBindings);
|
|
41611
|
+
}
|
|
41251
41612
|
if (!isDynamicImport) {
|
|
41252
41613
|
// for pre-transforming
|
|
41253
41614
|
staticImportedUrls.add({ url: urlWithoutBase, id: resolvedId });
|
|
@@ -41297,9 +41658,11 @@ function importAnalysisPlugin(config) {
|
|
|
41297
41658
|
if (hasHMR && !ssr) {
|
|
41298
41659
|
debugHmr(`${isSelfAccepting
|
|
41299
41660
|
? `[self-accepts]`
|
|
41300
|
-
:
|
|
41301
|
-
? `[accepts-
|
|
41302
|
-
:
|
|
41661
|
+
: isPartiallySelfAccepting
|
|
41662
|
+
? `[accepts-exports]`
|
|
41663
|
+
: acceptedUrls.size
|
|
41664
|
+
? `[accepts-deps]`
|
|
41665
|
+
: `[detected api usage]`} ${prettyImporter}`);
|
|
41303
41666
|
// inject hot context
|
|
41304
41667
|
str().prepend(`import { createHotContext as __vite__createHotContext } from "${clientPublicPath}";` +
|
|
41305
41668
|
`import.meta.hot = __vite__createHotContext(${JSON.stringify(importerModule.url)});`);
|
|
@@ -41331,7 +41694,15 @@ function importAnalysisPlugin(config) {
|
|
|
41331
41694
|
if (ssr && importerModule.isSelfAccepting) {
|
|
41332
41695
|
isSelfAccepting = true;
|
|
41333
41696
|
}
|
|
41334
|
-
|
|
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);
|
|
41335
41706
|
if (hasHMR && prunedImports) {
|
|
41336
41707
|
handlePrunedModules(prunedImports, server);
|
|
41337
41708
|
}
|
|
@@ -41470,7 +41841,6 @@ function transformCjsImport(importExp, url, rawUrl, importIndex) {
|
|
|
41470
41841
|
}
|
|
41471
41842
|
}
|
|
41472
41843
|
|
|
41473
|
-
// import fs from 'fs'
|
|
41474
41844
|
/**
|
|
41475
41845
|
* A flag for injected helpers. This flag will be set to `false` if the output
|
|
41476
41846
|
* target is not native es - so that injected helper logic can be conditionally
|
|
@@ -41542,13 +41912,16 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41542
41912
|
const ssr = !!config.build.ssr;
|
|
41543
41913
|
const isWorker = config.isWorker;
|
|
41544
41914
|
const insertPreload = !(ssr || !!config.build.lib || isWorker);
|
|
41545
|
-
const
|
|
41915
|
+
const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
|
|
41916
|
+
const relativePreloadUrls = !(assetsBase.url || assetsBase.runtime);
|
|
41546
41917
|
const scriptRel = config.build.polyfillModulePreload
|
|
41547
41918
|
? `'modulepreload'`
|
|
41548
41919
|
: `(${detectScriptRel.toString()})()`;
|
|
41549
|
-
const assetsURL =
|
|
41920
|
+
const assetsURL = relativePreloadUrls
|
|
41550
41921
|
? `function(dep,importerUrl) { return new URL(dep, importerUrl).href }`
|
|
41551
|
-
: `function(dep) { return ${
|
|
41922
|
+
: `function(dep) { return ${assetsBase.runtime
|
|
41923
|
+
? assetsBase.runtime('dep')
|
|
41924
|
+
: `${JSON.stringify(assetsBase.url ?? config.base)}+dep`}}`;
|
|
41552
41925
|
const preloadCode = `const scriptRel = ${scriptRel};const assetsURL = ${assetsURL};const seen = {};export const ${preloadMethod} = ${preload.toString()}`;
|
|
41553
41926
|
return {
|
|
41554
41927
|
name: 'vite:build-import-analysis',
|
|
@@ -41605,7 +41978,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41605
41978
|
if (ssr) {
|
|
41606
41979
|
return [url, url];
|
|
41607
41980
|
}
|
|
41608
|
-
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);
|
|
41609
41982
|
}
|
|
41610
41983
|
// normalize all imports into resolved URLs
|
|
41611
41984
|
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
|
|
@@ -41630,7 +42003,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41630
42003
|
if (isDynamicImport && insertPreload) {
|
|
41631
42004
|
needPreloadHelper = true;
|
|
41632
42005
|
str().prependLeft(expStart, `${preloadMethod}(() => `);
|
|
41633
|
-
str().appendRight(expEnd, `,${isModernFlag}?"${preloadMarker}":void 0${
|
|
42006
|
+
str().appendRight(expEnd, `,${isModernFlag}?"${preloadMarker}":void 0${relativePreloadUrls ? ',import.meta.url' : ''})`);
|
|
41634
42007
|
}
|
|
41635
42008
|
if (!depsOptimizer) {
|
|
41636
42009
|
continue;
|
|
@@ -41772,7 +42145,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41772
42145
|
}
|
|
41773
42146
|
}
|
|
41774
42147
|
};
|
|
41775
|
-
const normalizedFile = path$
|
|
42148
|
+
const normalizedFile = path$q.posix.join(path$q.posix.dirname(chunk.fileName), url);
|
|
41776
42149
|
addDeps(normalizedFile);
|
|
41777
42150
|
}
|
|
41778
42151
|
let markerStartPos = code.indexOf(preloadMarkerWithQuote, end);
|
|
@@ -41789,8 +42162,8 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41789
42162
|
// main chunk is removed
|
|
41790
42163
|
(hasRemovedPureCssChunk && deps.size > 0)
|
|
41791
42164
|
? `[${[...deps]
|
|
41792
|
-
.map((d) => JSON.stringify(
|
|
41793
|
-
? path$
|
|
42165
|
+
.map((d) => JSON.stringify(relativePreloadUrls
|
|
42166
|
+
? path$q.relative(path$q.dirname(file), d)
|
|
41794
42167
|
: d))
|
|
41795
42168
|
.join(',')}]`
|
|
41796
42169
|
: `[]`, { contentOnly: true });
|
|
@@ -41828,7 +42201,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
41828
42201
|
function ssrManifestPlugin(config) {
|
|
41829
42202
|
// module id => preload assets mapping
|
|
41830
42203
|
const ssrManifest = {};
|
|
41831
|
-
const base = config.base;
|
|
42204
|
+
const base = config.base; // TODO:base
|
|
41832
42205
|
return {
|
|
41833
42206
|
name: 'vite:ssr-manifest',
|
|
41834
42207
|
generateBundle(_options, bundle) {
|
|
@@ -41878,14 +42251,14 @@ function ssrManifestPlugin(config) {
|
|
|
41878
42251
|
const chunk = bundle[filename];
|
|
41879
42252
|
if (chunk) {
|
|
41880
42253
|
chunk.viteMetadata.importedCss.forEach((file) => {
|
|
41881
|
-
deps.push(join$
|
|
42254
|
+
deps.push(join$2(base, file)); // TODO:base
|
|
41882
42255
|
});
|
|
41883
42256
|
chunk.imports.forEach(addDeps);
|
|
41884
42257
|
}
|
|
41885
42258
|
};
|
|
41886
|
-
const normalizedFile = normalizePath$3(join$
|
|
42259
|
+
const normalizedFile = normalizePath$3(join$2(dirname$2(chunk.fileName), url.slice(1, -1)));
|
|
41887
42260
|
addDeps(normalizedFile);
|
|
41888
|
-
ssrManifest[basename$
|
|
42261
|
+
ssrManifest[basename$2(name)] = deps;
|
|
41889
42262
|
}
|
|
41890
42263
|
}
|
|
41891
42264
|
}
|
|
@@ -41946,7 +42319,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
41946
42319
|
}
|
|
41947
42320
|
}
|
|
41948
42321
|
const url = rawUrl.slice(1, -1);
|
|
41949
|
-
const file = path$
|
|
42322
|
+
const file = path$q.resolve(path$q.dirname(id), url);
|
|
41950
42323
|
// Get final asset URL. Catch error if the file does not exist,
|
|
41951
42324
|
// in which we can resort to the initial URL and let it resolve in runtime
|
|
41952
42325
|
const builtUrl = await fileToUrl(file, config, this).catch(() => {
|
|
@@ -41992,10 +42365,10 @@ function loadFallbackPlugin() {
|
|
|
41992
42365
|
async load(id) {
|
|
41993
42366
|
try {
|
|
41994
42367
|
// if we don't add `await` here, we couldn't catch the error in readFile
|
|
41995
|
-
return await promises.readFile(cleanUrl(id), 'utf-8');
|
|
42368
|
+
return await promises$2.readFile(cleanUrl(id), 'utf-8');
|
|
41996
42369
|
}
|
|
41997
42370
|
catch (e) {
|
|
41998
|
-
return promises.readFile(id, 'utf-8');
|
|
42371
|
+
return promises$2.readFile(id, 'utf-8');
|
|
41999
42372
|
}
|
|
42000
42373
|
}
|
|
42001
42374
|
};
|
|
@@ -42016,7 +42389,7 @@ function ensureWatchPlugin() {
|
|
|
42016
42389
|
};
|
|
42017
42390
|
}
|
|
42018
42391
|
|
|
42019
|
-
function resolveBuildOptions(raw) {
|
|
42392
|
+
function resolveBuildOptions(raw, isBuild, logger) {
|
|
42020
42393
|
const resolved = {
|
|
42021
42394
|
target: 'modules',
|
|
42022
42395
|
polyfillModulePreload: true,
|
|
@@ -42135,7 +42508,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42135
42508
|
const ssr = !!options.ssr;
|
|
42136
42509
|
const libOptions = options.lib;
|
|
42137
42510
|
config.logger.info(colors$1.cyan(`vite v${VERSION} ${colors$1.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
|
|
42138
|
-
const resolve = (p) => path$
|
|
42511
|
+
const resolve = (p) => path$q.resolve(config.root, p);
|
|
42139
42512
|
const input = libOptions
|
|
42140
42513
|
? resolve(libOptions.entry)
|
|
42141
42514
|
: typeof options.ssr === 'string'
|
|
@@ -42193,9 +42566,10 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42193
42566
|
`This is deprecated and will override all Vite.js default output options. ` +
|
|
42194
42567
|
`Please use "rollupOptions.output" instead.`);
|
|
42195
42568
|
}
|
|
42569
|
+
const ssrWorkerBuild = ssr && config.ssr?.target !== 'webworker';
|
|
42196
42570
|
const cjsSsrBuild = ssr && config.ssr?.format === 'cjs';
|
|
42197
42571
|
const format = output.format || (cjsSsrBuild ? 'cjs' : 'es');
|
|
42198
|
-
const jsExt =
|
|
42572
|
+
const jsExt = ssrWorkerBuild || libOptions
|
|
42199
42573
|
? resolveOutputJsExtension(format, getPkgJson(config.root)?.type)
|
|
42200
42574
|
: 'js';
|
|
42201
42575
|
return {
|
|
@@ -42213,16 +42587,16 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42213
42587
|
? `[name].${jsExt}`
|
|
42214
42588
|
: libOptions
|
|
42215
42589
|
? resolveLibFilename(libOptions, format, config.root, jsExt)
|
|
42216
|
-
: path$
|
|
42590
|
+
: path$q.posix.join(options.assetsDir, `[name].[hash].js`),
|
|
42217
42591
|
chunkFileNames: libOptions
|
|
42218
42592
|
? `[name].[hash].${jsExt}`
|
|
42219
|
-
: path$
|
|
42593
|
+
: path$q.posix.join(options.assetsDir, `[name].[hash].js`),
|
|
42220
42594
|
assetFileNames: libOptions
|
|
42221
42595
|
? `[name].[ext]`
|
|
42222
|
-
: path$
|
|
42596
|
+
: path$q.posix.join(options.assetsDir, `[name].[hash].[ext]`),
|
|
42223
42597
|
inlineDynamicImports: output.format === 'umd' ||
|
|
42224
42598
|
output.format === 'iife' ||
|
|
42225
|
-
(
|
|
42599
|
+
(ssrWorkerBuild && typeof input === 'string'),
|
|
42226
42600
|
...output
|
|
42227
42601
|
};
|
|
42228
42602
|
};
|
|
@@ -42303,7 +42677,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
42303
42677
|
}
|
|
42304
42678
|
}
|
|
42305
42679
|
function prepareOutDir(outDir, emptyOutDir, config) {
|
|
42306
|
-
if (
|
|
42680
|
+
if (fs$n.existsSync(outDir)) {
|
|
42307
42681
|
if (emptyOutDir == null &&
|
|
42308
42682
|
!normalizePath$3(outDir).startsWith(config.root + '/')) {
|
|
42309
42683
|
// warn if outDir is outside of root
|
|
@@ -42314,7 +42688,7 @@ function prepareOutDir(outDir, emptyOutDir, config) {
|
|
|
42314
42688
|
emptyDir(outDir, ['.git']);
|
|
42315
42689
|
}
|
|
42316
42690
|
}
|
|
42317
|
-
if (config.publicDir &&
|
|
42691
|
+
if (config.publicDir && fs$n.existsSync(config.publicDir)) {
|
|
42318
42692
|
copyDir(config.publicDir, outDir);
|
|
42319
42693
|
}
|
|
42320
42694
|
}
|
|
@@ -42405,9 +42779,9 @@ function onRollupWarning(warning, warn, config) {
|
|
|
42405
42779
|
async function cjsSsrResolveExternal(config, user) {
|
|
42406
42780
|
// see if we have cached deps data available
|
|
42407
42781
|
let knownImports;
|
|
42408
|
-
const dataPath = path$
|
|
42782
|
+
const dataPath = path$q.join(getDepsCacheDir(config, false), '_metadata.json');
|
|
42409
42783
|
try {
|
|
42410
|
-
const data = JSON.parse(
|
|
42784
|
+
const data = JSON.parse(fs$n.readFileSync(dataPath, 'utf-8'));
|
|
42411
42785
|
knownImports = Object.keys(data.optimized);
|
|
42412
42786
|
}
|
|
42413
42787
|
catch (e) { }
|
|
@@ -42480,6 +42854,39 @@ function wrapSsrTransform(fn) {
|
|
|
42480
42854
|
function injectSsrFlag(options) {
|
|
42481
42855
|
return { ...(options ?? {}), ssr: true };
|
|
42482
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
|
+
}
|
|
42483
42890
|
|
|
42484
42891
|
var build$1 = {
|
|
42485
42892
|
__proto__: null,
|
|
@@ -42487,7 +42894,8 @@ var build$1 = {
|
|
|
42487
42894
|
resolveBuildPlugins: resolveBuildPlugins,
|
|
42488
42895
|
build: build,
|
|
42489
42896
|
resolveLibFilename: resolveLibFilename,
|
|
42490
|
-
onRollupWarning: onRollupWarning
|
|
42897
|
+
onRollupWarning: onRollupWarning,
|
|
42898
|
+
resolveBuildAdvancedBaseConfig: resolveBuildAdvancedBaseConfig
|
|
42491
42899
|
};
|
|
42492
42900
|
|
|
42493
42901
|
var src = {exports: {}};
|
|
@@ -43048,8 +43456,8 @@ var node = {exports: {}};
|
|
|
43048
43456
|
*/
|
|
43049
43457
|
|
|
43050
43458
|
(function (module, exports) {
|
|
43051
|
-
var tty = require$$0$
|
|
43052
|
-
var util = require$$0$
|
|
43459
|
+
var tty = require$$0$3;
|
|
43460
|
+
var util = require$$0$5;
|
|
43053
43461
|
|
|
43054
43462
|
/**
|
|
43055
43463
|
* This is the Node.js implementation of `debug()`.
|
|
@@ -43229,7 +43637,7 @@ function createWritableStdioStream (fd) {
|
|
|
43229
43637
|
break;
|
|
43230
43638
|
|
|
43231
43639
|
case 'FILE':
|
|
43232
|
-
var fs =
|
|
43640
|
+
var fs = require$$0__default;
|
|
43233
43641
|
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
|
43234
43642
|
stream._type = 'fs';
|
|
43235
43643
|
break;
|
|
@@ -43746,7 +44154,7 @@ var parseurl$1 = {exports: {}};
|
|
|
43746
44154
|
* @private
|
|
43747
44155
|
*/
|
|
43748
44156
|
|
|
43749
|
-
var url$3 = require$$0$
|
|
44157
|
+
var url$3 = require$$0$9;
|
|
43750
44158
|
var parse$9 = url$3.parse;
|
|
43751
44159
|
var Url = url$3.Url;
|
|
43752
44160
|
|
|
@@ -44508,7 +44916,7 @@ module.exports = function(a, b){
|
|
|
44508
44916
|
*/
|
|
44509
44917
|
|
|
44510
44918
|
var debug$4 = src.exports('connect:dispatcher');
|
|
44511
|
-
var EventEmitter$3 = require$$0$
|
|
44919
|
+
var EventEmitter$3 = require$$0$4.EventEmitter;
|
|
44512
44920
|
var finalhandler = finalhandler_1;
|
|
44513
44921
|
var http$4 = require$$1$3;
|
|
44514
44922
|
var merge = utilsMerge.exports;
|
|
@@ -45254,10 +45662,10 @@ var corsMiddleware = lib$2.exports;
|
|
|
45254
45662
|
|
|
45255
45663
|
var chokidar = {};
|
|
45256
45664
|
|
|
45257
|
-
const fs$b =
|
|
45258
|
-
const { Readable } = require$$0$
|
|
45665
|
+
const fs$b = require$$0__default;
|
|
45666
|
+
const { Readable } = require$$0$6;
|
|
45259
45667
|
const sysPath$3 = path$p;
|
|
45260
|
-
const { promisify: promisify$3 } = require$$0$
|
|
45668
|
+
const { promisify: promisify$3 } = require$$0$5;
|
|
45261
45669
|
const picomatch$1 = picomatch$3;
|
|
45262
45670
|
|
|
45263
45671
|
const readdir$1 = promisify$3(fs$b.readdir);
|
|
@@ -46020,9 +46428,9 @@ exports.isLinux = platform === 'linux';
|
|
|
46020
46428
|
exports.isIBMi = os.type() === 'OS400';
|
|
46021
46429
|
}(constants$1));
|
|
46022
46430
|
|
|
46023
|
-
const fs$a =
|
|
46431
|
+
const fs$a = require$$0__default;
|
|
46024
46432
|
const sysPath$2 = path$p;
|
|
46025
|
-
const { promisify: promisify$2 } = require$$0$
|
|
46433
|
+
const { promisify: promisify$2 } = require$$0$5;
|
|
46026
46434
|
const isBinaryPath = isBinaryPath$1;
|
|
46027
46435
|
const {
|
|
46028
46436
|
isWindows: isWindows$2,
|
|
@@ -46665,9 +47073,9 @@ var nodefsHandler = NodeFsHandler$1;
|
|
|
46665
47073
|
|
|
46666
47074
|
var fseventsHandler = {exports: {}};
|
|
46667
47075
|
|
|
46668
|
-
const fs$9 =
|
|
47076
|
+
const fs$9 = require$$0__default;
|
|
46669
47077
|
const sysPath$1 = path$p;
|
|
46670
|
-
const { promisify: promisify$1 } = require$$0$
|
|
47078
|
+
const { promisify: promisify$1 } = require$$0$5;
|
|
46671
47079
|
|
|
46672
47080
|
let fsevents;
|
|
46673
47081
|
try {
|
|
@@ -47188,10 +47596,10 @@ async _addToFsEvents(path, transform, forceAdd, priorDepth) {
|
|
|
47188
47596
|
fseventsHandler.exports = FsEventsHandler$1;
|
|
47189
47597
|
fseventsHandler.exports.canUse = canUse;
|
|
47190
47598
|
|
|
47191
|
-
const { EventEmitter: EventEmitter$2 } = require$$0$
|
|
47192
|
-
const fs$8 =
|
|
47599
|
+
const { EventEmitter: EventEmitter$2 } = require$$0$4;
|
|
47600
|
+
const fs$8 = require$$0__default;
|
|
47193
47601
|
const sysPath = path$p;
|
|
47194
|
-
const { promisify } = require$$0$
|
|
47602
|
+
const { promisify } = require$$0$5;
|
|
47195
47603
|
const readdirp = readdirp_1;
|
|
47196
47604
|
const anymatch = anymatch$2.exports.default;
|
|
47197
47605
|
const globParent = globParent$2;
|
|
@@ -48588,7 +48996,7 @@ var getArgs = function getArgumentsForPosition (
|
|
|
48588
48996
|
* Modified by Yuxi Evan You
|
|
48589
48997
|
*/
|
|
48590
48998
|
|
|
48591
|
-
const fs$7 =
|
|
48999
|
+
const fs$7 = require$$0__default;
|
|
48592
49000
|
const os$2 = require$$1;
|
|
48593
49001
|
const path$6 = path$p;
|
|
48594
49002
|
const colors = picocolors.exports;
|
|
@@ -48717,7 +49125,7 @@ function launchEditor (file, specifiedEditor, onErrorCallback) {
|
|
|
48717
49125
|
|
|
48718
49126
|
var launchEditor_1 = launchEditor;
|
|
48719
49127
|
|
|
48720
|
-
const url$2 = require$$0$
|
|
49128
|
+
const url$2 = require$$0$9;
|
|
48721
49129
|
const path$5 = path$p;
|
|
48722
49130
|
const launch = launchEditor_1;
|
|
48723
49131
|
|
|
@@ -48788,7 +49196,7 @@ async function resolveHttpsConfig(https, cacheDir) {
|
|
|
48788
49196
|
function readFileIfExists(value) {
|
|
48789
49197
|
if (typeof value === 'string') {
|
|
48790
49198
|
try {
|
|
48791
|
-
return
|
|
49199
|
+
return fs$n.readFileSync(path$q.resolve(value));
|
|
48792
49200
|
}
|
|
48793
49201
|
catch (e) {
|
|
48794
49202
|
return value;
|
|
@@ -48797,11 +49205,11 @@ function readFileIfExists(value) {
|
|
|
48797
49205
|
return value;
|
|
48798
49206
|
}
|
|
48799
49207
|
async function getCertificate(cacheDir) {
|
|
48800
|
-
const cachePath = path$
|
|
49208
|
+
const cachePath = path$q.join(cacheDir, '_cert.pem');
|
|
48801
49209
|
try {
|
|
48802
49210
|
const [stat, content] = await Promise.all([
|
|
48803
|
-
promises.stat(cachePath),
|
|
48804
|
-
promises.readFile(cachePath, 'utf8')
|
|
49211
|
+
promises$2.stat(cachePath),
|
|
49212
|
+
promises$2.readFile(cachePath, 'utf8')
|
|
48805
49213
|
]);
|
|
48806
49214
|
if (Date.now() - stat.ctime.valueOf() > 30 * 24 * 60 * 60 * 1000) {
|
|
48807
49215
|
throw new Error('cache is outdated.');
|
|
@@ -48809,10 +49217,10 @@ async function getCertificate(cacheDir) {
|
|
|
48809
49217
|
return content;
|
|
48810
49218
|
}
|
|
48811
49219
|
catch {
|
|
48812
|
-
const content = (await import('./dep-
|
|
48813
|
-
promises
|
|
49220
|
+
const content = (await import('./dep-f75aea7c.js')).createCertificate();
|
|
49221
|
+
promises$2
|
|
48814
49222
|
.mkdir(cacheDir, { recursive: true })
|
|
48815
|
-
.then(() => promises.writeFile(cachePath, content))
|
|
49223
|
+
.then(() => promises$2.writeFile(cachePath, content))
|
|
48816
49224
|
.catch(() => { });
|
|
48817
49225
|
return content;
|
|
48818
49226
|
}
|
|
@@ -49058,7 +49466,7 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
49058
49466
|
// #3087 dynamic import vars is ignored at rewrite import path,
|
|
49059
49467
|
// so here need process relative path
|
|
49060
49468
|
if (dep[0] === '.') {
|
|
49061
|
-
dep = path$
|
|
49469
|
+
dep = path$q.posix.resolve(path$q.dirname(url), dep);
|
|
49062
49470
|
}
|
|
49063
49471
|
return ssrImport(dep);
|
|
49064
49472
|
};
|
|
@@ -49114,7 +49522,7 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
49114
49522
|
// Use the Vite resolver only for bare imports while skipping
|
|
49115
49523
|
// any absolute paths, built-in modules and binary modules.
|
|
49116
49524
|
if (!bareImportRE.test(id) ||
|
|
49117
|
-
path$
|
|
49525
|
+
path$q.isAbsolute(id) ||
|
|
49118
49526
|
isBuiltin(id) ||
|
|
49119
49527
|
id.endsWith('.node')) {
|
|
49120
49528
|
return nodeResolve(id, parent, isMain, options);
|
|
@@ -49124,7 +49532,7 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
49124
49532
|
if (resolved) {
|
|
49125
49533
|
// hookNodeResolve must use platform-specific path.normalize
|
|
49126
49534
|
// to be compatible with dynamicImport (#6080)
|
|
49127
|
-
resolved = path$
|
|
49535
|
+
resolved = path$q.normalize(resolved);
|
|
49128
49536
|
}
|
|
49129
49537
|
return resolved;
|
|
49130
49538
|
}
|
|
@@ -49374,7 +49782,7 @@ class Limiter$1 {
|
|
|
49374
49782
|
|
|
49375
49783
|
var limiter = Limiter$1;
|
|
49376
49784
|
|
|
49377
|
-
const zlib =
|
|
49785
|
+
const zlib = require$$0$a;
|
|
49378
49786
|
|
|
49379
49787
|
const bufferUtil = bufferUtil$1.exports;
|
|
49380
49788
|
const Limiter = limiter;
|
|
@@ -50010,7 +50418,7 @@ if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
|
50010
50418
|
}
|
|
50011
50419
|
}
|
|
50012
50420
|
|
|
50013
|
-
const { Writable: Writable$1 } = require$$0$
|
|
50421
|
+
const { Writable: Writable$1 } = require$$0$6;
|
|
50014
50422
|
|
|
50015
50423
|
const PerMessageDeflate$3 = permessageDeflate;
|
|
50016
50424
|
const {
|
|
@@ -51570,13 +51978,13 @@ var extension$1 = { format: format$1, parse: parse$6 };
|
|
|
51570
51978
|
|
|
51571
51979
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
|
|
51572
51980
|
|
|
51573
|
-
const EventEmitter$1 = require$$0$
|
|
51981
|
+
const EventEmitter$1 = require$$0$4;
|
|
51574
51982
|
const https$2 = require$$1$4;
|
|
51575
51983
|
const http$3 = require$$1$3;
|
|
51576
51984
|
const net = require$$3$1;
|
|
51577
51985
|
const tls = require$$4;
|
|
51578
51986
|
const { randomBytes, createHash: createHash$1 } = require$$1$2;
|
|
51579
|
-
const { URL: URL$2 } = require$$0$
|
|
51987
|
+
const { URL: URL$2 } = require$$0$9;
|
|
51580
51988
|
|
|
51581
51989
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
51582
51990
|
const Receiver = receiver;
|
|
@@ -52925,7 +53333,7 @@ var subprotocol$1 = { parse: parse$4 };
|
|
|
52925
53333
|
|
|
52926
53334
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */
|
|
52927
53335
|
|
|
52928
|
-
const EventEmitter = require$$0$
|
|
53336
|
+
const EventEmitter = require$$0$4;
|
|
52929
53337
|
const http$2 = require$$1$3;
|
|
52930
53338
|
const { createHash } = require$$1$2;
|
|
52931
53339
|
|
|
@@ -53652,16 +54060,16 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
53652
54060
|
|
|
53653
54061
|
// this middleware is only active when (config.base !== '/')
|
|
53654
54062
|
function baseMiddleware({ config }) {
|
|
53655
|
-
const
|
|
54063
|
+
const devBase = config.base;
|
|
53656
54064
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
53657
54065
|
return function viteBaseMiddleware(req, res, next) {
|
|
53658
54066
|
const url = req.url;
|
|
53659
54067
|
const parsed = new URL(url, 'http://vitejs.dev');
|
|
53660
54068
|
const path = parsed.pathname || '/';
|
|
53661
|
-
if (path.startsWith(
|
|
54069
|
+
if (path.startsWith(devBase)) {
|
|
53662
54070
|
// rewrite url to remove base.. this ensures that other middleware does
|
|
53663
54071
|
// not need to consider base being prepended or not
|
|
53664
|
-
req.url = url.replace(
|
|
54072
|
+
req.url = url.replace(devBase, '/');
|
|
53665
54073
|
return next();
|
|
53666
54074
|
}
|
|
53667
54075
|
// skip redirect and error fallback on middleware mode, #4057
|
|
@@ -53671,18 +54079,18 @@ function baseMiddleware({ config }) {
|
|
|
53671
54079
|
if (path === '/' || path === '/index.html') {
|
|
53672
54080
|
// redirect root visit to based url with search and hash
|
|
53673
54081
|
res.writeHead(302, {
|
|
53674
|
-
Location:
|
|
54082
|
+
Location: devBase + (parsed.search || '') + (parsed.hash || '')
|
|
53675
54083
|
});
|
|
53676
54084
|
res.end();
|
|
53677
54085
|
return;
|
|
53678
54086
|
}
|
|
53679
54087
|
else if (req.headers.accept?.includes('text/html')) {
|
|
53680
54088
|
// non-based page visit
|
|
53681
|
-
const redirectPath =
|
|
54089
|
+
const redirectPath = devBase + url.slice(1);
|
|
53682
54090
|
res.writeHead(404, {
|
|
53683
54091
|
'Content-Type': 'text/html'
|
|
53684
54092
|
});
|
|
53685
|
-
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} - ` +
|
|
53686
54094
|
`did you mean to visit <a href="${redirectPath}">${redirectPath}</a> instead?`);
|
|
53687
54095
|
return;
|
|
53688
54096
|
}
|
|
@@ -54073,8 +54481,8 @@ var requiresPort = function required(port, protocol) {
|
|
|
54073
54481
|
|
|
54074
54482
|
(function (exports) {
|
|
54075
54483
|
var common = exports,
|
|
54076
|
-
url = require$$0$
|
|
54077
|
-
extend = require$$0$
|
|
54484
|
+
url = require$$0$9,
|
|
54485
|
+
extend = require$$0$5._extend,
|
|
54078
54486
|
required = requiresPort;
|
|
54079
54487
|
|
|
54080
54488
|
var upgradeHeader = /(^|,)\s*upgrade\s*($|,)/i,
|
|
@@ -54321,7 +54729,7 @@ function hasPort(host) {
|
|
|
54321
54729
|
return !!~host.indexOf(':');
|
|
54322
54730
|
}}(common$3));
|
|
54323
54731
|
|
|
54324
|
-
var url$1 = require$$0$
|
|
54732
|
+
var url$1 = require$$0$9,
|
|
54325
54733
|
common$2 = common$3;
|
|
54326
54734
|
|
|
54327
54735
|
|
|
@@ -54487,12 +54895,12 @@ var debug_1 = function () {
|
|
|
54487
54895
|
debug$3.apply(null, arguments);
|
|
54488
54896
|
};
|
|
54489
54897
|
|
|
54490
|
-
var url = require$$0$
|
|
54898
|
+
var url = require$$0$9;
|
|
54491
54899
|
var URL$1 = url.URL;
|
|
54492
54900
|
var http$1 = require$$1$3;
|
|
54493
54901
|
var https$1 = require$$1$4;
|
|
54494
|
-
var Writable = require$$0$
|
|
54495
|
-
var assert =
|
|
54902
|
+
var Writable = require$$0$6.Writable;
|
|
54903
|
+
var assert = assert$3;
|
|
54496
54904
|
var debug$2 = debug_1;
|
|
54497
54905
|
|
|
54498
54906
|
// Create handlers that pass events from native requests
|
|
@@ -55441,8 +55849,8 @@ var wsIncoming = {
|
|
|
55441
55849
|
|
|
55442
55850
|
(function (module) {
|
|
55443
55851
|
var httpProxy = module.exports,
|
|
55444
|
-
extend = require$$0$
|
|
55445
|
-
parse_url = require$$0$
|
|
55852
|
+
extend = require$$0$5._extend,
|
|
55853
|
+
parse_url = require$$0$9.parse,
|
|
55446
55854
|
EE3 = eventemitter3.exports,
|
|
55447
55855
|
http = require$$1$3,
|
|
55448
55856
|
https = require$$1$4,
|
|
@@ -55551,7 +55959,7 @@ function ProxyServer(options) {
|
|
|
55551
55959
|
|
|
55552
55960
|
}
|
|
55553
55961
|
|
|
55554
|
-
require$$0$
|
|
55962
|
+
require$$0$5.inherits(ProxyServer, EE3);
|
|
55555
55963
|
|
|
55556
55964
|
ProxyServer.prototype.onError = function (err) {
|
|
55557
55965
|
//
|
|
@@ -55796,7 +56204,7 @@ var lib$1 = {exports: {}};
|
|
|
55796
56204
|
|
|
55797
56205
|
(function (module, exports) {
|
|
55798
56206
|
|
|
55799
|
-
var url = require$$0$
|
|
56207
|
+
var url = require$$0$9;
|
|
55800
56208
|
|
|
55801
56209
|
module.exports = function historyApiFallback(options) {
|
|
55802
56210
|
options = options || {};
|
|
@@ -55927,7 +56335,7 @@ function spaFallbackMiddleware(root) {
|
|
|
55927
56335
|
from: /\/$/,
|
|
55928
56336
|
to({ parsedUrl }) {
|
|
55929
56337
|
const rewritten = decodeURIComponent(parsedUrl.pathname) + 'index.html';
|
|
55930
|
-
if (
|
|
56338
|
+
if (fs$n.existsSync(path$q.join(root, rewritten))) {
|
|
55931
56339
|
return rewritten;
|
|
55932
56340
|
}
|
|
55933
56341
|
else {
|
|
@@ -56005,9 +56413,9 @@ function transformMiddleware(server) {
|
|
|
56005
56413
|
// means that the dependency has already been pre-bundled and loaded
|
|
56006
56414
|
const mapFile = url.startsWith(FS_PREFIX)
|
|
56007
56415
|
? fsPathFromId(url)
|
|
56008
|
-
: normalizePath$3(ensureVolumeInPath(path$
|
|
56416
|
+
: normalizePath$3(ensureVolumeInPath(path$q.resolve(root, url.slice(1))));
|
|
56009
56417
|
try {
|
|
56010
|
-
const map = await promises.readFile(mapFile, 'utf-8');
|
|
56418
|
+
const map = await promises$2.readFile(mapFile, 'utf-8');
|
|
56011
56419
|
return send(req, res, map, 'json', {
|
|
56012
56420
|
headers: server.config.server.headers
|
|
56013
56421
|
});
|
|
@@ -56156,7 +56564,7 @@ function getHtmlFilename(url, server) {
|
|
|
56156
56564
|
return decodeURIComponent(fsPathFromId(url));
|
|
56157
56565
|
}
|
|
56158
56566
|
else {
|
|
56159
|
-
return decodeURIComponent(normalizePath$3(path$
|
|
56567
|
+
return decodeURIComponent(normalizePath$3(path$q.join(server.config.root, url.slice(1))));
|
|
56160
56568
|
}
|
|
56161
56569
|
}
|
|
56162
56570
|
const startsWithSingleSlashRE = /^\/(?!\/)/;
|
|
@@ -56168,15 +56576,16 @@ const processNodeUrl = (node, s, config, htmlPath, originalUrl, moduleGraph) =>
|
|
|
56168
56576
|
url = injectQuery(url, `t=${mod.lastHMRTimestamp}`);
|
|
56169
56577
|
}
|
|
56170
56578
|
}
|
|
56579
|
+
const devBase = config.base;
|
|
56171
56580
|
if (startsWithSingleSlashRE.test(url)) {
|
|
56172
56581
|
// prefix with base (dev only, base is never relative)
|
|
56173
|
-
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 });
|
|
56174
56583
|
}
|
|
56175
56584
|
else if (url.startsWith('.') &&
|
|
56176
56585
|
originalUrl &&
|
|
56177
56586
|
originalUrl !== '/' &&
|
|
56178
56587
|
htmlPath === '/index.html') {
|
|
56179
|
-
const replacer = (url) => path$
|
|
56588
|
+
const replacer = (url) => path$q.posix.join(devBase, path$q.posix.relative(originalUrl, devBase), url.slice(1));
|
|
56180
56589
|
// #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
|
|
56181
56590
|
// path will add `/a/` prefix, it will caused 404.
|
|
56182
56591
|
// rewrite before `./index.js` -> `localhost:5173/a/index.js`.
|
|
@@ -56192,7 +56601,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
56192
56601
|
let proxyModulePath;
|
|
56193
56602
|
let proxyModuleUrl;
|
|
56194
56603
|
const trailingSlash = htmlPath.endsWith('/');
|
|
56195
|
-
if (!trailingSlash &&
|
|
56604
|
+
if (!trailingSlash && fs$n.existsSync(filename)) {
|
|
56196
56605
|
proxyModulePath = htmlPath;
|
|
56197
56606
|
proxyModuleUrl = base + htmlPath.slice(1);
|
|
56198
56607
|
}
|
|
@@ -56283,7 +56692,7 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
56283
56692
|
tag: 'script',
|
|
56284
56693
|
attrs: {
|
|
56285
56694
|
type: 'module',
|
|
56286
|
-
src: path$
|
|
56695
|
+
src: path$q.posix.join(base, CLIENT_PUBLIC_PATH)
|
|
56287
56696
|
},
|
|
56288
56697
|
injectTo: 'head-prepend'
|
|
56289
56698
|
}
|
|
@@ -56300,9 +56709,9 @@ function indexHtmlMiddleware(server) {
|
|
|
56300
56709
|
// spa-fallback always redirects to /index.html
|
|
56301
56710
|
if (url?.endsWith('.html') && req.headers['sec-fetch-dest'] !== 'script') {
|
|
56302
56711
|
const filename = getHtmlFilename(url, server);
|
|
56303
|
-
if (
|
|
56712
|
+
if (fs$n.existsSync(filename)) {
|
|
56304
56713
|
try {
|
|
56305
|
-
let html =
|
|
56714
|
+
let html = fs$n.readFileSync(filename, 'utf-8');
|
|
56306
56715
|
html = await server.transformIndexHtml(url, html, req.originalUrl);
|
|
56307
56716
|
return send(req, res, html, 'html', {
|
|
56308
56717
|
headers: server.config.server.headers
|
|
@@ -56342,6 +56751,8 @@ class ModuleNode {
|
|
|
56342
56751
|
this.importers = new Set();
|
|
56343
56752
|
this.importedModules = new Set();
|
|
56344
56753
|
this.acceptedHmrDeps = new Set();
|
|
56754
|
+
this.acceptedHmrExports = null;
|
|
56755
|
+
this.importedBindings = null;
|
|
56345
56756
|
this.transformResult = null;
|
|
56346
56757
|
this.ssrTransformResult = null;
|
|
56347
56758
|
this.ssrModule = null;
|
|
@@ -56417,7 +56828,7 @@ class ModuleGraph {
|
|
|
56417
56828
|
* If there are dependencies that no longer have any importers, they are
|
|
56418
56829
|
* returned as a Set.
|
|
56419
56830
|
*/
|
|
56420
|
-
async updateModuleInfo(mod, importedModules, acceptedModules, isSelfAccepting, ssr) {
|
|
56831
|
+
async updateModuleInfo(mod, importedModules, importedBindings, acceptedModules, acceptedExports, isSelfAccepting, ssr) {
|
|
56421
56832
|
mod.isSelfAccepting = isSelfAccepting;
|
|
56422
56833
|
const prevImports = mod.importedModules;
|
|
56423
56834
|
const nextImports = (mod.importedModules = new Set());
|
|
@@ -56447,6 +56858,9 @@ class ModuleGraph {
|
|
|
56447
56858
|
: accepted;
|
|
56448
56859
|
deps.add(dep);
|
|
56449
56860
|
}
|
|
56861
|
+
// update accepted hmr exports
|
|
56862
|
+
mod.acceptedHmrExports = acceptedExports;
|
|
56863
|
+
mod.importedBindings = importedBindings;
|
|
56450
56864
|
return noLongerImported;
|
|
56451
56865
|
}
|
|
56452
56866
|
async ensureEntryFromUrl(rawUrl, ssr) {
|
|
@@ -56499,7 +56913,7 @@ class ModuleGraph {
|
|
|
56499
56913
|
url = removeImportQuery(removeTimestampQuery(url));
|
|
56500
56914
|
const resolved = await this.resolveId(url, !!ssr);
|
|
56501
56915
|
const resolvedId = resolved?.id || url;
|
|
56502
|
-
const ext = extname(cleanUrl(resolvedId));
|
|
56916
|
+
const ext = extname$1(cleanUrl(resolvedId));
|
|
56503
56917
|
const { pathname, search, hash } = parse$m(url);
|
|
56504
56918
|
if (ext && !pathname.endsWith(ext)) {
|
|
56505
56919
|
url = pathname + ext + (search || '') + (hash || '');
|
|
@@ -56510,7 +56924,7 @@ class ModuleGraph {
|
|
|
56510
56924
|
|
|
56511
56925
|
var isWsl$2 = {exports: {}};
|
|
56512
56926
|
|
|
56513
|
-
const fs$6 =
|
|
56927
|
+
const fs$6 = require$$0__default;
|
|
56514
56928
|
|
|
56515
56929
|
let isDocker$2;
|
|
56516
56930
|
|
|
@@ -56540,7 +56954,7 @@ var isDocker_1 = () => {
|
|
|
56540
56954
|
};
|
|
56541
56955
|
|
|
56542
56956
|
const os$1 = require$$1;
|
|
56543
|
-
const fs$5 =
|
|
56957
|
+
const fs$5 = require$$0__default;
|
|
56544
56958
|
const isDocker$1 = isDocker_1;
|
|
56545
56959
|
|
|
56546
56960
|
const isWsl$1 = () => {
|
|
@@ -56591,7 +57005,7 @@ var defineLazyProp = (object, propertyName, fn) => {
|
|
|
56591
57005
|
|
|
56592
57006
|
const path$4 = path$p;
|
|
56593
57007
|
const childProcess = require$$2;
|
|
56594
|
-
const {promises: fs$4, constants: fsConstants} =
|
|
57008
|
+
const {promises: fs$4, constants: fsConstants} = require$$0__default;
|
|
56595
57009
|
const isWsl = isWsl$2.exports;
|
|
56596
57010
|
const isDocker = isDocker_1;
|
|
56597
57011
|
const defineLazyProperty = defineLazyProp;
|
|
@@ -56910,7 +57324,7 @@ var crossSpawn = {exports: {}};
|
|
|
56910
57324
|
var windows = isexe$3;
|
|
56911
57325
|
isexe$3.sync = sync$2;
|
|
56912
57326
|
|
|
56913
|
-
var fs$3 =
|
|
57327
|
+
var fs$3 = require$$0__default;
|
|
56914
57328
|
|
|
56915
57329
|
function checkPathExt (path, options) {
|
|
56916
57330
|
var pathext = options.pathExt !== undefined ?
|
|
@@ -56953,7 +57367,7 @@ function sync$2 (path, options) {
|
|
|
56953
57367
|
var mode = isexe$2;
|
|
56954
57368
|
isexe$2.sync = sync$1;
|
|
56955
57369
|
|
|
56956
|
-
var fs$2 =
|
|
57370
|
+
var fs$2 = require$$0__default;
|
|
56957
57371
|
|
|
56958
57372
|
function isexe$2 (path, options, cb) {
|
|
56959
57373
|
fs$2.stat(path, function (er, stat) {
|
|
@@ -57310,7 +57724,7 @@ var shebangCommand$1 = (string = '') => {
|
|
|
57310
57724
|
return argument ? `${binary} ${argument}` : binary;
|
|
57311
57725
|
};
|
|
57312
57726
|
|
|
57313
|
-
const fs$1 =
|
|
57727
|
+
const fs$1 = require$$0__default;
|
|
57314
57728
|
const shebangCommand = shebangCommand$1;
|
|
57315
57729
|
|
|
57316
57730
|
function readShebang$1(command) {
|
|
@@ -57571,7 +57985,7 @@ function startBrowserProcess(browser, url) {
|
|
|
57571
57985
|
// on OS X Google Chrome with AppleScript
|
|
57572
57986
|
execSync('ps cax | grep "Google Chrome"');
|
|
57573
57987
|
execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
|
|
57574
|
-
cwd: join$
|
|
57988
|
+
cwd: join$2(VITE_PACKAGE_DIR, 'bin'),
|
|
57575
57989
|
stdio: 'ignore'
|
|
57576
57990
|
});
|
|
57577
57991
|
return true;
|
|
@@ -57615,19 +58029,19 @@ const ROOT_FILES = [
|
|
|
57615
58029
|
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
|
57616
58030
|
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
|
57617
58031
|
function hasWorkspacePackageJSON(root) {
|
|
57618
|
-
const path = join$
|
|
58032
|
+
const path = join$2(root, 'package.json');
|
|
57619
58033
|
if (!isFileReadable(path)) {
|
|
57620
58034
|
return false;
|
|
57621
58035
|
}
|
|
57622
|
-
const content = JSON.parse(
|
|
58036
|
+
const content = JSON.parse(fs$n.readFileSync(path, 'utf-8')) || {};
|
|
57623
58037
|
return !!content.workspaces;
|
|
57624
58038
|
}
|
|
57625
58039
|
function hasRootFile(root) {
|
|
57626
|
-
return ROOT_FILES.some((file) =>
|
|
58040
|
+
return ROOT_FILES.some((file) => fs$n.existsSync(join$2(root, file)));
|
|
57627
58041
|
}
|
|
57628
58042
|
function hasPackageJSON(root) {
|
|
57629
|
-
const path = join$
|
|
57630
|
-
return
|
|
58043
|
+
const path = join$2(root, 'package.json');
|
|
58044
|
+
return fs$n.existsSync(path);
|
|
57631
58045
|
}
|
|
57632
58046
|
/**
|
|
57633
58047
|
* Search up for the nearest `package.json`
|
|
@@ -57635,7 +58049,7 @@ function hasPackageJSON(root) {
|
|
|
57635
58049
|
function searchForPackageRoot(current, root = current) {
|
|
57636
58050
|
if (hasPackageJSON(current))
|
|
57637
58051
|
return current;
|
|
57638
|
-
const dir = dirname$
|
|
58052
|
+
const dir = dirname$2(current);
|
|
57639
58053
|
// reach the fs root
|
|
57640
58054
|
if (!dir || dir === current)
|
|
57641
58055
|
return root;
|
|
@@ -57649,7 +58063,7 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
57649
58063
|
return current;
|
|
57650
58064
|
if (hasWorkspacePackageJSON(current))
|
|
57651
58065
|
return current;
|
|
57652
|
-
const dir = dirname$
|
|
58066
|
+
const dir = dirname$2(current);
|
|
57653
58067
|
// reach the fs root
|
|
57654
58068
|
if (!dir || dir === current)
|
|
57655
58069
|
return root;
|
|
@@ -57667,7 +58081,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
57667
58081
|
: await resolveHttpServer(serverConfig, middlewares, httpsOptions);
|
|
57668
58082
|
const ws = createWebSocketServer(httpServer, config, httpsOptions);
|
|
57669
58083
|
const { ignored = [], ...watchOptions } = serverConfig.watch || {};
|
|
57670
|
-
const watcher = chokidar.watch(path$
|
|
58084
|
+
const watcher = chokidar.watch(path$q.resolve(root), {
|
|
57671
58085
|
ignored: [
|
|
57672
58086
|
'**/node_modules/**',
|
|
57673
58087
|
'**/.git/**',
|
|
@@ -57729,9 +58143,9 @@ async function createServer(inlineConfig = {}) {
|
|
|
57729
58143
|
closeHttpServer()
|
|
57730
58144
|
]);
|
|
57731
58145
|
},
|
|
57732
|
-
printUrls() {
|
|
58146
|
+
async printUrls() {
|
|
57733
58147
|
if (httpServer) {
|
|
57734
|
-
printCommonServerUrls(httpServer, config.server, config);
|
|
58148
|
+
await printCommonServerUrls(httpServer, config.server, config);
|
|
57735
58149
|
}
|
|
57736
58150
|
else {
|
|
57737
58151
|
throw new Error('cannot print server URLs in middleware mode.');
|
|
@@ -57830,7 +58244,8 @@ async function createServer(inlineConfig = {}) {
|
|
|
57830
58244
|
middlewares.use(proxyMiddleware(httpServer, proxy, config));
|
|
57831
58245
|
}
|
|
57832
58246
|
// base
|
|
57833
|
-
|
|
58247
|
+
const devBase = config.base;
|
|
58248
|
+
if (devBase !== '/') {
|
|
57834
58249
|
middlewares.use(baseMiddleware(server));
|
|
57835
58250
|
}
|
|
57836
58251
|
// open in editor support
|
|
@@ -57903,10 +58318,10 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
57903
58318
|
}
|
|
57904
58319
|
const options = server.config.server;
|
|
57905
58320
|
const port = inlinePort ?? options.port ?? 5173;
|
|
57906
|
-
const hostname = resolveHostname(options.host);
|
|
58321
|
+
const hostname = await resolveHostname(options.host);
|
|
57907
58322
|
const protocol = options.https ? 'https' : 'http';
|
|
57908
58323
|
const info = server.config.logger.info;
|
|
57909
|
-
const
|
|
58324
|
+
const devBase = server.config.base;
|
|
57910
58325
|
const serverPort = await httpServerStart(httpServer, {
|
|
57911
58326
|
port,
|
|
57912
58327
|
strictPort: options.strictPort,
|
|
@@ -57919,8 +58334,8 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
57919
58334
|
profileSession.post('Profiler.stop', (err, { profile }) => {
|
|
57920
58335
|
// Write profile to disk, upload, etc.
|
|
57921
58336
|
if (!err) {
|
|
57922
|
-
const outPath = path$
|
|
57923
|
-
|
|
58337
|
+
const outPath = path$q.resolve('./vite-profile.cpuprofile');
|
|
58338
|
+
fs$n.writeFileSync(outPath, JSON.stringify(profile));
|
|
57924
58339
|
info(colors$1.yellow(` CPU profile written to ${colors$1.white(colors$1.dim(outPath))}\n`));
|
|
57925
58340
|
}
|
|
57926
58341
|
else {
|
|
@@ -57929,7 +58344,7 @@ async function startServer(server, inlinePort, isRestart = false) {
|
|
|
57929
58344
|
});
|
|
57930
58345
|
}
|
|
57931
58346
|
if (options.open && !isRestart) {
|
|
57932
|
-
const path = typeof options.open === 'string' ? options.open :
|
|
58347
|
+
const path = typeof options.open === 'string' ? options.open : devBase;
|
|
57933
58348
|
openBrowser(path.startsWith('http')
|
|
57934
58349
|
? path
|
|
57935
58350
|
: `${protocol}://${hostname.name}:${serverPort}${path}`, true, server.config.logger);
|
|
@@ -57969,7 +58384,7 @@ function createServerCloseFn(server) {
|
|
|
57969
58384
|
});
|
|
57970
58385
|
}
|
|
57971
58386
|
function resolvedAllowDir(root, dir) {
|
|
57972
|
-
return normalizePath$3(path$
|
|
58387
|
+
return normalizePath$3(path$q.resolve(root, dir));
|
|
57973
58388
|
}
|
|
57974
58389
|
function resolveServerOptions(root, raw, logger) {
|
|
57975
58390
|
const server = {
|
|
@@ -58216,9 +58631,10 @@ async function preview(inlineConfig = {}) {
|
|
|
58216
58631
|
app.use(proxyMiddleware(httpServer, proxy, config));
|
|
58217
58632
|
}
|
|
58218
58633
|
app.use(compression());
|
|
58634
|
+
const previewBase = config.base === './' || config.base === '' ? '/' : config.base;
|
|
58219
58635
|
// static assets
|
|
58220
|
-
const distDir = path$
|
|
58221
|
-
app.use(
|
|
58636
|
+
const distDir = path$q.resolve(config.root, config.build.outDir);
|
|
58637
|
+
app.use(previewBase, sirv(distDir, {
|
|
58222
58638
|
etag: true,
|
|
58223
58639
|
dev: true,
|
|
58224
58640
|
single: config.appType === 'spa'
|
|
@@ -58226,11 +58642,10 @@ async function preview(inlineConfig = {}) {
|
|
|
58226
58642
|
// apply post server hooks from plugins
|
|
58227
58643
|
postHooks.forEach((fn) => fn && fn());
|
|
58228
58644
|
const options = config.preview;
|
|
58229
|
-
const hostname = resolveHostname(options.host);
|
|
58645
|
+
const hostname = await resolveHostname(options.host);
|
|
58230
58646
|
const port = options.port ?? 4173;
|
|
58231
58647
|
const protocol = options.https ? 'https' : 'http';
|
|
58232
58648
|
const logger = config.logger;
|
|
58233
|
-
const base = config.base;
|
|
58234
58649
|
const serverPort = await httpServerStart(httpServer, {
|
|
58235
58650
|
port,
|
|
58236
58651
|
strictPort: options.strictPort,
|
|
@@ -58238,7 +58653,7 @@ async function preview(inlineConfig = {}) {
|
|
|
58238
58653
|
logger
|
|
58239
58654
|
});
|
|
58240
58655
|
if (options.open) {
|
|
58241
|
-
const path = typeof options.open === 'string' ? options.open :
|
|
58656
|
+
const path = typeof options.open === 'string' ? options.open : previewBase;
|
|
58242
58657
|
openBrowser(path.startsWith('http')
|
|
58243
58658
|
? path
|
|
58244
58659
|
: `${protocol}://${hostname.name}:${serverPort}${path}`, true, logger);
|
|
@@ -58246,8 +58661,8 @@ async function preview(inlineConfig = {}) {
|
|
|
58246
58661
|
return {
|
|
58247
58662
|
config,
|
|
58248
58663
|
httpServer,
|
|
58249
|
-
printUrls() {
|
|
58250
|
-
printCommonServerUrls(httpServer, config.preview, config);
|
|
58664
|
+
async printUrls() {
|
|
58665
|
+
await printCommonServerUrls(httpServer, config.preview, config);
|
|
58251
58666
|
}
|
|
58252
58667
|
};
|
|
58253
58668
|
}
|
|
@@ -58268,38 +58683,39 @@ const normalizedEnvEntry = normalizePath$3(ENV_ENTRY);
|
|
|
58268
58683
|
function clientInjectionsPlugin(config) {
|
|
58269
58684
|
return {
|
|
58270
58685
|
name: 'vite:client-inject',
|
|
58271
|
-
transform(code, id, options) {
|
|
58686
|
+
async transform(code, id, options) {
|
|
58272
58687
|
if (id === normalizedClientEntry || id === normalizedEnvEntry) {
|
|
58273
|
-
let
|
|
58274
|
-
|
|
58275
|
-
const host =
|
|
58276
|
-
const protocol =
|
|
58277
|
-
const timeout =
|
|
58278
|
-
const overlay =
|
|
58279
|
-
|
|
58280
|
-
if (
|
|
58281
|
-
|
|
58282
|
-
|
|
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;
|
|
58283
58699
|
if (config.server.middlewareMode) {
|
|
58284
|
-
port
|
|
58285
|
-
}
|
|
58286
|
-
else {
|
|
58287
|
-
port = String(port || options.port || config.server.port);
|
|
58288
|
-
}
|
|
58289
|
-
let hmrBase = config.base;
|
|
58290
|
-
if (options.path) {
|
|
58291
|
-
hmrBase = path$p.posix.join(hmrBase, options.path);
|
|
58700
|
+
port || (port = '24678');
|
|
58292
58701
|
}
|
|
58293
|
-
|
|
58294
|
-
|
|
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);
|
|
58295
58709
|
}
|
|
58296
58710
|
return code
|
|
58297
58711
|
.replace(`__MODE__`, JSON.stringify(config.mode))
|
|
58298
|
-
.replace(`__BASE__`, JSON.stringify(
|
|
58712
|
+
.replace(`__BASE__`, JSON.stringify(devBase))
|
|
58299
58713
|
.replace(`__DEFINES__`, serializeDefine(config.define || {}))
|
|
58300
58714
|
.replace(`__HMR_PROTOCOL__`, JSON.stringify(protocol))
|
|
58301
58715
|
.replace(`__HMR_HOSTNAME__`, JSON.stringify(host))
|
|
58302
58716
|
.replace(`__HMR_PORT__`, JSON.stringify(port))
|
|
58717
|
+
.replace(`__HMR_DIRECT_TARGET__`, JSON.stringify(directTarget))
|
|
58718
|
+
.replace(`__HMR_BASE__`, JSON.stringify(hmrBase))
|
|
58303
58719
|
.replace(`__HMR_TIMEOUT__`, JSON.stringify(timeout))
|
|
58304
58720
|
.replace(`__HMR_ENABLE_OVERLAY__`, JSON.stringify(overlay));
|
|
58305
58721
|
}
|
|
@@ -58437,9 +58853,9 @@ async function bundleWorkerEntry(config, id, query) {
|
|
|
58437
58853
|
: workerOutputConfig
|
|
58438
58854
|
: {};
|
|
58439
58855
|
const { output: [outputChunk, ...outputChunks] } = await bundle.generate({
|
|
58440
|
-
entryFileNames: path$
|
|
58441
|
-
chunkFileNames: path$
|
|
58442
|
-
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]'),
|
|
58443
58859
|
...workerConfig,
|
|
58444
58860
|
format,
|
|
58445
58861
|
sourcemap: config.build.sourcemap
|
|
@@ -58491,7 +58907,7 @@ function emitSourcemapForWorkerEntry(config, query, chunk) {
|
|
|
58491
58907
|
// non-inline web workers can use a relative path
|
|
58492
58908
|
const sourceMapUrl = query?.inline != null
|
|
58493
58909
|
? mapFileName
|
|
58494
|
-
: path$
|
|
58910
|
+
: path$q.relative(config.build.assetsDir, mapFileName);
|
|
58495
58911
|
chunk.code += `//# sourceMappingURL=${sourceMapUrl}`;
|
|
58496
58912
|
}
|
|
58497
58913
|
}
|
|
@@ -58520,9 +58936,10 @@ async function workerFileToUrl(config, id, query) {
|
|
|
58520
58936
|
});
|
|
58521
58937
|
workerMap.bundle.set(id, fileName);
|
|
58522
58938
|
}
|
|
58523
|
-
|
|
58939
|
+
const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
|
|
58940
|
+
return assetsBase.relative || assetsBase.runtime
|
|
58524
58941
|
? encodeWorkerAssetFileName(fileName, workerMap)
|
|
58525
|
-
: config.base + fileName;
|
|
58942
|
+
: (assetsBase.url ?? config.base) + fileName;
|
|
58526
58943
|
}
|
|
58527
58944
|
function webWorkerPlugin(config) {
|
|
58528
58945
|
const isBuild = config.command === 'build';
|
|
@@ -58651,14 +59068,28 @@ function webWorkerPlugin(config) {
|
|
|
58651
59068
|
// Replace "__VITE_WORKER_ASSET__5aa0ddc0__" using relative paths
|
|
58652
59069
|
const workerMap = workerCache.get(config.mainConfig || config);
|
|
58653
59070
|
const { fileNameHash } = workerMap;
|
|
59071
|
+
const assetsBase = config.experimental.buildAdvancedBaseOptions.assets;
|
|
58654
59072
|
while ((match = workerAssetUrlRE.exec(code))) {
|
|
58655
59073
|
const [full, hash] = match;
|
|
58656
59074
|
const filename = fileNameHash.get(hash);
|
|
58657
|
-
let
|
|
58658
|
-
if (
|
|
58659
|
-
|
|
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);
|
|
58660
59092
|
}
|
|
58661
|
-
const replacement = JSON.stringify(outputFilepath).slice(1, -1);
|
|
58662
59093
|
s.overwrite(match.index, match.index + full.length, replacement, {
|
|
58663
59094
|
contentOnly: true
|
|
58664
59095
|
});
|
|
@@ -60283,7 +60714,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
60283
60714
|
}
|
|
60284
60715
|
s || (s = new MagicString(code));
|
|
60285
60716
|
const workerType = getWorkerType(code, cleanString, index + allExp.length);
|
|
60286
|
-
const file = normalizePath$3(path$
|
|
60717
|
+
const file = normalizePath$3(path$q.resolve(path$q.dirname(id), rawUrl.slice(1, -1)));
|
|
60287
60718
|
let url;
|
|
60288
60719
|
if (isBuild) {
|
|
60289
60720
|
getDepsOptimizer(config)?.registerWorkersSource(id);
|
|
@@ -60468,7 +60899,7 @@ async function transformDynamicImport(importSource, importer, resolve) {
|
|
|
60468
60899
|
if (!resolvedFileName) {
|
|
60469
60900
|
return null;
|
|
60470
60901
|
}
|
|
60471
|
-
const relativeFileName = posix$
|
|
60902
|
+
const relativeFileName = posix$2.relative(posix$2.dirname(normalizePath$3(importer)), normalizePath$3(resolvedFileName));
|
|
60472
60903
|
importSource = normalizePath$3('`' + (relativeFileName[0] === '.' ? '' : './') + relativeFileName + '`');
|
|
60473
60904
|
}
|
|
60474
60905
|
const dynamicImportPattern = parseDynamicImportPattern(importSource);
|
|
@@ -60625,7 +61056,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
60625
61056
|
|
|
60626
61057
|
var main$1 = {exports: {}};
|
|
60627
61058
|
|
|
60628
|
-
const fs =
|
|
61059
|
+
const fs = require$$0__default;
|
|
60629
61060
|
const path = path$p;
|
|
60630
61061
|
const os = require$$1;
|
|
60631
61062
|
|
|
@@ -60839,7 +61270,7 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
|
|
|
60839
61270
|
for (const file of envFiles) {
|
|
60840
61271
|
const path = lookupFile(envDir, [file], { pathOnly: true, rootDir: envDir });
|
|
60841
61272
|
if (path) {
|
|
60842
|
-
const parsed = dotenv.parse(
|
|
61273
|
+
const parsed = dotenv.parse(fs$n.readFileSync(path), {
|
|
60843
61274
|
debug: process.env.DEBUG?.includes('vite:dotenv') || undefined
|
|
60844
61275
|
});
|
|
60845
61276
|
// let environment variables use each other
|
|
@@ -60957,7 +61388,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60957
61388
|
}
|
|
60958
61389
|
}
|
|
60959
61390
|
// resolve root
|
|
60960
|
-
const resolvedRoot = normalizePath$3(config.root ? path$
|
|
61391
|
+
const resolvedRoot = normalizePath$3(config.root ? path$q.resolve(config.root) : process.cwd());
|
|
60961
61392
|
const clientAlias = [
|
|
60962
61393
|
{ find: /^[\/]?@vite\/env/, replacement: () => ENV_ENTRY },
|
|
60963
61394
|
{ find: /^[\/]?@vite\/client/, replacement: () => CLIENT_ENTRY }
|
|
@@ -60973,7 +61404,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60973
61404
|
};
|
|
60974
61405
|
// load .env files
|
|
60975
61406
|
const envDir = config.envDir
|
|
60976
|
-
? normalizePath$3(path$
|
|
61407
|
+
? normalizePath$3(path$q.resolve(resolvedRoot, config.envDir))
|
|
60977
61408
|
: resolvedRoot;
|
|
60978
61409
|
const userEnv = inlineConfig.envFile !== false &&
|
|
60979
61410
|
loadEnv(mode, envDir, resolveEnvPrefix(config));
|
|
@@ -60987,15 +61418,31 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
60987
61418
|
process.env.NODE_ENV = 'production';
|
|
60988
61419
|
}
|
|
60989
61420
|
// resolve public base url
|
|
60990
|
-
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);
|
|
60991
61438
|
const resolvedBuildOptions = resolveBuildOptions(config.build);
|
|
60992
61439
|
// resolve cache directory
|
|
60993
61440
|
const pkgPath = lookupFile(resolvedRoot, [`package.json`], { pathOnly: true });
|
|
60994
61441
|
const cacheDir = config.cacheDir
|
|
60995
|
-
? path$
|
|
61442
|
+
? path$q.resolve(resolvedRoot, config.cacheDir)
|
|
60996
61443
|
: pkgPath
|
|
60997
|
-
? path$
|
|
60998
|
-
: path$
|
|
61444
|
+
? path$q.join(path$q.dirname(pkgPath), `node_modules/.vite`)
|
|
61445
|
+
: path$q.join(resolvedRoot, `.vite`);
|
|
60999
61446
|
const assetsFilter = config.assetsInclude
|
|
61000
61447
|
? createFilter(config.assetsInclude)
|
|
61001
61448
|
: () => false;
|
|
@@ -61040,7 +61487,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
61040
61487
|
};
|
|
61041
61488
|
const { publicDir } = config;
|
|
61042
61489
|
const resolvedPublicDir = publicDir !== false && publicDir !== ''
|
|
61043
|
-
? path$
|
|
61490
|
+
? path$q.resolve(resolvedRoot, typeof publicDir === 'string' ? publicDir : 'public')
|
|
61044
61491
|
: '';
|
|
61045
61492
|
const server = resolveServerOptions(resolvedRoot, config.server, logger);
|
|
61046
61493
|
let ssr = resolveSSROptions(config.ssr);
|
|
@@ -61052,13 +61499,14 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
61052
61499
|
}
|
|
61053
61500
|
const middlewareMode = config?.server?.middlewareMode;
|
|
61054
61501
|
const optimizeDeps = config.optimizeDeps || {};
|
|
61502
|
+
const BASE_URL = resolvedBase;
|
|
61055
61503
|
const resolved = {
|
|
61056
61504
|
...config,
|
|
61057
61505
|
configFile: configFile ? normalizePath$3(configFile) : undefined,
|
|
61058
|
-
configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$
|
|
61506
|
+
configFileDependencies: configFileDependencies.map((name) => normalizePath$3(path$q.resolve(name))),
|
|
61059
61507
|
inlineConfig,
|
|
61060
61508
|
root: resolvedRoot,
|
|
61061
|
-
base:
|
|
61509
|
+
base: resolvedBase,
|
|
61062
61510
|
resolve: resolveOptions,
|
|
61063
61511
|
publicDir: resolvedPublicDir,
|
|
61064
61512
|
cacheDir,
|
|
@@ -61093,7 +61541,13 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
61093
61541
|
}
|
|
61094
61542
|
},
|
|
61095
61543
|
worker: resolvedWorkerOptions,
|
|
61096
|
-
appType: config.appType ?? middlewareMode === 'ssr' ? 'custom' : 'spa'
|
|
61544
|
+
appType: config.appType ?? middlewareMode === 'ssr' ? 'custom' : 'spa',
|
|
61545
|
+
experimental: {
|
|
61546
|
+
importGlobRestoreExtension: false,
|
|
61547
|
+
hmrPartialAccept: false,
|
|
61548
|
+
...config.experimental,
|
|
61549
|
+
buildAdvancedBaseOptions: resolvedBuildAdvancedBaseOptions
|
|
61550
|
+
}
|
|
61097
61551
|
};
|
|
61098
61552
|
if (middlewareMode === 'ssr') {
|
|
61099
61553
|
logger.warn(colors$1.yellow(`server.middlewareMode 'ssr' is now deprecated, use server.middlewareMode true and appType 'custom'`));
|
|
@@ -61155,16 +61609,12 @@ assetFileNames isn't equal for every build.rollupOptions.output. A single patter
|
|
|
61155
61609
|
return resolved;
|
|
61156
61610
|
}
|
|
61157
61611
|
/**
|
|
61158
|
-
* 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
|
|
61159
61613
|
* electron or expects to deploy
|
|
61160
61614
|
*/
|
|
61161
|
-
function resolveBaseUrl(base = '/', isBuild, logger) {
|
|
61162
|
-
// #1669 special treatment for empty for same dir relative base
|
|
61163
|
-
if (base === '' || base === './') {
|
|
61164
|
-
return isBuild ? base : '/';
|
|
61165
|
-
}
|
|
61615
|
+
function resolveBaseUrl(base = '/', isBuild, logger, optionName) {
|
|
61166
61616
|
if (base.startsWith('.')) {
|
|
61167
|
-
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 ` +
|
|
61168
61618
|
`URL, ./, or an empty string.`)));
|
|
61169
61619
|
base = '/';
|
|
61170
61620
|
}
|
|
@@ -61179,13 +61629,13 @@ function resolveBaseUrl(base = '/', isBuild, logger) {
|
|
|
61179
61629
|
else {
|
|
61180
61630
|
// ensure leading slash
|
|
61181
61631
|
if (!base.startsWith('/')) {
|
|
61182
|
-
logger.warn(colors$1.yellow(colors$1.bold(`(!) "
|
|
61632
|
+
logger.warn(colors$1.yellow(colors$1.bold(`(!) "${optionName}" option should start with a slash.`)));
|
|
61183
61633
|
base = '/' + base;
|
|
61184
61634
|
}
|
|
61185
61635
|
}
|
|
61186
61636
|
// ensure ending slash
|
|
61187
61637
|
if (!base.endsWith('/')) {
|
|
61188
|
-
logger.warn(colors$1.yellow(colors$1.bold(`(!) "
|
|
61638
|
+
logger.warn(colors$1.yellow(colors$1.bold(`(!) "${optionName}" option should end with a slash.`)));
|
|
61189
61639
|
base += '/';
|
|
61190
61640
|
}
|
|
61191
61641
|
return base;
|
|
@@ -61223,7 +61673,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
61223
61673
|
catch (e) { }
|
|
61224
61674
|
if (configFile) {
|
|
61225
61675
|
// explicit config path is always resolved from cwd
|
|
61226
|
-
resolvedPath = path$
|
|
61676
|
+
resolvedPath = path$q.resolve(configFile);
|
|
61227
61677
|
isTS = configFile.endsWith('.ts');
|
|
61228
61678
|
if (configFile.endsWith('.mjs')) {
|
|
61229
61679
|
isESM = true;
|
|
@@ -61232,27 +61682,27 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
61232
61682
|
else {
|
|
61233
61683
|
// implicit config file loaded from inline root (if present)
|
|
61234
61684
|
// otherwise from cwd
|
|
61235
|
-
const jsconfigFile = path$
|
|
61236
|
-
if (
|
|
61685
|
+
const jsconfigFile = path$q.resolve(configRoot, 'vite.config.js');
|
|
61686
|
+
if (fs$n.existsSync(jsconfigFile)) {
|
|
61237
61687
|
resolvedPath = jsconfigFile;
|
|
61238
61688
|
}
|
|
61239
61689
|
if (!resolvedPath) {
|
|
61240
|
-
const mjsconfigFile = path$
|
|
61241
|
-
if (
|
|
61690
|
+
const mjsconfigFile = path$q.resolve(configRoot, 'vite.config.mjs');
|
|
61691
|
+
if (fs$n.existsSync(mjsconfigFile)) {
|
|
61242
61692
|
resolvedPath = mjsconfigFile;
|
|
61243
61693
|
isESM = true;
|
|
61244
61694
|
}
|
|
61245
61695
|
}
|
|
61246
61696
|
if (!resolvedPath) {
|
|
61247
|
-
const tsconfigFile = path$
|
|
61248
|
-
if (
|
|
61697
|
+
const tsconfigFile = path$q.resolve(configRoot, 'vite.config.ts');
|
|
61698
|
+
if (fs$n.existsSync(tsconfigFile)) {
|
|
61249
61699
|
resolvedPath = tsconfigFile;
|
|
61250
61700
|
isTS = true;
|
|
61251
61701
|
}
|
|
61252
61702
|
}
|
|
61253
61703
|
if (!resolvedPath) {
|
|
61254
|
-
const cjsConfigFile = path$
|
|
61255
|
-
if (
|
|
61704
|
+
const cjsConfigFile = path$q.resolve(configRoot, 'vite.config.cjs');
|
|
61705
|
+
if (fs$n.existsSync(cjsConfigFile)) {
|
|
61256
61706
|
resolvedPath = cjsConfigFile;
|
|
61257
61707
|
isESM = false;
|
|
61258
61708
|
}
|
|
@@ -61273,10 +61723,10 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
|
|
|
61273
61723
|
// with --experimental-loader themselves, we have to do a hack here:
|
|
61274
61724
|
// bundle the config file w/ ts transforms first, write it to disk,
|
|
61275
61725
|
// load it with native Node ESM, then delete the file.
|
|
61276
|
-
|
|
61726
|
+
fs$n.writeFileSync(resolvedPath + '.js', bundled.code);
|
|
61277
61727
|
userConfig = (await dynamicImport(`${fileUrl}.js?t=${Date.now()}`))
|
|
61278
61728
|
.default;
|
|
61279
|
-
|
|
61729
|
+
fs$n.unlinkSync(resolvedPath + '.js');
|
|
61280
61730
|
debug(`TS + native esm config loaded in ${getTime()}`, fileUrl);
|
|
61281
61731
|
}
|
|
61282
61732
|
else {
|
|
@@ -61332,7 +61782,7 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
61332
61782
|
setup(build) {
|
|
61333
61783
|
build.onResolve({ filter: /.*/ }, (args) => {
|
|
61334
61784
|
const id = args.path;
|
|
61335
|
-
if (id[0] !== '.' && !path$
|
|
61785
|
+
if (id[0] !== '.' && !path$q.isAbsolute(id)) {
|
|
61336
61786
|
return {
|
|
61337
61787
|
external: true
|
|
61338
61788
|
};
|
|
@@ -61344,8 +61794,8 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
61344
61794
|
name: 'inject-file-scope-variables',
|
|
61345
61795
|
setup(build) {
|
|
61346
61796
|
build.onLoad({ filter: /\.[jt]s$/ }, async (args) => {
|
|
61347
|
-
const contents = await
|
|
61348
|
-
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))};` +
|
|
61349
61799
|
`const __filename = ${JSON.stringify(args.path)};` +
|
|
61350
61800
|
`const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(args.path).href)};`;
|
|
61351
61801
|
return {
|
|
@@ -61365,7 +61815,7 @@ async function bundleConfigFile(fileName, isESM = false) {
|
|
|
61365
61815
|
}
|
|
61366
61816
|
const _require = createRequire$1(import.meta.url);
|
|
61367
61817
|
async function loadConfigFromBundledFile(fileName, bundledCode) {
|
|
61368
|
-
const realFileName =
|
|
61818
|
+
const realFileName = fs$n.realpathSync(fileName);
|
|
61369
61819
|
const defaultLoader = _require.extensions['.js'];
|
|
61370
61820
|
_require.extensions['.js'] = (module, filename) => {
|
|
61371
61821
|
if (filename === realFileName) {
|
|
@@ -61389,4 +61839,4 @@ function isDepsOptimizerEnabled(config) {
|
|
|
61389
61839
|
(command === 'serve' && optimizeDeps.disabled === 'dev'));
|
|
61390
61840
|
}
|
|
61391
61841
|
|
|
61392
|
-
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 };
|