mirror of
https://github.com/vitejs/vite.git
synced 2024-11-21 14:48:41 +00:00
refactor: rename runner.destroy() to runner.close() (#18304)
This commit is contained in:
parent
41735a72a3
commit
cd368f9fed
@ -645,11 +645,11 @@ export class ModuleRunner {
|
||||
* Clears all caches, removes all HMR listeners, and resets source map support.
|
||||
* This method doesn't stop the HMR connection.
|
||||
*/
|
||||
public async destroy(): Promise<void>
|
||||
public async close(): Promise<void>
|
||||
/**
|
||||
* Returns `true` if the runner has been destroyed by calling `destroy()` method.
|
||||
* Returns `true` if the runner has been closed by calling `close()` method.
|
||||
*/
|
||||
public isDestroyed(): boolean
|
||||
public isClosed(): boolean
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -15,7 +15,7 @@ export async function handleHotPayload(
|
||||
payload: HotPayload,
|
||||
): Promise<void> {
|
||||
const hmrClient = runner.hmrClient
|
||||
if (!hmrClient || runner.isDestroyed()) return
|
||||
if (!hmrClient || runner.isClosed()) return
|
||||
switch (payload.type) {
|
||||
case 'connected':
|
||||
hmrClient.logger.debug(`connected.`)
|
||||
|
@ -54,7 +54,7 @@ export class ModuleRunner {
|
||||
Promise<EvaluatedModuleNode>
|
||||
>()
|
||||
|
||||
private destroyed = false
|
||||
private closed = false
|
||||
|
||||
constructor(
|
||||
public options: ModuleRunnerOptions,
|
||||
@ -100,18 +100,18 @@ export class ModuleRunner {
|
||||
* Clears all caches, removes all HMR listeners, and resets source map support.
|
||||
* This method doesn't stop the HMR connection.
|
||||
*/
|
||||
public async destroy(): Promise<void> {
|
||||
public async close(): Promise<void> {
|
||||
this.resetSourceMapSupport?.()
|
||||
this.clearCache()
|
||||
this.hmrClient = undefined
|
||||
this.destroyed = true
|
||||
this.closed = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the runtime has been destroyed by calling `destroy()` method.
|
||||
* Returns `true` if the runtime has been closed by calling `close()` method.
|
||||
*/
|
||||
public isDestroyed(): boolean {
|
||||
return this.destroyed
|
||||
public isClosed(): boolean {
|
||||
return this.closed
|
||||
}
|
||||
|
||||
private processImport(
|
||||
@ -243,8 +243,8 @@ export class ModuleRunner {
|
||||
importer: string | undefined,
|
||||
cachedModule: EvaluatedModuleNode | undefined,
|
||||
): Promise<EvaluatedModuleNode> {
|
||||
if (this.destroyed) {
|
||||
throw new Error(`Vite module runner has been destroyed.`)
|
||||
if (this.closed) {
|
||||
throw new Error(`Vite module runner has been closed.`)
|
||||
}
|
||||
|
||||
this.debug?.('[module runner] fetching', url)
|
||||
@ -373,7 +373,7 @@ export class ModuleRunner {
|
||||
enumerable: true,
|
||||
get: () => {
|
||||
if (!this.hmrClient) {
|
||||
throw new Error(`[module runner] HMR client was destroyed.`)
|
||||
throw new Error(`[module runner] HMR client was closed.`)
|
||||
}
|
||||
this.debug?.('[module runner] creating hmr context for', mod.url)
|
||||
hotContext ||= new HMRContext(this.hmrClient, mod.url)
|
||||
|
@ -68,7 +68,7 @@ class RunnableDevEnvironment extends DevEnvironment {
|
||||
override async close(): Promise<void> {
|
||||
await super.close()
|
||||
if (this._runner) {
|
||||
await this._runner.destroy()
|
||||
await this._runner.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ export async function createModuleRunnerTester(
|
||||
})
|
||||
|
||||
afterEach<TestClient>(async (t) => {
|
||||
await t.runner.destroy()
|
||||
await t.runner.close()
|
||||
await t.server.close()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user