vite 5.0.0-beta.1 → 5.0.0-beta.2
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 +7 -0
- package/client.d.ts +8 -56
- package/dist/node/chunks/{dep-c457d7ce.js → dep-13ae786e.js} +1 -1
- package/dist/node/chunks/{dep-6db0c752.js → dep-5c5f3875.js} +1 -1
- package/dist/node/chunks/{dep-e31699fa.js → dep-82f73734.js} +1488 -915
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.js +3 -3
- package/dist/node-cjs/publicUtils.cjs +263 -10
- package/package.json +5 -4
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import fs$l from 'node:fs';
|
|
1
|
+
import fs$l, { promises as promises$1 } from 'node:fs';
|
|
2
2
|
import fsp from 'node:fs/promises';
|
|
3
|
-
import path$o, {
|
|
3
|
+
import path$o, { posix as posix$1, isAbsolute as isAbsolute$2, join as join$2, relative as relative$2, dirname as dirname$2, basename as basename$2, extname as extname$1 } from 'node:path';
|
|
4
4
|
import { fileURLToPath, URL as URL$3, URLSearchParams, parse as parse$i, pathToFileURL } from 'node:url';
|
|
5
5
|
import { promisify as promisify$4, format as format$2, inspect } from 'node:util';
|
|
6
6
|
import { performance } from 'node:perf_hooks';
|
|
7
7
|
import { createRequire as createRequire$1, builtinModules } from 'node:module';
|
|
8
8
|
import require$$0$3 from 'tty';
|
|
9
9
|
import esbuild, { transform as transform$1, formatMessages, build as build$3 } from 'esbuild';
|
|
10
|
-
import require$$0$4, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, sep
|
|
10
|
+
import require$$0$4, { win32, posix, isAbsolute as isAbsolute$1, resolve as resolve$3, relative as relative$1, basename as basename$1, extname, dirname as dirname$1, join as join$1, sep, normalize } from 'path';
|
|
11
11
|
import * as require$$0$2 from 'fs';
|
|
12
|
-
import require$$0__default, { existsSync, readFileSync, statSync as statSync$1,
|
|
12
|
+
import require$$0__default, { existsSync, readFileSync, statSync as statSync$1, readdirSync } from 'fs';
|
|
13
13
|
import require$$0$5 from 'events';
|
|
14
14
|
import require$$5 from 'assert';
|
|
15
15
|
import require$$0$6 from 'util';
|
|
@@ -31,13 +31,13 @@ import assert$1 from 'node:assert';
|
|
|
31
31
|
import process$1 from 'node:process';
|
|
32
32
|
import v8 from 'node:v8';
|
|
33
33
|
import { VERSION } from 'rollup';
|
|
34
|
-
import require$$1 from 'worker_threads';
|
|
35
34
|
import { createServer as createServer$3, STATUS_CODES } from 'node:http';
|
|
36
35
|
import { createServer as createServer$2 } from 'node:https';
|
|
37
36
|
import require$$0$a from 'zlib';
|
|
38
37
|
import require$$0$b from 'buffer';
|
|
39
38
|
import require$$1$2 from 'https';
|
|
40
39
|
import require$$4$1 from 'tls';
|
|
40
|
+
import require$$1 from 'worker_threads';
|
|
41
41
|
import * as qs from 'querystring';
|
|
42
42
|
import readline from 'node:readline';
|
|
43
43
|
import zlib$1, { gzip } from 'node:zlib';
|
|
@@ -420,7 +420,7 @@ let SyncWalker$1 = class SyncWalker extends WalkerBase$1 {
|
|
|
420
420
|
* }} walker
|
|
421
421
|
* @returns {BaseNode}
|
|
422
422
|
*/
|
|
423
|
-
function walk$
|
|
423
|
+
function walk$3(ast, { enter, leave }) {
|
|
424
424
|
const instance = new SyncWalker$1(enter, leave);
|
|
425
425
|
return instance.visit(ast, null);
|
|
426
426
|
}
|
|
@@ -2559,7 +2559,7 @@ let Scope$1 = class Scope {
|
|
|
2559
2559
|
};
|
|
2560
2560
|
const attachScopes = function attachScopes(ast, propertyName = 'scope') {
|
|
2561
2561
|
let scope = new Scope$1();
|
|
2562
|
-
walk$
|
|
2562
|
+
walk$3(ast, {
|
|
2563
2563
|
enter(n, parent) {
|
|
2564
2564
|
const node = n;
|
|
2565
2565
|
// function foo () {...}
|
|
@@ -7796,7 +7796,7 @@ function getEsImportProxy(id, defaultIsModuleExports) {
|
|
|
7796
7796
|
/* eslint-disable no-param-reassign, no-undefined */
|
|
7797
7797
|
|
|
7798
7798
|
function getCandidatesForExtension(resolved, extension) {
|
|
7799
|
-
return [resolved + extension, `${resolved}${sep
|
|
7799
|
+
return [resolved + extension, `${resolved}${sep}index${extension}`];
|
|
7800
7800
|
}
|
|
7801
7801
|
|
|
7802
7802
|
function getCandidates(resolved, extensions) {
|
|
@@ -8849,7 +8849,7 @@ async function transformCommonjs(
|
|
|
8849
8849
|
const importedVariables = new Set();
|
|
8850
8850
|
const indentExclusionRanges = [];
|
|
8851
8851
|
|
|
8852
|
-
walk$
|
|
8852
|
+
walk$3(ast, {
|
|
8853
8853
|
enter(node, parent) {
|
|
8854
8854
|
if (skippedNodes.has(node)) {
|
|
8855
8855
|
this.skip();
|
|
@@ -11549,7 +11549,7 @@ if (typeof process === 'undefined' || process.type === 'renderer' || process.bro
|
|
|
11549
11549
|
}
|
|
11550
11550
|
|
|
11551
11551
|
var srcExports$1 = src$2.exports;
|
|
11552
|
-
var debug$
|
|
11552
|
+
var debug$h = /*@__PURE__*/getDefaultExportFromCjs(srcExports$1);
|
|
11553
11553
|
|
|
11554
11554
|
let pnp;
|
|
11555
11555
|
if (process.versions.pnp) {
|
|
@@ -11707,7 +11707,7 @@ function watchPackageDataPlugin(packageCache) {
|
|
|
11707
11707
|
let watchFile = watchFileStub;
|
|
11708
11708
|
const setPackageData = packageCache.set.bind(packageCache);
|
|
11709
11709
|
packageCache.set = (id, pkg) => {
|
|
11710
|
-
if (!isInNodeModules(pkg.dir) && !watchedDirs.has(pkg.dir)) {
|
|
11710
|
+
if (!isInNodeModules$1(pkg.dir) && !watchedDirs.has(pkg.dir)) {
|
|
11711
11711
|
watchedDirs.add(pkg.dir);
|
|
11712
11712
|
watchFile(path$o.join(pkg.dir, 'package.json'));
|
|
11713
11713
|
}
|
|
@@ -11857,7 +11857,7 @@ function isBuiltin(id) {
|
|
|
11857
11857
|
? id.slice(NODE_BUILTIN_NAMESPACE.length)
|
|
11858
11858
|
: id);
|
|
11859
11859
|
}
|
|
11860
|
-
function isInNodeModules(id) {
|
|
11860
|
+
function isInNodeModules$1(id) {
|
|
11861
11861
|
return id.includes('node_modules');
|
|
11862
11862
|
}
|
|
11863
11863
|
function moduleListContains(moduleList, id) {
|
|
@@ -11876,7 +11876,7 @@ const _require$3 = createRequire$1(import.meta.url);
|
|
|
11876
11876
|
const filter = process.env.VITE_DEBUG_FILTER;
|
|
11877
11877
|
const DEBUG = process.env.DEBUG;
|
|
11878
11878
|
function createDebugger(namespace, options = {}) {
|
|
11879
|
-
const log = debug$
|
|
11879
|
+
const log = debug$h(namespace);
|
|
11880
11880
|
const { onlyWhenFocused } = options;
|
|
11881
11881
|
let enabled = log.enabled;
|
|
11882
11882
|
if (enabled && onlyWhenFocused) {
|
|
@@ -12693,7 +12693,7 @@ const isNonDriveRelativeAbsolutePath = (p) => {
|
|
|
12693
12693
|
};
|
|
12694
12694
|
/**
|
|
12695
12695
|
* Determine if a file is being requested with the correct case, to ensure
|
|
12696
|
-
* consistent
|
|
12696
|
+
* consistent behavior between dev and prod and across operating systems.
|
|
12697
12697
|
*/
|
|
12698
12698
|
function shouldServeFile(filePath, root) {
|
|
12699
12699
|
// can skip case check on Linux
|
|
@@ -13003,7 +13003,7 @@ function buildReporterPlugin(config) {
|
|
|
13003
13003
|
// the same chunk. The intersecting dynamic importers' dynamic import is not
|
|
13004
13004
|
// expected to work. Note we're only detecting the direct ineffective
|
|
13005
13005
|
// dynamic import here.
|
|
13006
|
-
const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules(id) && chunk.moduleIds.includes(id));
|
|
13006
|
+
const detectedIneffectiveDynamicImport = module.dynamicImporters.some((id) => !isInNodeModules$1(id) && chunk.moduleIds.includes(id));
|
|
13007
13007
|
if (detectedIneffectiveDynamicImport) {
|
|
13008
13008
|
this.warn(`\n(!) ${module.id} is dynamically imported by ${module.dynamicImporters.join(', ')} but also statically imported by ${module.importers.join(', ')}, dynamic import will not move module into another chunk.\n`);
|
|
13009
13009
|
}
|
|
@@ -13172,635 +13172,988 @@ function displayTime(time) {
|
|
|
13172
13172
|
return `${mins}m${seconds < 1 ? '' : ` ${seconds.toFixed(0)}s`}`;
|
|
13173
13173
|
}
|
|
13174
13174
|
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
13180
|
-
|
|
13181
|
-
|
|
13182
|
-
|
|
13183
|
-
|
|
13184
|
-
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
|
|
13190
|
-
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13175
|
+
const POSIX_SEP_RE = new RegExp('\\' + path$o.posix.sep, 'g');
|
|
13176
|
+
const NATIVE_SEP_RE = new RegExp('\\' + path$o.sep, 'g');
|
|
13177
|
+
/** @type {Map<string,RegExp>}*/
|
|
13178
|
+
const PATTERN_REGEX_CACHE = new Map();
|
|
13179
|
+
const GLOB_ALL_PATTERN = `**/*`;
|
|
13180
|
+
const DEFAULT_EXTENSIONS = ['.ts', '.tsx', '.mts', '.cts'];
|
|
13181
|
+
const DEFAULT_EXTENSIONS_RE_GROUP = `\\.(?:${DEFAULT_EXTENSIONS.map((ext) => ext.substring(1)).join(
|
|
13182
|
+
'|'
|
|
13183
|
+
)})`;
|
|
13184
|
+
|
|
13185
|
+
const IS_POSIX = path$o.posix.sep === path$o.sep;
|
|
13186
|
+
|
|
13187
|
+
/**
|
|
13188
|
+
* @template T
|
|
13189
|
+
* @returns {{resolve:(result:T)=>void, reject:(error:any)=>void, promise: Promise<T>}}
|
|
13190
|
+
*/
|
|
13191
|
+
function makePromise() {
|
|
13192
|
+
let resolve, reject;
|
|
13193
|
+
const promise = new Promise((res, rej) => {
|
|
13194
|
+
resolve = res;
|
|
13195
|
+
reject = rej;
|
|
13196
|
+
});
|
|
13197
|
+
return { promise, resolve, reject };
|
|
13196
13198
|
}
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13211
|
-
|
|
13199
|
+
|
|
13200
|
+
/**
|
|
13201
|
+
* @param {string} filename
|
|
13202
|
+
* @param {import('./cache.js').TSConfckCache} [cache]
|
|
13203
|
+
* @returns {Promise<string|void>}
|
|
13204
|
+
*/
|
|
13205
|
+
async function resolveTSConfigJson(filename, cache) {
|
|
13206
|
+
if (path$o.extname(filename) !== '.json') {
|
|
13207
|
+
return; // ignore files that are not json
|
|
13208
|
+
}
|
|
13209
|
+
const tsconfig = path$o.resolve(filename);
|
|
13210
|
+
if (cache) {
|
|
13211
|
+
if (cache.hasParseResult(tsconfig) || cache.hasParseResult(filename)) {
|
|
13212
|
+
return tsconfig;
|
|
13213
|
+
}
|
|
13214
|
+
}
|
|
13215
|
+
return promises$1.stat(tsconfig).then((stat) => {
|
|
13216
|
+
if (stat.isFile() || stat.isFIFO()) {
|
|
13217
|
+
return tsconfig;
|
|
13218
|
+
} else {
|
|
13219
|
+
throw new Error(`${filename} exists but is not a regular file.`);
|
|
13220
|
+
}
|
|
13221
|
+
});
|
|
13212
13222
|
}
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13223
|
+
|
|
13224
|
+
/**
|
|
13225
|
+
*
|
|
13226
|
+
* @param {string} dir an absolute directory path
|
|
13227
|
+
* @returns {boolean} if dir path includes a node_modules segment
|
|
13228
|
+
*/
|
|
13229
|
+
const isInNodeModules = IS_POSIX
|
|
13230
|
+
? (dir) => dir.includes('/node_modules/')
|
|
13231
|
+
: (dir) => dir.match(/[/\\]node_modules[/\\]/);
|
|
13232
|
+
|
|
13233
|
+
/**
|
|
13234
|
+
* convert posix separator to native separator
|
|
13235
|
+
*
|
|
13236
|
+
* eg.
|
|
13237
|
+
* windows: C:/foo/bar -> c:\foo\bar
|
|
13238
|
+
* linux: /foo/bar -> /foo/bar
|
|
13239
|
+
*
|
|
13240
|
+
* @param {string} filename with posix separators
|
|
13241
|
+
* @returns {string} filename with native separators
|
|
13242
|
+
*/
|
|
13243
|
+
const posix2native = IS_POSIX
|
|
13244
|
+
? (filename) => filename
|
|
13245
|
+
: (filename) => filename.replace(POSIX_SEP_RE, path$o.sep);
|
|
13246
|
+
|
|
13247
|
+
/**
|
|
13248
|
+
* convert native separator to posix separator
|
|
13249
|
+
*
|
|
13250
|
+
* eg.
|
|
13251
|
+
* windows: C:\foo\bar -> c:/foo/bar
|
|
13252
|
+
* linux: /foo/bar -> /foo/bar
|
|
13253
|
+
*
|
|
13254
|
+
* @param {string} filename - filename with native separators
|
|
13255
|
+
* @returns {string} filename with posix separators
|
|
13256
|
+
*/
|
|
13257
|
+
const native2posix = IS_POSIX
|
|
13258
|
+
? (filename) => filename
|
|
13259
|
+
: (filename) => filename.replace(NATIVE_SEP_RE, path$o.posix.sep);
|
|
13260
|
+
|
|
13261
|
+
/**
|
|
13262
|
+
* converts params to native separator, resolves path and converts native back to posix
|
|
13263
|
+
*
|
|
13264
|
+
* needed on windows to handle posix paths in tsconfig
|
|
13265
|
+
*
|
|
13266
|
+
* @param dir {string|null} directory to resolve from
|
|
13267
|
+
* @param filename {string} filename or pattern to resolve
|
|
13268
|
+
* @returns string
|
|
13269
|
+
*/
|
|
13270
|
+
const resolve2posix = IS_POSIX
|
|
13271
|
+
? (dir, filename) => (dir ? path$o.resolve(dir, filename) : path$o.resolve(filename))
|
|
13272
|
+
: (dir, filename) =>
|
|
13273
|
+
native2posix(
|
|
13274
|
+
dir
|
|
13275
|
+
? path$o.resolve(posix2native(dir), posix2native(filename))
|
|
13276
|
+
: path$o.resolve(posix2native(filename))
|
|
13277
|
+
);
|
|
13278
|
+
|
|
13279
|
+
/**
|
|
13280
|
+
*
|
|
13281
|
+
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13282
|
+
* @returns {string[]}
|
|
13283
|
+
*/
|
|
13284
|
+
function resolveReferencedTSConfigFiles(result) {
|
|
13285
|
+
const dir = path$o.dirname(result.tsconfigFile);
|
|
13286
|
+
return result.tsconfig.references.map((ref) => {
|
|
13287
|
+
const refPath = ref.path.endsWith('.json') ? ref.path : path$o.join(ref.path, 'tsconfig.json');
|
|
13288
|
+
return resolve2posix(dir, refPath);
|
|
13289
|
+
});
|
|
13224
13290
|
}
|
|
13225
|
-
|
|
13226
|
-
|
|
13227
|
-
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
|
|
13238
|
-
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13291
|
+
|
|
13292
|
+
/**
|
|
13293
|
+
* @param {string} filename
|
|
13294
|
+
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13295
|
+
* @returns {import('./public.d.ts').TSConfckParseResult}
|
|
13296
|
+
*/
|
|
13297
|
+
function resolveSolutionTSConfig(filename, result) {
|
|
13298
|
+
if (
|
|
13299
|
+
result.referenced &&
|
|
13300
|
+
DEFAULT_EXTENSIONS.some((ext) => filename.endsWith(ext)) &&
|
|
13301
|
+
!isIncluded(filename, result)
|
|
13302
|
+
) {
|
|
13303
|
+
const solutionTSConfig = result.referenced.find((referenced) =>
|
|
13304
|
+
isIncluded(filename, referenced)
|
|
13305
|
+
);
|
|
13306
|
+
if (solutionTSConfig) {
|
|
13307
|
+
return solutionTSConfig;
|
|
13308
|
+
}
|
|
13309
|
+
}
|
|
13310
|
+
return result;
|
|
13311
|
+
}
|
|
13312
|
+
|
|
13313
|
+
/**
|
|
13314
|
+
*
|
|
13315
|
+
* @param {string} filename
|
|
13316
|
+
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13317
|
+
* @returns {boolean}
|
|
13318
|
+
*/
|
|
13319
|
+
function isIncluded(filename, result) {
|
|
13320
|
+
const dir = native2posix(path$o.dirname(result.tsconfigFile));
|
|
13321
|
+
const files = (result.tsconfig.files || []).map((file) => resolve2posix(dir, file));
|
|
13322
|
+
const absoluteFilename = resolve2posix(null, filename);
|
|
13323
|
+
if (files.includes(filename)) {
|
|
13324
|
+
return true;
|
|
13325
|
+
}
|
|
13326
|
+
const isIncluded = isGlobMatch(
|
|
13327
|
+
absoluteFilename,
|
|
13328
|
+
dir,
|
|
13329
|
+
result.tsconfig.include || (result.tsconfig.files ? [] : [GLOB_ALL_PATTERN])
|
|
13330
|
+
);
|
|
13331
|
+
if (isIncluded) {
|
|
13332
|
+
const isExcluded = isGlobMatch(absoluteFilename, dir, result.tsconfig.exclude || []);
|
|
13333
|
+
return !isExcluded;
|
|
13334
|
+
}
|
|
13335
|
+
return false;
|
|
13336
|
+
}
|
|
13337
|
+
|
|
13338
|
+
/**
|
|
13339
|
+
* test filenames agains glob patterns in tsconfig
|
|
13340
|
+
*
|
|
13341
|
+
* @param filename {string} posix style abolute path to filename to test
|
|
13342
|
+
* @param dir {string} posix style absolute path to directory of tsconfig containing patterns
|
|
13343
|
+
* @param patterns {string[]} glob patterns to match against
|
|
13344
|
+
* @returns {boolean} true when at least one pattern matches filename
|
|
13345
|
+
*/
|
|
13346
|
+
function isGlobMatch(filename, dir, patterns) {
|
|
13347
|
+
return patterns.some((pattern) => {
|
|
13348
|
+
// filename must end with part of pattern that comes after last wildcard
|
|
13349
|
+
let lastWildcardIndex = pattern.length;
|
|
13350
|
+
let hasWildcard = false;
|
|
13351
|
+
for (let i = pattern.length - 1; i > -1; i--) {
|
|
13352
|
+
if (pattern[i] === '*' || pattern[i] === '?') {
|
|
13353
|
+
lastWildcardIndex = i;
|
|
13354
|
+
hasWildcard = true;
|
|
13355
|
+
break;
|
|
13356
|
+
}
|
|
13357
|
+
}
|
|
13358
|
+
|
|
13359
|
+
// if pattern does not end with wildcard, filename must end with pattern after last wildcard
|
|
13360
|
+
if (
|
|
13361
|
+
lastWildcardIndex < pattern.length - 1 &&
|
|
13362
|
+
!filename.endsWith(pattern.slice(lastWildcardIndex + 1))
|
|
13363
|
+
) {
|
|
13364
|
+
return false;
|
|
13365
|
+
}
|
|
13366
|
+
|
|
13367
|
+
// if pattern ends with *, filename must end with a default extension
|
|
13368
|
+
if (pattern.endsWith('*') && !DEFAULT_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
13369
|
+
return false;
|
|
13370
|
+
}
|
|
13371
|
+
|
|
13372
|
+
// for **/* , filename must start with the dir
|
|
13373
|
+
if (pattern === GLOB_ALL_PATTERN) {
|
|
13374
|
+
return filename.startsWith(`${dir}/`);
|
|
13375
|
+
}
|
|
13376
|
+
|
|
13377
|
+
const resolvedPattern = resolve2posix(dir, pattern);
|
|
13378
|
+
|
|
13379
|
+
// filename must start with part of pattern that comes before first wildcard
|
|
13380
|
+
let firstWildcardIndex = -1;
|
|
13381
|
+
for (let i = 0; i < resolvedPattern.length; i++) {
|
|
13382
|
+
if (resolvedPattern[i] === '*' || resolvedPattern[i] === '?') {
|
|
13383
|
+
firstWildcardIndex = i;
|
|
13384
|
+
hasWildcard = true;
|
|
13385
|
+
break;
|
|
13386
|
+
}
|
|
13387
|
+
}
|
|
13388
|
+
if (
|
|
13389
|
+
firstWildcardIndex > 1 &&
|
|
13390
|
+
!filename.startsWith(resolvedPattern.slice(0, firstWildcardIndex - 1))
|
|
13391
|
+
) {
|
|
13392
|
+
return false;
|
|
13393
|
+
}
|
|
13394
|
+
|
|
13395
|
+
// if no wildcard in pattern, filename must be equal to resolved pattern
|
|
13396
|
+
if (!hasWildcard) {
|
|
13397
|
+
return filename === resolvedPattern;
|
|
13398
|
+
}
|
|
13399
|
+
|
|
13400
|
+
// complex pattern, use regex to check it
|
|
13401
|
+
if (PATTERN_REGEX_CACHE.has(resolvedPattern)) {
|
|
13402
|
+
return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
|
|
13403
|
+
}
|
|
13404
|
+
const regex = pattern2regex(resolvedPattern);
|
|
13405
|
+
PATTERN_REGEX_CACHE.set(resolvedPattern, regex);
|
|
13406
|
+
return regex.test(filename);
|
|
13407
|
+
});
|
|
13408
|
+
}
|
|
13409
|
+
|
|
13410
|
+
/**
|
|
13411
|
+
* @param {string} resolvedPattern
|
|
13412
|
+
* @returns {RegExp}
|
|
13413
|
+
*/
|
|
13414
|
+
function pattern2regex(resolvedPattern) {
|
|
13415
|
+
let regexStr = '^';
|
|
13416
|
+
for (let i = 0; i < resolvedPattern.length; i++) {
|
|
13417
|
+
const char = resolvedPattern[i];
|
|
13418
|
+
if (char === '?') {
|
|
13419
|
+
regexStr += '[^\\/]';
|
|
13420
|
+
continue;
|
|
13421
|
+
}
|
|
13422
|
+
if (char === '*') {
|
|
13423
|
+
if (resolvedPattern[i + 1] === '*' && resolvedPattern[i + 2] === '/') {
|
|
13424
|
+
i += 2;
|
|
13425
|
+
regexStr += '(?:[^\\/]*\\/)*'; // zero or more path segments
|
|
13426
|
+
continue;
|
|
13427
|
+
}
|
|
13428
|
+
regexStr += '[^\\/]*';
|
|
13429
|
+
continue;
|
|
13430
|
+
}
|
|
13431
|
+
if ('/.+^${}()|[]\\'.includes(char)) {
|
|
13432
|
+
regexStr += `\\`;
|
|
13433
|
+
}
|
|
13434
|
+
regexStr += char;
|
|
13435
|
+
}
|
|
13436
|
+
|
|
13437
|
+
// add known file endings if pattern ends on *
|
|
13438
|
+
if (resolvedPattern.endsWith('*')) {
|
|
13439
|
+
regexStr += DEFAULT_EXTENSIONS_RE_GROUP;
|
|
13440
|
+
}
|
|
13441
|
+
regexStr += '$';
|
|
13442
|
+
|
|
13443
|
+
return new RegExp(regexStr);
|
|
13444
|
+
}
|
|
13445
|
+
|
|
13446
|
+
/**
|
|
13447
|
+
* find the closest tsconfig.json file
|
|
13448
|
+
*
|
|
13449
|
+
* @param {string} filename - path to file to find tsconfig for (absolute or relative to cwd)
|
|
13450
|
+
* @param {import('./public.d.ts').TSConfckFindOptions} [options] - options
|
|
13451
|
+
* @returns {Promise<string|null>} absolute path to closest tsconfig.json or null if not found
|
|
13452
|
+
*/
|
|
13453
|
+
async function find(filename, options) {
|
|
13454
|
+
let dir = path$o.dirname(path$o.resolve(filename));
|
|
13455
|
+
if (options?.ignoreNodeModules && isInNodeModules(dir)) {
|
|
13456
|
+
return null;
|
|
13457
|
+
}
|
|
13458
|
+
const cache = options?.cache;
|
|
13459
|
+
if (cache?.hasTSConfigPath(dir)) {
|
|
13460
|
+
return cache.getTSConfigPath(dir);
|
|
13461
|
+
}
|
|
13462
|
+
const { /** @type {Promise<string|null>} */ promise, resolve, reject } = makePromise();
|
|
13463
|
+
const root = options?.root ? path$o.resolve(options.root) : null;
|
|
13464
|
+
findUp(dir, { promise, resolve, reject }, options?.cache, root);
|
|
13465
|
+
return promise;
|
|
13466
|
+
}
|
|
13467
|
+
|
|
13468
|
+
/**
|
|
13469
|
+
*
|
|
13470
|
+
* @param {string} dir
|
|
13471
|
+
* @param {{promise:Promise<string|null>,resolve:(result:string|null)=>void,reject:(err:any)=>void}} madePromise
|
|
13472
|
+
* @param {import('./cache.js').TSConfckCache} [cache]
|
|
13473
|
+
* @param {string} [root]
|
|
13474
|
+
*/
|
|
13475
|
+
function findUp(dir, { resolve, reject, promise }, cache, root) {
|
|
13476
|
+
const tsconfig = path$o.join(dir, 'tsconfig.json');
|
|
13477
|
+
if (cache) {
|
|
13478
|
+
if (cache.hasTSConfigPath(dir)) {
|
|
13479
|
+
let cached;
|
|
13480
|
+
try {
|
|
13481
|
+
cached = cache.getTSConfigPath(dir);
|
|
13482
|
+
} catch (e) {
|
|
13483
|
+
reject(e);
|
|
13484
|
+
return;
|
|
13485
|
+
}
|
|
13486
|
+
if (cached?.then) {
|
|
13487
|
+
cached.then(resolve).catch(reject);
|
|
13488
|
+
} else {
|
|
13489
|
+
resolve(cached);
|
|
13490
|
+
}
|
|
13491
|
+
} else {
|
|
13492
|
+
cache.setTSConfigPath(dir, promise);
|
|
13493
|
+
}
|
|
13494
|
+
}
|
|
13495
|
+
fs$l.stat(tsconfig, (err, stats) => {
|
|
13496
|
+
if (stats && (stats.isFile() || stats.isFIFO())) {
|
|
13497
|
+
resolve(tsconfig);
|
|
13498
|
+
} else if (err?.code !== 'ENOENT') {
|
|
13499
|
+
reject(err);
|
|
13500
|
+
} else {
|
|
13501
|
+
let parent;
|
|
13502
|
+
if (root === dir || (parent = path$o.dirname(dir)) === dir) {
|
|
13503
|
+
resolve(null);
|
|
13504
|
+
} else {
|
|
13505
|
+
findUp(parent, { promise, resolve, reject }, cache, root);
|
|
13506
|
+
}
|
|
13507
|
+
}
|
|
13508
|
+
});
|
|
13253
13509
|
}
|
|
13254
13510
|
|
|
13255
|
-
|
|
13511
|
+
/*
|
|
13512
|
+
this file contains code from strip-bom and strip-json-comments by Sindre Sorhus
|
|
13513
|
+
https://github.com/sindresorhus/strip-json-comments/blob/v4.0.0/index.js
|
|
13514
|
+
https://github.com/sindresorhus/strip-bom/blob/v5.0.0/index.js
|
|
13515
|
+
licensed under MIT, see ../LICENSE
|
|
13516
|
+
*/
|
|
13517
|
+
|
|
13518
|
+
/**
|
|
13519
|
+
* convert content of tsconfig.json to regular json
|
|
13520
|
+
*
|
|
13521
|
+
* @param {string} tsconfigJson - content of tsconfig.json
|
|
13522
|
+
* @returns {string} content as regular json, comments and dangling commas have been replaced with whitespace
|
|
13523
|
+
*/
|
|
13256
13524
|
function toJson(tsconfigJson) {
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13525
|
+
const stripped = stripDanglingComma(stripJsonComments(stripBom(tsconfigJson)));
|
|
13526
|
+
if (stripped.trim() === '') {
|
|
13527
|
+
// only whitespace left after stripping, return empty object so that JSON.parse still works
|
|
13528
|
+
return '{}';
|
|
13529
|
+
} else {
|
|
13530
|
+
return stripped;
|
|
13531
|
+
}
|
|
13263
13532
|
}
|
|
13533
|
+
|
|
13534
|
+
/**
|
|
13535
|
+
* replace dangling commas from pseudo-json string with single space
|
|
13536
|
+
* implementation heavily inspired by strip-json-comments
|
|
13537
|
+
*
|
|
13538
|
+
* @param {string} pseudoJson
|
|
13539
|
+
* @returns {string}
|
|
13540
|
+
*/
|
|
13264
13541
|
function stripDanglingComma(pseudoJson) {
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13272
|
-
|
|
13273
|
-
|
|
13274
|
-
|
|
13275
|
-
|
|
13276
|
-
|
|
13277
|
-
|
|
13278
|
-
|
|
13279
|
-
|
|
13280
|
-
|
|
13281
|
-
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13542
|
+
let insideString = false;
|
|
13543
|
+
let offset = 0;
|
|
13544
|
+
let result = '';
|
|
13545
|
+
let danglingCommaPos = null;
|
|
13546
|
+
for (let i = 0; i < pseudoJson.length; i++) {
|
|
13547
|
+
const currentCharacter = pseudoJson[i];
|
|
13548
|
+
if (currentCharacter === '"') {
|
|
13549
|
+
const escaped = isEscaped(pseudoJson, i);
|
|
13550
|
+
if (!escaped) {
|
|
13551
|
+
insideString = !insideString;
|
|
13552
|
+
}
|
|
13553
|
+
}
|
|
13554
|
+
if (insideString) {
|
|
13555
|
+
danglingCommaPos = null;
|
|
13556
|
+
continue;
|
|
13557
|
+
}
|
|
13558
|
+
if (currentCharacter === ',') {
|
|
13559
|
+
danglingCommaPos = i;
|
|
13560
|
+
continue;
|
|
13561
|
+
}
|
|
13562
|
+
if (danglingCommaPos) {
|
|
13563
|
+
if (currentCharacter === '}' || currentCharacter === ']') {
|
|
13564
|
+
result += pseudoJson.slice(offset, danglingCommaPos) + ' ';
|
|
13565
|
+
offset = danglingCommaPos + 1;
|
|
13566
|
+
danglingCommaPos = null;
|
|
13567
|
+
} else if (!currentCharacter.match(/\s/)) {
|
|
13568
|
+
danglingCommaPos = null;
|
|
13569
|
+
}
|
|
13570
|
+
}
|
|
13571
|
+
}
|
|
13572
|
+
return result + pseudoJson.substring(offset);
|
|
13296
13573
|
}
|
|
13574
|
+
|
|
13575
|
+
// start strip-json-comments
|
|
13576
|
+
/**
|
|
13577
|
+
*
|
|
13578
|
+
* @param {string} jsonString
|
|
13579
|
+
* @param {number} quotePosition
|
|
13580
|
+
* @returns {boolean}
|
|
13581
|
+
*/
|
|
13297
13582
|
function isEscaped(jsonString, quotePosition) {
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
|
|
13303
|
-
|
|
13304
|
-
|
|
13583
|
+
let index = quotePosition - 1;
|
|
13584
|
+
let backslashCount = 0;
|
|
13585
|
+
|
|
13586
|
+
while (jsonString[index] === '\\') {
|
|
13587
|
+
index -= 1;
|
|
13588
|
+
backslashCount += 1;
|
|
13589
|
+
}
|
|
13590
|
+
|
|
13591
|
+
return Boolean(backslashCount % 2);
|
|
13305
13592
|
}
|
|
13593
|
+
|
|
13594
|
+
/**
|
|
13595
|
+
*
|
|
13596
|
+
* @param {string} string
|
|
13597
|
+
* @param {number?} start
|
|
13598
|
+
* @param {number?} end
|
|
13599
|
+
*/
|
|
13306
13600
|
function strip(string, start, end) {
|
|
13307
|
-
|
|
13601
|
+
return string.slice(start, end).replace(/\S/g, ' ');
|
|
13308
13602
|
}
|
|
13309
|
-
|
|
13310
|
-
|
|
13603
|
+
|
|
13604
|
+
const singleComment = Symbol('singleComment');
|
|
13605
|
+
const multiComment = Symbol('multiComment');
|
|
13606
|
+
|
|
13607
|
+
/**
|
|
13608
|
+
* @param {string} jsonString
|
|
13609
|
+
* @returns {string}
|
|
13610
|
+
*/
|
|
13311
13611
|
function stripJsonComments(jsonString) {
|
|
13312
|
-
|
|
13313
|
-
|
|
13314
|
-
|
|
13315
|
-
|
|
13316
|
-
|
|
13317
|
-
|
|
13318
|
-
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13322
|
-
|
|
13323
|
-
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
13334
|
-
|
|
13335
|
-
|
|
13336
|
-
|
|
13337
|
-
|
|
13338
|
-
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
|
|
13344
|
-
|
|
13345
|
-
|
|
13346
|
-
|
|
13347
|
-
|
|
13348
|
-
|
|
13349
|
-
|
|
13350
|
-
|
|
13351
|
-
|
|
13352
|
-
|
|
13353
|
-
|
|
13354
|
-
|
|
13612
|
+
let isInsideString = false;
|
|
13613
|
+
/** @type {false | symbol} */
|
|
13614
|
+
let isInsideComment = false;
|
|
13615
|
+
let offset = 0;
|
|
13616
|
+
let result = '';
|
|
13617
|
+
|
|
13618
|
+
for (let index = 0; index < jsonString.length; index++) {
|
|
13619
|
+
const currentCharacter = jsonString[index];
|
|
13620
|
+
const nextCharacter = jsonString[index + 1];
|
|
13621
|
+
|
|
13622
|
+
if (!isInsideComment && currentCharacter === '"') {
|
|
13623
|
+
const escaped = isEscaped(jsonString, index);
|
|
13624
|
+
if (!escaped) {
|
|
13625
|
+
isInsideString = !isInsideString;
|
|
13626
|
+
}
|
|
13627
|
+
}
|
|
13628
|
+
|
|
13629
|
+
if (isInsideString) {
|
|
13630
|
+
continue;
|
|
13631
|
+
}
|
|
13632
|
+
|
|
13633
|
+
if (!isInsideComment && currentCharacter + nextCharacter === '//') {
|
|
13634
|
+
result += jsonString.slice(offset, index);
|
|
13635
|
+
offset = index;
|
|
13636
|
+
isInsideComment = singleComment;
|
|
13637
|
+
index++;
|
|
13638
|
+
} else if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
|
|
13639
|
+
index++;
|
|
13640
|
+
isInsideComment = false;
|
|
13641
|
+
result += strip(jsonString, offset, index);
|
|
13642
|
+
offset = index;
|
|
13643
|
+
} else if (isInsideComment === singleComment && currentCharacter === '\n') {
|
|
13644
|
+
isInsideComment = false;
|
|
13645
|
+
result += strip(jsonString, offset, index);
|
|
13646
|
+
offset = index;
|
|
13647
|
+
} else if (!isInsideComment && currentCharacter + nextCharacter === '/*') {
|
|
13648
|
+
result += jsonString.slice(offset, index);
|
|
13649
|
+
offset = index;
|
|
13650
|
+
isInsideComment = multiComment;
|
|
13651
|
+
index++;
|
|
13652
|
+
} else if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
13653
|
+
index++;
|
|
13654
|
+
isInsideComment = false;
|
|
13655
|
+
result += strip(jsonString, offset, index + 1);
|
|
13656
|
+
offset = index + 1;
|
|
13657
|
+
}
|
|
13658
|
+
}
|
|
13659
|
+
|
|
13660
|
+
return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
|
|
13355
13661
|
}
|
|
13662
|
+
// end strip-json-comments
|
|
13663
|
+
|
|
13664
|
+
// start strip-bom
|
|
13665
|
+
/**
|
|
13666
|
+
* @param {string} string
|
|
13667
|
+
* @returns {string}
|
|
13668
|
+
*/
|
|
13356
13669
|
function stripBom(string) {
|
|
13357
|
-
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
|
|
13361
|
-
}
|
|
13362
|
-
|
|
13363
|
-
var NATIVE_SEP_RE = new RegExp("\\" + require$$0$4.sep, "g");
|
|
13364
|
-
var PATTERN_REGEX_CACHE = /* @__PURE__ */ new Map();
|
|
13365
|
-
var GLOB_ALL_PATTERN = `**/*`;
|
|
13366
|
-
var DEFAULT_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts"];
|
|
13367
|
-
var DEFAULT_EXTENSIONS_RE_GROUP = `\\.(?:${DEFAULT_EXTENSIONS.map((ext) => ext.substring(1)).join(
|
|
13368
|
-
"|"
|
|
13369
|
-
)})`;
|
|
13370
|
-
new Function("path", "return import(path).then(m => m.default)");
|
|
13371
|
-
async function resolveTSConfig(filename) {
|
|
13372
|
-
if (require$$0$4.extname(filename) !== ".json") {
|
|
13373
|
-
return;
|
|
13374
|
-
}
|
|
13375
|
-
const tsconfig = require$$0$4.resolve(filename);
|
|
13376
|
-
try {
|
|
13377
|
-
const stat = await promises$1.stat(tsconfig);
|
|
13378
|
-
if (stat.isFile() || stat.isFIFO()) {
|
|
13379
|
-
return tsconfig;
|
|
13380
|
-
}
|
|
13381
|
-
} catch (e) {
|
|
13382
|
-
if (e.code !== "ENOENT") {
|
|
13383
|
-
throw e;
|
|
13384
|
-
}
|
|
13385
|
-
}
|
|
13386
|
-
throw new Error(`no tsconfig file found for ${filename}`);
|
|
13387
|
-
}
|
|
13388
|
-
function posix2native(filename) {
|
|
13389
|
-
return require$$0$4.posix.sep !== require$$0$4.sep && filename.includes(require$$0$4.posix.sep) ? filename.replace(POSIX_SEP_RE, require$$0$4.sep) : filename;
|
|
13390
|
-
}
|
|
13391
|
-
function native2posix(filename) {
|
|
13392
|
-
return require$$0$4.posix.sep !== require$$0$4.sep && filename.includes(require$$0$4.sep) ? filename.replace(NATIVE_SEP_RE, require$$0$4.posix.sep) : filename;
|
|
13393
|
-
}
|
|
13394
|
-
function resolve2posix(dir, filename) {
|
|
13395
|
-
if (require$$0$4.sep === require$$0$4.posix.sep) {
|
|
13396
|
-
return dir ? require$$0$4.resolve(dir, filename) : require$$0$4.resolve(filename);
|
|
13397
|
-
}
|
|
13398
|
-
return native2posix(
|
|
13399
|
-
dir ? require$$0$4.resolve(posix2native(dir), posix2native(filename)) : require$$0$4.resolve(posix2native(filename))
|
|
13400
|
-
);
|
|
13401
|
-
}
|
|
13402
|
-
function resolveReferencedTSConfigFiles(result) {
|
|
13403
|
-
const dir = require$$0$4.dirname(result.tsconfigFile);
|
|
13404
|
-
return result.tsconfig.references.map((ref) => {
|
|
13405
|
-
const refPath = ref.path.endsWith(".json") ? ref.path : require$$0$4.join(ref.path, "tsconfig.json");
|
|
13406
|
-
return resolve2posix(dir, refPath);
|
|
13407
|
-
});
|
|
13408
|
-
}
|
|
13409
|
-
function resolveSolutionTSConfig(filename, result) {
|
|
13410
|
-
if (result.referenced && DEFAULT_EXTENSIONS.some((ext) => filename.endsWith(ext)) && !isIncluded(filename, result)) {
|
|
13411
|
-
const solutionTSConfig = result.referenced.find(
|
|
13412
|
-
(referenced) => isIncluded(filename, referenced)
|
|
13413
|
-
);
|
|
13414
|
-
if (solutionTSConfig) {
|
|
13415
|
-
return {
|
|
13416
|
-
...solutionTSConfig,
|
|
13417
|
-
solution: result
|
|
13418
|
-
};
|
|
13419
|
-
}
|
|
13420
|
-
}
|
|
13421
|
-
return result;
|
|
13422
|
-
}
|
|
13423
|
-
function isIncluded(filename, result) {
|
|
13424
|
-
const dir = native2posix(require$$0$4.dirname(result.tsconfigFile));
|
|
13425
|
-
const files = (result.tsconfig.files || []).map((file) => resolve2posix(dir, file));
|
|
13426
|
-
const absoluteFilename = resolve2posix(null, filename);
|
|
13427
|
-
if (files.includes(filename)) {
|
|
13428
|
-
return true;
|
|
13429
|
-
}
|
|
13430
|
-
const isIncluded2 = isGlobMatch(
|
|
13431
|
-
absoluteFilename,
|
|
13432
|
-
dir,
|
|
13433
|
-
result.tsconfig.include || (result.tsconfig.files ? [] : [GLOB_ALL_PATTERN])
|
|
13434
|
-
);
|
|
13435
|
-
if (isIncluded2) {
|
|
13436
|
-
const isExcluded = isGlobMatch(absoluteFilename, dir, result.tsconfig.exclude || []);
|
|
13437
|
-
return !isExcluded;
|
|
13438
|
-
}
|
|
13439
|
-
return false;
|
|
13440
|
-
}
|
|
13441
|
-
function isGlobMatch(filename, dir, patterns) {
|
|
13442
|
-
return patterns.some((pattern) => {
|
|
13443
|
-
let lastWildcardIndex = pattern.length;
|
|
13444
|
-
let hasWildcard = false;
|
|
13445
|
-
for (let i = pattern.length - 1; i > -1; i--) {
|
|
13446
|
-
if (pattern[i] === "*" || pattern[i] === "?") {
|
|
13447
|
-
lastWildcardIndex = i;
|
|
13448
|
-
hasWildcard = true;
|
|
13449
|
-
break;
|
|
13450
|
-
}
|
|
13451
|
-
}
|
|
13452
|
-
if (lastWildcardIndex < pattern.length - 1 && !filename.endsWith(pattern.slice(lastWildcardIndex + 1))) {
|
|
13453
|
-
return false;
|
|
13454
|
-
}
|
|
13455
|
-
if (pattern.endsWith("*") && !DEFAULT_EXTENSIONS.some((ext) => filename.endsWith(ext))) {
|
|
13456
|
-
return false;
|
|
13457
|
-
}
|
|
13458
|
-
if (pattern === GLOB_ALL_PATTERN) {
|
|
13459
|
-
return filename.startsWith(`${dir}/`);
|
|
13460
|
-
}
|
|
13461
|
-
const resolvedPattern = resolve2posix(dir, pattern);
|
|
13462
|
-
let firstWildcardIndex = -1;
|
|
13463
|
-
for (let i = 0; i < resolvedPattern.length; i++) {
|
|
13464
|
-
if (resolvedPattern[i] === "*" || resolvedPattern[i] === "?") {
|
|
13465
|
-
firstWildcardIndex = i;
|
|
13466
|
-
hasWildcard = true;
|
|
13467
|
-
break;
|
|
13468
|
-
}
|
|
13469
|
-
}
|
|
13470
|
-
if (firstWildcardIndex > 1 && !filename.startsWith(resolvedPattern.slice(0, firstWildcardIndex - 1))) {
|
|
13471
|
-
return false;
|
|
13472
|
-
}
|
|
13473
|
-
if (!hasWildcard) {
|
|
13474
|
-
return filename === resolvedPattern;
|
|
13475
|
-
}
|
|
13476
|
-
if (PATTERN_REGEX_CACHE.has(resolvedPattern)) {
|
|
13477
|
-
return PATTERN_REGEX_CACHE.get(resolvedPattern).test(filename);
|
|
13478
|
-
}
|
|
13479
|
-
const regex = pattern2regex(resolvedPattern);
|
|
13480
|
-
PATTERN_REGEX_CACHE.set(resolvedPattern, regex);
|
|
13481
|
-
return regex.test(filename);
|
|
13482
|
-
});
|
|
13483
|
-
}
|
|
13484
|
-
function pattern2regex(resolvedPattern) {
|
|
13485
|
-
let regexStr = "^";
|
|
13486
|
-
for (let i = 0; i < resolvedPattern.length; i++) {
|
|
13487
|
-
const char = resolvedPattern[i];
|
|
13488
|
-
if (char === "?") {
|
|
13489
|
-
regexStr += "[^\\/]";
|
|
13490
|
-
continue;
|
|
13491
|
-
}
|
|
13492
|
-
if (char === "*") {
|
|
13493
|
-
if (resolvedPattern[i + 1] === "*" && resolvedPattern[i + 2] === "/") {
|
|
13494
|
-
i += 2;
|
|
13495
|
-
regexStr += "(?:[^\\/]*\\/)*";
|
|
13496
|
-
continue;
|
|
13497
|
-
}
|
|
13498
|
-
regexStr += "[^\\/]*";
|
|
13499
|
-
continue;
|
|
13500
|
-
}
|
|
13501
|
-
if ("/.+^${}()|[]\\".includes(char)) {
|
|
13502
|
-
regexStr += `\\`;
|
|
13503
|
-
}
|
|
13504
|
-
regexStr += char;
|
|
13505
|
-
}
|
|
13506
|
-
if (resolvedPattern.endsWith("*")) {
|
|
13507
|
-
regexStr += DEFAULT_EXTENSIONS_RE_GROUP;
|
|
13508
|
-
}
|
|
13509
|
-
regexStr += "$";
|
|
13510
|
-
return new RegExp(regexStr);
|
|
13670
|
+
// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
|
|
13671
|
+
// conversion translates it to FEFF (UTF-16 BOM).
|
|
13672
|
+
if (string.charCodeAt(0) === 0xfeff) {
|
|
13673
|
+
return string.slice(1);
|
|
13674
|
+
}
|
|
13675
|
+
return string;
|
|
13511
13676
|
}
|
|
13677
|
+
// end strip-bom
|
|
13678
|
+
|
|
13679
|
+
const not_found_result = {
|
|
13680
|
+
tsconfigFile: null,
|
|
13681
|
+
tsconfig: {}
|
|
13682
|
+
};
|
|
13512
13683
|
|
|
13513
|
-
|
|
13684
|
+
/**
|
|
13685
|
+
* parse the closest tsconfig.json file
|
|
13686
|
+
*
|
|
13687
|
+
* @param {string} filename - path to a tsconfig .json or a source file or directory (absolute or relative to cwd)
|
|
13688
|
+
* @param {import('./public.d.ts').TSConfckParseOptions} [options] - options
|
|
13689
|
+
* @returns {Promise<import('./public.d.ts').TSConfckParseResult>}
|
|
13690
|
+
* @throws {TSConfckParseError}
|
|
13691
|
+
*/
|
|
13514
13692
|
async function parse$f(filename, options) {
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
|
|
13532
|
-
|
|
13533
|
-
|
|
13534
|
-
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
|
|
13538
|
-
|
|
13539
|
-
|
|
13540
|
-
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13544
|
-
|
|
13693
|
+
/** @type {import('./cache.js').TSConfckCache} */
|
|
13694
|
+
const cache = options?.cache;
|
|
13695
|
+
if (cache?.hasParseResult(filename)) {
|
|
13696
|
+
return cache.getParseResult(filename);
|
|
13697
|
+
}
|
|
13698
|
+
const {
|
|
13699
|
+
resolve,
|
|
13700
|
+
reject,
|
|
13701
|
+
/** @type {Promise<import('./public.d.ts').TSConfckParseResult>}*/
|
|
13702
|
+
promise
|
|
13703
|
+
} = makePromise();
|
|
13704
|
+
cache?.setParseResult(filename, promise);
|
|
13705
|
+
try {
|
|
13706
|
+
let tsconfigFile =
|
|
13707
|
+
(await resolveTSConfigJson(filename, cache)) || (await find(filename, options));
|
|
13708
|
+
if (!tsconfigFile) {
|
|
13709
|
+
resolve(not_found_result);
|
|
13710
|
+
return promise;
|
|
13711
|
+
}
|
|
13712
|
+
let result;
|
|
13713
|
+
if (filename !== tsconfigFile && cache?.hasParseResult(tsconfigFile)) {
|
|
13714
|
+
result = await cache.getParseResult(tsconfigFile);
|
|
13715
|
+
} else {
|
|
13716
|
+
result = await parseFile$1(tsconfigFile, cache, filename === tsconfigFile);
|
|
13717
|
+
await Promise.all([parseExtends(result, cache), parseReferences(result, cache)]);
|
|
13718
|
+
}
|
|
13719
|
+
resolve(resolveSolutionTSConfig(filename, result));
|
|
13720
|
+
return promise;
|
|
13721
|
+
} catch (e) {
|
|
13722
|
+
reject(e);
|
|
13723
|
+
return promise;
|
|
13724
|
+
}
|
|
13545
13725
|
}
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13552
|
-
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
|
|
13556
|
-
|
|
13557
|
-
|
|
13558
|
-
|
|
13559
|
-
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13726
|
+
|
|
13727
|
+
/**
|
|
13728
|
+
*
|
|
13729
|
+
* @param {string} tsconfigFile - path to tsconfig file
|
|
13730
|
+
* @param {import('./cache.js').TSConfckCache} [cache] - cache
|
|
13731
|
+
* @param {boolean} [skipCache] - skip cache
|
|
13732
|
+
* @returns {Promise<import('./public.d.ts').TSConfckParseResult>}
|
|
13733
|
+
*/
|
|
13734
|
+
async function parseFile$1(tsconfigFile, cache, skipCache) {
|
|
13735
|
+
if (!skipCache && cache?.hasParseResult(tsconfigFile)) {
|
|
13736
|
+
return cache.getParseResult(tsconfigFile);
|
|
13737
|
+
}
|
|
13738
|
+
const promise = promises$1
|
|
13739
|
+
.readFile(tsconfigFile, 'utf-8')
|
|
13740
|
+
.then(toJson)
|
|
13741
|
+
.then((json) => {
|
|
13742
|
+
return {
|
|
13743
|
+
tsconfigFile,
|
|
13744
|
+
tsconfig: normalizeTSConfig(JSON.parse(json), path$o.dirname(tsconfigFile))
|
|
13745
|
+
};
|
|
13746
|
+
})
|
|
13747
|
+
.catch((e) => {
|
|
13748
|
+
throw new TSConfckParseError(
|
|
13749
|
+
`parsing ${tsconfigFile} failed: ${e}`,
|
|
13750
|
+
'PARSE_FILE',
|
|
13751
|
+
tsconfigFile,
|
|
13752
|
+
e
|
|
13753
|
+
);
|
|
13754
|
+
});
|
|
13755
|
+
if (!skipCache) {
|
|
13756
|
+
cache?.setParseResult(tsconfigFile, promise);
|
|
13757
|
+
}
|
|
13758
|
+
return promise;
|
|
13567
13759
|
}
|
|
13760
|
+
|
|
13761
|
+
/**
|
|
13762
|
+
* normalize to match the output of ts.parseJsonConfigFileContent
|
|
13763
|
+
*
|
|
13764
|
+
* @param {any} tsconfig - typescript tsconfig output
|
|
13765
|
+
* @param {string} dir - directory
|
|
13766
|
+
*/
|
|
13568
13767
|
function normalizeTSConfig(tsconfig, dir) {
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
|
|
13572
|
-
|
|
13573
|
-
|
|
13768
|
+
// set baseUrl to absolute path
|
|
13769
|
+
if (tsconfig.compilerOptions?.baseUrl && !path$o.isAbsolute(tsconfig.compilerOptions.baseUrl)) {
|
|
13770
|
+
tsconfig.compilerOptions.baseUrl = resolve2posix(dir, tsconfig.compilerOptions.baseUrl);
|
|
13771
|
+
}
|
|
13772
|
+
return tsconfig;
|
|
13574
13773
|
}
|
|
13774
|
+
|
|
13775
|
+
/**
|
|
13776
|
+
*
|
|
13777
|
+
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13778
|
+
* @param {import('./cache.js').TSConfckCache} [cache]
|
|
13779
|
+
* @returns {Promise<void>}
|
|
13780
|
+
*/
|
|
13575
13781
|
async function parseReferences(result, cache) {
|
|
13576
|
-
|
|
13577
|
-
|
|
13578
|
-
|
|
13579
|
-
|
|
13580
|
-
|
|
13581
|
-
|
|
13582
|
-
|
|
13782
|
+
if (!result.tsconfig.references) {
|
|
13783
|
+
return;
|
|
13784
|
+
}
|
|
13785
|
+
const referencedFiles = resolveReferencedTSConfigFiles(result);
|
|
13786
|
+
const referenced = await Promise.all(referencedFiles.map((file) => parseFile$1(file, cache)));
|
|
13787
|
+
await Promise.all(referenced.map((ref) => parseExtends(ref, cache)));
|
|
13788
|
+
referenced.forEach((ref) => {
|
|
13789
|
+
ref.solution = result;
|
|
13790
|
+
});
|
|
13791
|
+
result.referenced = referenced;
|
|
13583
13792
|
}
|
|
13793
|
+
|
|
13794
|
+
/**
|
|
13795
|
+
* @param {import('./public.d.ts').TSConfckParseResult} result
|
|
13796
|
+
* @param {import('./cache.js').TSConfckCache}[cache]
|
|
13797
|
+
* @returns {Promise<void>}
|
|
13798
|
+
*/
|
|
13584
13799
|
async function parseExtends(result, cache) {
|
|
13585
|
-
|
|
13586
|
-
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
|
|
13591
|
-
|
|
13592
|
-
|
|
13593
|
-
|
|
13594
|
-
|
|
13595
|
-
|
|
13596
|
-
|
|
13597
|
-
|
|
13598
|
-
|
|
13599
|
-
|
|
13600
|
-
|
|
13601
|
-
|
|
13602
|
-
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
|
|
13607
|
-
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
|
|
13618
|
-
|
|
13619
|
-
|
|
13620
|
-
|
|
13621
|
-
|
|
13622
|
-
|
|
13623
|
-
|
|
13624
|
-
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13800
|
+
if (!result.tsconfig.extends) {
|
|
13801
|
+
return;
|
|
13802
|
+
}
|
|
13803
|
+
// use result as first element in extended
|
|
13804
|
+
// but dereference tsconfig so that mergeExtended can modify the original without affecting extended[0]
|
|
13805
|
+
/** @type {import('./public.d.ts').TSConfckParseResult[]} */
|
|
13806
|
+
const extended = [
|
|
13807
|
+
{ tsconfigFile: result.tsconfigFile, tsconfig: JSON.parse(JSON.stringify(result.tsconfig)) }
|
|
13808
|
+
];
|
|
13809
|
+
|
|
13810
|
+
// flatten extends graph into extended
|
|
13811
|
+
let pos = 0;
|
|
13812
|
+
/** @type {string[]} */
|
|
13813
|
+
const extendsPath = [];
|
|
13814
|
+
let currentBranchDepth = 0;
|
|
13815
|
+
while (pos < extended.length) {
|
|
13816
|
+
const extending = extended[pos];
|
|
13817
|
+
extendsPath.push(extending.tsconfigFile);
|
|
13818
|
+
if (extending.tsconfig.extends) {
|
|
13819
|
+
// keep following this branch
|
|
13820
|
+
currentBranchDepth += 1;
|
|
13821
|
+
/** @type {string[]} */
|
|
13822
|
+
let resolvedExtends;
|
|
13823
|
+
if (!Array.isArray(extending.tsconfig.extends)) {
|
|
13824
|
+
resolvedExtends = [resolveExtends(extending.tsconfig.extends, extending.tsconfigFile)];
|
|
13825
|
+
} else {
|
|
13826
|
+
// reverse because typescript 5.0 treats ['a','b','c'] as c extends b extends a
|
|
13827
|
+
resolvedExtends = extending.tsconfig.extends
|
|
13828
|
+
.reverse()
|
|
13829
|
+
.map((ex) => resolveExtends(ex, extending.tsconfigFile));
|
|
13830
|
+
}
|
|
13831
|
+
|
|
13832
|
+
const circularExtends = resolvedExtends.find((tsconfigFile) =>
|
|
13833
|
+
extendsPath.includes(tsconfigFile)
|
|
13834
|
+
);
|
|
13835
|
+
if (circularExtends) {
|
|
13836
|
+
const circle = extendsPath.concat([circularExtends]).join(' -> ');
|
|
13837
|
+
throw new TSConfckParseError(
|
|
13838
|
+
`Circular dependency in "extends": ${circle}`,
|
|
13839
|
+
'EXTENDS_CIRCULAR',
|
|
13840
|
+
result.tsconfigFile
|
|
13841
|
+
);
|
|
13842
|
+
}
|
|
13843
|
+
// add new extends to the list directly after current
|
|
13844
|
+
extended.splice(
|
|
13845
|
+
pos + 1,
|
|
13846
|
+
0,
|
|
13847
|
+
...(await Promise.all(resolvedExtends.map((file) => parseFile$1(file, cache))))
|
|
13848
|
+
);
|
|
13849
|
+
} else {
|
|
13850
|
+
// reached a leaf, backtrack to the last branching point and continue
|
|
13851
|
+
extendsPath.splice(-currentBranchDepth);
|
|
13852
|
+
currentBranchDepth = 0;
|
|
13853
|
+
}
|
|
13854
|
+
pos = pos + 1;
|
|
13855
|
+
}
|
|
13856
|
+
result.extended = extended;
|
|
13857
|
+
// skip first as it is the original config
|
|
13858
|
+
for (const ext of result.extended.slice(1)) {
|
|
13859
|
+
extendTSConfig(result, ext);
|
|
13860
|
+
}
|
|
13631
13861
|
}
|
|
13862
|
+
|
|
13863
|
+
/**
|
|
13864
|
+
*
|
|
13865
|
+
* @param {string} extended
|
|
13866
|
+
* @param {string} from
|
|
13867
|
+
* @returns {string}
|
|
13868
|
+
*/
|
|
13632
13869
|
function resolveExtends(extended, from) {
|
|
13633
|
-
|
|
13634
|
-
|
|
13635
|
-
|
|
13636
|
-
|
|
13637
|
-
|
|
13638
|
-
|
|
13639
|
-
|
|
13640
|
-
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
|
|
13870
|
+
let error;
|
|
13871
|
+
|
|
13872
|
+
try {
|
|
13873
|
+
return createRequire$2(from).resolve(extended);
|
|
13874
|
+
} catch (e) {
|
|
13875
|
+
error = e;
|
|
13876
|
+
}
|
|
13877
|
+
|
|
13878
|
+
if (!path$o.isAbsolute(extended) && !extended.startsWith('./') && !extended.startsWith('../')) {
|
|
13879
|
+
try {
|
|
13880
|
+
const fallbackExtended = path$o.join(extended, 'tsconfig.json');
|
|
13881
|
+
return createRequire$2(from).resolve(fallbackExtended);
|
|
13882
|
+
} catch (e) {
|
|
13883
|
+
error = e;
|
|
13884
|
+
}
|
|
13885
|
+
}
|
|
13886
|
+
|
|
13887
|
+
throw new TSConfckParseError(
|
|
13888
|
+
`failed to resolve "extends":"${extended}" in ${from}`,
|
|
13889
|
+
'EXTENDS_RESOLVE',
|
|
13890
|
+
from,
|
|
13891
|
+
error
|
|
13892
|
+
);
|
|
13653
13893
|
}
|
|
13654
|
-
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13894
|
+
|
|
13895
|
+
// references, extends and custom keys are not carried over
|
|
13896
|
+
const EXTENDABLE_KEYS = [
|
|
13897
|
+
'compilerOptions',
|
|
13898
|
+
'files',
|
|
13899
|
+
'include',
|
|
13900
|
+
'exclude',
|
|
13901
|
+
'watchOptions',
|
|
13902
|
+
'compileOnSave',
|
|
13903
|
+
'typeAcquisition',
|
|
13904
|
+
'buildOptions'
|
|
13663
13905
|
];
|
|
13906
|
+
|
|
13907
|
+
/**
|
|
13908
|
+
*
|
|
13909
|
+
* @param {import('./public.d.ts').TSConfckParseResult} extending
|
|
13910
|
+
* @param {import('./public.d.ts').TSConfckParseResult} extended
|
|
13911
|
+
* @returns void
|
|
13912
|
+
*/
|
|
13664
13913
|
function extendTSConfig(extending, extended) {
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
}
|
|
13701
|
-
var REBASE_KEYS = [
|
|
13702
|
-
// root
|
|
13703
|
-
"files",
|
|
13704
|
-
"include",
|
|
13705
|
-
"exclude",
|
|
13706
|
-
// compilerOptions
|
|
13707
|
-
"baseUrl",
|
|
13708
|
-
"rootDir",
|
|
13709
|
-
"rootDirs",
|
|
13710
|
-
"typeRoots",
|
|
13711
|
-
"outDir",
|
|
13712
|
-
"outFile",
|
|
13713
|
-
"declarationDir",
|
|
13714
|
-
// watchOptions
|
|
13715
|
-
"excludeDirectories",
|
|
13716
|
-
"excludeFiles"
|
|
13717
|
-
];
|
|
13718
|
-
function rebaseRelative(key, value, prependPath) {
|
|
13719
|
-
if (!REBASE_KEYS.includes(key)) {
|
|
13720
|
-
return value;
|
|
13721
|
-
}
|
|
13722
|
-
if (Array.isArray(value)) {
|
|
13723
|
-
return value.map((x) => rebasePath(x, prependPath));
|
|
13724
|
-
} else {
|
|
13725
|
-
return rebasePath(value, prependPath);
|
|
13726
|
-
}
|
|
13727
|
-
}
|
|
13728
|
-
function rebasePath(value, prependPath) {
|
|
13729
|
-
if (require$$0$4.isAbsolute(value)) {
|
|
13730
|
-
return value;
|
|
13731
|
-
} else {
|
|
13732
|
-
return require$$0$4.posix.normalize(require$$0$4.posix.join(prependPath, value));
|
|
13733
|
-
}
|
|
13914
|
+
const extendingConfig = extending.tsconfig;
|
|
13915
|
+
const extendedConfig = extended.tsconfig;
|
|
13916
|
+
const relativePath = native2posix(
|
|
13917
|
+
path$o.relative(path$o.dirname(extending.tsconfigFile), path$o.dirname(extended.tsconfigFile))
|
|
13918
|
+
);
|
|
13919
|
+
for (const key of Object.keys(extendedConfig).filter((key) => EXTENDABLE_KEYS.includes(key))) {
|
|
13920
|
+
if (key === 'compilerOptions') {
|
|
13921
|
+
if (!extendingConfig.compilerOptions) {
|
|
13922
|
+
extendingConfig.compilerOptions = {};
|
|
13923
|
+
}
|
|
13924
|
+
for (const option of Object.keys(extendedConfig.compilerOptions)) {
|
|
13925
|
+
if (Object.prototype.hasOwnProperty.call(extendingConfig.compilerOptions, option)) {
|
|
13926
|
+
continue; // already set
|
|
13927
|
+
}
|
|
13928
|
+
extendingConfig.compilerOptions[option] = rebaseRelative(
|
|
13929
|
+
option,
|
|
13930
|
+
extendedConfig.compilerOptions[option],
|
|
13931
|
+
relativePath
|
|
13932
|
+
);
|
|
13933
|
+
}
|
|
13934
|
+
} else if (extendingConfig[key] === undefined) {
|
|
13935
|
+
if (key === 'watchOptions') {
|
|
13936
|
+
extendingConfig.watchOptions = {};
|
|
13937
|
+
for (const option of Object.keys(extendedConfig.watchOptions)) {
|
|
13938
|
+
extendingConfig.watchOptions[option] = rebaseRelative(
|
|
13939
|
+
option,
|
|
13940
|
+
extendedConfig.watchOptions[option],
|
|
13941
|
+
relativePath
|
|
13942
|
+
);
|
|
13943
|
+
}
|
|
13944
|
+
} else {
|
|
13945
|
+
extendingConfig[key] = rebaseRelative(key, extendedConfig[key], relativePath);
|
|
13946
|
+
}
|
|
13947
|
+
}
|
|
13948
|
+
}
|
|
13734
13949
|
}
|
|
13735
|
-
var TSConfckParseError = class _TSConfckParseError extends Error {
|
|
13736
|
-
constructor(message, code, tsconfigFile, cause) {
|
|
13737
|
-
super(message);
|
|
13738
|
-
Object.setPrototypeOf(this, _TSConfckParseError.prototype);
|
|
13739
|
-
this.name = _TSConfckParseError.name;
|
|
13740
|
-
this.code = code;
|
|
13741
|
-
this.cause = cause;
|
|
13742
|
-
this.tsconfigFile = tsconfigFile;
|
|
13743
|
-
}
|
|
13744
|
-
};
|
|
13745
13950
|
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13951
|
+
const REBASE_KEYS = [
|
|
13952
|
+
// root
|
|
13953
|
+
'files',
|
|
13954
|
+
'include',
|
|
13955
|
+
'exclude',
|
|
13956
|
+
// compilerOptions
|
|
13957
|
+
'baseUrl',
|
|
13958
|
+
'rootDir',
|
|
13959
|
+
'rootDirs',
|
|
13960
|
+
'typeRoots',
|
|
13961
|
+
'outDir',
|
|
13962
|
+
'outFile',
|
|
13963
|
+
'declarationDir',
|
|
13964
|
+
// watchOptions
|
|
13965
|
+
'excludeDirectories',
|
|
13966
|
+
'excludeFiles'
|
|
13758
13967
|
];
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
const path = join$2(root, 'package.json');
|
|
13763
|
-
if (!isFileReadable(path)) {
|
|
13764
|
-
return false;
|
|
13765
|
-
}
|
|
13766
|
-
const content = JSON.parse(fs$l.readFileSync(path, 'utf-8')) || {};
|
|
13767
|
-
return !!content.workspaces;
|
|
13768
|
-
}
|
|
13769
|
-
function hasRootFile(root) {
|
|
13770
|
-
return ROOT_FILES.some((file) => fs$l.existsSync(join$2(root, file)));
|
|
13771
|
-
}
|
|
13772
|
-
function hasPackageJSON(root) {
|
|
13773
|
-
const path = join$2(root, 'package.json');
|
|
13774
|
-
return fs$l.existsSync(path);
|
|
13775
|
-
}
|
|
13968
|
+
|
|
13969
|
+
/** @typedef {string | string[]} PathValue */
|
|
13970
|
+
|
|
13776
13971
|
/**
|
|
13777
|
-
*
|
|
13972
|
+
*
|
|
13973
|
+
* @param {string} key
|
|
13974
|
+
* @param {PathValue} value
|
|
13975
|
+
* @param {string} prependPath
|
|
13976
|
+
* @returns {PathValue}
|
|
13778
13977
|
*/
|
|
13779
|
-
function
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13978
|
+
function rebaseRelative(key, value, prependPath) {
|
|
13979
|
+
if (!REBASE_KEYS.includes(key)) {
|
|
13980
|
+
return value;
|
|
13981
|
+
}
|
|
13982
|
+
if (Array.isArray(value)) {
|
|
13983
|
+
return value.map((x) => rebasePath(x, prependPath));
|
|
13984
|
+
} else {
|
|
13985
|
+
return rebasePath(value, prependPath);
|
|
13986
|
+
}
|
|
13787
13987
|
}
|
|
13988
|
+
|
|
13788
13989
|
/**
|
|
13789
|
-
*
|
|
13990
|
+
*
|
|
13991
|
+
* @param {string} value
|
|
13992
|
+
* @param {string} prependPath
|
|
13993
|
+
* @returns {string}
|
|
13790
13994
|
*/
|
|
13791
|
-
function
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13995
|
+
function rebasePath(value, prependPath) {
|
|
13996
|
+
if (path$o.isAbsolute(value)) {
|
|
13997
|
+
return value;
|
|
13998
|
+
} else {
|
|
13999
|
+
// relative paths use posix syntax in tsconfig
|
|
14000
|
+
return path$o.posix.normalize(path$o.posix.join(prependPath, value));
|
|
14001
|
+
}
|
|
14002
|
+
}
|
|
14003
|
+
|
|
14004
|
+
class TSConfckParseError extends Error {
|
|
14005
|
+
/**
|
|
14006
|
+
* error code
|
|
14007
|
+
* @type {string}
|
|
14008
|
+
*/
|
|
14009
|
+
code;
|
|
14010
|
+
/**
|
|
14011
|
+
* error cause
|
|
14012
|
+
* @type { Error | undefined}
|
|
14013
|
+
*/
|
|
14014
|
+
cause;
|
|
14015
|
+
|
|
14016
|
+
/**
|
|
14017
|
+
* absolute path of tsconfig file where the error happened
|
|
14018
|
+
* @type {string}
|
|
14019
|
+
*/
|
|
14020
|
+
tsconfigFile;
|
|
14021
|
+
/**
|
|
14022
|
+
*
|
|
14023
|
+
* @param {string} message - error message
|
|
14024
|
+
* @param {string} code - error code
|
|
14025
|
+
* @param {string} tsconfigFile - path to tsconfig file
|
|
14026
|
+
* @param {Error?} cause - cause of this error
|
|
14027
|
+
*/
|
|
14028
|
+
constructor(message, code, tsconfigFile, cause) {
|
|
14029
|
+
super(message);
|
|
14030
|
+
// Set the prototype explicitly.
|
|
14031
|
+
Object.setPrototypeOf(this, TSConfckParseError.prototype);
|
|
14032
|
+
this.name = TSConfckParseError.name;
|
|
14033
|
+
this.code = code;
|
|
14034
|
+
this.cause = cause;
|
|
14035
|
+
this.tsconfigFile = tsconfigFile;
|
|
14036
|
+
}
|
|
14037
|
+
}
|
|
14038
|
+
|
|
14039
|
+
/** @template T */
|
|
14040
|
+
class TSConfckCache {
|
|
14041
|
+
/**
|
|
14042
|
+
* clear cache, use this if you have a long running process and tsconfig files have been added,changed or deleted
|
|
14043
|
+
*/
|
|
14044
|
+
clear() {
|
|
14045
|
+
this.#tsconfigPaths.clear();
|
|
14046
|
+
this.#parsed.clear();
|
|
14047
|
+
}
|
|
14048
|
+
|
|
14049
|
+
/**
|
|
14050
|
+
* has cached closest tsconfig for files in dir
|
|
14051
|
+
* @param {string} dir
|
|
14052
|
+
* @returns {boolean}
|
|
14053
|
+
*/
|
|
14054
|
+
hasTSConfigPath(dir) {
|
|
14055
|
+
return this.#tsconfigPaths.has(dir);
|
|
14056
|
+
}
|
|
14057
|
+
|
|
14058
|
+
/**
|
|
14059
|
+
* get cached closest tsconfig for files in dir
|
|
14060
|
+
* @param {string} dir
|
|
14061
|
+
* @returns {Promise<string|null>|string|null}
|
|
14062
|
+
* @throws {unknown} if cached value is an error
|
|
14063
|
+
*/
|
|
14064
|
+
getTSConfigPath(dir) {
|
|
14065
|
+
const value = this.#tsconfigPaths.get(dir);
|
|
14066
|
+
if (value === null || value.length || value.then) {
|
|
14067
|
+
return value;
|
|
14068
|
+
} else {
|
|
14069
|
+
throw value;
|
|
14070
|
+
}
|
|
14071
|
+
}
|
|
14072
|
+
|
|
14073
|
+
/**
|
|
14074
|
+
* has parsed tsconfig for file
|
|
14075
|
+
* @param {string} file
|
|
14076
|
+
* @returns {boolean}
|
|
14077
|
+
*/
|
|
14078
|
+
hasParseResult(file) {
|
|
14079
|
+
return this.#parsed.has(file);
|
|
14080
|
+
}
|
|
14081
|
+
|
|
14082
|
+
/**
|
|
14083
|
+
* get parsed tsconfig for file
|
|
14084
|
+
* @param {string} file
|
|
14085
|
+
* @returns {Promise<T>|T}
|
|
14086
|
+
* @throws {unknown} if cached value is an error
|
|
14087
|
+
*/
|
|
14088
|
+
getParseResult(file) {
|
|
14089
|
+
const value = this.#parsed.get(file);
|
|
14090
|
+
if (value.then || value.tsconfig) {
|
|
14091
|
+
return value;
|
|
14092
|
+
} else {
|
|
14093
|
+
throw value; // cached error, rethrow
|
|
14094
|
+
}
|
|
14095
|
+
}
|
|
14096
|
+
|
|
14097
|
+
/**
|
|
14098
|
+
* @internal
|
|
14099
|
+
* @private
|
|
14100
|
+
* @param file
|
|
14101
|
+
* @param {Promise<T>} result
|
|
14102
|
+
*/
|
|
14103
|
+
setParseResult(file, result) {
|
|
14104
|
+
this.#parsed.set(file, result);
|
|
14105
|
+
result
|
|
14106
|
+
.then((parsed) => {
|
|
14107
|
+
if (this.#parsed.get(file) === result) {
|
|
14108
|
+
this.#parsed.set(file, parsed);
|
|
14109
|
+
}
|
|
14110
|
+
})
|
|
14111
|
+
.catch((e) => {
|
|
14112
|
+
if (this.#parsed.get(file) === result) {
|
|
14113
|
+
this.#parsed.set(file, e);
|
|
14114
|
+
}
|
|
14115
|
+
});
|
|
14116
|
+
}
|
|
14117
|
+
|
|
14118
|
+
/**
|
|
14119
|
+
* @internal
|
|
14120
|
+
* @private
|
|
14121
|
+
* @param {string} dir
|
|
14122
|
+
* @param {Promise<string|null>} tsconfigPath
|
|
14123
|
+
*/
|
|
14124
|
+
setTSConfigPath(dir, tsconfigPath) {
|
|
14125
|
+
this.#tsconfigPaths.set(dir, tsconfigPath);
|
|
14126
|
+
tsconfigPath
|
|
14127
|
+
.then((path) => {
|
|
14128
|
+
if (this.#tsconfigPaths.get(dir) === tsconfigPath) {
|
|
14129
|
+
this.#tsconfigPaths.set(dir, path);
|
|
14130
|
+
}
|
|
14131
|
+
})
|
|
14132
|
+
.catch((e) => {
|
|
14133
|
+
if (this.#tsconfigPaths.get(dir) === tsconfigPath) {
|
|
14134
|
+
this.#tsconfigPaths.set(dir, e);
|
|
14135
|
+
}
|
|
14136
|
+
});
|
|
14137
|
+
}
|
|
14138
|
+
|
|
14139
|
+
/**
|
|
14140
|
+
* map directories to their closest tsconfig.json
|
|
14141
|
+
* @internal
|
|
14142
|
+
* @private
|
|
14143
|
+
* @type{Map<string,(Promise<string|null>|string|null)>}
|
|
14144
|
+
*/
|
|
14145
|
+
#tsconfigPaths = new Map();
|
|
14146
|
+
|
|
14147
|
+
/**
|
|
14148
|
+
* map files to their parsed tsconfig result
|
|
14149
|
+
* @internal
|
|
14150
|
+
* @private
|
|
14151
|
+
* @type {Map<string,(Promise<T>|T)> }
|
|
14152
|
+
*/
|
|
14153
|
+
#parsed = new Map();
|
|
13801
14154
|
}
|
|
13802
14155
|
|
|
13803
|
-
const debug$
|
|
14156
|
+
const debug$g = createDebugger('vite:esbuild');
|
|
13804
14157
|
// IIFE content looks like `var MyLib = function() {`. Spaces are removed when minified
|
|
13805
14158
|
const IIFE_BEGIN_RE = /(const|var)\s+\S+\s*=\s*function\(\)\s*\{.*"use strict";/s;
|
|
13806
14159
|
const validExtensionRE = /\.\w+$/;
|
|
@@ -13936,7 +14289,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
|
|
|
13936
14289
|
};
|
|
13937
14290
|
}
|
|
13938
14291
|
catch (e) {
|
|
13939
|
-
debug$
|
|
14292
|
+
debug$g?.(`esbuild error with options used: `, resolvedOptions);
|
|
13940
14293
|
// patch error information
|
|
13941
14294
|
if (e.errors) {
|
|
13942
14295
|
e.frame = '';
|
|
@@ -13972,7 +14325,6 @@ function esbuildPlugin(config) {
|
|
|
13972
14325
|
// tree-shaking. (#9164)
|
|
13973
14326
|
keepNames: false,
|
|
13974
14327
|
};
|
|
13975
|
-
initTSConfck(config.root);
|
|
13976
14328
|
return {
|
|
13977
14329
|
name: 'vite:esbuild',
|
|
13978
14330
|
configureServer(_server) {
|
|
@@ -14019,7 +14371,6 @@ const rollupToEsbuildFormatMap = {
|
|
|
14019
14371
|
iife: undefined,
|
|
14020
14372
|
};
|
|
14021
14373
|
const buildEsbuildPlugin = (config) => {
|
|
14022
|
-
initTSConfck(config.root);
|
|
14023
14374
|
return {
|
|
14024
14375
|
name: 'vite:esbuild-transpile',
|
|
14025
14376
|
async renderChunk(code, chunk, opts) {
|
|
@@ -14157,40 +14508,26 @@ function prettifyMessage(m, code) {
|
|
|
14157
14508
|
}
|
|
14158
14509
|
return res + `\n`;
|
|
14159
14510
|
}
|
|
14160
|
-
let
|
|
14161
|
-
let tsconfckParseOptions = { resolveWithEmptyIfConfigNotFound: true };
|
|
14162
|
-
function initTSConfck(root, force = false) {
|
|
14163
|
-
// bail if already cached
|
|
14164
|
-
if (!force && root === tsconfckRoot)
|
|
14165
|
-
return;
|
|
14166
|
-
const workspaceRoot = searchForWorkspaceRoot(root);
|
|
14167
|
-
tsconfckRoot = root;
|
|
14168
|
-
tsconfckParseOptions = initTSConfckParseOptions(workspaceRoot);
|
|
14169
|
-
// cached as the options value itself when promise is resolved
|
|
14170
|
-
tsconfckParseOptions.then((options) => {
|
|
14171
|
-
if (root === tsconfckRoot) {
|
|
14172
|
-
tsconfckParseOptions = options;
|
|
14173
|
-
}
|
|
14174
|
-
});
|
|
14175
|
-
}
|
|
14176
|
-
async function initTSConfckParseOptions(workspaceRoot) {
|
|
14177
|
-
const start = debug$f ? performance.now() : 0;
|
|
14178
|
-
const options = {
|
|
14179
|
-
cache: new Map(),
|
|
14180
|
-
root: workspaceRoot,
|
|
14181
|
-
tsConfigPaths: new Set(await findAll(workspaceRoot, {
|
|
14182
|
-
skip: (dir) => dir === 'node_modules' || dir === '.git',
|
|
14183
|
-
})),
|
|
14184
|
-
resolveWithEmptyIfConfigNotFound: true,
|
|
14185
|
-
};
|
|
14186
|
-
debug$f?.(timeFrom(start), 'tsconfck init', colors$1.dim(workspaceRoot));
|
|
14187
|
-
return options;
|
|
14188
|
-
}
|
|
14511
|
+
let tsconfckCache;
|
|
14189
14512
|
async function loadTsconfigJsonForFile(filename) {
|
|
14190
14513
|
try {
|
|
14191
|
-
|
|
14514
|
+
if (tsconfckCache) {
|
|
14515
|
+
// shortcut, the cache stores resolved TSConfckParseResult
|
|
14516
|
+
// so getting it from the cache directly we bypass aysnc fn call wrapping it in a promise again
|
|
14517
|
+
if (tsconfckCache.hasParseResult(filename)) {
|
|
14518
|
+
const result = await tsconfckCache.getParseResult(filename);
|
|
14519
|
+
return result.tsconfig;
|
|
14520
|
+
}
|
|
14521
|
+
}
|
|
14522
|
+
else {
|
|
14523
|
+
tsconfckCache = new TSConfckCache();
|
|
14524
|
+
}
|
|
14525
|
+
const result = await parse$f(filename, {
|
|
14526
|
+
cache: tsconfckCache,
|
|
14527
|
+
ignoreNodeModules: true,
|
|
14528
|
+
});
|
|
14192
14529
|
// tsconfig could be out of root, make sure it is watched on dev
|
|
14193
|
-
if (server && result.tsconfigFile
|
|
14530
|
+
if (server && result.tsconfigFile) {
|
|
14194
14531
|
ensureWatchedFile(server.watcher, result.tsconfigFile, server.config.root);
|
|
14195
14532
|
}
|
|
14196
14533
|
return result.tsconfig;
|
|
@@ -14213,12 +14550,12 @@ async function reloadOnTsconfigChange(changedFile) {
|
|
|
14213
14550
|
// any json file in the tsconfig cache could have been used to compile ts
|
|
14214
14551
|
if (path$o.basename(changedFile) === 'tsconfig.json' ||
|
|
14215
14552
|
(changedFile.endsWith('.json') &&
|
|
14216
|
-
|
|
14553
|
+
tsconfckCache?.hasParseResult(changedFile))) {
|
|
14217
14554
|
server.config.logger.info(`changed tsconfig file detected: ${changedFile} - Clearing cache and forcing full-reload to ensure TypeScript is compiled with updated config values.`, { clear: server.config.clearScreen, timestamp: true });
|
|
14218
14555
|
// clear module graph to remove code compiled with outdated config
|
|
14219
14556
|
server.moduleGraph.invalidateAll();
|
|
14220
14557
|
// reset tsconfck so that recompile works with up2date configs
|
|
14221
|
-
|
|
14558
|
+
tsconfckCache.clear();
|
|
14222
14559
|
// server may not be available if vite config is updated at the same time
|
|
14223
14560
|
if (server) {
|
|
14224
14561
|
// force full reload
|
|
@@ -16735,7 +17072,7 @@ var convertSourceMap$1 = {};
|
|
|
16735
17072
|
|
|
16736
17073
|
var convertSourceMap = /*@__PURE__*/getDefaultExportFromCjs(convertSourceMap$1);
|
|
16737
17074
|
|
|
16738
|
-
const debug$
|
|
17075
|
+
const debug$f = createDebugger('vite:sourcemap', {
|
|
16739
17076
|
onlyWhenFocused: true,
|
|
16740
17077
|
});
|
|
16741
17078
|
// Virtual modules should be prefixed with a null byte to avoid a
|
|
@@ -16774,7 +17111,7 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
16774
17111
|
// …to log the missing sources.
|
|
16775
17112
|
if (missingSources.length) {
|
|
16776
17113
|
logger.warnOnce(`Sourcemap for "${file}" points to missing source files`);
|
|
16777
|
-
debug$
|
|
17114
|
+
debug$f?.(`Missing sources:\n ` + missingSources.join(`\n `));
|
|
16778
17115
|
}
|
|
16779
17116
|
}
|
|
16780
17117
|
function genSourceMapUrl(map) {
|
|
@@ -16784,7 +17121,7 @@ function genSourceMapUrl(map) {
|
|
|
16784
17121
|
return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
|
|
16785
17122
|
}
|
|
16786
17123
|
function getCodeWithSourcemap(type, code, map) {
|
|
16787
|
-
if (debug$
|
|
17124
|
+
if (debug$f) {
|
|
16788
17125
|
code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
|
|
16789
17126
|
}
|
|
16790
17127
|
if (type === 'js') {
|
|
@@ -22503,7 +22840,7 @@ pp$8.parseForStatement = function(node) {
|
|
|
22503
22840
|
|
|
22504
22841
|
pp$8.parseFunctionStatement = function(node, isAsync, declarationPosition) {
|
|
22505
22842
|
this.next();
|
|
22506
|
-
return this.parseFunction(node, FUNC_STATEMENT | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
22843
|
+
return this.parseFunction(node, FUNC_STATEMENT$1 | (declarationPosition ? 0 : FUNC_HANGING_STATEMENT), false, isAsync)
|
|
22507
22844
|
};
|
|
22508
22845
|
|
|
22509
22846
|
pp$8.parseIfStatement = function(node) {
|
|
@@ -22773,7 +23110,7 @@ pp$8.parseVarId = function(decl, kind) {
|
|
|
22773
23110
|
this.checkLValPattern(decl.id, kind === "var" ? BIND_VAR : BIND_LEXICAL, false);
|
|
22774
23111
|
};
|
|
22775
23112
|
|
|
22776
|
-
var FUNC_STATEMENT = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID = 4;
|
|
23113
|
+
var FUNC_STATEMENT$1 = 1, FUNC_HANGING_STATEMENT = 2, FUNC_NULLABLE_ID$1 = 4;
|
|
22777
23114
|
|
|
22778
23115
|
// Parse a function declaration or literal (depending on the
|
|
22779
23116
|
// `statement & FUNC_STATEMENT`).
|
|
@@ -22789,8 +23126,8 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
22789
23126
|
if (this.options.ecmaVersion >= 8)
|
|
22790
23127
|
{ node.async = !!isAsync; }
|
|
22791
23128
|
|
|
22792
|
-
if (statement & FUNC_STATEMENT) {
|
|
22793
|
-
node.id = (statement & FUNC_NULLABLE_ID) && this.type !== types$1.name ? null : this.parseIdent();
|
|
23129
|
+
if (statement & FUNC_STATEMENT$1) {
|
|
23130
|
+
node.id = (statement & FUNC_NULLABLE_ID$1) && this.type !== types$1.name ? null : this.parseIdent();
|
|
22794
23131
|
if (node.id && !(statement & FUNC_HANGING_STATEMENT))
|
|
22795
23132
|
// If it is a regular function declaration in sloppy mode, then it is
|
|
22796
23133
|
// subject to Annex B semantics (BIND_FUNCTION). Otherwise, the binding
|
|
@@ -22805,7 +23142,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
22805
23142
|
this.awaitIdentPos = 0;
|
|
22806
23143
|
this.enterScope(functionFlags(node.async, node.generator));
|
|
22807
23144
|
|
|
22808
|
-
if (!(statement & FUNC_STATEMENT))
|
|
23145
|
+
if (!(statement & FUNC_STATEMENT$1))
|
|
22809
23146
|
{ node.id = this.type === types$1.name ? this.parseIdent() : null; }
|
|
22810
23147
|
|
|
22811
23148
|
this.parseFunctionParams(node);
|
|
@@ -22814,7 +23151,7 @@ pp$8.parseFunction = function(node, statement, allowExpressionBody, isAsync, for
|
|
|
22814
23151
|
this.yieldPos = oldYieldPos;
|
|
22815
23152
|
this.awaitPos = oldAwaitPos;
|
|
22816
23153
|
this.awaitIdentPos = oldAwaitIdentPos;
|
|
22817
|
-
return this.finishNode(node, (statement & FUNC_STATEMENT) ? "FunctionDeclaration" : "FunctionExpression")
|
|
23154
|
+
return this.finishNode(node, (statement & FUNC_STATEMENT$1) ? "FunctionDeclaration" : "FunctionExpression")
|
|
22818
23155
|
};
|
|
22819
23156
|
|
|
22820
23157
|
pp$8.parseFunctionParams = function(node) {
|
|
@@ -23169,7 +23506,7 @@ pp$8.parseExportDefaultDeclaration = function() {
|
|
|
23169
23506
|
var fNode = this.startNode();
|
|
23170
23507
|
this.next();
|
|
23171
23508
|
if (isAsync) { this.next(); }
|
|
23172
|
-
return this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync)
|
|
23509
|
+
return this.parseFunction(fNode, FUNC_STATEMENT$1 | FUNC_NULLABLE_ID$1, false, isAsync)
|
|
23173
23510
|
} else if (this.type === types$1._class) {
|
|
23174
23511
|
var cNode = this.startNode();
|
|
23175
23512
|
return this.parseClass(cNode, "nullableID")
|
|
@@ -28037,7 +28374,7 @@ const browserExternalId = '__vite-browser-external';
|
|
|
28037
28374
|
const optionalPeerDepId = '__vite-optional-peer-dep';
|
|
28038
28375
|
const subpathImportsPrefix = '#';
|
|
28039
28376
|
const startsWithWordCharRE = /^\w/;
|
|
28040
|
-
const debug$
|
|
28377
|
+
const debug$e = createDebugger('vite:resolve-details', {
|
|
28041
28378
|
onlyWhenFocused: true,
|
|
28042
28379
|
});
|
|
28043
28380
|
function resolvePlugin(resolveOptions) {
|
|
@@ -28106,7 +28443,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
28106
28443
|
// We don't need to resolve these paths since they are already resolved
|
|
28107
28444
|
// always return here even if res doesn't exist since /@fs/ is explicit
|
|
28108
28445
|
// if the file doesn't exist it should be a 404.
|
|
28109
|
-
debug$
|
|
28446
|
+
debug$e?.(`[@fs] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
28110
28447
|
return ensureVersionQuery(res, id, options, depsOptimizer);
|
|
28111
28448
|
}
|
|
28112
28449
|
// URL
|
|
@@ -28116,7 +28453,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
28116
28453
|
(rootInRoot || !id.startsWith(withTrailingSlash(root)))) {
|
|
28117
28454
|
const fsPath = path$o.resolve(root, id.slice(1));
|
|
28118
28455
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
28119
|
-
debug$
|
|
28456
|
+
debug$e?.(`[url] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
28120
28457
|
return ensureVersionQuery(res, id, options, depsOptimizer);
|
|
28121
28458
|
}
|
|
28122
28459
|
}
|
|
@@ -28147,7 +28484,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
28147
28484
|
}
|
|
28148
28485
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
28149
28486
|
res = ensureVersionQuery(res, id, options, depsOptimizer);
|
|
28150
|
-
debug$
|
|
28487
|
+
debug$e?.(`[relative] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
28151
28488
|
// If this isn't a script imported from a .html file, include side effects
|
|
28152
28489
|
// hints so the non-used code is properly tree-shaken during build time.
|
|
28153
28490
|
if (!options.idOnly &&
|
|
@@ -28170,14 +28507,14 @@ function resolvePlugin(resolveOptions) {
|
|
|
28170
28507
|
const basedir = importer ? path$o.dirname(importer) : process.cwd();
|
|
28171
28508
|
const fsPath = path$o.resolve(basedir, id);
|
|
28172
28509
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
28173
|
-
debug$
|
|
28510
|
+
debug$e?.(`[drive-relative] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
28174
28511
|
return ensureVersionQuery(res, id, options, depsOptimizer);
|
|
28175
28512
|
}
|
|
28176
28513
|
}
|
|
28177
28514
|
// absolute fs paths
|
|
28178
28515
|
if (isNonDriveRelativeAbsolutePath(id) &&
|
|
28179
28516
|
(res = tryFsResolve(id, options))) {
|
|
28180
|
-
debug$
|
|
28517
|
+
debug$e?.(`[fs] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
28181
28518
|
return ensureVersionQuery(res, id, options, depsOptimizer);
|
|
28182
28519
|
}
|
|
28183
28520
|
// external
|
|
@@ -28223,7 +28560,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
28223
28560
|
}
|
|
28224
28561
|
else {
|
|
28225
28562
|
if (!asSrc) {
|
|
28226
|
-
debug$
|
|
28563
|
+
debug$e?.(`externalized node built-in "${id}" to empty module. ` +
|
|
28227
28564
|
`(imported by: ${colors$1.white(colors$1.dim(importer))})`);
|
|
28228
28565
|
}
|
|
28229
28566
|
else if (isProduction) {
|
|
@@ -28236,7 +28573,7 @@ function resolvePlugin(resolveOptions) {
|
|
|
28236
28573
|
}
|
|
28237
28574
|
}
|
|
28238
28575
|
}
|
|
28239
|
-
debug$
|
|
28576
|
+
debug$e?.(`[fallthrough] ${colors$1.dim(id)}`);
|
|
28240
28577
|
},
|
|
28241
28578
|
load(id) {
|
|
28242
28579
|
if (id.startsWith(browserExternalId)) {
|
|
@@ -28290,7 +28627,7 @@ function ensureVersionQuery(resolved, id, options, depsOptimizer) {
|
|
|
28290
28627
|
// as if they would have been imported through a bare import
|
|
28291
28628
|
// Use the original id to do the check as the resolved id may be the real
|
|
28292
28629
|
// file path after symlinks resolution
|
|
28293
|
-
const isNodeModule = isInNodeModules(id) || isInNodeModules(resolved);
|
|
28630
|
+
const isNodeModule = isInNodeModules$1(id) || isInNodeModules$1(resolved);
|
|
28294
28631
|
if (isNodeModule && !resolved.match(DEP_VERSION_RE)) {
|
|
28295
28632
|
const versionHash = depsOptimizer.metadata.browserHash;
|
|
28296
28633
|
if (versionHash && isOptimizable(resolved, depsOptimizer.options)) {
|
|
@@ -28309,7 +28646,7 @@ function tryFsResolve(fsPath, options, tryIndex = true, targetWeb = true, skipPa
|
|
|
28309
28646
|
// source code so we only need to perform the check for dependencies.
|
|
28310
28647
|
// We don't support `?` in node_modules paths, so we only need to check in this branch.
|
|
28311
28648
|
const hashIndex = fsPath.indexOf('#');
|
|
28312
|
-
if (hashIndex >= 0 && isInNodeModules(fsPath)) {
|
|
28649
|
+
if (hashIndex >= 0 && isInNodeModules$1(fsPath)) {
|
|
28313
28650
|
const queryIndex = fsPath.indexOf('?');
|
|
28314
28651
|
// We only need to check foo#bar?baz and foo#bar, ignore foo?bar#baz
|
|
28315
28652
|
if (queryIndex < 0 || queryIndex > hashIndex) {
|
|
@@ -28405,7 +28742,9 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28405
28742
|
const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
|
|
28406
28743
|
// check for deep import, e.g. "my-lib/foo"
|
|
28407
28744
|
const deepMatch = id.match(deepImportRE);
|
|
28408
|
-
|
|
28745
|
+
// package name doesn't include postfixes
|
|
28746
|
+
// trim them to support importing package with queries (e.g. `import css from 'normalize.css?inline'`)
|
|
28747
|
+
const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : cleanUrl(id);
|
|
28409
28748
|
let basedir;
|
|
28410
28749
|
if (dedupe?.includes(pkgId)) {
|
|
28411
28750
|
basedir = root;
|
|
@@ -28440,7 +28779,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28440
28779
|
return;
|
|
28441
28780
|
}
|
|
28442
28781
|
const resolveId = deepMatch ? resolveDeepImport : resolvePackageEntry;
|
|
28443
|
-
const unresolvedId = deepMatch ? '.' + id.slice(pkgId.length) :
|
|
28782
|
+
const unresolvedId = deepMatch ? '.' + id.slice(pkgId.length) : id;
|
|
28444
28783
|
let resolved;
|
|
28445
28784
|
try {
|
|
28446
28785
|
resolved = resolveId(unresolvedId, pkg, targetWeb, options);
|
|
@@ -28466,7 +28805,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28466
28805
|
return resolved;
|
|
28467
28806
|
}
|
|
28468
28807
|
// don't external symlink packages
|
|
28469
|
-
if (!allowLinkedExternal && !isInNodeModules(resolved.id)) {
|
|
28808
|
+
if (!allowLinkedExternal && !isInNodeModules$1(resolved.id)) {
|
|
28470
28809
|
return resolved;
|
|
28471
28810
|
}
|
|
28472
28811
|
const resolvedExt = path$o.extname(resolved.id);
|
|
@@ -28484,7 +28823,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28484
28823
|
const index = resolved.id.indexOf(id);
|
|
28485
28824
|
if (index > -1) {
|
|
28486
28825
|
resolvedId = resolved.id.slice(index);
|
|
28487
|
-
debug$
|
|
28826
|
+
debug$e?.(`[processResult] ${colors$1.cyan(id)} -> ${colors$1.dim(resolvedId)}`);
|
|
28488
28827
|
}
|
|
28489
28828
|
}
|
|
28490
28829
|
return { ...resolved, id: resolvedId, external: true };
|
|
@@ -28500,7 +28839,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28500
28839
|
}
|
|
28501
28840
|
const ext = path$o.extname(resolved);
|
|
28502
28841
|
if (!options.ssrOptimizeCheck &&
|
|
28503
|
-
(!isInNodeModules(resolved) || // linked
|
|
28842
|
+
(!isInNodeModules$1(resolved) || // linked
|
|
28504
28843
|
!depsOptimizer || // resolving before listening to the server
|
|
28505
28844
|
options.scan) // initial esbuild scan phase
|
|
28506
28845
|
) {
|
|
@@ -28519,7 +28858,7 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
28519
28858
|
}
|
|
28520
28859
|
const skipOptimization = depsOptimizer?.options.noDiscovery ||
|
|
28521
28860
|
!isJsType ||
|
|
28522
|
-
(importer && isInNodeModules(importer)) ||
|
|
28861
|
+
(importer && isInNodeModules$1(importer)) ||
|
|
28523
28862
|
exclude?.includes(pkgId) ||
|
|
28524
28863
|
exclude?.includes(id) ||
|
|
28525
28864
|
SPECIAL_QUERY_RE.test(resolved) ||
|
|
@@ -28613,9 +28952,10 @@ async function tryOptimizedResolve(depsOptimizer, id, importer, preserveSymlinks
|
|
|
28613
28952
|
}
|
|
28614
28953
|
}
|
|
28615
28954
|
function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache }, targetWeb, options) {
|
|
28955
|
+
const { file: idWithoutPostfix, postfix } = splitFileAndPostfix(id);
|
|
28616
28956
|
const cached = getResolvedCache('.', targetWeb);
|
|
28617
28957
|
if (cached) {
|
|
28618
|
-
return cached;
|
|
28958
|
+
return cached + postfix;
|
|
28619
28959
|
}
|
|
28620
28960
|
try {
|
|
28621
28961
|
let entryPoint;
|
|
@@ -28703,9 +29043,9 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
28703
29043
|
const entryPointPath = path$o.join(dir, entry);
|
|
28704
29044
|
const resolvedEntryPoint = tryFsResolve(entryPointPath, options, true, true, skipPackageJson);
|
|
28705
29045
|
if (resolvedEntryPoint) {
|
|
28706
|
-
debug$
|
|
29046
|
+
debug$e?.(`[package entry] ${colors$1.cyan(idWithoutPostfix)} -> ${colors$1.dim(resolvedEntryPoint)}${postfix !== '' ? ` (postfix: ${postfix})` : ''}`);
|
|
28707
29047
|
setResolvedCache('.', resolvedEntryPoint, targetWeb);
|
|
28708
|
-
return resolvedEntryPoint;
|
|
29048
|
+
return resolvedEntryPoint + postfix;
|
|
28709
29049
|
}
|
|
28710
29050
|
}
|
|
28711
29051
|
}
|
|
@@ -28787,7 +29127,7 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
28787
29127
|
const resolved = tryFsResolve(path$o.join(dir, relativeId), options, !exportsField, // try index only if no exports field
|
|
28788
29128
|
targetWeb);
|
|
28789
29129
|
if (resolved) {
|
|
28790
|
-
debug$
|
|
29130
|
+
debug$e?.(`[node/deep-import] ${colors$1.cyan(id)} -> ${colors$1.dim(resolved)}`);
|
|
28791
29131
|
setResolvedCache(id, resolved, targetWeb);
|
|
28792
29132
|
return resolved;
|
|
28793
29133
|
}
|
|
@@ -28804,7 +29144,7 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath, externalize
|
|
|
28804
29144
|
if ((res = bareImportRE.test(browserMappedPath)
|
|
28805
29145
|
? tryNodeResolve(browserMappedPath, importer, options, true)?.id
|
|
28806
29146
|
: tryFsResolve(path$o.join(pkg.dir, browserMappedPath), options))) {
|
|
28807
|
-
debug$
|
|
29147
|
+
debug$e?.(`[browser mapped] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
28808
29148
|
let result = { id: res };
|
|
28809
29149
|
if (options.idOnly) {
|
|
28810
29150
|
return result;
|
|
@@ -37284,7 +37624,7 @@ function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
|
|
|
37284
37624
|
}
|
|
37285
37625
|
|
|
37286
37626
|
const modulePreloadPolyfillId = 'vite/modulepreload-polyfill';
|
|
37287
|
-
const resolvedModulePreloadPolyfillId = '\0' + modulePreloadPolyfillId;
|
|
37627
|
+
const resolvedModulePreloadPolyfillId = '\0' + modulePreloadPolyfillId + '.js';
|
|
37288
37628
|
function modulePreloadPolyfillPlugin(config) {
|
|
37289
37629
|
// `isModernFlag` is only available during build since it is resolved by `vite:build-import-analysis`
|
|
37290
37630
|
const skip = config.command !== 'build' || config.build.ssr;
|
|
@@ -38219,7 +38559,6 @@ const commonjsProxyRE = /\?commonjs-proxy/;
|
|
|
38219
38559
|
const inlineRE = /[?&]inline\b/;
|
|
38220
38560
|
const inlineCSSRE = /[?&]inline-css\b/;
|
|
38221
38561
|
const styleAttrRE = /[?&]style-attr\b/;
|
|
38222
|
-
const usedRE = /[?&]used\b/;
|
|
38223
38562
|
const varRE = /^var\(/i;
|
|
38224
38563
|
const cssBundleName = 'style.css';
|
|
38225
38564
|
const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
|
|
@@ -38422,8 +38761,7 @@ function cssPostPlugin(config) {
|
|
|
38422
38761
|
`const __vite__css = ${JSON.stringify(cssContent)}`,
|
|
38423
38762
|
`__vite__updateStyle(__vite__id, __vite__css)`,
|
|
38424
38763
|
// css modules exports change on edit so it can't self accept
|
|
38425
|
-
`${modulesCode ||
|
|
38426
|
-
`import.meta.hot.accept()\nexport default __vite__css`}`,
|
|
38764
|
+
`${modulesCode || 'import.meta.hot.accept()'}`,
|
|
38427
38765
|
`import.meta.hot.prune(() => __vite__removeStyle(__vite__id))`,
|
|
38428
38766
|
].join('\n');
|
|
38429
38767
|
return { code, map: { mappings: '' } };
|
|
@@ -38446,24 +38784,19 @@ function cssPostPlugin(config) {
|
|
|
38446
38784
|
styles.set(id, css);
|
|
38447
38785
|
}
|
|
38448
38786
|
let code;
|
|
38449
|
-
if (
|
|
38450
|
-
|
|
38451
|
-
|
|
38452
|
-
|
|
38453
|
-
|
|
38454
|
-
|
|
38455
|
-
|
|
38456
|
-
content = await minifyCSS(content, config, true);
|
|
38457
|
-
}
|
|
38458
|
-
code = `export default ${JSON.stringify(content)}`;
|
|
38787
|
+
if (modulesCode) {
|
|
38788
|
+
code = modulesCode;
|
|
38789
|
+
}
|
|
38790
|
+
else if (inlined) {
|
|
38791
|
+
let content = css;
|
|
38792
|
+
if (config.build.cssMinify) {
|
|
38793
|
+
content = await minifyCSS(content, config, true);
|
|
38459
38794
|
}
|
|
38795
|
+
code = `export default ${JSON.stringify(content)}`;
|
|
38460
38796
|
}
|
|
38461
38797
|
else {
|
|
38462
|
-
//
|
|
38463
|
-
|
|
38464
|
-
// this is a limitation of the current approach by `?used` to make tree-shake work
|
|
38465
|
-
// See #8936 for more details
|
|
38466
|
-
code = modulesCode || `export default ''`;
|
|
38798
|
+
// empty module when it's not a CSS module nor `?inline`
|
|
38799
|
+
code = '';
|
|
38467
38800
|
}
|
|
38468
38801
|
return {
|
|
38469
38802
|
code,
|
|
@@ -38653,9 +38986,9 @@ function cssPostPlugin(config) {
|
|
|
38653
38986
|
// chunks instead.
|
|
38654
38987
|
chunk.imports = chunk.imports.filter((file) => {
|
|
38655
38988
|
if (pureCssChunkNames.includes(file)) {
|
|
38656
|
-
const { importedCss } = bundle[file]
|
|
38657
|
-
.viteMetadata;
|
|
38989
|
+
const { importedCss, importedAssets } = bundle[file].viteMetadata;
|
|
38658
38990
|
importedCss.forEach((file) => chunk.viteMetadata.importedCss.add(file));
|
|
38991
|
+
importedAssets.forEach((file) => chunk.viteMetadata.importedAssets.add(file));
|
|
38659
38992
|
return false;
|
|
38660
38993
|
}
|
|
38661
38994
|
return true;
|
|
@@ -38980,8 +39313,8 @@ function createCachedImport(imp) {
|
|
|
38980
39313
|
return cached;
|
|
38981
39314
|
};
|
|
38982
39315
|
}
|
|
38983
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
|
38984
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
39316
|
+
const importPostcssImport = createCachedImport(() => import('./dep-13ae786e.js').then(function (n) { return n.i; }));
|
|
39317
|
+
const importPostcssModules = createCachedImport(() => import('./dep-5c5f3875.js').then(function (n) { return n.i; }));
|
|
38985
39318
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38986
39319
|
/**
|
|
38987
39320
|
* @experimental
|
|
@@ -40061,7 +40394,248 @@ function esbuildCjsExternalPlugin(externals, platform) {
|
|
|
40061
40394
|
};
|
|
40062
40395
|
}
|
|
40063
40396
|
|
|
40064
|
-
const
|
|
40397
|
+
const leftCurlyBrace = "{".charCodeAt(0);
|
|
40398
|
+
const space = " ".charCodeAt(0);
|
|
40399
|
+
|
|
40400
|
+
const keyword = "assert";
|
|
40401
|
+
const FUNC_STATEMENT = 1, FUNC_NULLABLE_ID = 4;
|
|
40402
|
+
|
|
40403
|
+
function importAssertions(Parser) {
|
|
40404
|
+
// Use supplied version acorn version if present, to avoid
|
|
40405
|
+
// reference mismatches due to different acorn versions. This
|
|
40406
|
+
// allows this plugin to be used with Rollup which supplies
|
|
40407
|
+
// its own internal version of acorn and thereby sidesteps
|
|
40408
|
+
// the package manager.
|
|
40409
|
+
const acorn$1 = Parser.acorn || acorn;
|
|
40410
|
+
const { tokTypes: tt, TokenType } = acorn$1;
|
|
40411
|
+
|
|
40412
|
+
return class extends Parser {
|
|
40413
|
+
constructor(...args) {
|
|
40414
|
+
super(...args);
|
|
40415
|
+
this.assertToken = new TokenType(keyword);
|
|
40416
|
+
}
|
|
40417
|
+
|
|
40418
|
+
_codeAt(i) {
|
|
40419
|
+
return this.input.charCodeAt(i);
|
|
40420
|
+
}
|
|
40421
|
+
|
|
40422
|
+
_eat(t) {
|
|
40423
|
+
if (this.type !== t) {
|
|
40424
|
+
this.unexpected();
|
|
40425
|
+
}
|
|
40426
|
+
this.next();
|
|
40427
|
+
}
|
|
40428
|
+
|
|
40429
|
+
readToken(code) {
|
|
40430
|
+
let i = 0;
|
|
40431
|
+
for (; i < keyword.length; i++) {
|
|
40432
|
+
if (this._codeAt(this.pos + i) !== keyword.charCodeAt(i)) {
|
|
40433
|
+
return super.readToken(code);
|
|
40434
|
+
}
|
|
40435
|
+
}
|
|
40436
|
+
|
|
40437
|
+
// ensure that the keyword is at the correct location
|
|
40438
|
+
// ie `assert{...` or `assert {...`
|
|
40439
|
+
for (;; i++) {
|
|
40440
|
+
if (this._codeAt(this.pos + i) === leftCurlyBrace) {
|
|
40441
|
+
// Found '{'
|
|
40442
|
+
break;
|
|
40443
|
+
} else if (this._codeAt(this.pos + i) === space) {
|
|
40444
|
+
// white space is allowed between `assert` and `{`, so continue.
|
|
40445
|
+
continue;
|
|
40446
|
+
} else {
|
|
40447
|
+
return super.readToken(code);
|
|
40448
|
+
}
|
|
40449
|
+
}
|
|
40450
|
+
|
|
40451
|
+
// If we're inside a dynamic import expression we'll parse
|
|
40452
|
+
// the `assert` keyword as a standard object property name
|
|
40453
|
+
// ie `import(""./foo.json", { assert: { type: "json" } })`
|
|
40454
|
+
if (this.type.label === "{") {
|
|
40455
|
+
return super.readToken(code);
|
|
40456
|
+
}
|
|
40457
|
+
|
|
40458
|
+
this.pos += keyword.length;
|
|
40459
|
+
return this.finishToken(this.assertToken);
|
|
40460
|
+
}
|
|
40461
|
+
|
|
40462
|
+
parseDynamicImport(node) {
|
|
40463
|
+
this.next(); // skip `(`
|
|
40464
|
+
|
|
40465
|
+
// Parse node.source.
|
|
40466
|
+
node.source = this.parseMaybeAssign();
|
|
40467
|
+
|
|
40468
|
+
if (this.eat(tt.comma)) {
|
|
40469
|
+
const obj = this.parseObj(false);
|
|
40470
|
+
node.arguments = [obj];
|
|
40471
|
+
}
|
|
40472
|
+
this._eat(tt.parenR);
|
|
40473
|
+
return this.finishNode(node, "ImportExpression");
|
|
40474
|
+
}
|
|
40475
|
+
|
|
40476
|
+
// ported from acorn/src/statement.js pp.parseExport
|
|
40477
|
+
parseExport(node, exports) {
|
|
40478
|
+
this.next();
|
|
40479
|
+
// export * from '...'
|
|
40480
|
+
if (this.eat(tt.star)) {
|
|
40481
|
+
if (this.options.ecmaVersion >= 11) {
|
|
40482
|
+
if (this.eatContextual("as")) {
|
|
40483
|
+
node.exported = this.parseIdent(true);
|
|
40484
|
+
this.checkExport(exports, node.exported.name, this.lastTokStart);
|
|
40485
|
+
} else {
|
|
40486
|
+
node.exported = null;
|
|
40487
|
+
}
|
|
40488
|
+
}
|
|
40489
|
+
this.expectContextual("from");
|
|
40490
|
+
if (this.type !== tt.string) { this.unexpected(); }
|
|
40491
|
+
node.source = this.parseExprAtom();
|
|
40492
|
+
|
|
40493
|
+
if (this.type === this.assertToken || this.type === tt._with) {
|
|
40494
|
+
this.next();
|
|
40495
|
+
const assertions = this.parseImportAssertions();
|
|
40496
|
+
if (assertions) {
|
|
40497
|
+
node.assertions = assertions;
|
|
40498
|
+
}
|
|
40499
|
+
}
|
|
40500
|
+
|
|
40501
|
+
this.semicolon();
|
|
40502
|
+
return this.finishNode(node, "ExportAllDeclaration")
|
|
40503
|
+
}
|
|
40504
|
+
if (this.eat(tt._default)) { // export default ...
|
|
40505
|
+
this.checkExport(exports, "default", this.lastTokStart);
|
|
40506
|
+
var isAsync;
|
|
40507
|
+
if (this.type === tt._function || (isAsync = this.isAsyncFunction())) {
|
|
40508
|
+
var fNode = this.startNode();
|
|
40509
|
+
this.next();
|
|
40510
|
+
if (isAsync) { this.next(); }
|
|
40511
|
+
node.declaration = this.parseFunction(fNode, FUNC_STATEMENT | FUNC_NULLABLE_ID, false, isAsync);
|
|
40512
|
+
} else if (this.type === tt._class) {
|
|
40513
|
+
var cNode = this.startNode();
|
|
40514
|
+
node.declaration = this.parseClass(cNode, "nullableID");
|
|
40515
|
+
} else {
|
|
40516
|
+
node.declaration = this.parseMaybeAssign();
|
|
40517
|
+
this.semicolon();
|
|
40518
|
+
}
|
|
40519
|
+
return this.finishNode(node, "ExportDefaultDeclaration")
|
|
40520
|
+
}
|
|
40521
|
+
// export var|const|let|function|class ...
|
|
40522
|
+
if (this.shouldParseExportStatement()) {
|
|
40523
|
+
node.declaration = this.parseStatement(null);
|
|
40524
|
+
if (node.declaration.type === "VariableDeclaration")
|
|
40525
|
+
{ this.checkVariableExport(exports, node.declaration.declarations); }
|
|
40526
|
+
else
|
|
40527
|
+
{ this.checkExport(exports, node.declaration.id.name, node.declaration.id.start); }
|
|
40528
|
+
node.specifiers = [];
|
|
40529
|
+
node.source = null;
|
|
40530
|
+
} else { // export { x, y as z } [from '...']
|
|
40531
|
+
node.declaration = null;
|
|
40532
|
+
node.specifiers = this.parseExportSpecifiers(exports);
|
|
40533
|
+
if (this.eatContextual("from")) {
|
|
40534
|
+
if (this.type !== tt.string) { this.unexpected(); }
|
|
40535
|
+
node.source = this.parseExprAtom();
|
|
40536
|
+
|
|
40537
|
+
if (this.type === this.assertToken || this.type === tt._with) {
|
|
40538
|
+
this.next();
|
|
40539
|
+
const assertions = this.parseImportAssertions();
|
|
40540
|
+
if (assertions) {
|
|
40541
|
+
node.assertions = assertions;
|
|
40542
|
+
}
|
|
40543
|
+
}
|
|
40544
|
+
} else {
|
|
40545
|
+
for (var i = 0, list = node.specifiers; i < list.length; i += 1) {
|
|
40546
|
+
// check for keywords used as local names
|
|
40547
|
+
var spec = list[i];
|
|
40548
|
+
|
|
40549
|
+
this.checkUnreserved(spec.local);
|
|
40550
|
+
// check if export is defined
|
|
40551
|
+
this.checkLocalExport(spec.local);
|
|
40552
|
+
}
|
|
40553
|
+
|
|
40554
|
+
node.source = null;
|
|
40555
|
+
}
|
|
40556
|
+
this.semicolon();
|
|
40557
|
+
}
|
|
40558
|
+
return this.finishNode(node, "ExportNamedDeclaration")
|
|
40559
|
+
}
|
|
40560
|
+
|
|
40561
|
+
parseImport(node) {
|
|
40562
|
+
this.next();
|
|
40563
|
+
// import '...'
|
|
40564
|
+
if (this.type === tt.string) {
|
|
40565
|
+
node.specifiers = [];
|
|
40566
|
+
node.source = this.parseExprAtom();
|
|
40567
|
+
} else {
|
|
40568
|
+
node.specifiers = this.parseImportSpecifiers();
|
|
40569
|
+
this.expectContextual("from");
|
|
40570
|
+
node.source =
|
|
40571
|
+
this.type === tt.string ? this.parseExprAtom() : this.unexpected();
|
|
40572
|
+
}
|
|
40573
|
+
|
|
40574
|
+
if (this.type === this.assertToken || this.type == tt._with) {
|
|
40575
|
+
this.next();
|
|
40576
|
+
const assertions = this.parseImportAssertions();
|
|
40577
|
+
if (assertions) {
|
|
40578
|
+
node.assertions = assertions;
|
|
40579
|
+
}
|
|
40580
|
+
}
|
|
40581
|
+
this.semicolon();
|
|
40582
|
+
return this.finishNode(node, "ImportDeclaration");
|
|
40583
|
+
}
|
|
40584
|
+
|
|
40585
|
+
parseImportAssertions() {
|
|
40586
|
+
this._eat(tt.braceL);
|
|
40587
|
+
const attrs = this.parseAssertEntries();
|
|
40588
|
+
this._eat(tt.braceR);
|
|
40589
|
+
return attrs;
|
|
40590
|
+
}
|
|
40591
|
+
|
|
40592
|
+
parseAssertEntries() {
|
|
40593
|
+
const attrs = [];
|
|
40594
|
+
const attrNames = new Set();
|
|
40595
|
+
|
|
40596
|
+
do {
|
|
40597
|
+
if (this.type === tt.braceR) {
|
|
40598
|
+
break;
|
|
40599
|
+
}
|
|
40600
|
+
|
|
40601
|
+
const node = this.startNode();
|
|
40602
|
+
|
|
40603
|
+
// parse AssertionKey : IdentifierName, StringLiteral
|
|
40604
|
+
let assertionKeyNode;
|
|
40605
|
+
if (this.type === tt.string) {
|
|
40606
|
+
assertionKeyNode = this.parseLiteral(this.value);
|
|
40607
|
+
} else {
|
|
40608
|
+
assertionKeyNode = this.parseIdent(true);
|
|
40609
|
+
}
|
|
40610
|
+
this.next();
|
|
40611
|
+
node.key = assertionKeyNode;
|
|
40612
|
+
|
|
40613
|
+
// check if we already have an entry for an attribute
|
|
40614
|
+
// if a duplicate entry is found, throw an error
|
|
40615
|
+
// for now this logic will come into play only when someone declares `type` twice
|
|
40616
|
+
if (attrNames.has(node.key.name)) {
|
|
40617
|
+
this.raise(this.pos, "Duplicated key in assertions");
|
|
40618
|
+
}
|
|
40619
|
+
attrNames.add(node.key.name);
|
|
40620
|
+
|
|
40621
|
+
if (this.type !== tt.string) {
|
|
40622
|
+
this.raise(
|
|
40623
|
+
this.pos,
|
|
40624
|
+
"Only string is supported as an assertion value"
|
|
40625
|
+
);
|
|
40626
|
+
}
|
|
40627
|
+
|
|
40628
|
+
node.value = this.parseLiteral(this.value);
|
|
40629
|
+
|
|
40630
|
+
attrs.push(this.finishNode(node, "ImportAttribute"));
|
|
40631
|
+
} while (this.eat(tt.comma));
|
|
40632
|
+
|
|
40633
|
+
return attrs;
|
|
40634
|
+
}
|
|
40635
|
+
};
|
|
40636
|
+
}
|
|
40637
|
+
|
|
40638
|
+
const debug$d = createDebugger('vite:ssr-external');
|
|
40065
40639
|
/**
|
|
40066
40640
|
* Converts "parent > child" syntax to just "child"
|
|
40067
40641
|
*/
|
|
@@ -40139,7 +40713,7 @@ function createIsConfiguredAsSsrExternal(config) {
|
|
|
40139
40713
|
try {
|
|
40140
40714
|
return !!tryNodeResolve(id,
|
|
40141
40715
|
// Skip passing importer in build to avoid externalizing non-hoisted dependencies
|
|
40142
|
-
//
|
|
40716
|
+
// unresolvable from root (which would be unresolvable from output bundles also)
|
|
40143
40717
|
config.command === 'build' ? undefined : importer, resolveOptions, ssr?.target === 'webworker', undefined, true,
|
|
40144
40718
|
// try to externalize, will return undefined or an object without
|
|
40145
40719
|
// a external flag if it isn't externalizable
|
|
@@ -40149,7 +40723,7 @@ function createIsConfiguredAsSsrExternal(config) {
|
|
|
40149
40723
|
!!configuredAsExternal)?.external;
|
|
40150
40724
|
}
|
|
40151
40725
|
catch (e) {
|
|
40152
|
-
debug$
|
|
40726
|
+
debug$d?.(`Failed to node resolve "${id}". Skipping externalizing it by default.`);
|
|
40153
40727
|
// may be an invalid import that's resolved by a plugin
|
|
40154
40728
|
return false;
|
|
40155
40729
|
}
|
|
@@ -40240,7 +40814,7 @@ function cjsSsrCollectExternals(root, resolveOptions, ssrExternals, seen, logger
|
|
|
40240
40814
|
// no main entry, but deep imports may be allowed
|
|
40241
40815
|
const pkgDir = resolvePackageData(id, root)?.dir;
|
|
40242
40816
|
if (pkgDir) {
|
|
40243
|
-
if (isInNodeModules(pkgDir)) {
|
|
40817
|
+
if (isInNodeModules$1(pkgDir)) {
|
|
40244
40818
|
ssrExternals.add(id);
|
|
40245
40819
|
}
|
|
40246
40820
|
else {
|
|
@@ -40249,7 +40823,7 @@ function cjsSsrCollectExternals(root, resolveOptions, ssrExternals, seen, logger
|
|
|
40249
40823
|
continue;
|
|
40250
40824
|
}
|
|
40251
40825
|
// resolve failed, assume include
|
|
40252
|
-
debug$
|
|
40826
|
+
debug$d?.(`Failed to resolve entries for package "${id}"\n`, e);
|
|
40253
40827
|
continue;
|
|
40254
40828
|
}
|
|
40255
40829
|
// no esm entry but has require entry
|
|
@@ -40257,7 +40831,7 @@ function cjsSsrCollectExternals(root, resolveOptions, ssrExternals, seen, logger
|
|
|
40257
40831
|
ssrExternals.add(id);
|
|
40258
40832
|
}
|
|
40259
40833
|
// trace the dependencies of linked packages
|
|
40260
|
-
else if (!isInNodeModules(esmEntry)) {
|
|
40834
|
+
else if (!isInNodeModules$1(esmEntry)) {
|
|
40261
40835
|
const pkgDir = resolvePackageData(id, root)?.dir;
|
|
40262
40836
|
if (pkgDir) {
|
|
40263
40837
|
depsToTrace.add(pkgDir);
|
|
@@ -40368,7 +40942,7 @@ function jsonPlugin(options = {}, isBuild) {
|
|
|
40368
40942
|
|
|
40369
40943
|
const ERR_OPTIMIZE_DEPS_PROCESSING_ERROR = 'ERR_OPTIMIZE_DEPS_PROCESSING_ERROR';
|
|
40370
40944
|
const ERR_OUTDATED_OPTIMIZED_DEP = 'ERR_OUTDATED_OPTIMIZED_DEP';
|
|
40371
|
-
const debug$
|
|
40945
|
+
const debug$c = createDebugger('vite:optimize-deps');
|
|
40372
40946
|
function optimizedDepsPlugin(config) {
|
|
40373
40947
|
return {
|
|
40374
40948
|
name: 'vite:optimized-deps',
|
|
@@ -40415,7 +40989,7 @@ function optimizedDepsPlugin(config) {
|
|
|
40415
40989
|
}
|
|
40416
40990
|
}
|
|
40417
40991
|
}
|
|
40418
|
-
debug$
|
|
40992
|
+
debug$c?.(`load ${colors$1.cyan(file)}`);
|
|
40419
40993
|
// Load the file from the cache instead of waiting for other plugin
|
|
40420
40994
|
// load hooks to avoid race conditions, once processing is resolved,
|
|
40421
40995
|
// we are sure that the file has been properly save to disk
|
|
@@ -40478,7 +41052,7 @@ function optimizedDepsBuildPlugin(config) {
|
|
|
40478
41052
|
const info = optimizedDepInfoFromFile(depsOptimizer.metadata, file);
|
|
40479
41053
|
if (info) {
|
|
40480
41054
|
await info.processing;
|
|
40481
|
-
debug$
|
|
41055
|
+
debug$c?.(`load ${colors$1.cyan(file)}`);
|
|
40482
41056
|
}
|
|
40483
41057
|
else {
|
|
40484
41058
|
throw new Error(`Something unexpected happened while optimizing "${id}".`);
|
|
@@ -40836,7 +41410,7 @@ function importGlobPlugin(config) {
|
|
|
40836
41410
|
async transform(code, id) {
|
|
40837
41411
|
if (!code.includes('import.meta.glob'))
|
|
40838
41412
|
return;
|
|
40839
|
-
const result = await transformGlobImport(code, id, config.root, (im, _, options) => this.resolve(im, id, options).then((i) => i?.id || im), config.
|
|
41413
|
+
const result = await transformGlobImport(code, id, config.root, (im, _, options) => this.resolve(im, id, options).then((i) => i?.id || im), config.experimental.importGlobRestoreExtension);
|
|
40840
41414
|
if (result) {
|
|
40841
41415
|
if (server) {
|
|
40842
41416
|
const allGlobs = result.matches.map((i) => i.globsResolved);
|
|
@@ -41017,18 +41591,10 @@ async function parseImportGlob(code, importer, root, resolveId) {
|
|
|
41017
41591
|
}
|
|
41018
41592
|
const importPrefix = '__vite_glob_';
|
|
41019
41593
|
const { basename, dirname, relative, join } = posix$1;
|
|
41020
|
-
const warnedCSSDefaultImportVarName = '__vite_warned_css_default_import';
|
|
41021
|
-
const jsonStringifyInOneline = (input) => JSON.stringify(input).replace(/[{,:]/g, '$& ').replace(/\}/g, ' }');
|
|
41022
|
-
const createCssDefaultImportWarning = (globs, options) => `if (!${warnedCSSDefaultImportVarName}) {` +
|
|
41023
|
-
`${warnedCSSDefaultImportVarName} = true;` +
|
|
41024
|
-
`console.warn(${JSON.stringify('Default import of CSS without `?inline` is deprecated. ' +
|
|
41025
|
-
"Add the `{ query: '?inline' }` glob option to fix this.\n" +
|
|
41026
|
-
`For example: \`import.meta.glob(${jsonStringifyInOneline(globs.length === 1 ? globs[0] : globs)}, ${jsonStringifyInOneline({ ...options, query: '?inline' })})\``)});` +
|
|
41027
|
-
`}`;
|
|
41028
41594
|
/**
|
|
41029
41595
|
* @param optimizeExport for dynamicImportVar plugin don't need to optimize export.
|
|
41030
41596
|
*/
|
|
41031
|
-
async function transformGlobImport(code, id, root, resolveId,
|
|
41597
|
+
async function transformGlobImport(code, id, root, resolveId, restoreQueryExtension = false) {
|
|
41032
41598
|
id = slash$1(id);
|
|
41033
41599
|
root = slash$1(root);
|
|
41034
41600
|
const isVirtual = isVirtualModule(id);
|
|
@@ -41038,7 +41604,7 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41038
41604
|
if (!matches.length)
|
|
41039
41605
|
return null;
|
|
41040
41606
|
const s = new MagicString(code);
|
|
41041
|
-
const staticImports = (await Promise.all(matches.map(async ({
|
|
41607
|
+
const staticImports = (await Promise.all(matches.map(async ({ globsResolved, isRelative, options, index, start, end }) => {
|
|
41042
41608
|
const cwd = getCommonBase(globsResolved) ?? root;
|
|
41043
41609
|
const files = (await glob(globsResolved, {
|
|
41044
41610
|
cwd,
|
|
@@ -41080,7 +41646,6 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41080
41646
|
}
|
|
41081
41647
|
return { filePath, importPath };
|
|
41082
41648
|
};
|
|
41083
|
-
let includesCSS = false;
|
|
41084
41649
|
files.forEach((file, i) => {
|
|
41085
41650
|
const paths = resolvePaths(file);
|
|
41086
41651
|
const filePath = paths.filePath;
|
|
@@ -41092,8 +41657,6 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41092
41657
|
importQuery = `${importQuery}&lang.${fileExtension}`;
|
|
41093
41658
|
}
|
|
41094
41659
|
importPath = `${importPath}${importQuery}`;
|
|
41095
|
-
const isCSS = !query && isCSSRequest(file) && !isModuleCSSRequest(file);
|
|
41096
|
-
includesCSS ||= isCSS;
|
|
41097
41660
|
const importKey = options.import && options.import !== '*'
|
|
41098
41661
|
? options.import
|
|
41099
41662
|
: undefined;
|
|
@@ -41103,23 +41666,13 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41103
41666
|
? `{ ${importKey} as ${variableName} }`
|
|
41104
41667
|
: `* as ${variableName}`;
|
|
41105
41668
|
staticImports.push(`import ${expression} from ${JSON.stringify(importPath)}`);
|
|
41106
|
-
|
|
41107
|
-
objectProps.push(`get ${JSON.stringify(filePath)}() { ${createCssDefaultImportWarning(globs, options)} return ${variableName} }`);
|
|
41108
|
-
}
|
|
41109
|
-
else {
|
|
41110
|
-
objectProps.push(`${JSON.stringify(filePath)}: ${variableName}`);
|
|
41111
|
-
}
|
|
41669
|
+
objectProps.push(`${JSON.stringify(filePath)}: ${variableName}`);
|
|
41112
41670
|
}
|
|
41113
41671
|
else {
|
|
41114
41672
|
let importStatement = `import(${JSON.stringify(importPath)})`;
|
|
41115
41673
|
if (importKey)
|
|
41116
41674
|
importStatement += `.then(m => m[${JSON.stringify(importKey)}])`;
|
|
41117
|
-
|
|
41118
|
-
objectProps.push(`${JSON.stringify(filePath)}: () => { ${createCssDefaultImportWarning(globs, options)} return ${importStatement}}`);
|
|
41119
|
-
}
|
|
41120
|
-
else {
|
|
41121
|
-
objectProps.push(`${JSON.stringify(filePath)}: () => ${importStatement}`);
|
|
41122
|
-
}
|
|
41675
|
+
objectProps.push(`${JSON.stringify(filePath)}: () => ${importStatement}`);
|
|
41123
41676
|
}
|
|
41124
41677
|
});
|
|
41125
41678
|
files.forEach((i) => matchedFiles.add(i));
|
|
@@ -41127,19 +41680,7 @@ async function transformGlobImport(code, id, root, resolveId, isProduction, rest
|
|
|
41127
41680
|
const lineBreaks = originalLineBreakCount > 0
|
|
41128
41681
|
? '\n'.repeat(originalLineBreakCount)
|
|
41129
41682
|
: '';
|
|
41130
|
-
|
|
41131
|
-
if (!isProduction && includesCSS) {
|
|
41132
|
-
replacement =
|
|
41133
|
-
'/* #__PURE__ */ Object.assign(' +
|
|
41134
|
-
'(() => {' +
|
|
41135
|
-
`let ${warnedCSSDefaultImportVarName} = false;` +
|
|
41136
|
-
`return {${objectProps.join(',')}${lineBreaks}};` +
|
|
41137
|
-
'})()' +
|
|
41138
|
-
')';
|
|
41139
|
-
}
|
|
41140
|
-
else {
|
|
41141
|
-
replacement = `/* #__PURE__ */ Object.assign({${objectProps.join(',')}${lineBreaks}})`;
|
|
41142
|
-
}
|
|
41683
|
+
const replacement = `/* #__PURE__ */ Object.assign({${objectProps.join(',')}${lineBreaks}})`;
|
|
41143
41684
|
s.overwrite(start, end, replacement);
|
|
41144
41685
|
return staticImports;
|
|
41145
41686
|
}))).flat();
|
|
@@ -41619,7 +42160,7 @@ async function readModifiedFile(file) {
|
|
|
41619
42160
|
}
|
|
41620
42161
|
}
|
|
41621
42162
|
|
|
41622
|
-
const debug$
|
|
42163
|
+
const debug$b = createDebugger('vite:import-analysis');
|
|
41623
42164
|
const clientDir = normalizePath$3(CLIENT_DIR);
|
|
41624
42165
|
const skipRE = /\.(?:map|json)(?:$|\?)/;
|
|
41625
42166
|
const canSkipImportAnalysis = (id) => skipRE.test(id) || isDirectCSSRequest(id);
|
|
@@ -41737,7 +42278,7 @@ function importAnalysisPlugin(config) {
|
|
|
41737
42278
|
const ssr = options?.ssr === true;
|
|
41738
42279
|
const prettyImporter = prettifyUrl(importer, root);
|
|
41739
42280
|
if (canSkipImportAnalysis(importer)) {
|
|
41740
|
-
debug$
|
|
42281
|
+
debug$b?.(colors$1.dim(`[skipped] ${prettyImporter}`));
|
|
41741
42282
|
return null;
|
|
41742
42283
|
}
|
|
41743
42284
|
const start = performance.now();
|
|
@@ -41777,7 +42318,7 @@ function importAnalysisPlugin(config) {
|
|
|
41777
42318
|
}
|
|
41778
42319
|
if (!imports.length && !this._addedImports) {
|
|
41779
42320
|
importerModule.isSelfAccepting = false;
|
|
41780
|
-
debug$
|
|
42321
|
+
debug$b?.(`${timeFrom(start)} ${colors$1.dim(`[no imports] ${prettyImporter}`)}`);
|
|
41781
42322
|
return source;
|
|
41782
42323
|
}
|
|
41783
42324
|
let hasHMR = false;
|
|
@@ -41965,26 +42506,6 @@ function importAnalysisPlugin(config) {
|
|
|
41965
42506
|
}
|
|
41966
42507
|
// normalize
|
|
41967
42508
|
const [url, resolvedId] = await normalizeUrl(specifier, start);
|
|
41968
|
-
if (!isDynamicImport &&
|
|
41969
|
-
specifier &&
|
|
41970
|
-
!specifier.includes('?') && // ignore custom queries
|
|
41971
|
-
isCSSRequest(resolvedId) &&
|
|
41972
|
-
!isModuleCSSRequest(resolvedId)) {
|
|
41973
|
-
const sourceExp = source.slice(expStart, start);
|
|
41974
|
-
if (sourceExp.includes('from') && // check default and named imports
|
|
41975
|
-
!sourceExp.includes('__vite_glob_') // glob handles deprecation message itself
|
|
41976
|
-
) {
|
|
41977
|
-
const newImport = sourceExp + specifier + `?inline` + source.slice(end, expEnd);
|
|
41978
|
-
this.warn(`\n` +
|
|
41979
|
-
colors$1.cyan(importerModule.file) +
|
|
41980
|
-
`\n` +
|
|
41981
|
-
colors$1.reset(generateCodeFrame(source, start)) +
|
|
41982
|
-
`\n` +
|
|
41983
|
-
colors$1.yellow(`Default and named imports from CSS files are deprecated. ` +
|
|
41984
|
-
`Use the ?inline query instead. ` +
|
|
41985
|
-
`For example: ${newImport}`));
|
|
41986
|
-
}
|
|
41987
|
-
}
|
|
41988
42509
|
// record as safe modules
|
|
41989
42510
|
// safeModulesPath should not include the base prefix.
|
|
41990
42511
|
// See https://github.com/vitejs/vite/issues/9438#issuecomment-1465270409
|
|
@@ -42008,7 +42529,7 @@ function importAnalysisPlugin(config) {
|
|
|
42008
42529
|
}
|
|
42009
42530
|
}
|
|
42010
42531
|
else if (needsInterop) {
|
|
42011
|
-
debug$
|
|
42532
|
+
debug$b?.(`${url} needs interop`);
|
|
42012
42533
|
interopNamedImports(str(), importSpecifier, url, index, importer, config);
|
|
42013
42534
|
rewriteDone = true;
|
|
42014
42535
|
}
|
|
@@ -42059,7 +42580,7 @@ function importAnalysisPlugin(config) {
|
|
|
42059
42580
|
}
|
|
42060
42581
|
}
|
|
42061
42582
|
else if (!importer.startsWith(withTrailingSlash(clientDir))) {
|
|
42062
|
-
if (!isInNodeModules(importer)) {
|
|
42583
|
+
if (!isInNodeModules$1(importer)) {
|
|
42063
42584
|
// check @vite-ignore which suppresses dynamic import warning
|
|
42064
42585
|
const hasViteIgnore = hasViteIgnoreRE.test(
|
|
42065
42586
|
// complete expression inside parens
|
|
@@ -42144,7 +42665,7 @@ function importAnalysisPlugin(config) {
|
|
|
42144
42665
|
handlePrunedModules(prunedImports, server);
|
|
42145
42666
|
}
|
|
42146
42667
|
}
|
|
42147
|
-
debug$
|
|
42668
|
+
debug$b?.(`${timeFrom(start)} ${colors$1.dim(`[${importedUrls.size} imports rewritten] ${prettyImporter}`)}`);
|
|
42148
42669
|
if (s) {
|
|
42149
42670
|
return transformStableResult(s, importer, config);
|
|
42150
42671
|
}
|
|
@@ -42379,7 +42900,7 @@ function serializeDefine(define) {
|
|
|
42379
42900
|
return res + `}`;
|
|
42380
42901
|
}
|
|
42381
42902
|
|
|
42382
|
-
const wasmHelperId = '\0vite/wasm-helper';
|
|
42903
|
+
const wasmHelperId = '\0vite/wasm-helper.js';
|
|
42383
42904
|
const wasmHelper = async (opts = {}, url) => {
|
|
42384
42905
|
let result;
|
|
42385
42906
|
if (url.startsWith('data:')) {
|
|
@@ -42667,7 +43188,10 @@ function webWorkerPlugin(config) {
|
|
|
42667
43188
|
? 'module'
|
|
42668
43189
|
: 'classic'
|
|
42669
43190
|
: 'module';
|
|
42670
|
-
const workerTypeOption =
|
|
43191
|
+
const workerTypeOption = `{
|
|
43192
|
+
${workerType === 'module' ? `type: "module",` : ''}
|
|
43193
|
+
name: options?.name
|
|
43194
|
+
}`;
|
|
42671
43195
|
if (isBuild) {
|
|
42672
43196
|
getDepsOptimizer(config, ssr)?.registerWorkersSource(id);
|
|
42673
43197
|
if (query.inline != null) {
|
|
@@ -42677,33 +43201,39 @@ function webWorkerPlugin(config) {
|
|
|
42677
43201
|
// Using blob URL for SharedWorker results in multiple instances of a same worker
|
|
42678
43202
|
workerConstructor === 'Worker'
|
|
42679
43203
|
? `${encodedJs}
|
|
42680
|
-
const blob = typeof window !== "undefined" && window.Blob && new Blob([
|
|
43204
|
+
const blob = typeof window !== "undefined" && window.Blob && new Blob([${workerType === 'classic'
|
|
43205
|
+
? ''
|
|
43206
|
+
: // `URL` is always available, in `Worker[type="module"]`
|
|
43207
|
+
`'URL.revokeObjectURL(import.meta.url);'+`}atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
|
|
42681
43208
|
export default function WorkerWrapper(options) {
|
|
42682
43209
|
let objURL;
|
|
42683
43210
|
try {
|
|
42684
43211
|
objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
|
|
42685
43212
|
if (!objURL) throw ''
|
|
42686
|
-
|
|
43213
|
+
const worker = new ${workerConstructor}(objURL, ${workerTypeOption});
|
|
43214
|
+
worker.addEventListener("error", () => {
|
|
43215
|
+
(window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
43216
|
+
});
|
|
43217
|
+
return worker;
|
|
42687
43218
|
} catch(e) {
|
|
42688
43219
|
return new ${workerConstructor}(
|
|
42689
43220
|
"data:application/javascript;base64," + encodedJs,
|
|
42690
|
-
{
|
|
42691
|
-
${workerTypeOption ? `type: "${workerTypeOption}",` : ''}
|
|
42692
|
-
name: options?.name
|
|
42693
|
-
}
|
|
43221
|
+
${workerTypeOption}
|
|
42694
43222
|
);
|
|
42695
|
-
}
|
|
42696
|
-
|
|
42697
|
-
|
|
43223
|
+
}${
|
|
43224
|
+
// For module workers, we should not revoke the URL until the worker runs,
|
|
43225
|
+
// otherwise the worker fails to run
|
|
43226
|
+
workerType === 'classic'
|
|
43227
|
+
? ` finally {
|
|
43228
|
+
objURL && (window.URL || window.webkitURL).revokeObjectURL(objURL);
|
|
43229
|
+
}`
|
|
43230
|
+
: ''}
|
|
42698
43231
|
}`
|
|
42699
43232
|
: `${encodedJs}
|
|
42700
43233
|
export default function WorkerWrapper(options) {
|
|
42701
43234
|
return new ${workerConstructor}(
|
|
42702
43235
|
"data:application/javascript;base64," + encodedJs,
|
|
42703
|
-
{
|
|
42704
|
-
${workerTypeOption ? `type: "${workerTypeOption}",` : ''}
|
|
42705
|
-
name: options?.name
|
|
42706
|
-
}
|
|
43236
|
+
${workerTypeOption}
|
|
42707
43237
|
);
|
|
42708
43238
|
}
|
|
42709
43239
|
`;
|
|
@@ -42732,10 +43262,7 @@ function webWorkerPlugin(config) {
|
|
|
42732
43262
|
code: `export default function WorkerWrapper(options) {
|
|
42733
43263
|
return new ${workerConstructor}(
|
|
42734
43264
|
${JSON.stringify(url)},
|
|
42735
|
-
{
|
|
42736
|
-
${workerTypeOption ? `type: "${workerTypeOption}",` : ''}
|
|
42737
|
-
name: options?.name
|
|
42738
|
-
}
|
|
43265
|
+
${workerTypeOption}
|
|
42739
43266
|
);
|
|
42740
43267
|
}`,
|
|
42741
43268
|
map: { mappings: '' }, // Empty sourcemap to suppress Rollup warning
|
|
@@ -42824,7 +43351,7 @@ function preAliasPlugin(config) {
|
|
|
42824
43351
|
fs$l.existsSync(resolvedId) &&
|
|
42825
43352
|
!moduleListContains(optimizeDeps.exclude, id) &&
|
|
42826
43353
|
path$o.isAbsolute(resolvedId) &&
|
|
42827
|
-
(isInNodeModules(resolvedId) ||
|
|
43354
|
+
(isInNodeModules$1(resolvedId) ||
|
|
42828
43355
|
optimizeDeps.include?.includes(id)) &&
|
|
42829
43356
|
isOptimizable(resolvedId, optimizeDeps) &&
|
|
42830
43357
|
!(isBuild && ssr && isConfiguredAsExternal(id, importer)) &&
|
|
@@ -43133,7 +43660,9 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
43133
43660
|
builtUrl = injectQuery(builtUrl, WORKER_FILE_ID);
|
|
43134
43661
|
builtUrl = injectQuery(builtUrl, `type=${workerType}`);
|
|
43135
43662
|
}
|
|
43136
|
-
s.update(urlIndex, urlIndex + exp.length,
|
|
43663
|
+
s.update(urlIndex, urlIndex + exp.length,
|
|
43664
|
+
// add `'' +` to skip vite:asset-import-meta-url plugin
|
|
43665
|
+
`new URL('' + ${JSON.stringify(builtUrl)}, import.meta.url)`);
|
|
43137
43666
|
}
|
|
43138
43667
|
if (s) {
|
|
43139
43668
|
return transformStableResult(s, id, config);
|
|
@@ -43210,11 +43739,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
43210
43739
|
// A hack to allow 'as' & 'query' exist at the same time
|
|
43211
43740
|
query: injectQuery(queryString, 'url'),
|
|
43212
43741
|
};
|
|
43213
|
-
|
|
43214
|
-
// target so we use the global location here. It can be
|
|
43215
|
-
// window.location or self.location in case it is used in a Web Worker.
|
|
43216
|
-
// @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
|
|
43217
|
-
s.update(index, index + exp.length, `new URL((import.meta.glob(${JSON.stringify(pattern)}, ${JSON.stringify(globOptions)}))[${pureUrl}], self.location)`);
|
|
43742
|
+
s.update(index, index + exp.length, `new URL((import.meta.glob(${JSON.stringify(pattern)}, ${JSON.stringify(globOptions)}))[${pureUrl}], import.meta.url)`);
|
|
43218
43743
|
continue;
|
|
43219
43744
|
}
|
|
43220
43745
|
}
|
|
@@ -43259,7 +43784,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
43259
43784
|
config.logger.warnOnce(`\n${rawExp} doesn't exist at build time, it will remain unchanged to be resolved at runtime`);
|
|
43260
43785
|
builtUrl = url;
|
|
43261
43786
|
}
|
|
43262
|
-
s.update(index, index + exp.length, `new URL(${JSON.stringify(builtUrl)},
|
|
43787
|
+
s.update(index, index + exp.length, `new URL(${JSON.stringify(builtUrl)}, import.meta.url)`);
|
|
43263
43788
|
}
|
|
43264
43789
|
if (s) {
|
|
43265
43790
|
return transformStableResult(s, id, config);
|
|
@@ -43457,7 +43982,7 @@ function dynamicImportToGlob(node, sourceString) {
|
|
|
43457
43982
|
return glob;
|
|
43458
43983
|
}
|
|
43459
43984
|
|
|
43460
|
-
const dynamicImportHelperId = '\0vite/dynamic-import-helper';
|
|
43985
|
+
const dynamicImportHelperId = '\0vite/dynamic-import-helper.js';
|
|
43461
43986
|
const relativePathRE = /^\.{1,2}\//;
|
|
43462
43987
|
// fast path to check if source contains a dynamic import. we check for a
|
|
43463
43988
|
// trailing slash too as a dynamic import statement can have comments between
|
|
@@ -43862,7 +44387,7 @@ function throwClosedServerError() {
|
|
|
43862
44387
|
// send a 504 status code request timeout
|
|
43863
44388
|
throw err;
|
|
43864
44389
|
}
|
|
43865
|
-
let parser = Parser$1;
|
|
44390
|
+
let parser = Parser$1.extend(importAssertions);
|
|
43866
44391
|
async function createPluginContainer(config, moduleGraph, watcher) {
|
|
43867
44392
|
const { plugins, logger, root, build: { rollupOptions }, } = config;
|
|
43868
44393
|
const { getSortedPluginHooks, getSortedPlugins } = createPluginHookUtils(plugins);
|
|
@@ -44243,7 +44768,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44243
44768
|
(await handleHookPromise(optionsHook.call(minimalContext, options))) || options;
|
|
44244
44769
|
}
|
|
44245
44770
|
if (options.acornInjectPlugins) {
|
|
44246
|
-
parser = Parser$1.extend(...arraify(options.acornInjectPlugins));
|
|
44771
|
+
parser = Parser$1.extend(importAssertions, ...arraify(options.acornInjectPlugins));
|
|
44247
44772
|
}
|
|
44248
44773
|
return {
|
|
44249
44774
|
acorn,
|
|
@@ -44397,7 +44922,7 @@ async function createPluginContainer(config, moduleGraph, watcher) {
|
|
|
44397
44922
|
return container;
|
|
44398
44923
|
}
|
|
44399
44924
|
|
|
44400
|
-
const debug$
|
|
44925
|
+
const debug$a = createDebugger('vite:deps');
|
|
44401
44926
|
const htmlTypesRE = /\.(html|vue|svelte|astro|imba)$/;
|
|
44402
44927
|
// A simple regex to detect import sources. This is only used on
|
|
44403
44928
|
// <script lang="ts"> blocks in vue (setup only) or svelte files, since
|
|
@@ -44427,7 +44952,7 @@ function scanImports(config) {
|
|
|
44427
44952
|
}
|
|
44428
44953
|
if (scanContext.cancelled)
|
|
44429
44954
|
return;
|
|
44430
|
-
debug$
|
|
44955
|
+
debug$a?.(`Crawling dependencies using entries: ${entries
|
|
44431
44956
|
.map((entry) => `\n ${colors$1.dim(entry)}`)
|
|
44432
44957
|
.join('')}`);
|
|
44433
44958
|
return prepareEsbuildScanner(config, entries, deps, missing, scanContext);
|
|
@@ -44480,13 +45005,13 @@ function scanImports(config) {
|
|
|
44480
45005
|
throw e;
|
|
44481
45006
|
})
|
|
44482
45007
|
.finally(() => {
|
|
44483
|
-
if (debug$
|
|
45008
|
+
if (debug$a) {
|
|
44484
45009
|
const duration = (performance.now() - start).toFixed(2);
|
|
44485
45010
|
const depsStr = Object.keys(orderedDependencies(deps))
|
|
44486
45011
|
.sort()
|
|
44487
45012
|
.map((id) => `\n ${colors$1.cyan(id)} -> ${colors$1.dim(deps[id])}`)
|
|
44488
45013
|
.join('') || colors$1.dim('no dependencies found');
|
|
44489
|
-
debug$
|
|
45014
|
+
debug$a(`Scan completed in ${duration}ms: ${depsStr}`);
|
|
44490
45015
|
}
|
|
44491
45016
|
});
|
|
44492
45017
|
return {
|
|
@@ -44610,7 +45135,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
44610
45135
|
else {
|
|
44611
45136
|
transpiledContents = contents;
|
|
44612
45137
|
}
|
|
44613
|
-
const result = await transformGlobImport(transpiledContents, id, config.root, resolve
|
|
45138
|
+
const result = await transformGlobImport(transpiledContents, id, config.root, resolve);
|
|
44614
45139
|
return result?.s.toString() || transpiledContents;
|
|
44615
45140
|
};
|
|
44616
45141
|
return {
|
|
@@ -44646,7 +45171,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
44646
45171
|
// It is possible for the scanner to scan html types in node_modules.
|
|
44647
45172
|
// If we can optimize this html type, skip it so it's handled by the
|
|
44648
45173
|
// bare import resolve, and recorded as optimization dep.
|
|
44649
|
-
if (isInNodeModules(resolved) &&
|
|
45174
|
+
if (isInNodeModules$1(resolved) &&
|
|
44650
45175
|
isOptimizable(resolved, config.optimizeDeps))
|
|
44651
45176
|
return;
|
|
44652
45177
|
return {
|
|
@@ -44769,7 +45294,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
44769
45294
|
if (shouldExternalizeDep(resolved, id)) {
|
|
44770
45295
|
return externalUnlessEntry({ path: id });
|
|
44771
45296
|
}
|
|
44772
|
-
if (isInNodeModules(resolved) || include?.includes(id)) {
|
|
45297
|
+
if (isInNodeModules$1(resolved) || include?.includes(id)) {
|
|
44773
45298
|
// dependency or forced included, externalize and stop crawling
|
|
44774
45299
|
if (isOptimizable(resolved, config.optimizeDeps)) {
|
|
44775
45300
|
depImports[id] = resolved;
|
|
@@ -45047,7 +45572,7 @@ function nestedResolveBasedir(id, basedir, preserveSymlinks = false) {
|
|
|
45047
45572
|
return basedir;
|
|
45048
45573
|
}
|
|
45049
45574
|
|
|
45050
|
-
const debug$
|
|
45575
|
+
const debug$9 = createDebugger('vite:deps');
|
|
45051
45576
|
/**
|
|
45052
45577
|
* The amount to wait for requests to register newly found dependencies before triggering
|
|
45053
45578
|
* a re-bundle + page reload
|
|
@@ -45183,7 +45708,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45183
45708
|
depsOptimizer.scanProcessing = new Promise((resolve) => {
|
|
45184
45709
|
(async () => {
|
|
45185
45710
|
try {
|
|
45186
|
-
debug$
|
|
45711
|
+
debug$9?.(colors$1.green(`scanning for dependencies...`));
|
|
45187
45712
|
discover = discoverProjectDependencies(config);
|
|
45188
45713
|
const deps = await discover.result;
|
|
45189
45714
|
discover = undefined;
|
|
@@ -45326,7 +45851,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45326
45851
|
};
|
|
45327
45852
|
if (!needsReload) {
|
|
45328
45853
|
await commitProcessing();
|
|
45329
|
-
if (!debug$
|
|
45854
|
+
if (!debug$9) {
|
|
45330
45855
|
if (newDepsToLogHandle)
|
|
45331
45856
|
clearTimeout(newDepsToLogHandle);
|
|
45332
45857
|
newDepsToLogHandle = setTimeout(() => {
|
|
@@ -45335,7 +45860,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45335
45860
|
}, 2 * debounceMs);
|
|
45336
45861
|
}
|
|
45337
45862
|
else {
|
|
45338
|
-
debug$
|
|
45863
|
+
debug$9(colors$1.green(`✨ ${!isRerun
|
|
45339
45864
|
? `dependencies optimized`
|
|
45340
45865
|
: `optimized dependencies unchanged`}`));
|
|
45341
45866
|
}
|
|
@@ -45347,11 +45872,11 @@ async function createDepsOptimizer(config, server) {
|
|
|
45347
45872
|
// We don't resolve the processing promise, as they will be resolved
|
|
45348
45873
|
// once a rerun is committed
|
|
45349
45874
|
processingResult.cancel();
|
|
45350
|
-
debug$
|
|
45875
|
+
debug$9?.(colors$1.green(`✨ delaying reload as new dependencies have been found...`));
|
|
45351
45876
|
}
|
|
45352
45877
|
else {
|
|
45353
45878
|
await commitProcessing();
|
|
45354
|
-
if (!debug$
|
|
45879
|
+
if (!debug$9) {
|
|
45355
45880
|
if (newDepsToLogHandle)
|
|
45356
45881
|
clearTimeout(newDepsToLogHandle);
|
|
45357
45882
|
newDepsToLogHandle = undefined;
|
|
@@ -45397,7 +45922,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45397
45922
|
// optimizeDeps processing is finished
|
|
45398
45923
|
const deps = Object.keys(metadata.discovered);
|
|
45399
45924
|
const depsString = depsLogString(deps);
|
|
45400
|
-
debug$
|
|
45925
|
+
debug$9?.(colors$1.green(`new dependencies found: ${depsString}`));
|
|
45401
45926
|
runOptimizer();
|
|
45402
45927
|
}
|
|
45403
45928
|
function getDiscoveredBrowserHash(hash, deps, missing) {
|
|
@@ -45482,7 +46007,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45482
46007
|
// On build time, a missing dep appearing after onCrawlEnd is an internal error
|
|
45483
46008
|
// On dev, switch after this point to a simple debounce strategy
|
|
45484
46009
|
crawlEndFinder = undefined;
|
|
45485
|
-
debug$
|
|
46010
|
+
debug$9?.(colors$1.green(`✨ static imports crawl ended`));
|
|
45486
46011
|
if (closed) {
|
|
45487
46012
|
return;
|
|
45488
46013
|
}
|
|
@@ -45496,7 +46021,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45496
46021
|
const crawlDeps = Object.keys(metadata.discovered);
|
|
45497
46022
|
const scanDeps = Object.keys(result.metadata.optimized);
|
|
45498
46023
|
if (scanDeps.length === 0 && crawlDeps.length === 0) {
|
|
45499
|
-
debug$
|
|
46024
|
+
debug$9?.(colors$1.green(`✨ no dependencies found by the scanner or crawling static imports`));
|
|
45500
46025
|
result.cancel();
|
|
45501
46026
|
firstRunCalled = true;
|
|
45502
46027
|
return;
|
|
@@ -45514,13 +46039,13 @@ async function createDepsOptimizer(config, server) {
|
|
|
45514
46039
|
}
|
|
45515
46040
|
}
|
|
45516
46041
|
if (scannerMissedDeps) {
|
|
45517
|
-
debug$
|
|
46042
|
+
debug$9?.(colors$1.yellow(`✨ new dependencies were found while crawling that weren't detected by the scanner`));
|
|
45518
46043
|
}
|
|
45519
|
-
debug$
|
|
46044
|
+
debug$9?.(colors$1.green(`✨ re-running optimizer`));
|
|
45520
46045
|
debouncedProcessing(0);
|
|
45521
46046
|
}
|
|
45522
46047
|
else {
|
|
45523
|
-
debug$
|
|
46048
|
+
debug$9?.(colors$1.green(`✨ using post-scan optimizer result, the scanner found every used dependency`));
|
|
45524
46049
|
startNextDiscoveredBatch();
|
|
45525
46050
|
runOptimizer(result);
|
|
45526
46051
|
}
|
|
@@ -45529,7 +46054,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
45529
46054
|
const crawlDeps = Object.keys(metadata.discovered);
|
|
45530
46055
|
currentlyProcessing = false;
|
|
45531
46056
|
if (crawlDeps.length === 0) {
|
|
45532
|
-
debug$
|
|
46057
|
+
debug$9?.(colors$1.green(`✨ no dependencies found while crawling the static imports`));
|
|
45533
46058
|
firstRunCalled = true;
|
|
45534
46059
|
}
|
|
45535
46060
|
else {
|
|
@@ -45660,14 +46185,14 @@ function findInteropMismatches(discovered, optimized) {
|
|
|
45660
46185
|
// This only happens when a discovered dependency has mixed ESM and CJS syntax
|
|
45661
46186
|
// and it hasn't been manually added to optimizeDeps.needsInterop
|
|
45662
46187
|
needsInteropMismatch.push(dep);
|
|
45663
|
-
debug$
|
|
46188
|
+
debug$9?.(colors$1.cyan(`✨ needsInterop mismatch detected for ${dep}`));
|
|
45664
46189
|
}
|
|
45665
46190
|
}
|
|
45666
46191
|
}
|
|
45667
46192
|
return needsInteropMismatch;
|
|
45668
46193
|
}
|
|
45669
46194
|
|
|
45670
|
-
const debug$
|
|
46195
|
+
const debug$8 = createDebugger('vite:deps');
|
|
45671
46196
|
const jsExtensionRE = /\.js$/i;
|
|
45672
46197
|
const jsMapExtensionRE = /\.js\.map$/i;
|
|
45673
46198
|
/**
|
|
@@ -45675,7 +46200,7 @@ const jsMapExtensionRE = /\.js\.map$/i;
|
|
|
45675
46200
|
* Used by Vite CLI when running `vite optimize`.
|
|
45676
46201
|
*/
|
|
45677
46202
|
async function optimizeDeps(config, force = config.optimizeDeps.force, asCommand = false) {
|
|
45678
|
-
const log = asCommand ? config.logger.info : debug$
|
|
46203
|
+
const log = asCommand ? config.logger.info : debug$8;
|
|
45679
46204
|
const ssr = config.command === 'build' && !!config.build.ssr;
|
|
45680
46205
|
const cachedMetadata = await loadCachedDepOptimizationMetadata(config, ssr, force, asCommand);
|
|
45681
46206
|
if (cachedMetadata) {
|
|
@@ -45738,7 +46263,7 @@ let firstLoadCachedDepOptimizationMetadata = true;
|
|
|
45738
46263
|
* if it exists and pre-bundling isn't forced
|
|
45739
46264
|
*/
|
|
45740
46265
|
async function loadCachedDepOptimizationMetadata(config, ssr, force = config.optimizeDeps.force, asCommand = false) {
|
|
45741
|
-
const log = asCommand ? config.logger.info : debug$
|
|
46266
|
+
const log = asCommand ? config.logger.info : debug$8;
|
|
45742
46267
|
if (firstLoadCachedDepOptimizationMetadata) {
|
|
45743
46268
|
firstLoadCachedDepOptimizationMetadata = false;
|
|
45744
46269
|
// Fire up a clean up of stale processing deps dirs if older process exited early
|
|
@@ -45946,7 +46471,7 @@ function runOptimizeDeps(resolvedConfig, depsInfo, ssr = resolvedConfig.command
|
|
|
45946
46471
|
}
|
|
45947
46472
|
}
|
|
45948
46473
|
}
|
|
45949
|
-
debug$
|
|
46474
|
+
debug$8?.(`Dependencies bundled in ${(performance.now() - start).toFixed(2)}ms`);
|
|
45950
46475
|
return successfulResult;
|
|
45951
46476
|
})
|
|
45952
46477
|
.catch((e) => {
|
|
@@ -46305,7 +46830,7 @@ async function extractExportsData(filePath, config, ssr) {
|
|
|
46305
46830
|
}
|
|
46306
46831
|
catch {
|
|
46307
46832
|
const loader = esbuildOptions.loader?.[path$o.extname(filePath)] || 'jsx';
|
|
46308
|
-
debug$
|
|
46833
|
+
debug$8?.(`Unable to parse: ${filePath}.\n Trying again with a ${loader} transform.`);
|
|
46309
46834
|
const transformed = await transformWithEsbuild(entryContent, filePath, {
|
|
46310
46835
|
loader,
|
|
46311
46836
|
});
|
|
@@ -46515,7 +47040,7 @@ var index$1 = {
|
|
|
46515
47040
|
const isModernFlag = `__VITE_IS_MODERN__`;
|
|
46516
47041
|
const preloadMethod = `__vitePreload`;
|
|
46517
47042
|
const preloadMarker = `__VITE_PRELOAD__`;
|
|
46518
|
-
const preloadHelperId = '\0vite/preload-helper';
|
|
47043
|
+
const preloadHelperId = '\0vite/preload-helper.js';
|
|
46519
47044
|
const preloadMarkerWithQuote = new RegExp(`['"]${preloadMarker}['"]`);
|
|
46520
47045
|
const dynamicImportPrefixRE = /import\s*\(/;
|
|
46521
47046
|
// TODO: abstract
|
|
@@ -46649,7 +47174,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
46649
47174
|
}
|
|
46650
47175
|
},
|
|
46651
47176
|
async transform(source, importer) {
|
|
46652
|
-
if (isInNodeModules(importer) && !dynamicImportPrefixRE.test(source)) {
|
|
47177
|
+
if (isInNodeModules$1(importer) && !dynamicImportPrefixRE.test(source)) {
|
|
46653
47178
|
return;
|
|
46654
47179
|
}
|
|
46655
47180
|
await init;
|
|
@@ -46760,24 +47285,6 @@ function buildImportAnalysisPlugin(config) {
|
|
|
46760
47285
|
}
|
|
46761
47286
|
}
|
|
46762
47287
|
}
|
|
46763
|
-
// Differentiate CSS imports that use the default export from those that
|
|
46764
|
-
// do not by injecting a ?used query - this allows us to avoid including
|
|
46765
|
-
// the CSS string when unnecessary (esbuild has trouble tree-shaking
|
|
46766
|
-
// them)
|
|
46767
|
-
if (specifier &&
|
|
46768
|
-
isCSSRequest(specifier) &&
|
|
46769
|
-
// always inject ?used query when it is a dynamic import
|
|
46770
|
-
// because there is no way to check whether the default export is used
|
|
46771
|
-
(source.slice(expStart, start).includes('from') || isDynamicImport) &&
|
|
46772
|
-
// already has ?used query (by import.meta.glob)
|
|
46773
|
-
!specifier.match(/\?used(&|$)/) &&
|
|
46774
|
-
// don't append ?used when SPECIAL_QUERY_RE exists
|
|
46775
|
-
!specifier.match(SPECIAL_QUERY_RE) &&
|
|
46776
|
-
// edge case for package names ending with .css (e.g normalize.css)
|
|
46777
|
-
!(bareImportRE.test(specifier) && !specifier.includes('/'))) {
|
|
46778
|
-
const url = specifier.replace(/\?|$/, (m) => `?used${m ? '&' : ''}`);
|
|
46779
|
-
str().update(start, end, isDynamicImport ? `'${url}'` : url);
|
|
46780
|
-
}
|
|
46781
47288
|
}
|
|
46782
47289
|
if (needPreloadHelper &&
|
|
46783
47290
|
insertPreload &&
|
|
@@ -47268,6 +47775,9 @@ function stattag (stat) {
|
|
|
47268
47775
|
|
|
47269
47776
|
var getEtag = /*@__PURE__*/getDefaultExportFromCjs(etag_1);
|
|
47270
47777
|
|
|
47778
|
+
const debug$7 = createDebugger('vite:send', {
|
|
47779
|
+
onlyWhenFocused: true,
|
|
47780
|
+
});
|
|
47271
47781
|
const alias = {
|
|
47272
47782
|
js: 'application/javascript',
|
|
47273
47783
|
css: 'text/css',
|
|
@@ -47298,11 +47808,22 @@ function send$2(req, res, content, type, options) {
|
|
|
47298
47808
|
content = getCodeWithSourcemap(type, content.toString(), map);
|
|
47299
47809
|
}
|
|
47300
47810
|
}
|
|
47301
|
-
|
|
47302
|
-
|
|
47811
|
+
// inject fallback sourcemap for js for improved debugging
|
|
47812
|
+
// https://github.com/vitejs/vite/pull/13514#issuecomment-1592431496
|
|
47813
|
+
else if (type === 'js' && (!map || map.mappings !== '')) {
|
|
47814
|
+
const code = content.toString();
|
|
47815
|
+
// if the code has existing inline sourcemap, assume it's correct and skip
|
|
47816
|
+
if (convertSourceMap.mapFileCommentRegex.test(code)) {
|
|
47817
|
+
debug$7?.(`Skipped injecting fallback sourcemap for ${req.url}`);
|
|
47818
|
+
}
|
|
47819
|
+
else {
|
|
47303
47820
|
const urlWithoutTimestamp = removeTimestampQuery(req.url);
|
|
47304
|
-
const ms = new MagicString(
|
|
47305
|
-
content = getCodeWithSourcemap(type,
|
|
47821
|
+
const ms = new MagicString(code);
|
|
47822
|
+
content = getCodeWithSourcemap(type, code, ms.generateMap({
|
|
47823
|
+
source: path$o.basename(urlWithoutTimestamp),
|
|
47824
|
+
hires: 'boundary',
|
|
47825
|
+
includeContent: true,
|
|
47826
|
+
}));
|
|
47306
47827
|
}
|
|
47307
47828
|
}
|
|
47308
47829
|
res.statusCode = 200;
|
|
@@ -47310,6 +47831,63 @@ function send$2(req, res, content, type, options) {
|
|
|
47310
47831
|
return;
|
|
47311
47832
|
}
|
|
47312
47833
|
|
|
47834
|
+
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
|
47835
|
+
const ROOT_FILES = [
|
|
47836
|
+
// '.git',
|
|
47837
|
+
// https://pnpm.io/workspaces/
|
|
47838
|
+
'pnpm-workspace.yaml',
|
|
47839
|
+
// https://rushjs.io/pages/advanced/config_files/
|
|
47840
|
+
// 'rush.json',
|
|
47841
|
+
// https://nx.dev/latest/react/getting-started/nx-setup
|
|
47842
|
+
// 'workspace.json',
|
|
47843
|
+
// 'nx.json',
|
|
47844
|
+
// https://github.com/lerna/lerna#lernajson
|
|
47845
|
+
'lerna.json',
|
|
47846
|
+
];
|
|
47847
|
+
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
|
47848
|
+
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
|
47849
|
+
function hasWorkspacePackageJSON(root) {
|
|
47850
|
+
const path = join$2(root, 'package.json');
|
|
47851
|
+
if (!isFileReadable(path)) {
|
|
47852
|
+
return false;
|
|
47853
|
+
}
|
|
47854
|
+
const content = JSON.parse(fs$l.readFileSync(path, 'utf-8')) || {};
|
|
47855
|
+
return !!content.workspaces;
|
|
47856
|
+
}
|
|
47857
|
+
function hasRootFile(root) {
|
|
47858
|
+
return ROOT_FILES.some((file) => fs$l.existsSync(join$2(root, file)));
|
|
47859
|
+
}
|
|
47860
|
+
function hasPackageJSON(root) {
|
|
47861
|
+
const path = join$2(root, 'package.json');
|
|
47862
|
+
return fs$l.existsSync(path);
|
|
47863
|
+
}
|
|
47864
|
+
/**
|
|
47865
|
+
* Search up for the nearest `package.json`
|
|
47866
|
+
*/
|
|
47867
|
+
function searchForPackageRoot(current, root = current) {
|
|
47868
|
+
if (hasPackageJSON(current))
|
|
47869
|
+
return current;
|
|
47870
|
+
const dir = dirname$2(current);
|
|
47871
|
+
// reach the fs root
|
|
47872
|
+
if (!dir || dir === current)
|
|
47873
|
+
return root;
|
|
47874
|
+
return searchForPackageRoot(dir, root);
|
|
47875
|
+
}
|
|
47876
|
+
/**
|
|
47877
|
+
* Search up for the nearest workspace root
|
|
47878
|
+
*/
|
|
47879
|
+
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
47880
|
+
if (hasRootFile(current))
|
|
47881
|
+
return current;
|
|
47882
|
+
if (hasWorkspacePackageJSON(current))
|
|
47883
|
+
return current;
|
|
47884
|
+
const dir = dirname$2(current);
|
|
47885
|
+
// reach the fs root
|
|
47886
|
+
if (!dir || dir === current)
|
|
47887
|
+
return root;
|
|
47888
|
+
return searchForWorkspaceRoot(dir, root);
|
|
47889
|
+
}
|
|
47890
|
+
|
|
47313
47891
|
function totalist(dir, callback, pre='') {
|
|
47314
47892
|
dir = resolve$3('.', dir);
|
|
47315
47893
|
let arr = readdirSync(dir);
|
|
@@ -55104,6 +55682,63 @@ function createConvertSourceMapReadMap(originalFileName) {
|
|
|
55104
55682
|
};
|
|
55105
55683
|
}
|
|
55106
55684
|
|
|
55685
|
+
/**
|
|
55686
|
+
* @param {import('estree').Node} param
|
|
55687
|
+
* @returns {string[]}
|
|
55688
|
+
*/
|
|
55689
|
+
function extract_names(param) {
|
|
55690
|
+
return extract_identifiers(param).map((node) => node.name);
|
|
55691
|
+
}
|
|
55692
|
+
|
|
55693
|
+
/**
|
|
55694
|
+
* @param {import('estree').Node} param
|
|
55695
|
+
* @param {import('estree').Identifier[]} nodes
|
|
55696
|
+
* @returns {import('estree').Identifier[]}
|
|
55697
|
+
*/
|
|
55698
|
+
function extract_identifiers(param, nodes = []) {
|
|
55699
|
+
switch (param.type) {
|
|
55700
|
+
case 'Identifier':
|
|
55701
|
+
nodes.push(param);
|
|
55702
|
+
break;
|
|
55703
|
+
|
|
55704
|
+
case 'MemberExpression':
|
|
55705
|
+
let object = param;
|
|
55706
|
+
while (object.type === 'MemberExpression') {
|
|
55707
|
+
object = /** @type {any} */ (object.object);
|
|
55708
|
+
}
|
|
55709
|
+
nodes.push(/** @type {any} */ (object));
|
|
55710
|
+
break;
|
|
55711
|
+
|
|
55712
|
+
case 'ObjectPattern':
|
|
55713
|
+
for (const prop of param.properties) {
|
|
55714
|
+
if (prop.type === 'RestElement') {
|
|
55715
|
+
extract_identifiers(prop.argument, nodes);
|
|
55716
|
+
} else {
|
|
55717
|
+
extract_identifiers(prop.value, nodes);
|
|
55718
|
+
}
|
|
55719
|
+
}
|
|
55720
|
+
|
|
55721
|
+
break;
|
|
55722
|
+
|
|
55723
|
+
case 'ArrayPattern':
|
|
55724
|
+
for (const element of param.elements) {
|
|
55725
|
+
if (element) extract_identifiers(element, nodes);
|
|
55726
|
+
}
|
|
55727
|
+
|
|
55728
|
+
break;
|
|
55729
|
+
|
|
55730
|
+
case 'RestElement':
|
|
55731
|
+
extract_identifiers(param.argument, nodes);
|
|
55732
|
+
break;
|
|
55733
|
+
|
|
55734
|
+
case 'AssignmentPattern':
|
|
55735
|
+
extract_identifiers(param.left, nodes);
|
|
55736
|
+
break;
|
|
55737
|
+
}
|
|
55738
|
+
|
|
55739
|
+
return nodes;
|
|
55740
|
+
}
|
|
55741
|
+
|
|
55107
55742
|
/**
|
|
55108
55743
|
* @typedef { import('estree').Node} Node
|
|
55109
55744
|
* @typedef {{
|
|
@@ -55336,71 +55971,6 @@ function walk$1(ast, { enter, leave }) {
|
|
|
55336
55971
|
return instance.visit(ast, null);
|
|
55337
55972
|
}
|
|
55338
55973
|
|
|
55339
|
-
/**
|
|
55340
|
-
* @param {import('estree').Node} param
|
|
55341
|
-
* @returns {string[]}
|
|
55342
|
-
*/
|
|
55343
|
-
function extract_names(param) {
|
|
55344
|
-
return extract_identifiers(param).map(node => node.name);
|
|
55345
|
-
}
|
|
55346
|
-
|
|
55347
|
-
/**
|
|
55348
|
-
* @param {import('estree').Node} param
|
|
55349
|
-
* @param {import('estree').Identifier[]} nodes
|
|
55350
|
-
* @returns {import('estree').Identifier[]}
|
|
55351
|
-
*/
|
|
55352
|
-
function extract_identifiers(param, nodes = []) {
|
|
55353
|
-
switch (param.type) {
|
|
55354
|
-
case 'Identifier':
|
|
55355
|
-
nodes.push(param);
|
|
55356
|
-
break;
|
|
55357
|
-
|
|
55358
|
-
case 'MemberExpression':
|
|
55359
|
-
let object = param;
|
|
55360
|
-
while (object.type === 'MemberExpression') {
|
|
55361
|
-
object = /** @type {any} */ (object.object);
|
|
55362
|
-
}
|
|
55363
|
-
nodes.push(/** @type {any} */ (object));
|
|
55364
|
-
break;
|
|
55365
|
-
|
|
55366
|
-
case 'ObjectPattern':
|
|
55367
|
-
/** @param {import('estree').Property | import('estree').RestElement} prop */
|
|
55368
|
-
const handle_prop = (prop) => {
|
|
55369
|
-
if (prop.type === 'RestElement') {
|
|
55370
|
-
extract_identifiers(prop.argument, nodes);
|
|
55371
|
-
} else {
|
|
55372
|
-
extract_identifiers(prop.value, nodes);
|
|
55373
|
-
}
|
|
55374
|
-
};
|
|
55375
|
-
|
|
55376
|
-
param.properties.forEach(handle_prop);
|
|
55377
|
-
break;
|
|
55378
|
-
|
|
55379
|
-
case 'ArrayPattern':
|
|
55380
|
-
/** @param {import('estree').Node} element */
|
|
55381
|
-
const handle_element = (element) => {
|
|
55382
|
-
if (element) extract_identifiers(element, nodes);
|
|
55383
|
-
};
|
|
55384
|
-
|
|
55385
|
-
param.elements.forEach((element) => {
|
|
55386
|
-
if (element) {
|
|
55387
|
-
handle_element(element);
|
|
55388
|
-
}
|
|
55389
|
-
});
|
|
55390
|
-
break;
|
|
55391
|
-
|
|
55392
|
-
case 'RestElement':
|
|
55393
|
-
extract_identifiers(param.argument, nodes);
|
|
55394
|
-
break;
|
|
55395
|
-
|
|
55396
|
-
case 'AssignmentPattern':
|
|
55397
|
-
extract_identifiers(param.left, nodes);
|
|
55398
|
-
break;
|
|
55399
|
-
}
|
|
55400
|
-
|
|
55401
|
-
return nodes;
|
|
55402
|
-
}
|
|
55403
|
-
|
|
55404
55974
|
const ssrModuleExportsKey = `__vite_ssr_exports__`;
|
|
55405
55975
|
const ssrImportKey = `__vite_ssr_import__`;
|
|
55406
55976
|
const ssrDynamicImportKey = `__vite_ssr_dynamic_import__`;
|
|
@@ -65448,7 +66018,7 @@ function resolveServerOptions(root, raw, logger) {
|
|
|
65448
66018
|
...raw,
|
|
65449
66019
|
sourcemapIgnoreList: raw?.sourcemapIgnoreList === false
|
|
65450
66020
|
? () => false
|
|
65451
|
-
: raw?.sourcemapIgnoreList || isInNodeModules,
|
|
66021
|
+
: raw?.sourcemapIgnoreList || isInNodeModules$1,
|
|
65452
66022
|
middlewareMode: !!raw?.middlewareMode,
|
|
65453
66023
|
};
|
|
65454
66024
|
let allowDirs = server.fs?.allow;
|
|
@@ -65865,6 +66435,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
65865
66435
|
});
|
|
65866
66436
|
// resolve root
|
|
65867
66437
|
const resolvedRoot = normalizePath$3(config.root ? path$o.resolve(config.root) : process.cwd());
|
|
66438
|
+
if (resolvedRoot.includes('#')) {
|
|
66439
|
+
logger.warn(colors$1.yellow(`The project root contains the "#" character (${colors$1.cyan(resolvedRoot)}), which may not work when running Vite. Consider renaming the directory to remove the "#".`));
|
|
66440
|
+
}
|
|
65868
66441
|
const clientAlias = [
|
|
65869
66442
|
{
|
|
65870
66443
|
find: /^\/?@vite\/env/,
|
|
@@ -66086,7 +66659,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
|
66086
66659
|
if (middlewareMode === 'ssr') {
|
|
66087
66660
|
logger.warn(colors$1.yellow(`Setting server.middlewareMode to 'ssr' is deprecated, set server.middlewareMode to \`true\`${config.appType === 'custom' ? '' : ` and appType to 'custom'`} instead`));
|
|
66088
66661
|
}
|
|
66089
|
-
if (middlewareMode === 'html') {
|
|
66662
|
+
else if (middlewareMode === 'html') {
|
|
66090
66663
|
logger.warn(colors$1.yellow(`Setting server.middlewareMode to 'html' is deprecated, set server.middlewareMode to \`true\` instead`));
|
|
66091
66664
|
}
|
|
66092
66665
|
if (config.server?.force &&
|
|
@@ -66422,4 +66995,4 @@ function isDepsOptimizerEnabled(config, ssr) {
|
|
|
66422
66995
|
(command === 'serve' && disabled === 'dev'));
|
|
66423
66996
|
}
|
|
66424
66997
|
|
|
66425
|
-
export { loadEnv as A, resolveEnvPrefix as B, colors$1 as C, getDefaultExportFromCjs as D, commonjsGlobal as E, index$1 as F, build$1 as G, index as H, preview$1 as I, preprocessCSS as a, build as b, createServer as c, resolvePackageData as d, buildErrorMessage as e, formatPostcssSourceMap as f, defineConfig as g, resolveConfig as h, isInNodeModules as i, resolveBaseUrl as j, getDepOptimizationConfig as k, loadConfigFromFile as l, isDepsOptimizerEnabled as m, normalizePath$3 as n, optimizeDeps as o, preview as p, mergeConfig as q, resolvePackageEntry as r, sortUserPlugins as s, transformWithEsbuild as t, mergeAlias as u, createFilter as v, send$2 as w, createLogger as x, searchForWorkspaceRoot as y, isFileServingAllowed as z };
|
|
66998
|
+
export { loadEnv as A, resolveEnvPrefix as B, colors$1 as C, getDefaultExportFromCjs as D, commonjsGlobal as E, index$1 as F, build$1 as G, index as H, preview$1 as I, preprocessCSS as a, build as b, createServer as c, resolvePackageData as d, buildErrorMessage as e, formatPostcssSourceMap as f, defineConfig as g, resolveConfig as h, isInNodeModules$1 as i, resolveBaseUrl as j, getDepOptimizationConfig as k, loadConfigFromFile as l, isDepsOptimizerEnabled as m, normalizePath$3 as n, optimizeDeps as o, preview as p, mergeConfig as q, resolvePackageEntry as r, sortUserPlugins as s, transformWithEsbuild as t, mergeAlias as u, createFilter as v, send$2 as w, createLogger as x, searchForWorkspaceRoot as y, isFileServingAllowed as z };
|