vite 5.0.5 → 5.0.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.
@@ -1,4 +1,4 @@
|
|
1
|
-
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { z as commonjsGlobal, y as getDefaultExportFromCjs } from './dep-YJaePtkC.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -27,11 +27,11 @@ import { createHash as createHash$2 } from 'node:crypto';
|
|
27
27
|
import { promises } from 'node:dns';
|
28
28
|
import { CLIENT_ENTRY, VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, FS_PREFIX, wildcardHosts, loopbackHosts, CLIENT_PUBLIC_PATH, ENV_PUBLIC_PATH, ENV_ENTRY, DEP_VERSION_RE, SPECIAL_QUERY_RE, DEFAULT_MAIN_FIELDS, DEFAULT_EXTENSIONS, CSS_LANGS_RE, ESBUILD_MODULES_TARGET, KNOWN_ASSET_TYPES, VITE_PACKAGE_DIR, DEFAULT_DEV_PORT, CLIENT_DIR, JS_TYPES_RE, VERSION as VERSION$1, DEFAULT_PREVIEW_PORT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES } from '../constants.js';
|
29
29
|
import require$$0$a from 'crypto';
|
30
|
-
import { Buffer as Buffer$1 } from 'node:buffer';
|
31
30
|
import require$$0$8, { createRequire as createRequire$2 } from 'module';
|
32
31
|
import assert$1 from 'node:assert';
|
33
32
|
import process$1 from 'node:process';
|
34
33
|
import v8 from 'node:v8';
|
34
|
+
import { Buffer as Buffer$1 } from 'node:buffer';
|
35
35
|
import { VERSION } from 'rollup';
|
36
36
|
import { parseAstAsync, parseAst } from 'rollup/parseAst';
|
37
37
|
import * as qs from 'querystring';
|
@@ -12419,6 +12419,27 @@ function copyDir(srcDir, destDir) {
|
|
12419
12419
|
}
|
12420
12420
|
}
|
12421
12421
|
}
|
12422
|
+
async function recursiveReaddir(dir) {
|
12423
|
+
if (!fs$l.existsSync(dir)) {
|
12424
|
+
return [];
|
12425
|
+
}
|
12426
|
+
let dirents;
|
12427
|
+
try {
|
12428
|
+
dirents = await fsp.readdir(dir, { withFileTypes: true });
|
12429
|
+
}
|
12430
|
+
catch (e) {
|
12431
|
+
if (e.code === 'EACCES') {
|
12432
|
+
// Ignore permission errors
|
12433
|
+
return [];
|
12434
|
+
}
|
12435
|
+
throw e;
|
12436
|
+
}
|
12437
|
+
const files = await Promise.all(dirents.map((dirent) => {
|
12438
|
+
const res = path$o.resolve(dir, dirent.name);
|
12439
|
+
return dirent.isDirectory() ? recursiveReaddir(res) : normalizePath$3(res);
|
12440
|
+
}));
|
12441
|
+
return files.flat(1);
|
12442
|
+
}
|
12422
12443
|
// `fs.realpathSync.native` resolves differently in Windows network drive,
|
12423
12444
|
// causing file read errors. skip for now.
|
12424
12445
|
// https://github.com/nodejs/node/issues/37737
|
@@ -16401,6 +16422,39 @@ function lookup(extn) {
|
|
16401
16422
|
return mimes$1[!~idx ? tmp : tmp.substring(++idx)];
|
16402
16423
|
}
|
16403
16424
|
|
16425
|
+
const publicFilesMap = new WeakMap();
|
16426
|
+
async function initPublicFiles(config) {
|
16427
|
+
const fileNames = await recursiveReaddir(config.publicDir);
|
16428
|
+
const publicFiles = new Set(fileNames.map((fileName) => fileName.slice(config.publicDir.length)));
|
16429
|
+
publicFilesMap.set(config, publicFiles);
|
16430
|
+
return publicFiles;
|
16431
|
+
}
|
16432
|
+
function getPublicFiles(config) {
|
16433
|
+
return publicFilesMap.get(config);
|
16434
|
+
}
|
16435
|
+
function checkPublicFile(url, config) {
|
16436
|
+
// note if the file is in /public, the resolver would have returned it
|
16437
|
+
// as-is so it's not going to be a fully resolved path.
|
16438
|
+
const { publicDir } = config;
|
16439
|
+
if (!publicDir || url[0] !== '/') {
|
16440
|
+
return;
|
16441
|
+
}
|
16442
|
+
const fileName = cleanUrl(url);
|
16443
|
+
// short-circuit if we have an in-memory publicFiles cache
|
16444
|
+
const publicFiles = getPublicFiles(config);
|
16445
|
+
if (publicFiles) {
|
16446
|
+
return publicFiles.has(fileName)
|
16447
|
+
? normalizePath$3(path$o.join(publicDir, fileName))
|
16448
|
+
: undefined;
|
16449
|
+
}
|
16450
|
+
const publicFile = normalizePath$3(path$o.join(publicDir, fileName));
|
16451
|
+
if (!publicFile.startsWith(withTrailingSlash(normalizePath$3(publicDir)))) {
|
16452
|
+
// can happen if URL starts with '../'
|
16453
|
+
return;
|
16454
|
+
}
|
16455
|
+
return fs$l.existsSync(publicFile) ? publicFile : undefined;
|
16456
|
+
}
|
16457
|
+
|
16404
16458
|
// referenceId is base64url but replaces - with $
|
16405
16459
|
const assetUrlRE = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g;
|
16406
16460
|
const rawRE = /(?:\?|&)raw(?:&|$)/;
|
@@ -16550,24 +16604,6 @@ function assetPlugin(config) {
|
|
16550
16604
|
},
|
16551
16605
|
};
|
16552
16606
|
}
|
16553
|
-
function checkPublicFile(url, { publicDir }) {
|
16554
|
-
// note if the file is in /public, the resolver would have returned it
|
16555
|
-
// as-is so it's not going to be a fully resolved path.
|
16556
|
-
if (!publicDir || url[0] !== '/') {
|
16557
|
-
return;
|
16558
|
-
}
|
16559
|
-
const publicFile = path$o.join(publicDir, cleanUrl(url));
|
16560
|
-
if (!normalizePath$3(publicFile).startsWith(withTrailingSlash(normalizePath$3(publicDir)))) {
|
16561
|
-
// can happen if URL starts with '../'
|
16562
|
-
return;
|
16563
|
-
}
|
16564
|
-
if (fs$l.existsSync(publicFile)) {
|
16565
|
-
return publicFile;
|
16566
|
-
}
|
16567
|
-
else {
|
16568
|
-
return;
|
16569
|
-
}
|
16570
|
-
}
|
16571
16607
|
async function fileToUrl$1(id, config, ctx) {
|
16572
16608
|
if (config.command === 'serve') {
|
16573
16609
|
return fileToDevUrl(id, config);
|
@@ -37976,9 +38012,7 @@ function polyfill() {
|
|
37976
38012
|
const htmlProxyRE$1 = /\?html-proxy=?(?:&inline-css)?(?:&style-attr)?&index=(\d+)\.(js|css)$/;
|
37977
38013
|
const inlineCSSRE$1 = /__VITE_INLINE_CSS__([a-z\d]{8}_\d+)__/g;
|
37978
38014
|
// Do not allow preceding '.', but do allow preceding '...' for spread operations
|
37979
|
-
const inlineImportRE =
|
37980
|
-
// eslint-disable-next-line regexp/no-unused-capturing-group -- https://github.com/ota-meshi/eslint-plugin-regexp/issues/675
|
37981
|
-
/(?<!(?<!\.\.)\.)\bimport\s*\(("(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*')\)/dg;
|
38015
|
+
const inlineImportRE = /(?<!(?<!\.\.)\.)\bimport\s*\(("(?:[^"]|(?<=\\)")*"|'(?:[^']|(?<=\\)')*')\)/dg;
|
37982
38016
|
const htmlLangRE = /\.(?:html|htm)$/;
|
37983
38017
|
const importMapRE = /[ \t]*<script[^>]*type\s*=\s*(?:"importmap"|'importmap'|importmap)[^>]*>.*?<\/script>/is;
|
37984
38018
|
const moduleScriptRE = /[ \t]*<script[^>]*type\s*=\s*(?:"module"|'module'|module)[^>]*>/i;
|
@@ -39703,8 +39737,8 @@ function createCachedImport(imp) {
|
|
39703
39737
|
return cached;
|
39704
39738
|
};
|
39705
39739
|
}
|
39706
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
39707
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
39740
|
+
const importPostcssImport = createCachedImport(() => import('./dep-I1uDMLJL.js').then(function (n) { return n.i; }));
|
39741
|
+
const importPostcssModules = createCachedImport(() => import('./dep-Sacttr-6.js').then(function (n) { return n.i; }));
|
39708
39742
|
const importPostcss = createCachedImport(() => import('postcss'));
|
39709
39743
|
/**
|
39710
39744
|
* @experimental
|
@@ -48640,7 +48674,7 @@ function sirv (dir, opts={}) {
|
|
48640
48674
|
}
|
48641
48675
|
|
48642
48676
|
const knownJavascriptExtensionRE = /\.[tj]sx?$/;
|
48643
|
-
const sirvOptions = ({ getHeaders,
|
48677
|
+
const sirvOptions = ({ getHeaders, }) => {
|
48644
48678
|
return {
|
48645
48679
|
dev: true,
|
48646
48680
|
etag: true,
|
@@ -48661,19 +48695,33 @@ const sirvOptions = ({ getHeaders, shouldServe, }) => {
|
|
48661
48695
|
}
|
48662
48696
|
}
|
48663
48697
|
},
|
48664
|
-
shouldServe,
|
48665
48698
|
};
|
48666
48699
|
};
|
48667
|
-
function servePublicMiddleware(server) {
|
48700
|
+
function servePublicMiddleware(server, publicFiles) {
|
48668
48701
|
const dir = server.config.publicDir;
|
48669
48702
|
const serve = sirv(dir, sirvOptions({
|
48670
48703
|
getHeaders: () => server.config.server.headers,
|
48671
|
-
shouldServe: (filePath) => shouldServeFile(filePath, dir),
|
48672
48704
|
}));
|
48705
|
+
const toFilePath = (url) => {
|
48706
|
+
let filePath = cleanUrl(url);
|
48707
|
+
if (filePath.indexOf('%') !== -1) {
|
48708
|
+
try {
|
48709
|
+
filePath = decodeURI(filePath);
|
48710
|
+
}
|
48711
|
+
catch (err) {
|
48712
|
+
/* malform uri */
|
48713
|
+
}
|
48714
|
+
}
|
48715
|
+
return normalizePath$3(filePath);
|
48716
|
+
};
|
48673
48717
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
48674
48718
|
return function viteServePublicMiddleware(req, res, next) {
|
48675
|
-
//
|
48676
|
-
|
48719
|
+
// To avoid the performance impact of `existsSync` on every request, we check against an
|
48720
|
+
// in-memory set of known public files. This set is updated on restarts.
|
48721
|
+
// also skip import request and internal requests `/@fs/ /@vite-client` etc...
|
48722
|
+
if (!publicFiles.has(toFilePath(req.url)) ||
|
48723
|
+
isImportRequest(req.url) ||
|
48724
|
+
isInternalRequest(req.url)) {
|
48677
48725
|
return next();
|
48678
48726
|
}
|
48679
48727
|
serve(req, res, next);
|
@@ -59546,6 +59594,7 @@ function createServer(inlineConfig = {}) {
|
|
59546
59594
|
}
|
59547
59595
|
async function _createServer(inlineConfig = {}, options) {
|
59548
59596
|
const config = await resolveConfig(inlineConfig, 'serve');
|
59597
|
+
const initPublicFilesPromise = initPublicFiles(config);
|
59549
59598
|
const { root, server: serverConfig } = config;
|
59550
59599
|
const httpsOptions = await resolveHttpsConfig(config.server.https);
|
59551
59600
|
const { middlewareMode } = serverConfig;
|
@@ -59744,6 +59793,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
59744
59793
|
process.stdin.on('end', exitProcess);
|
59745
59794
|
}
|
59746
59795
|
}
|
59796
|
+
const publicFiles = await initPublicFilesPromise;
|
59747
59797
|
const onHMRUpdate = async (file, configOnly) => {
|
59748
59798
|
if (serverConfig.hmr !== false) {
|
59749
59799
|
try {
|
@@ -59760,6 +59810,9 @@ async function _createServer(inlineConfig = {}, options) {
|
|
59760
59810
|
const onFileAddUnlink = async (file, isUnlink) => {
|
59761
59811
|
file = normalizePath$3(file);
|
59762
59812
|
await container.watchChange(file, { event: isUnlink ? 'delete' : 'create' });
|
59813
|
+
if (config.publicDir && file.startsWith(config.publicDir)) {
|
59814
|
+
publicFiles[isUnlink ? 'delete' : 'add'](file.slice(config.publicDir.length));
|
59815
|
+
}
|
59763
59816
|
await handleFileAddUnlink(file, server, isUnlink);
|
59764
59817
|
await onHMRUpdate(file, true);
|
59765
59818
|
};
|
@@ -59831,7 +59884,7 @@ async function _createServer(inlineConfig = {}, options) {
|
|
59831
59884
|
// this applies before the transform middleware so that these files are served
|
59832
59885
|
// as-is without transforms.
|
59833
59886
|
if (config.publicDir) {
|
59834
|
-
middlewares.use(servePublicMiddleware(server));
|
59887
|
+
middlewares.use(servePublicMiddleware(server, publicFiles));
|
59835
59888
|
}
|
59836
59889
|
// main transform middleware
|
59837
59890
|
middlewares.use(transformMiddleware(server));
|
@@ -62061,9 +62114,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
62061
62114
|
const query = parseRequest(id);
|
62062
62115
|
let s;
|
62063
62116
|
const cleanString = stripLiteral(code);
|
62064
|
-
const workerImportMetaUrlRE =
|
62065
|
-
// eslint-disable-next-line regexp/no-unused-capturing-group -- https://github.com/ota-meshi/eslint-plugin-regexp/issues/675
|
62066
|
-
/\bnew\s+(?:Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
62117
|
+
const workerImportMetaUrlRE = /\bnew\s+(?:Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/dg;
|
62067
62118
|
let match;
|
62068
62119
|
while ((match = workerImportMetaUrlRE.exec(cleanString))) {
|
62069
62120
|
const [[, endIndex], [expStart, expEnd], [urlStart, urlEnd]] = match.indices;
|
@@ -62146,9 +62197,7 @@ function assetImportMetaUrlPlugin(config) {
|
|
62146
62197
|
code.includes('new URL') &&
|
62147
62198
|
code.includes(`import.meta.url`)) {
|
62148
62199
|
let s;
|
62149
|
-
const assetImportMetaUrlRE =
|
62150
|
-
// eslint-disable-next-line regexp/no-unused-capturing-group -- https://github.com/ota-meshi/eslint-plugin-regexp/issues/675
|
62151
|
-
/\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/dg;
|
62200
|
+
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/dg;
|
62152
62201
|
const cleanString = stripLiteral(code);
|
62153
62202
|
let match;
|
62154
62203
|
while ((match = assetImportMetaUrlRE.exec(cleanString))) {
|
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-YJaePtkC.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -27,11 +27,11 @@ import 'node:child_process';
|
|
27
27
|
import 'node:crypto';
|
28
28
|
import 'node:dns';
|
29
29
|
import 'crypto';
|
30
|
-
import 'node:buffer';
|
31
30
|
import 'module';
|
32
31
|
import 'node:assert';
|
33
32
|
import 'node:process';
|
34
33
|
import 'node:v8';
|
34
|
+
import 'node:buffer';
|
35
35
|
import 'rollup';
|
36
36
|
import 'rollup/parseAst';
|
37
37
|
import 'querystring';
|
@@ -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-YJaePtkC.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-YJaePtkC.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-YJaePtkC.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-YJaePtkC.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-YJaePtkC.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-YJaePtkC.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';
|
@@ -30,11 +30,11 @@ import 'node:child_process';
|
|
30
30
|
import 'node:crypto';
|
31
31
|
import 'node:dns';
|
32
32
|
import 'crypto';
|
33
|
-
import 'node:buffer';
|
34
33
|
import 'module';
|
35
34
|
import 'node:assert';
|
36
35
|
import 'node:process';
|
37
36
|
import 'node:v8';
|
37
|
+
import 'node:buffer';
|
38
38
|
import 'querystring';
|
39
39
|
import 'node:readline';
|
40
40
|
import 'node:events';
|