vite 5.4.0 → 5.4.1
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/client.d.ts +2 -11
- package/dist/node/chunks/{dep-DvdjAuZF.js → dep-BkYu-SNl.js} +1 -1
- package/dist/node/chunks/{dep-NjL7WTE1.js → dep-Cy9twKMn.js} +67 -59
- package/dist/node/chunks/{dep-C3NStZH1.js → dep-SDtFYyy1.js} +1 -1
- package/dist/node/cli.js +5 -5
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +2 -2
- package/package.json +3 -3
package/client.d.ts
CHANGED
@@ -251,15 +251,6 @@ declare interface VitePreloadErrorEvent extends Event {
|
|
251
251
|
payload: Error
|
252
252
|
}
|
253
253
|
|
254
|
-
declare interface
|
255
|
-
|
256
|
-
type: 'vite:preloadError',
|
257
|
-
listener: (this: Window, ev: VitePreloadErrorEvent) => unknown,
|
258
|
-
options?: boolean | AddEventListenerOptions,
|
259
|
-
): void
|
260
|
-
removeEventListener(
|
261
|
-
type: 'vite:preloadError',
|
262
|
-
listener: (this: Window, ev: VitePreloadErrorEvent) => unknown,
|
263
|
-
options?: boolean | EventListenerOptions,
|
264
|
-
): void
|
254
|
+
declare interface WindowEventMap {
|
255
|
+
'vite:preloadError': VitePreloadErrorEvent
|
265
256
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-
|
1
|
+
import { C as commonjsGlobal, B as getDefaultExportFromCjs } from './dep-Cy9twKMn.js';
|
2
2
|
import require$$0__default from 'fs';
|
3
3
|
import require$$0 from 'postcss';
|
4
4
|
import require$$0$1 from 'path';
|
@@ -16662,11 +16662,6 @@ function watchPackageDataPlugin(packageCache) {
|
|
16662
16662
|
if (id.endsWith("/package.json")) {
|
16663
16663
|
invalidatePackageData(packageCache, path$n.normalize(id));
|
16664
16664
|
}
|
16665
|
-
},
|
16666
|
-
handleHotUpdate({ file }) {
|
16667
|
-
if (file.endsWith("/package.json")) {
|
16668
|
-
invalidatePackageData(packageCache, path$n.normalize(file));
|
16669
|
-
}
|
16670
16665
|
}
|
16671
16666
|
};
|
16672
16667
|
}
|
@@ -36930,8 +36925,8 @@ function createCachedImport(imp) {
|
|
36930
36925
|
return cached;
|
36931
36926
|
};
|
36932
36927
|
}
|
36933
|
-
const importPostcssImport = createCachedImport(() => import('./dep-
|
36934
|
-
const importPostcssModules = createCachedImport(() => import('./dep-
|
36928
|
+
const importPostcssImport = createCachedImport(() => import('./dep-SDtFYyy1.js').then(function (n) { return n.i; }));
|
36929
|
+
const importPostcssModules = createCachedImport(() => import('./dep-BkYu-SNl.js').then(function (n) { return n.i; }));
|
36935
36930
|
const importPostcss = createCachedImport(() => import('postcss'));
|
36936
36931
|
const preprocessorWorkerControllerCache = /* @__PURE__ */ new WeakMap();
|
36937
36932
|
let alwaysFakeWorkerWorkerControllerCache;
|
@@ -37926,7 +37921,7 @@ async function compileLightningCSS(id, src, config, urlReplacer) {
|
|
37926
37921
|
}
|
37927
37922
|
deps.add(dep.url);
|
37928
37923
|
if (urlReplacer) {
|
37929
|
-
const replaceUrl = await urlReplacer(dep.url,
|
37924
|
+
const replaceUrl = await urlReplacer(dep.url, dep.loc.filePath);
|
37930
37925
|
css = css.replace(dep.placeholder, () => replaceUrl);
|
37931
37926
|
} else {
|
37932
37927
|
css = css.replace(dep.placeholder, () => dep.url);
|
@@ -47174,8 +47169,7 @@ function throwFileNotFoundInOptimizedDep(id) {
|
|
47174
47169
|
const nonJsRe = /\.json(?:$|\?)/;
|
47175
47170
|
const isNonJsRequest = (request) => nonJsRe.test(request);
|
47176
47171
|
const importMetaEnvMarker = "__vite_import_meta_env__";
|
47177
|
-
const
|
47178
|
-
const importMetaEnvKeyRe = new RegExp(`${importMetaEnvMarker}\\..+?\\b`, "g");
|
47172
|
+
const importMetaEnvKeyReCache = /* @__PURE__ */ new Map();
|
47179
47173
|
function definePlugin(config) {
|
47180
47174
|
const isBuild = config.command === "build";
|
47181
47175
|
const isBuildLib = isBuild && config.build.lib;
|
@@ -47231,8 +47225,6 @@ function definePlugin(config) {
|
|
47231
47225
|
SSR: ssr + "",
|
47232
47226
|
...userDefineEnv
|
47233
47227
|
});
|
47234
|
-
const banner = `const ${importMetaEnvMarker} = ${importMetaEnvVal};
|
47235
|
-
`;
|
47236
47228
|
const patternKeys = Object.keys(userDefine);
|
47237
47229
|
if (replaceProcessEnv && Object.keys(processEnv).length) {
|
47238
47230
|
patternKeys.push("process.env");
|
@@ -47241,7 +47233,7 @@ function definePlugin(config) {
|
|
47241
47233
|
patternKeys.push("import.meta.env", "import.meta.hot");
|
47242
47234
|
}
|
47243
47235
|
const pattern = patternKeys.length ? new RegExp(patternKeys.map(escapeRegex).join("|")) : null;
|
47244
|
-
return [define, pattern,
|
47236
|
+
return [define, pattern, importMetaEnvVal];
|
47245
47237
|
}
|
47246
47238
|
const defaultPattern = generatePattern(false);
|
47247
47239
|
const ssrPattern = generatePattern(true);
|
@@ -47258,21 +47250,35 @@ function definePlugin(config) {
|
|
47258
47250
|
) {
|
47259
47251
|
return;
|
47260
47252
|
}
|
47261
|
-
|
47253
|
+
let [define, pattern, importMetaEnvVal] = ssr ? ssrPattern : defaultPattern;
|
47262
47254
|
if (!pattern) return;
|
47263
47255
|
pattern.lastIndex = 0;
|
47264
47256
|
if (!pattern.test(code)) return;
|
47257
|
+
const hasDefineImportMetaEnv = "import.meta.env" in define;
|
47258
|
+
let marker = importMetaEnvMarker;
|
47259
|
+
if (hasDefineImportMetaEnv && code.includes(marker)) {
|
47260
|
+
let i = 1;
|
47261
|
+
do {
|
47262
|
+
marker = importMetaEnvMarker + i++;
|
47263
|
+
} while (code.includes(marker));
|
47264
|
+
if (marker !== importMetaEnvMarker) {
|
47265
|
+
define = { ...define, "import.meta.env": marker };
|
47266
|
+
}
|
47267
|
+
}
|
47265
47268
|
const result = await replaceDefine(code, id, define, config);
|
47266
|
-
|
47267
|
-
|
47268
|
-
|
47269
|
-
|
47270
|
-
|
47271
|
-
result.code
|
47272
|
-
|
47273
|
-
|
47274
|
-
map
|
47275
|
-
|
47269
|
+
if (hasDefineImportMetaEnv) {
|
47270
|
+
result.code = result.code.replaceAll(
|
47271
|
+
getImportMetaEnvKeyRe(marker),
|
47272
|
+
(m) => "undefined".padEnd(m.length)
|
47273
|
+
);
|
47274
|
+
if (result.code.includes(marker)) {
|
47275
|
+
result.code = `const ${marker} = ${importMetaEnvVal};
|
47276
|
+
` + result.code;
|
47277
|
+
if (result.map) {
|
47278
|
+
const map = JSON.parse(result.map);
|
47279
|
+
map.mappings = ";" + map.mappings;
|
47280
|
+
result.map = map;
|
47281
|
+
}
|
47276
47282
|
}
|
47277
47283
|
}
|
47278
47284
|
return result;
|
@@ -47328,6 +47334,14 @@ function handleDefineValue(value) {
|
|
47328
47334
|
if (typeof value === "string") return value;
|
47329
47335
|
return JSON.stringify(value);
|
47330
47336
|
}
|
47337
|
+
function getImportMetaEnvKeyRe(marker) {
|
47338
|
+
let re = importMetaEnvKeyReCache.get(marker);
|
47339
|
+
if (!re) {
|
47340
|
+
re = new RegExp(`${marker}\\..+?\\b`, "g");
|
47341
|
+
importMetaEnvKeyReCache.set(marker, re);
|
47342
|
+
}
|
47343
|
+
return re;
|
47344
|
+
}
|
47331
47345
|
|
47332
47346
|
const normalizedClientEntry = normalizePath$3(CLIENT_ENTRY);
|
47333
47347
|
const normalizedEnvEntry = normalizePath$3(ENV_ENTRY);
|
@@ -47671,7 +47685,7 @@ function webWorkerPlugin(config) {
|
|
47671
47685
|
}`;
|
47672
47686
|
let urlCode;
|
47673
47687
|
if (isBuild) {
|
47674
|
-
if (isWorker &&
|
47688
|
+
if (isWorker && config.bundleChain.at(-1) === cleanUrl(id)) {
|
47675
47689
|
urlCode = "self.location.href";
|
47676
47690
|
} else if (inlineRE.test(id)) {
|
47677
47691
|
const chunk = await bundleWorkerEntry(config, id);
|
@@ -48000,7 +48014,7 @@ function workerImportMetaUrlPlugin(config) {
|
|
48000
48014
|
file = await workerResolver(url, id);
|
48001
48015
|
file ??= url[0] === "/" ? slash$1(path$n.join(config.publicDir, url)) : slash$1(path$n.resolve(path$n.dirname(id), url));
|
48002
48016
|
}
|
48003
|
-
if (isBuild && config.isWorker &&
|
48017
|
+
if (isBuild && config.isWorker && config.bundleChain.at(-1) === cleanUrl(file)) {
|
48004
48018
|
s.update(expStart, expEnd, "self.location.href");
|
48005
48019
|
} else {
|
48006
48020
|
let builtUrl;
|
@@ -54228,10 +54242,10 @@ function resolveEmptyOutDir(emptyOutDir, root, outDirs, logger) {
|
|
54228
54242
|
for (const outDir of outDirs) {
|
54229
54243
|
if (!normalizePath$3(outDir).startsWith(withTrailingSlash(root))) {
|
54230
54244
|
logger?.warn(
|
54231
|
-
|
54245
|
+
colors$1.yellow(
|
54232
54246
|
`
|
54233
|
-
${
|
54234
|
-
|
54247
|
+
${colors$1.bold(`(!)`)} outDir ${colors$1.white(
|
54248
|
+
colors$1.dim(outDir)
|
54235
54249
|
)} is not inside project root and will not be emptied.
|
54236
54250
|
Use --emptyOutDir to override.
|
54237
54251
|
`
|
@@ -64465,17 +64479,15 @@ function buildImportAnalysisPlugin(config) {
|
|
64465
64479
|
const ssr = !!config.build.ssr;
|
64466
64480
|
const isWorker = config.isWorker;
|
64467
64481
|
const insertPreload = !(ssr || !!config.build.lib || isWorker);
|
64468
|
-
const resolveModulePreloadDependencies = config.build.modulePreload && config.build.modulePreload.resolveDependencies;
|
64469
64482
|
const renderBuiltUrl = config.experimental.renderBuiltUrl;
|
64470
|
-
const customModulePreloadPaths = !!(resolveModulePreloadDependencies || renderBuiltUrl);
|
64471
64483
|
const isRelativeBase = config.base === "./" || config.base === "";
|
64472
|
-
const optimizeModulePreloadRelativePaths = isRelativeBase && !
|
64484
|
+
const optimizeModulePreloadRelativePaths = isRelativeBase && !renderBuiltUrl;
|
64473
64485
|
const { modulePreload } = config.build;
|
64474
64486
|
const scriptRel2 = modulePreload && modulePreload.polyfill ? `'modulepreload'` : `(${detectScriptRel.toString()})()`;
|
64475
|
-
const assetsURL2 =
|
64476
|
-
// If `experimental.renderBuiltUrl`
|
64477
|
-
//
|
64478
|
-
//
|
64487
|
+
const assetsURL2 = renderBuiltUrl ? (
|
64488
|
+
// If `experimental.renderBuiltUrl` is used, the dependencies are already resolved.
|
64489
|
+
// To avoid the need for `new URL(dep, import.meta.url)`, a helper `__vitePreloadRelativeDep` is
|
64490
|
+
// used to resolve from relative paths which can be minimized.
|
64479
64491
|
`function(dep, importerUrl) { return dep[0] === '.' ? new URL(dep, importerUrl).href : dep }`
|
64480
64492
|
) : optimizeModulePreloadRelativePaths ? (
|
64481
64493
|
// If there isn't custom resolvers affecting the deps list, deps in the list are relative
|
@@ -64573,7 +64585,7 @@ function buildImportAnalysisPlugin(config) {
|
|
64573
64585
|
}
|
64574
64586
|
str().appendRight(
|
64575
64587
|
expEnd,
|
64576
|
-
`,${isModernFlag}?${preloadMarker}:void 0${optimizeModulePreloadRelativePaths ||
|
64588
|
+
`,${isModernFlag}?${preloadMarker}:void 0${optimizeModulePreloadRelativePaths || renderBuiltUrl ? ",import.meta.url" : ""})`
|
64577
64589
|
);
|
64578
64590
|
}
|
64579
64591
|
}
|
@@ -64754,34 +64766,30 @@ function buildImportAnalysisPlugin(config) {
|
|
64754
64766
|
markerStartPos2 = indexOfMatchInSlice(code, preloadMarkerRE);
|
64755
64767
|
}
|
64756
64768
|
if (markerStartPos2 > 0) {
|
64757
|
-
|
64769
|
+
let depsArray = deps.size > 1 || // main chunk is removed
|
64758
64770
|
hasRemovedPureCssChunk && deps.size > 0 ? modulePreload === false ? (
|
64759
64771
|
// CSS deps use the same mechanism as module preloads, so even if disabled,
|
64760
64772
|
// we still need to pass these deps to the preload helper in dynamic imports.
|
64761
64773
|
[...deps].filter((d) => d.endsWith(".css"))
|
64762
64774
|
) : [...deps] : [];
|
64763
|
-
|
64764
|
-
if (
|
64765
|
-
const
|
64766
|
-
const
|
64767
|
-
|
64768
|
-
|
64769
|
-
const cssDeps = [];
|
64770
|
-
const otherDeps = [];
|
64771
|
-
for (const dep of depsArray) {
|
64772
|
-
(dep.endsWith(".css") ? cssDeps : otherDeps).push(dep);
|
64773
|
-
}
|
64774
|
-
resolvedDeps = [
|
64775
|
-
...resolveDependencies(normalizedFile, otherDeps, {
|
64776
|
-
hostId: file,
|
64777
|
-
hostType: "js"
|
64778
|
-
}),
|
64779
|
-
...cssDeps
|
64780
|
-
];
|
64781
|
-
} else {
|
64782
|
-
resolvedDeps = depsArray;
|
64775
|
+
const resolveDependencies = modulePreload ? modulePreload.resolveDependencies : void 0;
|
64776
|
+
if (resolveDependencies && normalizedFile) {
|
64777
|
+
const cssDeps = [];
|
64778
|
+
const otherDeps = [];
|
64779
|
+
for (const dep of depsArray) {
|
64780
|
+
(dep.endsWith(".css") ? cssDeps : otherDeps).push(dep);
|
64783
64781
|
}
|
64784
|
-
|
64782
|
+
depsArray = [
|
64783
|
+
...resolveDependencies(normalizedFile, otherDeps, {
|
64784
|
+
hostId: file,
|
64785
|
+
hostType: "js"
|
64786
|
+
}),
|
64787
|
+
...cssDeps
|
64788
|
+
];
|
64789
|
+
}
|
64790
|
+
let renderedDeps;
|
64791
|
+
if (renderBuiltUrl) {
|
64792
|
+
renderedDeps = depsArray.map((dep) => {
|
64785
64793
|
const replacement = toOutputFilePathInJS(
|
64786
64794
|
dep,
|
64787
64795
|
"asset",
|
package/dist/node/cli.js
CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
2
2
|
import fs__default from 'node:fs';
|
3
3
|
import { performance } from 'node:perf_hooks';
|
4
4
|
import { EventEmitter } from 'events';
|
5
|
-
import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-
|
5
|
+
import { A as colors, v as createLogger, r as resolveConfig } from './chunks/dep-Cy9twKMn.js';
|
6
6
|
import { VERSION } from './constants.js';
|
7
7
|
import 'node:fs/promises';
|
8
8
|
import 'node:url';
|
@@ -730,7 +730,7 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--
|
|
730
730
|
`[boolean] force the optimizer to ignore the cache and re-bundle`
|
731
731
|
).action(async (root, options) => {
|
732
732
|
filterDuplicateOptions(options);
|
733
|
-
const { createServer } = await import('./chunks/dep-
|
733
|
+
const { createServer } = await import('./chunks/dep-Cy9twKMn.js').then(function (n) { return n.E; });
|
734
734
|
try {
|
735
735
|
const server = await createServer({
|
736
736
|
root,
|
@@ -822,7 +822,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
|
|
822
822
|
`[boolean] force empty outDir when it's outside of root`
|
823
823
|
).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
|
824
824
|
filterDuplicateOptions(options);
|
825
|
-
const { build } = await import('./chunks/dep-
|
825
|
+
const { build } = await import('./chunks/dep-Cy9twKMn.js').then(function (n) { return n.F; });
|
826
826
|
const buildOptions = cleanOptions(options);
|
827
827
|
try {
|
828
828
|
await build({
|
@@ -851,7 +851,7 @@ cli.command("optimize [root]", "pre-bundle dependencies").option(
|
|
851
851
|
).action(
|
852
852
|
async (root, options) => {
|
853
853
|
filterDuplicateOptions(options);
|
854
|
-
const { optimizeDeps } = await import('./chunks/dep-
|
854
|
+
const { optimizeDeps } = await import('./chunks/dep-Cy9twKMn.js').then(function (n) { return n.D; });
|
855
855
|
try {
|
856
856
|
const config = await resolveConfig(
|
857
857
|
{
|
@@ -877,7 +877,7 @@ ${e.stack}`),
|
|
877
877
|
cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`, { type: [convertHost] }).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--open [path]", `[boolean | string] open browser on startup`).option("--outDir <dir>", `[string] output directory (default: dist)`).action(
|
878
878
|
async (root, options) => {
|
879
879
|
filterDuplicateOptions(options);
|
880
|
-
const { preview } = await import('./chunks/dep-
|
880
|
+
const { preview } = await import('./chunks/dep-Cy9twKMn.js').then(function (n) { return n.G; });
|
881
881
|
try {
|
882
882
|
const server = await preview({
|
883
883
|
root,
|
package/dist/node/index.d.ts
CHANGED
@@ -717,7 +717,7 @@ interface CommonServerOptions {
|
|
717
717
|
* https://github.com/expressjs/cors#configuration-options
|
718
718
|
*/
|
719
719
|
interface CorsOptions {
|
720
|
-
origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
720
|
+
origin?: CorsOrigin | ((origin: string | undefined, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
721
721
|
methods?: string | string[];
|
722
722
|
allowedHeaders?: string | string[];
|
723
723
|
exposedHeaders?: string | string[];
|
package/dist/node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
export { parseAst, parseAstAsync } from 'rollup/parseAst';
|
2
|
-
import { i as isInNodeModules, a as arraify } from './chunks/dep-
|
3
|
-
export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-
|
2
|
+
import { i as isInNodeModules, a as arraify } from './chunks/dep-Cy9twKMn.js';
|
3
|
+
export { b as build, g as buildErrorMessage, k as createFilter, v as createLogger, c as createServer, d as defineConfig, h as fetchModule, f as formatPostcssSourceMap, x as isFileServingAllowed, l as loadConfigFromFile, y as loadEnv, j as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, e as preprocessCSS, p as preview, r as resolveConfig, z as resolveEnvPrefix, q as rollupVersion, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-Cy9twKMn.js';
|
4
4
|
export { VERSION as version } from './constants.js';
|
5
5
|
export { version as esbuildVersion } from 'esbuild';
|
6
6
|
import { existsSync, readFileSync } from 'node:fs';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "vite",
|
3
|
-
"version": "5.4.
|
3
|
+
"version": "5.4.1",
|
4
4
|
"type": "module",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Evan You",
|
@@ -73,7 +73,7 @@
|
|
73
73
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
74
74
|
"dependencies": {
|
75
75
|
"esbuild": "^0.21.3",
|
76
|
-
"postcss": "^8.4.
|
76
|
+
"postcss": "^8.4.41",
|
77
77
|
"rollup": "^4.13.0"
|
78
78
|
},
|
79
79
|
"optionalDependencies": {
|
@@ -110,7 +110,7 @@
|
|
110
110
|
"fast-glob": "^3.3.2",
|
111
111
|
"http-proxy": "^1.18.1",
|
112
112
|
"launch-editor-middleware": "^2.8.1",
|
113
|
-
"lightningcss": "^1.
|
113
|
+
"lightningcss": "^1.26.0",
|
114
114
|
"magic-string": "^0.30.11",
|
115
115
|
"micromatch": "^4.0.7",
|
116
116
|
"mlly": "^1.7.1",
|