mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
feat(cli): hooks.beforeWriteEntry 改为 async
This commit is contained in:
parent
f824b661bd
commit
cc21c47829
@ -61,7 +61,7 @@ export interface UserConfig {
|
||||
/** 是否使用import()加载组件 */
|
||||
dynamicImport?: boolean;
|
||||
hooks?: {
|
||||
beforeWriteEntry?: (genContentMap: Record<string, string>, app: Core) => void;
|
||||
beforeWriteEntry?: (genContentMap: Record<string, string>, app: Core) => Promise<Record<string, string>>;
|
||||
};
|
||||
onInit?: (app: Core) => ModuleMainFilePath | Promise<ModuleMainFilePath>;
|
||||
onPrepare?: (app: Core) => void;
|
||||
|
@ -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<string, string> = {
|
||||
let contentMap: Record<string, string> = {
|
||||
'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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user