vite 2.7.0-beta.5 → 2.7.0-beta.6
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 +10 -0
- package/dist/node/chunks/{dep-6920cd01.js → dep-0183a921.js} +74 -59
- package/dist/node/chunks/dep-0183a921.js.map +1 -0
- package/dist/node/chunks/{dep-732fded6.js → dep-146e2d5f.js} +2 -2
- package/dist/node/chunks/{dep-732fded6.js.map → dep-146e2d5f.js.map} +1 -1
- package/dist/node/chunks/{dep-bc61ebc7.js → dep-1b2328e8.js} +3 -3
- package/dist/node/chunks/dep-1b2328e8.js.map +1 -0
- package/dist/node/chunks/{dep-0a2fa784.js → dep-48461e78.js} +2 -2
- package/dist/node/chunks/{dep-0a2fa784.js.map → dep-48461e78.js.map} +1 -1
- package/dist/node/cli.js +4 -4
- package/dist/node/index.d.ts +2 -2
- package/dist/node/index.js +1 -1
- package/dist/node/terser.js +186 -54
- package/package.json +5 -5
- package/dist/node/chunks/dep-6920cd01.js.map +0 -1
- package/dist/node/chunks/dep-bc61ebc7.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# [2.7.0-beta.6](https://github.com/vitejs/vite/compare/v2.7.0-beta.5...v2.7.0-beta.6) (2021-11-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **dev:** Fix infinite recursion on query imports ([#5671](https://github.com/vitejs/vite/issues/5671)) ([#5674](https://github.com/vitejs/vite/issues/5674)) ([bce4e56](https://github.com/vitejs/vite/commit/bce4e56cb12b3c76f48bf2ddc37423025e79a0d2))
|
|
7
|
+
* **ssr:** avoid resolving ESM for CJS dependencies ([#5693](https://github.com/vitejs/vite/issues/5693)) ([b937ea4](https://github.com/vitejs/vite/commit/b937ea4cb1642a76d7a650802c0db2fede338474))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
# [2.7.0-beta.5](https://github.com/vitejs/vite/compare/v2.7.0-beta.4...v2.7.0-beta.5) (2021-11-13)
|
|
2
12
|
|
|
3
13
|
|
|
@@ -3974,7 +3974,7 @@ const knownTsRE = /\.(ts|mts|cts|tsx)$/;
|
|
|
3974
3974
|
const knownTsOutputRE = /\.(js|mjs|cjs|jsx)$/;
|
|
3975
3975
|
const isTsRequest = (url) => knownTsRE.test(cleanUrl(url));
|
|
3976
3976
|
const isPossibleTsOutput = (url) => knownTsOutputRE.test(cleanUrl(url));
|
|
3977
|
-
const getTsSrcPath = (filename) => filename.replace(/\.([cm])?(js)(x?)
|
|
3977
|
+
const getTsSrcPath = (filename) => filename.replace(/\.([cm])?(js)(x?)(\?|$)/, '.$1ts$3');
|
|
3978
3978
|
const importQueryRE = /(\?|&)import=?(?:&|$)/;
|
|
3979
3979
|
const internalPrefixes = [
|
|
3980
3980
|
FS_PREFIX,
|
|
@@ -20385,7 +20385,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
20385
20385
|
replacer: urlReplacer
|
|
20386
20386
|
}));
|
|
20387
20387
|
if (isModule) {
|
|
20388
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
20388
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-48461e78.js'); }).then(function (n) { return n.index; })).default({
|
|
20389
20389
|
...modulesOptions,
|
|
20390
20390
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
20391
20391
|
modules = _modules;
|
|
@@ -21350,7 +21350,7 @@ const assetAttrsConfig = {
|
|
|
21350
21350
|
const isAsyncScriptMap = new WeakMap();
|
|
21351
21351
|
async function traverseHtml(html, filePath, visitor) {
|
|
21352
21352
|
// lazy load compiler
|
|
21353
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
21353
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-1b2328e8.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
21354
21354
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
21355
21355
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
21356
21356
|
try {
|
|
@@ -29974,12 +29974,11 @@ function resolvePlugin(baseOptions) {
|
|
|
29974
29974
|
isRequire,
|
|
29975
29975
|
isFromTsImporter: isTsRequest(importer !== null && importer !== void 0 ? importer : '')
|
|
29976
29976
|
};
|
|
29977
|
-
const preserveSymlinks = !!(server === null || server === void 0 ? void 0 : server.config.resolve.preserveSymlinks);
|
|
29978
29977
|
let res;
|
|
29979
29978
|
// explicit fs paths that starts with /@fs/*
|
|
29980
29979
|
if (asSrc && id.startsWith(FS_PREFIX)) {
|
|
29981
29980
|
const fsPath = fsPathFromId(id);
|
|
29982
|
-
res = tryFsResolve(fsPath, options
|
|
29981
|
+
res = tryFsResolve(fsPath, options);
|
|
29983
29982
|
isDebug$5 && debug$d(`[@fs] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
29984
29983
|
// always return here even if res doesn't exist since /@fs/ is explicit
|
|
29985
29984
|
// if the file doesn't exist it should be a 404
|
|
@@ -29989,7 +29988,7 @@ function resolvePlugin(baseOptions) {
|
|
|
29989
29988
|
// /foo -> /fs-root/foo
|
|
29990
29989
|
if (asSrc && id.startsWith('/')) {
|
|
29991
29990
|
const fsPath = path__default.resolve(root, id.slice(1));
|
|
29992
|
-
if ((res = tryFsResolve(fsPath, options
|
|
29991
|
+
if ((res = tryFsResolve(fsPath, options))) {
|
|
29993
29992
|
isDebug$5 && debug$d(`[url] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
29994
29993
|
return res;
|
|
29995
29994
|
}
|
|
@@ -30011,10 +30010,10 @@ function resolvePlugin(baseOptions) {
|
|
|
30011
30010
|
}
|
|
30012
30011
|
}
|
|
30013
30012
|
if (targetWeb &&
|
|
30014
|
-
(res = tryResolveBrowserMapping(fsPath, importer, options, true
|
|
30013
|
+
(res = tryResolveBrowserMapping(fsPath, importer, options, true))) {
|
|
30015
30014
|
return res;
|
|
30016
30015
|
}
|
|
30017
|
-
if ((res = tryFsResolve(fsPath, options
|
|
30016
|
+
if ((res = tryFsResolve(fsPath, options))) {
|
|
30018
30017
|
isDebug$5 && debug$d(`[relative] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
30019
30018
|
const pkg = importer != null && idToPkgMap.get(importer);
|
|
30020
30019
|
if (pkg) {
|
|
@@ -30028,8 +30027,7 @@ function resolvePlugin(baseOptions) {
|
|
|
30028
30027
|
}
|
|
30029
30028
|
}
|
|
30030
30029
|
// absolute fs paths
|
|
30031
|
-
if (path__default.isAbsolute(id) &&
|
|
30032
|
-
(res = tryFsResolve(id, options, preserveSymlinks))) {
|
|
30030
|
+
if (path__default.isAbsolute(id) && (res = tryFsResolve(id, options))) {
|
|
30033
30031
|
isDebug$5 && debug$d(`[fs] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
30034
30032
|
return res;
|
|
30035
30033
|
}
|
|
@@ -30054,7 +30052,7 @@ function resolvePlugin(baseOptions) {
|
|
|
30054
30052
|
return res;
|
|
30055
30053
|
}
|
|
30056
30054
|
if (targetWeb &&
|
|
30057
|
-
(res = tryResolveBrowserMapping(id, importer, options, false
|
|
30055
|
+
(res = tryResolveBrowserMapping(id, importer, options, false))) {
|
|
30058
30056
|
return res;
|
|
30059
30057
|
}
|
|
30060
30058
|
if ((res = tryNodeResolve(id, importer, options, targetWeb, server, ssr))) {
|
|
@@ -30103,7 +30101,7 @@ function resolvePlugin(baseOptions) {
|
|
|
30103
30101
|
}
|
|
30104
30102
|
};
|
|
30105
30103
|
}
|
|
30106
|
-
function tryFsResolve(fsPath, options,
|
|
30104
|
+
function tryFsResolve(fsPath, options, tryIndex = true, targetWeb = true) {
|
|
30107
30105
|
let file = fsPath;
|
|
30108
30106
|
let postfix = '';
|
|
30109
30107
|
let postfixIndex = fsPath.indexOf('?');
|
|
@@ -30117,36 +30115,36 @@ function tryFsResolve(fsPath, options, preserveSymlinks, tryIndex = true, target
|
|
|
30117
30115
|
let res;
|
|
30118
30116
|
// if we fould postfix exist, we should first try resolving file with postfix. details see #4703.
|
|
30119
30117
|
if (postfix &&
|
|
30120
|
-
(res = tryResolveFile(fsPath, '', options, false, targetWeb,
|
|
30118
|
+
(res = tryResolveFile(fsPath, '', options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30121
30119
|
return res;
|
|
30122
30120
|
}
|
|
30123
|
-
if ((res = tryResolveFile(file, postfix, options, false, targetWeb,
|
|
30121
|
+
if ((res = tryResolveFile(file, postfix, options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30124
30122
|
return res;
|
|
30125
30123
|
}
|
|
30126
30124
|
for (const ext of options.extensions || DEFAULT_EXTENSIONS$1) {
|
|
30127
30125
|
if (postfix &&
|
|
30128
|
-
(res = tryResolveFile(fsPath + ext, '', options, false, targetWeb,
|
|
30126
|
+
(res = tryResolveFile(fsPath + ext, '', options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30129
30127
|
return res;
|
|
30130
30128
|
}
|
|
30131
|
-
if ((res = tryResolveFile(file + ext, postfix, options, false, targetWeb,
|
|
30129
|
+
if ((res = tryResolveFile(file + ext, postfix, options, false, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30132
30130
|
return res;
|
|
30133
30131
|
}
|
|
30134
30132
|
}
|
|
30135
30133
|
if (postfix &&
|
|
30136
|
-
(res = tryResolveFile(fsPath, '', options, tryIndex, targetWeb,
|
|
30134
|
+
(res = tryResolveFile(fsPath, '', options, tryIndex, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30137
30135
|
return res;
|
|
30138
30136
|
}
|
|
30139
|
-
if ((res = tryResolveFile(file, postfix, options, tryIndex, targetWeb,
|
|
30137
|
+
if ((res = tryResolveFile(file, postfix, options, tryIndex, targetWeb, options.tryPrefix, options.skipPackageJson))) {
|
|
30140
30138
|
return res;
|
|
30141
30139
|
}
|
|
30142
30140
|
}
|
|
30143
|
-
function tryResolveFile(file, postfix, options, tryIndex, targetWeb,
|
|
30141
|
+
function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix, skipPackageJson) {
|
|
30144
30142
|
// #2051 if we don't have read permission on a directory, existsSync() still
|
|
30145
30143
|
// works and will result in massively slow subsequent checks (which are
|
|
30146
30144
|
// unnecessary in the first place)
|
|
30147
30145
|
if (isFileReadable(file)) {
|
|
30148
30146
|
if (!fs__default.statSync(file).isDirectory()) {
|
|
30149
|
-
return getRealPath(file, preserveSymlinks) + postfix;
|
|
30147
|
+
return getRealPath(file, options.preserveSymlinks) + postfix;
|
|
30150
30148
|
}
|
|
30151
30149
|
else if (tryIndex) {
|
|
30152
30150
|
if (!skipPackageJson) {
|
|
@@ -30154,11 +30152,11 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, preserveSym
|
|
|
30154
30152
|
if (fs__default.existsSync(pkgPath)) {
|
|
30155
30153
|
// path points to a node package
|
|
30156
30154
|
const pkg = loadPackageData(pkgPath);
|
|
30157
|
-
const resolved = resolvePackageEntry(file, pkg,
|
|
30155
|
+
const resolved = resolvePackageEntry(file, pkg, targetWeb, options);
|
|
30158
30156
|
return resolved;
|
|
30159
30157
|
}
|
|
30160
30158
|
}
|
|
30161
|
-
const index = tryFsResolve(file + '/index', options
|
|
30159
|
+
const index = tryFsResolve(file + '/index', options);
|
|
30162
30160
|
if (index)
|
|
30163
30161
|
return index + postfix;
|
|
30164
30162
|
}
|
|
@@ -30166,11 +30164,11 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, preserveSym
|
|
|
30166
30164
|
const tryTsExtension = options.isFromTsImporter && isPossibleTsOutput(file);
|
|
30167
30165
|
if (tryTsExtension) {
|
|
30168
30166
|
const tsSrcPath = getTsSrcPath(file);
|
|
30169
|
-
return tryResolveFile(tsSrcPath, postfix, options, tryIndex, targetWeb,
|
|
30167
|
+
return tryResolveFile(tsSrcPath, postfix, options, tryIndex, targetWeb, tryPrefix, skipPackageJson);
|
|
30170
30168
|
}
|
|
30171
30169
|
if (tryPrefix) {
|
|
30172
30170
|
const prefixed = `${path__default.dirname(file)}/${tryPrefix}${path__default.basename(file)}`;
|
|
30173
|
-
return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb
|
|
30171
|
+
return tryResolveFile(prefixed, postfix, options, tryIndex, targetWeb);
|
|
30174
30172
|
}
|
|
30175
30173
|
}
|
|
30176
30174
|
const idToPkgMap = new Map();
|
|
@@ -30227,9 +30225,29 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
30227
30225
|
if (!pkg) {
|
|
30228
30226
|
return;
|
|
30229
30227
|
}
|
|
30230
|
-
let
|
|
30231
|
-
|
|
30232
|
-
|
|
30228
|
+
let resolveId = resolvePackageEntry;
|
|
30229
|
+
let unresolvedId = pkgId;
|
|
30230
|
+
if (unresolvedId !== nestedPath) {
|
|
30231
|
+
resolveId = resolveDeepImport;
|
|
30232
|
+
unresolvedId = '.' + nestedPath.slice(pkgId.length);
|
|
30233
|
+
}
|
|
30234
|
+
let resolved;
|
|
30235
|
+
try {
|
|
30236
|
+
resolved = resolveId(unresolvedId, pkg, targetWeb, options);
|
|
30237
|
+
}
|
|
30238
|
+
catch (err) {
|
|
30239
|
+
if (!options.tryEsmOnly) {
|
|
30240
|
+
throw err;
|
|
30241
|
+
}
|
|
30242
|
+
}
|
|
30243
|
+
if (!resolved && options.tryEsmOnly) {
|
|
30244
|
+
resolved = resolveId(unresolvedId, pkg, targetWeb, {
|
|
30245
|
+
...options,
|
|
30246
|
+
isRequire: false,
|
|
30247
|
+
mainFields: DEFAULT_MAIN_FIELDS,
|
|
30248
|
+
extensions: DEFAULT_EXTENSIONS$1
|
|
30249
|
+
});
|
|
30250
|
+
}
|
|
30233
30251
|
if (!resolved) {
|
|
30234
30252
|
return;
|
|
30235
30253
|
}
|
|
@@ -30373,7 +30391,7 @@ function loadPackageData(pkgPath, cacheKey = pkgPath) {
|
|
|
30373
30391
|
packageCache.set(cacheKey, pkg);
|
|
30374
30392
|
return pkg;
|
|
30375
30393
|
}
|
|
30376
|
-
function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache },
|
|
30394
|
+
function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache }, targetWeb, options) {
|
|
30377
30395
|
var _a, _b;
|
|
30378
30396
|
const cached = getResolvedCache('.', targetWeb);
|
|
30379
30397
|
if (cached) {
|
|
@@ -30405,7 +30423,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
30405
30423
|
// the heuristics here is to actually read the browser entry when
|
|
30406
30424
|
// possible and check for hints of UMD. If it is UMD, prefer "module"
|
|
30407
30425
|
// instead; Otherwise, assume it's ESM and use it.
|
|
30408
|
-
const resolvedBrowserEntry = tryFsResolve(path__default.join(dir, browserEntry), options
|
|
30426
|
+
const resolvedBrowserEntry = tryFsResolve(path__default.join(dir, browserEntry), options);
|
|
30409
30427
|
if (resolvedBrowserEntry) {
|
|
30410
30428
|
const content = fs__default.readFileSync(resolvedBrowserEntry, 'utf-8');
|
|
30411
30429
|
if ((/typeof exports\s*==/.test(content) &&
|
|
@@ -30442,7 +30460,7 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
30442
30460
|
entryPoint = mapWithBrowserField(entryPoint, browserField) || entryPoint;
|
|
30443
30461
|
}
|
|
30444
30462
|
entryPoint = path__default.join(dir, entryPoint);
|
|
30445
|
-
const resolvedEntryPoint = tryFsResolve(entryPoint, options
|
|
30463
|
+
const resolvedEntryPoint = tryFsResolve(entryPoint, options);
|
|
30446
30464
|
if (resolvedEntryPoint) {
|
|
30447
30465
|
isDebug$5 &&
|
|
30448
30466
|
debug$d(`[package entry] ${source.cyan(id)} -> ${source.dim(resolvedEntryPoint)}`);
|
|
@@ -30476,7 +30494,7 @@ function resolveExports(pkg, key, options, targetWeb) {
|
|
|
30476
30494
|
conditions
|
|
30477
30495
|
});
|
|
30478
30496
|
}
|
|
30479
|
-
function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolvedCache, dir, data },
|
|
30497
|
+
function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolvedCache, dir, data }, targetWeb, options) {
|
|
30480
30498
|
const cache = getResolvedCache(id, targetWeb);
|
|
30481
30499
|
if (cache) {
|
|
30482
30500
|
return cache;
|
|
@@ -30507,7 +30525,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
30507
30525
|
}
|
|
30508
30526
|
}
|
|
30509
30527
|
if (relativeId) {
|
|
30510
|
-
const resolved = tryFsResolve(path__default.join(dir, relativeId), options,
|
|
30528
|
+
const resolved = tryFsResolve(path__default.join(dir, relativeId), options, !exportsField, // try index only if no exports field
|
|
30511
30529
|
targetWeb);
|
|
30512
30530
|
if (resolved) {
|
|
30513
30531
|
isDebug$5 &&
|
|
@@ -30517,7 +30535,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
30517
30535
|
}
|
|
30518
30536
|
}
|
|
30519
30537
|
}
|
|
30520
|
-
function tryResolveBrowserMapping(id, importer, options, isFilePath
|
|
30538
|
+
function tryResolveBrowserMapping(id, importer, options, isFilePath) {
|
|
30521
30539
|
let res;
|
|
30522
30540
|
const pkg = importer && idToPkgMap.get(importer);
|
|
30523
30541
|
if (pkg && isObject$3(pkg.data.browser)) {
|
|
@@ -30525,7 +30543,7 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, preserveSym
|
|
|
30525
30543
|
const browserMappedPath = mapWithBrowserField(mapId, pkg.data.browser);
|
|
30526
30544
|
if (browserMappedPath) {
|
|
30527
30545
|
const fsPath = path__default.join(pkg.dir, browserMappedPath);
|
|
30528
|
-
if ((res = tryFsResolve(fsPath, options
|
|
30546
|
+
if ((res = tryFsResolve(fsPath, options))) {
|
|
30529
30547
|
isDebug$5 &&
|
|
30530
30548
|
debug$d(`[browser mapped] ${source.cyan(id)} -> ${source.dim(res)}`);
|
|
30531
30549
|
idToPkgMap.set(res, pkg);
|
|
@@ -43186,9 +43204,7 @@ function resolveBuildOptions(root, raw) {
|
|
|
43186
43204
|
input = Array.isArray(raw.rollupOptions.input)
|
|
43187
43205
|
? raw.rollupOptions.input.map(input => resolve(input))
|
|
43188
43206
|
: typeof raw.rollupOptions.input === 'object'
|
|
43189
|
-
? Object.
|
|
43190
|
-
// @ts-ignore
|
|
43191
|
-
...Object.keys(raw.rollupOptions.input).map(key => ({ [key]: resolve(raw.rollupOptions.input[key]) })))
|
|
43207
|
+
? Object.fromEntries(Object.entries(raw.rollupOptions.input).map(([key, value]) => [key, resolve(value)]))
|
|
43192
43208
|
: resolve(raw.rollupOptions.input);
|
|
43193
43209
|
}
|
|
43194
43210
|
else {
|
|
@@ -49346,7 +49362,7 @@ function readFileIfExists(value) {
|
|
|
49346
49362
|
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
|
|
49347
49363
|
*/
|
|
49348
49364
|
async function createCertificate() {
|
|
49349
|
-
const { generate } = await Promise.resolve().then(function () { return require('./dep-
|
|
49365
|
+
const { generate } = await Promise.resolve().then(function () { return require('./dep-146e2d5f.js'); }).then(function (n) { return n.index; });
|
|
49350
49366
|
const pems = generate(null, {
|
|
49351
49367
|
algorithm: 'sha256',
|
|
49352
49368
|
days: 30,
|
|
@@ -67073,28 +67089,20 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
67073
67089
|
};
|
|
67074
67090
|
urlStack = urlStack.concat(url);
|
|
67075
67091
|
const isCircular = (url) => urlStack.includes(url);
|
|
67076
|
-
const { isProduction, resolve: { dedupe }, root } = server.config;
|
|
67092
|
+
const { isProduction, resolve: { dedupe, preserveSymlinks }, root } = server.config;
|
|
67077
67093
|
// The `extensions` and `mainFields` options are used to ensure that
|
|
67078
67094
|
// CommonJS modules are preferred. We want to avoid ESM->ESM imports
|
|
67079
67095
|
// whenever possible, because `hookNodeResolve` can't intercept them.
|
|
67080
67096
|
const resolveOptions = {
|
|
67081
|
-
// By adding "require" to the `conditions` array, resolution of the
|
|
67082
|
-
// pkg.exports field will use "require" condition whenever it comes
|
|
67083
|
-
// before "import" condition.
|
|
67084
|
-
conditions: ['node', 'require'],
|
|
67085
67097
|
dedupe,
|
|
67086
|
-
extensions: ['.js', '.cjs', '.
|
|
67098
|
+
extensions: ['.js', '.cjs', '.json'],
|
|
67087
67099
|
isBuild: true,
|
|
67088
67100
|
isProduction,
|
|
67089
|
-
|
|
67101
|
+
isRequire: true,
|
|
67102
|
+
mainFields: ['main'],
|
|
67103
|
+
preserveSymlinks,
|
|
67090
67104
|
root
|
|
67091
67105
|
};
|
|
67092
|
-
// Prevent ESM modules from being resolved during test runs, since Jest
|
|
67093
|
-
// cannot `require` them. Note: This prevents testing of ESM-only packages.
|
|
67094
|
-
if (typeof jest !== 'undefined') {
|
|
67095
|
-
resolveOptions.isRequire = true;
|
|
67096
|
-
resolveOptions.mainFields = ['main'];
|
|
67097
|
-
}
|
|
67098
67106
|
// Since dynamic imports can happen in parallel, we need to
|
|
67099
67107
|
// account for multiple pending deps and duplicate imports.
|
|
67100
67108
|
const pendingDeps = [];
|
|
@@ -67164,8 +67172,8 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
|
|
|
67164
67172
|
async function nodeImport(id, importer, resolveOptions) {
|
|
67165
67173
|
// Node's module resolution is hi-jacked so Vite can ensure the
|
|
67166
67174
|
// configured `resolve.dedupe` and `mode` options are respected.
|
|
67167
|
-
const viteResolve = (id, importer) => {
|
|
67168
|
-
const resolved = tryNodeResolve(id, importer,
|
|
67175
|
+
const viteResolve = (id, importer, options = resolveOptions) => {
|
|
67176
|
+
const resolved = tryNodeResolve(id, importer, options, false);
|
|
67169
67177
|
if (!resolved) {
|
|
67170
67178
|
const err = new Error(`Cannot find module '${id}' imported from '${importer}'`);
|
|
67171
67179
|
err.code = 'ERR_MODULE_NOT_FOUND';
|
|
@@ -67178,18 +67186,25 @@ async function nodeImport(id, importer, resolveOptions) {
|
|
|
67178
67186
|
if (id[0] === '.' || isBuiltin(id)) {
|
|
67179
67187
|
return nodeResolve(id, parent, isMain, options);
|
|
67180
67188
|
}
|
|
67181
|
-
if (
|
|
67182
|
-
return id;
|
|
67189
|
+
if (parent) {
|
|
67190
|
+
return viteResolve(id, parent.id);
|
|
67183
67191
|
}
|
|
67184
|
-
|
|
67192
|
+
// Importing a CJS module from an ESM module. In this case, the import
|
|
67193
|
+
// specifier is already an absolute path, so this is a no-op.
|
|
67194
|
+
// Options like `resolve.dedupe` and `mode` are not respected.
|
|
67195
|
+
return id;
|
|
67185
67196
|
});
|
|
67186
67197
|
let url;
|
|
67187
|
-
// `resolve` doesn't handle `node:` builtins, so handle them directly
|
|
67188
67198
|
if (id.startsWith('node:') || isBuiltin(id)) {
|
|
67189
67199
|
url = id;
|
|
67190
67200
|
}
|
|
67191
67201
|
else {
|
|
67192
|
-
url = viteResolve(id, importer
|
|
67202
|
+
url = viteResolve(id, importer,
|
|
67203
|
+
// Non-external modules can import ESM-only modules, but only outside
|
|
67204
|
+
// of test runs, because we use Node `require` in Jest to avoid segfault.
|
|
67205
|
+
typeof jest === 'undefined'
|
|
67206
|
+
? { ...resolveOptions, tryEsmOnly: true }
|
|
67207
|
+
: resolveOptions);
|
|
67193
67208
|
if (usingDynamicImport) {
|
|
67194
67209
|
url = require$$0$7.pathToFileURL(url).toString();
|
|
67195
67210
|
}
|
|
@@ -82204,4 +82219,4 @@ exports.send = send$1;
|
|
|
82204
82219
|
exports.sortUserPlugins = sortUserPlugins;
|
|
82205
82220
|
exports.source = source;
|
|
82206
82221
|
exports.transformWithEsbuild = transformWithEsbuild;
|
|
82207
|
-
//# sourceMappingURL=dep-
|
|
82222
|
+
//# sourceMappingURL=dep-0183a921.js.map
|