vite 5.0.0-beta.1 → 5.0.0-beta.3
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 +36 -2
- package/client.d.ts +8 -56
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/env.mjs.map +1 -1
- package/dist/node/chunks/{dep-c457d7ce.js → dep-68c42983.js} +1 -1
- package/dist/node/chunks/{dep-6db0c752.js → dep-9586b1f1.js} +1 -1
- package/dist/node/chunks/{dep-e31699fa.js → dep-dc9999ab.js} +1978 -1431
- package/dist/node/cli.js +12 -8
- package/dist/node/index.d.ts +7 -58
- package/dist/node/index.js +4 -3
- package/dist/node-cjs/publicUtils.cjs +364 -82
- package/index.cjs +14 -0
- package/index.d.cts +6 -0
- package/package.json +36 -29
|
@@ -15,7 +15,8 @@ var fs$2 = require('fs');
|
|
|
15
15
|
var readline = require('node:readline');
|
|
16
16
|
var require$$2 = require('os');
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
19
|
+
const { version: version$2 } = JSON.parse(fs$1.readFileSync(new URL('../../package.json', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))).toString());
|
|
19
20
|
const VERSION = version$2;
|
|
20
21
|
/**
|
|
21
22
|
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
|
|
@@ -23,32 +24,11 @@ const VERSION = version$2;
|
|
|
23
24
|
const FS_PREFIX = `/@fs/`;
|
|
24
25
|
const VITE_PACKAGE_DIR = path$3.resolve(
|
|
25
26
|
// import.meta.url is `dist/node/constants.js` after bundle
|
|
26
|
-
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
27
|
+
node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))), '../../..');
|
|
27
28
|
const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
|
|
28
29
|
path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
|
|
29
30
|
path$3.dirname(CLIENT_ENTRY);
|
|
30
31
|
|
|
31
|
-
const chars$1 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
32
|
-
const intToChar$1 = new Uint8Array(64); // 64 possible chars.
|
|
33
|
-
const charToInt$1 = new Uint8Array(128); // z is 122 in ASCII
|
|
34
|
-
for (let i = 0; i < chars$1.length; i++) {
|
|
35
|
-
const c = chars$1.charCodeAt(i);
|
|
36
|
-
intToChar$1[i] = c;
|
|
37
|
-
charToInt$1[c] = i;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Matches the scheme of a URL, eg "http://"
|
|
41
|
-
var UrlType;
|
|
42
|
-
(function (UrlType) {
|
|
43
|
-
UrlType[UrlType["Empty"] = 1] = "Empty";
|
|
44
|
-
UrlType[UrlType["Hash"] = 2] = "Hash";
|
|
45
|
-
UrlType[UrlType["Query"] = 3] = "Query";
|
|
46
|
-
UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
|
|
47
|
-
UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
|
|
48
|
-
UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
|
|
49
|
-
UrlType[UrlType["Absolute"] = 7] = "Absolute";
|
|
50
|
-
})(UrlType || (UrlType = {}));
|
|
51
|
-
|
|
52
32
|
const comma = ','.charCodeAt(0);
|
|
53
33
|
const semicolon = ';'.charCodeAt(0);
|
|
54
34
|
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
@@ -137,6 +117,18 @@ function encodeInteger(buf, pos, state, segment, j) {
|
|
|
137
117
|
return pos;
|
|
138
118
|
}
|
|
139
119
|
|
|
120
|
+
// Matches the scheme of a URL, eg "http://"
|
|
121
|
+
var UrlType;
|
|
122
|
+
(function (UrlType) {
|
|
123
|
+
UrlType[UrlType["Empty"] = 1] = "Empty";
|
|
124
|
+
UrlType[UrlType["Hash"] = 2] = "Hash";
|
|
125
|
+
UrlType[UrlType["Query"] = 3] = "Query";
|
|
126
|
+
UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
|
|
127
|
+
UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
|
|
128
|
+
UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
|
|
129
|
+
UrlType[UrlType["Absolute"] = 7] = "Absolute";
|
|
130
|
+
})(UrlType || (UrlType = {}));
|
|
131
|
+
|
|
140
132
|
function getDefaultExportFromCjs (x) {
|
|
141
133
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
142
134
|
}
|
|
@@ -1228,7 +1220,7 @@ if (typeof process === 'undefined' || process.type === 'renderer' || process.bro
|
|
|
1228
1220
|
}
|
|
1229
1221
|
|
|
1230
1222
|
var srcExports = src.exports;
|
|
1231
|
-
var debug$
|
|
1223
|
+
var debug$2 = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
|
|
1232
1224
|
|
|
1233
1225
|
var utils$3 = {};
|
|
1234
1226
|
|
|
@@ -3311,7 +3303,7 @@ const normalizePath$1 = function normalizePath(filename) {
|
|
|
3311
3303
|
};
|
|
3312
3304
|
|
|
3313
3305
|
function getMatcherString(id, resolutionBase) {
|
|
3314
|
-
if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('
|
|
3306
|
+
if (resolutionBase === false || require$$0$1.isAbsolute(id) || id.startsWith('**')) {
|
|
3315
3307
|
return normalizePath$1(id);
|
|
3316
3308
|
}
|
|
3317
3309
|
// resolve('') is valid and will default to process.cwd()
|
|
@@ -3366,7 +3358,7 @@ forbiddenIdentifiers.add('');
|
|
|
3366
3358
|
|
|
3367
3359
|
if (process.versions.pnp) {
|
|
3368
3360
|
try {
|
|
3369
|
-
node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
3361
|
+
node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)))('pnpapi');
|
|
3370
3362
|
}
|
|
3371
3363
|
catch { }
|
|
3372
3364
|
}
|
|
@@ -3376,16 +3368,18 @@ const windowsSlashRE = /\\/g;
|
|
|
3376
3368
|
function slash(p) {
|
|
3377
3369
|
return p.replace(windowsSlashRE, '/');
|
|
3378
3370
|
}
|
|
3371
|
+
// Some runtimes like Bun injects namespaced modules here, which is not a node builtin
|
|
3372
|
+
node_module.builtinModules.filter((id) => !id.includes(':'));
|
|
3379
3373
|
function isInNodeModules(id) {
|
|
3380
3374
|
return id.includes('node_modules');
|
|
3381
3375
|
}
|
|
3382
3376
|
// TODO: use import()
|
|
3383
|
-
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
3377
|
+
const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href)));
|
|
3384
3378
|
// set in bin/vite.js
|
|
3385
3379
|
const filter = process.env.VITE_DEBUG_FILTER;
|
|
3386
3380
|
const DEBUG = process.env.DEBUG;
|
|
3387
3381
|
function createDebugger(namespace, options = {}) {
|
|
3388
|
-
const log = debug$
|
|
3382
|
+
const log = debug$2(namespace);
|
|
3389
3383
|
const { onlyWhenFocused } = options;
|
|
3390
3384
|
let enabled = log.enabled;
|
|
3391
3385
|
if (enabled && onlyWhenFocused) {
|
|
@@ -3470,6 +3464,7 @@ function isObject$1(value) {
|
|
|
3470
3464
|
}
|
|
3471
3465
|
function tryStatSync(file) {
|
|
3472
3466
|
try {
|
|
3467
|
+
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
|
|
3473
3468
|
return fs$1.statSync(file, { throwIfNoEntry: false });
|
|
3474
3469
|
}
|
|
3475
3470
|
catch {
|
|
@@ -3477,11 +3472,10 @@ function tryStatSync(file) {
|
|
|
3477
3472
|
}
|
|
3478
3473
|
}
|
|
3479
3474
|
function isFileReadable(filename) {
|
|
3475
|
+
if (!tryStatSync(filename)) {
|
|
3476
|
+
return false;
|
|
3477
|
+
}
|
|
3480
3478
|
try {
|
|
3481
|
-
// The "throwIfNoEntry" is a performance optimization for cases where the file does not exist
|
|
3482
|
-
if (!fs$1.statSync(filename, { throwIfNoEntry: false })) {
|
|
3483
|
-
return false;
|
|
3484
|
-
}
|
|
3485
3479
|
// Check if current process has read permission to the file
|
|
3486
3480
|
fs$1.accessSync(filename, fs$1.constants.R_OK);
|
|
3487
3481
|
return true;
|
|
@@ -3507,7 +3501,7 @@ const usingDynamicImport = typeof jest === 'undefined';
|
|
|
3507
3501
|
usingDynamicImport
|
|
3508
3502
|
? new Function('file', 'return import(file)')
|
|
3509
3503
|
: _require;
|
|
3510
|
-
path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (
|
|
3504
|
+
path$3.dirname(node_url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))));
|
|
3511
3505
|
function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
3512
3506
|
const merged = { ...defaults };
|
|
3513
3507
|
for (const key in overrides) {
|
|
@@ -3704,6 +3698,245 @@ function splitVendorChunkPlugin() {
|
|
|
3704
3698
|
};
|
|
3705
3699
|
}
|
|
3706
3700
|
|
|
3701
|
+
var convertSourceMap$1 = {};
|
|
3702
|
+
|
|
3703
|
+
(function (exports) {
|
|
3704
|
+
|
|
3705
|
+
Object.defineProperty(exports, 'commentRegex', {
|
|
3706
|
+
get: function getCommentRegex () {
|
|
3707
|
+
// Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
|
|
3708
|
+
return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
|
|
3709
|
+
}
|
|
3710
|
+
});
|
|
3711
|
+
|
|
3712
|
+
|
|
3713
|
+
Object.defineProperty(exports, 'mapFileCommentRegex', {
|
|
3714
|
+
get: function getMapFileCommentRegex () {
|
|
3715
|
+
// Matches sourceMappingURL in either // or /* comment styles.
|
|
3716
|
+
return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
|
|
3717
|
+
}
|
|
3718
|
+
});
|
|
3719
|
+
|
|
3720
|
+
var decodeBase64;
|
|
3721
|
+
if (typeof Buffer !== 'undefined') {
|
|
3722
|
+
if (typeof Buffer.from === 'function') {
|
|
3723
|
+
decodeBase64 = decodeBase64WithBufferFrom;
|
|
3724
|
+
} else {
|
|
3725
|
+
decodeBase64 = decodeBase64WithNewBuffer;
|
|
3726
|
+
}
|
|
3727
|
+
} else {
|
|
3728
|
+
decodeBase64 = decodeBase64WithAtob;
|
|
3729
|
+
}
|
|
3730
|
+
|
|
3731
|
+
function decodeBase64WithBufferFrom(base64) {
|
|
3732
|
+
return Buffer.from(base64, 'base64').toString();
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
function decodeBase64WithNewBuffer(base64) {
|
|
3736
|
+
if (typeof value === 'number') {
|
|
3737
|
+
throw new TypeError('The value to decode must not be of type number.');
|
|
3738
|
+
}
|
|
3739
|
+
return new Buffer(base64, 'base64').toString();
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3742
|
+
function decodeBase64WithAtob(base64) {
|
|
3743
|
+
return decodeURIComponent(escape(atob(base64)));
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
function stripComment(sm) {
|
|
3747
|
+
return sm.split(',').pop();
|
|
3748
|
+
}
|
|
3749
|
+
|
|
3750
|
+
function readFromFileMap(sm, read) {
|
|
3751
|
+
var r = exports.mapFileCommentRegex.exec(sm);
|
|
3752
|
+
// for some odd reason //# .. captures in 1 and /* .. */ in 2
|
|
3753
|
+
var filename = r[1] || r[2];
|
|
3754
|
+
|
|
3755
|
+
try {
|
|
3756
|
+
var sm = read(filename);
|
|
3757
|
+
if (sm != null && typeof sm.catch === 'function') {
|
|
3758
|
+
return sm.catch(throwError);
|
|
3759
|
+
} else {
|
|
3760
|
+
return sm;
|
|
3761
|
+
}
|
|
3762
|
+
} catch (e) {
|
|
3763
|
+
throwError(e);
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
function throwError(e) {
|
|
3767
|
+
throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
|
|
3768
|
+
}
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
function Converter (sm, opts) {
|
|
3772
|
+
opts = opts || {};
|
|
3773
|
+
|
|
3774
|
+
if (opts.hasComment) {
|
|
3775
|
+
sm = stripComment(sm);
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3778
|
+
if (opts.encoding === 'base64') {
|
|
3779
|
+
sm = decodeBase64(sm);
|
|
3780
|
+
} else if (opts.encoding === 'uri') {
|
|
3781
|
+
sm = decodeURIComponent(sm);
|
|
3782
|
+
}
|
|
3783
|
+
|
|
3784
|
+
if (opts.isJSON || opts.encoding) {
|
|
3785
|
+
sm = JSON.parse(sm);
|
|
3786
|
+
}
|
|
3787
|
+
|
|
3788
|
+
this.sourcemap = sm;
|
|
3789
|
+
}
|
|
3790
|
+
|
|
3791
|
+
Converter.prototype.toJSON = function (space) {
|
|
3792
|
+
return JSON.stringify(this.sourcemap, null, space);
|
|
3793
|
+
};
|
|
3794
|
+
|
|
3795
|
+
if (typeof Buffer !== 'undefined') {
|
|
3796
|
+
if (typeof Buffer.from === 'function') {
|
|
3797
|
+
Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
|
|
3798
|
+
} else {
|
|
3799
|
+
Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
|
|
3800
|
+
}
|
|
3801
|
+
} else {
|
|
3802
|
+
Converter.prototype.toBase64 = encodeBase64WithBtoa;
|
|
3803
|
+
}
|
|
3804
|
+
|
|
3805
|
+
function encodeBase64WithBufferFrom() {
|
|
3806
|
+
var json = this.toJSON();
|
|
3807
|
+
return Buffer.from(json, 'utf8').toString('base64');
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
function encodeBase64WithNewBuffer() {
|
|
3811
|
+
var json = this.toJSON();
|
|
3812
|
+
if (typeof json === 'number') {
|
|
3813
|
+
throw new TypeError('The json to encode must not be of type number.');
|
|
3814
|
+
}
|
|
3815
|
+
return new Buffer(json, 'utf8').toString('base64');
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
function encodeBase64WithBtoa() {
|
|
3819
|
+
var json = this.toJSON();
|
|
3820
|
+
return btoa(unescape(encodeURIComponent(json)));
|
|
3821
|
+
}
|
|
3822
|
+
|
|
3823
|
+
Converter.prototype.toURI = function () {
|
|
3824
|
+
var json = this.toJSON();
|
|
3825
|
+
return encodeURIComponent(json);
|
|
3826
|
+
};
|
|
3827
|
+
|
|
3828
|
+
Converter.prototype.toComment = function (options) {
|
|
3829
|
+
var encoding, content, data;
|
|
3830
|
+
if (options != null && options.encoding === 'uri') {
|
|
3831
|
+
encoding = '';
|
|
3832
|
+
content = this.toURI();
|
|
3833
|
+
} else {
|
|
3834
|
+
encoding = ';base64';
|
|
3835
|
+
content = this.toBase64();
|
|
3836
|
+
}
|
|
3837
|
+
data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
|
|
3838
|
+
return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
|
|
3839
|
+
};
|
|
3840
|
+
|
|
3841
|
+
// returns copy instead of original
|
|
3842
|
+
Converter.prototype.toObject = function () {
|
|
3843
|
+
return JSON.parse(this.toJSON());
|
|
3844
|
+
};
|
|
3845
|
+
|
|
3846
|
+
Converter.prototype.addProperty = function (key, value) {
|
|
3847
|
+
if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
|
|
3848
|
+
return this.setProperty(key, value);
|
|
3849
|
+
};
|
|
3850
|
+
|
|
3851
|
+
Converter.prototype.setProperty = function (key, value) {
|
|
3852
|
+
this.sourcemap[key] = value;
|
|
3853
|
+
return this;
|
|
3854
|
+
};
|
|
3855
|
+
|
|
3856
|
+
Converter.prototype.getProperty = function (key) {
|
|
3857
|
+
return this.sourcemap[key];
|
|
3858
|
+
};
|
|
3859
|
+
|
|
3860
|
+
exports.fromObject = function (obj) {
|
|
3861
|
+
return new Converter(obj);
|
|
3862
|
+
};
|
|
3863
|
+
|
|
3864
|
+
exports.fromJSON = function (json) {
|
|
3865
|
+
return new Converter(json, { isJSON: true });
|
|
3866
|
+
};
|
|
3867
|
+
|
|
3868
|
+
exports.fromURI = function (uri) {
|
|
3869
|
+
return new Converter(uri, { encoding: 'uri' });
|
|
3870
|
+
};
|
|
3871
|
+
|
|
3872
|
+
exports.fromBase64 = function (base64) {
|
|
3873
|
+
return new Converter(base64, { encoding: 'base64' });
|
|
3874
|
+
};
|
|
3875
|
+
|
|
3876
|
+
exports.fromComment = function (comment) {
|
|
3877
|
+
var m, encoding;
|
|
3878
|
+
comment = comment
|
|
3879
|
+
.replace(/^\/\*/g, '//')
|
|
3880
|
+
.replace(/\*\/$/g, '');
|
|
3881
|
+
m = exports.commentRegex.exec(comment);
|
|
3882
|
+
encoding = m && m[4] || 'uri';
|
|
3883
|
+
return new Converter(comment, { encoding: encoding, hasComment: true });
|
|
3884
|
+
};
|
|
3885
|
+
|
|
3886
|
+
function makeConverter(sm) {
|
|
3887
|
+
return new Converter(sm, { isJSON: true });
|
|
3888
|
+
}
|
|
3889
|
+
|
|
3890
|
+
exports.fromMapFileComment = function (comment, read) {
|
|
3891
|
+
if (typeof read === 'string') {
|
|
3892
|
+
throw new Error(
|
|
3893
|
+
'String directory paths are no longer supported with `fromMapFileComment`\n' +
|
|
3894
|
+
'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
|
|
3895
|
+
)
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
var sm = readFromFileMap(comment, read);
|
|
3899
|
+
if (sm != null && typeof sm.then === 'function') {
|
|
3900
|
+
return sm.then(makeConverter);
|
|
3901
|
+
} else {
|
|
3902
|
+
return makeConverter(sm);
|
|
3903
|
+
}
|
|
3904
|
+
};
|
|
3905
|
+
|
|
3906
|
+
// Finds last sourcemap comment in file or returns null if none was found
|
|
3907
|
+
exports.fromSource = function (content) {
|
|
3908
|
+
var m = content.match(exports.commentRegex);
|
|
3909
|
+
return m ? exports.fromComment(m.pop()) : null;
|
|
3910
|
+
};
|
|
3911
|
+
|
|
3912
|
+
// Finds last sourcemap comment in file or returns null if none was found
|
|
3913
|
+
exports.fromMapFileSource = function (content, read) {
|
|
3914
|
+
if (typeof read === 'string') {
|
|
3915
|
+
throw new Error(
|
|
3916
|
+
'String directory paths are no longer supported with `fromMapFileSource`\n' +
|
|
3917
|
+
'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
|
|
3918
|
+
)
|
|
3919
|
+
}
|
|
3920
|
+
var m = content.match(exports.mapFileCommentRegex);
|
|
3921
|
+
return m ? exports.fromMapFileComment(m.pop(), read) : null;
|
|
3922
|
+
};
|
|
3923
|
+
|
|
3924
|
+
exports.removeComments = function (src) {
|
|
3925
|
+
return src.replace(exports.commentRegex, '');
|
|
3926
|
+
};
|
|
3927
|
+
|
|
3928
|
+
exports.removeMapFileComments = function (src) {
|
|
3929
|
+
return src.replace(exports.mapFileCommentRegex, '');
|
|
3930
|
+
};
|
|
3931
|
+
|
|
3932
|
+
exports.generateMapFileComment = function (file, options) {
|
|
3933
|
+
var data = 'sourceMappingURL=' + file;
|
|
3934
|
+
return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
|
|
3935
|
+
};
|
|
3936
|
+
} (convertSourceMap$1));
|
|
3937
|
+
|
|
3938
|
+
var convertSourceMap = /*@__PURE__*/getDefaultExportFromCjs(convertSourceMap$1);
|
|
3939
|
+
|
|
3707
3940
|
/*!
|
|
3708
3941
|
* etag
|
|
3709
3942
|
* Copyright(c) 2014-2016 Douglas Christopher Wilson
|
|
@@ -3945,6 +4178,13 @@ class Chunk {
|
|
|
3945
4178
|
this.end = index;
|
|
3946
4179
|
|
|
3947
4180
|
if (this.edited) {
|
|
4181
|
+
// after split we should save the edit content record into the correct chunk
|
|
4182
|
+
// to make sure sourcemap correct
|
|
4183
|
+
// For example:
|
|
4184
|
+
// ' test'.trim()
|
|
4185
|
+
// split -> ' ' + 'test'
|
|
4186
|
+
// ✔️ edit -> '' + 'test'
|
|
4187
|
+
// ✖️ edit -> 'test' + ''
|
|
3948
4188
|
// TODO is this block necessary?...
|
|
3949
4189
|
newChunk.edit('', false);
|
|
3950
4190
|
this.content = '';
|
|
@@ -3973,6 +4213,10 @@ class Chunk {
|
|
|
3973
4213
|
if (trimmed.length) {
|
|
3974
4214
|
if (trimmed !== this.content) {
|
|
3975
4215
|
this.split(this.start + trimmed.length).edit('', undefined, true);
|
|
4216
|
+
if (this.edited) {
|
|
4217
|
+
// save the change, if it has been edited
|
|
4218
|
+
this.edit(trimmed, this.storeName, true);
|
|
4219
|
+
}
|
|
3976
4220
|
}
|
|
3977
4221
|
return true;
|
|
3978
4222
|
} else {
|
|
@@ -3991,7 +4235,11 @@ class Chunk {
|
|
|
3991
4235
|
|
|
3992
4236
|
if (trimmed.length) {
|
|
3993
4237
|
if (trimmed !== this.content) {
|
|
3994
|
-
this.split(this.end - trimmed.length);
|
|
4238
|
+
const newChunk = this.split(this.end - trimmed.length);
|
|
4239
|
+
if (this.edited) {
|
|
4240
|
+
// save the change, if it has been edited
|
|
4241
|
+
newChunk.edit(trimmed, this.storeName, true);
|
|
4242
|
+
}
|
|
3995
4243
|
this.edit('', undefined, true);
|
|
3996
4244
|
}
|
|
3997
4245
|
return true;
|
|
@@ -4016,7 +4264,7 @@ function getBtoa() {
|
|
|
4016
4264
|
}
|
|
4017
4265
|
}
|
|
4018
4266
|
|
|
4019
|
-
const btoa = /*#__PURE__*/ getBtoa();
|
|
4267
|
+
const btoa$1 = /*#__PURE__*/ getBtoa();
|
|
4020
4268
|
|
|
4021
4269
|
class SourceMap {
|
|
4022
4270
|
constructor(properties) {
|
|
@@ -4036,7 +4284,7 @@ class SourceMap {
|
|
|
4036
4284
|
}
|
|
4037
4285
|
|
|
4038
4286
|
toUrl() {
|
|
4039
|
-
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
|
|
4287
|
+
return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
|
|
4040
4288
|
}
|
|
4041
4289
|
}
|
|
4042
4290
|
|
|
@@ -5003,7 +5251,7 @@ class MagicString {
|
|
|
5003
5251
|
}
|
|
5004
5252
|
}
|
|
5005
5253
|
|
|
5006
|
-
const debug = createDebugger('vite:sourcemap', {
|
|
5254
|
+
const debug$1 = createDebugger('vite:sourcemap', {
|
|
5007
5255
|
onlyWhenFocused: true,
|
|
5008
5256
|
});
|
|
5009
5257
|
function genSourceMapUrl(map) {
|
|
@@ -5013,7 +5261,7 @@ function genSourceMapUrl(map) {
|
|
|
5013
5261
|
return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
|
|
5014
5262
|
}
|
|
5015
5263
|
function getCodeWithSourcemap(type, code, map) {
|
|
5016
|
-
if (debug) {
|
|
5264
|
+
if (debug$1) {
|
|
5017
5265
|
code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
|
|
5018
5266
|
}
|
|
5019
5267
|
if (type === 'js') {
|
|
@@ -5025,6 +5273,9 @@ function getCodeWithSourcemap(type, code, map) {
|
|
|
5025
5273
|
return code;
|
|
5026
5274
|
}
|
|
5027
5275
|
|
|
5276
|
+
const debug = createDebugger('vite:send', {
|
|
5277
|
+
onlyWhenFocused: true,
|
|
5278
|
+
});
|
|
5028
5279
|
const alias = {
|
|
5029
5280
|
js: 'application/javascript',
|
|
5030
5281
|
css: 'text/css',
|
|
@@ -5055,11 +5306,22 @@ function send(req, res, content, type, options) {
|
|
|
5055
5306
|
content = getCodeWithSourcemap(type, content.toString(), map);
|
|
5056
5307
|
}
|
|
5057
5308
|
}
|
|
5058
|
-
|
|
5059
|
-
|
|
5309
|
+
// inject fallback sourcemap for js for improved debugging
|
|
5310
|
+
// https://github.com/vitejs/vite/pull/13514#issuecomment-1592431496
|
|
5311
|
+
else if (type === 'js' && (!map || map.mappings !== '')) {
|
|
5312
|
+
const code = content.toString();
|
|
5313
|
+
// if the code has existing inline sourcemap, assume it's correct and skip
|
|
5314
|
+
if (convertSourceMap.mapFileCommentRegex.test(code)) {
|
|
5315
|
+
debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
|
|
5316
|
+
}
|
|
5317
|
+
else {
|
|
5060
5318
|
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
|
5061
|
-
const ms = new MagicString(
|
|
5062
|
-
content = getCodeWithSourcemap(type,
|
|
5319
|
+
const ms = new MagicString(code);
|
|
5320
|
+
content = getCodeWithSourcemap(type, code, ms.generateMap({
|
|
5321
|
+
source: path$3.basename(urlWithoutTimestamp),
|
|
5322
|
+
hires: 'boundary',
|
|
5323
|
+
includeContent: true,
|
|
5324
|
+
}));
|
|
5063
5325
|
}
|
|
5064
5326
|
}
|
|
5065
5327
|
res.statusCode = 200;
|
|
@@ -5191,8 +5453,13 @@ function hasWorkspacePackageJSON(root) {
|
|
|
5191
5453
|
if (!isFileReadable(path)) {
|
|
5192
5454
|
return false;
|
|
5193
5455
|
}
|
|
5194
|
-
|
|
5195
|
-
|
|
5456
|
+
try {
|
|
5457
|
+
const content = JSON.parse(fs$1.readFileSync(path, 'utf-8')) || {};
|
|
5458
|
+
return !!content.workspaces;
|
|
5459
|
+
}
|
|
5460
|
+
catch {
|
|
5461
|
+
return false;
|
|
5462
|
+
}
|
|
5196
5463
|
}
|
|
5197
5464
|
function hasRootFile(root) {
|
|
5198
5465
|
return ROOT_FILES.some((file) => fs$1.existsSync(path$3.join(root, file)));
|
|
@@ -5641,48 +5908,59 @@ main$1.exports.populate = DotenvModule.populate;
|
|
|
5641
5908
|
|
|
5642
5909
|
main$1.exports = DotenvModule;
|
|
5643
5910
|
|
|
5911
|
+
// like String.prototype.search but returns the last index
|
|
5912
|
+
function _searchLast (str, rgx) {
|
|
5913
|
+
const matches = Array.from(str.matchAll(rgx));
|
|
5914
|
+
return matches.length > 0 ? matches.slice(-1)[0].index : -1
|
|
5915
|
+
}
|
|
5916
|
+
|
|
5644
5917
|
function _interpolate (envValue, environment, config) {
|
|
5645
|
-
|
|
5918
|
+
// find the last unescaped dollar sign in the
|
|
5919
|
+
// value so that we can evaluate it
|
|
5920
|
+
const lastUnescapedDollarSignIndex = _searchLast(envValue, /(?!(?<=\\))\$/g);
|
|
5646
5921
|
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
return newEnv
|
|
5651
|
-
}
|
|
5922
|
+
// If we couldn't match any unescaped dollar sign
|
|
5923
|
+
// let's return the string as is
|
|
5924
|
+
if (lastUnescapedDollarSignIndex === -1) return envValue
|
|
5652
5925
|
|
|
5653
|
-
|
|
5926
|
+
// This is the right-most group of variables in the string
|
|
5927
|
+
const rightMostGroup = envValue.slice(lastUnescapedDollarSignIndex);
|
|
5654
5928
|
|
|
5655
|
-
|
|
5929
|
+
/**
|
|
5930
|
+
* This finds the inner most variable/group divided
|
|
5931
|
+
* by variable name and default value (if present)
|
|
5932
|
+
* (
|
|
5933
|
+
* (?!(?<=\\))\$ // only match dollar signs that are not escaped
|
|
5934
|
+
* {? // optional opening curly brace
|
|
5935
|
+
* ([\w]+) // match the variable name
|
|
5936
|
+
* (?::-([^}\\]*))? // match an optional default value
|
|
5937
|
+
* }? // optional closing curly brace
|
|
5938
|
+
* )
|
|
5939
|
+
*/
|
|
5940
|
+
const matchGroup = /((?!(?<=\\))\${?([\w]+)(?::-([^}\\]*))?}?)/;
|
|
5941
|
+
const match = rightMostGroup.match(matchGroup);
|
|
5942
|
+
|
|
5943
|
+
if (match != null) {
|
|
5944
|
+
const [, group, variableName, defaultValue] = match;
|
|
5945
|
+
|
|
5946
|
+
return _interpolate(
|
|
5947
|
+
envValue.replace(
|
|
5948
|
+
group,
|
|
5949
|
+
environment[variableName] ||
|
|
5950
|
+
defaultValue ||
|
|
5951
|
+
config.parsed[variableName] ||
|
|
5952
|
+
''
|
|
5953
|
+
),
|
|
5954
|
+
environment,
|
|
5955
|
+
config
|
|
5956
|
+
)
|
|
5957
|
+
}
|
|
5656
5958
|
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
value = replacePart.replace('\\$', '$');
|
|
5660
|
-
} else {
|
|
5661
|
-
// PATCH: compatible with env variables ended with unescaped $
|
|
5662
|
-
if(!parts[2]) {
|
|
5663
|
-
return newEnv
|
|
5664
|
-
}
|
|
5665
|
-
const keyParts = parts[2].split(':-');
|
|
5666
|
-
const key = keyParts[0];
|
|
5667
|
-
replacePart = parts[0].substring(prefix.length);
|
|
5668
|
-
// process.env value 'wins' over .env file's value
|
|
5669
|
-
value = Object.prototype.hasOwnProperty.call(environment, key)
|
|
5670
|
-
? environment[key]
|
|
5671
|
-
: (config.parsed[key] || keyParts[1] || '');
|
|
5672
|
-
|
|
5673
|
-
// If the value is found, remove nested expansions.
|
|
5674
|
-
if (keyParts.length > 1 && value) {
|
|
5675
|
-
const replaceNested = matches[index + 1];
|
|
5676
|
-
matches[index + 1] = '';
|
|
5677
|
-
|
|
5678
|
-
newEnv = newEnv.replace(replaceNested, '');
|
|
5679
|
-
}
|
|
5680
|
-
// Resolve recursive interpolations
|
|
5681
|
-
value = _interpolate(value, environment, config);
|
|
5682
|
-
}
|
|
5959
|
+
return envValue
|
|
5960
|
+
}
|
|
5683
5961
|
|
|
5684
|
-
|
|
5685
|
-
|
|
5962
|
+
function _resolveEscapeSequences (value) {
|
|
5963
|
+
return value.replace(/\\\$/g, '$')
|
|
5686
5964
|
}
|
|
5687
5965
|
|
|
5688
5966
|
function expand (config) {
|
|
@@ -5690,9 +5968,13 @@ function expand (config) {
|
|
|
5690
5968
|
const environment = config.ignoreProcessEnv ? {} : process.env;
|
|
5691
5969
|
|
|
5692
5970
|
for (const configKey in config.parsed) {
|
|
5693
|
-
const value = Object.prototype.hasOwnProperty.call(environment, configKey)
|
|
5971
|
+
const value = Object.prototype.hasOwnProperty.call(environment, configKey)
|
|
5972
|
+
? environment[configKey]
|
|
5973
|
+
: config.parsed[configKey];
|
|
5694
5974
|
|
|
5695
|
-
config.parsed[configKey] =
|
|
5975
|
+
config.parsed[configKey] = _resolveEscapeSequences(
|
|
5976
|
+
_interpolate(value, environment, config)
|
|
5977
|
+
);
|
|
5696
5978
|
}
|
|
5697
5979
|
|
|
5698
5980
|
// PATCH: don't write to process.env
|
package/index.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable no-restricted-globals */
|
|
2
2
|
|
|
3
|
+
warnCjsUsage()
|
|
4
|
+
|
|
3
5
|
// type utils
|
|
4
6
|
module.exports.defineConfig = (config) => config
|
|
5
7
|
|
|
@@ -32,3 +34,15 @@ unsupportedCJS.forEach((name) => {
|
|
|
32
34
|
)
|
|
33
35
|
}
|
|
34
36
|
})
|
|
37
|
+
|
|
38
|
+
function warnCjsUsage() {
|
|
39
|
+
if (process.env.VITE_CJS_IGNORE_WARNING) return
|
|
40
|
+
globalThis.__vite_cjs_skip_clear_screen = true
|
|
41
|
+
const yellow = (str) => `\u001b[33m${str}\u001b[39m`
|
|
42
|
+
const log = process.env.VITE_CJS_TRACE ? console.trace : console.warn
|
|
43
|
+
log(
|
|
44
|
+
yellow(
|
|
45
|
+
`The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.`,
|
|
46
|
+
),
|
|
47
|
+
)
|
|
48
|
+
}
|