mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
feat(codegen): add new option exclude for plugin containerLifeCycle
This commit is contained in:
parent
aa1bb1c0d7
commit
7a1b9802a4
@ -16,13 +16,14 @@ import { isJSFunction, isJSExpression } from '@alilc/lowcode-types';
|
|||||||
import { isJSExpressionFn } from '../../../utils/common';
|
import { isJSExpressionFn } from '../../../utils/common';
|
||||||
|
|
||||||
export interface PluginConfig {
|
export interface PluginConfig {
|
||||||
fileType: string;
|
fileType?: string;
|
||||||
exportNameMapping: Record<string, string>;
|
exportNameMapping?: Record<string, string>;
|
||||||
normalizeNameMapping: Record<string, string>;
|
normalizeNameMapping?: Record<string, string>;
|
||||||
|
exclude?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
|
||||||
const cfg: PluginConfig = {
|
const cfg = {
|
||||||
fileType: FileType.JSX,
|
fileType: FileType.JSX,
|
||||||
exportNameMapping: {},
|
exportNameMapping: {},
|
||||||
normalizeNameMapping: {},
|
normalizeNameMapping: {},
|
||||||
@ -56,6 +57,10 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
normalizeName = cfg.normalizeNameMapping[lifeCycleName] || lifeCycleName;
|
normalizeName = cfg.normalizeNameMapping[lifeCycleName] || lifeCycleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg?.exclude?.includes(normalizeName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const exportName = cfg.exportNameMapping[lifeCycleName] || lifeCycleName;
|
const exportName = cfg.exportNameMapping[lifeCycleName] || lifeCycleName;
|
||||||
if (normalizeName === 'constructor') {
|
if (normalizeName === 'constructor') {
|
||||||
return {
|
return {
|
||||||
@ -97,7 +102,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
|||||||
}),
|
}),
|
||||||
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]],
|
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]],
|
||||||
};
|
};
|
||||||
});
|
}).filter((i) => !!i);
|
||||||
|
|
||||||
next.chunks.push(...chunks.filter((x): x is ICodeChunk => x !== null));
|
next.chunks.push(...chunks.filter((x): x is ICodeChunk => x !== null));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user