diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index a0ef1e93..07f5f7d4 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -61,7 +61,7 @@ export interface UserConfig { /** 是否使用import()加载组件 */ dynamicImport?: boolean; hooks?: { - beforeWriteEntry?: (genContentMap: Record, app: Core) => void; + beforeWriteEntry?: (genContentMap: Record, app: Core) => Promise>; }; onInit?: (app: Core) => ModuleMainFilePath | Promise; onPrepare?: (app: Core) => void; diff --git a/packages/cli/src/utils/prepareEntryFile.ts b/packages/cli/src/utils/prepareEntryFile.ts index e8793c7d..bd58a455 100644 --- a/packages/cli/src/utils/prepareEntryFile.ts +++ b/packages/cli/src/utils/prepareEntryFile.ts @@ -6,7 +6,7 @@ import { EntryType } from '../types'; export const prepareEntryFile = async (app: App) => { const { componentMap = {}, pluginMap = {}, configMap = {}, valueMap = {}, eventMap = {} } = app.moduleMainFilePath; const { componentFileAffix, dynamicImport, hooks } = app.options; - const contentMap: Record = { + let contentMap: Record = { 'comp-entry.ts': generateContent(EntryType.COMPONENT, componentMap, componentFileAffix), 'async-comp-entry.ts': generateContent(EntryType.COMPONENT, componentMap, componentFileAffix, dynamicImport), 'plugin-entry.ts': generateContent(EntryType.PLUGIN, pluginMap), @@ -17,7 +17,7 @@ export const prepareEntryFile = async (app: App) => { }; if (typeof hooks?.beforeWriteEntry === 'function') { - await hooks.beforeWriteEntry(contentMap, app); + contentMap = await hooks.beforeWriteEntry(contentMap, app); } Object.keys(contentMap).forEach((fileName: string) => {