vite 2.9.0-beta.2 → 2.9.0-beta.3
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-183d31dd.js → dep-192b3800.js} +1 -1
- package/dist/node/chunks/{dep-6ae84d6b.js → dep-19d0f55f.js} +180 -119
- package/dist/node/chunks/{dep-ce77a218.js → dep-ca2a26a1.js} +1 -1
- package/dist/node/chunks/{dep-c4c66661.js → dep-f14ba655.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +10 -8
- package/dist/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -18935,7 +18935,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
18935
18935
|
replacer: urlReplacer
|
|
18936
18936
|
}));
|
|
18937
18937
|
if (isModule) {
|
|
18938
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
18938
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-ca2a26a1.js'); }).then(function (n) { return n.index; })).default({
|
|
18939
18939
|
...modulesOptions,
|
|
18940
18940
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
18941
18941
|
modules = _modules;
|
|
@@ -21393,7 +21393,7 @@ const assetAttrsConfig = {
|
|
|
21393
21393
|
const isAsyncScriptMap = new WeakMap();
|
|
21394
21394
|
async function traverseHtml(html, filePath, visitor) {
|
|
21395
21395
|
// lazy load compiler
|
|
21396
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
21396
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-f14ba655.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
21397
21397
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
21398
21398
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
21399
21399
|
try {
|
|
@@ -35633,7 +35633,8 @@ const isDebugEnabled = _debug('vite:deps').enabled;
|
|
|
35633
35633
|
async function optimizeDeps(config, force = config.server.force, asCommand = false, newDeps, // missing imports encountered after server has started
|
|
35634
35634
|
ssr) {
|
|
35635
35635
|
const { metadata, run } = await createOptimizeDepsRun(config, force, asCommand, null, newDeps, ssr);
|
|
35636
|
-
await run();
|
|
35636
|
+
const result = await run();
|
|
35637
|
+
result.commit();
|
|
35637
35638
|
return metadata;
|
|
35638
35639
|
}
|
|
35639
35640
|
/**
|
|
@@ -35661,8 +35662,7 @@ ssr) {
|
|
|
35661
35662
|
hash: mainHash,
|
|
35662
35663
|
browserHash: mainHash,
|
|
35663
35664
|
optimized: {},
|
|
35664
|
-
discovered: {}
|
|
35665
|
-
processing: processing.promise
|
|
35665
|
+
discovered: {}
|
|
35666
35666
|
};
|
|
35667
35667
|
if (!force) {
|
|
35668
35668
|
let prevData;
|
|
@@ -35674,9 +35674,20 @@ ssr) {
|
|
|
35674
35674
|
// hash is consistent, no need to re-bundle
|
|
35675
35675
|
if (prevData && prevData.hash === metadata.hash) {
|
|
35676
35676
|
log('Hash is consistent. Skipping. Use --force to override.');
|
|
35677
|
+
// Nothing to commit or cancel as we are using the cache, we only
|
|
35678
|
+
// need to resolve the processing promise so requests can move on
|
|
35679
|
+
const resolve = () => {
|
|
35680
|
+
processing.resolve();
|
|
35681
|
+
};
|
|
35677
35682
|
return {
|
|
35678
35683
|
metadata: prevData,
|
|
35679
|
-
run: () =>
|
|
35684
|
+
run: async () => {
|
|
35685
|
+
return {
|
|
35686
|
+
alteredFiles: false,
|
|
35687
|
+
commit: resolve,
|
|
35688
|
+
cancel: resolve
|
|
35689
|
+
};
|
|
35690
|
+
}
|
|
35680
35691
|
};
|
|
35681
35692
|
}
|
|
35682
35693
|
}
|
|
@@ -35742,15 +35753,20 @@ ssr) {
|
|
|
35742
35753
|
async function prebundleDeps() {
|
|
35743
35754
|
// We prebundle dependencies with esbuild and cache them, but there is no need
|
|
35744
35755
|
// to wait here. Code that needs to access the cached deps needs to await
|
|
35745
|
-
// the
|
|
35756
|
+
// the optimizeDepInfo.processing promise for each dep
|
|
35746
35757
|
var _a, _b, _c, _d;
|
|
35747
35758
|
const qualifiedIds = Object.keys(deps);
|
|
35748
35759
|
if (!qualifiedIds.length) {
|
|
35749
|
-
|
|
35750
|
-
|
|
35751
|
-
|
|
35752
|
-
|
|
35753
|
-
|
|
35760
|
+
return {
|
|
35761
|
+
alteredFiles: false,
|
|
35762
|
+
commit() {
|
|
35763
|
+
// Write metadata file, delete `deps` folder and rename the `processing` folder to `deps`
|
|
35764
|
+
commitProcessingDepsCacheSync();
|
|
35765
|
+
log(`No dependencies to bundle. Skipping.\n\n\n`);
|
|
35766
|
+
processing.resolve();
|
|
35767
|
+
},
|
|
35768
|
+
cancel
|
|
35769
|
+
};
|
|
35754
35770
|
}
|
|
35755
35771
|
let depsString;
|
|
35756
35772
|
if (isDebugEnabled) {
|
|
@@ -35896,24 +35912,36 @@ ssr) {
|
|
|
35896
35912
|
}
|
|
35897
35913
|
metadata.browserHash = newBrowserHash;
|
|
35898
35914
|
}
|
|
35899
|
-
// Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync
|
|
35900
|
-
commitProcessingDepsCacheSync();
|
|
35901
35915
|
debug$d(`deps bundled in ${(perf_hooks.performance.now() - start).toFixed(2)}ms`);
|
|
35902
|
-
|
|
35903
|
-
|
|
35916
|
+
return {
|
|
35917
|
+
alteredFiles,
|
|
35918
|
+
commit() {
|
|
35919
|
+
// Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync
|
|
35920
|
+
commitProcessingDepsCacheSync();
|
|
35921
|
+
processing.resolve();
|
|
35922
|
+
},
|
|
35923
|
+
cancel
|
|
35924
|
+
};
|
|
35904
35925
|
}
|
|
35905
35926
|
function commitProcessingDepsCacheSync() {
|
|
35906
|
-
var _a;
|
|
35907
35927
|
// Rewire the file paths from the temporal processing dir to the final deps cache dir
|
|
35908
35928
|
const dataPath = path__default.join(processingCacheDir, '_metadata.json');
|
|
35909
35929
|
writeFile(dataPath, stringifyOptimizedDepsMetadata(metadata, depsCacheDir));
|
|
35910
35930
|
// Processing is done, we can now replace the depsCacheDir with processingCacheDir
|
|
35911
|
-
|
|
35912
|
-
const rmSync = (_a = fs__default.rmSync) !== null && _a !== void 0 ? _a : fs__default.rmdirSync; // TODO: Remove after support for Node 12 is dropped
|
|
35913
|
-
rmSync(depsCacheDir, { recursive: true });
|
|
35914
|
-
}
|
|
35931
|
+
removeDirSync(depsCacheDir);
|
|
35915
35932
|
fs__default.renameSync(processingCacheDir, depsCacheDir);
|
|
35916
35933
|
}
|
|
35934
|
+
function cancel() {
|
|
35935
|
+
removeDirSync(processingCacheDir);
|
|
35936
|
+
processing.resolve();
|
|
35937
|
+
}
|
|
35938
|
+
}
|
|
35939
|
+
function removeDirSync(dir) {
|
|
35940
|
+
var _a;
|
|
35941
|
+
if (fs__default.existsSync(dir)) {
|
|
35942
|
+
const rmSync = (_a = fs__default.rmSync) !== null && _a !== void 0 ? _a : fs__default.rmdirSync; // TODO: Remove after support for Node 12 is dropped
|
|
35943
|
+
rmSync(dir, { recursive: true });
|
|
35944
|
+
}
|
|
35917
35945
|
}
|
|
35918
35946
|
async function findKnownImports(config) {
|
|
35919
35947
|
const deps = (await scanImports(config)).deps;
|
|
@@ -36002,7 +36030,7 @@ function parseOptimizedDepsMetadata(jsonMetadata, depsCacheDir, processing) {
|
|
|
36002
36030
|
for (const o of Object.keys(metadata.optimized)) {
|
|
36003
36031
|
metadata.optimized[o].processing = processing;
|
|
36004
36032
|
}
|
|
36005
|
-
return { ...metadata, discovered: {}
|
|
36033
|
+
return { ...metadata, discovered: {} };
|
|
36006
36034
|
}
|
|
36007
36035
|
function stringifyOptimizedDepsMetadata(metadata, depsCacheDir) {
|
|
36008
36036
|
return JSON.stringify(metadata, (key, value) => {
|
|
@@ -43475,7 +43503,7 @@ async function getCertificate(cacheDir) {
|
|
|
43475
43503
|
return content;
|
|
43476
43504
|
}
|
|
43477
43505
|
catch {
|
|
43478
|
-
const content = (await Promise.resolve().then(function () { return require('./dep-
|
|
43506
|
+
const content = (await Promise.resolve().then(function () { return require('./dep-192b3800.js'); })).createCertificate();
|
|
43479
43507
|
fs$n.promises
|
|
43480
43508
|
.mkdir(cacheDir, { recursive: true })
|
|
43481
43509
|
.then(() => fs$n.promises.writeFile(cachePath, content))
|
|
@@ -54449,13 +54477,26 @@ function isPrimitive(value) {
|
|
|
54449
54477
|
* a re-bundle + page reload
|
|
54450
54478
|
*/
|
|
54451
54479
|
const debounceMs = 100;
|
|
54452
|
-
function createMissingImporterRegisterFn(server) {
|
|
54480
|
+
function createMissingImporterRegisterFn(server, initialProcessingPromise) {
|
|
54453
54481
|
const { logger } = server.config;
|
|
54454
54482
|
let metadata = server._optimizeDepsMetadata;
|
|
54455
54483
|
let handle;
|
|
54456
|
-
let
|
|
54484
|
+
let newDepsDiscovered = false;
|
|
54457
54485
|
let depOptimizationProcessing = newDepOptimizationProcessing();
|
|
54458
|
-
let
|
|
54486
|
+
let depOptimizationProcessingQueue = [];
|
|
54487
|
+
const resolveEnqueuedProcessingPromises = () => {
|
|
54488
|
+
// Resolve all the processings (including the ones which were delayed)
|
|
54489
|
+
for (const processing of depOptimizationProcessingQueue) {
|
|
54490
|
+
processing.resolve();
|
|
54491
|
+
}
|
|
54492
|
+
depOptimizationProcessingQueue = [];
|
|
54493
|
+
};
|
|
54494
|
+
let enqueuedRerun;
|
|
54495
|
+
let currentlyProcessing = true;
|
|
54496
|
+
initialProcessingPromise.then(() => {
|
|
54497
|
+
currentlyProcessing = false;
|
|
54498
|
+
enqueuedRerun === null || enqueuedRerun === void 0 ? void 0 : enqueuedRerun();
|
|
54499
|
+
});
|
|
54459
54500
|
async function rerun(ssr) {
|
|
54460
54501
|
// debounce time to wait for new missing deps finished, issue a new
|
|
54461
54502
|
// optimization of deps (both old and newly found) once the previous
|
|
@@ -54467,74 +54508,70 @@ function createMissingImporterRegisterFn(server) {
|
|
|
54467
54508
|
// the previous bundled dependencies have changed.
|
|
54468
54509
|
// if the rerun fails, server._optimizeDepsMetadata remains untouched,
|
|
54469
54510
|
// current discovered deps are cleaned, and a fullReload is issued
|
|
54470
|
-
//
|
|
54471
|
-
|
|
54472
|
-
|
|
54473
|
-
const awaitedOptimizeDepsPromise = lastDepOptimizationPromise;
|
|
54474
|
-
await lastDepOptimizationPromise;
|
|
54475
|
-
if (awaitedOptimizeDepsPromise !== lastDepOptimizationPromise) {
|
|
54476
|
-
// There were two or more rerun queued and one of them already
|
|
54477
|
-
// started. Only let through the first one, and discard the others
|
|
54478
|
-
return;
|
|
54479
|
-
}
|
|
54480
|
-
if (handle) {
|
|
54481
|
-
// New deps could have been found here, skip this rerun. Once the
|
|
54482
|
-
// debounce time is over, a new rerun will be issued
|
|
54483
|
-
return;
|
|
54484
|
-
}
|
|
54511
|
+
// Ensure that rerun is called sequentially
|
|
54512
|
+
enqueuedRerun = undefined;
|
|
54513
|
+
currentlyProcessing = true;
|
|
54485
54514
|
logger.info(colors$1.yellow(`new dependencies found: ${Object.keys(metadata.discovered).join(', ')}, updating...`), {
|
|
54486
54515
|
timestamp: true
|
|
54487
54516
|
});
|
|
54488
54517
|
// All deps, previous known and newly discovered are rebundled,
|
|
54489
54518
|
// respect insertion order to keep the metadata file stable
|
|
54519
|
+
const newDeps = {};
|
|
54490
54520
|
// Clone optimized info objects, fileHash, browserHash may be changed for them
|
|
54491
|
-
const
|
|
54492
|
-
|
|
54493
|
-
|
|
54494
|
-
|
|
54495
|
-
const
|
|
54496
|
-
|
|
54497
|
-
|
|
54498
|
-
|
|
54499
|
-
|
|
54521
|
+
for (const dep of Object.keys(metadata.optimized)) {
|
|
54522
|
+
newDeps[dep] = { ...metadata.optimized[dep] };
|
|
54523
|
+
}
|
|
54524
|
+
// Don't clone discovered info objects, they are read after awaited
|
|
54525
|
+
for (const dep of Object.keys(metadata.discovered)) {
|
|
54526
|
+
newDeps[dep] = metadata.discovered[dep];
|
|
54527
|
+
}
|
|
54528
|
+
newDepsDiscovered = false;
|
|
54529
|
+
// Add the current depOptimizationProcessing to the queue, these
|
|
54530
|
+
// promises are going to be resolved once a rerun is committed
|
|
54531
|
+
depOptimizationProcessingQueue.push(depOptimizationProcessing);
|
|
54500
54532
|
// Create a new promise for the next rerun, discovered missing
|
|
54501
54533
|
// dependencies will be asigned this promise from this point
|
|
54502
54534
|
depOptimizationProcessing = newDepOptimizationProcessing();
|
|
54503
54535
|
let newData = null;
|
|
54504
54536
|
try {
|
|
54505
54537
|
const optimizeDeps = await createOptimizeDepsRun(server.config, true, false, metadata, newDeps, ssr);
|
|
54506
|
-
|
|
54507
|
-
|
|
54508
|
-
|
|
54509
|
-
|
|
54510
|
-
|
|
54511
|
-
|
|
54512
|
-
|
|
54513
|
-
|
|
54514
|
-
|
|
54515
|
-
|
|
54516
|
-
|
|
54517
|
-
|
|
54518
|
-
|
|
54519
|
-
|
|
54520
|
-
|
|
54521
|
-
|
|
54522
|
-
|
|
54523
|
-
|
|
54538
|
+
const processingResult = await optimizeDeps.run();
|
|
54539
|
+
const commitProcessing = () => {
|
|
54540
|
+
processingResult.commit();
|
|
54541
|
+
newData = optimizeDeps.metadata;
|
|
54542
|
+
// update ssr externals
|
|
54543
|
+
if (ssr) {
|
|
54544
|
+
server._ssrExternals = resolveSSRExternal(server.config, Object.keys(newData.optimized));
|
|
54545
|
+
}
|
|
54546
|
+
// While optimizeDeps is running, new missing deps may be discovered,
|
|
54547
|
+
// in which case they will keep being added to metadata.discovered
|
|
54548
|
+
for (const o of Object.keys(metadata.discovered)) {
|
|
54549
|
+
if (!newData.optimized[o]) {
|
|
54550
|
+
newData.discovered[o] = metadata.discovered[o];
|
|
54551
|
+
}
|
|
54552
|
+
}
|
|
54553
|
+
metadata = server._optimizeDepsMetadata = newData;
|
|
54554
|
+
resolveEnqueuedProcessingPromises();
|
|
54555
|
+
};
|
|
54556
|
+
if (!processingResult.alteredFiles) {
|
|
54557
|
+
commitProcessing();
|
|
54524
54558
|
logger.info(colors$1.green(`✨ new dependencies pre-bundled...`), {
|
|
54525
54559
|
timestamp: true
|
|
54526
54560
|
});
|
|
54527
54561
|
}
|
|
54528
54562
|
else {
|
|
54529
|
-
if (
|
|
54563
|
+
if (newDepsDiscovered) {
|
|
54530
54564
|
// There are newly discovered deps, and another rerun is about to be
|
|
54531
|
-
// excecuted. Avoid the current full reload
|
|
54532
|
-
|
|
54533
|
-
|
|
54565
|
+
// excecuted. Avoid the current full reload discarding this rerun result
|
|
54566
|
+
// We don't resolve the processing promise, as they will be resolved
|
|
54567
|
+
// once a rerun is committed
|
|
54568
|
+
processingResult.cancel();
|
|
54569
|
+
logger.info(colors$1.green(`✨ delaying reload as new dependencies have been found...`), {
|
|
54534
54570
|
timestamp: true
|
|
54535
54571
|
});
|
|
54536
54572
|
}
|
|
54537
54573
|
else {
|
|
54574
|
+
commitProcessing();
|
|
54538
54575
|
logger.info(colors$1.green(`✨ dependencies updated, reloading page...`), {
|
|
54539
54576
|
timestamp: true
|
|
54540
54577
|
});
|
|
@@ -54544,15 +54581,14 @@ function createMissingImporterRegisterFn(server) {
|
|
|
54544
54581
|
}
|
|
54545
54582
|
catch (e) {
|
|
54546
54583
|
logger.error(colors$1.red(`error while updating dependencies:\n${e.stack}`), { timestamp: true, error: e });
|
|
54584
|
+
resolveEnqueuedProcessingPromises();
|
|
54547
54585
|
// Reset missing deps, let the server rediscover the dependencies
|
|
54548
54586
|
metadata.discovered = {};
|
|
54549
54587
|
fullReload();
|
|
54550
54588
|
}
|
|
54551
|
-
|
|
54552
|
-
|
|
54553
|
-
|
|
54554
|
-
thisDepOptimizationProcessing.resolve();
|
|
54555
|
-
}
|
|
54589
|
+
currentlyProcessing = false;
|
|
54590
|
+
// @ts-ignore
|
|
54591
|
+
enqueuedRerun === null || enqueuedRerun === void 0 ? void 0 : enqueuedRerun();
|
|
54556
54592
|
}
|
|
54557
54593
|
function fullReload() {
|
|
54558
54594
|
// Cached transform results have stale imports (resolved to
|
|
@@ -54563,7 +54599,6 @@ function createMissingImporterRegisterFn(server) {
|
|
|
54563
54599
|
type: 'full-reload',
|
|
54564
54600
|
path: '*'
|
|
54565
54601
|
});
|
|
54566
|
-
needFullReload = false;
|
|
54567
54602
|
}
|
|
54568
54603
|
return function registerMissingImport(id, resolved, ssr) {
|
|
54569
54604
|
const optimized = metadata.optimized[id];
|
|
@@ -54576,6 +54611,7 @@ function createMissingImporterRegisterFn(server) {
|
|
|
54576
54611
|
// It will be processed in the next rerun call
|
|
54577
54612
|
return missing;
|
|
54578
54613
|
}
|
|
54614
|
+
newDepsDiscovered = true;
|
|
54579
54615
|
missing = metadata.discovered[id] = {
|
|
54580
54616
|
file: getOptimizedDepPath(id, server.config),
|
|
54581
54617
|
src: resolved,
|
|
@@ -54590,11 +54626,15 @@ function createMissingImporterRegisterFn(server) {
|
|
|
54590
54626
|
};
|
|
54591
54627
|
// Debounced rerun, let other missing dependencies be discovered before
|
|
54592
54628
|
// the running next optimizeDeps
|
|
54629
|
+
enqueuedRerun = undefined;
|
|
54593
54630
|
if (handle)
|
|
54594
54631
|
clearTimeout(handle);
|
|
54595
54632
|
handle = setTimeout(() => {
|
|
54596
54633
|
handle = undefined;
|
|
54597
|
-
rerun(ssr);
|
|
54634
|
+
enqueuedRerun = () => rerun(ssr);
|
|
54635
|
+
if (!currentlyProcessing) {
|
|
54636
|
+
enqueuedRerun();
|
|
54637
|
+
}
|
|
54598
54638
|
}, debounceMs);
|
|
54599
54639
|
// Return the path for the optimized bundle, this path is known before
|
|
54600
54640
|
// esbuild is run to generate the pre-bundle
|
|
@@ -54712,7 +54752,6 @@ async function createServer(inlineConfig = {}) {
|
|
|
54712
54752
|
let configFileDependencies = [];
|
|
54713
54753
|
const metadata = server._optimizeDepsMetadata;
|
|
54714
54754
|
if (metadata) {
|
|
54715
|
-
await metadata.processing;
|
|
54716
54755
|
configFileDependencies = Object.keys(metadata.optimized);
|
|
54717
54756
|
}
|
|
54718
54757
|
server._ssrExternals || (server._ssrExternals = resolveSSRExternal(config, configFileDependencies));
|
|
@@ -54889,11 +54928,14 @@ async function createServer(inlineConfig = {}) {
|
|
|
54889
54928
|
// Don't await for the optimization to finish, we can start the
|
|
54890
54929
|
// server right away here
|
|
54891
54930
|
server._optimizeDepsMetadata = optimizeDeps.metadata;
|
|
54892
|
-
|
|
54931
|
+
// Run deps optimization in parallel
|
|
54932
|
+
const initialProcessingPromise = optimizeDeps
|
|
54933
|
+
.run()
|
|
54934
|
+
.then((result) => result.commit());
|
|
54893
54935
|
// While running the first optimizeDeps, _registerMissingImport is null
|
|
54894
54936
|
// so the resolve plugin resolves straight to node_modules during the
|
|
54895
54937
|
// deps discovery scan phase
|
|
54896
|
-
server._registerMissingImport = createMissingImporterRegisterFn(server);
|
|
54938
|
+
server._registerMissingImport = createMissingImporterRegisterFn(server, initialProcessingPromise);
|
|
54897
54939
|
};
|
|
54898
54940
|
if (!middlewareMode && httpServer) {
|
|
54899
54941
|
let isOptimized = false;
|
|
@@ -55523,7 +55565,7 @@ function importAnalysisPlugin(config) {
|
|
|
55523
55565
|
const isRelative = url.startsWith('.');
|
|
55524
55566
|
const isSelfImport = !isRelative && cleanUrl(url) === cleanUrl(importer);
|
|
55525
55567
|
// normalize all imports into resolved URLs
|
|
55526
|
-
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js`
|
|
55568
|
+
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
|
|
55527
55569
|
if (resolved.id.startsWith(root + '/')) {
|
|
55528
55570
|
// in root: infer short absolute path from root
|
|
55529
55571
|
url = resolved.id.slice(root.length);
|
|
@@ -55584,6 +55626,10 @@ function importAnalysisPlugin(config) {
|
|
|
55584
55626
|
}
|
|
55585
55627
|
return [url, resolved.id];
|
|
55586
55628
|
};
|
|
55629
|
+
// Import rewrites, we do them after all the URLs have been resolved
|
|
55630
|
+
// to help with the discovery of new dependencies. If we need to wait
|
|
55631
|
+
// for each dependency there could be one reload per import
|
|
55632
|
+
const importRewrites = [];
|
|
55587
55633
|
for (let index = 0; index < imports.length; index++) {
|
|
55588
55634
|
const { s: start, e: end, ss: expStart, se: expEnd, d: dynamicIndex,
|
|
55589
55635
|
// #2083 User may use escape path,
|
|
@@ -55667,48 +55713,49 @@ function importAnalysisPlugin(config) {
|
|
|
55667
55713
|
const url = normalizedUrl;
|
|
55668
55714
|
// record as safe modules
|
|
55669
55715
|
server === null || server === void 0 ? void 0 : server.moduleGraph.safeModulesPath.add(fsPathFromUrl(url));
|
|
55670
|
-
// rewrite
|
|
55671
55716
|
if (url !== specifier) {
|
|
55672
|
-
|
|
55673
|
-
|
|
55674
|
-
|
|
55675
|
-
|
|
55676
|
-
|
|
55677
|
-
|
|
55678
|
-
|
|
55679
|
-
|
|
55680
|
-
|
|
55681
|
-
|
|
55682
|
-
|
|
55683
|
-
|
|
55684
|
-
|
|
55685
|
-
|
|
55686
|
-
|
|
55687
|
-
|
|
55688
|
-
|
|
55689
|
-
else if (needsInterop) {
|
|
55690
|
-
debug$1(`${url} needs interop`);
|
|
55691
|
-
if (isDynamicImport) {
|
|
55692
|
-
// rewrite `import('package')` to expose the default directly
|
|
55693
|
-
str().overwrite(dynamicIndex, end + 1, `import('${url}').then(m => m.default && m.default.__esModule ? m.default : ({ ...m.default, default: m.default }))`);
|
|
55717
|
+
importRewrites.push(async () => {
|
|
55718
|
+
let rewriteDone = false;
|
|
55719
|
+
if (isOptimizedDepFile(resolvedId, config) &&
|
|
55720
|
+
!resolvedId.match(optimizedDepChunkRE)) {
|
|
55721
|
+
// for optimized cjs deps, support named imports by rewriting named imports to const assignments.
|
|
55722
|
+
// internal optimized chunks don't need es interop and are excluded
|
|
55723
|
+
// The browserHash in resolvedId could be stale in which case there will be a full
|
|
55724
|
+
// page reload. We could return a 404 in that case but it is safe to return the request
|
|
55725
|
+
const file = cleanUrl(resolvedId); // Remove ?v={hash}
|
|
55726
|
+
const needsInterop = await optimizedDepNeedsInterop(server._optimizeDepsMetadata, file);
|
|
55727
|
+
if (needsInterop === undefined) {
|
|
55728
|
+
// Non-entry dynamic imports from dependencies will reach here as there isn't
|
|
55729
|
+
// optimize info for them, but they don't need es interop. If the request isn't
|
|
55730
|
+
// a dynamic import, then it is an internal Vite error
|
|
55731
|
+
if (!file.match(optimizedDepDynamicRE)) {
|
|
55732
|
+
config.logger.error(colors$1.red(`Vite Error, ${url} optimized info should be defined`));
|
|
55733
|
+
}
|
|
55694
55734
|
}
|
|
55695
|
-
else {
|
|
55696
|
-
|
|
55697
|
-
|
|
55698
|
-
|
|
55699
|
-
str().overwrite(
|
|
55735
|
+
else if (needsInterop) {
|
|
55736
|
+
debug$1(`${url} needs interop`);
|
|
55737
|
+
if (isDynamicImport) {
|
|
55738
|
+
// rewrite `import('package')` to expose the default directly
|
|
55739
|
+
str().overwrite(dynamicIndex, end + 1, `import('${url}').then(m => m.default && m.default.__esModule ? m.default : ({ ...m.default, default: m.default }))`);
|
|
55700
55740
|
}
|
|
55701
55741
|
else {
|
|
55702
|
-
|
|
55703
|
-
|
|
55742
|
+
const exp = source.slice(expStart, expEnd);
|
|
55743
|
+
const rewritten = transformCjsImport(exp, url, rawUrl, index);
|
|
55744
|
+
if (rewritten) {
|
|
55745
|
+
str().overwrite(expStart, expEnd, rewritten);
|
|
55746
|
+
}
|
|
55747
|
+
else {
|
|
55748
|
+
// #1439 export * from '...'
|
|
55749
|
+
str().overwrite(start, end, url);
|
|
55750
|
+
}
|
|
55704
55751
|
}
|
|
55752
|
+
rewriteDone = true;
|
|
55705
55753
|
}
|
|
55706
|
-
rewriteDone = true;
|
|
55707
55754
|
}
|
|
55708
|
-
|
|
55709
|
-
|
|
55710
|
-
|
|
55711
|
-
}
|
|
55755
|
+
if (!rewriteDone) {
|
|
55756
|
+
str().overwrite(start, end, isDynamicImport ? `'${url}'` : url);
|
|
55757
|
+
}
|
|
55758
|
+
});
|
|
55712
55759
|
}
|
|
55713
55760
|
// record for HMR import chain analysis
|
|
55714
55761
|
// make sure to normalize away base
|
|
@@ -55804,9 +55851,23 @@ function importAnalysisPlugin(config) {
|
|
|
55804
55851
|
if (config.server.preTransformRequests && staticImportedUrls.size) {
|
|
55805
55852
|
staticImportedUrls.forEach((url) => {
|
|
55806
55853
|
url = unwrapId$1(removeImportQuery(url)).replace(NULL_BYTE_PLACEHOLDER, '\0');
|
|
55807
|
-
transformRequest(url, server, { ssr })
|
|
55854
|
+
transformRequest(url, server, { ssr }).catch((e) => {
|
|
55855
|
+
if ((e === null || e === void 0 ? void 0 : e.code) === ERR_OUTDATED_OPTIMIZED_DEP) {
|
|
55856
|
+
// This are expected errors
|
|
55857
|
+
return;
|
|
55858
|
+
}
|
|
55859
|
+
// Unexpected error, log the issue but avoid an unhandled exception
|
|
55860
|
+
config.logger.error(e.message);
|
|
55861
|
+
});
|
|
55808
55862
|
});
|
|
55809
55863
|
}
|
|
55864
|
+
// Await for import rewrites that requires dependencies to be pre-bundled to
|
|
55865
|
+
// know if es interop is needed after starting further transformRequest calls
|
|
55866
|
+
// This will let Vite process deeper into the user code and find more missing
|
|
55867
|
+
// dependencies before the next page reload
|
|
55868
|
+
for (const rewrite of importRewrites) {
|
|
55869
|
+
await rewrite();
|
|
55870
|
+
}
|
|
55810
55871
|
if (s) {
|
|
55811
55872
|
return s.toString();
|
|
55812
55873
|
}
|
package/dist/node/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0 = require('events');
|
|
4
|
-
var index = require('./chunks/dep-
|
|
4
|
+
var index = require('./chunks/dep-19d0f55f.js');
|
|
5
5
|
var perf_hooks = require('perf_hooks');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
@@ -683,7 +683,7 @@ cli
|
|
|
683
683
|
.action(async (root, options) => {
|
|
684
684
|
// output structure is preserved even after bundling so require()
|
|
685
685
|
// is ok here
|
|
686
|
-
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
686
|
+
const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-19d0f55f.js'); }).then(function (n) { return n.index$1; });
|
|
687
687
|
try {
|
|
688
688
|
const server = await createServer({
|
|
689
689
|
root,
|
|
@@ -732,7 +732,7 @@ cli
|
|
|
732
732
|
.option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
|
|
733
733
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
|
734
734
|
.action(async (root, options) => {
|
|
735
|
-
const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
735
|
+
const { build } = await Promise.resolve().then(function () { return require('./chunks/dep-19d0f55f.js'); }).then(function (n) { return n.build$1; });
|
|
736
736
|
const buildOptions = cleanOptions(options);
|
|
737
737
|
try {
|
|
738
738
|
await build({
|
|
@@ -755,7 +755,7 @@ cli
|
|
|
755
755
|
.command('optimize [root]', 'pre-bundle dependencies')
|
|
756
756
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
|
757
757
|
.action(async (root, options) => {
|
|
758
|
-
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
758
|
+
const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-19d0f55f.js'); }).then(function (n) { return n.index; });
|
|
759
759
|
try {
|
|
760
760
|
const config = await index.resolveConfig({
|
|
761
761
|
root,
|
|
@@ -778,7 +778,7 @@ cli
|
|
|
778
778
|
.option('--https', `[boolean] use TLS + HTTP/2`)
|
|
779
779
|
.option('--open [path]', `[boolean | string] open browser on startup`)
|
|
780
780
|
.action(async (root, options) => {
|
|
781
|
-
const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-
|
|
781
|
+
const { preview } = await Promise.resolve().then(function () { return require('./chunks/dep-19d0f55f.js'); }).then(function (n) { return n.preview$1; });
|
|
782
782
|
try {
|
|
783
783
|
const server = await preview({
|
|
784
784
|
root,
|
package/dist/node/index.d.ts
CHANGED
|
@@ -520,11 +520,6 @@ export declare interface DepOptimizationMetadata {
|
|
|
520
520
|
* Metadata for each newly discovered dependency after processing
|
|
521
521
|
*/
|
|
522
522
|
discovered: Record<string, OptimizedDepInfo>;
|
|
523
|
-
/**
|
|
524
|
-
* During optimization, ids can still be resolved to their final location
|
|
525
|
-
* but the bundles may not yet be saved to disk
|
|
526
|
-
*/
|
|
527
|
-
processing: Promise<DepOptimizationResult | undefined>;
|
|
528
523
|
}
|
|
529
524
|
|
|
530
525
|
export declare interface DepOptimizationOptions {
|
|
@@ -579,8 +574,8 @@ export declare interface DepOptimizationOptions {
|
|
|
579
574
|
}
|
|
580
575
|
|
|
581
576
|
export declare interface DepOptimizationProcessing {
|
|
582
|
-
promise: Promise<
|
|
583
|
-
resolve: (
|
|
577
|
+
promise: Promise<void>;
|
|
578
|
+
resolve: () => void;
|
|
584
579
|
}
|
|
585
580
|
|
|
586
581
|
export declare interface DepOptimizationResult {
|
|
@@ -591,6 +586,13 @@ export declare interface DepOptimizationResult {
|
|
|
591
586
|
* for large applications
|
|
592
587
|
*/
|
|
593
588
|
alteredFiles: boolean;
|
|
589
|
+
/**
|
|
590
|
+
* When doing a re-run, if there are newly discovered dependendencies
|
|
591
|
+
* the page reload will be delayed until the next rerun so the
|
|
592
|
+
* result will be discarded
|
|
593
|
+
*/
|
|
594
|
+
commit: () => void;
|
|
595
|
+
cancel: () => void;
|
|
594
596
|
}
|
|
595
597
|
|
|
596
598
|
export declare interface ErrorPayload {
|
|
@@ -1180,7 +1182,7 @@ export declare interface OptimizedDepInfo {
|
|
|
1180
1182
|
* During optimization, ids can still be resolved to their final location
|
|
1181
1183
|
* but the bundles may not yet be saved to disk
|
|
1182
1184
|
*/
|
|
1183
|
-
processing: Promise<
|
|
1185
|
+
processing: Promise<void>;
|
|
1184
1186
|
}
|
|
1185
1187
|
|
|
1186
1188
|
/**
|
package/dist/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "2.9.0-beta.
|
|
3
|
+
"version": "2.9.0-beta.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Evan You",
|
|
6
6
|
"description": "Native-ESM powered web dev build tool",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"esbuild": "^0.14.
|
|
46
|
+
"esbuild": "^0.14.27",
|
|
47
47
|
"postcss": "^8.4.6",
|
|
48
48
|
"resolve": "^1.22.0",
|
|
49
49
|
"rollup": "^2.59.0"
|