From 94d1139dbcb7a5d651621d62270bb970a587ae6c Mon Sep 17 00:00:00 2001 From: Ulrich Stark <8657779+ulrichstark@users.noreply.github.com> Date: Tue, 2 Jun 2026 23:12:12 +0200 Subject: [PATCH 1/3] chore: integrate knip and remove unused code, exports and dependencies --- .../theme/components/SponsorBanner.vue | 640 ------------------ docs/package.json | 4 +- knip.json | 85 +++ packages/vite/src/module-runner/types.ts | 4 +- packages/vite/src/node/config.ts | 18 +- packages/vite/src/node/optimizer/index.ts | 4 +- packages/vite/src/node/plugin.ts | 2 +- packages/vite/src/node/plugins/asset.ts | 8 +- packages/vite/src/node/plugins/css.ts | 6 +- .../src/node/plugins/dynamicImportVars.ts | 2 +- packages/vite/src/node/plugins/esbuild.ts | 67 +- packages/vite/src/node/plugins/html.ts | 6 +- .../vite/src/node/plugins/importAnalysis.ts | 6 +- .../src/node/plugins/importAnalysisBuild.ts | 4 +- .../vite/src/node/plugins/importMetaGlob.ts | 4 +- packages/vite/src/node/plugins/index.ts | 2 +- packages/vite/src/node/plugins/license.ts | 2 +- .../vite/src/node/plugins/optimizedDeps.ts | 2 +- packages/vite/src/node/plugins/resolve.ts | 2 +- packages/vite/src/node/plugins/worker.ts | 2 +- packages/vite/src/node/server/hmr.ts | 6 +- packages/vite/src/node/server/index.ts | 4 +- .../vite/src/node/server/middlewares/error.ts | 2 +- .../vite/src/node/server/pluginContainer.ts | 14 +- .../vite/src/node/server/transformRequest.ts | 2 +- packages/vite/src/node/server/ws.ts | 2 +- packages/vite/src/node/ssr/ssrStacktrace.ts | 2 +- packages/vite/src/node/ssr/ssrTransform.ts | 12 +- packages/vite/src/node/utils.ts | 11 +- packages/vite/src/shared/forwardConsole.ts | 2 +- packages/vite/src/shared/invokeMethods.ts | 2 +- pnpm-lock.yaml | 96 --- 32 files changed, 145 insertions(+), 880 deletions(-) delete mode 100644 docs/.vitepress/theme/components/SponsorBanner.vue create mode 100644 knip.json diff --git a/docs/.vitepress/theme/components/SponsorBanner.vue b/docs/.vitepress/theme/components/SponsorBanner.vue deleted file mode 100644 index 410a7569031331..00000000000000 --- a/docs/.vitepress/theme/components/SponsorBanner.vue +++ /dev/null @@ -1,640 +0,0 @@ - - - - - - - diff --git a/docs/package.json b/docs/package.json index 2313ef6e5ea817..c09286c9c8ba70 100644 --- a/docs/package.json +++ b/docs/package.json @@ -10,7 +10,6 @@ "devDependencies": { "@iconify/vue": "^5.0.1", "@shikijs/vitepress-twoslash": "^4.1.0", - "@types/express": "^5.0.6", "@voidzero-dev/vitepress-theme": "^4.8.4", "feed": "^5.2.1", "markdown-it-image-size": "^15.0.1", @@ -19,7 +18,6 @@ "vitepress-plugin-graphviz": "^0.1.0", "vitepress-plugin-group-icons": "^1.7.5", "vitepress-plugin-llms": "^1.13.1", - "vue": "^3.5.35", - "vue-tsc": "^3.3.3" + "vue": "^3.5.35" } } diff --git a/knip.json b/knip.json new file mode 100644 index 00000000000000..2de7f178f3b66e --- /dev/null +++ b/knip.json @@ -0,0 +1,85 @@ +{ + "$schema": "https://unpkg.com/knip@6/schema.json", + "ignoreWorkspaces": ["playground/**"], + "ignoreFiles": [ + "packages/vite/src/**/__tests__/**", + "packages/vite/misc/*.d.ts", + "packages/vite/src/types/shims.d.ts" + ], + "ignoreIssues": { + "**/__tests__/**": ["exports", "types", "namespaceMembers", "duplicates"], + "**/__tests__/**/package.json": ["dependencies", "devDependencies"], + "**/__tests_dts__/**/package.json": ["dependencies", "devDependencies"], + "docs/.vitepress/theme/landing/**/*.vue": ["unlisted"], + "docs/.vitepress/theme/live/**/*.vue": ["unlisted"], + "packages/vite/src/types/**/*.d.ts": [ + "exports", + "types", + "namespaceMembers" + ] + }, + "ignoreBinaries": ["only-allow"], + "vite": { + "config": [] + }, + "workspaces": { + ".": { + "entry": ["scripts/**/*.ts"], + "project": ["scripts/**/*.ts"] + }, + "packages/vite": { + "paths": { + "@vite/env": ["./src/client/env.ts"] + }, + "ignoreDependencies": [ + "@types/node", + "jiti", + "less", + "sass-embedded", + "stylus", + "tsx", + "yaml" + ], + "entry": [ + "src/node/index.ts", + "src/node/cli.ts", + "src/node/internalIndex.ts", + "src/module-runner/index.ts", + "src/client/client.ts", + "src/client/env.ts", + "src/client/overlay.ts", + "src/**/__tests__/**/*.spec.ts", + "src/**/__tests_dts__/**/*.ts", + "rolldown*.ts", + "rollupLicensePlugin.ts" + ], + "project": [ + "src/**/*.{js,cjs,mjs,ts,cts,mts,tsx,d.ts}", + "misc/**/*.{js,d.ts}", + "rolldown*.ts" + ] + }, + "packages/create-vite": { + "entry": ["__tests__/**/*.spec.ts"], + "project": ["src/**/*.ts", "__tests__/**/*.spec.ts"] + }, + "packages/plugin-legacy": { + "ignoreDependencies": ["core-js", "regenerator-runtime", "systemjs"], + "entry": ["src/**/__tests__/**/*.spec.ts"], + "project": ["src/**/*.{js,cjs,mjs,ts,cts,mts,d.ts}"] + }, + "docs": { + "entry": [ + ".vitepress/buildEnd.config.ts", + ".vitepress/theme/landing/Layout.vue", + ".vitepress/theme/live/Layout.vue", + ".vitepress/theme/components/BlogIndex.vue", + ".vitepress/theme/components/SupportedVersions.vue", + ".vitepress/inlined-scripts/*.js", + "_data/**/*.{js,ts}", + "**/*.md" + ], + "project": [".vitepress/**/*.{js,ts,vue,d.ts}", "_data/**/*.{js,ts}"] + } + } +} diff --git a/packages/vite/src/module-runner/types.ts b/packages/vite/src/module-runner/types.ts index 38586c2900d288..1acd1b0f1e5352 100644 --- a/packages/vite/src/module-runner/types.ts +++ b/packages/vite/src/module-runner/types.ts @@ -22,7 +22,7 @@ import type { } from './constants' import type { InterceptorOptions } from './sourcemap/interceptor' -export type { DefineImportMetadata, SSRImportMetadata } +export type { SSRImportMetadata } export interface ModuleRunnerImportMeta { url: string @@ -123,7 +123,7 @@ export interface ModuleRunnerOptions { evaluatedModules?: EvaluatedModules } -export interface ImportMetaEnv { +interface ImportMetaEnv { [key: string]: any BASE_URL: string MODE: string diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index 8991f6d7168112..31b426f3b6336a 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -189,7 +189,7 @@ export function defineConfig(config: UserConfigExport): UserConfigExport { return config } -export interface CreateDevEnvironmentContext { +interface CreateDevEnvironmentContext { ws: WebSocketServer } @@ -285,7 +285,7 @@ type AllResolveOptions = ResolveOptions & { type ResolvedAllResolveOptions = Required & { alias: Alias[] } -export interface SharedEnvironmentOptions { +interface SharedEnvironmentOptions { /** * Define global variable replacements. * Entries will be defined on `window` during dev and replaced during build. @@ -333,7 +333,7 @@ export interface EnvironmentOptions extends SharedEnvironmentOptions { build?: BuildEnvironmentOptions } -export type ResolvedResolveOptions = Required +type ResolvedResolveOptions = Required export type ResolvedEnvironmentOptions = { define?: Record @@ -349,7 +349,7 @@ export type ResolvedEnvironmentOptions = { optimizeDepsPluginNames: string[] } -export type DefaultEnvironmentOptions = Omit< +type DefaultEnvironmentOptions = Omit< EnvironmentOptions, 'consumer' | 'resolve' | 'keepProcessEnv' > & { @@ -765,7 +765,7 @@ export interface ResolvedConfig extends Readonly< } & PluginHookUtils > {} -export async function resolveDevToolsConfig( +async function resolveDevToolsConfig( config: DevToolsConfig | boolean | undefined, host: string | boolean | undefined, logger: Logger, @@ -907,7 +907,7 @@ const configDefaults = Object.freeze({ appType: 'spa', } satisfies UserConfig) -export function resolveDevEnvironmentOptions( +function resolveDevEnvironmentOptions( dev: DevEnvironmentOptions | undefined, environmentName: string | undefined, consumer: 'client' | 'server' | undefined, @@ -1021,9 +1021,7 @@ function resolveEnvironmentOptions( } } -export function getDefaultEnvironmentOptions( - config: UserConfig, -): EnvironmentOptions { +function getDefaultEnvironmentOptions(config: UserConfig): EnvironmentOptions { return { define: config.define, resolve: { @@ -2216,7 +2214,7 @@ assetFileNames isn't equal for every build.rolldownOptions.output. A single patt * Resolve base url. Note that some users use Vite to build for non-web targets like * electron or expects to deploy */ -export function resolveBaseUrl( +function resolveBaseUrl( base: UserConfig['base'] = configDefaults.base, isBuild: boolean, logger: Logger, diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index c88de8003208d3..a699ab13e42f3c 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -955,7 +955,7 @@ function getDepsCacheSuffix(environment: Environment): string { return environment.name === 'client' ? '' : `_${environment.name}` } -export function getDepsCacheDir(environment: Environment): string { +function getDepsCacheDir(environment: Environment): string { return getDepsCacheDirPrefix(environment) + getDepsCacheSuffix(environment) } @@ -1419,7 +1419,7 @@ export async function optimizedDepNeedsInterop( } const MAX_TEMP_DIR_AGE_MS = 24 * 60 * 60 * 1000 -export async function cleanupDepsCacheStaleDirs( +async function cleanupDepsCacheStaleDirs( config: ResolvedConfig, ): Promise { try { diff --git a/packages/vite/src/node/plugin.ts b/packages/vite/src/node/plugin.ts index a0be15a581123e..383b88e9767c56 100644 --- a/packages/vite/src/node/plugin.ts +++ b/packages/vite/src/node/plugin.ts @@ -66,7 +66,7 @@ export interface PluginContextExtension { environment: Environment } -export interface PluginContextMetaExtension { +interface PluginContextMetaExtension { viteVersion: string } diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 35cd29ea8cf582..47a2f40723ff0e 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -48,8 +48,8 @@ export const assetUrlRE: RegExp = /__VITE_ASSET__([\w$]+)__(?:\$_(.*?)__)?/g const jsSourceMapRE = /\.[cm]?js\.map$/ -export const noInlineRE: RegExp = /[?&]no-inline\b/ -export const inlineRE: RegExp = /[?&]inline\b/ +const noInlineRE: RegExp = /[?&]no-inline\b/ +const inlineRE: RegExp = /[?&]inline\b/ const assetCache = new WeakMap>() @@ -60,7 +60,7 @@ export const cssEntriesMap: WeakMap< > = new WeakMap() // add own dictionary entry by directly assigning mrmime -export function registerCustomMime(): void { +function registerCustomMime(): void { // https://github.com/lukeed/mrmime/issues/3 // instead of `image/vnd.microsoft.icon` which is registered on IANA Media Types DB // image/x-icon should be used instead for better compatibility (https://github.com/h5bp/html5-boilerplate/issues/219) @@ -330,7 +330,7 @@ export async function fileToUrl( } } -export async function fileToDevUrl( +async function fileToDevUrl( environment: Environment, id: string, asFileUrl = false, diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 367a97c9aa0d1f..e2bfd4217395fe 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -2004,9 +2004,9 @@ type CssUrlReplacer = ( // https://drafts.csswg.org/css-syntax-3/#identifier-code-point export const cssUrlRE: RegExp = /(? = { close: () => void | Promise } -export interface StylePreprocessorResults { +interface StylePreprocessorResults { code: string map?: ExistingRawSourceMap | undefined additionalMap?: ExistingRawSourceMap | undefined diff --git a/packages/vite/src/node/plugins/dynamicImportVars.ts b/packages/vite/src/node/plugins/dynamicImportVars.ts index 70f3f3af5ed559..fa614dde0721fb 100644 --- a/packages/vite/src/node/plugins/dynamicImportVars.ts +++ b/packages/vite/src/node/plugins/dynamicImportVars.ts @@ -24,7 +24,7 @@ import { perEnvironmentState } from '../environment' import { hasViteIgnoreRE } from './importAnalysis' import { workerOrSharedWorkerRE } from './worker' -export const dynamicImportHelperId = '\0vite/dynamic-import-helper.js' +const dynamicImportHelperId = '\0vite/dynamic-import-helper.js' const relativePathRE = /^\.{1,2}\// // fast path to check if source contains a dynamic import. we check for a diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index a5ff2ef0ed56f5..a94fbe114fd2e6 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -14,7 +14,6 @@ import type { FSWatcher } from '#dep-types/chokidar' import { combineSourcemaps, createDebugger, - createFilter, ensureWatchedFile, generateCodeFrame, } from '../utils' @@ -31,13 +30,12 @@ const IIFE_BEGIN_RE = /(?:const|var)\s+\S+\s*=\s*\(?function\([^()]*\)\s*\{\s*"use strict";/ const validExtensionRE = /\.\w+$/ -const jsxExtensionsRE = /\.(?:j|t)sx\b/ // the final build should always support dynamic import and import.meta. // if they need to be polyfilled, plugin-legacy should be used. // plugin-legacy detects these two features when checking for modern code. // Browser support: https://caniuse.com/es6-module-dynamic-import,mdn-javascript_operators_import_meta#:~:text=Feature%20summary -export const defaultEsbuildSupported = { +const defaultEsbuildSupported = { 'dynamic-import': true, 'import-meta': true, } @@ -74,7 +72,7 @@ type TSConfigJSON = { } [key: string]: any } -export type TSCompilerOptions = NonNullable +type TSCompilerOptions = NonNullable let esbuild: Promise | undefined const importEsbuild = () => { @@ -275,67 +273,6 @@ export async function transformWithEsbuild( } } -export function esbuildPlugin(config: ResolvedConfig): Plugin { - const options = config.esbuild as ESBuildOptions - const { jsxInject, include, exclude, ...esbuildTransformOptions } = options - - const filter = createFilter(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/) - - // Remove optimization options for dev as we only need to transpile them, - // and for build as the final optimization is in `buildEsbuildPlugin` - const transformOptions: EsbuildTransformOptions = { - target: 'esnext', - ...esbuildTransformOptions, - minify: false, - minifyIdentifiers: false, - minifySyntax: false, - minifyWhitespace: false, - treeShaking: false, - // keepNames is not needed when minify is disabled. - // Also transforming multiple times with keepNames enabled breaks - // tree-shaking. (#9164) - keepNames: false, - supported: { - ...defaultEsbuildSupported, - ...esbuildTransformOptions.supported, - }, - } - - let server: ViteDevServer | undefined - - return { - name: 'vite:esbuild', - configureServer(_server) { - server = _server - }, - async transform(code, id) { - if (filter(id) || filter(cleanUrl(id))) { - const result = await transformWithEsbuild( - code, - id, - transformOptions, - undefined, - config, - server?.watcher, - ) - if (result.warnings.length) { - result.warnings.forEach((m) => { - this.warn(prettifyMessage(m, code)) - }) - } - if (jsxInject && jsxExtensionsRE.test(id)) { - result.code = jsxInject + ';' + result.code - } - return { - code: result.code, - map: result.map, - moduleType: 'js', - } - } - }, - } -} - const rollupToEsbuildFormatMap: Record< string, EsbuildTransformOptions['format'] | undefined diff --git a/packages/vite/src/node/plugins/html.ts b/packages/vite/src/node/plugins/html.ts index a1ddfe00935ce3..c0868cd6a92554 100644 --- a/packages/vite/src/node/plugins/html.ts +++ b/packages/vite/src/node/plugins/html.ts @@ -84,7 +84,7 @@ export const isHTMLRequest = (request: string): boolean => htmlLangRE.test(request) // HTML Proxy Caches are stored by config -> filePath -> index -export const htmlProxyMap: WeakMap< +const htmlProxyMap: WeakMap< ResolvedConfig, Map< string, @@ -169,7 +169,7 @@ const noInlineLinkRels = new Set([ 'manifest', ]) -export const isAsyncScriptMap: WeakMap< +const isAsyncScriptMap: WeakMap< ResolvedConfig, Map > = new WeakMap() @@ -1078,7 +1078,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin { } } -export function parseRelAttr(attr: string): string[] { +function parseRelAttr(attr: string): string[] { return attr.split(spaceRe).map((v) => v.toLowerCase()) } diff --git a/packages/vite/src/node/plugins/importAnalysis.ts b/packages/vite/src/node/plugins/importAnalysis.ts index bd346f86f1c1bb..3554f5450a1210 100644 --- a/packages/vite/src/node/plugins/importAnalysis.ts +++ b/packages/vite/src/node/plugins/importAnalysis.ts @@ -84,7 +84,7 @@ const debug = createDebugger('vite:import-analysis') const clientDir = normalizePath(CLIENT_DIR) const skipRE = /\.(?:map|json)(?:$|\?)/ -export const canSkipImportAnalysis = (id: string): boolean => +const canSkipImportAnalysis = (id: string): boolean => skipRE.test(id) || isDirectCSSRequest(id) const optimizedDepChunkRE = /\/chunk-[A-Z\d]{8}\.js/ @@ -885,7 +885,7 @@ function mergeAcceptedUrls(orderedUrls: Array | undefined>) { return acceptedUrls } -export function createParseErrorInfo( +function createParseErrorInfo( importer: string, source: string, ): { message: string; showCodeFrame: boolean } { @@ -929,7 +929,7 @@ const interopHelper = (m: any, n: boolean) => : m const interopHelperStr = interopHelper.toString().replaceAll('\n', '') -export function interopNamedImports( +function interopNamedImports( str: MagicString, importSpecifier: ImportSpecifier, rewrittenUrl: string, diff --git a/packages/vite/src/node/plugins/importAnalysisBuild.ts b/packages/vite/src/node/plugins/importAnalysisBuild.ts index 07e0366ac47124..66ec17bf99ebf0 100644 --- a/packages/vite/src/node/plugins/importAnalysisBuild.ts +++ b/packages/vite/src/node/plugins/importAnalysisBuild.ts @@ -26,9 +26,9 @@ type VitePreloadErrorEvent = Event & { payload: Error } * target is not native es - so that injected helper logic can be conditionally * dropped. */ -export const isModernFlag = `__VITE_IS_MODERN__` +const isModernFlag = `__VITE_IS_MODERN__` export const preloadMethod = `__vitePreload` -export const preloadMarker = `__VITE_PRELOAD__` +const preloadMarker = `__VITE_PRELOAD__` export const preloadHelperId = '\0vite/preload-helper.js' const preloadMarkerRE = new RegExp(preloadMarker, 'g') diff --git a/packages/vite/src/node/plugins/importMetaGlob.ts b/packages/vite/src/node/plugins/importMetaGlob.ts index 4bed9f5c8f3b78..6d91b7e127258d 100644 --- a/packages/vite/src/node/plugins/importMetaGlob.ts +++ b/packages/vite/src/node/plugins/importMetaGlob.ts @@ -637,7 +637,7 @@ function globSafeResolvedPath(resolved: string, glob: string) { return globSafePath(staticPart) + dynamicPart } -export async function toAbsoluteGlob( +async function toAbsoluteGlob( glob: string, root: string, importer: string | undefined, @@ -711,7 +711,7 @@ export function getCommonBase(globsResolved: string[]): null | string { return commonAncestor } -export function isVirtualModule(id: string): boolean { +function isVirtualModule(id: string): boolean { // https://vite.dev/guide/api-plugin.html#virtual-modules-convention return id.startsWith('virtual:') || id[0] === '\0' || !id.includes('/') } diff --git a/packages/vite/src/node/plugins/index.ts b/packages/vite/src/node/plugins/index.ts index 2255d37416b620..b7adf3db2e5e3f 100644 --- a/packages/vite/src/node/plugins/index.ts +++ b/packages/vite/src/node/plugins/index.ts @@ -293,7 +293,7 @@ function extractFilter( // Same as `@rollup/plugin-alias` default resolver, but we attach additional meta // if we can't resolve to something, which will error in `importAnalysis` -export const viteAliasCustomResolver: ResolverFunction = async function ( +const viteAliasCustomResolver: ResolverFunction = async function ( id, importer, options, diff --git a/packages/vite/src/node/plugins/license.ts b/packages/vite/src/node/plugins/license.ts index 661c13aa771213..aa2202afa5684b 100644 --- a/packages/vite/src/node/plugins/license.ts +++ b/packages/vite/src/node/plugins/license.ts @@ -5,7 +5,7 @@ import { isInNodeModules, sortObjectKeys } from '../utils' import type { PackageCache } from '../packages' import { findNearestMainPackageData } from '../packages' -export interface LicenseEntry { +interface LicenseEntry { /** * Package name */ diff --git a/packages/vite/src/node/plugins/optimizedDeps.ts b/packages/vite/src/node/plugins/optimizedDeps.ts index a7b4c524ce7c27..3516a71e552c25 100644 --- a/packages/vite/src/node/plugins/optimizedDeps.ts +++ b/packages/vite/src/node/plugins/optimizedDeps.ts @@ -123,7 +123,7 @@ export function throwOutdatedRequest(id: string): never { throw err } -export function throwFileNotFoundInOptimizedDep(id: string): never { +function throwFileNotFoundInOptimizedDep(id: string): never { const err: any = new Error( `The file does not exist at "${id}" which is in the optimize deps directory. ` + `The dependency might be incompatible with the dep optimizer. ` + diff --git a/packages/vite/src/node/plugins/resolve.ts b/packages/vite/src/node/plugins/resolve.ts index 9c0aece84ea4c7..1e3af14107155d 100644 --- a/packages/vite/src/node/plugins/resolve.ts +++ b/packages/vite/src/node/plugins/resolve.ts @@ -903,7 +903,7 @@ export async function tryOptimizedResolve( } } -export function resolvePackageEntry( +function resolvePackageEntry( id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, options: InternalResolveOptions, diff --git a/packages/vite/src/node/plugins/worker.ts b/packages/vite/src/node/plugins/worker.ts index 240a2ebba0b8cd..c69e8d904eec6c 100644 --- a/packages/vite/src/node/plugins/worker.ts +++ b/packages/vite/src/node/plugins/worker.ts @@ -305,7 +305,7 @@ async function bundleWorkerEntry( return newBundleInfo } -export const workerAssetUrlRE: RegExp = /__VITE_WORKER_ASSET__([a-z\d]{8})__/g +const workerAssetUrlRE: RegExp = /__VITE_WORKER_ASSET__([a-z\d]{8})__/g export async function workerFileToUrl( config: ResolvedConfig, diff --git a/packages/vite/src/node/server/hmr.ts b/packages/vite/src/node/server/hmr.ts index 93890f03a7769f..63808fd85c320b 100644 --- a/packages/vite/src/node/server/hmr.ts +++ b/packages/vite/src/node/server/hmr.ts @@ -369,9 +369,7 @@ export const normalizeHotChannel = ( } } -export function getSortedPluginsByHotUpdateHook( - plugins: readonly Plugin[], -): Plugin[] { +function getSortedPluginsByHotUpdateHook(plugins: readonly Plugin[]): Plugin[] { const sortedPlugins: Plugin[] = [] // Use indexes to track and insert the ordered plugins directly in the // resulting array to avoid creating 3 extra temporary arrays per hook @@ -1152,7 +1150,7 @@ async function readModifiedFile(file: string): Promise { } } -export type ServerHotChannelApi = { +type ServerHotChannelApi = { innerEmitter: EventEmitter outsideEmitter: EventEmitter } diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 7a25018c7136d5..a2ed4af5d9e079 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -267,7 +267,7 @@ export type ServerHook = ( export type HttpServer = http.Server | Http2SecureServer -export async function resolveForwardConsoleOptions( +async function resolveForwardConsoleOptions( value: boolean | ForwardConsoleOptions | undefined, ): Promise { value ??= (await determineAgent()).isAgent @@ -475,7 +475,7 @@ export function createServer( return _createServer(inlineConfig, { listen: true }) } -export async function _createServer( +async function _createServer( inlineConfig: ResolvedConfig | InlineConfig | undefined = {}, options: { listen: boolean diff --git a/packages/vite/src/node/server/middlewares/error.ts b/packages/vite/src/node/server/middlewares/error.ts index 08fab7c6b25694..6758c6eccec031 100644 --- a/packages/vite/src/node/server/middlewares/error.ts +++ b/packages/vite/src/node/server/middlewares/error.ts @@ -42,7 +42,7 @@ function cleanStack(stack: string) { .join('\n') } -export function logError(server: ViteDevServer, err: RollupError): void { +function logError(server: ViteDevServer, err: RollupError): void { const msg = buildErrorMessage(err, [ colors.red(`Internal server error: ${err.message}`), ]) diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index e14d5c613f3d20..c7d64f19e61423 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -47,7 +47,6 @@ import type { ModuleOptions, ModuleType, NormalizedInputOptions, - OutputOptions, ParallelPluginHooks, PartialNull, PartialResolvedId, @@ -135,13 +134,6 @@ export function throwClosedServerError(): never { throw err } -export interface PluginContainerOptions { - cwd?: string - output?: OutputOptions - modules?: Map - writeFile?: (name: string, source: string | Uint8Array) => void -} - /** * Create a plugin container with a set of plugins. We pass them as a parameter * instead of using environment.plugins to allow the creation of different @@ -1172,11 +1164,7 @@ class TransformPluginContext } } -export type { - EnvironmentPluginContainer, - TransformPluginContext, - TransformResult, -} +export type { EnvironmentPluginContainer, TransformPluginContext } // Backward compatibility class PluginContainer { diff --git a/packages/vite/src/node/server/transformRequest.ts b/packages/vite/src/node/server/transformRequest.ts index 35d01b3833d129..9fe45dd0db96ef 100644 --- a/packages/vite/src/node/server/transformRequest.ts +++ b/packages/vite/src/node/server/transformRequest.ts @@ -38,7 +38,7 @@ import type { DevEnvironment } from './environment' import { isServerAccessDeniedForTransform } from './middlewares/transform' export const ERR_LOAD_URL = 'ERR_LOAD_URL' -export const ERR_LOAD_PUBLIC_URL = 'ERR_LOAD_PUBLIC_URL' +const ERR_LOAD_PUBLIC_URL = 'ERR_LOAD_PUBLIC_URL' export const ERR_DENIED_ID = 'ERR_DENIED_ID' const debugLoad = createDebugger('vite:load') diff --git a/packages/vite/src/node/server/ws.ts b/packages/vite/src/node/server/ws.ts index 733059ef78048c..6156ca24aaa43c 100644 --- a/packages/vite/src/node/server/ws.ts +++ b/packages/vite/src/node/server/ws.ts @@ -31,7 +31,7 @@ const WebSocketServerRaw = process.versions.bun import.meta.require('ws').WebSocketServer : WebSocketServerRaw_ -export const HMR_HEADER = 'vite-hmr' +const HMR_HEADER = 'vite-hmr' export type WebSocketCustomListener = ( data: T, diff --git a/packages/vite/src/node/ssr/ssrStacktrace.ts b/packages/vite/src/node/ssr/ssrStacktrace.ts index be1bd44874ab33..19c2e916e69bdf 100644 --- a/packages/vite/src/node/ssr/ssrStacktrace.ts +++ b/packages/vite/src/node/ssr/ssrStacktrace.ts @@ -72,7 +72,7 @@ export function ssrRewriteStacktrace( return { result: rewritten, alreadyRewritten } } -export function rebindErrorStacktrace(e: Error, stacktrace: string): void { +function rebindErrorStacktrace(e: Error, stacktrace: string): void { const { configurable, writable } = Object.getOwnPropertyDescriptor( e, 'stack', diff --git a/packages/vite/src/node/ssr/ssrTransform.ts b/packages/vite/src/node/ssr/ssrTransform.ts index bdb0f42802ca45..a334cd24895ff8 100644 --- a/packages/vite/src/node/ssr/ssrTransform.ts +++ b/packages/vite/src/node/ssr/ssrTransform.ts @@ -23,12 +23,12 @@ export interface ModuleRunnerTransformOptions { } } -export const ssrModuleExportsKey = `__vite_ssr_exports__` -export const ssrImportKey = `__vite_ssr_import__` -export const ssrDynamicImportKey = `__vite_ssr_dynamic_import__` -export const ssrExportAllKey = `__vite_ssr_exportAll__` -export const ssrExportNameKey = `__vite_ssr_exportName__` -export const ssrImportMetaKey = `__vite_ssr_import_meta__` +const ssrModuleExportsKey = `__vite_ssr_exports__` +const ssrImportKey = `__vite_ssr_import__` +const ssrDynamicImportKey = `__vite_ssr_dynamic_import__` +const ssrExportAllKey = `__vite_ssr_exportAll__` +const ssrExportNameKey = `__vite_ssr_exportName__` +const ssrImportMetaKey = `__vite_ssr_import_meta__` export async function ssrTransform( code: string, diff --git a/packages/vite/src/node/utils.ts b/packages/vite/src/node/utils.ts index 8d538a293aae32..61891ef83eb1a1 100644 --- a/packages/vite/src/node/utils.ts +++ b/packages/vite/src/node/utils.ts @@ -225,7 +225,7 @@ function testCaseInsensitiveFS() { return fs.existsSync(CLIENT_ENTRY.replace('client.mjs', 'cLiEnT.mjs')) } -export const isCaseInsensitiveFS: boolean = testCaseInsensitiveFS() +const isCaseInsensitiveFS: boolean = testCaseInsensitiveFS() const VOLUME_RE = /^[A-Z]:/i @@ -331,9 +331,6 @@ export const rawRE: RegExp = /(\?|&)raw(?:&|$)/ export function removeUrlQuery(url: string): string { return url.replace(urlRE, '$1').replace(trailingSeparatorRE, '') } -export function removeRawQuery(url: string): string { - return url.replace(rawRE, '$1').replace(trailingSeparatorRE, '') -} export function injectQuery(url: string, queryToInject: string): string { const { file, postfix } = splitFileAndPostfix(url) @@ -444,7 +441,7 @@ export function isFilePathESM( } } -export const splitRE: RegExp = /\r?\n/g +const splitRE: RegExp = /\r?\n/g const range: number = 2 @@ -784,7 +781,7 @@ const imageCandidateRegex = /(?:^|\s|(?<=,))(?[\w-]+\([^)]*\)|"[^"]*"|'[^']*'|[^,]\S*[^,])\s*(?:\s(?\w[^,]+))?(?:,|$)/g const escapedSpaceCharacters = /(?: |\\t|\\n|\\f|\\r)+/g -export function parseSrcset(string: string): ImageCandidate[] { +function parseSrcset(string: string): ImageCandidate[] { const matches = string .trim() .replace(escapedSpaceCharacters, ' ') @@ -1667,7 +1664,7 @@ export function stripBase(path: string, base: string): string { return path.startsWith(devBase) ? path.slice(devBase.length - 1) : path } -export function arrayEqual(a: any[], b: any[]): boolean { +function arrayEqual(a: any[], b: any[]): boolean { if (a === b) return true if (a.length !== b.length) return false for (let i = 0; i < a.length; i++) { diff --git a/packages/vite/src/shared/forwardConsole.ts b/packages/vite/src/shared/forwardConsole.ts index 6ee999d9c23c89..1ab25870e1f6da 100644 --- a/packages/vite/src/shared/forwardConsole.ts +++ b/packages/vite/src/shared/forwardConsole.ts @@ -4,7 +4,7 @@ import { SendBeforeConnectError, } from './moduleRunnerTransport' -export type ForwardConsoleLogLevel = +type ForwardConsoleLogLevel = | 'error' | 'warn' | 'info' diff --git a/packages/vite/src/shared/invokeMethods.ts b/packages/vite/src/shared/invokeMethods.ts index 57b1993060105f..49be39453fa2c8 100644 --- a/packages/vite/src/shared/invokeMethods.ts +++ b/packages/vite/src/shared/invokeMethods.ts @@ -8,7 +8,7 @@ export type FetchResult = | ExternalFetchResult | ViteFetchResult -export interface CachedFetchResult { +interface CachedFetchResult { /** * If the module is cached in the runner, this confirms * it was not invalidated on the server side. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cc92753b652051..be90f2a83b8ff8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -129,9 +129,6 @@ importers: '@shikijs/vitepress-twoslash': specifier: ^4.1.0 version: 4.1.0(ms@2.1.3)(typescript@6.0.3) - '@types/express': - specifier: ^5.0.6 - version: 5.0.6 '@voidzero-dev/vitepress-theme': specifier: ^4.8.4 version: 4.8.4(focus-trap@8.0.1)(vite@packages+vite)(vitepress@2.0.0-alpha.17)(vue@3.5.35) @@ -159,9 +156,6 @@ importers: vue: specifier: ^3.5.35 version: 3.5.35(typescript@6.0.3) - vue-tsc: - specifier: ^3.3.3 - version: 3.3.3(typescript@6.0.3) packages/create-vite: devDependencies: @@ -4004,15 +3998,9 @@ packages: '@types/babel__traverse@7.28.0': resolution: {integrity: sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==} - '@types/body-parser@1.19.6': - resolution: {integrity: sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==} - '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} - '@types/connect@3.4.38': - resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} - '@types/convert-source-map@2.0.3': resolution: {integrity: sha512-ag0BfJLZf6CQz8VIuRIEYQ5Ggwk/82uvTQf27RcpyDNbY0Vw49LIPqAxk5tqYfrCs9xDaIMvl4aj7ZopnYL8bA==} @@ -4034,18 +4022,9 @@ packages: '@types/etag@1.8.4': resolution: {integrity: sha512-f1z/UMth8gQ6636NBqhFmJ3zES7EuDcUnV6K1gl1osHp+85KPKX+VixYWUpqLkw1fftCagyHJjJOZjZkEi2rHw==} - '@types/express-serve-static-core@5.1.1': - resolution: {integrity: sha512-v4zIMr/cX7/d2BpAEX3KNKL/JrT1s43s96lLvvdTmza1oEvDudCqK9aF/djc/SWgy8Yh0h30TZx5VpzqFCxk5A==} - - '@types/express@5.0.6': - resolution: {integrity: sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==} - '@types/hast@3.0.4': resolution: {integrity: sha512-WPs+bbQw5aCj+x6laNGWLH3wviHtoCv/P3+otBhbOhJgG8qtpdAMlTCxLtsTWA7LH1Oh/bFCHsBn0TPS5m30EQ==} - '@types/http-errors@2.0.5': - resolution: {integrity: sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==} - '@types/jsesc@2.5.1': resolution: {integrity: sha512-9VN+6yxLOPLOav+7PwjZbxiID2bVaeq0ED4qSQmdQTdjnXJSaCVKTR58t15oqH1H5t8Ng2ZX1SabJVoN9Q34bw==} @@ -4088,12 +4067,6 @@ packages: '@types/pnpapi@0.0.5': resolution: {integrity: sha512-tjymquatF9seZGE3GcN1barqNqpmyEpqIN0rBKTcoZWwgDC0SgBp5LFqCRJE6YhzXA7TjpXbpTdcL5A8cwyryw==} - '@types/qs@6.14.0': - resolution: {integrity: sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ==} - - '@types/range-parser@1.2.7': - resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} - '@types/react-dom@19.2.3': resolution: {integrity: sha512-jp2L/eY6fn+KgVVQAOqYItbF0VY/YApe5Mz2F0aykSO8gx31bYCZyvSeYxCHKvzHG5eZjc+zyaS5BrBWya2+kQ==} peerDependencies: @@ -4102,12 +4075,6 @@ packages: '@types/react@19.2.15': resolution: {integrity: sha512-eRwcGNHve+E8qtEQSSRl6urh+rFop4v8gm6O8rGv25CodbvFdLjA1vVQ1KkiFE0w0UPOnb8tDiFKL5lp0rtY5Q==} - '@types/send@1.2.1': - resolution: {integrity: sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==} - - '@types/serve-static@2.2.0': - resolution: {integrity: sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==} - '@types/stylus@0.48.43': resolution: {integrity: sha512-72dv/zdhuyXWVHUXG2VTPEQdOG+oen95/DNFx2aMFFaY6LoITI6PwEqf5x31JF49kp2w9hvUzkNfTGBIeg61LQ==} @@ -4702,9 +4669,6 @@ packages: '@volar/source-map@2.4.28': resolution: {integrity: sha512-yX2BDBqJkRXfKw8my8VarTyjv48QwxdJtvRgUpNE5erCsgEUdI2DsLbpa+rOQVAJYshY99szEcRDmyHbF10ggQ==} - '@volar/typescript@2.4.28': - resolution: {integrity: sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw==} - '@vue/compiler-core@3.4.38': resolution: {integrity: sha512-8IQOTCWnLFqfHzOGm9+P8OPSEDukgg3Huc92qSG49if/xI2SAwLHQO2qaPQbjCWPBcQoO1WYfXfTACUrWV3c5A==} @@ -7947,9 +7911,6 @@ packages: resolution: {integrity: sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==} engines: {node: '>=0.10.0'} - vscode-uri@3.1.0: - resolution: {integrity: sha512-/BpdSx+yCQGnCvecbyXdxHDkuk55/G3xwnC0GqY4gmQ3j+A+g8kzzgB4Nk/SINjqn6+waqw3EgbVF2QKExkRxQ==} - vue-demi@0.14.10: resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} engines: {node: '>=12'} @@ -7966,12 +7927,6 @@ packages: peerDependencies: vue: ^3.0.0 - vue-tsc@3.3.3: - resolution: {integrity: sha512-SWUEG7YRUeDJHT7Xsuhf02elYX2gxPzzAII7OxDAh4KNOr4QHQ0Lls0YfnaO5GNd560CwVa2HTfdqmA5MqvRqQ==} - hasBin: true - peerDependencies: - typescript: '>=5.0.0' - vue-virtual-scroller@3.0.4: resolution: {integrity: sha512-3qh3c9VUVysuXynaa4fVZ3ncx3VgD7EPRiQcj+jUVZl5u/TTkD3c27XvSEu3JGJfsJt/vVTVziZ3djiiHtW4cQ==} peerDependencies: @@ -10014,20 +9969,11 @@ snapshots: dependencies: '@babel/types': 7.29.7 - '@types/body-parser@1.19.6': - dependencies: - '@types/connect': 3.4.38 - '@types/node': 24.12.4 - '@types/chai@5.2.3': dependencies: '@types/deep-eql': 4.0.2 assertion-error: 2.0.1 - '@types/connect@3.4.38': - dependencies: - '@types/node': 24.12.4 - '@types/convert-source-map@2.0.3': {} '@types/cross-spawn@6.0.6': @@ -10048,25 +9994,10 @@ snapshots: dependencies: '@types/node': 24.12.4 - '@types/express-serve-static-core@5.1.1': - dependencies: - '@types/node': 24.12.4 - '@types/qs': 6.14.0 - '@types/range-parser': 1.2.7 - '@types/send': 1.2.1 - - '@types/express@5.0.6': - dependencies: - '@types/body-parser': 1.19.6 - '@types/express-serve-static-core': 5.1.1 - '@types/serve-static': 2.2.0 - '@types/hast@3.0.4': dependencies: '@types/unist': 3.0.3 - '@types/http-errors@2.0.5': {} - '@types/jsesc@2.5.1': {} '@types/json-schema@7.0.15': {} @@ -10104,10 +10035,6 @@ snapshots: '@types/pnpapi@0.0.5': {} - '@types/qs@6.14.0': {} - - '@types/range-parser@1.2.7': {} - '@types/react-dom@19.2.3(@types/react@19.2.15)': dependencies: '@types/react': 19.2.15 @@ -10116,15 +10043,6 @@ snapshots: dependencies: csstype: 3.2.3 - '@types/send@1.2.1': - dependencies: - '@types/node': 24.12.4 - - '@types/serve-static@2.2.0': - dependencies: - '@types/http-errors': 2.0.5 - '@types/node': 24.12.4 - '@types/stylus@0.48.43': dependencies: '@types/node': 24.12.4 @@ -10773,12 +10691,6 @@ snapshots: '@volar/source-map@2.4.28': {} - '@volar/typescript@2.4.28': - dependencies: - '@volar/language-core': 2.4.28 - path-browserify: 1.0.1 - vscode-uri: 3.1.0 - '@vue/compiler-core@3.4.38': dependencies: '@babel/parser': 7.29.7 @@ -14306,8 +14218,6 @@ snapshots: void-elements@3.1.0: {} - vscode-uri@3.1.0: {} - vue-demi@0.14.10(vue@3.5.35): dependencies: vue: 3.5.35(typescript@6.0.3) @@ -14316,12 +14226,6 @@ snapshots: dependencies: vue: 3.5.35(typescript@6.0.3) - vue-tsc@3.3.3(typescript@6.0.3): - dependencies: - '@volar/typescript': 2.4.28 - '@vue/language-core': 3.3.3 - typescript: 6.0.3 - vue-virtual-scroller@3.0.4(vue@3.5.35): dependencies: vue: 3.5.35(typescript@6.0.3) From ab82cd455c701478266696bcdf9f133bb821c10e Mon Sep 17 00:00:00 2001 From: Ulrich Stark <8657779+ulrichstark@users.noreply.github.com> Date: Thu, 11 Jun 2026 21:24:34 +0200 Subject: [PATCH 2/3] fix linting issues --- packages/vite/src/node/plugins/css.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 950f77b501e186..c21d6999d184f9 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -2005,9 +2005,9 @@ type CssUrlReplacer = ( export const cssUrlRE: RegExp = /(? Date: Thu, 11 Jun 2026 21:32:39 +0200 Subject: [PATCH 3/3] Revert "fix linting issues" This reverts commit ab82cd455c701478266696bcdf9f133bb821c10e. --- packages/vite/src/node/plugins/css.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index c21d6999d184f9..950f77b501e186 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -2005,9 +2005,9 @@ type CssUrlReplacer = ( export const cssUrlRE: RegExp = /(?