GeezerVison is showing github.com — feat(codegen): add new option exclude for plugin containerLifeCycle · timeless1406/lowcode-engine@7a1b980
File tree
Expand file treeCollapse file tree
Open diff view settings
modules/code-generator/src/plugins/component/react
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: modules/code-generator/src/plugins/component/react/containerLifeCycle.ts +10-5Lines changed: 10 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,13 +16,14 @@ import { isJSFunction, isJSExpression } from '@alilc/lowcode-types'; |
16 | 16 | import { isJSExpressionFn } from '../../../utils/common'; |
17 | 17 |
|
18 | 18 | 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[]; |
22 | 23 | } |
23 | 24 |
|
24 | 25 | const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => { |
25 | | - const cfg: PluginConfig = { |
| 26 | + const cfg = { |
26 | 27 | fileType: FileType.JSX, |
27 | 28 | exportNameMapping: {}, |
28 | 29 | normalizeNameMapping: {}, |
@@ -56,6 +57,10 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => |
56 | 57 | normalizeName = cfg.normalizeNameMapping[lifeCycleName] || lifeCycleName; |
57 | 58 | } |
58 | 59 |
|
| 60 | + if (cfg?.exclude?.includes(normalizeName)) { |
| 61 | + return null; |
| 62 | + } |
| 63 | + |
59 | 64 | const exportName = cfg.exportNameMapping[lifeCycleName] || lifeCycleName; |
60 | 65 | if (normalizeName === 'constructor') { |
61 | 66 | return { |
@@ -97,7 +102,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => |
97 | 102 | }), |
98 | 103 | linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]], |
99 | 104 | }; |
100 | | - }); |
| 105 | + }).filter((i) => !!i); |
101 | 106 |
|
102 | 107 | next.chunks.push(...chunks.filter((x): x is ICodeChunk => x !== null)); |
103 | 108 | } |
|