diff --git a/packages/vite/src/node/plugin.ts b/packages/vite/src/node/plugin.ts index 053878a826f036..69b19415b0daa7 100644 --- a/packages/vite/src/node/plugin.ts +++ b/packages/vite/src/node/plugin.ts @@ -37,8 +37,7 @@ import type { ConfigEnv, ResolvedConfig } from './' * If a plugin should be applied only for server or build, a function format * config file can be used to conditional determine the plugins to use. */ -export interface Plugin - extends Omit { +export interface Plugin extends RollupPlugin { /** * Enforce plugin invocation tier similar to webpack loaders. * @@ -129,7 +128,7 @@ export interface Plugin /** * extend hooks with ssr flag */ - resolveId?( + resolveId?: ( this: PluginContext, source: string, importer: string | undefined, @@ -140,17 +139,18 @@ export interface Plugin * @internal */ scan?: boolean + isEntry: boolean } - ): Promise | ResolveIdResult - load?( + ) => Promise | ResolveIdResult + load?: ( this: PluginContext, id: string, options?: { ssr?: boolean } - ): Promise | LoadResult - transform?( + ) => Promise | LoadResult + transform?: ( this: TransformPluginContext, code: string, id: string, options?: { ssr?: boolean } - ): Promise | TransformResult + ) => Promise | TransformResult } diff --git a/packages/vite/src/node/server/pluginContainer.ts b/packages/vite/src/node/server/pluginContainer.ts index 86dcefe024542f..0a708ed62c4e6c 100644 --- a/packages/vite/src/node/server/pluginContainer.ts +++ b/packages/vite/src/node/server/pluginContainer.ts @@ -97,6 +97,7 @@ export interface PluginContainer { * @internal */ scan?: boolean + isEntry?: boolean } ): Promise transform( @@ -527,6 +528,7 @@ export async function createPluginContainer( const skip = options?.skip const ssr = options?.ssr const scan = !!options?.scan + const isEntry = !!options?.isEntry const ctx = new Context() ctx.ssr = !!ssr ctx._scan = scan @@ -546,7 +548,7 @@ export async function createPluginContainer( ctx as any, rawId, importer, - { ssr, scan } + { ssr, scan, isEntry } ) if (!result) continue