vite 2.9.7 → 2.9.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-fb8c3a62.js → dep-5482f2f7.js} +2 -2
- package/dist/node/chunks/{dep-c7a54f50.js → dep-d052c2a9.js} +1 -1
- package/dist/node/chunks/{dep-88bd5805.js → dep-e1fc1d62.js} +127 -54
- package/dist/node/chunks/{dep-0429b5b4.js → dep-e72d45e1.js} +1 -1
- package/dist/node/cli.js +6 -6
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./dep-
|
|
3
|
+
var index = require('./dep-e1fc1d62.js');
|
|
4
4
|
var require$$1 = require('crypto');
|
|
5
5
|
require('fs');
|
|
6
6
|
require('path');
|
|
@@ -19,9 +19,9 @@ require('https');
|
|
|
19
19
|
require('zlib');
|
|
20
20
|
require('tls');
|
|
21
21
|
require('assert');
|
|
22
|
-
require('esbuild');
|
|
23
22
|
require('buffer');
|
|
24
23
|
require('querystring');
|
|
24
|
+
require('esbuild');
|
|
25
25
|
require('child_process');
|
|
26
26
|
require('worker_threads');
|
|
27
27
|
require('readline');
|
|
@@ -18,9 +18,9 @@ var zlib$1 = require('zlib');
|
|
|
18
18
|
var require$$1$2 = require('crypto');
|
|
19
19
|
var require$$4 = require('tls');
|
|
20
20
|
var require$$5 = require('assert');
|
|
21
|
-
var esbuild = require('esbuild');
|
|
22
21
|
var require$$0$8 = require('buffer');
|
|
23
22
|
var qs = require('querystring');
|
|
23
|
+
var esbuild = require('esbuild');
|
|
24
24
|
var require$$1$5 = require('child_process');
|
|
25
25
|
var require$$1$1 = require('worker_threads');
|
|
26
26
|
var readline = require('readline');
|
|
@@ -2317,7 +2317,7 @@ const isJSRequest = (url) => {
|
|
|
2317
2317
|
};
|
|
2318
2318
|
const knownTsRE = /\.(ts|mts|cts|tsx)$/;
|
|
2319
2319
|
const knownTsOutputRE = /\.(js|mjs|cjs|jsx)$/;
|
|
2320
|
-
const isTsRequest = (url) => knownTsRE.test(
|
|
2320
|
+
const isTsRequest = (url) => knownTsRE.test(url);
|
|
2321
2321
|
const isPossibleTsOutput = (url) => knownTsOutputRE.test(cleanUrl(url));
|
|
2322
2322
|
function getPotentialTsSrcPaths(filePath) {
|
|
2323
2323
|
const [name, type, query = ''] = filePath.split(/(\.(?:[cm]?js|jsx))(\?.*)?$/);
|
|
@@ -2559,6 +2559,14 @@ function copyDir(srcDir, destDir) {
|
|
|
2559
2559
|
}
|
|
2560
2560
|
}
|
|
2561
2561
|
}
|
|
2562
|
+
function removeDirSync(dir) {
|
|
2563
|
+
var _a;
|
|
2564
|
+
if (fs__default.existsSync(dir)) {
|
|
2565
|
+
const rmSync = (_a = fs__default.rmSync) !== null && _a !== void 0 ? _a : fs__default.rmdirSync; // TODO: Remove after support for Node 12 is dropped
|
|
2566
|
+
rmSync(dir, { recursive: true });
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
const renameDir = isWindows$4 ? require$$0$3.promisify(gracefulRename) : fs__default.renameSync;
|
|
2562
2570
|
function ensureWatchedFile(watcher, file, root) {
|
|
2563
2571
|
if (file &&
|
|
2564
2572
|
// only need to watch if out of root
|
|
@@ -2571,15 +2579,17 @@ function ensureWatchedFile(watcher, file, root) {
|
|
|
2571
2579
|
}
|
|
2572
2580
|
}
|
|
2573
2581
|
const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
|
|
2582
|
+
const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/;
|
|
2574
2583
|
async function processSrcSet(srcs, replacer) {
|
|
2575
2584
|
const imageCandidates = srcs
|
|
2576
2585
|
.split(',')
|
|
2577
2586
|
.map((s) => {
|
|
2578
|
-
const
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2587
|
+
const src = s.replace(escapedSpaceCharacters, ' ').trim();
|
|
2588
|
+
const [url] = imageSetUrlRE.exec(src) || [];
|
|
2589
|
+
return {
|
|
2590
|
+
url,
|
|
2591
|
+
descriptor: src === null || src === void 0 ? void 0 : src.slice(url.length).trim()
|
|
2592
|
+
};
|
|
2583
2593
|
})
|
|
2584
2594
|
.filter(({ url }) => !!url);
|
|
2585
2595
|
const ret = await Promise.all(imageCandidates.map(async ({ url, descriptor }) => {
|
|
@@ -2712,6 +2722,38 @@ function parseRequest(id) {
|
|
|
2712
2722
|
return Object.fromEntries(new require$$0$4.URLSearchParams(search.slice(1)));
|
|
2713
2723
|
}
|
|
2714
2724
|
const blankReplacer$1 = (match) => ' '.repeat(match.length);
|
|
2725
|
+
// Based on node-graceful-fs
|
|
2726
|
+
// The ISC License
|
|
2727
|
+
// Copyright (c) 2011-2022 Isaac Z. Schlueter, Ben Noordhuis, and Contributors
|
|
2728
|
+
// https://github.com/isaacs/node-graceful-fs/blob/main/LICENSE
|
|
2729
|
+
// On Windows, A/V software can lock the directory, causing this
|
|
2730
|
+
// to fail with an EACCES or EPERM if the directory contains newly
|
|
2731
|
+
// created files. The original tried for up to 60 seconds, we only
|
|
2732
|
+
// wait for 5 seconds, as a longer time would be seen as an error
|
|
2733
|
+
const GRACEFUL_RENAME_TIMEOUT = 5000;
|
|
2734
|
+
function gracefulRename(from, to, cb) {
|
|
2735
|
+
const start = Date.now();
|
|
2736
|
+
let backoff = 0;
|
|
2737
|
+
fs__default.rename(from, to, function CB(er) {
|
|
2738
|
+
if (er &&
|
|
2739
|
+
(er.code === 'EACCES' || er.code === 'EPERM') &&
|
|
2740
|
+
Date.now() - start < GRACEFUL_RENAME_TIMEOUT) {
|
|
2741
|
+
setTimeout(function () {
|
|
2742
|
+
fs__default.stat(to, function (stater, st) {
|
|
2743
|
+
if (stater && stater.code === 'ENOENT')
|
|
2744
|
+
gracefulRename(from, to, CB);
|
|
2745
|
+
else
|
|
2746
|
+
cb(er);
|
|
2747
|
+
});
|
|
2748
|
+
}, backoff);
|
|
2749
|
+
if (backoff < 100)
|
|
2750
|
+
backoff += 10;
|
|
2751
|
+
return;
|
|
2752
|
+
}
|
|
2753
|
+
if (cb)
|
|
2754
|
+
cb(er);
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2715
2757
|
|
|
2716
2758
|
/* eslint no-console: 0 */
|
|
2717
2759
|
const LogLevels = {
|
|
@@ -29046,7 +29088,7 @@ const assetAttrsConfig = {
|
|
|
29046
29088
|
const isAsyncScriptMap = new WeakMap();
|
|
29047
29089
|
async function traverseHtml(html, filePath, visitor) {
|
|
29048
29090
|
// lazy load compiler
|
|
29049
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
29091
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-d052c2a9.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
29050
29092
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
29051
29093
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
29052
29094
|
try {
|
|
@@ -29460,13 +29502,11 @@ function resolveHtmlTransforms(plugins) {
|
|
|
29460
29502
|
}
|
|
29461
29503
|
return [preHooks, postHooks];
|
|
29462
29504
|
}
|
|
29463
|
-
const maybeVirtualHtmlSet = new Set();
|
|
29464
29505
|
async function applyHtmlTransforms(html, hooks, ctx) {
|
|
29465
29506
|
const headTags = [];
|
|
29466
29507
|
const headPrependTags = [];
|
|
29467
29508
|
const bodyTags = [];
|
|
29468
29509
|
const bodyPrependTags = [];
|
|
29469
|
-
maybeVirtualHtmlSet.add(ctx.filename);
|
|
29470
29510
|
for (const hook of hooks) {
|
|
29471
29511
|
const res = await hook(html, ctx);
|
|
29472
29512
|
if (!res) {
|
|
@@ -29644,8 +29684,6 @@ async function injectSourcesContent(map, file, logger) {
|
|
|
29644
29684
|
sourcePath = path__default.resolve(sourceRoot, sourcePath);
|
|
29645
29685
|
}
|
|
29646
29686
|
return fs$n.promises.readFile(sourcePath, 'utf-8').catch(() => {
|
|
29647
|
-
if (maybeVirtualHtmlSet.has(normalizePath$4(sourcePath)))
|
|
29648
|
-
return null;
|
|
29649
29687
|
missingSources.push(sourcePath);
|
|
29650
29688
|
return null;
|
|
29651
29689
|
});
|
|
@@ -29688,6 +29726,7 @@ const commonjsProxyRE = /\?commonjs-proxy/;
|
|
|
29688
29726
|
const inlineRE = /(\?|&)inline\b/;
|
|
29689
29727
|
const inlineCSSRE = /(\?|&)inline-css\b/;
|
|
29690
29728
|
const usedRE = /(\?|&)used\b/;
|
|
29729
|
+
const varRE = /^var\(/i;
|
|
29691
29730
|
const isCSSRequest = (request) => cssLangRE.test(request);
|
|
29692
29731
|
const isDirectCSSRequest = (request) => cssLangRE.test(request) && directRequestRE.test(request);
|
|
29693
29732
|
const isDirectRequest = (request) => directRequestRE.test(request);
|
|
@@ -30160,7 +30199,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
30160
30199
|
replacer: urlReplacer
|
|
30161
30200
|
}));
|
|
30162
30201
|
if (isModule) {
|
|
30163
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
30202
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-e72d45e1.js'); }).then(function (n) { return n.index; })).default({
|
|
30164
30203
|
...modulesOptions,
|
|
30165
30204
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
30166
30205
|
modules = _modules;
|
|
@@ -30190,8 +30229,8 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
30190
30229
|
.default(postcssPlugins)
|
|
30191
30230
|
.process(code, {
|
|
30192
30231
|
...postcssOptions,
|
|
30193
|
-
to:
|
|
30194
|
-
from:
|
|
30232
|
+
to: id,
|
|
30233
|
+
from: id,
|
|
30195
30234
|
map: {
|
|
30196
30235
|
inline: false,
|
|
30197
30236
|
annotation: false,
|
|
@@ -30338,7 +30377,7 @@ async function resolvePostcssConfig(config) {
|
|
|
30338
30377
|
const cssUrlRE = /(?<=^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
|
|
30339
30378
|
const cssDataUriRE = /(?<=^|[^\w\-\u0080-\uffff])data-uri\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
|
|
30340
30379
|
const importCssRE = /@import ('[^']+\.css'|"[^"]+\.css"|[^'")]+\.css)/;
|
|
30341
|
-
const cssImageSetRE = /image-set\(([^)]
|
|
30380
|
+
const cssImageSetRE = /(?<=image-set\()((?:[\w\-]+\([^\)]*\)|[^)])*)(?=\))/;
|
|
30342
30381
|
const UrlRewritePostcssPlugin = (opts) => {
|
|
30343
30382
|
if (!opts) {
|
|
30344
30383
|
throw new Error('base or replace is required');
|
|
@@ -30356,7 +30395,9 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
|
30356
30395
|
const importer = (_a = declaration.source) === null || _a === void 0 ? void 0 : _a.input.file;
|
|
30357
30396
|
return opts.replacer(rawUrl, importer);
|
|
30358
30397
|
};
|
|
30359
|
-
const rewriterToUse =
|
|
30398
|
+
const rewriterToUse = isCssImageSet
|
|
30399
|
+
? rewriteCssImageSet
|
|
30400
|
+
: rewriteCssUrls;
|
|
30360
30401
|
promises.push(rewriterToUse(declaration.value, replacerForDeclaration).then((url) => {
|
|
30361
30402
|
declaration.value = url;
|
|
30362
30403
|
}));
|
|
@@ -30389,9 +30430,15 @@ function rewriteImportCss(css, replacer) {
|
|
|
30389
30430
|
}
|
|
30390
30431
|
function rewriteCssImageSet(css, replacer) {
|
|
30391
30432
|
return asyncReplace(css, cssImageSetRE, async (match) => {
|
|
30392
|
-
const [
|
|
30393
|
-
const url = await processSrcSet(rawUrl, ({ url }) =>
|
|
30394
|
-
|
|
30433
|
+
const [, rawUrl] = match;
|
|
30434
|
+
const url = await processSrcSet(rawUrl, async ({ url }) => {
|
|
30435
|
+
// the url maybe url(...)
|
|
30436
|
+
if (cssUrlRE.test(url)) {
|
|
30437
|
+
return await rewriteCssUrls(url, replacer);
|
|
30438
|
+
}
|
|
30439
|
+
return await doUrlReplace(url, url, replacer);
|
|
30440
|
+
});
|
|
30441
|
+
return url;
|
|
30395
30442
|
});
|
|
30396
30443
|
}
|
|
30397
30444
|
async function doUrlReplace(rawUrl, matched, replacer, funcName = 'url') {
|
|
@@ -30401,7 +30448,10 @@ async function doUrlReplace(rawUrl, matched, replacer, funcName = 'url') {
|
|
|
30401
30448
|
wrap = first;
|
|
30402
30449
|
rawUrl = rawUrl.slice(1, -1);
|
|
30403
30450
|
}
|
|
30404
|
-
if (isExternalUrl(rawUrl) ||
|
|
30451
|
+
if (isExternalUrl(rawUrl) ||
|
|
30452
|
+
isDataUrl(rawUrl) ||
|
|
30453
|
+
rawUrl.startsWith('#') ||
|
|
30454
|
+
varRE.test(rawUrl)) {
|
|
30405
30455
|
return matched;
|
|
30406
30456
|
}
|
|
30407
30457
|
const newUrl = await replacer(rawUrl);
|
|
@@ -39386,7 +39436,7 @@ async function optimizeDeps(config, force = config.server.force, asCommand = fal
|
|
|
39386
39436
|
const depsString = depsLogString(Object.keys(depsInfo));
|
|
39387
39437
|
log(colors$1.green(`Optimizing dependencies:\n ${depsString}`));
|
|
39388
39438
|
const result = await runOptimizeDeps(config, depsInfo);
|
|
39389
|
-
result.commit();
|
|
39439
|
+
await result.commit();
|
|
39390
39440
|
return result.metadata;
|
|
39391
39441
|
}
|
|
39392
39442
|
function createOptimizedDepsMetadata(config, timestamp) {
|
|
@@ -39512,7 +39562,7 @@ async function runOptimizeDeps(config, depsInfo) {
|
|
|
39512
39562
|
metadata,
|
|
39513
39563
|
commit() {
|
|
39514
39564
|
// Write metadata file, delete `deps` folder and rename the `processing` folder to `deps`
|
|
39515
|
-
commitProcessingDepsCacheSync();
|
|
39565
|
+
return commitProcessingDepsCacheSync();
|
|
39516
39566
|
},
|
|
39517
39567
|
cancel
|
|
39518
39568
|
};
|
|
@@ -39639,27 +39689,20 @@ async function runOptimizeDeps(config, depsInfo) {
|
|
|
39639
39689
|
metadata,
|
|
39640
39690
|
commit() {
|
|
39641
39691
|
// Write metadata file, delete `deps` folder and rename the new `processing` folder to `deps` in sync
|
|
39642
|
-
commitProcessingDepsCacheSync();
|
|
39692
|
+
return commitProcessingDepsCacheSync();
|
|
39643
39693
|
},
|
|
39644
39694
|
cancel
|
|
39645
39695
|
};
|
|
39646
|
-
function commitProcessingDepsCacheSync() {
|
|
39696
|
+
async function commitProcessingDepsCacheSync() {
|
|
39647
39697
|
// Processing is done, we can now replace the depsCacheDir with processingCacheDir
|
|
39648
39698
|
// Rewire the file paths from the temporal processing dir to the final deps cache dir
|
|
39649
39699
|
removeDirSync(depsCacheDir);
|
|
39650
|
-
|
|
39700
|
+
await renameDir(processingCacheDir, depsCacheDir);
|
|
39651
39701
|
}
|
|
39652
39702
|
function cancel() {
|
|
39653
39703
|
removeDirSync(processingCacheDir);
|
|
39654
39704
|
}
|
|
39655
39705
|
}
|
|
39656
|
-
function removeDirSync(dir) {
|
|
39657
|
-
var _a;
|
|
39658
|
-
if (fs__default.existsSync(dir)) {
|
|
39659
|
-
const rmSync = (_a = fs__default.rmSync) !== null && _a !== void 0 ? _a : fs__default.rmdirSync; // TODO: Remove after support for Node 12 is dropped
|
|
39660
|
-
rmSync(dir, { recursive: true });
|
|
39661
|
-
}
|
|
39662
|
-
}
|
|
39663
39706
|
async function findKnownImports(config) {
|
|
39664
39707
|
const deps = (await scanImports(config)).deps;
|
|
39665
39708
|
await addManuallyIncludedOptimizeDeps(deps, config);
|
|
@@ -40158,7 +40201,7 @@ function resolvePlugin(baseOptions) {
|
|
|
40158
40201
|
isOptimizedDepUrl = createIsOptimizedDepUrl(server.config);
|
|
40159
40202
|
},
|
|
40160
40203
|
async resolveId(id, importer, resolveOpts) {
|
|
40161
|
-
var _a, _b, _c, _d, _e;
|
|
40204
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
40162
40205
|
const ssr = (resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.ssr) === true;
|
|
40163
40206
|
if (id.startsWith(browserExternalId)) {
|
|
40164
40207
|
return id;
|
|
@@ -40173,9 +40216,17 @@ function resolvePlugin(baseOptions) {
|
|
|
40173
40216
|
const options = {
|
|
40174
40217
|
isRequire,
|
|
40175
40218
|
...baseOptions,
|
|
40176
|
-
isFromTsImporter: isTsRequest(importer !== null && importer !== void 0 ? importer : ''),
|
|
40177
40219
|
scan: (_d = resolveOpts === null || resolveOpts === void 0 ? void 0 : resolveOpts.scan) !== null && _d !== void 0 ? _d : baseOptions.scan
|
|
40178
40220
|
};
|
|
40221
|
+
if (importer) {
|
|
40222
|
+
if (isTsRequest(importer)) {
|
|
40223
|
+
options.isFromTsImporter = true;
|
|
40224
|
+
}
|
|
40225
|
+
else {
|
|
40226
|
+
const moduleLang = (_g = (_f = (_e = this.getModuleInfo(importer)) === null || _e === void 0 ? void 0 : _e.meta) === null || _f === void 0 ? void 0 : _f.vite) === null || _g === void 0 ? void 0 : _g.lang;
|
|
40227
|
+
options.isFromTsImporter = moduleLang && isTsRequest(`.${moduleLang}`);
|
|
40228
|
+
}
|
|
40229
|
+
}
|
|
40179
40230
|
let res;
|
|
40180
40231
|
// resolve pre-bundled deps requests, these could be resolved by
|
|
40181
40232
|
// tryFileResolve or /fs/ resolution but these files may not yet
|
|
@@ -40215,7 +40266,7 @@ function resolvePlugin(baseOptions) {
|
|
|
40215
40266
|
// Optimized files could not yet exist in disk, resolve to the full path
|
|
40216
40267
|
// Inject the current browserHash version if the path doesn't have one
|
|
40217
40268
|
if (!normalizedFsPath.match(DEP_VERSION_RE)) {
|
|
40218
|
-
const browserHash = (
|
|
40269
|
+
const browserHash = (_h = optimizedDepInfoFromFile(server._optimizedDeps.metadata, normalizedFsPath)) === null || _h === void 0 ? void 0 : _h.browserHash;
|
|
40219
40270
|
if (browserHash) {
|
|
40220
40271
|
return injectQuery(normalizedFsPath, `v=${browserHash}`);
|
|
40221
40272
|
}
|
|
@@ -47315,7 +47366,7 @@ async function getCertificate(cacheDir) {
|
|
|
47315
47366
|
return content;
|
|
47316
47367
|
}
|
|
47317
47368
|
catch {
|
|
47318
|
-
const content = (await Promise.resolve().then(function () { return require('./dep-
|
|
47369
|
+
const content = (await Promise.resolve().then(function () { return require('./dep-5482f2f7.js'); })).createCertificate();
|
|
47319
47370
|
fs$n.promises
|
|
47320
47371
|
.mkdir(cacheDir, { recursive: true })
|
|
47321
47372
|
.then(() => fs$n.promises.writeFile(cachePath, content))
|
|
@@ -54479,7 +54530,8 @@ async function ssrTransform(code, inMap, url) {
|
|
|
54479
54530
|
ast = parser.parse(code, {
|
|
54480
54531
|
sourceType: 'module',
|
|
54481
54532
|
ecmaVersion: 'latest',
|
|
54482
|
-
locations: true
|
|
54533
|
+
locations: true,
|
|
54534
|
+
allowHashBang: true
|
|
54483
54535
|
});
|
|
54484
54536
|
}
|
|
54485
54537
|
catch (err) {
|
|
@@ -56178,24 +56230,43 @@ const processNodeUrl = (node, s, config, htmlPath, originalUrl, moduleGraph) =>
|
|
|
56178
56230
|
const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl }) => {
|
|
56179
56231
|
const { config, moduleGraph, watcher } = server;
|
|
56180
56232
|
const base = config.base || '/';
|
|
56233
|
+
let proxyModulePath;
|
|
56234
|
+
let proxyModuleUrl;
|
|
56235
|
+
const trailingSlash = htmlPath.endsWith('/');
|
|
56236
|
+
if (!trailingSlash && fs__default.existsSync(filename)) {
|
|
56237
|
+
proxyModulePath = htmlPath;
|
|
56238
|
+
proxyModuleUrl = base + htmlPath.slice(1);
|
|
56239
|
+
}
|
|
56240
|
+
else {
|
|
56241
|
+
// There are users of vite.transformIndexHtml calling it with url '/'
|
|
56242
|
+
// for SSR integrations #7993, filename is root for this case
|
|
56243
|
+
// A user may also use a valid name for a virtual html file
|
|
56244
|
+
// Mark the path as virtual in both cases so sourcemaps aren't processed
|
|
56245
|
+
// and ids are properly handled
|
|
56246
|
+
const validPath = `${htmlPath}${trailingSlash ? 'index.html' : ''}`;
|
|
56247
|
+
proxyModulePath = `\0${validPath}`;
|
|
56248
|
+
proxyModuleUrl = `${VALID_ID_PREFIX}${NULL_BYTE_PLACEHOLDER}${validPath}`;
|
|
56249
|
+
}
|
|
56181
56250
|
const s = new MagicString(html);
|
|
56182
56251
|
let inlineModuleIndex = -1;
|
|
56183
|
-
const
|
|
56252
|
+
const proxyCacheUrl = cleanUrl(proxyModulePath).replace(normalizePath$4(config.root), '');
|
|
56184
56253
|
const styleUrl = [];
|
|
56185
56254
|
const addInlineModule = (node, ext) => {
|
|
56186
56255
|
inlineModuleIndex++;
|
|
56187
|
-
const url = filePath.replace(normalizePath$4(config.root), '');
|
|
56188
56256
|
const contentNode = node.children[0];
|
|
56189
56257
|
const code = contentNode.content;
|
|
56190
|
-
|
|
56191
|
-
|
|
56192
|
-
|
|
56193
|
-
|
|
56194
|
-
|
|
56258
|
+
let map;
|
|
56259
|
+
if (!proxyModulePath.startsWith('\0')) {
|
|
56260
|
+
map = new MagicString(html)
|
|
56261
|
+
.snip(contentNode.loc.start.offset, contentNode.loc.end.offset)
|
|
56262
|
+
.generateMap({ hires: true });
|
|
56263
|
+
map.sources = [filename];
|
|
56264
|
+
map.file = filename;
|
|
56265
|
+
}
|
|
56195
56266
|
// add HTML Proxy to Map
|
|
56196
|
-
addToHTMLProxyCache(config,
|
|
56267
|
+
addToHTMLProxyCache(config, proxyCacheUrl, inlineModuleIndex, { code, map });
|
|
56197
56268
|
// inline js module. convert to src="proxy"
|
|
56198
|
-
const modulePath = `${
|
|
56269
|
+
const modulePath = `${proxyModuleUrl}?html-proxy&index=${inlineModuleIndex}.${ext}`;
|
|
56199
56270
|
// invalidate the module so the newly cached contents will be served
|
|
56200
56271
|
const module = server === null || server === void 0 ? void 0 : server.moduleGraph.getModuleById(modulePath);
|
|
56201
56272
|
if (module) {
|
|
@@ -56238,11 +56309,11 @@ const devHtmlHook = async (html, { path: htmlPath, filename, server, originalUrl
|
|
|
56238
56309
|
}
|
|
56239
56310
|
});
|
|
56240
56311
|
await Promise.all(styleUrl.map(async ({ start, end, code }, index) => {
|
|
56241
|
-
const url =
|
|
56312
|
+
const url = `${proxyModulePath}?html-proxy&index=${index}.css`;
|
|
56242
56313
|
// ensure module in graph after successful load
|
|
56243
56314
|
const mod = await moduleGraph.ensureEntryFromUrl(url, false);
|
|
56244
56315
|
ensureWatchedFile(watcher, mod.file, config.root);
|
|
56245
|
-
const result = await server.pluginContainer.transform(code,
|
|
56316
|
+
const result = await server.pluginContainer.transform(code, mod.id);
|
|
56246
56317
|
s.overwrite(start, end, (result === null || result === void 0 ? void 0 : result.code) || '');
|
|
56247
56318
|
}));
|
|
56248
56319
|
html = s.toString();
|
|
@@ -59541,8 +59612,8 @@ function createOptimizedDeps(server) {
|
|
|
59541
59612
|
Object.keys(metadata.optimized).some((dep) => {
|
|
59542
59613
|
return (metadata.optimized[dep].fileHash !== newData.optimized[dep].fileHash);
|
|
59543
59614
|
});
|
|
59544
|
-
const commitProcessing = () => {
|
|
59545
|
-
processingResult.commit();
|
|
59615
|
+
const commitProcessing = async () => {
|
|
59616
|
+
await processingResult.commit();
|
|
59546
59617
|
// While optimizeDeps is running, new missing deps may be discovered,
|
|
59547
59618
|
// in which case they will keep being added to metadata.discovered
|
|
59548
59619
|
for (const id in metadata.discovered) {
|
|
@@ -59580,7 +59651,7 @@ function createOptimizedDeps(server) {
|
|
|
59580
59651
|
resolveEnqueuedProcessingPromises();
|
|
59581
59652
|
};
|
|
59582
59653
|
if (!needsReload) {
|
|
59583
|
-
commitProcessing();
|
|
59654
|
+
await commitProcessing();
|
|
59584
59655
|
if (!isDebugEnabled) {
|
|
59585
59656
|
if (newDepsToLogHandle)
|
|
59586
59657
|
clearTimeout(newDepsToLogHandle);
|
|
@@ -59607,7 +59678,7 @@ function createOptimizedDeps(server) {
|
|
|
59607
59678
|
});
|
|
59608
59679
|
}
|
|
59609
59680
|
else {
|
|
59610
|
-
commitProcessing();
|
|
59681
|
+
await commitProcessing();
|
|
59611
59682
|
if (!isDebugEnabled) {
|
|
59612
59683
|
if (newDepsToLogHandle)
|
|
59613
59684
|
clearTimeout(newDepsToLogHandle);
|
|
@@ -61677,7 +61748,9 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
|
|
|
61677
61748
|
merged[key] = [].concat(existing, value);
|
|
61678
61749
|
continue;
|
|
61679
61750
|
}
|
|
61680
|
-
else if (key === 'noExternal' &&
|
|
61751
|
+
else if (key === 'noExternal' &&
|
|
61752
|
+
rootPath === 'ssr' &&
|
|
61753
|
+
(existing === true || value === true)) {
|
|
61681
61754
|
merged[key] = true;
|
|
61682
61755
|
continue;
|
|
61683
61756
|
}
|
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-e1fc1d62.js');
|
|
5
5
|
var perf_hooks = require('perf_hooks');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
@@ -19,9 +19,9 @@ require('zlib');
|
|
|
19
19
|
require('crypto');
|
|
20
20
|
require('tls');
|
|
21
21
|
require('assert');
|
|
22
|
-
require('esbuild');
|
|
23
22
|
require('buffer');
|
|
24
23
|
require('querystring');
|
|
24
|
+
require('esbuild');
|
|
25
25
|
require('child_process');
|
|
26
26
|
require('worker_threads');
|
|
27
27
|
require('readline');
|
|
@@ -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-e1fc1d62.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-e1fc1d62.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-e1fc1d62.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-e1fc1d62.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
|
@@ -613,7 +613,7 @@ export declare interface DepOptimizationResult {
|
|
|
613
613
|
* the page reload will be delayed until the next rerun so we need
|
|
614
614
|
* to be able to discard the result
|
|
615
615
|
*/
|
|
616
|
-
commit: () => void
|
|
616
|
+
commit: () => Promise<void>;
|
|
617
617
|
cancel: () => void;
|
|
618
618
|
}
|
|
619
619
|
|
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var index = require('./chunks/dep-
|
|
5
|
+
var index = require('./chunks/dep-e1fc1d62.js');
|
|
6
6
|
require('fs');
|
|
7
7
|
require('path');
|
|
8
8
|
require('tty');
|
|
@@ -21,9 +21,9 @@ require('zlib');
|
|
|
21
21
|
require('crypto');
|
|
22
22
|
require('tls');
|
|
23
23
|
require('assert');
|
|
24
|
-
require('esbuild');
|
|
25
24
|
require('buffer');
|
|
26
25
|
require('querystring');
|
|
26
|
+
require('esbuild');
|
|
27
27
|
require('child_process');
|
|
28
28
|
require('worker_threads');
|
|
29
29
|
require('readline');
|