vite 4.3.0-beta.4 → 4.3.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/dist/node/chunks/{dep-a36bfc56.js → dep-631467cd.js} +171 -103
- package/dist/node/chunks/{dep-a4107a1b.js → dep-9ae8857c.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +0 -1
- package/dist/node/index.js +2 -2
- package/dist/node-cjs/publicUtils.cjs +1 -1
- package/package.json +1 -1
|
@@ -23009,11 +23009,11 @@ function tryNodeResolve(id, importer, options, targetWeb, depsOptimizer, ssr = f
|
|
|
23009
23009
|
if (dedupe?.includes(pkgId)) {
|
|
23010
23010
|
basedir = root;
|
|
23011
23011
|
}
|
|
23012
|
-
else if (importer &&
|
|
23012
|
+
else if (importer &&
|
|
23013
|
+
path$o.isAbsolute(importer) &&
|
|
23014
|
+
// css processing appends `*` for importer
|
|
23015
|
+
(importer[importer.length - 1] === '*' || fs$l.existsSync(cleanUrl(importer)))) {
|
|
23013
23016
|
basedir = path$o.dirname(importer);
|
|
23014
|
-
if (!fs$l.existsSync(basedir)) {
|
|
23015
|
-
basedir = root;
|
|
23016
|
-
}
|
|
23017
23017
|
}
|
|
23018
23018
|
else {
|
|
23019
23019
|
basedir = root;
|
|
@@ -28621,29 +28621,42 @@ function optimizedDepsPlugin(config) {
|
|
|
28621
28621
|
};
|
|
28622
28622
|
}
|
|
28623
28623
|
function optimizedDepsBuildPlugin(config) {
|
|
28624
|
+
let buildStartCalled = false;
|
|
28624
28625
|
return {
|
|
28625
28626
|
name: 'vite:optimized-deps-build',
|
|
28626
28627
|
buildStart() {
|
|
28627
|
-
|
|
28628
|
-
|
|
28629
|
-
// it will be the SSR optimizer if config.build.ssr is defined
|
|
28628
|
+
// Only reset the registered ids after a rebuild during build --watch
|
|
28629
|
+
if (!config.isWorker && buildStartCalled) {
|
|
28630
28630
|
getDepsOptimizer(config)?.resetRegisteredIds();
|
|
28631
28631
|
}
|
|
28632
|
+
buildStartCalled = true;
|
|
28632
28633
|
},
|
|
28633
|
-
resolveId(id, importer,
|
|
28634
|
-
|
|
28634
|
+
async resolveId(id, importer, options) {
|
|
28635
|
+
const depsOptimizer = getDepsOptimizer(config);
|
|
28636
|
+
if (!depsOptimizer)
|
|
28637
|
+
return;
|
|
28638
|
+
if (depsOptimizer.isOptimizedDepFile(id)) {
|
|
28635
28639
|
return id;
|
|
28636
28640
|
}
|
|
28641
|
+
else {
|
|
28642
|
+
if (options?.custom?.['vite:pre-alias']) {
|
|
28643
|
+
// Skip registering the id if it is being resolved from the pre-alias plugin
|
|
28644
|
+
// When a optimized dep is aliased, we need to avoid waiting for it before optimizing
|
|
28645
|
+
return;
|
|
28646
|
+
}
|
|
28647
|
+
const resolved = await this.resolve(id, importer, {
|
|
28648
|
+
...options,
|
|
28649
|
+
skipSelf: true,
|
|
28650
|
+
});
|
|
28651
|
+
if (resolved) {
|
|
28652
|
+
depsOptimizer.delayDepsOptimizerUntil(resolved.id, async () => {
|
|
28653
|
+
await this.load(resolved);
|
|
28654
|
+
});
|
|
28655
|
+
}
|
|
28656
|
+
}
|
|
28637
28657
|
},
|
|
28638
|
-
|
|
28639
|
-
const
|
|
28640
|
-
getDepsOptimizer(config, ssr)?.delayDepsOptimizerUntil(id, async () => {
|
|
28641
|
-
await this.load({ id });
|
|
28642
|
-
});
|
|
28643
|
-
},
|
|
28644
|
-
async load(id, options) {
|
|
28645
|
-
const ssr = options?.ssr === true;
|
|
28646
|
-
const depsOptimizer = getDepsOptimizer(config, ssr);
|
|
28658
|
+
async load(id) {
|
|
28659
|
+
const depsOptimizer = getDepsOptimizer(config);
|
|
28647
28660
|
if (!depsOptimizer?.isOptimizedDepFile(id)) {
|
|
28648
28661
|
return;
|
|
28649
28662
|
}
|
|
@@ -38485,7 +38498,7 @@ function createCachedImport(imp) {
|
|
|
38485
38498
|
};
|
|
38486
38499
|
}
|
|
38487
38500
|
const importPostcssImport = createCachedImport(() => import('./dep-e3f470e2.js').then(function (n) { return n.i; }));
|
|
38488
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
|
38501
|
+
const importPostcssModules = createCachedImport(() => import('./dep-9ae8857c.js').then(function (n) { return n.i; }));
|
|
38489
38502
|
const importPostcss = createCachedImport(() => import('postcss'));
|
|
38490
38503
|
/**
|
|
38491
38504
|
* @experimental
|
|
@@ -40602,7 +40615,7 @@ function importAnalysisPlugin(config) {
|
|
|
40602
40615
|
}
|
|
40603
40616
|
else if (needsInterop) {
|
|
40604
40617
|
debug$a?.(`${url} needs interop`);
|
|
40605
|
-
interopNamedImports(str(), importSpecifier, url, index);
|
|
40618
|
+
interopNamedImports(str(), importSpecifier, url, index, importer, config);
|
|
40606
40619
|
rewriteDone = true;
|
|
40607
40620
|
}
|
|
40608
40621
|
}
|
|
@@ -40611,7 +40624,7 @@ function importAnalysisPlugin(config) {
|
|
|
40611
40624
|
// correctly throw the error message.
|
|
40612
40625
|
else if (url.includes(browserExternalId) &&
|
|
40613
40626
|
source.slice(expStart, start).includes('{')) {
|
|
40614
|
-
interopNamedImports(str(), importSpecifier, url, index);
|
|
40627
|
+
interopNamedImports(str(), importSpecifier, url, index, importer, config);
|
|
40615
40628
|
rewriteDone = true;
|
|
40616
40629
|
}
|
|
40617
40630
|
if (!rewriteDone) {
|
|
@@ -40756,7 +40769,7 @@ function mergeAcceptedUrls(orderedUrls) {
|
|
|
40756
40769
|
}
|
|
40757
40770
|
return acceptedUrls;
|
|
40758
40771
|
}
|
|
40759
|
-
function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex) {
|
|
40772
|
+
function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex, importer, config) {
|
|
40760
40773
|
const source = str.original;
|
|
40761
40774
|
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex, } = importSpecifier;
|
|
40762
40775
|
if (dynamicIndex > -1) {
|
|
@@ -40766,7 +40779,7 @@ function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex) {
|
|
|
40766
40779
|
else {
|
|
40767
40780
|
const exp = source.slice(expStart, expEnd);
|
|
40768
40781
|
const rawUrl = source.slice(start, end);
|
|
40769
|
-
const rewritten = transformCjsImport(exp, rewrittenUrl, rawUrl, importIndex);
|
|
40782
|
+
const rewritten = transformCjsImport(exp, rewrittenUrl, rawUrl, importIndex, importer, config);
|
|
40770
40783
|
if (rewritten) {
|
|
40771
40784
|
str.overwrite(expStart, expEnd, rewritten, { contentOnly: true });
|
|
40772
40785
|
}
|
|
@@ -40789,12 +40802,18 @@ function interopNamedImports(str, importSpecifier, rewrittenUrl, importIndex) {
|
|
|
40789
40802
|
*
|
|
40790
40803
|
* Credits \@csr632 via #837
|
|
40791
40804
|
*/
|
|
40792
|
-
function transformCjsImport(importExp, url, rawUrl, importIndex) {
|
|
40805
|
+
function transformCjsImport(importExp, url, rawUrl, importIndex, importer, config) {
|
|
40793
40806
|
const node = parse$d(importExp, {
|
|
40794
40807
|
ecmaVersion: 'latest',
|
|
40795
40808
|
sourceType: 'module',
|
|
40796
40809
|
}).body[0];
|
|
40797
|
-
|
|
40810
|
+
// `export * from '...'` may cause unexpected problem, so give it a warning
|
|
40811
|
+
if (config.command === 'serve' &&
|
|
40812
|
+
node.type === 'ExportAllDeclaration' &&
|
|
40813
|
+
!node.exported) {
|
|
40814
|
+
config.logger.warn(picocolorsExports.yellow(`\nUnable to interop \`${importExp}\` in ${importer}, this may lose module exports. Please export "${rawUrl}" as ESM or use named exports instead, e.g. \`export { A, B } from "${rawUrl}"\``));
|
|
40815
|
+
}
|
|
40816
|
+
else if (node.type === 'ImportDeclaration' ||
|
|
40798
40817
|
node.type === 'ExportNamedDeclaration') {
|
|
40799
40818
|
if (!node.specifiers.length) {
|
|
40800
40819
|
return `import "${url}"`;
|
|
@@ -41358,8 +41377,9 @@ function preAliasPlugin(config) {
|
|
|
41358
41377
|
return optimizedId; // aliased dep already optimized
|
|
41359
41378
|
}
|
|
41360
41379
|
const resolved = await this.resolve(id, importer, {
|
|
41361
|
-
skipSelf: true,
|
|
41362
41380
|
...options,
|
|
41381
|
+
custom: { ...options.custom, 'vite:pre-alias': true },
|
|
41382
|
+
skipSelf: true,
|
|
41363
41383
|
});
|
|
41364
41384
|
if (resolved && !depsOptimizer.isOptimizedDepFile(resolved.id)) {
|
|
41365
41385
|
const optimizeDeps = depsOptimizer.options;
|
|
@@ -42119,6 +42139,14 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
42119
42139
|
: { pre: [], post: [] };
|
|
42120
42140
|
const { modulePreload } = config.build;
|
|
42121
42141
|
return [
|
|
42142
|
+
...(isDepsOptimizerEnabled(config, false) ||
|
|
42143
|
+
isDepsOptimizerEnabled(config, true)
|
|
42144
|
+
? [
|
|
42145
|
+
isBuild
|
|
42146
|
+
? optimizedDepsBuildPlugin(config)
|
|
42147
|
+
: optimizedDepsPlugin(config),
|
|
42148
|
+
]
|
|
42149
|
+
: []),
|
|
42122
42150
|
isWatch ? ensureWatchPlugin() : null,
|
|
42123
42151
|
isBuild ? metadataPlugin() : null,
|
|
42124
42152
|
watchPackageDataPlugin(config.packageCache),
|
|
@@ -42129,14 +42157,6 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
42129
42157
|
(typeof modulePreload === 'object' && modulePreload.polyfill)
|
|
42130
42158
|
? modulePreloadPolyfillPlugin(config)
|
|
42131
42159
|
: null,
|
|
42132
|
-
...(isDepsOptimizerEnabled(config, false) ||
|
|
42133
|
-
isDepsOptimizerEnabled(config, true)
|
|
42134
|
-
? [
|
|
42135
|
-
isBuild
|
|
42136
|
-
? optimizedDepsBuildPlugin(config)
|
|
42137
|
-
: optimizedDepsPlugin(config),
|
|
42138
|
-
]
|
|
42139
|
-
: []),
|
|
42140
42160
|
resolvePlugin({
|
|
42141
42161
|
...config.resolve,
|
|
42142
42162
|
root: config.root,
|
|
@@ -43363,7 +43383,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
43363
43383
|
const ssr = isBuild && !!config.build.ssr; // safe as Dev SSR don't use this optimizer
|
|
43364
43384
|
const sessionTimestamp = Date.now().toString();
|
|
43365
43385
|
const cachedMetadata = await loadCachedDepOptimizationMetadata(config, ssr);
|
|
43366
|
-
let
|
|
43386
|
+
let debounceProcessingHandle;
|
|
43367
43387
|
let closed = false;
|
|
43368
43388
|
let metadata = cachedMetadata || initDepsOptimizerMetadata(config, ssr, sessionTimestamp);
|
|
43369
43389
|
const depsOptimizer = {
|
|
@@ -43379,7 +43399,6 @@ async function createDepsOptimizer(config, server) {
|
|
|
43379
43399
|
ensureFirstRun,
|
|
43380
43400
|
close,
|
|
43381
43401
|
options: getDepOptimizationConfig(config, ssr),
|
|
43382
|
-
server,
|
|
43383
43402
|
};
|
|
43384
43403
|
depsOptimizerMap.set(config, depsOptimizer);
|
|
43385
43404
|
let newDepsDiscovered = false;
|
|
@@ -43404,12 +43423,23 @@ async function createDepsOptimizer(config, server) {
|
|
|
43404
43423
|
};
|
|
43405
43424
|
let enqueuedRerun;
|
|
43406
43425
|
let currentlyProcessing = false;
|
|
43407
|
-
// If there wasn't a cache or it is outdated, we need to prepare a first run
|
|
43408
43426
|
let firstRunCalled = !!cachedMetadata;
|
|
43427
|
+
// During build, we wait for every module to be scanned before resolving
|
|
43428
|
+
// optimized deps loading for rollup on each rebuild. It will be recreated
|
|
43429
|
+
// after each buildStart.
|
|
43430
|
+
// During dev, if this is a cold run, we wait for static imports discovered
|
|
43431
|
+
// from the first request before resolving to minimize full page reloads.
|
|
43432
|
+
// On warm start or after the first optimization is run, we use a simpler
|
|
43433
|
+
// debounce strategy each time a new dep is discovered.
|
|
43434
|
+
let crawlEndFinder;
|
|
43435
|
+
if (isBuild || !cachedMetadata) {
|
|
43436
|
+
crawlEndFinder = setupOnCrawlEnd(onCrawlEnd);
|
|
43437
|
+
}
|
|
43409
43438
|
let optimizationResult;
|
|
43410
43439
|
let discover;
|
|
43411
43440
|
async function close() {
|
|
43412
43441
|
closed = true;
|
|
43442
|
+
crawlEndFinder?.cancel();
|
|
43413
43443
|
await Promise.allSettled([
|
|
43414
43444
|
discover?.cancel(),
|
|
43415
43445
|
depsOptimizer.scanProcessing,
|
|
@@ -43502,8 +43532,8 @@ async function createDepsOptimizer(config, server) {
|
|
|
43502
43532
|
// Ensure that rerun is called sequentially
|
|
43503
43533
|
enqueuedRerun = undefined;
|
|
43504
43534
|
// Ensure that a rerun will not be issued for current discovered deps
|
|
43505
|
-
if (
|
|
43506
|
-
clearTimeout(
|
|
43535
|
+
if (debounceProcessingHandle)
|
|
43536
|
+
clearTimeout(debounceProcessingHandle);
|
|
43507
43537
|
if (closed || Object.keys(metadata.discovered).length === 0) {
|
|
43508
43538
|
currentlyProcessing = false;
|
|
43509
43539
|
return;
|
|
@@ -43632,12 +43662,12 @@ async function createDepsOptimizer(config, server) {
|
|
|
43632
43662
|
enqueuedRerun?.();
|
|
43633
43663
|
}
|
|
43634
43664
|
function fullReload() {
|
|
43635
|
-
if (
|
|
43665
|
+
if (server) {
|
|
43636
43666
|
// Cached transform results have stale imports (resolved to
|
|
43637
43667
|
// old locations) so they need to be invalidated before the page is
|
|
43638
43668
|
// reloaded.
|
|
43639
|
-
|
|
43640
|
-
|
|
43669
|
+
server.moduleGraph.invalidateAll();
|
|
43670
|
+
server.ws.send({
|
|
43641
43671
|
type: 'full-reload',
|
|
43642
43672
|
path: '*',
|
|
43643
43673
|
});
|
|
@@ -43675,7 +43705,10 @@ async function createDepsOptimizer(config, server) {
|
|
|
43675
43705
|
// We'll wait until the user codebase is eagerly processed by Vite so
|
|
43676
43706
|
// we can get a list of every missing dependency before giving to the
|
|
43677
43707
|
// browser a dependency that may be outdated, thus avoiding full page reloads
|
|
43678
|
-
if (
|
|
43708
|
+
if (!crawlEndFinder) {
|
|
43709
|
+
if (isBuild) {
|
|
43710
|
+
logger.error('Vite Internal Error: Missing dependency found after crawling ended');
|
|
43711
|
+
}
|
|
43679
43712
|
// Debounced rerun, let other missing dependencies be discovered before
|
|
43680
43713
|
// the running next optimizeDeps
|
|
43681
43714
|
debouncedProcessing();
|
|
@@ -43708,25 +43741,33 @@ async function createDepsOptimizer(config, server) {
|
|
|
43708
43741
|
// Debounced rerun, let other missing dependencies be discovered before
|
|
43709
43742
|
// the running next optimizeDeps
|
|
43710
43743
|
enqueuedRerun = undefined;
|
|
43711
|
-
if (
|
|
43712
|
-
clearTimeout(
|
|
43744
|
+
if (debounceProcessingHandle)
|
|
43745
|
+
clearTimeout(debounceProcessingHandle);
|
|
43713
43746
|
if (newDepsToLogHandle)
|
|
43714
43747
|
clearTimeout(newDepsToLogHandle);
|
|
43715
43748
|
newDepsToLogHandle = undefined;
|
|
43716
|
-
|
|
43717
|
-
|
|
43749
|
+
debounceProcessingHandle = setTimeout(() => {
|
|
43750
|
+
debounceProcessingHandle = undefined;
|
|
43718
43751
|
enqueuedRerun = rerun;
|
|
43719
43752
|
if (!currentlyProcessing) {
|
|
43720
43753
|
enqueuedRerun();
|
|
43721
43754
|
}
|
|
43722
43755
|
}, timeout);
|
|
43723
43756
|
}
|
|
43757
|
+
// During dev, onCrawlEnd is called once when the server starts and all static
|
|
43758
|
+
// imports after the first request have been crawled (dynamic imports may also
|
|
43759
|
+
// be crawled if the browser requests them right away).
|
|
43760
|
+
// During build, onCrawlEnd will be called once after each buildStart (so in
|
|
43761
|
+
// watch mode it will be called after each rebuild has processed every module).
|
|
43762
|
+
// All modules are transformed first in this case (both static and dynamic).
|
|
43724
43763
|
async function onCrawlEnd() {
|
|
43764
|
+
// On build time, a missing dep appearing after onCrawlEnd is an internal error
|
|
43765
|
+
// On dev, switch after this point to a simple debounce strategy
|
|
43766
|
+
crawlEndFinder = undefined;
|
|
43725
43767
|
debug$8?.(picocolorsExports.green(`✨ static imports crawl ended`));
|
|
43726
|
-
if (
|
|
43768
|
+
if (closed) {
|
|
43727
43769
|
return;
|
|
43728
43770
|
}
|
|
43729
|
-
currentlyProcessing = false;
|
|
43730
43771
|
const crawlDeps = Object.keys(metadata.discovered);
|
|
43731
43772
|
// Await for the scan+optimize step running in the background
|
|
43732
43773
|
// It normally should be over by the time crawling of user code ended
|
|
@@ -43734,6 +43775,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
43734
43775
|
if (!isBuild && optimizationResult) {
|
|
43735
43776
|
const result = await optimizationResult.result;
|
|
43736
43777
|
optimizationResult = undefined;
|
|
43778
|
+
currentlyProcessing = false;
|
|
43737
43779
|
const scanDeps = Object.keys(result.metadata.optimized);
|
|
43738
43780
|
if (scanDeps.length === 0 && crawlDeps.length === 0) {
|
|
43739
43781
|
debug$8?.(picocolorsExports.green(`✨ no dependencies found by the scanner or crawling static imports`));
|
|
@@ -43766,6 +43808,7 @@ async function createDepsOptimizer(config, server) {
|
|
|
43766
43808
|
}
|
|
43767
43809
|
}
|
|
43768
43810
|
else {
|
|
43811
|
+
currentlyProcessing = false;
|
|
43769
43812
|
if (crawlDeps.length === 0) {
|
|
43770
43813
|
debug$8?.(picocolorsExports.green(`✨ no dependencies found while crawling the static imports`));
|
|
43771
43814
|
firstRunCalled = true;
|
|
@@ -43776,27 +43819,49 @@ async function createDepsOptimizer(config, server) {
|
|
|
43776
43819
|
}
|
|
43777
43820
|
}
|
|
43778
43821
|
}
|
|
43779
|
-
|
|
43822
|
+
// Called during buildStart at build time, when build --watch is used.
|
|
43823
|
+
function resetRegisteredIds() {
|
|
43824
|
+
crawlEndFinder?.cancel();
|
|
43825
|
+
crawlEndFinder = setupOnCrawlEnd(onCrawlEnd);
|
|
43826
|
+
}
|
|
43827
|
+
function registerWorkersSource(id) {
|
|
43828
|
+
crawlEndFinder?.registerWorkersSource(id);
|
|
43829
|
+
}
|
|
43830
|
+
function delayDepsOptimizerUntil(id, done) {
|
|
43831
|
+
if (crawlEndFinder && !depsOptimizer.isOptimizedDepFile(id)) {
|
|
43832
|
+
crawlEndFinder.delayDepsOptimizerUntil(id, done);
|
|
43833
|
+
}
|
|
43834
|
+
}
|
|
43835
|
+
function ensureFirstRun() {
|
|
43836
|
+
crawlEndFinder?.ensureFirstRun();
|
|
43837
|
+
}
|
|
43838
|
+
}
|
|
43839
|
+
const runOptimizerIfIdleAfterMs = 50;
|
|
43840
|
+
function setupOnCrawlEnd(onCrawlEnd) {
|
|
43780
43841
|
let registeredIds = [];
|
|
43781
|
-
|
|
43782
|
-
|
|
43783
|
-
const waitingOn = new
|
|
43842
|
+
const seenIds = new Set();
|
|
43843
|
+
const workersSources = new Set();
|
|
43844
|
+
const waitingOn = new Map();
|
|
43784
43845
|
let firstRunEnsured = false;
|
|
43785
|
-
|
|
43786
|
-
|
|
43787
|
-
|
|
43788
|
-
|
|
43789
|
-
|
|
43790
|
-
|
|
43846
|
+
let crawlEndCalled = false;
|
|
43847
|
+
let cancelled = false;
|
|
43848
|
+
function cancel() {
|
|
43849
|
+
cancelled = true;
|
|
43850
|
+
}
|
|
43851
|
+
function callOnCrawlEnd() {
|
|
43852
|
+
if (!cancelled && !crawlEndCalled) {
|
|
43853
|
+
crawlEndCalled = true;
|
|
43854
|
+
onCrawlEnd();
|
|
43855
|
+
}
|
|
43791
43856
|
}
|
|
43792
43857
|
// If all the inputs are dependencies, we aren't going to get any
|
|
43793
43858
|
// delayDepsOptimizerUntil(id) calls. We need to guard against this
|
|
43794
43859
|
// by forcing a rerun if no deps have been registered
|
|
43795
43860
|
function ensureFirstRun() {
|
|
43796
|
-
if (!firstRunEnsured &&
|
|
43861
|
+
if (!firstRunEnsured && seenIds.size === 0) {
|
|
43797
43862
|
setTimeout(() => {
|
|
43798
|
-
if (
|
|
43799
|
-
|
|
43863
|
+
if (seenIds.size === 0) {
|
|
43864
|
+
callOnCrawlEnd();
|
|
43800
43865
|
}
|
|
43801
43866
|
}, runOptimizerIfIdleAfterMs);
|
|
43802
43867
|
}
|
|
@@ -43807,55 +43872,66 @@ async function createDepsOptimizer(config, server) {
|
|
|
43807
43872
|
// Avoid waiting for this id, as it may be blocked by the rollup
|
|
43808
43873
|
// bundling process of the worker that also depends on the optimizer
|
|
43809
43874
|
registeredIds = registeredIds.filter((registered) => registered.id !== id);
|
|
43810
|
-
|
|
43811
|
-
|
|
43812
|
-
|
|
43813
|
-
}
|
|
43875
|
+
const resolve = waitingOn.get(id);
|
|
43876
|
+
// Forced resolve to avoid waiting for the bundling of the worker to finish
|
|
43877
|
+
resolve?.();
|
|
43814
43878
|
}
|
|
43815
43879
|
function delayDepsOptimizerUntil(id, done) {
|
|
43816
|
-
if (!
|
|
43880
|
+
if (!seenIds.has(id)) {
|
|
43817
43881
|
seenIds.add(id);
|
|
43818
43882
|
registeredIds.push({ id, done });
|
|
43819
|
-
|
|
43883
|
+
callOnCrawlEndWhenIdle();
|
|
43820
43884
|
}
|
|
43821
43885
|
}
|
|
43822
|
-
async function
|
|
43823
|
-
if (waitingOn.size > 0)
|
|
43886
|
+
async function callOnCrawlEndWhenIdle() {
|
|
43887
|
+
if (cancelled || waitingOn.size > 0)
|
|
43824
43888
|
return;
|
|
43825
43889
|
const processingRegisteredIds = registeredIds;
|
|
43826
43890
|
registeredIds = [];
|
|
43827
43891
|
const donePromises = processingRegisteredIds.map(async (registeredId) => {
|
|
43828
|
-
|
|
43829
|
-
|
|
43830
|
-
|
|
43831
|
-
|
|
43832
|
-
|
|
43833
|
-
|
|
43834
|
-
|
|
43892
|
+
// During build, we need to cancel workers
|
|
43893
|
+
let resolve;
|
|
43894
|
+
const waitUntilDone = new Promise((_resolve) => {
|
|
43895
|
+
resolve = _resolve;
|
|
43896
|
+
registeredId
|
|
43897
|
+
.done()
|
|
43898
|
+
.catch(() => {
|
|
43899
|
+
// Ignore errors
|
|
43900
|
+
})
|
|
43901
|
+
.finally(() => resolve());
|
|
43902
|
+
});
|
|
43903
|
+
waitingOn.set(registeredId.id, () => resolve());
|
|
43904
|
+
await waitUntilDone;
|
|
43905
|
+
waitingOn.delete(registeredId.id);
|
|
43835
43906
|
});
|
|
43836
43907
|
const afterLoad = () => {
|
|
43837
|
-
if (
|
|
43908
|
+
if (cancelled)
|
|
43838
43909
|
return;
|
|
43839
43910
|
if (registeredIds.length > 0 &&
|
|
43840
43911
|
registeredIds.every((registeredId) => workersSources.has(registeredId.id))) {
|
|
43841
43912
|
return;
|
|
43842
43913
|
}
|
|
43843
43914
|
if (registeredIds.length > 0) {
|
|
43844
|
-
|
|
43915
|
+
callOnCrawlEndWhenIdle();
|
|
43845
43916
|
}
|
|
43846
43917
|
else {
|
|
43847
|
-
|
|
43918
|
+
callOnCrawlEnd();
|
|
43848
43919
|
}
|
|
43849
43920
|
};
|
|
43850
|
-
|
|
43851
|
-
if (registeredIds.length > 0
|
|
43852
|
-
results.some((result) => result.status === 'rejected')) {
|
|
43921
|
+
await Promise.allSettled(donePromises);
|
|
43922
|
+
if (registeredIds.length > 0) {
|
|
43853
43923
|
afterLoad();
|
|
43854
43924
|
}
|
|
43855
43925
|
else {
|
|
43856
43926
|
setTimeout(afterLoad, runOptimizerIfIdleAfterMs);
|
|
43857
43927
|
}
|
|
43858
43928
|
}
|
|
43929
|
+
return {
|
|
43930
|
+
ensureFirstRun,
|
|
43931
|
+
registerWorkersSource,
|
|
43932
|
+
delayDepsOptimizerUntil,
|
|
43933
|
+
cancel,
|
|
43934
|
+
};
|
|
43859
43935
|
}
|
|
43860
43936
|
async function createDevSsrDepsOptimizer(config) {
|
|
43861
43937
|
const metadata = await optimizeServerSsrDeps(config);
|
|
@@ -44081,6 +44157,9 @@ function runOptimizeDeps(resolvedConfig, depsInfo, ssr = resolvedConfig.command
|
|
|
44081
44157
|
metadata,
|
|
44082
44158
|
cancel: cleanUp,
|
|
44083
44159
|
commit: async () => {
|
|
44160
|
+
if (cleaned) {
|
|
44161
|
+
throw new Error('Can not commit a Deps Optimization run as it was cancelled');
|
|
44162
|
+
}
|
|
44084
44163
|
// Ignore clean up requests after this point so the temp folder isn't deleted before
|
|
44085
44164
|
// we finish commiting the new deps cache files to the deps folder
|
|
44086
44165
|
committed = true;
|
|
@@ -44981,7 +45060,7 @@ function buildImportAnalysisPlugin(config) {
|
|
|
44981
45060
|
}
|
|
44982
45061
|
else if (needsInterop) {
|
|
44983
45062
|
// config.logger.info(`${url} needs interop`)
|
|
44984
|
-
interopNamedImports(str(), imports[index], url, index);
|
|
45063
|
+
interopNamedImports(str(), imports[index], url, index, importer, config);
|
|
44985
45064
|
rewriteDone = true;
|
|
44986
45065
|
}
|
|
44987
45066
|
if (!rewriteDone) {
|
|
@@ -45511,7 +45590,7 @@ function send$2(req, res, content, type, options) {
|
|
|
45511
45590
|
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
|
45512
45591
|
const ROOT_FILES = [
|
|
45513
45592
|
// '.git',
|
|
45514
|
-
// https://pnpm.
|
|
45593
|
+
// https://pnpm.io/workspaces/
|
|
45515
45594
|
'pnpm-workspace.yaml',
|
|
45516
45595
|
// https://rushjs.io/pages/advanced/config_files/
|
|
45517
45596
|
// 'rush.json',
|
|
@@ -45988,7 +46067,7 @@ function onRollupWarning(warning, warn, config) {
|
|
|
45988
46067
|
dynamicImportWarningIgnoreList.some((msg) => warning.message.includes(msg))) {
|
|
45989
46068
|
return;
|
|
45990
46069
|
}
|
|
45991
|
-
if (
|
|
46070
|
+
if (warningIgnoreList.includes(warning.code)) {
|
|
45992
46071
|
return;
|
|
45993
46072
|
}
|
|
45994
46073
|
if (warning.code === 'PLUGIN_WARNING') {
|
|
@@ -52659,12 +52738,7 @@ async function resolveHttpsConfig(https) {
|
|
|
52659
52738
|
}
|
|
52660
52739
|
async function readFileIfExists(value) {
|
|
52661
52740
|
if (typeof value === 'string') {
|
|
52662
|
-
|
|
52663
|
-
return fsp.readFile(path$o.resolve(value));
|
|
52664
|
-
}
|
|
52665
|
-
catch (e) {
|
|
52666
|
-
return value;
|
|
52667
|
-
}
|
|
52741
|
+
return fsp.readFile(path$o.resolve(value)).catch(() => value);
|
|
52668
52742
|
}
|
|
52669
52743
|
return value;
|
|
52670
52744
|
}
|
|
@@ -63159,10 +63233,6 @@ async function createServer(inlineConfig = {}) {
|
|
|
63159
63233
|
}
|
|
63160
63234
|
async function _createServer(inlineConfig = {}, options) {
|
|
63161
63235
|
const config = await resolveConfig(inlineConfig, 'serve');
|
|
63162
|
-
if (isDepsOptimizerEnabled(config, false)) {
|
|
63163
|
-
// start optimizer in the background, we still need to await the setup
|
|
63164
|
-
await initDepsOptimizer(config);
|
|
63165
|
-
}
|
|
63166
63236
|
const { root, server: serverConfig } = config;
|
|
63167
63237
|
const httpsOptions = await resolveHttpsConfig(config.server.https);
|
|
63168
63238
|
const { middlewareMode } = serverConfig;
|
|
@@ -63401,12 +63471,6 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
63401
63471
|
}
|
|
63402
63472
|
// error handler
|
|
63403
63473
|
middlewares.use(errorMiddleware(server, middlewareMode));
|
|
63404
|
-
// when the optimizer is ready, hook server so that it can reload the page
|
|
63405
|
-
// or invalidate the module graph when needed
|
|
63406
|
-
const depsOptimizer = getDepsOptimizer(config);
|
|
63407
|
-
if (depsOptimizer) {
|
|
63408
|
-
depsOptimizer.server = server;
|
|
63409
|
-
}
|
|
63410
63474
|
// httpServer.listen can be called multiple times
|
|
63411
63475
|
// when port when using next port number
|
|
63412
63476
|
// this code is to avoid calling buildStart multiple times
|
|
@@ -63419,6 +63483,10 @@ async function _createServer(inlineConfig = {}, options) {
|
|
|
63419
63483
|
return initingServer;
|
|
63420
63484
|
initingServer = (async function () {
|
|
63421
63485
|
await container.buildStart({});
|
|
63486
|
+
// start deps optimizer after all container plugins are ready
|
|
63487
|
+
if (isDepsOptimizerEnabled(config, false)) {
|
|
63488
|
+
await initDepsOptimizer(config, server);
|
|
63489
|
+
}
|
|
63422
63490
|
initingServer = undefined;
|
|
63423
63491
|
serverInited = true;
|
|
63424
63492
|
})();
|
|
@@ -64383,7 +64451,7 @@ async function loadConfigFromBundledFile(fileName, bundledCode, isESM) {
|
|
|
64383
64451
|
if (isESM) {
|
|
64384
64452
|
const fileBase = `${fileName}.timestamp-${Date.now()}-${Math.random()
|
|
64385
64453
|
.toString(16)
|
|
64386
|
-
.slice(2)}
|
|
64454
|
+
.slice(2)}`;
|
|
64387
64455
|
const fileNameTmp = `${fileBase}.mjs`;
|
|
64388
64456
|
const fileUrl = `${pathToFileURL(fileBase)}.mjs`;
|
|
64389
64457
|
await fsp.writeFile(fileNameTmp, bundledCode);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import require$$0__default from 'fs';
|
|
2
2
|
import require$$0 from 'postcss';
|
|
3
|
-
import { D as commonjsGlobal } from './dep-
|
|
3
|
+
import { D as commonjsGlobal } from './dep-631467cd.js';
|
|
4
4
|
import require$$0$1 from 'path';
|
|
5
5
|
import require$$5 from 'crypto';
|
|
6
6
|
import require$$0$2 from 'util';
|
package/dist/node/cli.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { performance } from 'node:perf_hooks';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
|
-
import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-
|
|
5
|
+
import { B as picocolorsExports, C as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-631467cd.js';
|
|
6
6
|
import { VERSION } from './constants.js';
|
|
7
7
|
import 'node:fs/promises';
|
|
8
8
|
import 'node:url';
|
|
@@ -728,7 +728,7 @@ cli
|
|
|
728
728
|
filterDuplicateOptions(options);
|
|
729
729
|
// output structure is preserved even after bundling so require()
|
|
730
730
|
// is ok here
|
|
731
|
-
const { createServer } = await import('./chunks/dep-
|
|
731
|
+
const { createServer } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.G; });
|
|
732
732
|
try {
|
|
733
733
|
const server = await createServer({
|
|
734
734
|
root,
|
|
@@ -806,7 +806,7 @@ cli
|
|
|
806
806
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
807
807
|
.action(async (root, options) => {
|
|
808
808
|
filterDuplicateOptions(options);
|
|
809
|
-
const { build } = await import('./chunks/dep-
|
|
809
|
+
const { build } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.F; });
|
|
810
810
|
const buildOptions = cleanOptions(options);
|
|
811
811
|
try {
|
|
812
812
|
await build({
|
|
@@ -834,7 +834,7 @@ cli
|
|
|
834
834
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
835
835
|
.action(async (root, options) => {
|
|
836
836
|
filterDuplicateOptions(options);
|
|
837
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
|
837
|
+
const { optimizeDeps } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.E; });
|
|
838
838
|
try {
|
|
839
839
|
const config = await resolveConfig({
|
|
840
840
|
root,
|
|
@@ -860,7 +860,7 @@ cli
|
|
|
860
860
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
|
861
861
|
.action(async (root, options) => {
|
|
862
862
|
filterDuplicateOptions(options);
|
|
863
|
-
const { preview } = await import('./chunks/dep-
|
|
863
|
+
const { preview } = await import('./chunks/dep-631467cd.js').then(function (n) { return n.H; });
|
|
864
864
|
try {
|
|
865
865
|
const server = await preview({
|
|
866
866
|
root,
|
package/dist/node/index.d.ts
CHANGED
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as isInNodeModules } from './chunks/dep-
|
|
2
|
-
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
|
1
|
+
import { i as isInNodeModules } from './chunks/dep-631467cd.js';
|
|
2
|
+
export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, l as loadConfigFromFile, z as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, A as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-631467cd.js';
|
|
3
3
|
export { VERSION as version } from './constants.js';
|
|
4
4
|
export { version as esbuildVersion } from 'esbuild';
|
|
5
5
|
export { VERSION as rollupVersion } from 'rollup';
|
|
@@ -3866,7 +3866,7 @@ function createLogger(level = 'info', options = {}) {
|
|
|
3866
3866
|
// https://github.com/vitejs/vite/issues/2820#issuecomment-812495079
|
|
3867
3867
|
const ROOT_FILES = [
|
|
3868
3868
|
// '.git',
|
|
3869
|
-
// https://pnpm.
|
|
3869
|
+
// https://pnpm.io/workspaces/
|
|
3870
3870
|
'pnpm-workspace.yaml',
|
|
3871
3871
|
// https://rushjs.io/pages/advanced/config_files/
|
|
3872
3872
|
// 'rush.json',
|