Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: remove exporting internal APIs #14583

Merged
merged 7 commits into from
Oct 13, 2023
Merged
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
4 changes: 4 additions & 0 deletions docs/guide/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ Also there are other breaking changes which only affect few users.
- Top level `this` was rewritten to `globalThis` by default when building. This behavior is now removed.
- [[#14231] feat!: add extension to internal virtual modules](https://github.com/vitejs/vite/pull/14231)
- Internal virtual modules' id now has an extension (`.js`).
- [[#14583] refactor!: remove exporting internal APIs](https://github.com/vitejs/vite/pull/14583)
- Removed accidentally exported internal APIs: `isDepsOptimizerEnabled` and `getDepOptimizationConfig`
- Removed exported internal types: `DepOptimizationResult`, `DepOptimizationProcessing`, and `DepsOptimizer`
- Renamed `ResolveWorkerOptions` type to `ResolvedWorkerOptions`
- [[#5657] fix: return 404 for resources requests outside the base path](https://github.com/vitejs/vite/pull/5657)
- In the past, Vite responded to requests outside the base path without `Accept: text/html`, as if they were requested with the base path. Vite no longer does that and responds with 404 instead.

Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { ServerOptions } from './server'
import type { LogLevel } from './logger'
import { createLogger } from './logger'
import { VERSION } from './constants'
import { resolveConfig } from '.'
import { resolveConfig } from './config'

const cli = cac('vite')

Expand Down
16 changes: 3 additions & 13 deletions packages/vite/src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,6 @@ import { resolveSSROptions } from './ssr'
const debug = createDebugger('vite:config')
const promisifiedRealpath = promisify(fs.realpath)

export type {
RenderBuiltAssetUrl,
ModulePreloadOptions,
ResolvedModulePreloadOptions,
ResolveModulePreloadDependenciesFn,
} from './build'

// NOTE: every export in this file is re-exported from ./index.ts so it will
// be part of the public API.

export interface ConfigEnv {
command: 'build' | 'serve'
mode: string
Expand Down Expand Up @@ -327,7 +317,7 @@ export interface LegacyOptions {
*/
}

export interface ResolveWorkerOptions extends PluginHookUtils {
export interface ResolvedWorkerOptions extends PluginHookUtils {
format: 'es' | 'iife'
plugins: Plugin[]
rollupOptions: RollupOptions
Expand Down Expand Up @@ -377,7 +367,7 @@ export type ResolvedConfig = Readonly<
optimizeDeps: DepOptimizationOptions
/** @internal */
packageCache: PackageCache
worker: ResolveWorkerOptions
worker: ResolvedWorkerOptions
appType: AppType
experimental: ExperimentalOptions
} & PluginHookUtils
Expand Down Expand Up @@ -682,7 +672,7 @@ export async function resolveConfig(
...workerPostPlugins,
]
workerConfig = await runConfigHook(workerConfig, workerUserPlugins, configEnv)
const resolvedWorkerOptions: ResolveWorkerOptions = {
const resolvedWorkerOptions: ResolvedWorkerOptions = {
format: workerConfig.worker?.format || 'iife',
plugins: [],
rollupOptions: workerConfig.worker?.rollupOptions || {},
Expand Down
30 changes: 26 additions & 4 deletions packages/vite/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import type * as Rollup from 'rollup'

export type { Rollup }
export * from './config'
export {
defineConfig,
loadConfigFromFile,
resolveConfig,
sortUserPlugins,
} from './config'
export { createServer } from './server'
export { preview } from './preview'
export { build } from './build'
Expand All @@ -12,6 +17,23 @@ export { buildErrorMessage } from './server/middlewares/error'
export * from './publicUtils'

// additional types
export type {
AppType,
ConfigEnv,
ExperimentalOptions,
InlineConfig,
LegacyOptions,
PluginHookUtils,
PluginOption,
ResolveFn,
ResolvedWorkerOptions,
ResolvedConfig,
UserConfig,
UserConfigExport,
UserConfigFn,
UserConfigFnObject,
UserConfigFnPromise,
} from './config'
export type { FilterPattern } from './utils'
export type { CorsOptions, CorsOrigin, CommonServerOptions } from './http'
export type {
Expand All @@ -28,6 +50,9 @@ export type {
LibraryFormats,
RenderBuiltAssetUrl,
ResolvedBuildOptions,
ModulePreloadOptions,
ResolvedModulePreloadOptions,
ResolveModulePreloadDependenciesFn,
} from './build'
export type {
PreviewOptions,
Expand All @@ -39,10 +64,7 @@ export type {
DepOptimizationMetadata,
DepOptimizationOptions,
DepOptimizationConfig,
DepOptimizationResult,
DepOptimizationProcessing,
OptimizedDepInfo,
DepsOptimizer,
ExportsData,
} from './optimizer'
export type {
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/optimizer/esbuildDepPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import path from 'node:path'
import type { ImportKind, Plugin } from 'esbuild'
import { KNOWN_ASSET_TYPES } from '../constants'
import type { PackageCache } from '../packages'
import { getDepOptimizationConfig } from '..'
import type { ResolvedConfig } from '..'
import { getDepOptimizationConfig } from '../config'
import type { ResolvedConfig } from '../config'
import {
escapeRegex,
flattenId,
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { printServerUrls } from './logger'
import { bindCLIShortcuts } from './shortcuts'
import type { BindCLIShortcutsOptions } from './shortcuts'
import { DEFAULT_PREVIEW_PORT } from './constants'
import { resolveConfig } from '.'
import type { InlineConfig, ResolvedConfig } from '.'
import { resolveConfig } from './config'
import type { InlineConfig, ResolvedConfig } from './config'

export interface PreviewOptions extends CommonServerOptions {}

Expand Down