Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
640 changes: 0 additions & 640 deletions docs/.vitepress/theme/components/SponsorBanner.vue

This file was deleted.

4 changes: 1 addition & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"devDependencies": {
"@iconify/vue": "^5.0.1",
"@shikijs/vitepress-twoslash": "^4.2.0",
"@types/express": "^5.0.6",
"@voidzero-dev/vitepress-theme": "^4.8.4",
"feed": "^5.2.1",
"markdown-it-image-size": "^15.0.1",
Expand All @@ -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.4"
"vue": "^3.5.35"
}
}
85 changes: 85 additions & 0 deletions knip.json
Original file line number Diff line number Diff line change
@@ -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}"]
}
}
}
4 changes: 2 additions & 2 deletions packages/vite/src/module-runner/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -123,7 +123,7 @@ export interface ModuleRunnerOptions {
evaluatedModules?: EvaluatedModules
}

export interface ImportMetaEnv {
interface ImportMetaEnv {
[key: string]: any
BASE_URL: string
MODE: string
Expand Down
18 changes: 8 additions & 10 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function defineConfig(config: UserConfigExport): UserConfigExport {
return config
}

export interface CreateDevEnvironmentContext {
interface CreateDevEnvironmentContext {
ws: WebSocketServer
}

Expand Down Expand Up @@ -277,7 +277,7 @@ type AllResolveOptions = ResolveOptions & {

type ResolvedAllResolveOptions = Required<ResolveOptions> & { alias: Alias[] }

export interface SharedEnvironmentOptions {
interface SharedEnvironmentOptions {
/**
* Define global variable replacements.
* Entries will be defined on `window` during dev and replaced during build.
Expand Down Expand Up @@ -325,7 +325,7 @@ export interface EnvironmentOptions extends SharedEnvironmentOptions {
build?: BuildEnvironmentOptions
}

export type ResolvedResolveOptions = Required<ResolveOptions>
type ResolvedResolveOptions = Required<ResolveOptions>

export type ResolvedEnvironmentOptions = {
define?: Record<string, any>
Expand All @@ -341,7 +341,7 @@ export type ResolvedEnvironmentOptions = {
optimizeDepsPluginNames: string[]
}

export type DefaultEnvironmentOptions = Omit<
type DefaultEnvironmentOptions = Omit<
EnvironmentOptions,
'consumer' | 'resolve' | 'keepProcessEnv'
> & {
Expand Down Expand Up @@ -757,7 +757,7 @@ export interface ResolvedConfig extends Readonly<
} & PluginHookUtils
> {}

export async function resolveDevToolsConfig(
async function resolveDevToolsConfig(
config: DevToolsConfig | boolean | undefined,
host: string | boolean | undefined,
logger: Logger,
Expand Down Expand Up @@ -899,7 +899,7 @@ const configDefaults = Object.freeze({
appType: 'spa',
} satisfies UserConfig)

export function resolveDevEnvironmentOptions(
function resolveDevEnvironmentOptions(
dev: DevEnvironmentOptions | undefined,
environmentName: string | undefined,
consumer: 'client' | 'server' | undefined,
Expand Down Expand Up @@ -1013,9 +1013,7 @@ function resolveEnvironmentOptions(
}
}

export function getDefaultEnvironmentOptions(
config: UserConfig,
): EnvironmentOptions {
function getDefaultEnvironmentOptions(config: UserConfig): EnvironmentOptions {
return {
define: config.define,
resolve: {
Expand Down Expand Up @@ -2208,7 +2206,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,
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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<void> {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface PluginContextExtension {
environment: Environment
}

export interface PluginContextMetaExtension {
interface PluginContextMetaExtension {
viteVersion: string
}

Expand Down
8 changes: 4 additions & 4 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Environment, Map<string, string>>()

Expand All @@ -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)
Expand Down Expand Up @@ -330,7 +330,7 @@ export async function fileToUrl(
}
}

export async function fileToDevUrl(
async function fileToDevUrl(
environment: Environment,
id: string,
asFileUrl = false,
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2004,10 +2004,10 @@
// https://drafts.csswg.org/css-syntax-3/#identifier-code-point
export const cssUrlRE: RegExp =
/(?<!@import\s+)(?<=^|[^\w\-\u0080-\uffff])url\((\s*('[^']+'|"[^"]+")\s*|(?:\\.|[^'")\\])+)\)/
export const cssDataUriRE: RegExp =
const cssDataUriRE: RegExp =
/(?<=^|[^\w\-\u0080-\uffff])data-uri\((\s*('[^']+'|"[^"]+")\s*|[^'")]+)\)/

Check failure on line 2008 in packages/vite/src/node/plugins/css.ts

View workflow job for this annotation

GitHub Actions / Lint: node-24, ubuntu-latest

Capturing group number 2 is defined but never used

Check failure on line 2008 in packages/vite/src/node/plugins/css.ts

View workflow job for this annotation

GitHub Actions / Lint: node-24, ubuntu-latest

Capturing group number 1 is defined but never used
export const importCssRE: RegExp =
const importCssRE: RegExp =
/@import\s+(?:url\()?('[^']+\.css'|"[^"]+\.css"|[^'"\s)]+\.css)/

Check failure on line 2010 in packages/vite/src/node/plugins/css.ts

View workflow job for this annotation

GitHub Actions / Lint: node-24, ubuntu-latest

Capturing group number 1 is defined but never used
// Assuming a function name won't be longer than 256 chars
// eslint-disable-next-line regexp/no-unused-capturing-group -- doesn't detect asyncReplace usage
const cssImageSetRE = /(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/
Expand Down Expand Up @@ -2402,7 +2402,7 @@
close: () => void | Promise<void>
}

export interface StylePreprocessorResults {
interface StylePreprocessorResults {
code: string
map?: ExistingRawSourceMap | undefined
additionalMap?: ExistingRawSourceMap | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/dynamicImportVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
67 changes: 2 additions & 65 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import type { FSWatcher } from '#dep-types/chokidar'
import {
combineSourcemaps,
createDebugger,
createFilter,
ensureWatchedFile,
generateCodeFrame,
} from '../utils'
Expand All @@ -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,
}
Expand Down Expand Up @@ -74,7 +72,7 @@ type TSConfigJSON = {
}
[key: string]: any
}
export type TSCompilerOptions = NonNullable<TSConfigJSON['compilerOptions']>
type TSCompilerOptions = NonNullable<TSConfigJSON['compilerOptions']>

let esbuild: Promise<typeof import('esbuild')> | undefined
const importEsbuild = () => {
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading