vite 5.0.6 → 5.0.7
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.
@@ -1,4 +1,4 @@
|
|
1
|
-
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-wTaJK0Jt.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -12419,6 +12419,7 @@ function copyDir(srcDir, destDir) {
|
|
12419
12419
|
}
|
12420
12420
|
}
|
12421
12421
|
}
|
12422
|
+
const ERR_SYMLINK_IN_RECURSIVE_READDIR = 'ERR_SYMLINK_IN_RECURSIVE_READDIR';
|
12422
12423
|
async function recursiveReaddir(dir) {
|
12423
12424
|
if (!fs$l.existsSync(dir)) {
|
12424
12425
|
return [];
|
@@ -12434,6 +12435,11 @@ async function recursiveReaddir(dir) {
|
|
12434
12435
|
}
|
12435
12436
|
throw e;
|
12436
12437
|
}
|
12438
|
+
if (dirents.some((dirent) => dirent.isSymbolicLink())) {
|
12439
|
+
const err = new Error('Symbolic links are not supported in recursiveReaddir');
|
12440
|
+
err.code = ERR_SYMLINK_IN_RECURSIVE_READDIR;
|
12441
|
+
throw err;
|
12442
|
+
}
|
12437
12443
|
const files = await Promise.all(dirents.map((dirent) => {
|
12438
12444
|
const res = path$o.resolve(dir, dirent.name);
|
12439
12445
|
return dirent.isDirectory() ? recursiveReaddir(res) : normalizePath$3(res);
|
@@ -16424,7 +16430,16 @@ function lookup(extn) {
|
|
16424
16430
|
|
16425
16431
|
const publicFilesMap = new WeakMap();
|
16426
16432
|
async function initPublicFiles(config) {
|
16427
|
-
|
16433
|
+
let fileNames;
|
16434
|
+
try {
|
16435
|
+
fileNames = await recursiveReaddir(config.publicDir);
|
16436
|
+
}
|
16437
|
+
catch (e) {
|
16438
|
+
if (e.code === ERR_SYMLINK_IN_RECURSIVE_READDIR) {
|
16439
|
+
return;
|
16440
|
+
}
|
16441
|
+
throw e;
|
16442
|
+
}
|
16428
16443
|
const publicFiles = new Set(fileNames.map((fileName) => fileName.slice(config.publicDir.length)));
|
16429
16444
|
publicFilesMap.set(config, publicFiles);
|
16430
16445
|
return publicFiles;
|
@@ -16662,7 +16677,7 @@ function isGitLfsPlaceholder(content) {
|
|
16662
16677
|
* Register an asset to be emitted as part of the bundle (if necessary)
|
16663
16678
|
* and returns the resolved public URL
|
16664
16679
|
*/
|
16665
|
-
async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false) {
|
16680
|
+
async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false, shouldInline) {
|
16666
16681
|
if (!skipPublicCheck && checkPublicFile(id, config)) {
|
16667
16682
|
return publicFileToBuiltUrl(id, config);
|
16668
16683
|
}
|
@@ -16673,13 +16688,17 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
16673
16688
|
}
|
16674
16689
|
const file = cleanUrl(id);
|
16675
16690
|
const content = await fsp.readFile(file);
|
16691
|
+
if (shouldInline == null) {
|
16692
|
+
shouldInline =
|
16693
|
+
!!config.build.lib ||
|
16694
|
+
// Don't inline SVG with fragments, as they are meant to be reused
|
16695
|
+
(!(file.endsWith('.svg') && id.includes('#')) &&
|
16696
|
+
!file.endsWith('.html') &&
|
16697
|
+
content.length < Number(config.build.assetsInlineLimit) &&
|
16698
|
+
!isGitLfsPlaceholder(content));
|
16699
|
+
}
|
16676
16700
|
let url;
|
16677
|
-
if (
|
16678
|
-
// Don't inline SVG with fragments, as they are meant to be reused
|
16679
|
-
(!(file.endsWith('.svg') && id.includes('#')) &&
|
16680
|
-
!file.endsWith('.html') &&
|
16681
|
-
content.length < Number(config.build.assetsInlineLimit) &&
|
16682
|
-
!isGitLfsPlaceholder(content))) {
|
16701
|
+
if (shouldInline) {
|
16683
16702
|
if (config.build.lib && isGitLfsPlaceholder(content)) {
|
16684
16703
|
config.logger.warn(colors$1.yellow(`Inlined file ${id} was not downloaded via Git LFS`));
|
16685
16704
|
}
|
@@ -16709,7 +16728,7 @@ async function fileToBuiltUrl(id, config, pluginContext, skipPublicCheck = false
|
|
16709
16728
|
cache.set(id, url);
|
16710
16729
|
return url;
|
16711
16730
|
}
|
16712
|
-
async function urlToBuiltUrl(url, importer, config, pluginContext) {
|
16731
|
+
async function urlToBuiltUrl(url, importer, config, pluginContext, shouldInline) {
|
16713
16732
|
if (checkPublicFile(url, config)) {
|
16714
16733
|
return publicFileToBuiltUrl(url, config);
|
16715
16734
|
}
|
@@ -16718,7 +16737,7 @@ async function urlToBuiltUrl(url, importer, config, pluginContext) {
|
|
16718
16737
|
: path$o.join(path$o.dirname(importer), url);
|
16719
16738
|
return fileToBuiltUrl(file, config, pluginContext,
|
16720
16739
|
// skip public check since we just did it above
|
16721
|
-
true);
|
16740
|
+
true, shouldInline);
|
16722
16741
|
}
|
16723
16742
|
// Inspired by https://github.com/iconify/iconify/blob/main/packages/utils/src/svg/url.ts
|
16724
16743
|
function svgToDataURL(content) {
|
@@ -29295,7 +29314,7 @@ function equalWithoutSuffix(path, key, suffix) {
|
|
29295
29314
|
return key.endsWith(suffix) && key.slice(0, -suffix.length) === path;
|
29296
29315
|
}
|
29297
29316
|
function getRealPath(resolved, preserveSymlinks) {
|
29298
|
-
if (!preserveSymlinks
|
29317
|
+
if (!preserveSymlinks) {
|
29299
29318
|
resolved = safeRealpathSync(resolved);
|
29300
29319
|
}
|
29301
29320
|
return normalizePath$3(resolved);
|
@@ -38014,6 +38033,7 @@ const inlineCSSRE$1 = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g;
|
|
38014
38033
|
// Do not allow preceding '.', but do allow preceding '...' for spread operations
|
38015
38034
|
const inlineImportRE = /(?<!(?<!\.\.)\.)\bimport\s*\(("(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*')\)/dg;
|
38016
38035
|
const htmlLangRE = /\.(?:html|htm)$/;
|
38036
|
+
const spaceRe = /[\t\n\f\r ]/;
|
38017
38037
|
const importMapRE = /[ \t]*<script[^>]*type\s*=\s*(?:"importmap"|'importmap'|importmap)[^>]*>.*?<\/script>/is;
|
38018
38038
|
const moduleScriptRE = /[ \t]*<script[^>]*type\s*=\s*(?:"module"|'module'|module)[^>]*>/i;
|
38019
38039
|
const modulePreloadLinkRE = /[ \t]*<link[^>]*rel\s*=\s*(?:"modulepreload"|'modulepreload'|modulepreload)[\s\S]*?\/>/i;
|
@@ -38076,6 +38096,16 @@ const assetAttrsConfig = {
|
|
38076
38096
|
image: ['xlink:href', 'href'],
|
38077
38097
|
use: ['xlink:href', 'href'],
|
38078
38098
|
};
|
38099
|
+
// Some `<link rel>` elements should not be inlined in build. Excluding:
|
38100
|
+
// - `shortcut` : only valid for IE <9, use `icon`
|
38101
|
+
// - `mask-icon` : deprecated since Safari 12 (for pinned tabs)
|
38102
|
+
// - `apple-touch-icon-precomposed` : only valid for iOS <7 (for avoiding gloss effect)
|
38103
|
+
const noInlineLinkRels = new Set([
|
38104
|
+
'icon',
|
38105
|
+
'apple-touch-icon',
|
38106
|
+
'apple-touch-startup-image',
|
38107
|
+
'manifest',
|
38108
|
+
]);
|
38079
38109
|
const isAsyncScriptMap = new WeakMap();
|
38080
38110
|
function nodeIsElement(node) {
|
38081
38111
|
return node.nodeName[0] !== '#';
|
@@ -38237,13 +38267,13 @@ function buildHtmlPlugin(config) {
|
|
38237
38267
|
// references the post-build location, ignoring empty attributes and
|
38238
38268
|
// attributes that directly reference named output.
|
38239
38269
|
const namedOutput = Object.keys(config?.build?.rollupOptions?.input || {});
|
38240
|
-
const processAssetUrl = async (url) => {
|
38270
|
+
const processAssetUrl = async (url, shouldInline) => {
|
38241
38271
|
if (url !== '' && // Empty attribute
|
38242
38272
|
!namedOutput.includes(url) && // Direct reference to named output
|
38243
38273
|
!namedOutput.includes(removeLeadingSlash(url)) // Allow for absolute references as named output can't be an absolute path
|
38244
38274
|
) {
|
38245
38275
|
try {
|
38246
|
-
return await urlToBuiltUrl(url, id, config, this);
|
38276
|
+
return await urlToBuiltUrl(url, id, config, this, shouldInline);
|
38247
38277
|
}
|
38248
38278
|
catch (e) {
|
38249
38279
|
if (e.code !== 'ENOENT') {
|
@@ -38343,8 +38373,16 @@ function buildHtmlPlugin(config) {
|
|
38343
38373
|
js += importExpression;
|
38344
38374
|
}
|
38345
38375
|
else {
|
38376
|
+
// If the node is a link, check if it can be inlined. If not, set `shouldInline`
|
38377
|
+
// to `false` to force no inline. If `undefined`, it leaves to the default heuristics.
|
38378
|
+
const isNoInlineLink = node.nodeName === 'link' &&
|
38379
|
+
node.attrs.some((p) => p.name === 'rel' &&
|
38380
|
+
p.value
|
38381
|
+
.split(spaceRe)
|
38382
|
+
.some((v) => noInlineLinkRels.has(v.toLowerCase())));
|
38383
|
+
const shouldInline = isNoInlineLink ? false : undefined;
|
38346
38384
|
assetUrlsPromises.push((async () => {
|
38347
|
-
const processedUrl = await processAssetUrl(url);
|
38385
|
+
const processedUrl = await processAssetUrl(url, shouldInline);
|
38348
38386
|
if (processedUrl !== url) {
|
38349
38387
|
overwriteAttrValue(s, getAttrSourceCodeLocation(node, attrKey), processedUrl);
|
38350
38388
|
}
|
@@ -39737,8 +39775,8 @@ function createCachedImport(imp) {
|
|
39737
39775
|
return cached;
|
39738
39776
|
};
|
39739
39777
|
}
|
39740
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
39741
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
39778
|
+
const importPostcssImport = createCachedImport(() => import('./dep-tttr_ygS.js').then(function (n) { return n.i; }));
|
39779
|
+
const importPostcssModules = createCachedImport(() => import('./dep-iw_F17O-.js').then(function (n) { return n.i; }));
|
39742
39780
|
const importPostcss = createCachedImport(() => import('postcss'));
|
39743
39781
|
/**
|
39744
39782
|
* @experimental
|
@@ -48719,7 +48757,7 @@ function servePublicMiddleware(server, publicFiles) {
|
|
48719
48757
|
// To avoid the performance impact of `existsSync` on every request, we check against an
|
48720
48758
|
// in-memory set of known public files. This set is updated on restarts.
|
48721
48759
|
// also skip import request and internal requests `/@fs/ /@vite-client` etc...
|
48722
|
-
if (!publicFiles.has(toFilePath(req.url)) ||
|
48760
|
+
if ((publicFiles && !publicFiles.has(toFilePath(req.url))) ||
|
48723
48761
|
isImportRequest(req.url) ||
|
48724
48762
|
isInternalRequest(req.url)) {
|
48725
48763
|
return next();
|
@@ -59810,7 +59848,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
59810
59848
|
const onFileAddUnlink = async (file, isUnlink) => {
|
59811
59849
|
file = normalizePath$3(file);
|
59812
59850
|
await container.watchChange(file, { event: isUnlink ? 'delete' : 'create' });
|
59813
|
-
if (config.publicDir && file.startsWith(config.publicDir)) {
|
59851
|
+
if (publicFiles && config.publicDir && file.startsWith(config.publicDir)) {
|
59814
59852
|
publicFiles[isUnlink ? 'delete' : 'add'](file.slice(config.publicDir.length));
|
59815
59853
|
}
|
59816
59854
|
await handleFileAddUnlink(file, server, isUnlink);
|
@@ -64210,7 +64248,7 @@ async function createDepsOptimizer(config, server) {
|
|
64210
64248
|
// Ensure that a rerun will not be issued for current discovered deps
|
64211
64249
|
if (debounceProcessingHandle)
|
64212
64250
|
clearTimeout(debounceProcessingHandle);
|
64213
|
-
if (closed
|
64251
|
+
if (closed) {
|
64214
64252
|
currentlyProcessing = false;
|
64215
64253
|
return;
|
64216
64254
|
}
|
@@ -64411,9 +64449,6 @@ async function createDepsOptimizer(config, server) {
|
|
64411
64449
|
});
|
64412
64450
|
}
|
64413
64451
|
function debouncedProcessing(timeout = debounceMs) {
|
64414
|
-
if (!newDepsDiscovered) {
|
64415
|
-
return;
|
64416
|
-
}
|
64417
64452
|
// Debounced rerun, let other missing dependencies be discovered before
|
64418
64453
|
// the running next optimizeDeps
|
64419
64454
|
enqueuedRerun = undefined;
|
@@ -64455,8 +64490,10 @@ async function createDepsOptimizer(config, server) {
|
|
64455
64490
|
const scanDeps = Object.keys(result.metadata.optimized);
|
64456
64491
|
if (scanDeps.length === 0 && crawlDeps.length === 0) {
|
64457
64492
|
debug$2?.(colors$1.green(`✨ no dependencies found by the scanner or crawling static imports`));
|
64458
|
-
result
|
64459
|
-
|
64493
|
+
// We still commit the result so the scanner isn't run on the next cold start
|
64494
|
+
// for projects without dependencies
|
64495
|
+
startNextDiscoveredBatch();
|
64496
|
+
runOptimizer(result);
|
64460
64497
|
return;
|
64461
64498
|
}
|
64462
64499
|
const needsInteropMismatch = findInteropMismatches(metadata.discovered, result.metadata.optimized);
|
@@ -64490,10 +64527,8 @@ async function createDepsOptimizer(config, server) {
|
|
64490
64527
|
debug$2?.(colors$1.green(`✨ no dependencies found while crawling the static imports`));
|
64491
64528
|
firstRunCalled = true;
|
64492
64529
|
}
|
64493
|
-
|
64494
|
-
|
64495
|
-
debouncedProcessing(0);
|
64496
|
-
}
|
64530
|
+
// queue the first optimizer run, even without deps so the result is cached
|
64531
|
+
debouncedProcessing(0);
|
64497
64532
|
}
|
64498
64533
|
}
|
64499
64534
|
// Called during buildStart at build time, when build --watch is used.
|
@@ -67337,7 +67372,9 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
|
|
67337
67372
|
},
|
67338
67373
|
});
|
67339
67374
|
// validate config
|
67340
|
-
if (config.build?.terserOptions &&
|
67375
|
+
if (config.build?.terserOptions &&
|
67376
|
+
config.build.minify &&
|
67377
|
+
config.build.minify !== 'terser') {
|
67341
67378
|
logger.warn(colors$1.yellow(`build.terserOptions is specified but build.minify is not set to use Terser. ` +
|
67342
67379
|
`Note Vite now defaults to use esbuild for minification. If you still ` +
|
67343
67380
|
`prefer Terser, set build.minify to "terser".`));
|
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 { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { x as colors, k as createLogger, r as resolveConfig } from './chunks/dep-wTaJK0Jt.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -759,7 +759,7 @@ cli
|
|
759
759
|
filterDuplicateOptions(options);
|
760
760
|
// output structure is preserved even after bundling so require()
|
761
761
|
// is ok here
|
762
|
-
const { createServer } = await import('./chunks/dep-
|
762
|
+
const { createServer } = await import('./chunks/dep-wTaJK0Jt.js').then(function (n) { return n.A; });
|
763
763
|
try {
|
764
764
|
const server = await createServer({
|
765
765
|
root,
|
@@ -839,7 +839,7 @@ cli
|
|
839
839
|
.option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
|
840
840
|
.action(async (root, options) => {
|
841
841
|
filterDuplicateOptions(options);
|
842
|
-
const { build } = await import('./chunks/dep-
|
842
|
+
const { build } = await import('./chunks/dep-wTaJK0Jt.js').then(function (n) { return n.C; });
|
843
843
|
const buildOptions = cleanOptions(options);
|
844
844
|
try {
|
845
845
|
await build({
|
@@ -867,7 +867,7 @@ cli
|
|
867
867
|
.option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
|
868
868
|
.action(async (root, options) => {
|
869
869
|
filterDuplicateOptions(options);
|
870
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
870
|
+
const { optimizeDeps } = await import('./chunks/dep-wTaJK0Jt.js').then(function (n) { return n.B; });
|
871
871
|
try {
|
872
872
|
const config = await resolveConfig({
|
873
873
|
root,
|
@@ -893,7 +893,7 @@ cli
|
|
893
893
|
.option('--outDir <dir>', `[string] output directory (default: dist)`)
|
894
894
|
.action(async (root, options) => {
|
895
895
|
filterDuplicateOptions(options);
|
896
|
-
const { preview } = await import('./chunks/dep-
|
896
|
+
const { preview } = await import('./chunks/dep-wTaJK0Jt.js').then(function (n) { return n.D; });
|
897
897
|
try {
|
898
898
|
const server = await preview({
|
899
899
|
root,
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules } from './chunks/dep-
|
3
|
-
export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules } from './chunks/dep-wTaJK0Jt.js';
|
3
|
+
export { b as build, e as buildErrorMessage, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, u as isFileServingAllowed, l as loadConfigFromFile, v as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, r as resolveConfig, w as resolveEnvPrefix, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-wTaJK0Jt.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
export { VERSION as rollupVersion } from 'rollup';
|