vite 2.9.0-beta.4 → 2.9.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/dist/node/chunks/{dep-dd016db2.js → dep-35d2a41c.js} +116 -8
- package/dist/node/chunks/{dep-8a000299.js → dep-57c89c81.js} +1 -1
- package/dist/node/chunks/{dep-5a245411.js → dep-a7fb482c.js} +923 -665
- package/dist/node/chunks/{dep-0d07874d.js → dep-c9843b31.js} +1 -1
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +23 -14
- package/dist/node/index.js +3 -2
- package/package.json +8 -7
|
@@ -18,9 +18,9 @@ var zlib$1 = require('zlib');
|
|
|
18
18
|
var require$$1$1 = require('crypto');
|
|
19
19
|
var require$$4 = require('tls');
|
|
20
20
|
var require$$5 = require('assert');
|
|
21
|
+
var esbuild = require('esbuild');
|
|
21
22
|
var require$$0$8 = require('buffer');
|
|
22
23
|
var qs = require('querystring');
|
|
23
|
-
var esbuild = require('esbuild');
|
|
24
24
|
var require$$1$5 = require('child_process');
|
|
25
25
|
var require$$1$2 = require('worker_threads');
|
|
26
26
|
var readline = require('readline');
|
|
@@ -498,7 +498,7 @@ function setup(env) {
|
|
|
498
498
|
namespaces = split[i].replace(/\*/g, '.*?');
|
|
499
499
|
|
|
500
500
|
if (namespaces[0] === '-') {
|
|
501
|
-
createDebug.skips.push(new RegExp('^' + namespaces.
|
|
501
|
+
createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
|
|
502
502
|
} else {
|
|
503
503
|
createDebug.names.push(new RegExp('^' + namespaces + '$'));
|
|
504
504
|
}
|
|
@@ -1394,7 +1394,7 @@ const schemeRegex = /^[\w+.-]+:\/\//;
|
|
|
1394
1394
|
* 4. Port, including ":", optional.
|
|
1395
1395
|
* 5. Path, including "/", optional.
|
|
1396
1396
|
*/
|
|
1397
|
-
const urlRegex = /^([\w+.-]+:)\/\/([
|
|
1397
|
+
const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?/;
|
|
1398
1398
|
function isAbsoluteUrl(input) {
|
|
1399
1399
|
return schemeRegex.test(input);
|
|
1400
1400
|
}
|
|
@@ -2482,6 +2482,24 @@ async function processSrcSet(srcs, replacer) {
|
|
|
2482
2482
|
url + ` ${descriptor}${index === ret.length - 1 ? '' : ', '}`);
|
|
2483
2483
|
}, '');
|
|
2484
2484
|
}
|
|
2485
|
+
function escapeToLinuxLikePath(path) {
|
|
2486
|
+
if (/^[A-Z]:/.test(path)) {
|
|
2487
|
+
return path.replace(/^([A-Z]):\//, '/windows/$1/');
|
|
2488
|
+
}
|
|
2489
|
+
if (/^\/[^/]/.test(path)) {
|
|
2490
|
+
return `/linux${path}`;
|
|
2491
|
+
}
|
|
2492
|
+
return path;
|
|
2493
|
+
}
|
|
2494
|
+
function unescapeToLinuxLikePath(path) {
|
|
2495
|
+
if (path.startsWith('/linux/')) {
|
|
2496
|
+
return path.slice('/linux'.length);
|
|
2497
|
+
}
|
|
2498
|
+
if (path.startsWith('/windows/')) {
|
|
2499
|
+
return path.replace(/^\/windows\/([A-Z])\//, '$1:/');
|
|
2500
|
+
}
|
|
2501
|
+
return path;
|
|
2502
|
+
}
|
|
2485
2503
|
// based on https://github.com/sveltejs/svelte/blob/abf11bb02b2afbd3e4cac509a0f70e318c306364/src/compiler/utils/mapped_code.ts#L221
|
|
2486
2504
|
const nullSourceMap = {
|
|
2487
2505
|
names: [],
|
|
@@ -2494,6 +2512,18 @@ function combineSourcemaps(filename, sourcemapList) {
|
|
|
2494
2512
|
sourcemapList.every((m) => m.sources.length === 0)) {
|
|
2495
2513
|
return { ...nullSourceMap };
|
|
2496
2514
|
}
|
|
2515
|
+
// hack for parse broken with normalized absolute paths on windows (C:/path/to/something).
|
|
2516
|
+
// escape them to linux like paths
|
|
2517
|
+
// also avoid mutation here to prevent breaking plugin's using cache to generate sourcemaps like vue (see #7442)
|
|
2518
|
+
sourcemapList = sourcemapList.map((sourcemap) => {
|
|
2519
|
+
const newSourcemaps = { ...sourcemap };
|
|
2520
|
+
newSourcemaps.sources = sourcemap.sources.map((source) => source ? escapeToLinuxLikePath(source) : null);
|
|
2521
|
+
if (sourcemap.sourceRoot) {
|
|
2522
|
+
newSourcemaps.sourceRoot = escapeToLinuxLikePath(sourcemap.sourceRoot);
|
|
2523
|
+
}
|
|
2524
|
+
return newSourcemaps;
|
|
2525
|
+
});
|
|
2526
|
+
const escapedFilename = escapeToLinuxLikePath(filename);
|
|
2497
2527
|
// We don't declare type here so we can convert/fake/map as RawSourceMap
|
|
2498
2528
|
let map; //: SourceMap
|
|
2499
2529
|
let mapIndex = 1;
|
|
@@ -2503,17 +2533,20 @@ function combineSourcemaps(filename, sourcemapList) {
|
|
|
2503
2533
|
}
|
|
2504
2534
|
else {
|
|
2505
2535
|
map = remapping(sourcemapList[0], function loader(sourcefile) {
|
|
2506
|
-
if (sourcefile ===
|
|
2536
|
+
if (sourcefile === escapedFilename && sourcemapList[mapIndex]) {
|
|
2507
2537
|
return sourcemapList[mapIndex++];
|
|
2508
2538
|
}
|
|
2509
2539
|
else {
|
|
2510
|
-
return
|
|
2540
|
+
return null;
|
|
2511
2541
|
}
|
|
2512
2542
|
}, true);
|
|
2513
2543
|
}
|
|
2514
2544
|
if (!map.file) {
|
|
2515
2545
|
delete map.file;
|
|
2516
2546
|
}
|
|
2547
|
+
// unescape the previous hack
|
|
2548
|
+
map.sources = map.sources.map((source) => source ? unescapeToLinuxLikePath(source) : source);
|
|
2549
|
+
map.file = filename;
|
|
2517
2550
|
return map;
|
|
2518
2551
|
}
|
|
2519
2552
|
function resolveHostname(optionsHost) {
|
|
@@ -4478,7 +4511,9 @@ function assetPlugin(config) {
|
|
|
4478
4511
|
const file = getAssetFilename(hash, config) || this.getFileName(hash);
|
|
4479
4512
|
chunk.viteMetadata.importedAssets.add(cleanUrl(file));
|
|
4480
4513
|
const outputFilepath = config.base + file + postfix;
|
|
4481
|
-
s.overwrite(match.index, match.index + full.length, outputFilepath
|
|
4514
|
+
s.overwrite(match.index, match.index + full.length, outputFilepath, {
|
|
4515
|
+
contentOnly: true
|
|
4516
|
+
});
|
|
4482
4517
|
}
|
|
4483
4518
|
if (s) {
|
|
4484
4519
|
return {
|
|
@@ -18546,6 +18581,64 @@ const dataToEsm = function dataToEsm(data, options = {}) {
|
|
|
18546
18581
|
return `${namedExportCode}export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
|
|
18547
18582
|
};
|
|
18548
18583
|
|
|
18584
|
+
const isDebug$6 = !!process.env.DEBUG;
|
|
18585
|
+
const debug$f = createDebugger('vite:sourcemap', {
|
|
18586
|
+
onlyWhenFocused: true
|
|
18587
|
+
});
|
|
18588
|
+
// Virtual modules should be prefixed with a null byte to avoid a
|
|
18589
|
+
// false positive "missing source" warning. We also check for certain
|
|
18590
|
+
// prefixes used for special handling in esbuildDepPlugin.
|
|
18591
|
+
const virtualSourceRE = /^(\0|dep:|browser-external:)/;
|
|
18592
|
+
async function injectSourcesContent(map, file, logger) {
|
|
18593
|
+
let sourceRoot;
|
|
18594
|
+
try {
|
|
18595
|
+
// The source root is undefined for virtual modules and permission errors.
|
|
18596
|
+
sourceRoot = await fs$n.promises.realpath(path__default.resolve(path__default.dirname(file), map.sourceRoot || ''));
|
|
18597
|
+
}
|
|
18598
|
+
catch { }
|
|
18599
|
+
const missingSources = [];
|
|
18600
|
+
map.sourcesContent = await Promise.all(map.sources.map((sourcePath) => {
|
|
18601
|
+
if (sourcePath && !virtualSourceRE.test(sourcePath)) {
|
|
18602
|
+
sourcePath = decodeURI(sourcePath);
|
|
18603
|
+
if (sourceRoot) {
|
|
18604
|
+
sourcePath = path__default.resolve(sourceRoot, sourcePath);
|
|
18605
|
+
}
|
|
18606
|
+
return fs$n.promises.readFile(sourcePath, 'utf-8').catch(() => {
|
|
18607
|
+
if (maybeVirtualHtmlSet.has(normalizePath$4(sourcePath)))
|
|
18608
|
+
return null;
|
|
18609
|
+
missingSources.push(sourcePath);
|
|
18610
|
+
return null;
|
|
18611
|
+
});
|
|
18612
|
+
}
|
|
18613
|
+
return null;
|
|
18614
|
+
}));
|
|
18615
|
+
// Use this command…
|
|
18616
|
+
// DEBUG="vite:sourcemap" vite build
|
|
18617
|
+
// …to log the missing sources.
|
|
18618
|
+
if (missingSources.length) {
|
|
18619
|
+
logger.warnOnce(`Sourcemap for "${file}" points to missing source files`);
|
|
18620
|
+
isDebug$6 && debug$f(`Missing sources:\n ` + missingSources.join(`\n `));
|
|
18621
|
+
}
|
|
18622
|
+
}
|
|
18623
|
+
function genSourceMapUrl(map) {
|
|
18624
|
+
if (typeof map !== 'string') {
|
|
18625
|
+
map = JSON.stringify(map);
|
|
18626
|
+
}
|
|
18627
|
+
return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
|
|
18628
|
+
}
|
|
18629
|
+
function getCodeWithSourcemap(type, code, map) {
|
|
18630
|
+
if (isDebug$6) {
|
|
18631
|
+
code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
|
|
18632
|
+
}
|
|
18633
|
+
if (type === 'js') {
|
|
18634
|
+
code += `\n//# sourceMappingURL=${genSourceMapUrl(map !== null && map !== void 0 ? map : undefined)}`;
|
|
18635
|
+
}
|
|
18636
|
+
else if (type === 'css') {
|
|
18637
|
+
code += `\n/*# sourceMappingURL=${genSourceMapUrl(map !== null && map !== void 0 ? map : undefined)} */`;
|
|
18638
|
+
}
|
|
18639
|
+
return code;
|
|
18640
|
+
}
|
|
18641
|
+
|
|
18549
18642
|
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
18550
18643
|
const cssLangRE = new RegExp(cssLangs);
|
|
18551
18644
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
@@ -18600,7 +18693,7 @@ function cssPlugin(config) {
|
|
|
18600
18693
|
}
|
|
18601
18694
|
return url;
|
|
18602
18695
|
};
|
|
18603
|
-
const { code: css, modules, deps } = await compileCSS(id, raw, config, urlReplacer, atImportResolvers, server);
|
|
18696
|
+
const { code: css, modules, deps, map } = await compileCSS(id, raw, config, urlReplacer, atImportResolvers, server);
|
|
18604
18697
|
if (modules) {
|
|
18605
18698
|
moduleCache.set(id, modules);
|
|
18606
18699
|
}
|
|
@@ -18642,8 +18735,7 @@ function cssPlugin(config) {
|
|
|
18642
18735
|
}
|
|
18643
18736
|
return {
|
|
18644
18737
|
code: css,
|
|
18645
|
-
|
|
18646
|
-
map: { mappings: '' }
|
|
18738
|
+
map
|
|
18647
18739
|
};
|
|
18648
18740
|
}
|
|
18649
18741
|
};
|
|
@@ -18686,10 +18778,13 @@ function cssPostPlugin(config) {
|
|
|
18686
18778
|
if (inlined) {
|
|
18687
18779
|
return `export default ${JSON.stringify(css)}`;
|
|
18688
18780
|
}
|
|
18781
|
+
const sourcemap = this.getCombinedSourcemap();
|
|
18782
|
+
await injectSourcesContent(sourcemap, cleanUrl(id), config.logger);
|
|
18783
|
+
const cssContent = getCodeWithSourcemap('css', css, sourcemap);
|
|
18689
18784
|
return [
|
|
18690
18785
|
`import { updateStyle as __vite__updateStyle, removeStyle as __vite__removeStyle } from ${JSON.stringify(path__default.posix.join(config.base, CLIENT_PUBLIC_PATH))}`,
|
|
18691
18786
|
`const __vite__id = ${JSON.stringify(id)}`,
|
|
18692
|
-
`const __vite__css = ${JSON.stringify(
|
|
18787
|
+
`const __vite__css = ${JSON.stringify(cssContent)}`,
|
|
18693
18788
|
`__vite__updateStyle(__vite__id, __vite__css)`,
|
|
18694
18789
|
// css modules exports change on edit so it can't self accept
|
|
18695
18790
|
`${modulesCode ||
|
|
@@ -18928,9 +19023,9 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
18928
19023
|
!isModule &&
|
|
18929
19024
|
!needInlineImport &&
|
|
18930
19025
|
!hasUrl) {
|
|
18931
|
-
return { code };
|
|
19026
|
+
return { code, map: null };
|
|
18932
19027
|
}
|
|
18933
|
-
let
|
|
19028
|
+
let preprocessorMap;
|
|
18934
19029
|
let modules;
|
|
18935
19030
|
const deps = new Set();
|
|
18936
19031
|
// 2. pre-processors: sass etc.
|
|
@@ -18963,7 +19058,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
18963
19058
|
throw preprocessResult.errors[0];
|
|
18964
19059
|
}
|
|
18965
19060
|
code = preprocessResult.code;
|
|
18966
|
-
|
|
19061
|
+
preprocessorMap = combineSourcemapsIfExists(opts.filename, preprocessResult.map, preprocessResult.additionalMap);
|
|
18967
19062
|
if (preprocessResult.deps) {
|
|
18968
19063
|
preprocessResult.deps.forEach((dep) => {
|
|
18969
19064
|
// sometimes sass registers the file itself as a dep
|
|
@@ -18996,7 +19091,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
18996
19091
|
replacer: urlReplacer
|
|
18997
19092
|
}));
|
|
18998
19093
|
if (isModule) {
|
|
18999
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
19094
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-c9843b31.js'); }).then(function (n) { return n.index; })).default({
|
|
19000
19095
|
...modulesOptions,
|
|
19001
19096
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
19002
19097
|
modules = _modules;
|
|
@@ -19018,7 +19113,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
19018
19113
|
if (!postcssPlugins.length) {
|
|
19019
19114
|
return {
|
|
19020
19115
|
code,
|
|
19021
|
-
map
|
|
19116
|
+
map: preprocessorMap
|
|
19022
19117
|
};
|
|
19023
19118
|
}
|
|
19024
19119
|
// postcss is an unbundled dep and should be lazy imported
|
|
@@ -19026,12 +19121,14 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
19026
19121
|
.default(postcssPlugins)
|
|
19027
19122
|
.process(code, {
|
|
19028
19123
|
...postcssOptions,
|
|
19029
|
-
to: id,
|
|
19030
|
-
from: id,
|
|
19124
|
+
to: cleanUrl(id),
|
|
19125
|
+
from: cleanUrl(id),
|
|
19031
19126
|
map: {
|
|
19032
19127
|
inline: false,
|
|
19033
19128
|
annotation: false,
|
|
19034
|
-
|
|
19129
|
+
sourcesContent: false
|
|
19130
|
+
// when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
|
|
19131
|
+
// prev: preprocessorMap,
|
|
19035
19132
|
}
|
|
19036
19133
|
});
|
|
19037
19134
|
// record CSS dependencies from @imports
|
|
@@ -19074,14 +19171,46 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
19074
19171
|
config.logger.warn(colors$1.yellow(msg));
|
|
19075
19172
|
}
|
|
19076
19173
|
}
|
|
19174
|
+
const rawPostcssMap = postcssResult.map.toJSON();
|
|
19175
|
+
const postcssMap = formatPostcssSourceMap(
|
|
19176
|
+
// version property of rawPostcssMap is declared as string
|
|
19177
|
+
// but actually it is a number
|
|
19178
|
+
rawPostcssMap, cleanUrl(id));
|
|
19077
19179
|
return {
|
|
19078
19180
|
ast: postcssResult,
|
|
19079
19181
|
code: postcssResult.css,
|
|
19080
|
-
map:
|
|
19182
|
+
map: combineSourcemapsIfExists(cleanUrl(id), postcssMap, preprocessorMap),
|
|
19081
19183
|
modules,
|
|
19082
19184
|
deps
|
|
19083
19185
|
};
|
|
19084
19186
|
}
|
|
19187
|
+
function formatPostcssSourceMap(rawMap, file) {
|
|
19188
|
+
const inputFileDir = path__default.dirname(file);
|
|
19189
|
+
const sources = rawMap.sources
|
|
19190
|
+
// remove <no source> from sources, to prevent source map to be combined incorrectly
|
|
19191
|
+
.filter((source) => source !== '<no source>')
|
|
19192
|
+
.map((source) => {
|
|
19193
|
+
const cleanSource = cleanUrl(decodeURIComponent(source));
|
|
19194
|
+
return normalizePath$4(path__default.resolve(inputFileDir, cleanSource));
|
|
19195
|
+
});
|
|
19196
|
+
return {
|
|
19197
|
+
file,
|
|
19198
|
+
mappings: rawMap.mappings,
|
|
19199
|
+
names: rawMap.names,
|
|
19200
|
+
sources,
|
|
19201
|
+
version: rawMap.version
|
|
19202
|
+
};
|
|
19203
|
+
}
|
|
19204
|
+
function combineSourcemapsIfExists(filename, map1, map2) {
|
|
19205
|
+
return map1 && map2
|
|
19206
|
+
? combineSourcemaps(filename, [
|
|
19207
|
+
// type of version property of ExistingRawSourceMap is number
|
|
19208
|
+
// but it is always 3
|
|
19209
|
+
map1,
|
|
19210
|
+
map2
|
|
19211
|
+
])
|
|
19212
|
+
: map1;
|
|
19213
|
+
}
|
|
19085
19214
|
async function resolvePostcssConfig(config) {
|
|
19086
19215
|
var _a;
|
|
19087
19216
|
let result = postcssConfigCache.get(config);
|
|
@@ -19271,12 +19400,16 @@ const scss = async (source, root, options, resolvers) => {
|
|
|
19271
19400
|
? importer.push(...options.importer)
|
|
19272
19401
|
: importer.push(options.importer);
|
|
19273
19402
|
}
|
|
19403
|
+
const { content: data, map: additionalMap } = await getSource(source, options.filename, options.additionalData);
|
|
19274
19404
|
const finalOptions = {
|
|
19275
19405
|
...options,
|
|
19276
|
-
data
|
|
19406
|
+
data,
|
|
19277
19407
|
file: options.filename,
|
|
19278
19408
|
outFile: options.filename,
|
|
19279
|
-
importer
|
|
19409
|
+
importer,
|
|
19410
|
+
sourceMap: true,
|
|
19411
|
+
omitSourceMapUrl: true,
|
|
19412
|
+
sourceMapRoot: path__default.dirname(options.filename)
|
|
19280
19413
|
};
|
|
19281
19414
|
try {
|
|
19282
19415
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -19290,8 +19423,13 @@ const scss = async (source, root, options, resolvers) => {
|
|
|
19290
19423
|
});
|
|
19291
19424
|
});
|
|
19292
19425
|
const deps = result.stats.includedFiles;
|
|
19426
|
+
const map = result.map
|
|
19427
|
+
? JSON.parse(result.map.toString())
|
|
19428
|
+
: undefined;
|
|
19293
19429
|
return {
|
|
19294
19430
|
code: result.css.toString(),
|
|
19431
|
+
map,
|
|
19432
|
+
additionalMap,
|
|
19295
19433
|
errors: [],
|
|
19296
19434
|
deps
|
|
19297
19435
|
};
|
|
@@ -19358,12 +19496,16 @@ async function rebaseUrls(file, rootFile, alias) {
|
|
|
19358
19496
|
const less = async (source, root, options, resolvers) => {
|
|
19359
19497
|
const nodeLess = loadPreprocessor("less" /* less */, root);
|
|
19360
19498
|
const viteResolverPlugin = createViteLessPlugin(nodeLess, options.filename, options.alias, resolvers);
|
|
19361
|
-
|
|
19499
|
+
const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData);
|
|
19362
19500
|
let result;
|
|
19363
19501
|
try {
|
|
19364
|
-
result = await nodeLess.render(
|
|
19502
|
+
result = await nodeLess.render(content, {
|
|
19365
19503
|
...options,
|
|
19366
|
-
plugins: [viteResolverPlugin, ...(options.plugins || [])]
|
|
19504
|
+
plugins: [viteResolverPlugin, ...(options.plugins || [])],
|
|
19505
|
+
sourceMap: {
|
|
19506
|
+
outputSourceFiles: true,
|
|
19507
|
+
sourceMapFileInline: false
|
|
19508
|
+
}
|
|
19367
19509
|
});
|
|
19368
19510
|
}
|
|
19369
19511
|
catch (e) {
|
|
@@ -19377,8 +19519,14 @@ const less = async (source, root, options, resolvers) => {
|
|
|
19377
19519
|
};
|
|
19378
19520
|
return { code: '', errors: [normalizedError], deps: [] };
|
|
19379
19521
|
}
|
|
19522
|
+
const map = result.map && JSON.parse(result.map);
|
|
19523
|
+
if (map) {
|
|
19524
|
+
delete map.sourcesContent;
|
|
19525
|
+
}
|
|
19380
19526
|
return {
|
|
19381
19527
|
code: result.css.toString(),
|
|
19528
|
+
map,
|
|
19529
|
+
additionalMap,
|
|
19382
19530
|
deps: result.imports,
|
|
19383
19531
|
errors: []
|
|
19384
19532
|
};
|
|
@@ -19437,29 +19585,63 @@ const styl = async (source, root, options) => {
|
|
|
19437
19585
|
const nodeStylus = loadPreprocessor("stylus" /* stylus */, root);
|
|
19438
19586
|
// Get source with preprocessor options.additionalData. Make sure a new line separator
|
|
19439
19587
|
// is added to avoid any render error, as added stylus content may not have semi-colon separators
|
|
19440
|
-
|
|
19588
|
+
const { content, map: additionalMap } = await getSource(source, options.filename, options.additionalData, '\n');
|
|
19441
19589
|
// Get preprocessor options.imports dependencies as stylus
|
|
19442
19590
|
// does not return them with its builtin `.deps()` method
|
|
19443
19591
|
const importsDeps = ((_a = options.imports) !== null && _a !== void 0 ? _a : []).map((dep) => path__default.resolve(dep));
|
|
19444
19592
|
try {
|
|
19445
|
-
const ref = nodeStylus(
|
|
19446
|
-
|
|
19593
|
+
const ref = nodeStylus(content, options);
|
|
19594
|
+
ref.set('sourcemap', {
|
|
19595
|
+
comment: false,
|
|
19596
|
+
inline: false,
|
|
19597
|
+
basePath: root
|
|
19598
|
+
});
|
|
19447
19599
|
const result = ref.render();
|
|
19448
19600
|
// Concat imports deps with computed deps
|
|
19449
19601
|
const deps = [...ref.deps(), ...importsDeps];
|
|
19450
|
-
|
|
19602
|
+
// @ts-expect-error sourcemap exists
|
|
19603
|
+
const map = ref.sourcemap;
|
|
19604
|
+
return {
|
|
19605
|
+
code: result,
|
|
19606
|
+
map: formatStylusSourceMap(map, root),
|
|
19607
|
+
additionalMap,
|
|
19608
|
+
errors: [],
|
|
19609
|
+
deps
|
|
19610
|
+
};
|
|
19451
19611
|
}
|
|
19452
19612
|
catch (e) {
|
|
19453
19613
|
return { code: '', errors: [e], deps: [] };
|
|
19454
19614
|
}
|
|
19455
19615
|
};
|
|
19456
|
-
function
|
|
19616
|
+
function formatStylusSourceMap(mapBefore, root) {
|
|
19617
|
+
const map = { ...mapBefore };
|
|
19618
|
+
const resolveFromRoot = (p) => normalizePath$4(path__default.resolve(root, p));
|
|
19619
|
+
if (map.file) {
|
|
19620
|
+
map.file = resolveFromRoot(map.file);
|
|
19621
|
+
}
|
|
19622
|
+
map.sources = map.sources.map(resolveFromRoot);
|
|
19623
|
+
return map;
|
|
19624
|
+
}
|
|
19625
|
+
async function getSource(source, filename, additionalData, sep = '') {
|
|
19457
19626
|
if (!additionalData)
|
|
19458
|
-
return source;
|
|
19627
|
+
return { content: source };
|
|
19459
19628
|
if (typeof additionalData === 'function') {
|
|
19460
|
-
|
|
19461
|
-
|
|
19462
|
-
|
|
19629
|
+
const newContent = await additionalData(source, filename);
|
|
19630
|
+
if (typeof newContent === 'string') {
|
|
19631
|
+
return { content: newContent };
|
|
19632
|
+
}
|
|
19633
|
+
return newContent;
|
|
19634
|
+
}
|
|
19635
|
+
const ms = new MagicString$1(source);
|
|
19636
|
+
ms.appendLeft(0, sep);
|
|
19637
|
+
ms.appendLeft(0, additionalData);
|
|
19638
|
+
const map = ms.generateMap({ hires: true });
|
|
19639
|
+
map.file = filename;
|
|
19640
|
+
map.sources = [filename];
|
|
19641
|
+
return {
|
|
19642
|
+
content: ms.toString(),
|
|
19643
|
+
map
|
|
19644
|
+
};
|
|
19463
19645
|
}
|
|
19464
19646
|
const preProcessors = Object.freeze({
|
|
19465
19647
|
["less" /* less */]: less,
|
|
@@ -19472,7 +19654,7 @@ function isPreProcessor(lang) {
|
|
|
19472
19654
|
return lang && lang in preProcessors;
|
|
19473
19655
|
}
|
|
19474
19656
|
|
|
19475
|
-
/* es-module-lexer 0.10.
|
|
19657
|
+
/* es-module-lexer 0.10.1 */
|
|
19476
19658
|
const A=1===new Uint8Array(new Uint16Array([1]).buffer)[0];function parse$f(E,g="@"){if(!C)return init.then(()=>parse$f(E));const I=E.length+1,o=(C.__heap_base.value||C.__heap_base)+4*I-C.memory.buffer.byteLength;o>0&&C.memory.grow(Math.ceil(o/65536));const k=C.sa(I-1);if((A?B:Q)(E,new Uint16Array(C.memory.buffer,k,I)),!C.parse())throw Object.assign(new Error(`Parse error ${g}:${E.slice(0,C.e()).split("\n").length}:${C.e()-E.lastIndexOf("\n",C.e()-1)}`),{idx:C.e()});const J=[],i=[];for(;C.ri();){const A=C.is(),Q=C.ie(),B=C.ai(),g=C.id(),I=C.ss(),o=C.se();let k;C.ip()&&(k=w(E.slice(-1===g?A-1:A,-1===g?Q+1:Q))),J.push({n:k,s:A,e:Q,ss:I,se:o,d:g,a:B});}for(;C.re();){const A=E.slice(C.es(),C.ee()),Q=A[0];i.push('"'===Q||"'"===Q?w(A):A);}function w(A){try{return (0, eval)(A)}catch(A){}}return [J,i,!!C.f()]}function Q(A,Q){const B=A.length;let C=0;for(;C<B;){const B=A.charCodeAt(C);Q[C++]=(255&B)<<8|B>>>8;}}function B(A,Q){const B=A.length;let C=0;for(;C<B;)Q[C]=A.charCodeAt(C++);}let C;const init=WebAssembly.compile((E="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ajYCiApBARAhIQMLQQAoAogKIQICQCADQf0ARg0AIAIgAUYNBSACIQEgAkEAKAKMCk0NAQwFCwtBACACQQJqNgKICgwBC0EAIANBAmo2AogKQQEQIRpBACgCiAoiAiACECYaC0EBECEhAgtBACgCiAohAwJAIAJB5gBHDQAgA0ECakGeCEEGECgNAEEAIANBCGo2AogKIABBARAhECIPC0EAIANBfmo2AogKDAMLEB0PCwJAIAMpAAJC7ICEg7COwDlSDQAgAy8BChAeRQ0AQQAgA0EKajYCiApBARAhIQJBACgCiAohAyACECQaIANBACgCiAoQAkEAQQAoAogKQX5qNgKICg8LQQAgA0EEaiIDNgKICgtBACADQQRqIgI2AogKQQBBADoA5AkDQEEAIAJBAmo2AogKQQEQISEDQQAoAogKIQICQCADECRBIHJB+wBHDQBBAEEAKAKICkF+ajYCiAoPC0EAKAKICiIDIAJGDQEgAiADEAICQEEBECEiAkEsRg0AAkAgAkE9Rw0AQQBBACgCiApBfmo2AogKDwtBAEEAKAKICkF+ajYCiAoPC0EAKAKICiECDAALCw8LQQAgA0EKajYCiApBARAhGkEAKAKICiEDC0EAIANBEGo2AogKAkBBARAhIgJBKkcNAEEAQQAoAogKQQJqNgKICkEBECEhAgtBACgCiAohAyACECQaIANBACgCiAoQAkEAQQAoAogKQX5qNgKICg8LIAMgA0EOahACC6sGAQR/QQBBACgCiAoiAEEMaiIBNgKICgJAAkACQAJAAkACQAJAAkACQAJAQQEQISICQVlqDggCCAECAQEBBwALIAJBIkYNASACQfsARg0CC0EAKAKICiABRg0HC0EALwHqCQ0BQQAoAogKIQJBACgCjAohAwNAIAIgA08NBAJAAkAgAi8BACIBQSdGDQAgAUEiRw0BCyAAIAEQIg8LQQAgAkECaiICNgKICgwACwtBACgCiAohAkEALwHqCQ0BAkADQAJAAkACQCACQQAoAowKTw0AQQEQISICQSJGDQEgAkEnRg0BIAJB/QBHDQJBAEEAKAKICkECajYCiAoLQQEQIRpBACgCiAoiAikAAELmgMiD8I3ANlINBkEAIAJBCGo2AogKQQEQISICQSJGDQMgAkEnRg0DDAYLIAIQFwtBAEEAKAKICkECaiICNgKICgwACwsgACACECIMBQtBAEEAKAKICkF+ajYCiAoPC0EAIAJBfmo2AogKDwsQHQ8LQQBBACgCiApBAmo2AogKQQEQIUHtAEcNAUEAKAKICiICQQJqQZYIQQYQKA0BQQAoAvAJLwEAQS5GDQEgACAAIAJBCGpBACgCqAkQAQ8LQQAoAvwJQQAvAeoJIgJBAnRqQQAoAogKNgIAQQAgAkEBajsB6glBACgC8AkvAQBBLkYNAEEAQQAoAogKIgFBAmo2AogKQQEQISECIABBACgCiApBACABEAFBAEEALwHoCSIBQQFqOwHoCUEAKAKACiABQQJ0akEAKALECTYCAAJAIAJBIkYNACACQSdGDQBBAEEAKAKICkF+ajYCiAoPCyACEBdBAEEAKAKICkECaiICNgKICgJAAkACQEEBECFBV2oOBAECAgACC0EAQQAoAogKQQJqNgKICkEBECEaQQAoAsQJIgEgAjYCBCABQQE6ABggAUEAKAKICiICNgIQQQAgAkF+ajYCiAoPC0EAKALECSIBIAI2AgQgAUEBOgAYQQBBAC8B6glBf2o7AeoJIAFBACgCiApBAmo2AgxBAEEALwHoCUF/ajsB6AkPC0EAQQAoAogKQX5qNgKICg8LC0cBA39BACgCiApBAmohAEEAKAKMCiEBAkADQCAAIgJBfmogAU8NASACQQJqIQAgAi8BAEF2ag4EAQAAAQALC0EAIAI2AogKC5gBAQN/QQBBACgCiAoiAUECajYCiAogAUEGaiEBQQAoAowKIQIDQAJAAkACQCABQXxqIAJPDQAgAUF+ai8BACEDAkACQCAADQAgA0EqRg0BIANBdmoOBAIEBAIECyADQSpHDQMLIAEvAQBBL0cNAkEAIAFBfmo2AogKDAELIAFBfmohAQtBACABNgKICg8LIAFBAmohAQwACwu/AQEEf0EAKAKICiEAQQAoAowKIQECQAJAA0AgACICQQJqIQAgAiABTw0BAkACQCAALwEAIgNBpH9qDgUBAgICBAALIANBJEcNASACLwEEQfsARw0BQQBBAC8B5gkiAEEBajsB5glBACgC+AkgAEEBdGpBAC8B7Ak7AQBBACACQQRqNgKICkEAQQAvAeoJQQFqIgA7AewJQQAgADsB6gkPCyACQQRqIQAMAAsLQQAgADYCiAoQHQ8LQQAgADYCiAoL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","undefined"!=typeof Buffer?Buffer.from(E,"base64"):Uint8Array.from(atob(E),A=>A.charCodeAt(0)))).then(WebAssembly.instantiate).then(({exports:A})=>{C=A;});var E;
|
|
19477
19659
|
|
|
19478
19660
|
// This is a generated file. Do not edit.
|
|
@@ -21166,7 +21348,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21166
21348
|
source.slice(end, end + 5) === '.glob') {
|
|
21167
21349
|
const { importsString, exp, endIndex, isEager } = await transformImportGlob(source, start, importer, index, config.root, config.logger, undefined, resolve, insertPreload);
|
|
21168
21350
|
str().prepend(importsString);
|
|
21169
|
-
str().overwrite(expStart, endIndex, exp);
|
|
21351
|
+
str().overwrite(expStart, endIndex, exp, { contentOnly: true });
|
|
21170
21352
|
if (!isEager) {
|
|
21171
21353
|
needPreloadHelper = true;
|
|
21172
21354
|
}
|
|
@@ -21176,7 +21358,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21176
21358
|
needPreloadHelper = true;
|
|
21177
21359
|
const original = source.slice(expStart, expEnd);
|
|
21178
21360
|
const replacement = `${preloadMethod}(() => ${original},${isModernFlag}?"${preloadMarker}":void 0)`;
|
|
21179
|
-
str().overwrite(expStart, expEnd, replacement);
|
|
21361
|
+
str().overwrite(expStart, expEnd, replacement, { contentOnly: true });
|
|
21180
21362
|
}
|
|
21181
21363
|
// Differentiate CSS imports that use the default export from those that
|
|
21182
21364
|
// do not by injecting a ?used query - this allows us to avoid including
|
|
@@ -21188,7 +21370,9 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21188
21370
|
// edge case for package names ending with .css (e.g normalize.css)
|
|
21189
21371
|
!(bareImportRE.test(specifier) && !specifier.includes('/'))) {
|
|
21190
21372
|
const url = specifier.replace(/\?|$/, (m) => `?used${m ? '&' : ''}`);
|
|
21191
|
-
str().overwrite(start, end, dynamicIndex > -1 ? `'${url}'` : url
|
|
21373
|
+
str().overwrite(start, end, dynamicIndex > -1 ? `'${url}'` : url, {
|
|
21374
|
+
contentOnly: true
|
|
21375
|
+
});
|
|
21192
21376
|
}
|
|
21193
21377
|
}
|
|
21194
21378
|
if (needPreloadHelper &&
|
|
@@ -21212,7 +21396,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21212
21396
|
const s = new MagicString$1(code);
|
|
21213
21397
|
let match;
|
|
21214
21398
|
while ((match = re.exec(code))) {
|
|
21215
|
-
s.overwrite(match.index, match.index + isModernFlag.length, isModern);
|
|
21399
|
+
s.overwrite(match.index, match.index + isModernFlag.length, isModern, { contentOnly: true });
|
|
21216
21400
|
}
|
|
21217
21401
|
return {
|
|
21218
21402
|
code: s.toString(),
|
|
@@ -21284,7 +21468,9 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21284
21468
|
});
|
|
21285
21469
|
hasRemovedPureCssChunk = true;
|
|
21286
21470
|
}
|
|
21287
|
-
s.overwrite(expStart, expEnd, 'Promise.resolve({})'
|
|
21471
|
+
s.overwrite(expStart, expEnd, 'Promise.resolve({})', {
|
|
21472
|
+
contentOnly: true
|
|
21473
|
+
});
|
|
21288
21474
|
}
|
|
21289
21475
|
}
|
|
21290
21476
|
};
|
|
@@ -21304,7 +21490,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
21304
21490
|
// main chunk is removed
|
|
21305
21491
|
(hasRemovedPureCssChunk && deps.size > 0)
|
|
21306
21492
|
? `[${[...deps].map((d) => JSON.stringify(d)).join(',')}]`
|
|
21307
|
-
: `[]
|
|
21493
|
+
: `[]`, { contentOnly: true });
|
|
21308
21494
|
}
|
|
21309
21495
|
}
|
|
21310
21496
|
chunk.code = s.toString();
|
|
@@ -21419,7 +21605,7 @@ function htmlInlineProxyPlugin(config) {
|
|
|
21419
21605
|
const file = cleanUrl(id);
|
|
21420
21606
|
const url = file.replace(normalizePath$4(config.root), '');
|
|
21421
21607
|
const result = htmlProxyMap.get(config).get(url)[index];
|
|
21422
|
-
if (
|
|
21608
|
+
if (result) {
|
|
21423
21609
|
return result;
|
|
21424
21610
|
}
|
|
21425
21611
|
else {
|
|
@@ -21429,14 +21615,14 @@ function htmlInlineProxyPlugin(config) {
|
|
|
21429
21615
|
}
|
|
21430
21616
|
};
|
|
21431
21617
|
}
|
|
21432
|
-
function addToHTMLProxyCache(config, filePath, index,
|
|
21618
|
+
function addToHTMLProxyCache(config, filePath, index, result) {
|
|
21433
21619
|
if (!htmlProxyMap.get(config)) {
|
|
21434
21620
|
htmlProxyMap.set(config, new Map());
|
|
21435
21621
|
}
|
|
21436
21622
|
if (!htmlProxyMap.get(config).get(filePath)) {
|
|
21437
21623
|
htmlProxyMap.get(config).set(filePath, []);
|
|
21438
21624
|
}
|
|
21439
|
-
htmlProxyMap.get(config).get(filePath)[index] =
|
|
21625
|
+
htmlProxyMap.get(config).get(filePath)[index] = result;
|
|
21440
21626
|
}
|
|
21441
21627
|
function addToHTMLProxyTransformResult(hash, code) {
|
|
21442
21628
|
htmlProxyResult.set(hash, code);
|
|
@@ -21453,7 +21639,7 @@ const assetAttrsConfig = {
|
|
|
21453
21639
|
const isAsyncScriptMap = new WeakMap();
|
|
21454
21640
|
async function traverseHtml(html, filePath, visitor) {
|
|
21455
21641
|
// lazy load compiler
|
|
21456
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
21642
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-57c89c81.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
21457
21643
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
21458
21644
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
21459
21645
|
try {
|
|
@@ -21552,7 +21738,7 @@ function buildHtmlPlugin(config) {
|
|
|
21552
21738
|
const isPublicFile = !!(url && checkPublicFile(url, config));
|
|
21553
21739
|
if (isPublicFile) {
|
|
21554
21740
|
// referencing public dir url, prefix with base
|
|
21555
|
-
s.overwrite(src.value.loc.start.offset, src.value.loc.end.offset, `"${config.base + url.slice(1)}"
|
|
21741
|
+
s.overwrite(src.value.loc.start.offset, src.value.loc.end.offset, `"${config.base + url.slice(1)}"`, { contentOnly: true });
|
|
21556
21742
|
}
|
|
21557
21743
|
if (isModule) {
|
|
21558
21744
|
inlineModuleIndex++;
|
|
@@ -21568,7 +21754,9 @@ function buildHtmlPlugin(config) {
|
|
|
21568
21754
|
.join('');
|
|
21569
21755
|
// <script type="module">...</script>
|
|
21570
21756
|
const filePath = id.replace(normalizePath$4(config.root), '');
|
|
21571
|
-
addToHTMLProxyCache(config, filePath, inlineModuleIndex,
|
|
21757
|
+
addToHTMLProxyCache(config, filePath, inlineModuleIndex, {
|
|
21758
|
+
code: contents
|
|
21759
|
+
});
|
|
21572
21760
|
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.js"`;
|
|
21573
21761
|
shouldRemove = true;
|
|
21574
21762
|
}
|
|
@@ -21615,7 +21803,7 @@ function buildHtmlPlugin(config) {
|
|
|
21615
21803
|
}
|
|
21616
21804
|
}
|
|
21617
21805
|
else if (checkPublicFile(url, config)) {
|
|
21618
|
-
s.overwrite(p.value.loc.start.offset, p.value.loc.end.offset, `"${config.base + url.slice(1)}"
|
|
21806
|
+
s.overwrite(p.value.loc.start.offset, p.value.loc.end.offset, `"${config.base + url.slice(1)}"`, { contentOnly: true });
|
|
21619
21807
|
}
|
|
21620
21808
|
}
|
|
21621
21809
|
}
|
|
@@ -21634,18 +21822,20 @@ function buildHtmlPlugin(config) {
|
|
|
21634
21822
|
const styleNode = inlineStyle.value;
|
|
21635
21823
|
const code = styleNode.content;
|
|
21636
21824
|
const filePath = id.replace(normalizePath$4(config.root), '');
|
|
21637
|
-
addToHTMLProxyCache(config, filePath, inlineModuleIndex, code);
|
|
21825
|
+
addToHTMLProxyCache(config, filePath, inlineModuleIndex, { code });
|
|
21638
21826
|
// will transform with css plugin and cache result with css-post plugin
|
|
21639
21827
|
js += `\nimport "${id}?html-proxy&inline-css&index=${inlineModuleIndex}.css"`;
|
|
21640
21828
|
// will transfrom in `applyHtmlTransforms`
|
|
21641
|
-
s.overwrite(styleNode.loc.start.offset, styleNode.loc.end.offset, `"__VITE_INLINE_CSS__${cleanUrl(id)}_${inlineModuleIndex}__"
|
|
21829
|
+
s.overwrite(styleNode.loc.start.offset, styleNode.loc.end.offset, `"__VITE_INLINE_CSS__${cleanUrl(id)}_${inlineModuleIndex}__"`, { contentOnly: true });
|
|
21642
21830
|
}
|
|
21643
21831
|
// <style>...</style>
|
|
21644
21832
|
if (node.tag === 'style' && node.children.length) {
|
|
21645
21833
|
const styleNode = node.children.pop();
|
|
21646
21834
|
const filePath = id.replace(normalizePath$4(config.root), '');
|
|
21647
21835
|
inlineModuleIndex++;
|
|
21648
|
-
addToHTMLProxyCache(config, filePath, inlineModuleIndex,
|
|
21836
|
+
addToHTMLProxyCache(config, filePath, inlineModuleIndex, {
|
|
21837
|
+
code: styleNode.content
|
|
21838
|
+
});
|
|
21649
21839
|
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.css"`;
|
|
21650
21840
|
shouldRemove = true;
|
|
21651
21841
|
}
|
|
@@ -21675,7 +21865,7 @@ function buildHtmlPlugin(config) {
|
|
|
21675
21865
|
const url = attr.name === 'srcset'
|
|
21676
21866
|
? await processSrcSet(content, ({ url }) => urlToBuiltUrl(url, id, config, this))
|
|
21677
21867
|
: await urlToBuiltUrl(content, id, config, this);
|
|
21678
|
-
s.overwrite(value.loc.start.offset, value.loc.end.offset, `"${url}"
|
|
21868
|
+
s.overwrite(value.loc.start.offset, value.loc.end.offset, `"${url}"`, { contentOnly: true });
|
|
21679
21869
|
}
|
|
21680
21870
|
catch (e) {
|
|
21681
21871
|
if (e.code !== 'ENOENT') {
|
|
@@ -21687,10 +21877,12 @@ function buildHtmlPlugin(config) {
|
|
|
21687
21877
|
// emit <script>import("./aaa")</script> asset
|
|
21688
21878
|
for (const { start, end, url } of scriptUrls) {
|
|
21689
21879
|
if (!isExcludedUrl(url)) {
|
|
21690
|
-
s.overwrite(start, end, await urlToBuiltUrl(url, id, config, this));
|
|
21880
|
+
s.overwrite(start, end, await urlToBuiltUrl(url, id, config, this), { contentOnly: true });
|
|
21691
21881
|
}
|
|
21692
21882
|
else if (checkPublicFile(url, config)) {
|
|
21693
|
-
s.overwrite(start, end, config.base + url.slice(1)
|
|
21883
|
+
s.overwrite(start, end, config.base + url.slice(1), {
|
|
21884
|
+
contentOnly: true
|
|
21885
|
+
});
|
|
21694
21886
|
}
|
|
21695
21887
|
}
|
|
21696
21888
|
processedHtml.set(id, s.toString());
|
|
@@ -21806,7 +21998,7 @@ function buildHtmlPlugin(config) {
|
|
|
21806
21998
|
s || (s = new MagicString$1(result));
|
|
21807
21999
|
const { 0: full, 1: scopedName } = match;
|
|
21808
22000
|
const cssTransformedCode = htmlProxyResult.get(scopedName);
|
|
21809
|
-
s.overwrite(match.index, match.index + full.length, cssTransformedCode);
|
|
22001
|
+
s.overwrite(match.index, match.index + full.length, cssTransformedCode, { contentOnly: true });
|
|
21810
22002
|
}
|
|
21811
22003
|
if (s) {
|
|
21812
22004
|
result = s.toString();
|
|
@@ -21853,11 +22045,13 @@ function resolveHtmlTransforms(plugins) {
|
|
|
21853
22045
|
}
|
|
21854
22046
|
return [preHooks, postHooks];
|
|
21855
22047
|
}
|
|
22048
|
+
const maybeVirtualHtmlSet = new Set();
|
|
21856
22049
|
async function applyHtmlTransforms(html, hooks, ctx) {
|
|
21857
22050
|
const headTags = [];
|
|
21858
22051
|
const headPrependTags = [];
|
|
21859
22052
|
const bodyTags = [];
|
|
21860
22053
|
const bodyPrependTags = [];
|
|
22054
|
+
maybeVirtualHtmlSet.add(ctx.filename);
|
|
21861
22055
|
for (const hook of hooks) {
|
|
21862
22056
|
const res = await hook(html, ctx);
|
|
21863
22057
|
if (!res) {
|
|
@@ -22423,11 +22617,21 @@ async function parseExtends(result, cache) {
|
|
|
22423
22617
|
}
|
|
22424
22618
|
}
|
|
22425
22619
|
function resolveExtends(extended, from) {
|
|
22620
|
+
let error;
|
|
22426
22621
|
try {
|
|
22427
22622
|
return require$$0$5.createRequire(from).resolve(extended);
|
|
22428
22623
|
} catch (e) {
|
|
22429
|
-
|
|
22624
|
+
error = e;
|
|
22430
22625
|
}
|
|
22626
|
+
if (!path__default.isAbsolute(extended) && !extended.startsWith("./") && !extended.startsWith("../")) {
|
|
22627
|
+
try {
|
|
22628
|
+
const fallbackExtended = path__default.join(extended, "tsconfig.json");
|
|
22629
|
+
return require$$0$5.createRequire(from).resolve(fallbackExtended);
|
|
22630
|
+
} catch (e) {
|
|
22631
|
+
error = e;
|
|
22632
|
+
}
|
|
22633
|
+
}
|
|
22634
|
+
throw new TSConfckParseError(`failed to resolve "extends":"${extended}" in ${from}`, "EXTENDS_RESOLVE", from, error);
|
|
22431
22635
|
}
|
|
22432
22636
|
var EXTENDABLE_KEYS = [
|
|
22433
22637
|
"compilerOptions",
|
|
@@ -22508,7 +22712,7 @@ var TSConfckParseError = class extends Error {
|
|
|
22508
22712
|
}
|
|
22509
22713
|
};
|
|
22510
22714
|
|
|
22511
|
-
const debug$
|
|
22715
|
+
const debug$e = createDebugger('vite:esbuild');
|
|
22512
22716
|
let server;
|
|
22513
22717
|
async function transformWithEsbuild(code, filename, options, inMap) {
|
|
22514
22718
|
var _a, _b, _c;
|
|
@@ -22599,7 +22803,7 @@ async function transformWithEsbuild(code, filename, options, inMap) {
|
|
|
22599
22803
|
};
|
|
22600
22804
|
}
|
|
22601
22805
|
catch (e) {
|
|
22602
|
-
debug$
|
|
22806
|
+
debug$e(`esbuild error with options used: `, resolvedOptions);
|
|
22603
22807
|
// patch error information
|
|
22604
22808
|
if (e.errors) {
|
|
22605
22809
|
e.frame = '';
|
|
@@ -30036,17 +30240,18 @@ const externalTypes = [
|
|
|
30036
30240
|
'tsx',
|
|
30037
30241
|
...KNOWN_ASSET_TYPES
|
|
30038
30242
|
];
|
|
30039
|
-
function esbuildDepPlugin(qualified, exportsData, config
|
|
30243
|
+
function esbuildDepPlugin(qualified, exportsData, config) {
|
|
30040
30244
|
// remove optimizable extensions from `externalTypes` list
|
|
30041
30245
|
const allExternalTypes = config.optimizeDeps.extensions
|
|
30042
30246
|
? externalTypes.filter((type) => { var _a; return !((_a = config.optimizeDeps.extensions) === null || _a === void 0 ? void 0 : _a.includes('.' + type)); })
|
|
30043
30247
|
: externalTypes;
|
|
30044
30248
|
// default resolver which prefers ESM
|
|
30045
|
-
const _resolve = config.createResolver({ asSrc: false });
|
|
30249
|
+
const _resolve = config.createResolver({ asSrc: false, scan: true });
|
|
30046
30250
|
// cjs resolver that prefers Node
|
|
30047
30251
|
const _resolveRequire = config.createResolver({
|
|
30048
30252
|
asSrc: false,
|
|
30049
|
-
isRequire: true
|
|
30253
|
+
isRequire: true,
|
|
30254
|
+
scan: true
|
|
30050
30255
|
});
|
|
30051
30256
|
const resolve = (id, importer, kind, resolveDir) => {
|
|
30052
30257
|
let _importer;
|
|
@@ -30060,7 +30265,7 @@ function esbuildDepPlugin(qualified, exportsData, config, ssr) {
|
|
|
30060
30265
|
_importer = importer in qualified ? qualified[importer] : importer;
|
|
30061
30266
|
}
|
|
30062
30267
|
const resolver = kind.startsWith('require') ? _resolveRequire : _resolve;
|
|
30063
|
-
return resolver(id, _importer, undefined
|
|
30268
|
+
return resolver(id, _importer, undefined);
|
|
30064
30269
|
};
|
|
30065
30270
|
return {
|
|
30066
30271
|
name: 'vite:dep-pre-bundle',
|
|
@@ -35957,6 +36162,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
35957
36162
|
constructor(initialPlugin) {
|
|
35958
36163
|
this.meta = minimalContext.meta;
|
|
35959
36164
|
this.ssr = false;
|
|
36165
|
+
this._scan = false;
|
|
35960
36166
|
this._activeId = null;
|
|
35961
36167
|
this._activeCode = null;
|
|
35962
36168
|
this._addedImports = null;
|
|
@@ -35976,7 +36182,11 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
35976
36182
|
skip = new Set(this._resolveSkips);
|
|
35977
36183
|
skip.add(this._activePlugin);
|
|
35978
36184
|
}
|
|
35979
|
-
let out = await container.resolveId(id, importer, {
|
|
36185
|
+
let out = await container.resolveId(id, importer, {
|
|
36186
|
+
skip,
|
|
36187
|
+
ssr: this.ssr,
|
|
36188
|
+
scan: this._scan
|
|
36189
|
+
});
|
|
35980
36190
|
if (typeof out === 'string')
|
|
35981
36191
|
out = { id: out };
|
|
35982
36192
|
return out;
|
|
@@ -36125,7 +36335,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
36125
36335
|
combinedMap = m;
|
|
36126
36336
|
}
|
|
36127
36337
|
else {
|
|
36128
|
-
combinedMap = combineSourcemaps(this.filename, [
|
|
36338
|
+
combinedMap = combineSourcemaps(cleanUrl(this.filename), [
|
|
36129
36339
|
{
|
|
36130
36340
|
...m,
|
|
36131
36341
|
sourcesContent: combinedMap.sourcesContent
|
|
@@ -36139,7 +36349,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
36139
36349
|
? new MagicString$1(this.originalCode).generateMap({
|
|
36140
36350
|
includeContent: true,
|
|
36141
36351
|
hires: true,
|
|
36142
|
-
source: this.filename
|
|
36352
|
+
source: cleanUrl(this.filename)
|
|
36143
36353
|
})
|
|
36144
36354
|
: null;
|
|
36145
36355
|
}
|
|
@@ -36183,8 +36393,10 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
36183
36393
|
async resolveId(rawId, importer = path$p.join(root, 'index.html'), options) {
|
|
36184
36394
|
const skip = options === null || options === void 0 ? void 0 : options.skip;
|
|
36185
36395
|
const ssr = options === null || options === void 0 ? void 0 : options.ssr;
|
|
36396
|
+
const scan = !!(options === null || options === void 0 ? void 0 : options.scan);
|
|
36186
36397
|
const ctx = new Context();
|
|
36187
36398
|
ctx.ssr = !!ssr;
|
|
36399
|
+
ctx._scan = scan;
|
|
36188
36400
|
ctx._resolveSkips = skip;
|
|
36189
36401
|
const resolveStart = isDebug ? perf_hooks.performance.now() : 0;
|
|
36190
36402
|
let id = null;
|
|
@@ -36196,7 +36408,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
36196
36408
|
continue;
|
|
36197
36409
|
ctx._activePlugin = plugin;
|
|
36198
36410
|
const pluginResolveStart = isDebug ? perf_hooks.performance.now() : 0;
|
|
36199
|
-
const result = await plugin.resolveId.call(ctx, rawId, importer, { ssr });
|
|
36411
|
+
const result = await plugin.resolveId.call(ctx, rawId, importer, { ssr, scan });
|
|
36200
36412
|
if (!result)
|
|
36201
36413
|
continue;
|
|
36202
36414
|
if (typeof result === 'string') {
|
|
@@ -36298,7 +36510,7 @@ async function createPluginContainer({ plugins, logger, root, build: { rollupOpt
|
|
|
36298
36510
|
return container;
|
|
36299
36511
|
}
|
|
36300
36512
|
|
|
36301
|
-
const debug$
|
|
36513
|
+
const debug$d = createDebugger('vite:deps');
|
|
36302
36514
|
const htmlTypesRE = /\.(html|vue|svelte|astro)$/;
|
|
36303
36515
|
// A simple regex to detect import sources. This is only used on
|
|
36304
36516
|
// <script lang="ts"> blocks in vue (setup only) or svelte files, since
|
|
@@ -36349,7 +36561,7 @@ async function scanImports(config) {
|
|
|
36349
36561
|
return { deps: {}, missing: {} };
|
|
36350
36562
|
}
|
|
36351
36563
|
else {
|
|
36352
|
-
debug$
|
|
36564
|
+
debug$d(`Crawling dependencies using entries:\n ${entries.join('\n ')}`);
|
|
36353
36565
|
}
|
|
36354
36566
|
const deps = {};
|
|
36355
36567
|
const missing = {};
|
|
@@ -36366,12 +36578,19 @@ async function scanImports(config) {
|
|
|
36366
36578
|
plugins: [...plugins, plugin],
|
|
36367
36579
|
...esbuildOptions
|
|
36368
36580
|
})));
|
|
36369
|
-
debug$
|
|
36581
|
+
debug$d(`Scan completed in ${(perf_hooks.performance.now() - start).toFixed(2)}ms:`, deps);
|
|
36370
36582
|
return {
|
|
36371
|
-
|
|
36583
|
+
// Ensure a fixed order so hashes are stable and improve logs
|
|
36584
|
+
deps: orderedDependencies(deps),
|
|
36372
36585
|
missing
|
|
36373
36586
|
};
|
|
36374
36587
|
}
|
|
36588
|
+
function orderedDependencies(deps) {
|
|
36589
|
+
const depsList = Object.entries(deps);
|
|
36590
|
+
// Ensure the same browserHash for the same set of dependencies
|
|
36591
|
+
depsList.sort((a, b) => a[0].localeCompare(b[0]));
|
|
36592
|
+
return Object.fromEntries(depsList);
|
|
36593
|
+
}
|
|
36375
36594
|
function globEntries(pattern, config) {
|
|
36376
36595
|
return out(pattern, {
|
|
36377
36596
|
cwd: config.root,
|
|
@@ -36398,7 +36617,9 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
|
|
|
36398
36617
|
if (seen.has(key)) {
|
|
36399
36618
|
return seen.get(key);
|
|
36400
36619
|
}
|
|
36401
|
-
const resolved = await container.resolveId(id, importer && normalizePath$4(importer)
|
|
36620
|
+
const resolved = await container.resolveId(id, importer && normalizePath$4(importer), {
|
|
36621
|
+
scan: true
|
|
36622
|
+
});
|
|
36402
36623
|
const res = resolved === null || resolved === void 0 ? void 0 : resolved.id;
|
|
36403
36624
|
seen.set(key, res);
|
|
36404
36625
|
return res;
|
|
@@ -36662,7 +36883,7 @@ async function transformGlob(source, importer, root, loader, resolve, logger) {
|
|
|
36662
36883
|
continue;
|
|
36663
36884
|
const { importsString, exp, endIndex } = await transformImportGlob(source, start, normalizePath$4(importer), index, root, logger, undefined, resolve);
|
|
36664
36885
|
s.prepend(importsString);
|
|
36665
|
-
s.overwrite(expStart, endIndex, exp);
|
|
36886
|
+
s.overwrite(expStart, endIndex, exp, { contentOnly: true });
|
|
36666
36887
|
}
|
|
36667
36888
|
return s.toString();
|
|
36668
36889
|
}
|
|
@@ -36704,75 +36925,127 @@ function isScannable(id) {
|
|
|
36704
36925
|
return JS_TYPES_RE.test(id) || htmlTypesRE.test(id);
|
|
36705
36926
|
}
|
|
36706
36927
|
|
|
36707
|
-
const
|
|
36708
|
-
const
|
|
36928
|
+
const debuggerViteDeps = createDebugger('vite:deps');
|
|
36929
|
+
const debug$c = debuggerViteDeps;
|
|
36930
|
+
const isDebugEnabled$1 = _debug('vite:deps').enabled;
|
|
36709
36931
|
const jsExtensionRE = /\.js$/i;
|
|
36710
36932
|
const jsMapExtensionRE = /\.js\.map$/i;
|
|
36711
36933
|
/**
|
|
36712
36934
|
* Used by Vite CLI when running `vite optimize`
|
|
36713
36935
|
*/
|
|
36714
|
-
async function optimizeDeps(config, force = config.server.force, asCommand = false
|
|
36715
|
-
|
|
36716
|
-
const
|
|
36717
|
-
|
|
36936
|
+
async function optimizeDeps(config, force = config.server.force, asCommand = false) {
|
|
36937
|
+
const log = asCommand ? config.logger.info : debug$c;
|
|
36938
|
+
const cachedMetadata = loadCachedDepOptimizationMetadata(config, force, asCommand);
|
|
36939
|
+
if (cachedMetadata) {
|
|
36940
|
+
return cachedMetadata;
|
|
36941
|
+
}
|
|
36942
|
+
const depsInfo = await discoverProjectDependencies(config);
|
|
36943
|
+
const depsString = depsLogString(Object.keys(depsInfo));
|
|
36944
|
+
log(colors$1.green(`Optimizing dependencies:\n ${depsString}`));
|
|
36945
|
+
const result = await runOptimizeDeps(config, depsInfo);
|
|
36718
36946
|
result.commit();
|
|
36719
|
-
return metadata;
|
|
36947
|
+
return result.metadata;
|
|
36948
|
+
}
|
|
36949
|
+
function createOptimizedDepsMetadata(config, timestamp) {
|
|
36950
|
+
const hash = getDepHash(config);
|
|
36951
|
+
return {
|
|
36952
|
+
hash,
|
|
36953
|
+
browserHash: getOptimizedBrowserHash(hash, {}, timestamp),
|
|
36954
|
+
optimized: {},
|
|
36955
|
+
chunks: {},
|
|
36956
|
+
discovered: {},
|
|
36957
|
+
depInfoList: []
|
|
36958
|
+
};
|
|
36959
|
+
}
|
|
36960
|
+
function addOptimizedDepInfo(metadata, type, depInfo) {
|
|
36961
|
+
metadata[type][depInfo.id] = depInfo;
|
|
36962
|
+
metadata.depInfoList.push(depInfo);
|
|
36963
|
+
return depInfo;
|
|
36720
36964
|
}
|
|
36721
36965
|
/**
|
|
36722
|
-
*
|
|
36723
|
-
*
|
|
36966
|
+
* Creates the initial dep optimization metadata, loading it from the deps cache
|
|
36967
|
+
* if it exists and pre-bundling isn't forced
|
|
36724
36968
|
*/
|
|
36725
|
-
|
|
36726
|
-
|
|
36727
|
-
config = {
|
|
36728
|
-
...config,
|
|
36729
|
-
command: 'build'
|
|
36730
|
-
};
|
|
36731
|
-
const { root, logger } = config;
|
|
36732
|
-
const log = asCommand ? logger.info : debug$d;
|
|
36969
|
+
function loadCachedDepOptimizationMetadata(config, force = config.server.force, asCommand = false) {
|
|
36970
|
+
const log = asCommand ? config.logger.info : debug$c;
|
|
36733
36971
|
// Before Vite 2.9, dependencies were cached in the root of the cacheDir
|
|
36734
36972
|
// For compat, we remove the cache if we find the old structure
|
|
36735
36973
|
if (fs__default.existsSync(path__default.join(config.cacheDir, '_metadata.json'))) {
|
|
36736
36974
|
emptyDir(config.cacheDir);
|
|
36737
36975
|
}
|
|
36738
36976
|
const depsCacheDir = getDepsCacheDir(config);
|
|
36739
|
-
const processingCacheDir = getProcessingDepsCacheDir(config);
|
|
36740
|
-
const mainHash = getDepHash(root, config);
|
|
36741
|
-
const processing = newDepOptimizationProcessing();
|
|
36742
|
-
const metadata = {
|
|
36743
|
-
hash: mainHash,
|
|
36744
|
-
browserHash: mainHash,
|
|
36745
|
-
optimized: {},
|
|
36746
|
-
chunks: {},
|
|
36747
|
-
discovered: {}
|
|
36748
|
-
};
|
|
36749
36977
|
if (!force) {
|
|
36750
|
-
let
|
|
36978
|
+
let cachedMetadata;
|
|
36751
36979
|
try {
|
|
36752
|
-
const
|
|
36753
|
-
|
|
36980
|
+
const cachedMetadataPath = path__default.join(depsCacheDir, '_metadata.json');
|
|
36981
|
+
cachedMetadata = parseOptimizedDepsMetadata(fs__default.readFileSync(cachedMetadataPath, 'utf-8'), depsCacheDir);
|
|
36754
36982
|
}
|
|
36755
36983
|
catch (e) { }
|
|
36756
36984
|
// hash is consistent, no need to re-bundle
|
|
36757
|
-
if (
|
|
36985
|
+
if (cachedMetadata && cachedMetadata.hash === getDepHash(config)) {
|
|
36758
36986
|
log('Hash is consistent. Skipping. Use --force to override.');
|
|
36759
36987
|
// Nothing to commit or cancel as we are using the cache, we only
|
|
36760
36988
|
// need to resolve the processing promise so requests can move on
|
|
36761
|
-
|
|
36762
|
-
processing.resolve();
|
|
36763
|
-
};
|
|
36764
|
-
return {
|
|
36765
|
-
metadata: prevData,
|
|
36766
|
-
run: async () => {
|
|
36767
|
-
return {
|
|
36768
|
-
alteredFiles: false,
|
|
36769
|
-
commit: resolve,
|
|
36770
|
-
cancel: resolve
|
|
36771
|
-
};
|
|
36772
|
-
}
|
|
36773
|
-
};
|
|
36989
|
+
return cachedMetadata;
|
|
36774
36990
|
}
|
|
36775
36991
|
}
|
|
36992
|
+
else {
|
|
36993
|
+
config.logger.info('Forced re-optimization of dependencies');
|
|
36994
|
+
}
|
|
36995
|
+
// Start with a fresh cache
|
|
36996
|
+
removeDirSync(depsCacheDir);
|
|
36997
|
+
}
|
|
36998
|
+
/**
|
|
36999
|
+
* Initial optimizeDeps at server start. Perform a fast scan using esbuild to
|
|
37000
|
+
* find deps to pre-bundle and include user hard-coded dependencies
|
|
37001
|
+
*/
|
|
37002
|
+
async function discoverProjectDependencies(config, timestamp) {
|
|
37003
|
+
const { deps, missing } = await scanImports(config);
|
|
37004
|
+
const missingIds = Object.keys(missing);
|
|
37005
|
+
if (missingIds.length) {
|
|
37006
|
+
throw new Error(`The following dependencies are imported but could not be resolved:\n\n ${missingIds
|
|
37007
|
+
.map((id) => `${colors$1.cyan(id)} ${colors$1.white(colors$1.dim(`(imported by ${missing[id]})`))}`)
|
|
37008
|
+
.join(`\n `)}\n\nAre they installed?`);
|
|
37009
|
+
}
|
|
37010
|
+
await addManuallyIncludedOptimizeDeps(deps, config);
|
|
37011
|
+
const browserHash = getOptimizedBrowserHash(getDepHash(config), deps, timestamp);
|
|
37012
|
+
const discovered = {};
|
|
37013
|
+
for (const id in deps) {
|
|
37014
|
+
const entry = deps[id];
|
|
37015
|
+
discovered[id] = {
|
|
37016
|
+
id,
|
|
37017
|
+
file: getOptimizedDepPath(id, config),
|
|
37018
|
+
src: entry,
|
|
37019
|
+
browserHash: browserHash
|
|
37020
|
+
};
|
|
37021
|
+
}
|
|
37022
|
+
return discovered;
|
|
37023
|
+
}
|
|
37024
|
+
function depsLogString(qualifiedIds) {
|
|
37025
|
+
if (isDebugEnabled$1) {
|
|
37026
|
+
return colors$1.yellow(qualifiedIds.join(`\n `));
|
|
37027
|
+
}
|
|
37028
|
+
else {
|
|
37029
|
+
const total = qualifiedIds.length;
|
|
37030
|
+
const maxListed = 5;
|
|
37031
|
+
const listed = Math.min(total, maxListed);
|
|
37032
|
+
const extra = Math.max(0, total - maxListed);
|
|
37033
|
+
return colors$1.yellow(qualifiedIds.slice(0, listed).join(`, `) +
|
|
37034
|
+
(extra > 0 ? `, ...and ${extra} more` : ``));
|
|
37035
|
+
}
|
|
37036
|
+
}
|
|
37037
|
+
/**
|
|
37038
|
+
* Internally, Vite uses this function to prepare a optimizeDeps run. When Vite starts, we can get
|
|
37039
|
+
* the metadata and start the server without waiting for the optimizeDeps processing to be completed
|
|
37040
|
+
*/
|
|
37041
|
+
async function runOptimizeDeps(config, depsInfo) {
|
|
37042
|
+
var _a, _b, _c, _d;
|
|
37043
|
+
config = {
|
|
37044
|
+
...config,
|
|
37045
|
+
command: 'build'
|
|
37046
|
+
};
|
|
37047
|
+
const depsCacheDir = getDepsCacheDir(config);
|
|
37048
|
+
const processingCacheDir = getProcessingDepsCacheDir(config);
|
|
36776
37049
|
// Create a temporal directory so we don't need to delete optimized deps
|
|
36777
37050
|
// until they have been processed. This also avoids leaving the deps cache
|
|
36778
37051
|
// directory in a corrupted state if there is an error
|
|
@@ -36785,256 +37058,156 @@ ssr) {
|
|
|
36785
37058
|
// a hint for Node.js
|
|
36786
37059
|
// all files in the cache directory should be recognized as ES modules
|
|
36787
37060
|
writeFile(path__default.resolve(processingCacheDir, 'package.json'), JSON.stringify({ type: 'module' }));
|
|
36788
|
-
|
|
36789
|
-
|
|
36790
|
-
|
|
36791
|
-
|
|
36792
|
-
|
|
36793
|
-
|
|
36794
|
-
|
|
36795
|
-
|
|
36796
|
-
|
|
36797
|
-
|
|
36798
|
-
|
|
36799
|
-
|
|
36800
|
-
.
|
|
36801
|
-
|
|
36802
|
-
|
|
36803
|
-
|
|
36804
|
-
}
|
|
36805
|
-
catch (e) {
|
|
36806
|
-
processing.resolve();
|
|
36807
|
-
throw e;
|
|
36808
|
-
}
|
|
36809
|
-
// update browser hash
|
|
36810
|
-
newBrowserHash = metadata.browserHash = getOptimizedBrowserHash(metadata.hash, deps);
|
|
36811
|
-
// We generate the mapping of dependency ids to their cache file location
|
|
36812
|
-
// before processing the dependencies with esbuild. This allow us to continue
|
|
36813
|
-
// processing files in the importAnalysis and resolve plugins
|
|
36814
|
-
for (const id in deps) {
|
|
36815
|
-
const entry = deps[id];
|
|
36816
|
-
metadata.optimized[id] = {
|
|
36817
|
-
file: getOptimizedDepPath(id, config),
|
|
36818
|
-
src: entry,
|
|
36819
|
-
browserHash: newBrowserHash,
|
|
36820
|
-
processing: processing.promise
|
|
36821
|
-
};
|
|
36822
|
-
}
|
|
37061
|
+
const metadata = createOptimizedDepsMetadata(config);
|
|
37062
|
+
metadata.browserHash = getOptimizedBrowserHash(metadata.hash, depsFromOptimizedDepInfo(depsInfo));
|
|
37063
|
+
// We prebundle dependencies with esbuild and cache them, but there is no need
|
|
37064
|
+
// to wait here. Code that needs to access the cached deps needs to await
|
|
37065
|
+
// the optimizedDepInfo.processing promise for each dep
|
|
37066
|
+
const qualifiedIds = Object.keys(depsInfo);
|
|
37067
|
+
if (!qualifiedIds.length) {
|
|
37068
|
+
return {
|
|
37069
|
+
metadata,
|
|
37070
|
+
commit() {
|
|
37071
|
+
// Write metadata file, delete `deps` folder and rename the `processing` folder to `deps`
|
|
37072
|
+
commitProcessingDepsCacheSync();
|
|
37073
|
+
config.logger.info(`No dependencies to bundle. Skipping.\n\n\n`);
|
|
37074
|
+
},
|
|
37075
|
+
cancel
|
|
37076
|
+
};
|
|
36823
37077
|
}
|
|
36824
|
-
|
|
36825
|
-
|
|
36826
|
-
|
|
36827
|
-
|
|
36828
|
-
|
|
36829
|
-
|
|
36830
|
-
|
|
36831
|
-
|
|
36832
|
-
|
|
36833
|
-
}
|
|
36834
|
-
|
|
36835
|
-
|
|
36836
|
-
|
|
36837
|
-
|
|
36838
|
-
|
|
36839
|
-
|
|
36840
|
-
|
|
36841
|
-
|
|
36842
|
-
|
|
36843
|
-
|
|
36844
|
-
|
|
36845
|
-
|
|
36846
|
-
|
|
36847
|
-
|
|
36848
|
-
|
|
36849
|
-
|
|
36850
|
-
|
|
36851
|
-
};
|
|
36852
|
-
}
|
|
36853
|
-
let depsString;
|
|
36854
|
-
if (isDebugEnabled) {
|
|
36855
|
-
depsString = colors$1.yellow(qualifiedIds.join(`\n `));
|
|
37078
|
+
// esbuild generates nested directory output with lowest common ancestor base
|
|
37079
|
+
// this is unpredictable and makes it difficult to analyze entry / output
|
|
37080
|
+
// mapping. So what we do here is:
|
|
37081
|
+
// 1. flatten all ids to eliminate slash
|
|
37082
|
+
// 2. in the plugin, read the entry ourselves as virtual files to retain the
|
|
37083
|
+
// path.
|
|
37084
|
+
const flatIdDeps = {};
|
|
37085
|
+
const idToExports = {};
|
|
37086
|
+
const flatIdToExports = {};
|
|
37087
|
+
const { plugins = [], ...esbuildOptions } = (_b = (_a = config.optimizeDeps) === null || _a === void 0 ? void 0 : _a.esbuildOptions) !== null && _b !== void 0 ? _b : {};
|
|
37088
|
+
await init;
|
|
37089
|
+
for (const id in depsInfo) {
|
|
37090
|
+
const flatId = flattenId(id);
|
|
37091
|
+
const filePath = (flatIdDeps[flatId] = depsInfo[id].src);
|
|
37092
|
+
let exportsData;
|
|
37093
|
+
if ((_c = config.optimizeDeps.extensions) === null || _c === void 0 ? void 0 : _c.some((ext) => filePath.endsWith(ext))) {
|
|
37094
|
+
// For custom supported extensions, build the entry file to transform it into JS,
|
|
37095
|
+
// and then parse with es-module-lexer. Note that the `bundle` option is not `true`,
|
|
37096
|
+
// so only the entry file is being transformed.
|
|
37097
|
+
const result = await esbuild.build({
|
|
37098
|
+
...esbuildOptions,
|
|
37099
|
+
plugins,
|
|
37100
|
+
entryPoints: [filePath],
|
|
37101
|
+
write: false,
|
|
37102
|
+
format: 'esm'
|
|
37103
|
+
});
|
|
37104
|
+
exportsData = parse$f(result.outputFiles[0].text);
|
|
36856
37105
|
}
|
|
36857
37106
|
else {
|
|
36858
|
-
const
|
|
36859
|
-
|
|
36860
|
-
|
|
36861
|
-
const extra = Math.max(0, total - maxListed);
|
|
36862
|
-
depsString = colors$1.yellow(qualifiedIds.slice(0, listed).join(`\n `) +
|
|
36863
|
-
(extra > 0 ? `\n (...and ${extra} more)` : ``));
|
|
36864
|
-
}
|
|
36865
|
-
if (!asCommand) {
|
|
36866
|
-
if (!newDeps) {
|
|
36867
|
-
// This is auto run on server start - let the user know that we are
|
|
36868
|
-
// pre-optimizing deps
|
|
36869
|
-
logger.info(colors$1.green(`Pre-bundling dependencies:\n ${depsString}`));
|
|
36870
|
-
logger.info(`(this will be run only when your dependencies or config have changed)`);
|
|
37107
|
+
const entryContent = fs__default.readFileSync(filePath, 'utf-8');
|
|
37108
|
+
try {
|
|
37109
|
+
exportsData = parse$f(entryContent);
|
|
36871
37110
|
}
|
|
36872
|
-
|
|
36873
|
-
|
|
36874
|
-
|
|
36875
|
-
|
|
36876
|
-
// esbuild generates nested directory output with lowest common ancestor base
|
|
36877
|
-
// this is unpredictable and makes it difficult to analyze entry / output
|
|
36878
|
-
// mapping. So what we do here is:
|
|
36879
|
-
// 1. flatten all ids to eliminate slash
|
|
36880
|
-
// 2. in the plugin, read the entry ourselves as virtual files to retain the
|
|
36881
|
-
// path.
|
|
36882
|
-
const flatIdDeps = {};
|
|
36883
|
-
const idToExports = {};
|
|
36884
|
-
const flatIdToExports = {};
|
|
36885
|
-
const { plugins = [], ...esbuildOptions } = (_b = (_a = config.optimizeDeps) === null || _a === void 0 ? void 0 : _a.esbuildOptions) !== null && _b !== void 0 ? _b : {};
|
|
36886
|
-
await init;
|
|
36887
|
-
for (const id in deps) {
|
|
36888
|
-
const flatId = flattenId(id);
|
|
36889
|
-
const filePath = (flatIdDeps[flatId] = deps[id]);
|
|
36890
|
-
let exportsData;
|
|
36891
|
-
if ((_c = config.optimizeDeps.extensions) === null || _c === void 0 ? void 0 : _c.some((ext) => filePath.endsWith(ext))) {
|
|
36892
|
-
// For custom supported extensions, build the entry file to transform it into JS,
|
|
36893
|
-
// and then parse with es-module-lexer. Note that the `bundle` option is not `true`,
|
|
36894
|
-
// so only the entry file is being transformed.
|
|
36895
|
-
const result = await esbuild.build({
|
|
36896
|
-
...esbuildOptions,
|
|
36897
|
-
plugins,
|
|
36898
|
-
entryPoints: [filePath],
|
|
36899
|
-
write: false,
|
|
36900
|
-
format: 'esm'
|
|
37111
|
+
catch {
|
|
37112
|
+
debug$c(`Unable to parse dependency: ${id}. Trying again with a JSX transform.`);
|
|
37113
|
+
const transformed = await transformWithEsbuild(entryContent, filePath, {
|
|
37114
|
+
loader: 'jsx'
|
|
36901
37115
|
});
|
|
36902
|
-
|
|
37116
|
+
// Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
|
|
37117
|
+
// This is useful for packages such as Gatsby.
|
|
37118
|
+
esbuildOptions.loader = {
|
|
37119
|
+
'.js': 'jsx',
|
|
37120
|
+
...esbuildOptions.loader
|
|
37121
|
+
};
|
|
37122
|
+
exportsData = parse$f(transformed.code);
|
|
36903
37123
|
}
|
|
36904
|
-
|
|
36905
|
-
const
|
|
36906
|
-
|
|
36907
|
-
exportsData =
|
|
36908
|
-
}
|
|
36909
|
-
catch {
|
|
36910
|
-
debug$d(`Unable to parse dependency: ${id}. Trying again with a JSX transform.`);
|
|
36911
|
-
const transformed = await transformWithEsbuild(entryContent, filePath, {
|
|
36912
|
-
loader: 'jsx'
|
|
36913
|
-
});
|
|
36914
|
-
// Ensure that optimization won't fail by defaulting '.js' to the JSX parser.
|
|
36915
|
-
// This is useful for packages such as Gatsby.
|
|
36916
|
-
esbuildOptions.loader = {
|
|
36917
|
-
'.js': 'jsx',
|
|
36918
|
-
...esbuildOptions.loader
|
|
36919
|
-
};
|
|
36920
|
-
exportsData = parse$f(transformed.code);
|
|
36921
|
-
}
|
|
36922
|
-
for (const { ss, se } of exportsData[0]) {
|
|
36923
|
-
const exp = entryContent.slice(ss, se);
|
|
36924
|
-
if (/export\s+\*\s+from/.test(exp)) {
|
|
36925
|
-
exportsData.hasReExports = true;
|
|
36926
|
-
}
|
|
37124
|
+
for (const { ss, se } of exportsData[0]) {
|
|
37125
|
+
const exp = entryContent.slice(ss, se);
|
|
37126
|
+
if (/export\s+\*\s+from/.test(exp)) {
|
|
37127
|
+
exportsData.hasReExports = true;
|
|
36927
37128
|
}
|
|
36928
37129
|
}
|
|
36929
|
-
idToExports[id] = exportsData;
|
|
36930
|
-
flatIdToExports[flatId] = exportsData;
|
|
36931
|
-
}
|
|
36932
|
-
const define = {
|
|
36933
|
-
'process.env.NODE_ENV': JSON.stringify(config.mode)
|
|
36934
|
-
};
|
|
36935
|
-
for (const key in config.define) {
|
|
36936
|
-
const value = config.define[key];
|
|
36937
|
-
define[key] = typeof value === 'string' ? value : JSON.stringify(value);
|
|
36938
37130
|
}
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
|
|
36942
|
-
|
|
36943
|
-
|
|
36944
|
-
|
|
36945
|
-
|
|
36946
|
-
|
|
36947
|
-
|
|
36948
|
-
|
|
36949
|
-
|
|
36950
|
-
|
|
36951
|
-
|
|
36952
|
-
|
|
36953
|
-
|
|
36954
|
-
|
|
36955
|
-
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
37131
|
+
idToExports[id] = exportsData;
|
|
37132
|
+
flatIdToExports[flatId] = exportsData;
|
|
37133
|
+
}
|
|
37134
|
+
const define = {
|
|
37135
|
+
'process.env.NODE_ENV': JSON.stringify(config.mode)
|
|
37136
|
+
};
|
|
37137
|
+
for (const key in config.define) {
|
|
37138
|
+
const value = config.define[key];
|
|
37139
|
+
define[key] = typeof value === 'string' ? value : JSON.stringify(value);
|
|
37140
|
+
}
|
|
37141
|
+
const start = perf_hooks.performance.now();
|
|
37142
|
+
const result = await esbuild.build({
|
|
37143
|
+
absWorkingDir: process.cwd(),
|
|
37144
|
+
entryPoints: Object.keys(flatIdDeps),
|
|
37145
|
+
bundle: true,
|
|
37146
|
+
format: 'esm',
|
|
37147
|
+
target: config.build.target || undefined,
|
|
37148
|
+
external: (_d = config.optimizeDeps) === null || _d === void 0 ? void 0 : _d.exclude,
|
|
37149
|
+
logLevel: 'error',
|
|
37150
|
+
splitting: true,
|
|
37151
|
+
sourcemap: true,
|
|
37152
|
+
outdir: processingCacheDir,
|
|
37153
|
+
ignoreAnnotations: true,
|
|
37154
|
+
metafile: true,
|
|
37155
|
+
define,
|
|
37156
|
+
plugins: [
|
|
37157
|
+
...plugins,
|
|
37158
|
+
esbuildDepPlugin(flatIdDeps, flatIdToExports, config)
|
|
37159
|
+
],
|
|
37160
|
+
...esbuildOptions
|
|
37161
|
+
});
|
|
37162
|
+
const meta = result.metafile;
|
|
37163
|
+
// the paths in `meta.outputs` are relative to `process.cwd()`
|
|
37164
|
+
const processingCacheDirOutputPath = path__default.relative(process.cwd(), processingCacheDir);
|
|
37165
|
+
for (const id in depsInfo) {
|
|
37166
|
+
const output = esbuildOutputFromId(meta.outputs, id, processingCacheDir);
|
|
37167
|
+
addOptimizedDepInfo(metadata, 'optimized', {
|
|
37168
|
+
...depsInfo[id],
|
|
37169
|
+
needsInterop: needsInterop(id, idToExports[id], output),
|
|
37170
|
+
// We only need to hash the output.imports in to check for stability, but adding the hash
|
|
37171
|
+
// and file path gives us a unique hash that may be useful for other things in the future
|
|
37172
|
+
fileHash: getHash(metadata.hash + depsInfo[id].file + JSON.stringify(output.imports)),
|
|
37173
|
+
browserHash: metadata.browserHash
|
|
36959
37174
|
});
|
|
36960
|
-
|
|
36961
|
-
|
|
36962
|
-
|
|
36963
|
-
|
|
36964
|
-
|
|
36965
|
-
|
|
36966
|
-
const
|
|
36967
|
-
if (
|
|
36968
|
-
|
|
36969
|
-
|
|
36970
|
-
|
|
36971
|
-
|
|
36972
|
-
|
|
36973
|
-
|
|
36974
|
-
// the newly discovered deps don't have common chunks with them. Comparing their fileHash we
|
|
36975
|
-
// can find out if it is safe to keep the current browser state. If one of the file hashes
|
|
36976
|
-
// changed, a full page reload is needed
|
|
36977
|
-
let alteredFiles = false;
|
|
36978
|
-
if (currentData) {
|
|
36979
|
-
alteredFiles = Object.keys(currentData.optimized).some((dep) => {
|
|
36980
|
-
const currentInfo = currentData.optimized[dep];
|
|
36981
|
-
const info = metadata.optimized[dep];
|
|
36982
|
-
return (!(info === null || info === void 0 ? void 0 : info.fileHash) ||
|
|
36983
|
-
!(currentInfo === null || currentInfo === void 0 ? void 0 : currentInfo.fileHash) ||
|
|
36984
|
-
(info === null || info === void 0 ? void 0 : info.fileHash) !== (currentInfo === null || currentInfo === void 0 ? void 0 : currentInfo.fileHash));
|
|
36985
|
-
});
|
|
36986
|
-
debug$d(`optimized deps have altered files: ${alteredFiles}`);
|
|
36987
|
-
}
|
|
36988
|
-
for (const o of Object.keys(meta.outputs)) {
|
|
36989
|
-
if (!o.match(jsMapExtensionRE)) {
|
|
36990
|
-
const id = path__default
|
|
36991
|
-
.relative(processingCacheDirOutputPath, o)
|
|
36992
|
-
.replace(jsExtensionRE, '');
|
|
36993
|
-
const file = getOptimizedDepPath(id, config);
|
|
36994
|
-
if (!findFileInfo(metadata.optimized, file)) {
|
|
36995
|
-
metadata.chunks[id] = {
|
|
36996
|
-
file,
|
|
36997
|
-
src: '',
|
|
36998
|
-
needsInterop: false,
|
|
36999
|
-
browserHash: (!alteredFiles && ((_e = currentData === null || currentData === void 0 ? void 0 : currentData.chunks[id]) === null || _e === void 0 ? void 0 : _e.browserHash)) ||
|
|
37000
|
-
newBrowserHash
|
|
37001
|
-
};
|
|
37002
|
-
}
|
|
37175
|
+
}
|
|
37176
|
+
for (const o of Object.keys(meta.outputs)) {
|
|
37177
|
+
if (!o.match(jsMapExtensionRE)) {
|
|
37178
|
+
const id = path__default
|
|
37179
|
+
.relative(processingCacheDirOutputPath, o)
|
|
37180
|
+
.replace(jsExtensionRE, '');
|
|
37181
|
+
const file = getOptimizedDepPath(id, config);
|
|
37182
|
+
if (!findOptimizedDepInfoInRecord(metadata.optimized, (depInfo) => depInfo.file === file)) {
|
|
37183
|
+
addOptimizedDepInfo(metadata, 'chunks', {
|
|
37184
|
+
id,
|
|
37185
|
+
file,
|
|
37186
|
+
needsInterop: false,
|
|
37187
|
+
browserHash: metadata.browserHash
|
|
37188
|
+
});
|
|
37003
37189
|
}
|
|
37004
37190
|
}
|
|
37005
|
-
if (alteredFiles) {
|
|
37006
|
-
metadata.browserHash = newBrowserHash;
|
|
37007
|
-
}
|
|
37008
|
-
debug$d(`deps bundled in ${(perf_hooks.performance.now() - start).toFixed(2)}ms`);
|
|
37009
|
-
return {
|
|
37010
|
-
alteredFiles,
|
|
37011
|
-
commit() {
|
|
37012
|
-
if (alteredFiles) {
|
|
37013
|
-
// Overwrite individual hashes with the new global browserHash, a full page reload is required
|
|
37014
|
-
// New deps that ended up with a different hash replaced while doing analysis import are going to
|
|
37015
|
-
// return a not found so the browser doesn't cache them. And will properly get loaded after the reload
|
|
37016
|
-
for (const id in deps) {
|
|
37017
|
-
metadata.optimized[id].browserHash = newBrowserHash;
|
|
37018
|
-
}
|
|
37019
|
-
}
|
|
37020
|
-
// Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync
|
|
37021
|
-
commitProcessingDepsCacheSync();
|
|
37022
|
-
processing.resolve();
|
|
37023
|
-
},
|
|
37024
|
-
cancel
|
|
37025
|
-
};
|
|
37026
37191
|
}
|
|
37192
|
+
const dataPath = path__default.join(processingCacheDir, '_metadata.json');
|
|
37193
|
+
writeFile(dataPath, stringifyOptimizedDepsMetadata(metadata, depsCacheDir));
|
|
37194
|
+
debug$c(`deps bundled in ${(perf_hooks.performance.now() - start).toFixed(2)}ms`);
|
|
37195
|
+
return {
|
|
37196
|
+
metadata,
|
|
37197
|
+
commit() {
|
|
37198
|
+
// Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync
|
|
37199
|
+
commitProcessingDepsCacheSync();
|
|
37200
|
+
},
|
|
37201
|
+
cancel
|
|
37202
|
+
};
|
|
37027
37203
|
function commitProcessingDepsCacheSync() {
|
|
37028
|
-
// Rewire the file paths from the temporal processing dir to the final deps cache dir
|
|
37029
|
-
const dataPath = path__default.join(processingCacheDir, '_metadata.json');
|
|
37030
|
-
writeFile(dataPath, stringifyOptimizedDepsMetadata(metadata, depsCacheDir));
|
|
37031
37204
|
// Processing is done, we can now replace the depsCacheDir with processingCacheDir
|
|
37205
|
+
// Rewire the file paths from the temporal processing dir to the final deps cache dir
|
|
37032
37206
|
removeDirSync(depsCacheDir);
|
|
37033
37207
|
fs__default.renameSync(processingCacheDir, depsCacheDir);
|
|
37034
37208
|
}
|
|
37035
37209
|
function cancel() {
|
|
37036
37210
|
removeDirSync(processingCacheDir);
|
|
37037
|
-
processing.resolve();
|
|
37038
37211
|
}
|
|
37039
37212
|
}
|
|
37040
37213
|
function removeDirSync(dir) {
|
|
@@ -37081,27 +37254,12 @@ function newDepOptimizationProcessing() {
|
|
|
37081
37254
|
function depsFromOptimizedDepInfo(depsInfo) {
|
|
37082
37255
|
return Object.fromEntries(Object.entries(depsInfo).map((d) => [d[0], d[1].src]));
|
|
37083
37256
|
}
|
|
37084
|
-
function getHash(text) {
|
|
37085
|
-
return require$$1$1.createHash('sha256').update(text).digest('hex').substring(0, 8);
|
|
37086
|
-
}
|
|
37087
|
-
function getOptimizedBrowserHash(hash, deps) {
|
|
37088
|
-
return getHash(hash + JSON.stringify(deps));
|
|
37089
|
-
}
|
|
37090
|
-
function getCachedDepFilePath(id, depsCacheDir) {
|
|
37091
|
-
return normalizePath$4(path__default.resolve(depsCacheDir, flattenId(id) + '.js'));
|
|
37092
|
-
}
|
|
37093
37257
|
function getOptimizedDepPath(id, config) {
|
|
37094
|
-
return
|
|
37258
|
+
return normalizePath$4(path__default.resolve(getDepsCacheDir(config), flattenId(id) + '.js'));
|
|
37095
37259
|
}
|
|
37096
37260
|
function getDepsCacheDir(config) {
|
|
37097
37261
|
return normalizePath$4(path__default.resolve(config.cacheDir, 'deps'));
|
|
37098
37262
|
}
|
|
37099
|
-
function getProcessingDepFilePath(id, processingCacheDir) {
|
|
37100
|
-
return normalizePath$4(path__default.resolve(processingCacheDir, flattenId(id) + '.js'));
|
|
37101
|
-
}
|
|
37102
|
-
function getProcessingDepPath(id, config) {
|
|
37103
|
-
return getProcessingDepFilePath(id, getProcessingDepsCacheDir(config));
|
|
37104
|
-
}
|
|
37105
37263
|
function getProcessingDepsCacheDir(config) {
|
|
37106
37264
|
return normalizePath$4(path__default.resolve(config.cacheDir, 'processing'));
|
|
37107
37265
|
}
|
|
@@ -37125,7 +37283,7 @@ function createIsOptimizedDepUrl(config) {
|
|
|
37125
37283
|
};
|
|
37126
37284
|
}
|
|
37127
37285
|
function parseOptimizedDepsMetadata(jsonMetadata, depsCacheDir) {
|
|
37128
|
-
const
|
|
37286
|
+
const { hash, browserHash, optimized, chunks } = JSON.parse(jsonMetadata, (key, value) => {
|
|
37129
37287
|
// Paths can be absolute or relative to the deps cache dir where
|
|
37130
37288
|
// the _metadata.json is located
|
|
37131
37289
|
if (key === 'file' || key === 'src') {
|
|
@@ -37133,18 +37291,34 @@ function parseOptimizedDepsMetadata(jsonMetadata, depsCacheDir) {
|
|
|
37133
37291
|
}
|
|
37134
37292
|
return value;
|
|
37135
37293
|
});
|
|
37136
|
-
|
|
37137
|
-
|
|
37138
|
-
|
|
37139
|
-
|
|
37140
|
-
}
|
|
37141
|
-
|
|
37142
|
-
|
|
37143
|
-
|
|
37144
|
-
|
|
37145
|
-
|
|
37146
|
-
|
|
37147
|
-
|
|
37294
|
+
if (!chunks ||
|
|
37295
|
+
Object.values(optimized).some((depInfo) => !depInfo.fileHash)) {
|
|
37296
|
+
// outdated _metadata.json version, ignore
|
|
37297
|
+
return;
|
|
37298
|
+
}
|
|
37299
|
+
const metadata = {
|
|
37300
|
+
hash,
|
|
37301
|
+
browserHash,
|
|
37302
|
+
optimized: {},
|
|
37303
|
+
discovered: {},
|
|
37304
|
+
chunks: {},
|
|
37305
|
+
depInfoList: []
|
|
37306
|
+
};
|
|
37307
|
+
for (const id of Object.keys(optimized)) {
|
|
37308
|
+
addOptimizedDepInfo(metadata, 'optimized', {
|
|
37309
|
+
...optimized[id],
|
|
37310
|
+
id,
|
|
37311
|
+
browserHash
|
|
37312
|
+
});
|
|
37313
|
+
}
|
|
37314
|
+
for (const id of Object.keys(chunks)) {
|
|
37315
|
+
addOptimizedDepInfo(metadata, 'chunks', {
|
|
37316
|
+
...chunks[id],
|
|
37317
|
+
id,
|
|
37318
|
+
browserHash,
|
|
37319
|
+
needsInterop: false
|
|
37320
|
+
});
|
|
37321
|
+
}
|
|
37148
37322
|
return metadata;
|
|
37149
37323
|
}
|
|
37150
37324
|
/**
|
|
@@ -37154,44 +37328,38 @@ function parseOptimizedDepsMetadata(jsonMetadata, depsCacheDir) {
|
|
|
37154
37328
|
* browserHash to allow long term caching
|
|
37155
37329
|
*/
|
|
37156
37330
|
function stringifyOptimizedDepsMetadata(metadata, depsCacheDir) {
|
|
37157
|
-
|
|
37158
|
-
|
|
37159
|
-
|
|
37160
|
-
|
|
37331
|
+
const { hash, browserHash, optimized, chunks } = metadata;
|
|
37332
|
+
return JSON.stringify({
|
|
37333
|
+
hash,
|
|
37334
|
+
browserHash,
|
|
37335
|
+
optimized: Object.fromEntries(Object.values(optimized).map(({ id, src, file, fileHash, needsInterop }) => [
|
|
37336
|
+
id,
|
|
37337
|
+
{
|
|
37338
|
+
src,
|
|
37339
|
+
file,
|
|
37340
|
+
fileHash,
|
|
37341
|
+
needsInterop
|
|
37342
|
+
}
|
|
37343
|
+
])),
|
|
37344
|
+
chunks: Object.fromEntries(Object.values(chunks).map(({ id, file }) => [id, { file }]))
|
|
37345
|
+
}, (key, value) => {
|
|
37346
|
+
// Paths can be absolute or relative to the deps cache dir where
|
|
37347
|
+
// the _metadata.json is located
|
|
37161
37348
|
if (key === 'file' || key === 'src') {
|
|
37162
37349
|
return normalizePath$4(path__default.relative(depsCacheDir, value));
|
|
37163
37350
|
}
|
|
37164
|
-
if (key === 'optimized') {
|
|
37165
|
-
// Only remove browserHash for individual dep info
|
|
37166
|
-
const cleaned = {};
|
|
37167
|
-
for (const dep of Object.keys(value)) {
|
|
37168
|
-
const { browserHash, ...c } = value[dep];
|
|
37169
|
-
cleaned[dep] = c;
|
|
37170
|
-
}
|
|
37171
|
-
return cleaned;
|
|
37172
|
-
}
|
|
37173
|
-
if (key === 'optimized') {
|
|
37174
|
-
return Object.keys(value).reduce((cleaned, dep) => {
|
|
37175
|
-
const { browserHash, ...c } = value[dep];
|
|
37176
|
-
cleaned[dep] = c;
|
|
37177
|
-
return cleaned;
|
|
37178
|
-
}, {});
|
|
37179
|
-
}
|
|
37180
|
-
if (key === 'chunks') {
|
|
37181
|
-
return Object.keys(value).reduce((cleaned, dep) => {
|
|
37182
|
-
const { browserHash, needsInterop, src, ...c } = value[dep];
|
|
37183
|
-
cleaned[dep] = c;
|
|
37184
|
-
return cleaned;
|
|
37185
|
-
}, {});
|
|
37186
|
-
}
|
|
37187
37351
|
return value;
|
|
37188
37352
|
}, 2);
|
|
37189
37353
|
}
|
|
37354
|
+
function esbuildOutputFromId(outputs, id, cacheDirOutputPath) {
|
|
37355
|
+
const flatId = flattenId(id) + '.js';
|
|
37356
|
+
return outputs[normalizePath$4(path__default.relative(process.cwd(), path__default.join(cacheDirOutputPath, flatId)))];
|
|
37357
|
+
}
|
|
37190
37358
|
// https://github.com/vitejs/vite/issues/1724#issuecomment-767619642
|
|
37191
37359
|
// a list of modules that pretends to be ESM but still uses `require`.
|
|
37192
37360
|
// this causes esbuild to wrap them as CJS even when its entry appears to be ESM.
|
|
37193
37361
|
const KNOWN_INTEROP_IDS = new Set(['moment']);
|
|
37194
|
-
function needsInterop(id, exportsData,
|
|
37362
|
+
function needsInterop(id, exportsData, output) {
|
|
37195
37363
|
if (KNOWN_INTEROP_IDS.has(id)) {
|
|
37196
37364
|
return true;
|
|
37197
37365
|
}
|
|
@@ -37203,15 +37371,7 @@ function needsInterop(id, exportsData, outputs, cacheDirOutputPath) {
|
|
|
37203
37371
|
// if a peer dependency used require() on a ESM dependency, esbuild turns the
|
|
37204
37372
|
// ESM dependency's entry chunk into a single default export... detect
|
|
37205
37373
|
// such cases by checking exports mismatch, and force interop.
|
|
37206
|
-
const
|
|
37207
|
-
let generatedExports;
|
|
37208
|
-
for (const output in outputs) {
|
|
37209
|
-
if (normalizePath$4(output) ===
|
|
37210
|
-
normalizePath$4(path__default.join(cacheDirOutputPath, flatId))) {
|
|
37211
|
-
generatedExports = outputs[output].exports;
|
|
37212
|
-
break;
|
|
37213
|
-
}
|
|
37214
|
-
}
|
|
37374
|
+
const generatedExports = output.exports;
|
|
37215
37375
|
if (!generatedExports ||
|
|
37216
37376
|
(isSingleDefaultExport(generatedExports) && !isSingleDefaultExport(exports))) {
|
|
37217
37377
|
return true;
|
|
@@ -37222,9 +37382,9 @@ function isSingleDefaultExport(exports) {
|
|
|
37222
37382
|
return exports.length === 1 && exports[0] === 'default';
|
|
37223
37383
|
}
|
|
37224
37384
|
const lockfileFormats = ['package-lock.json', 'yarn.lock', 'pnpm-lock.yaml'];
|
|
37225
|
-
function getDepHash(
|
|
37385
|
+
function getDepHash(config) {
|
|
37226
37386
|
var _a, _b, _c, _d, _e, _f;
|
|
37227
|
-
let content = lookupFile(root, lockfileFormats) || '';
|
|
37387
|
+
let content = lookupFile(config.root, lockfileFormats) || '';
|
|
37228
37388
|
// also take config into account
|
|
37229
37389
|
// only a subset of config options that can affect dep optimization
|
|
37230
37390
|
content += JSON.stringify({
|
|
@@ -37249,23 +37409,30 @@ function getDepHash(root, config) {
|
|
|
37249
37409
|
}
|
|
37250
37410
|
return value;
|
|
37251
37411
|
});
|
|
37252
|
-
return
|
|
37412
|
+
return getHash(content);
|
|
37253
37413
|
}
|
|
37254
|
-
function
|
|
37255
|
-
return (
|
|
37256
|
-
findFileInfo(metadata.discovered, file) ||
|
|
37257
|
-
findFileInfo(metadata.chunks, file));
|
|
37414
|
+
function getOptimizedBrowserHash(hash, deps, timestamp = '') {
|
|
37415
|
+
return getHash(hash + JSON.stringify(deps) + timestamp);
|
|
37258
37416
|
}
|
|
37259
|
-
function
|
|
37417
|
+
function getHash(text) {
|
|
37418
|
+
return require$$1$1.createHash('sha256').update(text).digest('hex').substring(0, 8);
|
|
37419
|
+
}
|
|
37420
|
+
function optimizedDepInfoFromId(metadata, id) {
|
|
37421
|
+
return (metadata.optimized[id] || metadata.discovered[id] || metadata.chunks[id]);
|
|
37422
|
+
}
|
|
37423
|
+
function optimizedDepInfoFromFile(metadata, file) {
|
|
37424
|
+
return metadata.depInfoList.find((depInfo) => depInfo.file === file);
|
|
37425
|
+
}
|
|
37426
|
+
function findOptimizedDepInfoInRecord(dependenciesInfo, callbackFn) {
|
|
37260
37427
|
for (const o of Object.keys(dependenciesInfo)) {
|
|
37261
37428
|
const info = dependenciesInfo[o];
|
|
37262
|
-
if (info
|
|
37429
|
+
if (callbackFn(info, o)) {
|
|
37263
37430
|
return info;
|
|
37264
37431
|
}
|
|
37265
37432
|
}
|
|
37266
37433
|
}
|
|
37267
37434
|
async function optimizedDepNeedsInterop(metadata, file) {
|
|
37268
|
-
const depInfo =
|
|
37435
|
+
const depInfo = optimizedDepInfoFromFile(metadata, file);
|
|
37269
37436
|
if (!depInfo)
|
|
37270
37437
|
return undefined;
|
|
37271
37438
|
// Wait until the dependency has been pre-bundled
|
|
@@ -37275,17 +37442,25 @@ async function optimizedDepNeedsInterop(metadata, file) {
|
|
|
37275
37442
|
|
|
37276
37443
|
var index$1 = {
|
|
37277
37444
|
__proto__: null,
|
|
37445
|
+
debuggerViteDeps: debuggerViteDeps,
|
|
37278
37446
|
optimizeDeps: optimizeDeps,
|
|
37279
|
-
|
|
37447
|
+
createOptimizedDepsMetadata: createOptimizedDepsMetadata,
|
|
37448
|
+
addOptimizedDepInfo: addOptimizedDepInfo,
|
|
37449
|
+
loadCachedDepOptimizationMetadata: loadCachedDepOptimizationMetadata,
|
|
37450
|
+
discoverProjectDependencies: discoverProjectDependencies,
|
|
37451
|
+
depsLogString: depsLogString,
|
|
37452
|
+
runOptimizeDeps: runOptimizeDeps,
|
|
37280
37453
|
findKnownImports: findKnownImports,
|
|
37281
37454
|
newDepOptimizationProcessing: newDepOptimizationProcessing,
|
|
37282
37455
|
depsFromOptimizedDepInfo: depsFromOptimizedDepInfo,
|
|
37283
|
-
getHash: getHash,
|
|
37284
37456
|
getOptimizedDepPath: getOptimizedDepPath,
|
|
37285
37457
|
getDepsCacheDir: getDepsCacheDir,
|
|
37286
37458
|
isOptimizedDepFile: isOptimizedDepFile,
|
|
37287
37459
|
createIsOptimizedDepUrl: createIsOptimizedDepUrl,
|
|
37288
|
-
|
|
37460
|
+
getDepHash: getDepHash,
|
|
37461
|
+
getHash: getHash,
|
|
37462
|
+
optimizedDepInfoFromId: optimizedDepInfoFromId,
|
|
37463
|
+
optimizedDepInfoFromFile: optimizedDepInfoFromFile,
|
|
37289
37464
|
optimizedDepNeedsInterop: optimizedDepNeedsInterop
|
|
37290
37465
|
};
|
|
37291
37466
|
|
|
@@ -37401,8 +37576,8 @@ function resolve(pkg, entry='.', options={}) {
|
|
|
37401
37576
|
}
|
|
37402
37577
|
}
|
|
37403
37578
|
|
|
37404
|
-
const isDebug$
|
|
37405
|
-
const debug$
|
|
37579
|
+
const isDebug$5 = process.env.DEBUG;
|
|
37580
|
+
const debug$b = createDebugger('vite:resolve-details', {
|
|
37406
37581
|
onlyWhenFocused: true
|
|
37407
37582
|
});
|
|
37408
37583
|
function invalidatePackageData(packageCache, pkgPath) {
|
|
@@ -37434,7 +37609,7 @@ function resolvePackageData(id, basedir, preserveSymlinks = false, packageCache)
|
|
|
37434
37609
|
}
|
|
37435
37610
|
catch (e) {
|
|
37436
37611
|
if (e instanceof SyntaxError) {
|
|
37437
|
-
isDebug$
|
|
37612
|
+
isDebug$5 && debug$b(`Parsing failed: ${pkgPath}`);
|
|
37438
37613
|
}
|
|
37439
37614
|
// Ignore error for missing package.json
|
|
37440
37615
|
else if (e.code !== 'MODULE_NOT_FOUND') {
|
|
@@ -37524,8 +37699,8 @@ function watchPackageDataPlugin(config) {
|
|
|
37524
37699
|
// special id for paths marked with browser: false
|
|
37525
37700
|
// https://github.com/defunctzombie/package-browser-field-spec#ignore-a-module
|
|
37526
37701
|
const browserExternalId = '__vite-browser-external';
|
|
37527
|
-
const isDebug$
|
|
37528
|
-
const debug$
|
|
37702
|
+
const isDebug$4 = process.env.DEBUG;
|
|
37703
|
+
const debug$a = createDebugger('vite:resolve-details', {
|
|
37529
37704
|
onlyWhenFocused: true
|
|
37530
37705
|
});
|
|
37531
37706
|
function resolvePlugin(baseOptions) {
|
|
@@ -37539,8 +37714,8 @@ function resolvePlugin(baseOptions) {
|
|
|
37539
37714
|
server = _server;
|
|
37540
37715
|
isOptimizedDepUrl = createIsOptimizedDepUrl(server.config);
|
|
37541
37716
|
},
|
|
37542
|
-
resolveId(id, importer, resolveOpts) {
|
|
37543
|
-
var _a, _b, _c, _d;
|
|
37717
|
+
async resolveId(id, importer, resolveOpts) {
|
|
37718
|
+
var _a, _b, _c, _d, _e;
|
|
37544
37719
|
const ssr = (resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.ssr) === true;
|
|
37545
37720
|
if (id.startsWith(browserExternalId)) {
|
|
37546
37721
|
return id;
|
|
@@ -37555,22 +37730,24 @@ function resolvePlugin(baseOptions) {
|
|
|
37555
37730
|
const options = {
|
|
37556
37731
|
isRequire,
|
|
37557
37732
|
...baseOptions,
|
|
37558
|
-
isFromTsImporter: isTsRequest(importer !== null && importer !== void 0 ? importer : '')
|
|
37733
|
+
isFromTsImporter: isTsRequest(importer !== null && importer !== void 0 ? importer : ''),
|
|
37734
|
+
scan: (_d = resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.scan) !== null && _d !== void 0 ? _d : baseOptions.scan
|
|
37559
37735
|
};
|
|
37560
37736
|
let res;
|
|
37561
37737
|
// resolve pre-bundled deps requests, these could be resolved by
|
|
37562
37738
|
// tryFileResolve or /fs/ resolution but these files may not yet
|
|
37563
37739
|
// exists if we are in the middle of a deps re-processing
|
|
37564
37740
|
if (asSrc && (isOptimizedDepUrl === null || isOptimizedDepUrl === void 0 ? void 0 : isOptimizedDepUrl(id))) {
|
|
37565
|
-
|
|
37741
|
+
const optimizedPath = id.startsWith(FS_PREFIX)
|
|
37566
37742
|
? fsPathFromId(id)
|
|
37567
37743
|
: normalizePath$4(ensureVolumeInPath(path__default.resolve(root, id.slice(1))));
|
|
37744
|
+
return optimizedPath;
|
|
37568
37745
|
}
|
|
37569
37746
|
// explicit fs paths that starts with /@fs/*
|
|
37570
37747
|
if (asSrc && id.startsWith(FS_PREFIX)) {
|
|
37571
37748
|
const fsPath = fsPathFromId(id);
|
|
37572
37749
|
res = tryFsResolve(fsPath, options);
|
|
37573
|
-
isDebug$
|
|
37750
|
+
isDebug$4 && debug$a(`[@fs] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
37574
37751
|
// always return here even if res doesn't exist since /@fs/ is explicit
|
|
37575
37752
|
// if the file doesn't exist it should be a 404
|
|
37576
37753
|
return res || fsPath;
|
|
@@ -37580,7 +37757,7 @@ function resolvePlugin(baseOptions) {
|
|
|
37580
37757
|
if (asSrc && id.startsWith('/')) {
|
|
37581
37758
|
const fsPath = path__default.resolve(root, id.slice(1));
|
|
37582
37759
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
37583
|
-
isDebug$
|
|
37760
|
+
isDebug$4 && debug$a(`[url] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
37584
37761
|
return res;
|
|
37585
37762
|
}
|
|
37586
37763
|
}
|
|
@@ -37590,11 +37767,12 @@ function resolvePlugin(baseOptions) {
|
|
|
37590
37767
|
const fsPath = path__default.resolve(basedir, id);
|
|
37591
37768
|
// handle browser field mapping for relative imports
|
|
37592
37769
|
const normalizedFsPath = normalizePath$4(fsPath);
|
|
37593
|
-
if (server
|
|
37770
|
+
if ((server === null || server === void 0 ? void 0 : server._optimizedDeps) &&
|
|
37771
|
+
isOptimizedDepFile(normalizedFsPath, server.config)) {
|
|
37594
37772
|
// Optimized files could not yet exist in disk, resolve to the full path
|
|
37595
37773
|
// Inject the current browserHash version if the path doesn't have one
|
|
37596
37774
|
if (!normalizedFsPath.match(DEP_VERSION_RE)) {
|
|
37597
|
-
const browserHash = (
|
|
37775
|
+
const browserHash = (_e = optimizedDepInfoFromFile(server._optimizedDeps.metadata, normalizedFsPath)) === null || _e === void 0 ? void 0 : _e.browserHash;
|
|
37598
37776
|
if (browserHash) {
|
|
37599
37777
|
return injectQuery(normalizedFsPath, `v=${browserHash}`);
|
|
37600
37778
|
}
|
|
@@ -37616,8 +37794,8 @@ function resolvePlugin(baseOptions) {
|
|
|
37616
37794
|
return res;
|
|
37617
37795
|
}
|
|
37618
37796
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
37619
|
-
isDebug$
|
|
37620
|
-
debug$
|
|
37797
|
+
isDebug$4 &&
|
|
37798
|
+
debug$a(`[relative] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
37621
37799
|
const pkg = importer != null && idToPkgMap.get(importer);
|
|
37622
37800
|
if (pkg) {
|
|
37623
37801
|
idToPkgMap.set(res, pkg);
|
|
@@ -37631,7 +37809,7 @@ function resolvePlugin(baseOptions) {
|
|
|
37631
37809
|
}
|
|
37632
37810
|
// absolute fs paths
|
|
37633
37811
|
if (path__default.isAbsolute(id) && (res = tryFsResolve(id, options))) {
|
|
37634
|
-
isDebug$
|
|
37812
|
+
isDebug$4 && debug$a(`[fs] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
37635
37813
|
return res;
|
|
37636
37814
|
}
|
|
37637
37815
|
// external
|
|
@@ -37651,7 +37829,8 @@ function resolvePlugin(baseOptions) {
|
|
|
37651
37829
|
if (asSrc &&
|
|
37652
37830
|
server &&
|
|
37653
37831
|
!ssr &&
|
|
37654
|
-
|
|
37832
|
+
!options.scan &&
|
|
37833
|
+
(res = await tryOptimizedResolve(id, server, importer))) {
|
|
37655
37834
|
return res;
|
|
37656
37835
|
}
|
|
37657
37836
|
if (targetWeb &&
|
|
@@ -37680,7 +37859,7 @@ function resolvePlugin(baseOptions) {
|
|
|
37680
37859
|
}
|
|
37681
37860
|
else {
|
|
37682
37861
|
if (!asSrc) {
|
|
37683
|
-
debug$
|
|
37862
|
+
debug$a(`externalized node built-in "${id}" to empty module. ` +
|
|
37684
37863
|
`(imported by: ${colors$1.white(colors$1.dim(importer))})`);
|
|
37685
37864
|
}
|
|
37686
37865
|
return isProduction
|
|
@@ -37689,7 +37868,7 @@ function resolvePlugin(baseOptions) {
|
|
|
37689
37868
|
}
|
|
37690
37869
|
}
|
|
37691
37870
|
}
|
|
37692
|
-
isDebug$
|
|
37871
|
+
isDebug$4 && debug$a(`[fallthrough] ${colors$1.dim(id)}`);
|
|
37693
37872
|
},
|
|
37694
37873
|
load(id) {
|
|
37695
37874
|
if (id.startsWith(browserExternalId)) {
|
|
@@ -37786,7 +37965,7 @@ function tryResolveFile(file, postfix, options, tryIndex, targetWeb, tryPrefix,
|
|
|
37786
37965
|
}
|
|
37787
37966
|
const idToPkgMap = new Map();
|
|
37788
37967
|
function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
37789
|
-
var _a
|
|
37968
|
+
var _a;
|
|
37790
37969
|
const { root, dedupe, isBuild, preserveSymlinks, packageCache } = options;
|
|
37791
37970
|
// split id by last '>' for nested selected packages, for example:
|
|
37792
37971
|
// 'foo > bar > baz' => 'foo > bar' & 'baz'
|
|
@@ -37877,7 +38056,8 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
37877
38056
|
else {
|
|
37878
38057
|
if (!resolved.includes('node_modules') || // linked
|
|
37879
38058
|
!server || // build
|
|
37880
|
-
!server.
|
|
38059
|
+
!server._optimizedDeps || // resolving before listening to the server
|
|
38060
|
+
options.scan // initial esbuild scan phase
|
|
37881
38061
|
) {
|
|
37882
38062
|
return { id: resolved };
|
|
37883
38063
|
}
|
|
@@ -37895,7 +38075,7 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
37895
38075
|
// can cache it without re-validation, but only do so for known js types.
|
|
37896
38076
|
// otherwise we may introduce duplicated modules for externalized files
|
|
37897
38077
|
// from pre-bundled deps.
|
|
37898
|
-
const versionHash =
|
|
38078
|
+
const versionHash = server._optimizedDeps.metadata.browserHash;
|
|
37899
38079
|
if (versionHash && isJsType) {
|
|
37900
38080
|
resolved = injectQuery(resolved, `v=${versionHash}`);
|
|
37901
38081
|
}
|
|
@@ -37903,31 +38083,30 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
|
|
|
37903
38083
|
else {
|
|
37904
38084
|
// this is a missing import, queue optimize-deps re-run and
|
|
37905
38085
|
// get a resolved its optimized info
|
|
37906
|
-
const optimizedInfo = server.
|
|
38086
|
+
const optimizedInfo = server._optimizedDeps.registerMissingImport(id, resolved);
|
|
37907
38087
|
resolved = getOptimizedUrl(optimizedInfo);
|
|
37908
38088
|
}
|
|
37909
38089
|
return { id: resolved };
|
|
37910
38090
|
}
|
|
37911
38091
|
}
|
|
37912
38092
|
const getOptimizedUrl = (optimizedData) => `${optimizedData.file}?v=${optimizedData.browserHash}`;
|
|
37913
|
-
function tryOptimizedResolve(id, server, importer) {
|
|
37914
|
-
const
|
|
37915
|
-
if (!
|
|
38093
|
+
async function tryOptimizedResolve(id, server, importer) {
|
|
38094
|
+
const optimizedDeps = server._optimizedDeps;
|
|
38095
|
+
if (!optimizedDeps)
|
|
37916
38096
|
return;
|
|
37917
|
-
|
|
37918
|
-
const
|
|
37919
|
-
if (
|
|
37920
|
-
return getOptimizedUrl(
|
|
37921
|
-
}
|
|
37922
|
-
const isChunk = depData.chunks[id];
|
|
37923
|
-
if (isChunk) {
|
|
37924
|
-
return getOptimizedUrl(isChunk);
|
|
38097
|
+
await optimizedDeps.scanProcessing;
|
|
38098
|
+
const depInfo = optimizedDepInfoFromId(optimizedDeps.metadata, id);
|
|
38099
|
+
if (depInfo) {
|
|
38100
|
+
return getOptimizedUrl(depInfo);
|
|
37925
38101
|
}
|
|
37926
38102
|
if (!importer)
|
|
37927
38103
|
return;
|
|
37928
38104
|
// further check if id is imported by nested dependency
|
|
37929
38105
|
let resolvedSrc;
|
|
37930
|
-
for (const
|
|
38106
|
+
for (const optimizedData of optimizedDeps.metadata.depInfoList) {
|
|
38107
|
+
if (!optimizedData.src)
|
|
38108
|
+
continue; // Ignore chunks
|
|
38109
|
+
const pkgPath = optimizedData.id;
|
|
37931
38110
|
// check for scenarios, e.g.
|
|
37932
38111
|
// pkgPath => "my-lib > foo"
|
|
37933
38112
|
// id => "foo"
|
|
@@ -37976,7 +38155,9 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
37976
38155
|
: isObject$4(data.browser) && data.browser['.'];
|
|
37977
38156
|
if (browserEntry) {
|
|
37978
38157
|
// check if the package also has a "module" field.
|
|
37979
|
-
if (
|
|
38158
|
+
if (!options.isRequire &&
|
|
38159
|
+
typeof data.module === 'string' &&
|
|
38160
|
+
data.module !== browserEntry) {
|
|
37980
38161
|
// if both are present, we may have a problem: some package points both
|
|
37981
38162
|
// to ESM, with "module" targeting Node.js, while some packages points
|
|
37982
38163
|
// "module" to browser ESM and "browser" to UMD.
|
|
@@ -38028,8 +38209,8 @@ function resolvePackageEntry(id, { dir, data, setResolvedCache, getResolvedCache
|
|
|
38028
38209
|
const entryPointPath = path__default.join(dir, entry);
|
|
38029
38210
|
const resolvedEntryPoint = tryFsResolve(entryPointPath, options);
|
|
38030
38211
|
if (resolvedEntryPoint) {
|
|
38031
|
-
isDebug$
|
|
38032
|
-
debug$
|
|
38212
|
+
isDebug$4 &&
|
|
38213
|
+
debug$a(`[package entry] ${colors$1.cyan(id)} -> ${colors$1.dim(resolvedEntryPoint)}`);
|
|
38033
38214
|
setResolvedCache('.', resolvedEntryPoint, targetWeb);
|
|
38034
38215
|
return resolvedEntryPoint;
|
|
38035
38216
|
}
|
|
@@ -38093,8 +38274,8 @@ function resolveDeepImport(id, { webResolvedImports, setResolvedCache, getResolv
|
|
|
38093
38274
|
const resolved = tryFsResolve(path__default.join(dir, relativeId), options, !exportsField, // try index only if no exports field
|
|
38094
38275
|
targetWeb);
|
|
38095
38276
|
if (resolved) {
|
|
38096
|
-
isDebug$
|
|
38097
|
-
debug$
|
|
38277
|
+
isDebug$4 &&
|
|
38278
|
+
debug$a(`[node/deep-import] ${colors$1.cyan(id)} -> ${colors$1.dim(resolved)}`);
|
|
38098
38279
|
setResolvedCache(id, resolved, targetWeb);
|
|
38099
38280
|
return resolved;
|
|
38100
38281
|
}
|
|
@@ -38109,8 +38290,8 @@ function tryResolveBrowserMapping(id, importer, options, isFilePath) {
|
|
|
38109
38290
|
if (browserMappedPath) {
|
|
38110
38291
|
const fsPath = path__default.join(pkg.dir, browserMappedPath);
|
|
38111
38292
|
if ((res = tryFsResolve(fsPath, options))) {
|
|
38112
|
-
isDebug$
|
|
38113
|
-
debug$
|
|
38293
|
+
isDebug$4 &&
|
|
38294
|
+
debug$a(`[browser mapped] ${colors$1.cyan(id)} -> ${colors$1.dim(res)}`);
|
|
38114
38295
|
idToPkgMap.set(res, pkg);
|
|
38115
38296
|
return {
|
|
38116
38297
|
id: res,
|
|
@@ -38153,7 +38334,7 @@ function getRealPath(resolved, preserveSymlinks) {
|
|
|
38153
38334
|
return normalizePath$4(resolved);
|
|
38154
38335
|
}
|
|
38155
38336
|
|
|
38156
|
-
const debug$
|
|
38337
|
+
const debug$9 = createDebugger('vite:ssr-external');
|
|
38157
38338
|
/**
|
|
38158
38339
|
* Converts "parent > child" syntax to just "child"
|
|
38159
38340
|
*/
|
|
@@ -38248,7 +38429,7 @@ function collectExternals(root, preserveSymlinks, ssrExternals, seen, logger) {
|
|
|
38248
38429
|
}
|
|
38249
38430
|
catch { }
|
|
38250
38431
|
// resolve failed, assume include
|
|
38251
|
-
debug$
|
|
38432
|
+
debug$9(`Failed to resolve entries for package "${id}"\n`, e);
|
|
38252
38433
|
continue;
|
|
38253
38434
|
}
|
|
38254
38435
|
// no esm entry but has require entry
|
|
@@ -38431,7 +38612,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
38431
38612
|
// target so we use the global location here. It can be
|
|
38432
38613
|
// window.location or self.location in case it is used in a Web Worker.
|
|
38433
38614
|
// @see https://developer.mozilla.org/en-US/docs/Web/API/Window/self
|
|
38434
|
-
s.overwrite(index, index + exp.length, `new URL(import.meta.globEagerDefault(${JSON.stringify(pattern)})[${rawUrl}], self.location)
|
|
38615
|
+
s.overwrite(index, index + exp.length, `new URL(import.meta.globEagerDefault(${JSON.stringify(pattern)})[${rawUrl}], self.location)`, { contentOnly: true });
|
|
38435
38616
|
continue;
|
|
38436
38617
|
}
|
|
38437
38618
|
}
|
|
@@ -38443,7 +38624,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
|
38443
38624
|
config.logger.warnOnce(`\n${exp} doesn't exist at build time, it will remain unchanged to be resolved at runtime`);
|
|
38444
38625
|
return url;
|
|
38445
38626
|
});
|
|
38446
|
-
s.overwrite(index, index + exp.length, `new URL(${JSON.stringify(builtUrl)}, self.location)
|
|
38627
|
+
s.overwrite(index, index + exp.length, `new URL(${JSON.stringify(builtUrl)}, self.location)`, { contentOnly: true });
|
|
38447
38628
|
}
|
|
38448
38629
|
if (s) {
|
|
38449
38630
|
return {
|
|
@@ -38939,7 +39120,7 @@ var src = {exports: {}};
|
|
|
38939
39120
|
|
|
38940
39121
|
var browser = {exports: {}};
|
|
38941
39122
|
|
|
38942
|
-
var debug$
|
|
39123
|
+
var debug$8 = {exports: {}};
|
|
38943
39124
|
|
|
38944
39125
|
/**
|
|
38945
39126
|
* Helpers.
|
|
@@ -39296,7 +39477,7 @@ function coerce(val) {
|
|
|
39296
39477
|
if (val instanceof Error) return val.stack || val.message;
|
|
39297
39478
|
return val;
|
|
39298
39479
|
}
|
|
39299
|
-
}(debug$
|
|
39480
|
+
}(debug$8, debug$8.exports));
|
|
39300
39481
|
|
|
39301
39482
|
/**
|
|
39302
39483
|
* This is the web browser implementation of `debug()`.
|
|
@@ -39305,7 +39486,7 @@ function coerce(val) {
|
|
|
39305
39486
|
*/
|
|
39306
39487
|
|
|
39307
39488
|
(function (module, exports) {
|
|
39308
|
-
exports = module.exports = debug$
|
|
39489
|
+
exports = module.exports = debug$8.exports;
|
|
39309
39490
|
exports.log = log;
|
|
39310
39491
|
exports.formatArgs = formatArgs;
|
|
39311
39492
|
exports.save = save;
|
|
@@ -39502,7 +39683,7 @@ var util = require$$0__default$1;
|
|
|
39502
39683
|
* Expose `debug()` as the module.
|
|
39503
39684
|
*/
|
|
39504
39685
|
|
|
39505
|
-
exports = module.exports = debug$
|
|
39686
|
+
exports = module.exports = debug$8.exports;
|
|
39506
39687
|
exports.init = init;
|
|
39507
39688
|
exports.log = log;
|
|
39508
39689
|
exports.formatArgs = formatArgs;
|
|
@@ -40592,7 +40773,7 @@ function unpipe$1(stream) {
|
|
|
40592
40773
|
* @private
|
|
40593
40774
|
*/
|
|
40594
40775
|
|
|
40595
|
-
var debug$
|
|
40776
|
+
var debug$7 = src.exports('finalhandler');
|
|
40596
40777
|
var encodeUrl = encodeurl;
|
|
40597
40778
|
var escapeHtml = escapeHtml_1;
|
|
40598
40779
|
var onFinished = onFinished$2.exports;
|
|
@@ -40671,7 +40852,7 @@ function finalhandler$1 (req, res, options) {
|
|
|
40671
40852
|
|
|
40672
40853
|
// ignore 404 on in-flight response
|
|
40673
40854
|
if (!err && headersSent(res)) {
|
|
40674
|
-
debug$
|
|
40855
|
+
debug$7('cannot 404 after headers sent');
|
|
40675
40856
|
return
|
|
40676
40857
|
}
|
|
40677
40858
|
|
|
@@ -40696,7 +40877,7 @@ function finalhandler$1 (req, res, options) {
|
|
|
40696
40877
|
msg = 'Cannot ' + req.method + ' ' + encodeUrl(getResourceName(req));
|
|
40697
40878
|
}
|
|
40698
40879
|
|
|
40699
|
-
debug$
|
|
40880
|
+
debug$7('default %s', status);
|
|
40700
40881
|
|
|
40701
40882
|
// schedule onerror callback
|
|
40702
40883
|
if (err && onerror) {
|
|
@@ -40705,7 +40886,7 @@ function finalhandler$1 (req, res, options) {
|
|
|
40705
40886
|
|
|
40706
40887
|
// cannot actually respond
|
|
40707
40888
|
if (headersSent(res)) {
|
|
40708
|
-
debug$
|
|
40889
|
+
debug$7('cannot %d after headers sent', status);
|
|
40709
40890
|
req.socket.destroy();
|
|
40710
40891
|
return
|
|
40711
40892
|
}
|
|
@@ -40952,7 +41133,7 @@ module.exports = function(a, b){
|
|
|
40952
41133
|
* @private
|
|
40953
41134
|
*/
|
|
40954
41135
|
|
|
40955
|
-
var debug$
|
|
41136
|
+
var debug$6 = src.exports('connect:dispatcher');
|
|
40956
41137
|
var EventEmitter$3 = require$$0__default$3.EventEmitter;
|
|
40957
41138
|
var finalhandler = finalhandler_1;
|
|
40958
41139
|
var http$4 = require$$1__default$2;
|
|
@@ -41042,7 +41223,7 @@ proto.use = function use(route, fn) {
|
|
|
41042
41223
|
}
|
|
41043
41224
|
|
|
41044
41225
|
// add the middleware
|
|
41045
|
-
debug$
|
|
41226
|
+
debug$6('use %s %s', path || '/', handle.name || 'anonymous');
|
|
41046
41227
|
this.stack.push({ route: path, handle: handle });
|
|
41047
41228
|
|
|
41048
41229
|
return this;
|
|
@@ -41166,7 +41347,7 @@ function call(handle, route, err, req, res, next) {
|
|
|
41166
41347
|
var error = err;
|
|
41167
41348
|
var hasError = Boolean(err);
|
|
41168
41349
|
|
|
41169
|
-
debug$
|
|
41350
|
+
debug$6('%s %s : %s', handle.name || '<anonymous>', route, req.originalUrl);
|
|
41170
41351
|
|
|
41171
41352
|
try {
|
|
41172
41353
|
if (hasError && arity === 4) {
|
|
@@ -44660,7 +44841,7 @@ async function getCertificate(cacheDir) {
|
|
|
44660
44841
|
return content;
|
|
44661
44842
|
}
|
|
44662
44843
|
catch {
|
|
44663
|
-
const content = (await Promise.resolve().then(function () { return require('./dep-
|
|
44844
|
+
const content = (await Promise.resolve().then(function () { return require('./dep-35d2a41c.js'); })).createCertificate();
|
|
44664
44845
|
fs$n.promises
|
|
44665
44846
|
.mkdir(cacheDir, { recursive: true })
|
|
44666
44847
|
.then(() => fs$n.promises.writeFile(cachePath, content))
|
|
@@ -48892,8 +49073,11 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
48892
49073
|
let wss;
|
|
48893
49074
|
let httpsServer = undefined;
|
|
48894
49075
|
const hmr = isObject$4(config.server.hmr) && config.server.hmr;
|
|
48895
|
-
const
|
|
48896
|
-
|
|
49076
|
+
const hmrServer = hmr && hmr.server;
|
|
49077
|
+
const hmrPort = hmr && hmr.port;
|
|
49078
|
+
// TODO: the main server port may not have been chosen yet as it may use the next available
|
|
49079
|
+
const portsAreCompatible = !hmrPort || hmrPort === config.server.port;
|
|
49080
|
+
const wsServer = hmrServer || (portsAreCompatible && server);
|
|
48897
49081
|
if (wsServer) {
|
|
48898
49082
|
wss = new websocketServer({ noServer: true });
|
|
48899
49083
|
wsServer.on('upgrade', (req, socket, head) => {
|
|
@@ -48906,7 +49090,7 @@ function createWebSocketServer(server, config, httpsOptions) {
|
|
|
48906
49090
|
}
|
|
48907
49091
|
else {
|
|
48908
49092
|
const websocketServerOptions = {};
|
|
48909
|
-
const port =
|
|
49093
|
+
const port = hmrPort || 24678;
|
|
48910
49094
|
const host = (hmr && hmr.host) || undefined;
|
|
48911
49095
|
if (httpsOptions) {
|
|
48912
49096
|
// if we're serving the middlewares over https, the ws library doesn't support automatically creating an https server, so we need to do it ourselves
|
|
@@ -49820,20 +50004,20 @@ var webOutgoing = { // <--
|
|
|
49820
50004
|
|
|
49821
50005
|
var followRedirects$1 = {exports: {}};
|
|
49822
50006
|
|
|
49823
|
-
var debug$
|
|
50007
|
+
var debug$5;
|
|
49824
50008
|
|
|
49825
50009
|
var debug_1 = function () {
|
|
49826
|
-
if (!debug$
|
|
50010
|
+
if (!debug$5) {
|
|
49827
50011
|
try {
|
|
49828
50012
|
/* eslint global-require: off */
|
|
49829
|
-
debug$
|
|
50013
|
+
debug$5 = require("debug")("follow-redirects");
|
|
49830
50014
|
}
|
|
49831
50015
|
catch (error) { /* */ }
|
|
49832
|
-
if (typeof debug$
|
|
49833
|
-
debug$
|
|
50016
|
+
if (typeof debug$5 !== "function") {
|
|
50017
|
+
debug$5 = function () { /* */ };
|
|
49834
50018
|
}
|
|
49835
50019
|
}
|
|
49836
|
-
debug$
|
|
50020
|
+
debug$5.apply(null, arguments);
|
|
49837
50021
|
};
|
|
49838
50022
|
|
|
49839
50023
|
var url$1 = require$$0__default$5;
|
|
@@ -49842,7 +50026,7 @@ var http$1 = require$$1__default$2;
|
|
|
49842
50026
|
var https$1 = require$$1__default$4;
|
|
49843
50027
|
var Writable = require$$0__default$2.Writable;
|
|
49844
50028
|
var assert = require$$5__default;
|
|
49845
|
-
var debug$
|
|
50029
|
+
var debug$4 = debug_1;
|
|
49846
50030
|
|
|
49847
50031
|
// Create handlers that pass events from native requests
|
|
49848
50032
|
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
|
|
@@ -50225,7 +50409,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
|
|
50225
50409
|
}
|
|
50226
50410
|
|
|
50227
50411
|
// Create the redirected request
|
|
50228
|
-
debug$
|
|
50412
|
+
debug$4("redirecting to", redirectUrl);
|
|
50229
50413
|
this._isRedirect = true;
|
|
50230
50414
|
var redirectUrlParts = url$1.parse(redirectUrl);
|
|
50231
50415
|
Object.assign(this._options, redirectUrlParts);
|
|
@@ -50316,7 +50500,7 @@ function wrap(protocols) {
|
|
|
50316
50500
|
options.nativeProtocols = nativeProtocols;
|
|
50317
50501
|
|
|
50318
50502
|
assert.equal(options.protocol, protocol, "protocol mismatch");
|
|
50319
|
-
debug$
|
|
50503
|
+
debug$4("options", options);
|
|
50320
50504
|
return new RedirectableRequest(options, callback);
|
|
50321
50505
|
}
|
|
50322
50506
|
|
|
@@ -51031,7 +51215,7 @@ var httpProxy$1 = ProxyServer;
|
|
|
51031
51215
|
|
|
51032
51216
|
var httpProxy = httpProxy$1;
|
|
51033
51217
|
|
|
51034
|
-
const debug$
|
|
51218
|
+
const debug$3 = createDebugger('vite:proxy');
|
|
51035
51219
|
function proxyMiddleware(httpServer, config) {
|
|
51036
51220
|
const options = config.server.proxy;
|
|
51037
51221
|
// lazy require only when proxy is used
|
|
@@ -51066,7 +51250,7 @@ function proxyMiddleware(httpServer, config) {
|
|
|
51066
51250
|
if (opts.rewrite) {
|
|
51067
51251
|
req.url = opts.rewrite(url);
|
|
51068
51252
|
}
|
|
51069
|
-
debug$
|
|
51253
|
+
debug$3(`${req.url} -> ws ${opts.target}`);
|
|
51070
51254
|
proxy.ws(req, socket, head);
|
|
51071
51255
|
return;
|
|
51072
51256
|
}
|
|
@@ -51085,20 +51269,20 @@ function proxyMiddleware(httpServer, config) {
|
|
|
51085
51269
|
const bypassResult = opts.bypass(req, res, opts);
|
|
51086
51270
|
if (typeof bypassResult === 'string') {
|
|
51087
51271
|
req.url = bypassResult;
|
|
51088
|
-
debug$
|
|
51272
|
+
debug$3(`bypass: ${req.url} -> ${bypassResult}`);
|
|
51089
51273
|
return next();
|
|
51090
51274
|
}
|
|
51091
51275
|
else if (isObject$4(bypassResult)) {
|
|
51092
51276
|
Object.assign(options, bypassResult);
|
|
51093
|
-
debug$
|
|
51277
|
+
debug$3(`bypass: ${req.url} use modified options: %O`, options);
|
|
51094
51278
|
return next();
|
|
51095
51279
|
}
|
|
51096
51280
|
else if (bypassResult === false) {
|
|
51097
|
-
debug$
|
|
51281
|
+
debug$3(`bypass: ${req.url} -> 404`);
|
|
51098
51282
|
return res.end(404);
|
|
51099
51283
|
}
|
|
51100
51284
|
}
|
|
51101
|
-
debug$
|
|
51285
|
+
debug$3(`${req.url} -> ${opts.target || opts.forward}`);
|
|
51102
51286
|
if (opts.rewrite) {
|
|
51103
51287
|
req.url = opts.rewrite(req.url);
|
|
51104
51288
|
}
|
|
@@ -51395,7 +51579,6 @@ function stattag (stat) {
|
|
|
51395
51579
|
return '"' + size + '-' + mtime + '"'
|
|
51396
51580
|
}
|
|
51397
51581
|
|
|
51398
|
-
const isDebug$5 = process.env.DEBUG;
|
|
51399
51582
|
const alias$1 = {
|
|
51400
51583
|
js: 'application/javascript',
|
|
51401
51584
|
css: 'text/css',
|
|
@@ -51422,21 +51605,14 @@ function send$1(req, res, content, type, options) {
|
|
|
51422
51605
|
}
|
|
51423
51606
|
// inject source map reference
|
|
51424
51607
|
if (map && map.mappings) {
|
|
51425
|
-
if (
|
|
51426
|
-
content
|
|
51608
|
+
if (type === 'js' || type === 'css') {
|
|
51609
|
+
content = getCodeWithSourcemap(type, content.toString(), map);
|
|
51427
51610
|
}
|
|
51428
|
-
content += genSourceMapString(map);
|
|
51429
51611
|
}
|
|
51430
51612
|
res.statusCode = 200;
|
|
51431
51613
|
res.end(content);
|
|
51432
51614
|
return;
|
|
51433
51615
|
}
|
|
51434
|
-
function genSourceMapString(map) {
|
|
51435
|
-
if (typeof map !== 'string') {
|
|
51436
|
-
map = JSON.stringify(map);
|
|
51437
|
-
}
|
|
51438
|
-
return `\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(map).toString('base64')}`;
|
|
51439
|
-
}
|
|
51440
51616
|
|
|
51441
51617
|
var convertSourceMap = {};
|
|
51442
51618
|
|
|
@@ -51826,7 +52002,7 @@ async function ssrTransform(code, inMap, url) {
|
|
|
51826
52002
|
}
|
|
51827
52003
|
else {
|
|
51828
52004
|
// anonymous default exports
|
|
51829
|
-
s.overwrite(node.start, node.start + 14 /* 'export default'.length */, `${ssrModuleExportsKey}.default
|
|
52005
|
+
s.overwrite(node.start, node.start + 14 /* 'export default'.length */, `${ssrModuleExportsKey}.default =`, { contentOnly: true });
|
|
51830
52006
|
}
|
|
51831
52007
|
}
|
|
51832
52008
|
// export * from './foo'
|
|
@@ -51871,14 +52047,16 @@ async function ssrTransform(code, inMap, url) {
|
|
|
51871
52047
|
}
|
|
51872
52048
|
}
|
|
51873
52049
|
else {
|
|
51874
|
-
s.overwrite(id.start, id.end, binding);
|
|
52050
|
+
s.overwrite(id.start, id.end, binding, { contentOnly: true });
|
|
51875
52051
|
}
|
|
51876
52052
|
},
|
|
51877
52053
|
onImportMeta(node) {
|
|
51878
|
-
s.overwrite(node.start, node.end, ssrImportMetaKey);
|
|
52054
|
+
s.overwrite(node.start, node.end, ssrImportMetaKey, { contentOnly: true });
|
|
51879
52055
|
},
|
|
51880
52056
|
onDynamicImport(node) {
|
|
51881
|
-
s.overwrite(node.start, node.start + 6, ssrDynamicImportKey
|
|
52057
|
+
s.overwrite(node.start, node.start + 6, ssrDynamicImportKey, {
|
|
52058
|
+
contentOnly: true
|
|
52059
|
+
});
|
|
51882
52060
|
if (node.type === 'ImportExpression' && node.source.type === 'Literal') {
|
|
51883
52061
|
dynamicDeps.add(node.source.value);
|
|
51884
52062
|
}
|
|
@@ -52104,44 +52282,6 @@ function isInDestructuringAssignment(parent, parentStack) {
|
|
|
52104
52282
|
return false;
|
|
52105
52283
|
}
|
|
52106
52284
|
|
|
52107
|
-
const isDebug$4 = !!process.env.DEBUG;
|
|
52108
|
-
const debug$3 = createDebugger('vite:sourcemap', {
|
|
52109
|
-
onlyWhenFocused: true
|
|
52110
|
-
});
|
|
52111
|
-
// Virtual modules should be prefixed with a null byte to avoid a
|
|
52112
|
-
// false positive "missing source" warning. We also check for certain
|
|
52113
|
-
// prefixes used for special handling in esbuildDepPlugin.
|
|
52114
|
-
const virtualSourceRE = /^(\0|dep:|browser-external:)/;
|
|
52115
|
-
async function injectSourcesContent(map, file, logger) {
|
|
52116
|
-
let sourceRoot;
|
|
52117
|
-
try {
|
|
52118
|
-
// The source root is undefined for virtual modules and permission errors.
|
|
52119
|
-
sourceRoot = await fs$n.promises.realpath(path__default.resolve(path__default.dirname(file), map.sourceRoot || ''));
|
|
52120
|
-
}
|
|
52121
|
-
catch { }
|
|
52122
|
-
const missingSources = [];
|
|
52123
|
-
map.sourcesContent = await Promise.all(map.sources.map((sourcePath) => {
|
|
52124
|
-
if (sourcePath && !virtualSourceRE.test(sourcePath)) {
|
|
52125
|
-
sourcePath = decodeURI(sourcePath);
|
|
52126
|
-
if (sourceRoot) {
|
|
52127
|
-
sourcePath = path__default.resolve(sourceRoot, sourcePath);
|
|
52128
|
-
}
|
|
52129
|
-
return fs$n.promises.readFile(sourcePath, 'utf-8').catch(() => {
|
|
52130
|
-
missingSources.push(sourcePath);
|
|
52131
|
-
return null;
|
|
52132
|
-
});
|
|
52133
|
-
}
|
|
52134
|
-
return null;
|
|
52135
|
-
}));
|
|
52136
|
-
// Use this command…
|
|
52137
|
-
// DEBUG="vite:sourcemap" vite build
|
|
52138
|
-
// …to log the missing sources.
|
|
52139
|
-
if (missingSources.length) {
|
|
52140
|
-
logger.warnOnce(`Sourcemap for "${file}" points to missing source files`);
|
|
52141
|
-
isDebug$4 && debug$3(`Missing sources:\n ` + missingSources.join(`\n `));
|
|
52142
|
-
}
|
|
52143
|
-
}
|
|
52144
|
-
|
|
52145
52285
|
function totalist(dir, callback, pre='') {
|
|
52146
52286
|
dir = path$p.resolve('.', dir);
|
|
52147
52287
|
let arr = fs$n.readdirSync(dir);
|
|
@@ -52729,8 +52869,9 @@ function optimizedDepsPlugin() {
|
|
|
52729
52869
|
server = _server;
|
|
52730
52870
|
},
|
|
52731
52871
|
async load(id) {
|
|
52872
|
+
var _a, _b;
|
|
52732
52873
|
if (server && isOptimizedDepFile(id, server.config)) {
|
|
52733
|
-
const metadata = server === null || server === void 0 ? void 0 : server.
|
|
52874
|
+
const metadata = (_a = server === null || server === void 0 ? void 0 : server._optimizedDeps) === null || _a === void 0 ? void 0 : _a.metadata;
|
|
52734
52875
|
if (metadata) {
|
|
52735
52876
|
const file = cleanUrl(id);
|
|
52736
52877
|
const versionMatch = id.match(DEP_VERSION_RE);
|
|
@@ -52738,7 +52879,7 @@ function optimizedDepsPlugin() {
|
|
|
52738
52879
|
? versionMatch[1].split('=')[1]
|
|
52739
52880
|
: undefined;
|
|
52740
52881
|
// Search in both the currently optimized and newly discovered deps
|
|
52741
|
-
const info =
|
|
52882
|
+
const info = optimizedDepInfoFromFile(metadata, file);
|
|
52742
52883
|
if (info) {
|
|
52743
52884
|
if (browserHash && info.browserHash !== browserHash) {
|
|
52744
52885
|
throwOutdatedRequest(id);
|
|
@@ -52754,9 +52895,9 @@ function optimizedDepsPlugin() {
|
|
|
52754
52895
|
throwProcessingError(id);
|
|
52755
52896
|
return;
|
|
52756
52897
|
}
|
|
52757
|
-
const newMetadata = server.
|
|
52898
|
+
const newMetadata = (_b = server._optimizedDeps) === null || _b === void 0 ? void 0 : _b.metadata;
|
|
52758
52899
|
if (metadata !== newMetadata) {
|
|
52759
|
-
const currentInfo =
|
|
52900
|
+
const currentInfo = optimizedDepInfoFromFile(newMetadata, file);
|
|
52760
52901
|
if (info.browserHash !== (currentInfo === null || currentInfo === void 0 ? void 0 : currentInfo.browserHash)) {
|
|
52761
52902
|
throwOutdatedRequest(id);
|
|
52762
52903
|
}
|
|
@@ -52961,7 +53102,7 @@ function getHtmlFilename(url, server) {
|
|
|
52961
53102
|
return decodeURIComponent(fsPathFromId(url));
|
|
52962
53103
|
}
|
|
52963
53104
|
else {
|
|
52964
|
-
return decodeURIComponent(path__default.join(server.config.root, url.slice(1)));
|
|
53105
|
+
return decodeURIComponent(normalizePath$4(path__default.join(server.config.root, url.slice(1))));
|
|
52965
53106
|
}
|
|
52966
53107
|
}
|
|
52967
53108
|
const startsWithSingleSlashRE = /^\/(?!\/)/;
|
|
@@ -52976,7 +53117,7 @@ const processNodeUrl = (node, s, config, htmlPath, originalUrl, moduleGraph) =>
|
|
|
52976
53117
|
}
|
|
52977
53118
|
if (startsWithSingleSlashRE.test(url)) {
|
|
52978
53119
|
// prefix with base
|
|
52979
|
-
s.overwrite(node.value.loc.start.offset, node.value.loc.end.offset, `"${config.base + url.slice(1)}"
|
|
53120
|
+
s.overwrite(node.value.loc.start.offset, node.value.loc.end.offset, `"${config.base + url.slice(1)}"`, { contentOnly: true });
|
|
52980
53121
|
}
|
|
52981
53122
|
else if (url.startsWith('.') &&
|
|
52982
53123
|
originalUrl &&
|
|
@@ -52986,10 +53127,10 @@ const processNodeUrl = (node, s, config, htmlPath, originalUrl, moduleGraph) =>
|
|
|
52986
53127
|
// path will add `/a/` prefix, it will caused 404.
|
|
52987
53128
|
// rewrite before `./index.js` -> `localhost:3000/a/index.js`.
|
|
52988
53129
|
// rewrite after `../index.js` -> `localhost:3000/index.js`.
|
|
52989
|
-
s.overwrite(node.value.loc.start.offset, node.value.loc.end.offset, `"${path__default.posix.join(path__default.posix.relative(originalUrl, '/'), url.slice(1))}"
|
|
53130
|
+
s.overwrite(node.value.loc.start.offset, node.value.loc.end.offset, `"${path__default.posix.join(path__default.posix.relative(originalUrl, '/'), url.slice(1))}"`, { contentOnly: true });
|
|
52990
53131
|
}
|
|
52991
53132
|
};
|
|
52992
|
-
const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
|
|
53133
|
+
const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
|
|
52993
53134
|
const { config, moduleGraph } = server;
|
|
52994
53135
|
const base = config.base || '/';
|
|
52995
53136
|
const s = new MagicString$1(html);
|
|
@@ -52998,11 +53139,15 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
|
|
|
52998
53139
|
const addInlineModule = (node, ext) => {
|
|
52999
53140
|
inlineModuleIndex++;
|
|
53000
53141
|
const url = filePath.replace(normalizePath$4(config.root), '');
|
|
53001
|
-
const
|
|
53002
|
-
|
|
53003
|
-
|
|
53142
|
+
const contentNode = node.children[0];
|
|
53143
|
+
const code = contentNode.content;
|
|
53144
|
+
const map = new MagicString$1(html)
|
|
53145
|
+
.snip(contentNode.loc.start.offset, contentNode.loc.end.offset)
|
|
53146
|
+
.generateMap({ hires: true });
|
|
53147
|
+
map.sources = [filename];
|
|
53148
|
+
map.file = filename;
|
|
53004
53149
|
// add HTML Proxy to Map
|
|
53005
|
-
addToHTMLProxyCache(config, url, inlineModuleIndex,
|
|
53150
|
+
addToHTMLProxyCache(config, url, inlineModuleIndex, { code, map });
|
|
53006
53151
|
// inline js module. convert to src="proxy"
|
|
53007
53152
|
const modulePath = `${config.base + htmlPath.slice(1)}?html-proxy&index=${inlineModuleIndex}.${ext}`;
|
|
53008
53153
|
// invalidate the module so the newly cached contents will be served
|
|
@@ -53010,7 +53155,7 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
|
|
|
53010
53155
|
if (module) {
|
|
53011
53156
|
server === null || server === void 0 ? void 0 : server.moduleGraph.invalidateModule(module);
|
|
53012
53157
|
}
|
|
53013
|
-
s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${modulePath}"></script
|
|
53158
|
+
s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${modulePath}"></script>`, { contentOnly: true });
|
|
53014
53159
|
};
|
|
53015
53160
|
await traverseHtml(html, htmlPath, (node) => {
|
|
53016
53161
|
if (node.type !== 1 /* ELEMENT */) {
|
|
@@ -53022,7 +53167,7 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
|
|
|
53022
53167
|
if (src) {
|
|
53023
53168
|
processNodeUrl(src, s, config, htmlPath, originalUrl, moduleGraph);
|
|
53024
53169
|
}
|
|
53025
|
-
else if (isModule) {
|
|
53170
|
+
else if (isModule && node.children.length) {
|
|
53026
53171
|
addInlineModule(node, 'js');
|
|
53027
53172
|
}
|
|
53028
53173
|
}
|
|
@@ -53276,7 +53421,7 @@ async function handleHMRUpdate(file, server) {
|
|
|
53276
53421
|
const { ws, config, moduleGraph } = server;
|
|
53277
53422
|
const shortFile = getShortName(file, config.root);
|
|
53278
53423
|
const isConfig = file === config.configFile;
|
|
53279
|
-
const isConfigDependency = config.configFileDependencies.some((name) => file ===
|
|
53424
|
+
const isConfigDependency = config.configFileDependencies.some((name) => file === name);
|
|
53280
53425
|
const isEnv = config.inlineConfig.envFile !== false &&
|
|
53281
53426
|
(file === '.env' || file.startsWith('.env.'));
|
|
53282
53427
|
if (isConfig || isConfigDependency || isEnv) {
|
|
@@ -55631,16 +55776,33 @@ function isPrimitive(value) {
|
|
|
55631
55776
|
return !value || (typeof value !== 'object' && typeof value !== 'function');
|
|
55632
55777
|
}
|
|
55633
55778
|
|
|
55779
|
+
const isDebugEnabled = _debug('vite:deps').enabled;
|
|
55634
55780
|
/**
|
|
55635
55781
|
* The amount to wait for requests to register newly found dependencies before triggering
|
|
55636
55782
|
* a re-bundle + page reload
|
|
55637
55783
|
*/
|
|
55638
55784
|
const debounceMs = 100;
|
|
55639
|
-
function
|
|
55640
|
-
const {
|
|
55641
|
-
|
|
55785
|
+
function createOptimizedDeps(server) {
|
|
55786
|
+
const { config } = server;
|
|
55787
|
+
const { logger } = config;
|
|
55788
|
+
const sessionTimestamp = Date.now().toString();
|
|
55789
|
+
const cachedMetadata = loadCachedDepOptimizationMetadata(config);
|
|
55790
|
+
const optimizedDeps = {
|
|
55791
|
+
metadata: cachedMetadata || createOptimizedDepsMetadata(config, sessionTimestamp),
|
|
55792
|
+
registerMissingImport
|
|
55793
|
+
};
|
|
55642
55794
|
let handle;
|
|
55643
55795
|
let newDepsDiscovered = false;
|
|
55796
|
+
let newDepsToLog = [];
|
|
55797
|
+
let newDepsToLogHandle;
|
|
55798
|
+
const logNewlyDiscoveredDeps = () => {
|
|
55799
|
+
if (newDepsToLog.length) {
|
|
55800
|
+
config.logger.info(colors$1.green(`✨ new dependencies optimized: ${depsLogString(newDepsToLog)}`), {
|
|
55801
|
+
timestamp: true
|
|
55802
|
+
});
|
|
55803
|
+
newDepsToLog = [];
|
|
55804
|
+
}
|
|
55805
|
+
};
|
|
55644
55806
|
let depOptimizationProcessing = newDepOptimizationProcessing();
|
|
55645
55807
|
let depOptimizationProcessingQueue = [];
|
|
55646
55808
|
const resolveEnqueuedProcessingPromises = () => {
|
|
@@ -55651,28 +55813,59 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55651
55813
|
depOptimizationProcessingQueue = [];
|
|
55652
55814
|
};
|
|
55653
55815
|
let enqueuedRerun;
|
|
55654
|
-
let currentlyProcessing =
|
|
55655
|
-
|
|
55656
|
-
|
|
55657
|
-
|
|
55658
|
-
|
|
55659
|
-
|
|
55660
|
-
|
|
55661
|
-
|
|
55662
|
-
|
|
55816
|
+
let currentlyProcessing = false;
|
|
55817
|
+
// If there wasn't a cache or it is outdated, perform a fast scan with esbuild
|
|
55818
|
+
// to quickly find project dependencies and do a first optimize run
|
|
55819
|
+
if (!cachedMetadata) {
|
|
55820
|
+
currentlyProcessing = true;
|
|
55821
|
+
const scanPhaseProcessing = newDepOptimizationProcessing();
|
|
55822
|
+
optimizedDeps.scanProcessing = scanPhaseProcessing.promise;
|
|
55823
|
+
const warmUp = async () => {
|
|
55824
|
+
try {
|
|
55825
|
+
debuggerViteDeps(colors$1.green(`scanning for dependencies...`), {
|
|
55826
|
+
timestamp: true
|
|
55827
|
+
});
|
|
55828
|
+
const { metadata } = optimizedDeps;
|
|
55829
|
+
const discovered = await discoverProjectDependencies(config, sessionTimestamp);
|
|
55830
|
+
// Respect the scan phase discover order to improve reproducibility
|
|
55831
|
+
for (const depInfo of Object.values(discovered)) {
|
|
55832
|
+
addOptimizedDepInfo(metadata, 'discovered', {
|
|
55833
|
+
...depInfo,
|
|
55834
|
+
processing: depOptimizationProcessing.promise
|
|
55835
|
+
});
|
|
55836
|
+
}
|
|
55837
|
+
debuggerViteDeps(colors$1.green(`dependencies found: ${depsLogString(Object.keys(discovered))}`), {
|
|
55838
|
+
timestamp: true
|
|
55839
|
+
});
|
|
55840
|
+
scanPhaseProcessing.resolve();
|
|
55841
|
+
optimizedDeps.scanProcessing = undefined;
|
|
55842
|
+
runOptimizer();
|
|
55843
|
+
}
|
|
55844
|
+
catch (e) {
|
|
55845
|
+
logger.error(e.message);
|
|
55846
|
+
if (optimizedDeps.scanProcessing) {
|
|
55847
|
+
scanPhaseProcessing.resolve();
|
|
55848
|
+
optimizedDeps.scanProcessing = undefined;
|
|
55849
|
+
}
|
|
55850
|
+
}
|
|
55851
|
+
};
|
|
55852
|
+
setTimeout(warmUp, 0);
|
|
55853
|
+
}
|
|
55854
|
+
async function runOptimizer(isRerun = false) {
|
|
55855
|
+
// Ensure that rerun is called sequentially
|
|
55856
|
+
enqueuedRerun = undefined;
|
|
55857
|
+
currentlyProcessing = true;
|
|
55858
|
+
// Ensure that a rerun will not be issued for current discovered deps
|
|
55859
|
+
if (handle)
|
|
55860
|
+
clearTimeout(handle);
|
|
55663
55861
|
// a succesful completion of the optimizeDeps rerun will end up
|
|
55664
55862
|
// creating new bundled version of all current and discovered deps
|
|
55665
55863
|
// in the cache dir and a new metadata info object assigned
|
|
55666
|
-
// to
|
|
55864
|
+
// to optimizeDeps.metadata. A fullReload is only issued if
|
|
55667
55865
|
// the previous bundled dependencies have changed.
|
|
55668
|
-
// if the rerun fails,
|
|
55866
|
+
// if the rerun fails, optimizeDeps.metadata remains untouched,
|
|
55669
55867
|
// current discovered deps are cleaned, and a fullReload is issued
|
|
55670
|
-
|
|
55671
|
-
enqueuedRerun = undefined;
|
|
55672
|
-
currentlyProcessing = true;
|
|
55673
|
-
logger.info(colors$1.yellow(`new dependencies found: ${Object.keys(metadata.discovered).join(', ')}, updating...`), {
|
|
55674
|
-
timestamp: true
|
|
55675
|
-
});
|
|
55868
|
+
let { metadata } = optimizedDeps;
|
|
55676
55869
|
// All deps, previous known and newly discovered are rebundled,
|
|
55677
55870
|
// respect insertion order to keep the metadata file stable
|
|
55678
55871
|
const newDeps = {};
|
|
@@ -55680,9 +55873,10 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55680
55873
|
for (const dep of Object.keys(metadata.optimized)) {
|
|
55681
55874
|
newDeps[dep] = { ...metadata.optimized[dep] };
|
|
55682
55875
|
}
|
|
55683
|
-
// Don't clone discovered info objects, they are read after awaited
|
|
55684
55876
|
for (const dep of Object.keys(metadata.discovered)) {
|
|
55685
|
-
|
|
55877
|
+
// Clone the discovered info discarding its processing promise
|
|
55878
|
+
const { processing, ...info } = metadata.discovered[dep];
|
|
55879
|
+
newDeps[dep] = info;
|
|
55686
55880
|
}
|
|
55687
55881
|
newDepsDiscovered = false;
|
|
55688
55882
|
// Add the current depOptimizationProcessing to the queue, these
|
|
@@ -55691,32 +55885,70 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55691
55885
|
// Create a new promise for the next rerun, discovered missing
|
|
55692
55886
|
// dependencies will be asigned this promise from this point
|
|
55693
55887
|
depOptimizationProcessing = newDepOptimizationProcessing();
|
|
55694
|
-
let newData = null;
|
|
55695
55888
|
try {
|
|
55696
|
-
const
|
|
55697
|
-
const
|
|
55889
|
+
const processingResult = await runOptimizeDeps(config, newDeps);
|
|
55890
|
+
const newData = processingResult.metadata;
|
|
55891
|
+
// After a re-optimization, if the internal bundled chunks change a full page reload
|
|
55892
|
+
// is required. If the files are stable, we can avoid the reload that is expensive
|
|
55893
|
+
// for large applications. Comparing their fileHash we can find out if it is safe to
|
|
55894
|
+
// keep the current browser state.
|
|
55895
|
+
const needsReload = metadata.hash !== newData.hash ||
|
|
55896
|
+
Object.keys(metadata.optimized).some((dep) => {
|
|
55897
|
+
return (metadata.optimized[dep].fileHash !== newData.optimized[dep].fileHash);
|
|
55898
|
+
});
|
|
55698
55899
|
const commitProcessing = () => {
|
|
55699
55900
|
processingResult.commit();
|
|
55700
|
-
newData = optimizeDeps.metadata;
|
|
55701
|
-
// update ssr externals
|
|
55702
|
-
if (ssr) {
|
|
55703
|
-
server._ssrExternals = resolveSSRExternal(server.config, Object.keys(newData.optimized));
|
|
55704
|
-
}
|
|
55705
55901
|
// While optimizeDeps is running, new missing deps may be discovered,
|
|
55706
55902
|
// in which case they will keep being added to metadata.discovered
|
|
55707
|
-
for (const
|
|
55708
|
-
if (!newData.optimized[
|
|
55709
|
-
newData
|
|
55903
|
+
for (const id in metadata.discovered) {
|
|
55904
|
+
if (!newData.optimized[id]) {
|
|
55905
|
+
addOptimizedDepInfo(newData, 'discovered', metadata.discovered[id]);
|
|
55710
55906
|
}
|
|
55711
55907
|
}
|
|
55712
|
-
|
|
55908
|
+
// If we don't reload the page, we need to keep browserHash stable
|
|
55909
|
+
if (!needsReload) {
|
|
55910
|
+
newData.browserHash = metadata.browserHash;
|
|
55911
|
+
for (const dep in newData.chunks) {
|
|
55912
|
+
newData.chunks[dep].browserHash = metadata.browserHash;
|
|
55913
|
+
}
|
|
55914
|
+
for (const dep in newData.optimized) {
|
|
55915
|
+
newData.optimized[dep].browserHash = (metadata.optimized[dep] || metadata.discovered[dep]).browserHash;
|
|
55916
|
+
}
|
|
55917
|
+
}
|
|
55918
|
+
// Commit hash and needsInterop changes to the discovered deps info
|
|
55919
|
+
// object. Allow for code to await for the discovered processing promise
|
|
55920
|
+
// and use the information in the same object
|
|
55921
|
+
for (const o in newData.optimized) {
|
|
55922
|
+
const discovered = metadata.discovered[o];
|
|
55923
|
+
if (discovered) {
|
|
55924
|
+
const optimized = newData.optimized[o];
|
|
55925
|
+
discovered.browserHash = optimized.browserHash;
|
|
55926
|
+
discovered.fileHash = optimized.fileHash;
|
|
55927
|
+
discovered.needsInterop = optimized.needsInterop;
|
|
55928
|
+
discovered.processing = undefined;
|
|
55929
|
+
}
|
|
55930
|
+
}
|
|
55931
|
+
if (isRerun) {
|
|
55932
|
+
newDepsToLog.push(...Object.keys(newData.optimized).filter((dep) => !metadata.optimized[dep]));
|
|
55933
|
+
}
|
|
55934
|
+
metadata = optimizedDeps.metadata = newData;
|
|
55713
55935
|
resolveEnqueuedProcessingPromises();
|
|
55714
55936
|
};
|
|
55715
|
-
if (!
|
|
55937
|
+
if (!needsReload) {
|
|
55716
55938
|
commitProcessing();
|
|
55717
|
-
|
|
55718
|
-
|
|
55719
|
-
|
|
55939
|
+
if (!isDebugEnabled) {
|
|
55940
|
+
if (newDepsToLogHandle)
|
|
55941
|
+
clearTimeout(newDepsToLogHandle);
|
|
55942
|
+
newDepsToLogHandle = setTimeout(() => {
|
|
55943
|
+
newDepsToLogHandle = undefined;
|
|
55944
|
+
logNewlyDiscoveredDeps();
|
|
55945
|
+
}, 2 * debounceMs);
|
|
55946
|
+
}
|
|
55947
|
+
else {
|
|
55948
|
+
debuggerViteDeps(colors$1.green(`✨ optimized dependencies unchanged`), {
|
|
55949
|
+
timestamp: true
|
|
55950
|
+
});
|
|
55951
|
+
}
|
|
55720
55952
|
}
|
|
55721
55953
|
else {
|
|
55722
55954
|
if (newDepsDiscovered) {
|
|
@@ -55725,13 +55957,19 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55725
55957
|
// We don't resolve the processing promise, as they will be resolved
|
|
55726
55958
|
// once a rerun is committed
|
|
55727
55959
|
processingResult.cancel();
|
|
55728
|
-
|
|
55960
|
+
debuggerViteDeps(colors$1.green(`✨ delaying reload as new dependencies have been found...`), {
|
|
55729
55961
|
timestamp: true
|
|
55730
55962
|
});
|
|
55731
55963
|
}
|
|
55732
55964
|
else {
|
|
55733
55965
|
commitProcessing();
|
|
55734
|
-
|
|
55966
|
+
if (!isDebugEnabled) {
|
|
55967
|
+
if (newDepsToLogHandle)
|
|
55968
|
+
clearTimeout(newDepsToLogHandle);
|
|
55969
|
+
newDepsToLogHandle = undefined;
|
|
55970
|
+
logNewlyDiscoveredDeps();
|
|
55971
|
+
}
|
|
55972
|
+
logger.info(colors$1.green(`✨ optimized dependencies changed. reloading`), {
|
|
55735
55973
|
timestamp: true
|
|
55736
55974
|
});
|
|
55737
55975
|
fullReload();
|
|
@@ -55759,14 +55997,25 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55759
55997
|
path: '*'
|
|
55760
55998
|
});
|
|
55761
55999
|
}
|
|
55762
|
-
|
|
56000
|
+
async function rerun() {
|
|
56001
|
+
// debounce time to wait for new missing deps finished, issue a new
|
|
56002
|
+
// optimization of deps (both old and newly found) once the previous
|
|
56003
|
+
// optimizeDeps processing is finished
|
|
56004
|
+
const deps = Object.keys(optimizedDeps.metadata.discovered);
|
|
56005
|
+
const depsString = depsLogString(deps);
|
|
56006
|
+
debuggerViteDeps(colors$1.green(`new dependencies found: ${depsString}`), {
|
|
56007
|
+
timestamp: true
|
|
56008
|
+
});
|
|
56009
|
+
runOptimizer(true);
|
|
56010
|
+
}
|
|
55763
56011
|
function getDiscoveredBrowserHash(hash, deps, missing) {
|
|
55764
|
-
return getHash(hash +
|
|
55765
|
-
JSON.stringify(deps) +
|
|
55766
|
-
JSON.stringify(missing) +
|
|
55767
|
-
discoveredTimestamp);
|
|
56012
|
+
return getHash(hash + JSON.stringify(deps) + JSON.stringify(missing) + sessionTimestamp);
|
|
55768
56013
|
}
|
|
55769
|
-
|
|
56014
|
+
function registerMissingImport(id, resolved, ssr) {
|
|
56015
|
+
if (optimizedDeps.scanProcessing) {
|
|
56016
|
+
config.logger.error('Vite internal error: registering missing import before initial scanning is over');
|
|
56017
|
+
}
|
|
56018
|
+
const { metadata } = optimizedDeps;
|
|
55770
56019
|
const optimized = metadata.optimized[id];
|
|
55771
56020
|
if (optimized) {
|
|
55772
56021
|
return optimized;
|
|
@@ -55782,7 +56031,8 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55782
56031
|
return missing;
|
|
55783
56032
|
}
|
|
55784
56033
|
newDepsDiscovered = true;
|
|
55785
|
-
missing = metadata
|
|
56034
|
+
missing = addOptimizedDepInfo(metadata, 'discovered', {
|
|
56035
|
+
id,
|
|
55786
56036
|
file: getOptimizedDepPath(id, server.config),
|
|
55787
56037
|
src: resolved,
|
|
55788
56038
|
// Assing a browserHash to this missing dependency that is unique to
|
|
@@ -55793,15 +56043,18 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55793
56043
|
// loading of this pre-bundled dep needs to await for its processing
|
|
55794
56044
|
// promise to be resolved
|
|
55795
56045
|
processing: depOptimizationProcessing.promise
|
|
55796
|
-
};
|
|
56046
|
+
});
|
|
55797
56047
|
// Debounced rerun, let other missing dependencies be discovered before
|
|
55798
56048
|
// the running next optimizeDeps
|
|
55799
56049
|
enqueuedRerun = undefined;
|
|
55800
56050
|
if (handle)
|
|
55801
56051
|
clearTimeout(handle);
|
|
56052
|
+
if (newDepsToLogHandle)
|
|
56053
|
+
clearTimeout(newDepsToLogHandle);
|
|
56054
|
+
newDepsToLogHandle = undefined;
|
|
55802
56055
|
handle = setTimeout(() => {
|
|
55803
56056
|
handle = undefined;
|
|
55804
|
-
enqueuedRerun =
|
|
56057
|
+
enqueuedRerun = rerun;
|
|
55805
56058
|
if (!currentlyProcessing) {
|
|
55806
56059
|
enqueuedRerun();
|
|
55807
56060
|
}
|
|
@@ -55809,7 +56062,8 @@ function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
|
55809
56062
|
// Return the path for the optimized bundle, this path is known before
|
|
55810
56063
|
// esbuild is run to generate the pre-bundle
|
|
55811
56064
|
return missing;
|
|
55812
|
-
}
|
|
56065
|
+
}
|
|
56066
|
+
return optimizedDeps;
|
|
55813
56067
|
}
|
|
55814
56068
|
|
|
55815
56069
|
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
|
@@ -55919,12 +56173,18 @@ async function createServer(inlineConfig = {}) {
|
|
|
55919
56173
|
},
|
|
55920
56174
|
transformIndexHtml: null,
|
|
55921
56175
|
async ssrLoadModule(url, opts) {
|
|
55922
|
-
|
|
55923
|
-
|
|
55924
|
-
|
|
55925
|
-
|
|
56176
|
+
if (!server._ssrExternals) {
|
|
56177
|
+
let knownImports = [];
|
|
56178
|
+
const optimizedDeps = server._optimizedDeps;
|
|
56179
|
+
if (optimizedDeps) {
|
|
56180
|
+
await optimizedDeps.scanProcessing;
|
|
56181
|
+
knownImports = [
|
|
56182
|
+
...Object.keys(optimizedDeps.metadata.optimized),
|
|
56183
|
+
...Object.keys(optimizedDeps.metadata.discovered)
|
|
56184
|
+
];
|
|
56185
|
+
}
|
|
56186
|
+
server._ssrExternals = resolveSSRExternal(config, knownImports);
|
|
55926
56187
|
}
|
|
55927
|
-
server._ssrExternals || (server._ssrExternals = resolveSSRExternal(config, configFileDependencies));
|
|
55928
56188
|
return ssrLoadModule(url, server, undefined, undefined, opts === null || opts === void 0 ? void 0 : opts.fixStacktrace);
|
|
55929
56189
|
},
|
|
55930
56190
|
ssrFixStacktrace(e) {
|
|
@@ -55969,12 +56229,11 @@ async function createServer(inlineConfig = {}) {
|
|
|
55969
56229
|
}
|
|
55970
56230
|
return server._restartPromise;
|
|
55971
56231
|
},
|
|
55972
|
-
|
|
56232
|
+
_optimizedDeps: null,
|
|
55973
56233
|
_ssrExternals: null,
|
|
55974
56234
|
_globImporters: Object.create(null),
|
|
55975
56235
|
_restartPromise: null,
|
|
55976
56236
|
_forceOptimizeOnRestart: false,
|
|
55977
|
-
_registerMissingImport: null,
|
|
55978
56237
|
_pendingRequests: new Map()
|
|
55979
56238
|
};
|
|
55980
56239
|
server.transformIndexHtml = createDevHtmlTransformFn(server);
|
|
@@ -56093,29 +56352,15 @@ async function createServer(inlineConfig = {}) {
|
|
|
56093
56352
|
}
|
|
56094
56353
|
// error handler
|
|
56095
56354
|
middlewares.use(errorMiddleware(server, !!middlewareMode));
|
|
56096
|
-
const runOptimize = async () => {
|
|
56097
|
-
const optimizeDeps = await createOptimizeDepsRun(config, config.server.force);
|
|
56098
|
-
// Don't await for the optimization to finish, we can start the
|
|
56099
|
-
// server right away here
|
|
56100
|
-
server._optimizeDepsMetadata = optimizeDeps.metadata;
|
|
56101
|
-
// Run deps optimization in parallel
|
|
56102
|
-
const initialProcessingPromise = optimizeDeps
|
|
56103
|
-
.run()
|
|
56104
|
-
.then((result) => result.commit());
|
|
56105
|
-
// While running the first optimizeDeps, _registerMissingImport is null
|
|
56106
|
-
// so the resolve plugin resolves straight to node_modules during the
|
|
56107
|
-
// deps discovery scan phase
|
|
56108
|
-
server._registerMissingImport = createMissingImporterRegisterFn(server, initialProcessingPromise);
|
|
56109
|
-
};
|
|
56110
56355
|
if (!middlewareMode && httpServer) {
|
|
56111
56356
|
let isOptimized = false;
|
|
56112
|
-
// overwrite listen to
|
|
56357
|
+
// overwrite listen to init optimizer before server start
|
|
56113
56358
|
const listen = httpServer.listen.bind(httpServer);
|
|
56114
56359
|
httpServer.listen = (async (port, ...args) => {
|
|
56115
56360
|
if (!isOptimized) {
|
|
56116
56361
|
try {
|
|
56117
56362
|
await container.buildStart({});
|
|
56118
|
-
|
|
56363
|
+
server._optimizedDeps = createOptimizedDeps(server);
|
|
56119
56364
|
isOptimized = true;
|
|
56120
56365
|
}
|
|
56121
56366
|
catch (e) {
|
|
@@ -56128,7 +56373,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
56128
56373
|
}
|
|
56129
56374
|
else {
|
|
56130
56375
|
await container.buildStart({});
|
|
56131
|
-
|
|
56376
|
+
server._optimizedDeps = createOptimizedDeps(server);
|
|
56132
56377
|
}
|
|
56133
56378
|
return server;
|
|
56134
56379
|
}
|
|
@@ -56710,15 +56955,20 @@ function importAnalysisPlugin(config) {
|
|
|
56710
56955
|
url = url.replace(base, '/');
|
|
56711
56956
|
}
|
|
56712
56957
|
let importerFile = importer;
|
|
56713
|
-
if (moduleListContains((_a = config.optimizeDeps) === null || _a === void 0 ? void 0 : _a.exclude, url)
|
|
56714
|
-
server.
|
|
56715
|
-
|
|
56716
|
-
|
|
56717
|
-
|
|
56718
|
-
|
|
56719
|
-
|
|
56720
|
-
|
|
56721
|
-
|
|
56958
|
+
if (moduleListContains((_a = config.optimizeDeps) === null || _a === void 0 ? void 0 : _a.exclude, url)) {
|
|
56959
|
+
const optimizedDeps = server._optimizedDeps;
|
|
56960
|
+
if (optimizedDeps) {
|
|
56961
|
+
await optimizedDeps.scanProcessing;
|
|
56962
|
+
// if the dependency encountered in the optimized file was excluded from the optimization
|
|
56963
|
+
// the dependency needs to be resolved starting from the original source location of the optimized file
|
|
56964
|
+
// because starting from node_modules/.vite will not find the dependency if it was not hoisted
|
|
56965
|
+
// (that is, if it is under node_modules directory in the package source of the optimized file)
|
|
56966
|
+
for (const optimizedModule of optimizedDeps.metadata.depInfoList) {
|
|
56967
|
+
if (!optimizedModule.src)
|
|
56968
|
+
continue; // Ignore chunks
|
|
56969
|
+
if (optimizedModule.file === importerModule.file) {
|
|
56970
|
+
importerFile = optimizedModule.src;
|
|
56971
|
+
}
|
|
56722
56972
|
}
|
|
56723
56973
|
}
|
|
56724
56974
|
}
|
|
@@ -56825,7 +57075,7 @@ function importAnalysisPlugin(config) {
|
|
|
56825
57075
|
// e.g. `import.meta.glob('glob:./dir/*.js')`
|
|
56826
57076
|
const { imports, importsString, exp, endIndex, base, pattern, isEager } = await transformImportGlob(source, start, importer, index, root, config.logger, normalizeUrl, resolve);
|
|
56827
57077
|
str().prepend(importsString);
|
|
56828
|
-
str().overwrite(expStart, endIndex, exp);
|
|
57078
|
+
str().overwrite(expStart, endIndex, exp, { contentOnly: true });
|
|
56829
57079
|
imports.forEach((url) => {
|
|
56830
57080
|
url = url.replace(base, '/');
|
|
56831
57081
|
importedUrls.add(url);
|
|
@@ -56884,14 +57134,15 @@ function importAnalysisPlugin(config) {
|
|
|
56884
57134
|
if (url !== specifier) {
|
|
56885
57135
|
importRewrites.push(async () => {
|
|
56886
57136
|
let rewriteDone = false;
|
|
56887
|
-
if (
|
|
57137
|
+
if ((server === null || server === void 0 ? void 0 : server._optimizedDeps) &&
|
|
57138
|
+
isOptimizedDepFile(resolvedId, config) &&
|
|
56888
57139
|
!resolvedId.match(optimizedDepChunkRE)) {
|
|
56889
57140
|
// for optimized cjs deps, support named imports by rewriting named imports to const assignments.
|
|
56890
57141
|
// internal optimized chunks don't need es interop and are excluded
|
|
56891
57142
|
// The browserHash in resolvedId could be stale in which case there will be a full
|
|
56892
57143
|
// page reload. We could return a 404 in that case but it is safe to return the request
|
|
56893
57144
|
const file = cleanUrl(resolvedId); // Remove ?v={hash}
|
|
56894
|
-
const needsInterop = await optimizedDepNeedsInterop(server.
|
|
57145
|
+
const needsInterop = await optimizedDepNeedsInterop(server._optimizedDeps.metadata, file);
|
|
56895
57146
|
if (needsInterop === undefined) {
|
|
56896
57147
|
// Non-entry dynamic imports from dependencies will reach here as there isn't
|
|
56897
57148
|
// optimize info for them, but they don't need es interop. If the request isn't
|
|
@@ -56904,24 +57155,26 @@ function importAnalysisPlugin(config) {
|
|
|
56904
57155
|
debug$1(`${url} needs interop`);
|
|
56905
57156
|
if (isDynamicImport) {
|
|
56906
57157
|
// rewrite `import('package')` to expose the default directly
|
|
56907
|
-
str().overwrite(expStart, expEnd, `import('${url}').then(m => m.default && m.default.__esModule ? m.default : ({ ...m.default, default: m.default }))
|
|
57158
|
+
str().overwrite(expStart, expEnd, `import('${url}').then(m => m.default && m.default.__esModule ? m.default : ({ ...m.default, default: m.default }))`, { contentOnly: true });
|
|
56908
57159
|
}
|
|
56909
57160
|
else {
|
|
56910
57161
|
const exp = source.slice(expStart, expEnd);
|
|
56911
57162
|
const rewritten = transformCjsImport(exp, url, rawUrl, index);
|
|
56912
57163
|
if (rewritten) {
|
|
56913
|
-
str().overwrite(expStart, expEnd, rewritten
|
|
57164
|
+
str().overwrite(expStart, expEnd, rewritten, {
|
|
57165
|
+
contentOnly: true
|
|
57166
|
+
});
|
|
56914
57167
|
}
|
|
56915
57168
|
else {
|
|
56916
57169
|
// #1439 export * from '...'
|
|
56917
|
-
str().overwrite(start, end, url);
|
|
57170
|
+
str().overwrite(start, end, url, { contentOnly: true });
|
|
56918
57171
|
}
|
|
56919
57172
|
}
|
|
56920
57173
|
rewriteDone = true;
|
|
56921
57174
|
}
|
|
56922
57175
|
}
|
|
56923
57176
|
if (!rewriteDone) {
|
|
56924
|
-
str().overwrite(start, end, isDynamicImport ? `'${url}'` : url);
|
|
57177
|
+
str().overwrite(start, end, isDynamicImport ? `'${url}'` : url, { contentOnly: true });
|
|
56925
57178
|
}
|
|
56926
57179
|
});
|
|
56927
57180
|
}
|
|
@@ -56954,7 +57207,7 @@ function importAnalysisPlugin(config) {
|
|
|
56954
57207
|
if (!/^('.*'|".*"|`.*`)$/.test(url) ||
|
|
56955
57208
|
isExplicitImportRequired(url.slice(1, -1))) {
|
|
56956
57209
|
needQueryInjectHelper = true;
|
|
56957
|
-
str().overwrite(start, end, `__vite__injectQuery(${url}, 'import')
|
|
57210
|
+
str().overwrite(start, end, `__vite__injectQuery(${url}, 'import')`, { contentOnly: true });
|
|
56958
57211
|
}
|
|
56959
57212
|
}
|
|
56960
57213
|
}
|
|
@@ -56991,7 +57244,9 @@ function importAnalysisPlugin(config) {
|
|
|
56991
57244
|
for (const { url, start, end } of acceptedUrls) {
|
|
56992
57245
|
const [normalized] = await moduleGraph.resolveUrl(toAbsoluteUrl(markExplicitImport(url)), ssr);
|
|
56993
57246
|
normalizedAcceptedUrls.add(normalized);
|
|
56994
|
-
str().overwrite(start, end, JSON.stringify(normalized)
|
|
57247
|
+
str().overwrite(start, end, JSON.stringify(normalized), {
|
|
57248
|
+
contentOnly: true
|
|
57249
|
+
});
|
|
56995
57250
|
}
|
|
56996
57251
|
// update the module graph for HMR analysis.
|
|
56997
57252
|
// node CSS imports does its own graph update in the css plugin so we
|
|
@@ -57390,9 +57645,9 @@ function preAliasPlugin() {
|
|
|
57390
57645
|
configureServer(_server) {
|
|
57391
57646
|
server = _server;
|
|
57392
57647
|
},
|
|
57393
|
-
resolveId(id, importer, options) {
|
|
57394
|
-
if (!(options === null || options === void 0 ? void 0 : options.ssr) && bareImportRE.test(id)) {
|
|
57395
|
-
return tryOptimizedResolve(id, server, importer);
|
|
57648
|
+
async resolveId(id, importer, options) {
|
|
57649
|
+
if (!(options === null || options === void 0 ? void 0 : options.ssr) && bareImportRE.test(id) && !(options === null || options === void 0 ? void 0 : options.scan)) {
|
|
57650
|
+
return await tryOptimizedResolve(id, server, importer);
|
|
57396
57651
|
}
|
|
57397
57652
|
}
|
|
57398
57653
|
};
|
|
@@ -57497,7 +57752,7 @@ function definePlugin(config) {
|
|
|
57497
57752
|
const start = match.index;
|
|
57498
57753
|
const end = start + match[0].length;
|
|
57499
57754
|
const replacement = '' + replacements[match[1]];
|
|
57500
|
-
s.overwrite(start, end, replacement);
|
|
57755
|
+
s.overwrite(start, end, replacement, { contentOnly: true });
|
|
57501
57756
|
}
|
|
57502
57757
|
if (!hasReplaced) {
|
|
57503
57758
|
return null;
|
|
@@ -57618,7 +57873,9 @@ function workerImportMetaUrlPlugin(config) {
|
|
|
57618
57873
|
url = injectQuery(url, WORKER_FILE_ID);
|
|
57619
57874
|
url = injectQuery(url, `type=${workerType}`);
|
|
57620
57875
|
}
|
|
57621
|
-
s.overwrite(urlIndex, urlIndex + exp.length, JSON.stringify(url)
|
|
57876
|
+
s.overwrite(urlIndex, urlIndex + exp.length, JSON.stringify(url), {
|
|
57877
|
+
contentOnly: true
|
|
57878
|
+
});
|
|
57622
57879
|
}
|
|
57623
57880
|
if (s) {
|
|
57624
57881
|
return {
|
|
@@ -58053,7 +58310,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
58053
58310
|
const resolved = {
|
|
58054
58311
|
...config,
|
|
58055
58312
|
configFile: configFile ? normalizePath$4(configFile) : undefined,
|
|
58056
|
-
configFileDependencies,
|
|
58313
|
+
configFileDependencies: configFileDependencies.map((name) => normalizePath$4(path__default.resolve(name))),
|
|
58057
58314
|
inlineConfig,
|
|
58058
58315
|
root: resolvedRoot,
|
|
58059
58316
|
base: BASE_URL,
|
|
@@ -58536,6 +58793,7 @@ exports.commonjsGlobal = commonjsGlobal;
|
|
|
58536
58793
|
exports.createLogger = createLogger;
|
|
58537
58794
|
exports.createServer = createServer;
|
|
58538
58795
|
exports.defineConfig = defineConfig;
|
|
58796
|
+
exports.formatPostcssSourceMap = formatPostcssSourceMap;
|
|
58539
58797
|
exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
58540
58798
|
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
58541
58799
|
exports.index = index$1;
|