Skip to content

Commit

Permalink
feat(codegen): add new option exclude for plugin containerLifeCycle
Browse files Browse the repository at this point in the history
  • Loading branch information
eternalsky committed Jul 13, 2023
1 parent aa1bb1c commit e19931b
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ import { isJSFunction, isJSExpression } from '@alilc/lowcode-types';
import { isJSExpressionFn } from '../../../utils/common';

export interface PluginConfig {
fileType: string;
exportNameMapping: Record<string, string>;
normalizeNameMapping: Record<string, string>;
fileType?: string;
exportNameMapping?: Record<string, string>;
normalizeNameMapping?: Record<string, string>;
exclude?: string[];
}

const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => {
const cfg: PluginConfig = {
const cfg = {
fileType: FileType.JSX,
exportNameMapping: {},
normalizeNameMapping: {},
Expand Down Expand Up @@ -56,6 +57,10 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
normalizeName = cfg.normalizeNameMapping[lifeCycleName] || lifeCycleName;
}

if (cfg?.exclude?.includes(normalizeName)) {
return null;
}

const exportName = cfg.exportNameMapping[lifeCycleName] || lifeCycleName;
if (normalizeName === 'constructor') {
return {
Expand Down Expand Up @@ -97,7 +102,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
}),
linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsMethod]],
};
});
}).filter((i) => !!i);

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

0 comments on commit e19931b

Please sign in to comment.