Skip to content

Commit 5b68b86

Browse files
LeoYuanJackLian
authored andcommitted
refactor: moduleName of Component should not be converted
1 parent 9a68f0f commit 5b68b86

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

modules/code-generator/src/parser/SchemaParser.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
import { SUPPORT_SCHEMA_VERSION_LIST } from '../const';
3333

3434
import { getErrorMessage } from '../utils/errors';
35-
import { handleSubNodes, isValidContainerType } from '../utils/schema';
35+
import { handleSubNodes, isValidContainerType, ContainerType } from '../utils/schema';
3636
import { uniqueArray } from '../utils/common';
3737
import { componentAnalyzer } from '../analyzer/componentAnalyzer';
3838
import { ensureValidClassName } from '../utils/validate';
@@ -161,7 +161,8 @@ export class SchemaParser implements ISchemaParser {
161161
...subRoot,
162162
componentName: getRootComponentName(subRoot.componentName, compDeps),
163163
containerType: subRoot.componentName,
164-
moduleName: ensureValidClassName(changeCase.pascalCase(subRoot.fileName)),
164+
moduleName: ensureValidClassName(subRoot.componentName === ContainerType.Component ?
165+
subRoot.fileName : changeCase.pascalCase(subRoot.fileName)),
165166
};
166167
return container;
167168
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
4848
type: ChunkType.STRING,
4949
fileType: FileType.JSX,
5050
name: CLASS_DEFINE_CHUNK_NAME.InsVar,
51-
content: `static displayName = '${changeCase.pascalCase(ir.moduleName)}';`,
51+
content: `static displayName = '${ir.moduleName}';`,
5252
linkAfter: [
5353
CLASS_DEFINE_CHUNK_NAME.Start,
5454
],

modules/code-generator/src/utils/schema.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,10 @@ export function isValidContainerType(schema: IPublicTypeNodeSchema) {
147147
'Component',
148148
'Block',
149149
].includes(schema.componentName);
150+
}
151+
152+
export const enum ContainerType {
153+
Page = 'Page',
154+
Component = 'Component',
155+
Block = 'Block',
150156
}

0 commit comments

Comments
 (0)