diff --git a/docs/config/index.md b/docs/config/index.md index bab7df7a144987..7b8db252d50450 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -1018,7 +1018,6 @@ export default defineConfig({ - `external` is also omitted, use Vite's `optimizeDeps.exclude` option - `plugins` are merged with Vite's dep plugin - - `keepNames` takes precedence over the deprecated `optimizeDeps.keepNames` ## SSR Options diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index cefab59d94fe53..4ca3e0d371f6c9 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -38,15 +38,10 @@ export interface Options { * @default true */ jsxPure?: boolean - /** * Babel configuration applied in both dev and prod. */ babel?: BabelOptions - /** - * @deprecated Use `babel.parserOpts.plugins` instead - */ - parserPlugins?: ParserOptions['plugins'] } export type BabelOptions = Omit< @@ -104,7 +99,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] { babelOptions.presets ||= [] babelOptions.overrides ||= [] babelOptions.parserOpts ||= {} as any - babelOptions.parserOpts.plugins ||= opts.parserPlugins || [] + babelOptions.parserOpts.plugins ||= [] // Support patterns like: // - import * as React from 'react'; diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 420d084ef9a981..06d46a000780f7 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -432,13 +432,6 @@ export function createHotContext(ownerPath: string): ViteHotContext { } }, - acceptDeps() { - throw new Error( - `hot.acceptDeps() is deprecated. ` + - `Use hot.accept() with the same signature instead.` - ) - }, - dispose(cb) { disposeMap.set(ownerPath, cb) }, diff --git a/packages/vite/src/node/__tests__/config.spec.ts b/packages/vite/src/node/__tests__/config.spec.ts index dd427c19433475..19f8115a1d7102 100644 --- a/packages/vite/src/node/__tests__/config.spec.ts +++ b/packages/vite/src/node/__tests__/config.spec.ts @@ -159,52 +159,6 @@ describe('mergeConfig', () => { }) }) -describe('resolveConfig', () => { - beforeAll(() => { - // silence deprecation warning - jest.spyOn(console, 'warn').mockImplementation(() => {}) - }) - - afterAll(() => { - jest.clearAllMocks() - }) - - test('copies optimizeDeps.keepNames to esbuildOptions.keepNames', async () => { - const config: InlineConfig = { - optimizeDeps: { - keepNames: false - } - } - - expect(await resolveConfig(config, 'serve')).toMatchObject({ - optimizeDeps: { - esbuildOptions: { - keepNames: false - } - } - }) - }) - - test('uses esbuildOptions.keepNames if set', async () => { - const config: InlineConfig = { - optimizeDeps: { - keepNames: true, - esbuildOptions: { - keepNames: false - } - } - } - - expect(await resolveConfig(config, 'serve')).toMatchObject({ - optimizeDeps: { - esbuildOptions: { - keepNames: false - } - } - }) - }) -}) - describe('resolveEnvPrefix', () => { test(`use 'VITE_' as default value`, () => { const config: UserConfig = {} diff --git a/packages/vite/src/node/build.ts b/packages/vite/src/node/build.ts index ff03352a20d7a7..f584f007f2df5e 100644 --- a/packages/vite/src/node/build.ts +++ b/packages/vite/src/node/build.ts @@ -42,11 +42,6 @@ import { watchPackageDataPlugin } from './packages' import { ensureWatchPlugin } from './plugins/ensureWatch' export interface BuildOptions { - /** - * Base public path when served in production. - * @deprecated `base` is now a root-level config option. - */ - base?: string /** * Compatibility transform target. The transform is performed with esbuild * and the lowest supported target is es2015/es6. Note this only handles @@ -70,13 +65,6 @@ export interface BuildOptions { * @default true */ polyfillModulePreload?: boolean - /** - * whether to inject dynamic import polyfill. - * Note: does not apply to library mode. - * @default false - * @deprecated use plugin-legacy for browsers that don't support dynamic import - */ - polyfillDynamicImport?: boolean /** * Directory relative from `root` where build output will be placed. If the * directory exists, it will be removed before the build. @@ -130,10 +118,6 @@ export interface BuildOptions { * https://terser.org/docs/api-reference#minify-options */ terserOptions?: Terser.MinifyOptions - /** - * @deprecated Vite now uses esbuild for CSS minification. - */ - cleanCssOptions?: any /** * Will be merged with internal rollup options. * https://rollupjs.org/guide/en/#big-list-of-options @@ -198,12 +182,6 @@ export interface BuildOptions { * Can slightly improve build speed. */ reportCompressedSize?: boolean - /** - * Set to false to disable brotli compressed size reporting for build. - * Can slightly improve build speed. - * @deprecated use `build.reportCompressedSize` instead. - */ - brotliSize?: boolean /** * Adjust chunk size warning limit (in kbs). * @default 500 @@ -225,13 +203,7 @@ export interface LibraryOptions { export type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife' -export type ResolvedBuildOptions = Required< - Omit< - BuildOptions, - // make deprecated options optional - 'base' | 'cleanCssOptions' | 'polyfillDynamicImport' | 'brotliSize' - > -> +export type ResolvedBuildOptions = Required export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions { const resolved: ResolvedBuildOptions = { @@ -253,7 +225,6 @@ export function resolveBuildOptions(raw?: BuildOptions): ResolvedBuildOptions { ssr: false, ssrManifest: false, reportCompressedSize: true, - // brotliSize: true, chunkSizeWarningLimit: 500, watch: null, ...raw, @@ -451,15 +422,6 @@ async function doBuild( try { const buildOutputOptions = (output: OutputOptions = {}): OutputOptions => { - // @ts-ignore - if (output.output) { - config.logger.warn( - `You've set "rollupOptions.output.output" in your config. ` + - `This is deprecated and will override all Vite.js default output options. ` + - `Please use "rollupOptions.output" instead.` - ) - } - return { dir: outDir, format: ssr ? 'cjs' : 'es', diff --git a/packages/vite/src/node/config.ts b/packages/vite/src/node/config.ts index d242ac632c220e..b0085c9766c467 100644 --- a/packages/vite/src/node/config.ts +++ b/packages/vite/src/node/config.ts @@ -176,17 +176,6 @@ export interface UserConfig { * @default 'VITE_' */ envPrefix?: string | string[] - /** - * Import aliases - * @deprecated use `resolve.alias` instead - */ - alias?: AliasOptions - /** - * Force Vite to always resolve listed dependencies to the same copy (from - * project root). - * @deprecated use `resolve.dedupe` instead - */ - dedupe?: string[] /** * Worker bundle options */ @@ -235,10 +224,7 @@ export interface InlineConfig extends UserConfig { } export type ResolvedConfig = Readonly< - Omit< - UserConfig, - 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps' | 'worker' - > & { + Omit & { configFile: string | undefined configFileDependencies: string[] inlineConfig: InlineConfig @@ -261,7 +247,7 @@ export type ResolvedConfig = Readonly< assetsInclude: (file: string) => boolean logger: Logger createResolver: (options?: Partial) => ResolveFn - optimizeDeps: Omit + optimizeDeps: DepOptimizationOptions /** @internal */ packageCache: PackageCache worker: ResolveWorkerOptions @@ -370,12 +356,11 @@ export async function resolveConfig( // @ts-ignore because @rollup/plugin-alias' type doesn't allow function // replacement, but its implementation does work with function values. clientAlias, - config.resolve?.alias || config.alias || [] + config.resolve?.alias || [] ) ) const resolveOptions: ResolvedConfig['resolve'] = { - dedupe: config.dedupe, ...config.resolve, alias: resolvedAlias } @@ -501,7 +486,6 @@ export async function resolveConfig( optimizeDeps: { ...optimizeDeps, esbuildOptions: { - keepNames: optimizeDeps.keepNames, preserveSymlinks: config.resolve?.preserveSymlinks, ...optimizeDeps.esbuildOptions } @@ -540,117 +524,6 @@ export async function resolveConfig( }) } - // TODO Deprecation warnings - remove when out of beta - - const logDeprecationWarning = ( - deprecatedOption: string, - hint: string, - error?: Error - ) => { - logger.warn( - colors.yellow( - colors.bold( - `(!) "${deprecatedOption}" option is deprecated. ${hint}${ - error ? `\n${error.stack}` : '' - }` - ) - ) - ) - } - - if (config.build?.base) { - logDeprecationWarning( - 'build.base', - '"base" is now a root-level config option.' - ) - config.base = config.build.base - } - Object.defineProperty(resolvedBuildOptions, 'base', { - enumerable: false, - get() { - logDeprecationWarning( - 'build.base', - '"base" is now a root-level config option.', - new Error() - ) - return resolved.base - } - }) - - if (config.alias) { - logDeprecationWarning('alias', 'Use "resolve.alias" instead.') - } - Object.defineProperty(resolved, 'alias', { - enumerable: false, - get() { - logDeprecationWarning( - 'alias', - 'Use "resolve.alias" instead.', - new Error() - ) - return resolved.resolve.alias - } - }) - - if (config.dedupe) { - logDeprecationWarning('dedupe', 'Use "resolve.dedupe" instead.') - } - Object.defineProperty(resolved, 'dedupe', { - enumerable: false, - get() { - logDeprecationWarning( - 'dedupe', - 'Use "resolve.dedupe" instead.', - new Error() - ) - return resolved.resolve.dedupe - } - }) - - if (optimizeDeps.keepNames) { - logDeprecationWarning( - 'optimizeDeps.keepNames', - 'Use "optimizeDeps.esbuildOptions.keepNames" instead.' - ) - } - Object.defineProperty(resolved.optimizeDeps, 'keepNames', { - enumerable: false, - get() { - logDeprecationWarning( - 'optimizeDeps.keepNames', - 'Use "optimizeDeps.esbuildOptions.keepNames" instead.', - new Error() - ) - return resolved.optimizeDeps.esbuildOptions?.keepNames - } - }) - - if (config.build?.polyfillDynamicImport) { - logDeprecationWarning( - 'build.polyfillDynamicImport', - '"polyfillDynamicImport" has been removed. Please use @vitejs/plugin-legacy if your target browsers do not support dynamic imports.' - ) - } - - Object.defineProperty(resolvedBuildOptions, 'polyfillDynamicImport', { - enumerable: false, - get() { - logDeprecationWarning( - 'build.polyfillDynamicImport', - '"polyfillDynamicImport" has been removed. Please use @vitejs/plugin-legacy if your target browsers do not support dynamic imports.', - new Error() - ) - return false - } - }) - - if (config.build?.cleanCssOptions) { - logDeprecationWarning( - 'build.cleanCssOptions', - 'Vite now uses esbuild for CSS minification.' - ) - } - if (config.build?.terserOptions && config.build.minify !== 'terser') { logger.warn( colors.yellow( diff --git a/packages/vite/src/node/importGlob.ts b/packages/vite/src/node/importGlob.ts index a759bee2b5fa59..ab425bb596c68a 100644 --- a/packages/vite/src/node/importGlob.ts +++ b/packages/vite/src/node/importGlob.ts @@ -17,7 +17,6 @@ import { } from './utils' import type { RollupError } from 'rollup' import type { Logger } from '.' -import colors from 'picocolors' interface GlobParams { base: string @@ -28,12 +27,6 @@ interface GlobParams { interface GlobOptions { as?: string - /** - * @deprecated - */ - assert?: { - type: string - } } function formatGlobRelativePattern(base: string, pattern: string): GlobParams { @@ -133,19 +126,9 @@ export async function transformImportGlob( ;[importee] = await normalizeUrl(file, pos) } imports.push(importee) - // TODO remove assert syntax for the Vite 3.0 release. - const isRawAssert = options?.assert?.type === 'raw' + const isRawType = options?.as === 'raw' - if (isRawType || isRawAssert) { - if (isRawAssert) { - logger.warn( - colors.yellow( - colors.bold( - "(!) import.meta.glob('...', { assert: { type: 'raw' }}) is deprecated. Use import.meta.glob('...', { as: 'raw' }) instead." - ) - ) - ) - } + if (isRawType) { entries += ` ${JSON.stringify(file)}: ${JSON.stringify( await fsp.readFile(path.join(base, files[i]), 'utf-8') )},` diff --git a/packages/vite/src/node/index.ts b/packages/vite/src/node/index.ts index 2e849d846527ca..c15359f45b69de 100644 --- a/packages/vite/src/node/index.ts +++ b/packages/vite/src/node/index.ts @@ -4,7 +4,7 @@ export { preview } from './preview' export { build } from './build' export { optimizeDeps } from './optimizer' export { send } from './server/send' -export { createLogger, printHttpServerUrls } from './logger' +export { createLogger } from './logger' export { formatPostcssSourceMap } from './plugins/css' export { transformWithEsbuild } from './plugins/esbuild' export { resolvePackageEntry } from './plugins/resolve' diff --git a/packages/vite/src/node/logger.ts b/packages/vite/src/node/logger.ts index 8ece2dd8746b7f..4f5784aeb527ff 100644 --- a/packages/vite/src/node/logger.ts +++ b/packages/vite/src/node/logger.ts @@ -144,16 +144,6 @@ export function createLogger( return logger } -/** - * @deprecated Use `server.printUrls()` instead - */ -export function printHttpServerUrls( - server: Server, - config: ResolvedConfig -): void { - printCommonServerUrls(server, config.server, config) -} - export function printCommonServerUrls( server: Server, options: CommonServerOptions, diff --git a/packages/vite/src/node/optimizer/index.ts b/packages/vite/src/node/optimizer/index.ts index 3828cb2fbce18b..5745749db3fb6a 100644 --- a/packages/vite/src/node/optimizer/index.ts +++ b/packages/vite/src/node/optimizer/index.ts @@ -70,7 +70,6 @@ export interface DepOptimizationOptions { * * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option * - `plugins` are merged with Vite's dep plugin - * - `keepNames` takes precedence over the deprecated `optimizeDeps.keepNames` * * https://esbuild.github.io/api */ @@ -87,10 +86,6 @@ export interface DepOptimizationOptions { | 'outExtension' | 'metafile' > - /** - * @deprecated use `esbuildOptions.keepNames` - */ - keepNames?: boolean /** * List of file extensions that can be optimized. A corresponding esbuild * plugin must exist to handle the specific extension. diff --git a/packages/vite/src/node/plugins/reporter.ts b/packages/vite/src/node/plugins/reporter.ts index 08650a86e2c38c..808e8040cba9f7 100644 --- a/packages/vite/src/node/plugins/reporter.ts +++ b/packages/vite/src/node/plugins/reporter.ts @@ -33,11 +33,7 @@ export function buildReporterPlugin(config: ResolvedConfig): Plugin { } async function getCompressedSize(code: string | Uint8Array): Promise { - if ( - config.build.ssr || - !config.build.reportCompressedSize || - config.build.brotliSize === false - ) { + if (config.build.ssr || !config.build.reportCompressedSize) { return '' } return ` / gzip: ${( diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index 99aefea6de292a..67214b4a6119b7 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -41,9 +41,6 @@ import { openBrowser } from './openBrowser' import launchEditorMiddleware from 'launch-editor-middleware' import type { TransformOptions, TransformResult } from './transformRequest' import { transformRequest } from './transformRequest' -import type { ESBuildTransformResult } from '../plugins/esbuild' -import { transformWithEsbuild } from '../plugins/esbuild' -import type { TransformOptions as EsbuildTransformOptions } from 'esbuild' import { ssrLoadModule } from '../ssr/ssrModuleLoader' import { resolveSSRExternal } from '../ssr/ssrExternal' import { @@ -156,10 +153,6 @@ export interface ViteDevServer { * https://github.com/senchalabs/connect#use-middleware */ middlewares: Connect.Server - /** - * @deprecated use `server.middlewares` instead - */ - app: Connect.Server /** * native Node http server instance * will be null in middleware mode @@ -199,18 +192,6 @@ export interface ViteDevServer { html: string, originalUrl?: string ): Promise - /** - * Util for transforming a file with esbuild. - * Can be useful for certain plugins. - * - * @deprecated import `transformWithEsbuild` from `vite` instead - */ - transformWithEsbuild( - code: string, - filename: string, - options?: EsbuildTransformOptions, - inMap?: object - ): Promise /** * Transform module code into SSR format. * @experimental @@ -342,19 +323,12 @@ export async function createServer( const server: ViteDevServer = { config, middlewares, - get app() { - config.logger.warn( - `ViteDevServer.app is deprecated. Use ViteDevServer.middlewares instead.` - ) - return middlewares - }, httpServer, watcher, pluginContainer: container, ws, moduleGraph, ssrTransform, - transformWithEsbuild, transformRequest(url, options) { return transformRequest(url, server, options) }, diff --git a/packages/vite/types/hot.d.ts b/packages/vite/types/hot.d.ts index f06846ff59d530..daaf44e1efdc74 100644 --- a/packages/vite/types/hot.d.ts +++ b/packages/vite/types/hot.d.ts @@ -7,12 +7,6 @@ export interface ViteHotContext { accept(cb: (mod: any) => void): void accept(dep: string, cb: (mod: any) => void): void accept(deps: readonly string[], cb: (mods: any[]) => void): void - - /** - * @deprecated - */ - acceptDeps(): never - dispose(cb: (data: any) => void): void decline(): void invalidate(): void diff --git a/packages/vite/types/importMeta.d.ts b/packages/vite/types/importMeta.d.ts index 900b975d37d6ad..06dcb52b9ad954 100644 --- a/packages/vite/types/importMeta.d.ts +++ b/packages/vite/types/importMeta.d.ts @@ -9,12 +9,6 @@ // in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist. interface GlobOptions { as?: string - /** - * @deprecated - */ - assert?: { - type: string - } } interface ImportMeta { diff --git a/packages/vite/types/terser.d.ts b/packages/vite/types/terser.d.ts index 44c7398d508259..5c24660eb98781 100644 --- a/packages/vite/types/terser.d.ts +++ b/packages/vite/types/terser.d.ts @@ -185,8 +185,6 @@ export namespace Terser { module?: boolean nameCache?: object format?: FormatOptions - /** @deprecated use format instead */ - output?: FormatOptions parse?: ParseOptions safari10?: boolean sourceMap?: boolean | SourceMapOptions