Skip to content

Commit

Permalink
revert: remove AsyncDisposable (#14908)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Nov 8, 2023
1 parent 8b96e97 commit b953b0d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 24 deletions.
3 changes: 0 additions & 3 deletions packages/vite/src/node/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,3 @@ export const wildcardHosts = new Set([
export const DEFAULT_DEV_PORT = 5173

export const DEFAULT_PREVIEW_PORT = 4173

export const ASYNC_DISPOSE: typeof Symbol.asyncDispose =
Symbol.asyncDispose || Symbol.for('Symbol.asyncDispose')
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export type ExportsData = {
jsxLoader?: boolean
}

export interface DepsOptimizer extends AsyncDisposable {
export interface DepsOptimizer {
metadata: DepOptimizationMetadata
scanProcessing?: Promise<void>
registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo
Expand Down
5 changes: 0 additions & 5 deletions packages/vite/src/node/optimizer/optimizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import colors from 'picocolors'
import { createDebugger, getHash } from '../utils'
import { getDepOptimizationConfig } from '../config'
import type { ResolvedConfig, ViteDevServer } from '..'
import { ASYNC_DISPOSE } from '../constants'
import {
addManuallyIncludedOptimizeDeps,
addOptimizedDepInfo,
Expand Down Expand Up @@ -120,9 +119,6 @@ async function createDepsOptimizer(
resetRegisteredIds,
ensureFirstRun,
close,
[ASYNC_DISPOSE]() {
return this.close()
},
options: getDepOptimizationConfig(config, ssr),
}

Expand Down Expand Up @@ -836,7 +832,6 @@ async function createDevSsrDepsOptimizer(
ensureFirstRun: () => {},

close: async () => {},
[ASYNC_DISPOSE]: async () => {},
options: config.ssr.optimizeDeps,
}
devSsrDepsOptimizerMap.set(config, depsOptimizer)
Expand Down
7 changes: 2 additions & 5 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import type { SourceMap } from 'rollup'
import picomatch from 'picomatch'
import type { Matcher } from 'picomatch'
import type { InvalidatePayload } from 'types/customEvent'
import { ASYNC_DISPOSE, CLIENT_DIR, DEFAULT_DEV_PORT } from '../constants'
import type { CommonServerOptions } from '../http'
import {
httpServerStart,
Expand Down Expand Up @@ -45,6 +44,7 @@ import {
} from '../optimizer'
import { bindCLIShortcuts } from '../shortcuts'
import type { BindCLIShortcutsOptions } from '../shortcuts'
import { CLIENT_DIR, DEFAULT_DEV_PORT } from '../constants'
import type { Logger } from '../logger'
import { printServerUrls } from '../logger'
import { createNoopWatcher, resolveChokidarOptions } from '../watch'
Expand Down Expand Up @@ -185,7 +185,7 @@ export type ServerHook = (

export type HttpServer = http.Server | Http2SecureServer

export interface ViteDevServer extends AsyncDisposable {
export interface ViteDevServer {
/**
* The resolved vite config object
*/
Expand Down Expand Up @@ -554,9 +554,6 @@ export async function _createServer(
}
server.resolvedUrls = null
},
[ASYNC_DISPOSE]() {
return this.close()
},
printUrls() {
if (server.resolvedUrls) {
printServerUrls(
Expand Down
7 changes: 2 additions & 5 deletions packages/vite/src/node/server/pluginContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ import type { FSWatcher } from 'chokidar'
import colors from 'picocolors'
import type * as postcss from 'postcss'
import type { Plugin } from '../plugin'
import { ASYNC_DISPOSE, FS_PREFIX } from '../constants'
import {
cleanUrl,
combineSourcemaps,
Expand All @@ -79,6 +78,7 @@ import {
timeFrom,
unwrapId,
} from '../utils'
import { FS_PREFIX } from '../constants'
import type { ResolvedConfig } from '../config'
import { createPluginHookUtils, getHookHandler } from '../plugins'
import { buildErrorMessage } from './middlewares/error'
Expand All @@ -105,7 +105,7 @@ export interface PluginContainerOptions {
writeFile?: (name: string, source: string | Uint8Array) => void
}

export interface PluginContainer extends AsyncDisposable {
export interface PluginContainer {
options: InputOptions
getModuleInfo(id: string): ModuleInfo | null
buildStart(options: InputOptions): Promise<void>
Expand Down Expand Up @@ -799,9 +799,6 @@ export async function createPluginContainer(
() => [],
)
},
[ASYNC_DISPOSE]() {
return this.close()
},
}

return container
Expand Down
6 changes: 1 addition & 5 deletions packages/vite/src/node/server/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { WebSocketServer as WebSocketServerRaw_ } from 'ws'
import type { WebSocket as WebSocketTypes } from 'dep-types/ws'
import type { CustomPayload, ErrorPayload, HMRPayload } from 'types/hmrPayload'
import type { InferCustomEventPayload } from 'types/customEvent'
import { ASYNC_DISPOSE } from '../constants'
import type { ResolvedConfig } from '..'
import { isObject } from '../utils'
import type { HttpServer } from '.'
Expand All @@ -31,7 +30,7 @@ export type WebSocketCustomListener<T> = (
client: WebSocketClient,
) => void

export interface WebSocketServer extends AsyncDisposable {
export interface WebSocketServer {
/**
* Listen on port and host
*/
Expand Down Expand Up @@ -310,8 +309,5 @@ export function createWebSocketServer(
})
})
},
[ASYNC_DISPOSE]() {
return this.close()
},
}
}

0 comments on commit b953b0d

Please sign in to comment.