GeezerVison is showing github.com — fix: 修复生成的 icejs 项目不支持 constants 的问题, fixes #1259 · ikvm/lowcode-engine@3c16561
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +{ | | 2 | + "releaseCommitMessageFormat": "chore(release): code-generator - {{currentTag}}" | | 3 | +} |
Collapse file Copy file name to clipboard +55Lines changed: 55 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +import { | | 2 | + CLASS_DEFINE_CHUNK_NAME, | | 3 | + COMMON_CHUNK_NAME, | | 4 | + DEFAULT_LINK_AFTER, | | 5 | +} from '../../../const/generator'; | | 6 | + | | 7 | +import { | | 8 | + BuilderComponentPlugin, | | 9 | + BuilderComponentPluginFactory, | | 10 | + ChunkType, | | 11 | + FileType, | | 12 | + ICodeStruct, | | 13 | +} from '../../../types'; | | 14 | + | | 15 | +export interface PluginConfig { | | 16 | + fileType: string; | | 17 | +} | | 18 | + | | 19 | +const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) => { | | 20 | + const cfg: PluginConfig = { | | 21 | + fileType: FileType.JSX, | | 22 | + ...config, | | 23 | + }; | | 24 | + | | 25 | + const plugin: BuilderComponentPlugin = async (pre: ICodeStruct) => { | | 26 | + const next: ICodeStruct = { | | 27 | + ...pre, | | 28 | + }; | | 29 | + | | 30 | + next.chunks.push({ | | 31 | + type: ChunkType.STRING, | | 32 | + fileType: cfg.fileType, | | 33 | + name: COMMON_CHUNK_NAME.InternalDepsImport, | | 34 | + content: "import __$$constants from '../../constants';", | | 35 | + linkAfter: [COMMON_CHUNK_NAME.ExternalDepsImport], | | 36 | + }); | | 37 | + | | 38 | + next.chunks.push({ | | 39 | + type: ChunkType.STRING, | | 40 | + fileType: cfg.fileType, | | 41 | + name: CLASS_DEFINE_CHUNK_NAME.InsVar, | | 42 | + content: ` | | 43 | + get constants() { | | 44 | + return __$$constants || {}; | | 45 | + } | | 46 | + `, | | 47 | + linkAfter: [...DEFAULT_LINK_AFTER[CLASS_DEFINE_CHUNK_NAME.InsVar]], | | 48 | + }); | | 49 | + | | 50 | + return next; | | 51 | + }; | | 52 | + return plugin; | | 53 | +}; | | 54 | + | | 55 | +export default pluginFactory; |
Collapse file Copy file name to clipboardExpand all lines: modules/code-generator/src/solutions/icejs.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,6 +8,7 @@ import containerInitState from '../plugins/component/react/containerInitState'; | 8 | 8 | import containerInjectContext from '../plugins/component/react/containerInjectContext'; | 9 | 9 | import containerInjectUtils from '../plugins/component/react/containerInjectUtils'; | 10 | 10 | import containerInjectDataSourceEngine from '../plugins/component/react/containerInjectDataSourceEngine'; | | 11 | +import containerInjectConstants from '../plugins/component/react/containerInjectConstants'; | 11 | 12 | import containerInjectI18n from '../plugins/component/react/containerInjectI18n'; | 12 | 13 | import containerLifeCycle from '../plugins/component/react/containerLifeCycle'; | 13 | 14 | import containerMethod from '../plugins/component/react/containerMethod'; | @@ -22,7 +23,7 @@ import icejs from '../plugins/project/framework/icejs'; | 22 | 23 |
| 23 | 24 | import { prettier } from '../postprocessor'; | 24 | 25 |
| 25 | | -export interface IceJsProjectBuilderOptions extends IProjectBuilderOptions {} | | 26 | +export type IceJsProjectBuilderOptions = IProjectBuilderOptions; | 26 | 27 |
| 27 | 28 | export default function createIceJsProjectBuilder( | 28 | 29 | options?: IceJsProjectBuilderOptions, | @@ -65,6 +66,7 @@ export default function createIceJsProjectBuilder( | 65 | 66 | containerInjectUtils(), | 66 | 67 | containerInjectDataSourceEngine(), | 67 | 68 | containerInjectI18n(), | | 69 | + containerInjectConstants(), | 68 | 70 | containerInitState(), | 69 | 71 | containerLifeCycle(), | 70 | 72 | containerMethod(), | |
|