File tree Expand file tree Collapse file tree 4 files changed +27
-1
lines changed
packages/unplugin-dts/src Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -530,6 +530,13 @@ export interface PluginOptions {
530530 */
531531 declarationOnly? : boolean ,
532532
533+ /**
534+ * Hook called after the runtime is created.
535+ *
536+ * @default () => {}
537+ */
538+ afterBootstrap? : (runtime : Runtime ) => MaybePromise <void >,
539+
533540 /**
534541 * Hook called after diagnostic is emitted.
535542 *
Original file line number Diff line number Diff line change @@ -547,6 +547,13 @@ export interface PluginOptions {
547547 */
548548 declarationOnly? : boolean ,
549549
550+ /**
551+ * 运行时创建完毕后的钩子
552+ *
553+ * @default () => {}
554+ */
555+ afterBootstrap? : (runtime : Runtime ) => MaybePromise <void >,
556+
550557 /**
551558 * 获取诊断信息后的钩子
552559 *
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ export const pluginFactory: UnpluginFactory<PluginOptions | undefined> = /* #__P
4040 copyDtsFiles = meta . framework !== 'vite' ,
4141 declarationOnly = false ,
4242 strictOutput = true ,
43+ afterBootstrap,
4344 afterDiagnostic,
4445 beforeWriteFile,
4546 afterRollup,
@@ -214,6 +215,10 @@ export const pluginFactory: UnpluginFactory<PluginOptions | undefined> = /* #__P
214215 }
215216 }
216217
218+ if ( typeof afterBootstrap === 'function' ) {
219+ await unwrapPromise ( afterBootstrap ( runtime ) )
220+ }
221+
217222 handleDebug ( 'create ts program' )
218223 timeRecord += Date . now ( ) - startTime
219224 } ,
Original file line number Diff line number Diff line change @@ -6,9 +6,10 @@ import type {
66 MaybePromise ,
77 Resolver ,
88 RollupConfig ,
9+ Runtime ,
910} from './core'
1011
11- export type { Resolver , RollupConfig }
12+ export type { Resolver , RollupConfig , Runtime }
1213
1314export interface PluginOptions
1415 extends Omit <
@@ -24,6 +25,12 @@ export interface PluginOptions
2425 * @default false
2526 */
2627 declarationOnly ?: boolean ,
28+ /**
29+ * Hook called after the runtime is created.
30+ *
31+ * @default () => {}
32+ */
33+ afterBootstrap ?: ( runtime : Runtime ) => MaybePromise < void > ,
2734 /**
2835 * Hook called after diagnostic is emitted.
2936 *
You can’t perform that action at this time.
0 commit comments