Skip to content

Commit 7a1b980

Browse files
eternalskyLeoYuan
authored andcommitted
feat(codegen): add new option exclude for plugin containerLifeCycle
1 parent aa1bb1c commit 7a1b980

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

modules/code-generator/src/plugins/component/react/containerLifeCycle.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ import { isJSFunction, isJSExpression } from '@alilc/lowcode-types';
1616
import { isJSExpressionFn } from '../../../utils/common';
1717

1818
export interface PluginConfig {
19-
fileType: string;
20-
exportNameMapping: Record<string, string>;
21-
normalizeNameMapping: Record<string, string>;
19+
fileType?: string;
20+
exportNameMapping?: Record<string, string>;
21+
normalizeNameMapping?: Record<string, string>;
22+
exclude?: string[];
2223
}
2324

2425
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
25-
const cfg: PluginConfig = {
26+
const cfg = {
2627
fileType: FileType.JSX,
2728
exportNameMapping: {},
2829
normalizeNameMapping: {},
@@ -56,6 +57,10 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
5657
normalizeName = cfg.normalizeNameMapping[lifeCycleName] || lifeCycleName;
5758
}
5859

60+
if (cfg?.exclude?.includes(normalizeName)) {
61+
return null;
62+
}
63+
5964
const exportName = cfg.exportNameMapping[lifeCycleName] || lifeCycleName;
6065
if (normalizeName === 'constructor') {
6166
return {
@@ -97,7 +102,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
97102
}),
98103
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]],
99104
};
100-
});
105+
}).filter((i) => !!i);
101106

102107
next.chunks.push(...chunks.filter((x): x is ICodeChunk => x !== null));
103108
}

0 commit comments

Comments
 (0)