vite 2.7.0-beta.3 → 2.7.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/CHANGELOG.md +55 -0
- package/dist/node/chunks/{dep-5243d0d3.js → dep-56ab4c22.js} +392 -146
- package/dist/node/chunks/dep-56ab4c22.js.map +1 -0
- package/dist/node/chunks/{dep-777faa4b.js → dep-606d0866.js} +2 -2
- package/dist/node/chunks/{dep-777faa4b.js.map → dep-606d0866.js.map} +1 -1
- package/dist/node/chunks/{dep-c1084913.js → dep-707302f6.js} +2 -2
- package/dist/node/chunks/{dep-c1084913.js.map → dep-707302f6.js.map} +1 -1
- package/dist/node/chunks/{dep-59a3bcf9.js → dep-9a51c06c.js} +3 -3
- package/dist/node/chunks/dep-9a51c06c.js.map +1 -0
- package/dist/node/cli.js +4 -7
- package/dist/node/cli.js.map +1 -1
- package/dist/node/index.d.ts +18 -7
- package/dist/node/index.js +1 -1
- package/dist/node/terser.js +186 -54
- package/package.json +7 -6
- package/types/commonjs.d.ts +2 -2
- package/types/shims.d.ts +2 -3
- package/dist/node/chunks/dep-5243d0d3.js.map +0 -1
- package/dist/node/chunks/dep-59a3bcf9.js.map +0 -1
|
@@ -10,7 +10,7 @@ var require$$0$a = require('events');
|
|
|
10
10
|
var require$$0$7 = require('url');
|
|
11
11
|
var require$$1$2 = require('http');
|
|
12
12
|
var require$$0$9 = require('stream');
|
|
13
|
-
var resolve$
|
|
13
|
+
var resolve$3 = require('resolve');
|
|
14
14
|
var require$$0$6 = require('module');
|
|
15
15
|
var perf_hooks = require('perf_hooks');
|
|
16
16
|
var require$$1$3 = require('https');
|
|
@@ -50,7 +50,7 @@ var require$$0__default$5 = /*#__PURE__*/_interopDefaultLegacy(require$$0$a);
|
|
|
50
50
|
var require$$0__default$6 = /*#__PURE__*/_interopDefaultLegacy(require$$0$7);
|
|
51
51
|
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$2);
|
|
52
52
|
var require$$0__default$4 = /*#__PURE__*/_interopDefaultLegacy(require$$0$9);
|
|
53
|
-
var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve$
|
|
53
|
+
var resolve__default = /*#__PURE__*/_interopDefaultLegacy(resolve$3);
|
|
54
54
|
var require$$0__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$0$6);
|
|
55
55
|
var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
|
|
56
56
|
var require$$0__default$7 = /*#__PURE__*/_interopDefaultLegacy(require$$0$8);
|
|
@@ -3387,7 +3387,7 @@ function normalizePath$5(input) {
|
|
|
3387
3387
|
/**
|
|
3388
3388
|
* Attempts to resolve `input` URL relative to `base`.
|
|
3389
3389
|
*/
|
|
3390
|
-
function resolve$
|
|
3390
|
+
function resolve$2(input, base) {
|
|
3391
3391
|
if (!base)
|
|
3392
3392
|
base = '';
|
|
3393
3393
|
// Absolute URLs are very easy to resolve right.
|
|
@@ -3455,7 +3455,7 @@ function resolve$1$1(input, base) {
|
|
|
3455
3455
|
// https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
|
|
3456
3456
|
if (base && !base.endsWith('/'))
|
|
3457
3457
|
base += '/';
|
|
3458
|
-
return resolve$
|
|
3458
|
+
return resolve$2(input, base);
|
|
3459
3459
|
}
|
|
3460
3460
|
|
|
3461
3461
|
/**
|
|
@@ -3958,6 +3958,8 @@ const externalRE = /^(https?:)?\/\//;
|
|
|
3958
3958
|
const isExternalUrl = (url) => externalRE.test(url);
|
|
3959
3959
|
const dataUrlRE = /^\s*data:/i;
|
|
3960
3960
|
const isDataUrl = (url) => dataUrlRE.test(url);
|
|
3961
|
+
const virtualModuleRE = /^virtual-module:.*/;
|
|
3962
|
+
const virtualModulePrefix = 'virtual-module:';
|
|
3961
3963
|
const knownJsSrcRE = /\.((j|t)sx?|mjs|vue|marko|svelte|astro)($|\?)/;
|
|
3962
3964
|
const isJSRequest = (url) => {
|
|
3963
3965
|
url = cleanUrl(url);
|
|
@@ -3973,7 +3975,7 @@ const knownTsRE = /\.(ts|mts|cts|tsx)$/;
|
|
|
3973
3975
|
const knownTsOutputRE = /\.(js|mjs|cjs|jsx)$/;
|
|
3974
3976
|
const isTsRequest = (url) => knownTsRE.test(cleanUrl(url));
|
|
3975
3977
|
const isPossibleTsOutput = (url) => knownTsOutputRE.test(cleanUrl(url));
|
|
3976
|
-
const getTsSrcPath = (filename) => filename.replace(/\.([cm])?(js)(x?)
|
|
3978
|
+
const getTsSrcPath = (filename) => filename.replace(/\.([cm])?(js)(x?)(\?|$)/, '.$1ts$3');
|
|
3977
3979
|
const importQueryRE = /(\?|&)import=?(?:&|$)/;
|
|
3978
3980
|
const internalPrefixes = [
|
|
3979
3981
|
FS_PREFIX,
|
|
@@ -4058,6 +4060,9 @@ function prettifyUrl(url, root) {
|
|
|
4058
4060
|
function isObject$3(value) {
|
|
4059
4061
|
return Object.prototype.toString.call(value) === '[object Object]';
|
|
4060
4062
|
}
|
|
4063
|
+
function isDefined(value) {
|
|
4064
|
+
return value != null;
|
|
4065
|
+
}
|
|
4061
4066
|
function lookupFile(dir, formats, pathOnly = false) {
|
|
4062
4067
|
for (const format of formats) {
|
|
4063
4068
|
const fullPath = path__default.join(dir, format);
|
|
@@ -4343,9 +4348,8 @@ function createLogger(level = 'info', options = {}) {
|
|
|
4343
4348
|
const loggedErrors = new WeakSet();
|
|
4344
4349
|
const { prefix = '[vite]', allowClearScreen = true } = options;
|
|
4345
4350
|
const thresh = LogLevels[level];
|
|
4346
|
-
const
|
|
4347
|
-
|
|
4348
|
-
: () => { };
|
|
4351
|
+
const canClearScreen = allowClearScreen && process.stdout.isTTY && !process.env.CI;
|
|
4352
|
+
const clear = canClearScreen ? clearScreen : () => { };
|
|
4349
4353
|
function output(type, msg, options = {}) {
|
|
4350
4354
|
if (thresh >= LogLevels[type]) {
|
|
4351
4355
|
const method = type === 'info' ? 'log' : type;
|
|
@@ -4365,18 +4369,23 @@ function createLogger(level = 'info', options = {}) {
|
|
|
4365
4369
|
if (options.error) {
|
|
4366
4370
|
loggedErrors.add(options.error);
|
|
4367
4371
|
}
|
|
4368
|
-
if (
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
console[method](format(), source.yellow(`(x${sameCount + 1})`));
|
|
4372
|
-
}
|
|
4373
|
-
else {
|
|
4374
|
-
sameCount = 0;
|
|
4375
|
-
lastMsg = msg;
|
|
4376
|
-
lastType = type;
|
|
4377
|
-
if (options.clear) {
|
|
4372
|
+
if (canClearScreen) {
|
|
4373
|
+
if (type === lastType && msg === lastMsg) {
|
|
4374
|
+
sameCount++;
|
|
4378
4375
|
clear();
|
|
4376
|
+
console[method](format(), source.yellow(`(x${sameCount + 1})`));
|
|
4379
4377
|
}
|
|
4378
|
+
else {
|
|
4379
|
+
sameCount = 0;
|
|
4380
|
+
lastMsg = msg;
|
|
4381
|
+
lastType = type;
|
|
4382
|
+
if (options.clear) {
|
|
4383
|
+
clear();
|
|
4384
|
+
}
|
|
4385
|
+
console[method](format());
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
else {
|
|
4380
4389
|
console[method](format());
|
|
4381
4390
|
}
|
|
4382
4391
|
}
|
|
@@ -19599,7 +19608,7 @@ const plugins = (config, file) => {
|
|
|
19599
19608
|
|
|
19600
19609
|
var plugins_1 = plugins;
|
|
19601
19610
|
|
|
19602
|
-
const resolve$
|
|
19611
|
+
const resolve$1 = path__default.resolve;
|
|
19603
19612
|
|
|
19604
19613
|
const config$1 = dist$2;
|
|
19605
19614
|
const yaml = yaml$1;
|
|
@@ -19738,7 +19747,7 @@ const rc = withTypeScriptLoader((ctx, path, options) => {
|
|
|
19738
19747
|
/**
|
|
19739
19748
|
* @type {String} `process.cwd()`
|
|
19740
19749
|
*/
|
|
19741
|
-
path = path ? resolve$
|
|
19750
|
+
path = path ? resolve$1(path) : process.cwd();
|
|
19742
19751
|
|
|
19743
19752
|
return config$1.lilconfig('postcss', options)
|
|
19744
19753
|
.search(path)
|
|
@@ -19760,7 +19769,7 @@ rc.sync = withTypeScriptLoader((ctx, path, options) => {
|
|
|
19760
19769
|
/**
|
|
19761
19770
|
* @type {String} `process.cwd()`
|
|
19762
19771
|
*/
|
|
19763
|
-
path = path ? resolve$
|
|
19772
|
+
path = path ? resolve$1(path) : process.cwd();
|
|
19764
19773
|
|
|
19765
19774
|
const result = config$1.lilconfigSync('postcss', options).search(path);
|
|
19766
19775
|
|
|
@@ -20377,7 +20386,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
20377
20386
|
replacer: urlReplacer
|
|
20378
20387
|
}));
|
|
20379
20388
|
if (isModule) {
|
|
20380
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
20389
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-707302f6.js'); }).then(function (n) { return n.index; })).default({
|
|
20381
20390
|
...modulesOptions,
|
|
20382
20391
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
20383
20392
|
modules = _modules;
|
|
@@ -21342,7 +21351,7 @@ const assetAttrsConfig = {
|
|
|
21342
21351
|
const isAsyncScriptMap = new WeakMap();
|
|
21343
21352
|
async function traverseHtml(html, filePath, visitor) {
|
|
21344
21353
|
// lazy load compiler
|
|
21345
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
21354
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-9a51c06c.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
21346
21355
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
21347
21356
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
21348
21357
|
try {
|
|
@@ -22426,7 +22435,15 @@ function esbuildPlugin(options = {}) {
|
|
|
22426
22435
|
const rollupToEsbuildFormatMap = {
|
|
22427
22436
|
es: 'esm',
|
|
22428
22437
|
cjs: 'cjs',
|
|
22429
|
-
|
|
22438
|
+
// passing `var Lib = (() => {})()` to esbuild with format = "iife"
|
|
22439
|
+
// will turn it to `(() => { var Lib = (() => {})() })()`,
|
|
22440
|
+
// so we remove the format config to tell esbuild not doing this
|
|
22441
|
+
//
|
|
22442
|
+
// although esbuild doesn't change format, there is still possibility
|
|
22443
|
+
// that `{ treeShaking: true }` removes a top-level no-side-effect variable
|
|
22444
|
+
// like: `var Lib = 1`, which becomes `` after esbuild transforming,
|
|
22445
|
+
// but thankfully rollup does not do this optimization now
|
|
22446
|
+
iife: undefined
|
|
22430
22447
|
};
|
|
22431
22448
|
const buildEsbuildPlugin = (config) => {
|
|
22432
22449
|
return {
|
|
@@ -27622,7 +27639,7 @@ function getRequireStringArg(node) {
|
|
|
27622
27639
|
function hasDynamicModuleForPath(source, id, dynamicRequireModuleSet) {
|
|
27623
27640
|
if (!/^(?:\.{0,2}[/\\]|[A-Za-z]:[/\\])/.test(source)) {
|
|
27624
27641
|
try {
|
|
27625
|
-
const resolvedPath = normalizePathSlashes(resolve$
|
|
27642
|
+
const resolvedPath = normalizePathSlashes(resolve$3.sync(source, { basedir: path$t.dirname(id) }));
|
|
27626
27643
|
if (dynamicRequireModuleSet.has(resolvedPath)) {
|
|
27627
27644
|
return true;
|
|
27628
27645
|
}
|
|
@@ -29877,7 +29894,7 @@ function toName(name, entry) {
|
|
|
29877
29894
|
* @param {string[]} [options.conditions]
|
|
29878
29895
|
* @param {boolean} [options.unsafe]
|
|
29879
29896
|
*/
|
|
29880
|
-
function resolve
|
|
29897
|
+
function resolve(pkg, entry='.', options={}) {
|
|
29881
29898
|
let { name, exports } = pkg;
|
|
29882
29899
|
|
|
29883
29900
|
if (exports) {
|
|
@@ -29966,12 +29983,11 @@ function resolvePlugin(baseOptions) {
|
|
|
29966
29983
|
isRequire,
|
|
29967
29984
|
isFromTsImporter: isTsRequest(importer !== null && importer !== void 0 ? importer : '')
|
|
29968
29985
|
};
|
|
29969
|
-
const preserveSymlinks = !!(server === null || server === void 0 ? void 0 : server.config.resolve.preserveSymlinks);
|
|
29970
29986
|
let res;
|
|
29971
29987
|
// explicit fs paths that starts with /@fs/*
|
|
29972
29988
|
if (asSrc && id.startsWith(FS_PREFIX)) {
|
|
29973
29989
|
const fsPath = fsPathFromId(id);
|
|
29974
|
-
res = tryFsResolve(fsPath, options
|
|
29990
|
+
res = tryFsResolve(fsPath, options);
|
|
29975
29991
|
isDebug$5 && debug$d(`[@fs] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
29976
29992
|
// always return here even if res doesn't exist since /@fs/ is explicit
|
|
29977
29993
|
// if the file doesn't exist it should be a 404
|
|
@@ -29981,7 +29997,7 @@ function resolvePlugin(baseOptions) {
|
|
|
29981
29997
|
// /foo -> /fs-root/foo
|
|
29982
29998
|
if (asSrc && id.startsWith('/')) {
|
|
29983
29999
|
const fsPath = path__default.resolve(root, id.slice(1));
|
|
29984
|
-
if ((res = tryFsResolve(fsPath, options
|
|
30000
|
+
if ((res = tryFsResolve(fsPath, options))) {
|
|
29985
30001
|
isDebug$5 && debug$d(`[url] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
29986
30002
|
return res;
|
|
29987
30003
|
}
|
|
@@ -30003,10 +30019,10 @@ function resolvePlugin(baseOptions) {
|
|
|
30003
30019
|
}
|
|
30004
30020
|
}
|
|
30005
30021
|
if (targetWeb &&
|
|
30006
|
-
(res = tryResolveBrowserMapping(fsPath, importer, options, true
|
|
30022
|
+
(res = tryResolveBrowserMapping(fsPath, importer, options, true))) {
|
|
30007
30023
|
return res;
|
|
30008
30024
|
}
|
|
30009
|
-
if ((res = tryFsResolve(fsPath, options
|
|
30025
|
+
if ((res = tryFsResolve(fsPath, options))) {
|
|
30010
30026
|
isDebug$5 && debug$d(`[relative] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
30011
30027
|
const pkg = importer != null && idToPkgMap.get(importer);
|
|
30012
30028
|
if (pkg) {
|
|
@@ -30020,8 +30036,7 @@ function resolvePlugin(baseOptions) {
|
|
|
30020
30036
|
}
|
|
30021
30037
|
}
|
|
30022
30038
|
// absolute fs paths
|
|
30023
|
-
if (path__default.isAbsolute(id) &&
|
|
30024
|
-
(res = tryFsResolve(id, options, preserveSymlinks))) {
|
|
30039
|
+
if (path__default.isAbsolute(id) && (res = tryFsResolve(id, options))) {
|
|
30025
30040
|
isDebug$5 && debug$d(`[fs] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
30026
30041
|
return res;
|
|
30027
30042
|
}
|
|
@@ -30046,7 +30061,7 @@ function resolvePlugin(baseOptions) {
|
|
|
30046
30061
|
return res;
|
|
30047
30062
|
}
|
|
30048
30063
|
if (targetWeb &&
|
|
30049
|
-
(res = tryResolveBrowserMapping(id, importer, options, false
|
|
30064
|
+
(res = tryResolveBrowserMapping(id, importer, options, false))) {
|
|
30050
30065
|
return res;
|
|
30051
30066
|
}
|
|
30052
30067
|
if ((res = tryNodeResolve(id, importer, options, targetWeb, server, ssr))) {
|
|
@@ -30095,7 +30110,7 @@ function resolvePlugin(baseOptions) {
|
|
|
30095
30110
|
}
|
|
30096
30111
|
};
|
|
30097
30112
|
}
|
|
30098
|
-
function tryFsResolve(fsPath, options,
|
|
30113
|
+
function tryFsResolve(fsPath, options, tryIndex = true, targetWeb = true) {
|
|
30099
30114
|
let file = fsPath;
|
|
30100
30115
|
let postfix = '';
|
|
30101
30116
|
let postfixIndex = fsPath.indexOf('?');
|
|
@@ -30109,36 +30124,36 @@ function tryFsResolve(fsPath, options, preserveSymlinks, tryIndex = true, target
|
|
|
30109
30124
|
let res;
|
|
30110
30125
|
// if we fould postfix exist, we should first try resolving file with postfix. details see #4703.
|
|
30111
30126
|
if (postfix &&
|
|
30112
|
-
(res = tryResolveFile(fsPath, '', options, false, targetWeb,
|
|
30127
|
+
(res = tryResolveFile(fsPath, '', options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30113
30128
|
return res;
|
|
30114
30129
|
}
|
|
30115
|
-
if ((res = tryResolveFile(file, postfix, options, false, targetWeb,
|
|
30130
|
+
if ((res = tryResolveFile(file, postfix, options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30116
30131
|
return res;
|
|
30117
30132
|
}
|
|
30118
30133
|
for (const ext of options.extensions || DEFAULT_EXTENSIONS$1) {
|
|
30119
30134
|
if (postfix &&
|
|
30120
|
-
(res = tryResolveFile(fsPath + ext, '', options, false, targetWeb,
|
|
30135
|
+
(res = tryResolveFile(fsPath + ext, '', options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30121
30136
|
return res;
|
|
30122
30137
|
}
|
|
30123
|
-
if ((res = tryResolveFile(file + ext, postfix, options, false, targetWeb,
|
|
30138
|
+
if ((res = tryResolveFile(file + ext, postfix, options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30124
30139
|
return res;
|
|
30125
30140
|
}
|
|
30126
30141
|
}
|
|
30127
30142
|
if (postfix &&
|
|
30128
|
-
(res = tryResolveFile(fsPath, '', options, tryIndex, targetWeb,
|
|
30143
|
+
(res = tryResolveFile(fsPath, '', options, tryIndex, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30129
30144
|
return res;
|
|
30130
30145
|
}
|
|
30131
|
-
if ((res = tryResolveFile(file, postfix, options, tryIndex, targetWeb,
|
|
30146
|
+
if ((res = tryResolveFile(file, postfix, options, tryIndex, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30132
30147
|
return res;
|
|
30133
30148
|
}
|
|
30134
30149
|
}
|
|
30135
|
-
function tryResolveFile(file, postfix, options, tryIndex, targetWeb,
|
|
30150
|
+
function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix, skipPackageJson) {
|
|
30136
30151
|
// #2051 if we don't have read permission on a directory, existsSync() still
|
|
30137
30152
|
// works and will result in massively slow subsequent checks (which are
|
|
30138
30153
|
// unnecessary in the first place)
|
|
30139
30154
|
if (isFileReadable(file)) {
|
|
30140
30155
|
if (!fs__default.statSync(file).isDirectory()) {
|
|
30141
|
-
return getRealPath(file, preserveSymlinks) + postfix;
|
|
30156
|
+
return getRealPath(file, options.preserveSymlinks) + postfix;
|
|
30142
30157
|
}
|
|
30143
30158
|
else if (tryIndex) {
|
|
30144
30159
|
if (!skipPackageJson) {
|
|
@@ -30146,11 +30161,11 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, preserveSym
|
|
|
30146
30161
|
if (fs__default.existsSync(pkgPath)) {
|
|
30147
30162
|
// path points to a node package
|
|
30148
30163
|
const pkg = loadPackageData(pkgPath);
|
|
30149
|
-
const resolved = resolvePackageEntry(file, pkg,
|
|
30164
|
+
const resolved = resolvePackageEntry(file, pkg, targetWeb, options);
|
|
30150
30165
|
return resolved;
|
|
30151
30166
|
}
|
|
30152
30167
|
}
|
|
30153
|
-
const index = tryFsResolve(file + '/index', options
|
|
30168
|
+
const index = tryFsResolve(file + '/index', options);
|
|
30154
30169
|
if (index)
|
|
30155
30170
|
return index + postfix;
|
|
30156
30171
|
}
|
|
@@ -30158,11 +30173,11 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, preserveSym
|
|
|
30158
30173
|
const tryTsExtension = options.isFromTsImporter && isPossibleTsOutput(file);
|
|
30159
30174
|
if (tryTsExtension) {
|
|
30160
30175
|
const tsSrcPath = getTsSrcPath(file);
|
|
30161
|
-
return tryResolveFile(tsSrcPath, postfix, options, tryIndex, targetWeb,
|
|
30176
|
+
return tryResolveFile(tsSrcPath, postfix, options, tryIndex, targetWeb, tryPrefix, skipPackageJson);
|
|
30162
30177
|
}
|
|
30163
30178
|
if (tryPrefix) {
|
|
30164
30179
|
const prefixed = `${path__default.dirname(file)}/${tryPrefix}${path__default.basename(file)}`;
|
|
30165
|
-
return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb
|
|
30180
|
+
return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb);
|
|
30166
30181
|
}
|
|
30167
30182
|
}
|
|
30168
30183
|
const idToPkgMap = new Map();
|
|
@@ -30175,11 +30190,28 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
30175
30190
|
const lastArrowIndex = id.lastIndexOf('>');
|
|
30176
30191
|
const nestedRoot = id.substring(0, lastArrowIndex).trim();
|
|
30177
30192
|
const nestedPath = id.substring(lastArrowIndex + 1).trim();
|
|
30178
|
-
|
|
30179
|
-
|
|
30180
|
-
|
|
30193
|
+
const possiblePkgIds = [];
|
|
30194
|
+
for (let prevSlashIndex = -1;;) {
|
|
30195
|
+
let slashIndex = nestedPath.indexOf('/', prevSlashIndex + 1);
|
|
30196
|
+
if (slashIndex < 0) {
|
|
30197
|
+
slashIndex = nestedPath.length;
|
|
30198
|
+
}
|
|
30199
|
+
const part = nestedPath.slice(prevSlashIndex + 1, (prevSlashIndex = slashIndex));
|
|
30200
|
+
if (!part) {
|
|
30201
|
+
break;
|
|
30202
|
+
}
|
|
30203
|
+
// Assume path parts with an extension are not package roots, except for the
|
|
30204
|
+
// first path part (since periods are sadly allowed in package names).
|
|
30205
|
+
// At the same time, skip the first path part if it begins with "@"
|
|
30206
|
+
// (since "@foo/bar" should be treated as the top-level path).
|
|
30207
|
+
if (possiblePkgIds.length ? path__default.extname(part) : part[0] === '@') {
|
|
30208
|
+
continue;
|
|
30209
|
+
}
|
|
30210
|
+
const possiblePkgId = nestedPath.slice(0, slashIndex);
|
|
30211
|
+
possiblePkgIds.push(possiblePkgId);
|
|
30212
|
+
}
|
|
30181
30213
|
let basedir;
|
|
30182
|
-
if (dedupe
|
|
30214
|
+
if (dedupe === null || dedupe === void 0 ? void 0 : dedupe.some((id) => possiblePkgIds.includes(id))) {
|
|
30183
30215
|
basedir = root;
|
|
30184
30216
|
}
|
|
30185
30217
|
else if (importer &&
|
|
@@ -30190,18 +30222,41 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
30190
30222
|
else {
|
|
30191
30223
|
basedir = root;
|
|
30192
30224
|
}
|
|
30193
|
-
const preserveSymlinks = !!(server === null || server === void 0 ? void 0 : server.config.resolve.preserveSymlinks);
|
|
30194
30225
|
// nested node module, step-by-step resolve to the basedir of the nestedPath
|
|
30195
30226
|
if (nestedRoot) {
|
|
30196
|
-
basedir = nestedResolveFrom(nestedRoot, basedir, preserveSymlinks);
|
|
30227
|
+
basedir = nestedResolveFrom(nestedRoot, basedir, options.preserveSymlinks);
|
|
30197
30228
|
}
|
|
30198
|
-
|
|
30229
|
+
let pkg;
|
|
30230
|
+
const pkgId = possiblePkgIds.reverse().find((pkgId) => {
|
|
30231
|
+
pkg = resolvePackageData(pkgId, basedir, options.preserveSymlinks);
|
|
30232
|
+
return pkg;
|
|
30233
|
+
});
|
|
30199
30234
|
if (!pkg) {
|
|
30200
30235
|
return;
|
|
30201
30236
|
}
|
|
30202
|
-
let
|
|
30203
|
-
|
|
30204
|
-
|
|
30237
|
+
let resolveId = resolvePackageEntry;
|
|
30238
|
+
let unresolvedId = pkgId;
|
|
30239
|
+
if (unresolvedId !== nestedPath) {
|
|
30240
|
+
resolveId = resolveDeepImport;
|
|
30241
|
+
unresolvedId = '.' + nestedPath.slice(pkgId.length);
|
|
30242
|
+
}
|
|
30243
|
+
let resolved;
|
|
30244
|
+
try {
|
|
30245
|
+
resolved = resolveId(unresolvedId, pkg, targetWeb, options);
|
|
30246
|
+
}
|
|
30247
|
+
catch (err) {
|
|
30248
|
+
if (!options.tryEsmOnly) {
|
|
30249
|
+
throw err;
|
|
30250
|
+
}
|
|
30251
|
+
}
|
|
30252
|
+
if (!resolved && options.tryEsmOnly) {
|
|
30253
|
+
resolved = resolveId(unresolvedId, pkg, targetWeb, {
|
|
30254
|
+
...options,
|
|
30255
|
+
isRequire: false,
|
|
30256
|
+
mainFields: DEFAULT_MAIN_FIELDS,
|
|
30257
|
+
extensions: DEFAULT_EXTENSIONS$1
|
|
30258
|
+
});
|
|
30259
|
+
}
|
|
30205
30260
|
if (!resolved) {
|
|
30206
30261
|
return;
|
|
30207
30262
|
}
|
|
@@ -30228,7 +30283,7 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
30228
30283
|
if (!isJsType ||
|
|
30229
30284
|
(importer === null || importer === void 0 ? void 0 : importer.includes('node_modules')) ||
|
|
30230
30285
|
(exclude === null || exclude === void 0 ? void 0 : exclude.includes(pkgId)) ||
|
|
30231
|
-
(exclude === null || exclude === void 0 ? void 0 : exclude.includes(
|
|
30286
|
+
(exclude === null || exclude === void 0 ? void 0 : exclude.includes(nestedPath)) ||
|
|
30232
30287
|
SPECIAL_QUERY_RE.test(resolved) ||
|
|
30233
30288
|
ssr) {
|
|
30234
30289
|
// excluded from optimization
|
|
@@ -30345,7 +30400,7 @@ function loadPackageData(pkgPath, cacheKey = pkgPath) {
|
|
|
30345
30400
|
packageCache.set(cacheKey, pkg);
|
|
30346
30401
|
return pkg;
|
|
30347
30402
|
}
|
|
30348
|
-
function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache },
|
|
30403
|
+
function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache }, targetWeb, options) {
|
|
30349
30404
|
var _a, _b;
|
|
30350
30405
|
const cached = getResolvedCache('.', targetWeb);
|
|
30351
30406
|
if (cached) {
|
|
@@ -30377,7 +30432,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
30377
30432
|
// the heuristics here is to actually read the browser entry when
|
|
30378
30433
|
// possible and check for hints of UMD. If it is UMD, prefer "module"
|
|
30379
30434
|
// instead; Otherwise, assume it's ESM and use it.
|
|
30380
|
-
const resolvedBrowserEntry = tryFsResolve(path__default.join(dir, browserEntry), options
|
|
30435
|
+
const resolvedBrowserEntry = tryFsResolve(path__default.join(dir, browserEntry), options);
|
|
30381
30436
|
if (resolvedBrowserEntry) {
|
|
30382
30437
|
const content = fs__default.readFileSync(resolvedBrowserEntry, 'utf-8');
|
|
30383
30438
|
if ((/typeof exports\s*==/.test(content) &&
|
|
@@ -30414,7 +30469,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
30414
30469
|
entryPoint = mapWithBrowserField(entryPoint, browserField) || entryPoint;
|
|
30415
30470
|
}
|
|
30416
30471
|
entryPoint = path__default.join(dir, entryPoint);
|
|
30417
|
-
const resolvedEntryPoint = tryFsResolve(entryPoint, options
|
|
30472
|
+
const resolvedEntryPoint = tryFsResolve(entryPoint, options);
|
|
30418
30473
|
if (resolvedEntryPoint) {
|
|
30419
30474
|
isDebug$5 &&
|
|
30420
30475
|
debug$d(`[package entry] ${source.cyan(id)} -> ${source.dim(resolvedEntryPoint)}`);
|
|
@@ -30442,13 +30497,13 @@ function resolveExports(pkg, key, options, targetWeb) {
|
|
|
30442
30497
|
if (options.conditions) {
|
|
30443
30498
|
conditions.push(...options.conditions);
|
|
30444
30499
|
}
|
|
30445
|
-
return resolve
|
|
30500
|
+
return resolve(pkg, key, {
|
|
30446
30501
|
browser: targetWeb,
|
|
30447
30502
|
require: options.isRequire,
|
|
30448
30503
|
conditions
|
|
30449
30504
|
});
|
|
30450
30505
|
}
|
|
30451
|
-
function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolvedCache, dir, data },
|
|
30506
|
+
function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolvedCache, dir, data }, targetWeb, options) {
|
|
30452
30507
|
const cache = getResolvedCache(id, targetWeb);
|
|
30453
30508
|
if (cache) {
|
|
30454
30509
|
return cache;
|
|
@@ -30479,7 +30534,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
30479
30534
|
}
|
|
30480
30535
|
}
|
|
30481
30536
|
if (relativeId) {
|
|
30482
|
-
const resolved = tryFsResolve(path__default.join(dir, relativeId), options,
|
|
30537
|
+
const resolved = tryFsResolve(path__default.join(dir, relativeId), options, !exportsField, // try index only if no exports field
|
|
30483
30538
|
targetWeb);
|
|
30484
30539
|
if (resolved) {
|
|
30485
30540
|
isDebug$5 &&
|
|
@@ -30489,7 +30544,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
30489
30544
|
}
|
|
30490
30545
|
}
|
|
30491
30546
|
}
|
|
30492
|
-
function tryResolveBrowserMapping(id, importer, options, isFilePath
|
|
30547
|
+
function tryResolveBrowserMapping(id, importer, options, isFilePath) {
|
|
30493
30548
|
let res;
|
|
30494
30549
|
const pkg = importer && idToPkgMap.get(importer);
|
|
30495
30550
|
if (pkg && isObject$3(pkg.data.browser)) {
|
|
@@ -30497,7 +30552,7 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, preserveSym
|
|
|
30497
30552
|
const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser);
|
|
30498
30553
|
if (browserMappedPath) {
|
|
30499
30554
|
const fsPath = path__default.join(pkg.dir, browserMappedPath);
|
|
30500
|
-
if ((res = tryFsResolve(fsPath, options
|
|
30555
|
+
if ((res = tryFsResolve(fsPath, options))) {
|
|
30501
30556
|
isDebug$5 &&
|
|
30502
30557
|
debug$d(`[browser mapped] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
30503
30558
|
idToPkgMap.set(res, pkg);
|
|
@@ -30559,8 +30614,9 @@ function resolveSSRExternal(config, knownImports) {
|
|
|
30559
30614
|
ssrExternals.add(id);
|
|
30560
30615
|
seen.add(id);
|
|
30561
30616
|
});
|
|
30562
|
-
collectExternals(config.root, ssrExternals, seen);
|
|
30563
|
-
|
|
30617
|
+
collectExternals(config.root, config.resolve.preserveSymlinks, ssrExternals, seen);
|
|
30618
|
+
const importedDeps = knownImports.map(getNpmPackageName).filter(isDefined);
|
|
30619
|
+
for (const dep of importedDeps) {
|
|
30564
30620
|
// Assume external if not yet seen
|
|
30565
30621
|
// At this point, the project root and any linked packages have had their dependencies checked,
|
|
30566
30622
|
// so we can safely mark any knownImports not yet seen as external. They are guaranteed to be
|
|
@@ -30578,7 +30634,7 @@ function resolveSSRExternal(config, knownImports) {
|
|
|
30578
30634
|
return externals;
|
|
30579
30635
|
}
|
|
30580
30636
|
// do we need to do this ahead of time or could we do it lazily?
|
|
30581
|
-
function collectExternals(root, ssrExternals, seen) {
|
|
30637
|
+
function collectExternals(root, preserveSymlinks, ssrExternals, seen) {
|
|
30582
30638
|
var _a;
|
|
30583
30639
|
const pkgContent = lookupFile(root, ['package.json']);
|
|
30584
30640
|
if (!pkgContent) {
|
|
@@ -30591,6 +30647,7 @@ function collectExternals(root, ssrExternals, seen) {
|
|
|
30591
30647
|
};
|
|
30592
30648
|
const resolveOptions = {
|
|
30593
30649
|
root,
|
|
30650
|
+
preserveSymlinks,
|
|
30594
30651
|
isProduction: false,
|
|
30595
30652
|
isBuild: true
|
|
30596
30653
|
};
|
|
@@ -30642,7 +30699,7 @@ function collectExternals(root, ssrExternals, seen) {
|
|
|
30642
30699
|
// or are there others like SystemJS / AMD that we'd need to handle?
|
|
30643
30700
|
// for now, we'll just leave this as is
|
|
30644
30701
|
else if (/\.m?js$/.test(esmEntry)) {
|
|
30645
|
-
if (pkg.type ===
|
|
30702
|
+
if (pkg.type === 'module' || esmEntry.endsWith('.mjs')) {
|
|
30646
30703
|
ssrExternals.add(id);
|
|
30647
30704
|
continue;
|
|
30648
30705
|
}
|
|
@@ -30654,7 +30711,7 @@ function collectExternals(root, ssrExternals, seen) {
|
|
|
30654
30711
|
}
|
|
30655
30712
|
}
|
|
30656
30713
|
for (const depRoot of depsToTrace) {
|
|
30657
|
-
collectExternals(depRoot, ssrExternals, seen);
|
|
30714
|
+
collectExternals(depRoot, preserveSymlinks, ssrExternals, seen);
|
|
30658
30715
|
}
|
|
30659
30716
|
}
|
|
30660
30717
|
function shouldExternalizeForSSR(id, externals) {
|
|
@@ -30670,6 +30727,17 @@ function shouldExternalizeForSSR(id, externals) {
|
|
|
30670
30727
|
});
|
|
30671
30728
|
return should;
|
|
30672
30729
|
}
|
|
30730
|
+
function getNpmPackageName(importPath) {
|
|
30731
|
+
const parts = importPath.split('/');
|
|
30732
|
+
if (parts[0].startsWith('@')) {
|
|
30733
|
+
if (!parts[1])
|
|
30734
|
+
return null;
|
|
30735
|
+
return `${parts[0]}/${parts[1]}`;
|
|
30736
|
+
}
|
|
30737
|
+
else {
|
|
30738
|
+
return parts[0];
|
|
30739
|
+
}
|
|
30740
|
+
}
|
|
30673
30741
|
|
|
30674
30742
|
function ssrManifestPlugin(config) {
|
|
30675
30743
|
// module id => preload assets mapping
|
|
@@ -42247,7 +42315,7 @@ function errorMiddleware(server, allowNext = false) {
|
|
|
42247
42315
|
* https://github.com/preactjs/wmr/blob/main/packages/wmr/src/lib/rollup-plugin-container.js
|
|
42248
42316
|
*/
|
|
42249
42317
|
let parser = Parser.extend(acornClassFields, acornStaticClassFeatures);
|
|
42250
|
-
async function createPluginContainer({ plugins, logger, root, build: { rollupOptions } }, watcher) {
|
|
42318
|
+
async function createPluginContainer({ plugins, logger, root, build: { rollupOptions } }, moduleGraph, watcher) {
|
|
42251
42319
|
const isDebug = process.env.DEBUG;
|
|
42252
42320
|
const seenResolves = {};
|
|
42253
42321
|
const debugResolve = createDebugger('vite:resolve');
|
|
@@ -42258,7 +42326,6 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42258
42326
|
onlyWhenFocused: 'vite:plugin'
|
|
42259
42327
|
});
|
|
42260
42328
|
// ---------------------------------------------------------------------------
|
|
42261
|
-
const MODULES = new Map();
|
|
42262
42329
|
const watchFiles = new Set();
|
|
42263
42330
|
// get rollup version
|
|
42264
42331
|
const rollupPkgPath = path$t.resolve(require.resolve('rollup'), '../../package.json');
|
|
@@ -42273,6 +42340,36 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42273
42340
|
logger.warn(source.cyan(`[plugin:${plugin}] `) +
|
|
42274
42341
|
source.yellow(`context method ${source.bold(`${method}()`)} is not supported in serve mode. This plugin is likely not vite-compatible.`));
|
|
42275
42342
|
}
|
|
42343
|
+
// throw when an unsupported ModuleInfo property is accessed,
|
|
42344
|
+
// so that incompatible plugins fail in a non-cryptic way.
|
|
42345
|
+
const ModuleInfoProxy = {
|
|
42346
|
+
get(info, key) {
|
|
42347
|
+
if (key in info) {
|
|
42348
|
+
return info[key];
|
|
42349
|
+
}
|
|
42350
|
+
throw Error(`[vite] The "${key}" property of ModuleInfo is not supported.`);
|
|
42351
|
+
}
|
|
42352
|
+
};
|
|
42353
|
+
// same default value of "moduleInfo.meta" as in Rollup
|
|
42354
|
+
const EMPTY_OBJECT = Object.freeze({});
|
|
42355
|
+
function getModuleInfo(id) {
|
|
42356
|
+
const module = moduleGraph === null || moduleGraph === void 0 ? void 0 : moduleGraph.getModuleById(id);
|
|
42357
|
+
if (!module) {
|
|
42358
|
+
return null;
|
|
42359
|
+
}
|
|
42360
|
+
if (!module.info) {
|
|
42361
|
+
module.info = new Proxy({ id, meta: module.meta || EMPTY_OBJECT }, ModuleInfoProxy);
|
|
42362
|
+
}
|
|
42363
|
+
return module.info;
|
|
42364
|
+
}
|
|
42365
|
+
function updateModuleInfo(id, { meta }) {
|
|
42366
|
+
if (meta) {
|
|
42367
|
+
const moduleInfo = getModuleInfo(id);
|
|
42368
|
+
if (moduleInfo) {
|
|
42369
|
+
moduleInfo.meta = { ...moduleInfo.meta, ...meta };
|
|
42370
|
+
}
|
|
42371
|
+
}
|
|
42372
|
+
}
|
|
42276
42373
|
// we should create a new context for each async hook pipeline so that the
|
|
42277
42374
|
// active plugin in that pipeline can be tracked in a concurrency-safe manner.
|
|
42278
42375
|
// using a class to make creating new contexts more efficient
|
|
@@ -42305,19 +42402,12 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42305
42402
|
return out;
|
|
42306
42403
|
}
|
|
42307
42404
|
getModuleInfo(id) {
|
|
42308
|
-
|
|
42309
|
-
if (mod)
|
|
42310
|
-
return mod.info;
|
|
42311
|
-
mod = {
|
|
42312
|
-
/** @type {import('rollup').ModuleInfo} */
|
|
42313
|
-
// @ts-ignore-next
|
|
42314
|
-
info: {}
|
|
42315
|
-
};
|
|
42316
|
-
MODULES.set(id, mod);
|
|
42317
|
-
return mod.info;
|
|
42405
|
+
return getModuleInfo(id);
|
|
42318
42406
|
}
|
|
42319
42407
|
getModuleIds() {
|
|
42320
|
-
return
|
|
42408
|
+
return moduleGraph
|
|
42409
|
+
? moduleGraph.idToModuleMap.keys()
|
|
42410
|
+
: Array.prototype[Symbol.iterator]();
|
|
42321
42411
|
}
|
|
42322
42412
|
addWatchFile(id) {
|
|
42323
42413
|
watchFiles.add(id);
|
|
@@ -42483,6 +42573,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42483
42573
|
...options
|
|
42484
42574
|
};
|
|
42485
42575
|
})(),
|
|
42576
|
+
getModuleInfo,
|
|
42486
42577
|
async buildStart() {
|
|
42487
42578
|
await Promise.all(plugins.map((plugin) => {
|
|
42488
42579
|
if (plugin.buildStart) {
|
|
@@ -42547,6 +42638,9 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42547
42638
|
ctx._activePlugin = plugin;
|
|
42548
42639
|
const result = await plugin.load.call(ctx, id, { ssr });
|
|
42549
42640
|
if (result != null) {
|
|
42641
|
+
if (isObject$3(result)) {
|
|
42642
|
+
updateModuleInfo(id, result);
|
|
42643
|
+
}
|
|
42550
42644
|
return result;
|
|
42551
42645
|
}
|
|
42552
42646
|
}
|
|
@@ -42576,9 +42670,13 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42576
42670
|
isDebug &&
|
|
42577
42671
|
debugPluginTransform(timeFrom(start), plugin.name, prettifyUrl(id, root));
|
|
42578
42672
|
if (isObject$3(result)) {
|
|
42579
|
-
|
|
42580
|
-
|
|
42581
|
-
|
|
42673
|
+
if (result.code !== undefined) {
|
|
42674
|
+
code = result.code;
|
|
42675
|
+
if (result.map) {
|
|
42676
|
+
ctx.sourcemapChain.push(result.map);
|
|
42677
|
+
}
|
|
42678
|
+
}
|
|
42679
|
+
updateModuleInfo(id, result);
|
|
42582
42680
|
}
|
|
42583
42681
|
else {
|
|
42584
42682
|
code = result;
|
|
@@ -42603,6 +42701,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
42603
42701
|
|
|
42604
42702
|
const debug$b = createDebugger('vite:deps');
|
|
42605
42703
|
const htmlTypesRE = /\.(html|vue|svelte|astro)$/;
|
|
42704
|
+
const setupRE = /<script\s+setup/;
|
|
42606
42705
|
// A simple regex to detect import sources. This is only used on
|
|
42607
42706
|
// <script lang="ts"> blocks in vue (setup only) or svelte files, since
|
|
42608
42707
|
// seemingly unused imports are dropped by esbuild when transpiling TS which
|
|
@@ -42692,6 +42791,7 @@ const commentRE = /<!--(.|[\r\n])*?-->/;
|
|
|
42692
42791
|
const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
42693
42792
|
const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
42694
42793
|
const langRE = /\blang\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
42794
|
+
const contextRE = /\bcontext\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im;
|
|
42695
42795
|
function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
42696
42796
|
var _a, _b;
|
|
42697
42797
|
const seen = new Map();
|
|
@@ -42718,6 +42818,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
42718
42818
|
return {
|
|
42719
42819
|
name: 'vite:dep-scan',
|
|
42720
42820
|
setup(build) {
|
|
42821
|
+
const localScripts = {};
|
|
42721
42822
|
// external urls
|
|
42722
42823
|
build.onResolve({ filter: externalRE }, ({ path }) => ({
|
|
42723
42824
|
path,
|
|
@@ -42728,6 +42829,17 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
42728
42829
|
path,
|
|
42729
42830
|
external: true
|
|
42730
42831
|
}));
|
|
42832
|
+
// local scripts (`<script>` in Svelte and `<script setup>` in Vue)
|
|
42833
|
+
build.onResolve({ filter: virtualModuleRE }, ({ path }) => {
|
|
42834
|
+
return {
|
|
42835
|
+
// strip prefix to get valid filesystem path so esbuild can resolve imports in the file
|
|
42836
|
+
path: path.replace(virtualModulePrefix, ''),
|
|
42837
|
+
namespace: 'local-script'
|
|
42838
|
+
};
|
|
42839
|
+
});
|
|
42840
|
+
build.onLoad({ filter: /.*/, namespace: 'local-script' }, ({ path }) => {
|
|
42841
|
+
return localScripts[path];
|
|
42842
|
+
});
|
|
42731
42843
|
// html types: extract script contents -----------------------------------
|
|
42732
42844
|
build.onResolve({ filter: htmlTypesRE }, async ({ path, importer }) => {
|
|
42733
42845
|
return {
|
|
@@ -42748,10 +42860,9 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
42748
42860
|
let match;
|
|
42749
42861
|
while ((match = regex.exec(raw))) {
|
|
42750
42862
|
const [, openTag, content] = match;
|
|
42751
|
-
const srcMatch = openTag.match(srcRE);
|
|
42752
42863
|
const typeMatch = openTag.match(typeRE);
|
|
42753
|
-
const langMatch = openTag.match(langRE);
|
|
42754
42864
|
const type = typeMatch && (typeMatch[1] || typeMatch[2] || typeMatch[3]);
|
|
42865
|
+
const langMatch = openTag.match(langRE);
|
|
42755
42866
|
const lang = langMatch && (langMatch[1] || langMatch[2] || langMatch[3]);
|
|
42756
42867
|
// skip type="application/ld+json" and other non-JS types
|
|
42757
42868
|
if (type &&
|
|
@@ -42763,12 +42874,29 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
42763
42874
|
if (lang === 'ts' || lang === 'tsx' || lang === 'jsx') {
|
|
42764
42875
|
loader = lang;
|
|
42765
42876
|
}
|
|
42877
|
+
const srcMatch = openTag.match(srcRE);
|
|
42766
42878
|
if (srcMatch) {
|
|
42767
42879
|
const src = srcMatch[1] || srcMatch[2] || srcMatch[3];
|
|
42768
42880
|
js += `import ${JSON.stringify(src)}\n`;
|
|
42769
42881
|
}
|
|
42770
42882
|
else if (content.trim()) {
|
|
42771
|
-
|
|
42883
|
+
// There can be module scripts (`<script context="module">` in Svelte and `<script>` in Vue)
|
|
42884
|
+
// or local scripts (`<script>` in Svelte and `<script setup>` in Vue)
|
|
42885
|
+
// We need to handle these separately in case variable names are reused between them
|
|
42886
|
+
const contextMatch = openTag.match(contextRE);
|
|
42887
|
+
const context = contextMatch &&
|
|
42888
|
+
(contextMatch[1] || contextMatch[2] || contextMatch[3]);
|
|
42889
|
+
if ((path.endsWith('.vue') && setupRE.test(raw)) ||
|
|
42890
|
+
(path.endsWith('.svelte') && context !== 'module')) {
|
|
42891
|
+
localScripts[path] = {
|
|
42892
|
+
loader,
|
|
42893
|
+
contents: content
|
|
42894
|
+
};
|
|
42895
|
+
js += `import '${virtualModulePrefix}${path}';\n`;
|
|
42896
|
+
}
|
|
42897
|
+
else {
|
|
42898
|
+
js += content + '\n';
|
|
42899
|
+
}
|
|
42772
42900
|
}
|
|
42773
42901
|
}
|
|
42774
42902
|
// empty singleline & multiline comments to avoid matching comments
|
|
@@ -42777,7 +42905,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
42777
42905
|
.replace(singlelineCommentsRE, '');
|
|
42778
42906
|
if (loader.startsWith('ts') &&
|
|
42779
42907
|
(path.endsWith('.svelte') ||
|
|
42780
|
-
(path.endsWith('.vue') &&
|
|
42908
|
+
(path.endsWith('.vue') && setupRE.test(raw)))) {
|
|
42781
42909
|
// when using TS + (Vue + <script setup>) or Svelte, imports may seem
|
|
42782
42910
|
// unused to esbuild and dropped in the build output, which prevents
|
|
42783
42911
|
// esbuild from crawling further.
|
|
@@ -43043,7 +43171,8 @@ function loadFallbackPlugin() {
|
|
|
43043
43171
|
};
|
|
43044
43172
|
}
|
|
43045
43173
|
|
|
43046
|
-
function resolveBuildOptions(raw) {
|
|
43174
|
+
function resolveBuildOptions(root, raw) {
|
|
43175
|
+
var _a;
|
|
43047
43176
|
const resolved = {
|
|
43048
43177
|
target: 'modules',
|
|
43049
43178
|
polyfillModulePreload: true,
|
|
@@ -43078,6 +43207,31 @@ function resolveBuildOptions(raw) {
|
|
|
43078
43207
|
...raw === null || raw === void 0 ? void 0 : raw.dynamicImportVarsOptions
|
|
43079
43208
|
}
|
|
43080
43209
|
};
|
|
43210
|
+
const resolve = (p) => p.startsWith('\0') ? p : path__default.resolve(root, p);
|
|
43211
|
+
resolved.outDir = resolve(resolved.outDir);
|
|
43212
|
+
let input;
|
|
43213
|
+
if ((_a = raw === null || raw === void 0 ? void 0 : raw.rollupOptions) === null || _a === void 0 ? void 0 : _a.input) {
|
|
43214
|
+
input = Array.isArray(raw.rollupOptions.input)
|
|
43215
|
+
? raw.rollupOptions.input.map((input) => resolve(input))
|
|
43216
|
+
: typeof raw.rollupOptions.input === 'object'
|
|
43217
|
+
? Object.fromEntries(Object.entries(raw.rollupOptions.input).map(([key, value]) => [
|
|
43218
|
+
key,
|
|
43219
|
+
resolve(value)
|
|
43220
|
+
]))
|
|
43221
|
+
: resolve(raw.rollupOptions.input);
|
|
43222
|
+
}
|
|
43223
|
+
else {
|
|
43224
|
+
input = resolve((raw === null || raw === void 0 ? void 0 : raw.lib)
|
|
43225
|
+
? raw.lib.entry
|
|
43226
|
+
: typeof (raw === null || raw === void 0 ? void 0 : raw.ssr) === 'string'
|
|
43227
|
+
? raw.ssr
|
|
43228
|
+
: 'index.html');
|
|
43229
|
+
}
|
|
43230
|
+
if (!!(raw === null || raw === void 0 ? void 0 : raw.ssr) && typeof input === 'string' && input.endsWith('.html')) {
|
|
43231
|
+
throw new Error(`rollupOptions.input should not be an html file when building for SSR. ` +
|
|
43232
|
+
`Please specify a dedicated SSR entry.`);
|
|
43233
|
+
}
|
|
43234
|
+
resolved.rollupOptions.input = input;
|
|
43081
43235
|
// handle special build targets
|
|
43082
43236
|
if (resolved.target === 'modules') {
|
|
43083
43237
|
// Support browserslist
|
|
@@ -43156,27 +43310,18 @@ async function build(inlineConfig = {}) {
|
|
|
43156
43310
|
}
|
|
43157
43311
|
}
|
|
43158
43312
|
async function doBuild(inlineConfig = {}) {
|
|
43159
|
-
var _a, _b, _c
|
|
43313
|
+
var _a, _b, _c;
|
|
43160
43314
|
const config = await resolveConfig(inlineConfig, 'build', 'production');
|
|
43161
43315
|
const options = config.build;
|
|
43316
|
+
const input = options.rollupOptions.input;
|
|
43317
|
+
const outDir = options.outDir;
|
|
43162
43318
|
const ssr = !!options.ssr;
|
|
43163
43319
|
const libOptions = options.lib;
|
|
43164
43320
|
config.logger.info(source.cyan(`vite v${require('vite/package.json').version} ${source.green(`building ${ssr ? `SSR bundle ` : ``}for ${config.mode}...`)}`));
|
|
43165
|
-
const resolve = (p) => path__default.resolve(config.root, p);
|
|
43166
|
-
const input = libOptions
|
|
43167
|
-
? resolve(libOptions.entry)
|
|
43168
|
-
: typeof options.ssr === 'string'
|
|
43169
|
-
? resolve(options.ssr)
|
|
43170
|
-
: ((_a = options.rollupOptions) === null || _a === void 0 ? void 0 : _a.input) || resolve('index.html');
|
|
43171
|
-
if (ssr && typeof input === 'string' && input.endsWith('.html')) {
|
|
43172
|
-
throw new Error(`rollupOptions.input should not be an html file when building for SSR. ` +
|
|
43173
|
-
`Please specify a dedicated SSR entry.`);
|
|
43174
|
-
}
|
|
43175
|
-
const outDir = resolve(options.outDir);
|
|
43176
43321
|
// inject ssr arg to plugin load/transform hooks
|
|
43177
43322
|
const plugins = (ssr ? config.plugins.map((p) => injectSsrFlagToHooks(p)) : config.plugins);
|
|
43178
43323
|
// inject ssrExternal if present
|
|
43179
|
-
const userExternal = (
|
|
43324
|
+
const userExternal = (_a = options.rollupOptions) === null || _a === void 0 ? void 0 : _a.external;
|
|
43180
43325
|
let external = userExternal;
|
|
43181
43326
|
if (ssr) {
|
|
43182
43327
|
// see if we have cached deps data available
|
|
@@ -43197,7 +43342,6 @@ async function doBuild(inlineConfig = {}) {
|
|
|
43197
43342
|
}
|
|
43198
43343
|
const rollup = require('rollup');
|
|
43199
43344
|
const rollupOptions = {
|
|
43200
|
-
input,
|
|
43201
43345
|
context: 'globalThis',
|
|
43202
43346
|
preserveEntrySignatures: ssr
|
|
43203
43347
|
? 'allow-extension'
|
|
@@ -43254,7 +43398,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
43254
43398
|
};
|
|
43255
43399
|
};
|
|
43256
43400
|
// resolve lib mode outputs
|
|
43257
|
-
const outputs = resolveBuildOutputs((
|
|
43401
|
+
const outputs = resolveBuildOutputs((_b = options.rollupOptions) === null || _b === void 0 ? void 0 : _b.output, libOptions, config.logger);
|
|
43258
43402
|
// watch file changes with rollup
|
|
43259
43403
|
if (config.build.watch) {
|
|
43260
43404
|
config.logger.info(source.cyanBright(`\nwatching for file changes...`));
|
|
@@ -43277,7 +43421,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
43277
43421
|
ignored: [
|
|
43278
43422
|
'**/node_modules/**',
|
|
43279
43423
|
'**/.git/**',
|
|
43280
|
-
...(((
|
|
43424
|
+
...(((_c = watcherOptions === null || watcherOptions === void 0 ? void 0 : watcherOptions.chokidar) === null || _c === void 0 ? void 0 : _c.ignored) || [])
|
|
43281
43425
|
],
|
|
43282
43426
|
ignoreInitial: true,
|
|
43283
43427
|
ignorePermissionErrors: true,
|
|
@@ -49231,7 +49375,7 @@ function readFileIfExists(value) {
|
|
|
49231
49375
|
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
|
|
49232
49376
|
*/
|
|
49233
49377
|
async function createCertificate() {
|
|
49234
|
-
const { generate } = await Promise.resolve().then(function () { return require('./dep-
|
|
49378
|
+
const { generate } = await Promise.resolve().then(function () { return require('./dep-606d0866.js'); }).then(function (n) { return n.index; });
|
|
49235
49379
|
const pems = generate(null, {
|
|
49236
49380
|
algorithm: 'sha256',
|
|
49237
49381
|
days: 30,
|
|
@@ -56542,6 +56686,10 @@ const isDebug$3 = !!process.env.DEBUG;
|
|
|
56542
56686
|
const debug$4 = createDebugger('vite:sourcemap', {
|
|
56543
56687
|
onlyWhenFocused: true
|
|
56544
56688
|
});
|
|
56689
|
+
// Virtual modules should be prefixed with a null byte to avoid a
|
|
56690
|
+
// false positive "missing source" warning. We also check for certain
|
|
56691
|
+
// prefixes used for special handling in esbuildDepPlugin.
|
|
56692
|
+
const virtualSourceRE = /^(\0|dep:|browser-external:)/;
|
|
56545
56693
|
async function injectSourcesContent(map, file, logger) {
|
|
56546
56694
|
let sourceRoot;
|
|
56547
56695
|
try {
|
|
@@ -56551,7 +56699,7 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
56551
56699
|
catch { }
|
|
56552
56700
|
const missingSources = [];
|
|
56553
56701
|
map.sourcesContent = await Promise.all(map.sources.map((sourcePath) => {
|
|
56554
|
-
if (sourcePath) {
|
|
56702
|
+
if (sourcePath && !virtualSourceRE.test(sourcePath)) {
|
|
56555
56703
|
sourcePath = decodeURI(sourcePath);
|
|
56556
56704
|
if (sourceRoot) {
|
|
56557
56705
|
sourcePath = path__default.resolve(sourceRoot, sourcePath);
|
|
@@ -57011,7 +57159,7 @@ function isFileServingAllowed(url, server) {
|
|
|
57011
57159
|
return true;
|
|
57012
57160
|
const cleanedUrl = cleanUrl(url);
|
|
57013
57161
|
const file = ensureLeadingSlash(normalizePath$4(cleanedUrl));
|
|
57014
|
-
if (server.config.server.fs.deny.some((i) =>
|
|
57162
|
+
if (server.config.server.fs.deny.some((i) => micromatch_1.isMatch(file, i, _matchOptions)))
|
|
57015
57163
|
return false;
|
|
57016
57164
|
if (server.moduleGraph.safeModulesPath.has(file))
|
|
57017
57165
|
return true;
|
|
@@ -57482,13 +57630,13 @@ function invalidateSSRModule(mod, seen) {
|
|
|
57482
57630
|
mod.importers.forEach((importer) => invalidateSSRModule(importer, seen));
|
|
57483
57631
|
}
|
|
57484
57632
|
class ModuleGraph {
|
|
57485
|
-
constructor(
|
|
57633
|
+
constructor(resolveId) {
|
|
57634
|
+
this.resolveId = resolveId;
|
|
57486
57635
|
this.urlToModuleMap = new Map();
|
|
57487
57636
|
this.idToModuleMap = new Map();
|
|
57488
57637
|
// a single file may corresponds to multiple modules with different queries
|
|
57489
57638
|
this.fileToModulesMap = new Map();
|
|
57490
57639
|
this.safeModulesPath = new Set();
|
|
57491
|
-
this.container = container;
|
|
57492
57640
|
}
|
|
57493
57641
|
async getModuleByUrl(rawUrl) {
|
|
57494
57642
|
const [url] = await this.resolveUrl(rawUrl);
|
|
@@ -57510,6 +57658,7 @@ class ModuleGraph {
|
|
|
57510
57658
|
}
|
|
57511
57659
|
}
|
|
57512
57660
|
invalidateModule(mod, seen = new Set()) {
|
|
57661
|
+
mod.info = undefined;
|
|
57513
57662
|
mod.transformResult = null;
|
|
57514
57663
|
mod.ssrTransformResult = null;
|
|
57515
57664
|
invalidateSSRModule(mod, seen);
|
|
@@ -57558,10 +57707,12 @@ class ModuleGraph {
|
|
|
57558
57707
|
return noLongerImported;
|
|
57559
57708
|
}
|
|
57560
57709
|
async ensureEntryFromUrl(rawUrl) {
|
|
57561
|
-
const [url, resolvedId] = await this.resolveUrl(rawUrl);
|
|
57710
|
+
const [url, resolvedId, meta] = await this.resolveUrl(rawUrl);
|
|
57562
57711
|
let mod = this.urlToModuleMap.get(url);
|
|
57563
57712
|
if (!mod) {
|
|
57564
57713
|
mod = new ModuleNode(url);
|
|
57714
|
+
if (meta)
|
|
57715
|
+
mod.meta = meta;
|
|
57565
57716
|
this.urlToModuleMap.set(url, mod);
|
|
57566
57717
|
mod.id = resolvedId;
|
|
57567
57718
|
this.idToModuleMap.set(resolvedId, mod);
|
|
@@ -57602,15 +57753,15 @@ class ModuleGraph {
|
|
|
57602
57753
|
// 2. resolve its extension so that urls with or without extension all map to
|
|
57603
57754
|
// the same module
|
|
57604
57755
|
async resolveUrl(url) {
|
|
57605
|
-
var _a;
|
|
57606
57756
|
url = removeImportQuery(removeTimestampQuery(url));
|
|
57607
|
-
const
|
|
57757
|
+
const resolved = await this.resolveId(url);
|
|
57758
|
+
const resolvedId = (resolved === null || resolved === void 0 ? void 0 : resolved.id) || url;
|
|
57608
57759
|
const ext = path$t.extname(cleanUrl(resolvedId));
|
|
57609
57760
|
const { pathname, search, hash } = require$$0$7.parse(url);
|
|
57610
57761
|
if (ext && !pathname.endsWith(ext)) {
|
|
57611
57762
|
url = pathname + ext + (search || '') + (hash || '');
|
|
57612
57763
|
}
|
|
57613
|
-
return [url, resolvedId];
|
|
57764
|
+
return [url, resolvedId, resolved === null || resolved === void 0 ? void 0 : resolved.meta];
|
|
57614
57765
|
}
|
|
57615
57766
|
}
|
|
57616
57767
|
|
|
@@ -57624,7 +57775,8 @@ async function handleHMRUpdate(file, server) {
|
|
|
57624
57775
|
const shortFile = getShortName(file, config.root);
|
|
57625
57776
|
const isConfig = file === config.configFile;
|
|
57626
57777
|
const isConfigDependency = config.configFileDependencies.some((name) => file === path__default.resolve(name));
|
|
57627
|
-
const isEnv = config.inlineConfig.envFile !== false &&
|
|
57778
|
+
const isEnv = config.inlineConfig.envFile !== false &&
|
|
57779
|
+
(file === '.env' || file.startsWith('.env.'));
|
|
57628
57780
|
if (isConfig || isConfigDependency || isEnv) {
|
|
57629
57781
|
// auto restart server
|
|
57630
57782
|
debugHmr(`[config change] ${source.dim(shortFile)}`);
|
|
@@ -57732,7 +57884,8 @@ async function handleFileAddUnlink(file, server, isUnlink = false) {
|
|
|
57732
57884
|
for (const i in server._globImporters) {
|
|
57733
57885
|
const { module, importGlobs } = server._globImporters[i];
|
|
57734
57886
|
for (const { base, pattern } of importGlobs) {
|
|
57735
|
-
if (
|
|
57887
|
+
if (micromatch_1.isMatch(file, pattern) ||
|
|
57888
|
+
micromatch_1.isMatch(path__default.relative(base, file), pattern)) {
|
|
57736
57889
|
modules.push(module);
|
|
57737
57890
|
// We use `onFileChange` to invalidate `module.file` so that subsequent `ssrLoadModule()`
|
|
57738
57891
|
// calls get fresh glob import results with(out) the newly added(/removed) `file`.
|
|
@@ -66849,6 +67002,65 @@ function rebindErrorStacktrace(e, stacktrace) {
|
|
|
66849
67002
|
}
|
|
66850
67003
|
}
|
|
66851
67004
|
|
|
67005
|
+
/**
|
|
67006
|
+
* This plugin hooks into Node's module resolution algorithm at runtime,
|
|
67007
|
+
* so that SSR builds can benefit from `resolve.dedupe` like they do
|
|
67008
|
+
* in development.
|
|
67009
|
+
*/
|
|
67010
|
+
function ssrRequireHookPlugin(config) {
|
|
67011
|
+
var _a;
|
|
67012
|
+
if (config.command !== 'build' ||
|
|
67013
|
+
!((_a = config.resolve.dedupe) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
67014
|
+
isBuildOutputEsm(config)) {
|
|
67015
|
+
return null;
|
|
67016
|
+
}
|
|
67017
|
+
return {
|
|
67018
|
+
name: 'vite:ssr-require-hook',
|
|
67019
|
+
transform(code, id) {
|
|
67020
|
+
const moduleInfo = this.getModuleInfo(id);
|
|
67021
|
+
if (moduleInfo === null || moduleInfo === void 0 ? void 0 : moduleInfo.isEntry) {
|
|
67022
|
+
const s = new MagicString(code);
|
|
67023
|
+
s.prepend(`;(${dedupeRequire.toString()})(${JSON.stringify(config.resolve.dedupe)});\n`);
|
|
67024
|
+
return {
|
|
67025
|
+
code: s.toString(),
|
|
67026
|
+
map: s.generateMap({
|
|
67027
|
+
source: id
|
|
67028
|
+
})
|
|
67029
|
+
};
|
|
67030
|
+
}
|
|
67031
|
+
}
|
|
67032
|
+
};
|
|
67033
|
+
}
|
|
67034
|
+
/** Respect the `resolve.dedupe` option in production SSR. */
|
|
67035
|
+
function dedupeRequire(dedupe) {
|
|
67036
|
+
const Module = require('module');
|
|
67037
|
+
const resolveFilename = Module._resolveFilename;
|
|
67038
|
+
Module._resolveFilename = function (request, parent, isMain, options) {
|
|
67039
|
+
if (request[0] !== '.' && request[0] !== '/') {
|
|
67040
|
+
const parts = request.split('/');
|
|
67041
|
+
const pkgName = parts[0][0] === '@' ? parts[0] + '/' + parts[1] : parts[0];
|
|
67042
|
+
if (dedupe.includes(pkgName)) {
|
|
67043
|
+
// Use this module as the parent.
|
|
67044
|
+
parent = module;
|
|
67045
|
+
}
|
|
67046
|
+
}
|
|
67047
|
+
return resolveFilename(request, parent, isMain, options);
|
|
67048
|
+
};
|
|
67049
|
+
}
|
|
67050
|
+
function hookNodeResolve(getResolver) {
|
|
67051
|
+
const Module = require('module');
|
|
67052
|
+
const prevResolver = Module._resolveFilename;
|
|
67053
|
+
Module._resolveFilename = getResolver(prevResolver);
|
|
67054
|
+
return () => {
|
|
67055
|
+
Module._resolveFilename = prevResolver;
|
|
67056
|
+
};
|
|
67057
|
+
}
|
|
67058
|
+
function isBuildOutputEsm(config) {
|
|
67059
|
+
var _a;
|
|
67060
|
+
const outputs = arraify((_a = config.build.rollupOptions) === null || _a === void 0 ? void 0 : _a.output);
|
|
67061
|
+
return outputs.some((output) => (output === null || output === void 0 ? void 0 : output.format) === 'es' || (output === null || output === void 0 ? void 0 : output.format) === 'esm');
|
|
67062
|
+
}
|
|
67063
|
+
|
|
66852
67064
|
const pendingModules = new Map();
|
|
66853
67065
|
const pendingImports = new Map();
|
|
66854
67066
|
async function ssrLoadModule(url, server, context = { global }, urlStack = []) {
|
|
@@ -66897,13 +67109,27 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
66897
67109
|
};
|
|
66898
67110
|
urlStack = urlStack.concat(url);
|
|
66899
67111
|
const isCircular = (url) => urlStack.includes(url);
|
|
67112
|
+
const { isProduction, resolve: { dedupe, preserveSymlinks }, root } = server.config;
|
|
67113
|
+
// The `extensions` and `mainFields` options are used to ensure that
|
|
67114
|
+
// CommonJS modules are preferred. We want to avoid ESM->ESM imports
|
|
67115
|
+
// whenever possible, because `hookNodeResolve` can't intercept them.
|
|
67116
|
+
const resolveOptions = {
|
|
67117
|
+
dedupe,
|
|
67118
|
+
extensions: ['.js', '.cjs', '.json'],
|
|
67119
|
+
isBuild: true,
|
|
67120
|
+
isProduction,
|
|
67121
|
+
isRequire: true,
|
|
67122
|
+
mainFields: ['main'],
|
|
67123
|
+
preserveSymlinks,
|
|
67124
|
+
root
|
|
67125
|
+
};
|
|
66900
67126
|
// Since dynamic imports can happen in parallel, we need to
|
|
66901
67127
|
// account for multiple pending deps and duplicate imports.
|
|
66902
67128
|
const pendingDeps = [];
|
|
66903
67129
|
const ssrImport = async (dep) => {
|
|
66904
67130
|
var _a, _b;
|
|
66905
67131
|
if (dep[0] !== '.' && dep[0] !== '/') {
|
|
66906
|
-
return nodeImport(dep, mod.file,
|
|
67132
|
+
return nodeImport(dep, mod.file, resolveOptions);
|
|
66907
67133
|
}
|
|
66908
67134
|
dep = unwrapId$1(dep);
|
|
66909
67135
|
if (!isCircular(dep) && !((_a = pendingImports.get(dep)) === null || _a === void 0 ? void 0 : _a.some(isCircular))) {
|
|
@@ -66963,20 +67189,53 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
66963
67189
|
return Object.freeze(ssrModule);
|
|
66964
67190
|
}
|
|
66965
67191
|
// In node@12+ we can use dynamic import to load CJS and ESM
|
|
66966
|
-
async function nodeImport(id, importer,
|
|
67192
|
+
async function nodeImport(id, importer, resolveOptions) {
|
|
67193
|
+
// Node's module resolution is hi-jacked so Vite can ensure the
|
|
67194
|
+
// configured `resolve.dedupe` and `mode` options are respected.
|
|
67195
|
+
const viteResolve = (id, importer, options = resolveOptions) => {
|
|
67196
|
+
const resolved = tryNodeResolve(id, importer, options, false);
|
|
67197
|
+
if (!resolved) {
|
|
67198
|
+
const err = new Error(`Cannot find module '${id}' imported from '${importer}'`);
|
|
67199
|
+
err.code = 'ERR_MODULE_NOT_FOUND';
|
|
67200
|
+
throw err;
|
|
67201
|
+
}
|
|
67202
|
+
return resolved.id;
|
|
67203
|
+
};
|
|
67204
|
+
// When an ESM module imports an ESM dependency, this hook is *not* used.
|
|
67205
|
+
const unhookNodeResolve = hookNodeResolve((nodeResolve) => (id, parent, isMain, options) => {
|
|
67206
|
+
if (id[0] === '.' || isBuiltin(id)) {
|
|
67207
|
+
return nodeResolve(id, parent, isMain, options);
|
|
67208
|
+
}
|
|
67209
|
+
if (parent) {
|
|
67210
|
+
return viteResolve(id, parent.id);
|
|
67211
|
+
}
|
|
67212
|
+
// Importing a CJS module from an ESM module. In this case, the import
|
|
67213
|
+
// specifier is already an absolute path, so this is a no-op.
|
|
67214
|
+
// Options like `resolve.dedupe` and `mode` are not respected.
|
|
67215
|
+
return id;
|
|
67216
|
+
});
|
|
66967
67217
|
let url;
|
|
66968
|
-
// `resolve` doesn't handle `node:` builtins, so handle them directly
|
|
66969
67218
|
if (id.startsWith('node:') || isBuiltin(id)) {
|
|
66970
67219
|
url = id;
|
|
66971
67220
|
}
|
|
66972
67221
|
else {
|
|
66973
|
-
url =
|
|
67222
|
+
url = viteResolve(id, importer,
|
|
67223
|
+
// Non-external modules can import ESM-only modules, but only outside
|
|
67224
|
+
// of test runs, because we use Node `require` in Jest to avoid segfault.
|
|
67225
|
+
typeof jest === 'undefined'
|
|
67226
|
+
? { ...resolveOptions, tryEsmOnly: true }
|
|
67227
|
+
: resolveOptions);
|
|
66974
67228
|
if (usingDynamicImport) {
|
|
66975
67229
|
url = require$$0$7.pathToFileURL(url).toString();
|
|
66976
67230
|
}
|
|
66977
67231
|
}
|
|
66978
|
-
|
|
66979
|
-
|
|
67232
|
+
try {
|
|
67233
|
+
const mod = await dynamicImport(url);
|
|
67234
|
+
return proxyESM(id, mod);
|
|
67235
|
+
}
|
|
67236
|
+
finally {
|
|
67237
|
+
unhookNodeResolve();
|
|
67238
|
+
}
|
|
66980
67239
|
}
|
|
66981
67240
|
// rollup-style default import interop for cjs
|
|
66982
67241
|
function proxyESM(id, mod) {
|
|
@@ -66987,26 +67246,13 @@ function proxyESM(id, mod) {
|
|
|
66987
67246
|
: mod;
|
|
66988
67247
|
return new Proxy(mod, {
|
|
66989
67248
|
get(mod, prop) {
|
|
67249
|
+
var _a;
|
|
66990
67250
|
if (prop === 'default')
|
|
66991
67251
|
return defaultExport;
|
|
66992
|
-
return mod[prop];
|
|
67252
|
+
return (_a = mod[prop]) !== null && _a !== void 0 ? _a : defaultExport === null || defaultExport === void 0 ? void 0 : defaultExport[prop];
|
|
66993
67253
|
}
|
|
66994
67254
|
});
|
|
66995
67255
|
}
|
|
66996
|
-
const resolveCache = new Map();
|
|
66997
|
-
function resolve(id, importer, root, preserveSymlinks) {
|
|
66998
|
-
const key = id + importer + root;
|
|
66999
|
-
const cached = resolveCache.get(key);
|
|
67000
|
-
if (cached) {
|
|
67001
|
-
return cached;
|
|
67002
|
-
}
|
|
67003
|
-
const resolveDir = importer && fs__default.existsSync(cleanUrl(importer))
|
|
67004
|
-
? path__default.dirname(importer)
|
|
67005
|
-
: root;
|
|
67006
|
-
const resolved = resolveFrom$3(id, resolveDir, preserveSymlinks, true);
|
|
67007
|
-
resolveCache.set(key, resolved);
|
|
67008
|
-
return resolved;
|
|
67009
|
-
}
|
|
67010
67256
|
|
|
67011
67257
|
/**
|
|
67012
67258
|
* The amount to wait for requests to register newly found dependencies before triggering
|
|
@@ -67158,9 +67404,8 @@ async function createServer(inlineConfig = {}) {
|
|
|
67158
67404
|
disableGlobbing: true,
|
|
67159
67405
|
...watchOptions
|
|
67160
67406
|
});
|
|
67161
|
-
const
|
|
67162
|
-
const container = await createPluginContainer(config, watcher);
|
|
67163
|
-
const moduleGraph = new ModuleGraph(container);
|
|
67407
|
+
const moduleGraph = new ModuleGraph((url) => container.resolveId(url));
|
|
67408
|
+
const container = await createPluginContainer(config, moduleGraph, watcher);
|
|
67164
67409
|
const closeHttpServer = createServerCloseFn(httpServer);
|
|
67165
67410
|
// eslint-disable-next-line prefer-const
|
|
67166
67411
|
let exitProcess;
|
|
@@ -67267,7 +67512,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
67267
67512
|
}
|
|
67268
67513
|
// apply server configuration hooks from plugins
|
|
67269
67514
|
const postHooks = [];
|
|
67270
|
-
for (const plugin of plugins) {
|
|
67515
|
+
for (const plugin of config.plugins) {
|
|
67271
67516
|
if (plugin.configureServer) {
|
|
67272
67517
|
postHooks.push(await plugin.configureServer(server));
|
|
67273
67518
|
}
|
|
@@ -81154,6 +81399,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
81154
81399
|
ssrConfig: config.ssr,
|
|
81155
81400
|
asSrc: true
|
|
81156
81401
|
}),
|
|
81402
|
+
config.build.ssr ? ssrRequireHookPlugin(config) : null,
|
|
81157
81403
|
htmlInlineScriptProxyPlugin(config),
|
|
81158
81404
|
cssPlugin(config),
|
|
81159
81405
|
config.esbuild !== false ? esbuildPlugin(config.esbuild) : null,
|
|
@@ -81444,7 +81690,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
81444
81690
|
}
|
|
81445
81691
|
// resolve public base url
|
|
81446
81692
|
const BASE_URL = resolveBaseUrl(config.base, command === 'build', logger);
|
|
81447
|
-
const resolvedBuildOptions = resolveBuildOptions(config.build);
|
|
81693
|
+
const resolvedBuildOptions = resolveBuildOptions(resolvedRoot, config.build);
|
|
81448
81694
|
// resolve cache directory
|
|
81449
81695
|
const pkgPath = lookupFile(resolvedRoot, [`package.json`], true /* pathOnly */);
|
|
81450
81696
|
const cacheDir = config.cacheDir
|
|
@@ -81993,4 +82239,4 @@ exports.send = send$1;
|
|
|
81993
82239
|
exports.sortUserPlugins = sortUserPlugins;
|
|
81994
82240
|
exports.source = source;
|
|
81995
82241
|
exports.transformWithEsbuild = transformWithEsbuild;
|
|
81996
|
-
//# sourceMappingURL=dep-
|
|
82242
|
+
//# sourceMappingURL=dep-56ab4c22.js.map
|