alibaba / alibaba/lowcode-engine

出码引擎产出的Rax方案代码,无法运行

Open
#915 1 comment 0 reactions 1 assignee Claimed by @Clarence-pan View on GitHub
Dominant language
TypeScript
Stars
15.9k
Forks
2.7k
PR merge metrics
No merged PRs in 30d

Description

## **Describe the bug (required)** / **详细描述 bug(必填)**

使用[code-generator](https://github.com/alibaba/lowcode-engine/tree/main/modules/code-generator)出码引擎产出的Rax方案代码,无法运行。

---

## **To Reproduce (required)** / **如何复现 bug?(必填,非常重要)**

Steps to reproduce the behavior: / 详细复现步骤:

中文版示例:
1. 打开 [code-generator](https://github.com/alibaba/lowcode-engine/tree/main/modules/code-generator);
2. 修改example-schema.json内容为(**此内容使用Ice出码方案是可以执行的**):`{"version":"1.0.0","componentsMap":[{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"Col","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextCol"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"Row","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextRow"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"RowColContainer","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextRowColContainer"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"BlockCell","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextBlockCell"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"Block","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextBlock"},{"package":"@alilc/lowcode-materials","version":"1.0.2","exportName":"NextText","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextText"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"P","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextP"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"PageHeader","main":"lib/index.js","destructuring":true,"subName":"","componentName":"NextPageHeader"},{"package":"@alifd/pro-layout","version":"1.0.1-beta.6","exportName":"Page","main":"lib/index.js","destructuring":true,"componentName":"NextPage"}],"componentsTree":[{"componentName":"Page","id":"node_dockcviv8fo1","props":{"ref":"outerView","style":{"height":"100%"}},"fileName":"/","dataSource":{"list":[{"type":"fetch","isInit":true,"options":{"params":{},"method":"GET","isCors":true,"timeout":5000,"headers":{},"uri":"mock/info.json"},"id":"info","shouldFetch":{"type":"JSFunction","value":"function() { \n console.log('should fetch.....');\n return true; \n}"}}]},"state":{"text":{"type":"JSExpression","value":"\"outer\""},"isShowDialog":{"type":"JSExpression","value":"false"}},"css":"body {\n font-size: 12px;\n}\n\n.button {\n width: 100px;\n color: #ff00ff\n}","lifeCycles":{"componentDidMount":{"type":"JSFunction","value":"function componentDidMount() {\n console.log('did mount');\n}"},"componentWillUnmount":{"type":"JSFunction","value":"function componentWillUnmount() {\n console.log('will unmount');\n}"}},"methods":{"testFunc":{"type":"JSFunction","value":"function testFunc() {\n console.log('test func');\n}"},"onClick":{"type":"JSFunction","value":"function onClick() {\n this.setState({\n isShowDialog: true\n });\n}"},"closeDialog":{"type":"JSFunction","value":"function closeDialog() {\n this.setState({\n isShowDialog: false\n });\n}"}},"originCode":"class LowcodeComponent extends Component {\n state = {\n \"text\": \"outer\",\n \"isShowDialog\": false\n }\n componentDidMount() {\n console.log('did mount');\n }\n componentWillUnmount() {\n console.log('will unmount');\n }\n testFunc() {\n console.log('test func');\n }\n onClick() {\n this.setState({\n isShowDialog: true\n })\n }\n closeDialog() {\n this.setState({\n isShowDialog: false\n })\n }\n}","title":"","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextPage","id":"node_ockzs2vw431","props":{"headerDivider":true,"minHeight":"100vh","presetNav":true,"presetAside":true,"nav":false,"aside":false,"placeholderStyle":{"gridRowEnd":"span 1","gridColumnEnd":"span 12"},"headerProps":{"background":"surface"},"header":{"type":"JSSlot","value":[{"componentName":"NextPageHeader","id":"node_ocl6g95o9s25","props":{"style":{"background":"#ffffff","padding":"","display":"flex","flexDirection":"row","justifyContent":"center"}},"title":"页面头部","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextRowColContainer","id":"node_ocl6g95q1n5b","props":{"rowGap":20,"colGap":20},"title":"行列容器","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextRow","id":"node_ocl6g95q1n5c","props":{},"title":"行","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextCol","id":"node_ocl6g95q1n5d","props":{"colSpan":1},"title":"列","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextP","id":"node_ocl6g95q1n77","props":{"wrap":false,"type":"body2","verAlign":"middle","textSpacing":true,"align":"left"},"docId":"docl6g95q1n","title":"段落","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextText","id":"node_ocl6g95q1n78","props":{"type":"inherit","children":"面板标题","mark":false,"code":false,"delete":false,"underline":false,"strong":false},"docId":"docl6g95q1n","title":"","isLocked":false,"condition":true,"conditionGroup":""}]}]}]}]}]}],"title":"header"},"isTab":false,"contentAlignCenter":false,"contentProps":{"style":{"background":"rgba(255,255,255,0)"}},"ref":"nextpage-ee3a75ce"},"title":"页面","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextBlock","id":"node_ockzs2vw437","props":{"placeholderStyle":{"height":"100%"},"noPadding":false,"noBorder":false,"title":"区域标题","rowGap":20,"colGap":20,"background":"surface","layoutmode":"O","strict":true,"colSpan":12,"rowSpan":1,"mode":"transparent","childTotalColumns":12,"ref":"nextblock-7ce3de8d"},"title":"区域","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextBlockCell","id":"node_ockzs2vw438","props":{"colSpan":12,"rowSpan":1,"mode":"procard","isAutoContainer":true,"title":"区块标题","hasDivider":true,"loading":false,"bodyPadding":"","hasCollapse":false,"text":true,"visibleButtonCount":3,"operationConfig":{"align":"center"},"operations":[]},"title":"","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextRowColContainer","id":"node_ockzs2vw439","props":{"rowGap":20,"colGap":20},"title":"行列容器","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextRow","id":"node_ockzs2vw43a","props":{},"title":"行","isLocked":false,"condition":true,"conditionGroup":"","children":[{"componentName":"NextCol","id":"node_ockzs2vw43b","props":{"colSpan":1},"title":"列","isLocked":false,"condition":true,"conditionGroup":""}]}]}]}]}]}]}],"i18n":{}} `;
3. 为package.json增加一条script: `"rax": "node bin/lowcode-code-generator.js -i example-schema.json5 -o demo -s rax",`;
4. 运行rax命令,生成Rax代码,产出的代码层中有命名问题。需要将内容
`import {
Page as NextPage,
Block as NextBlock,
BlockCell as NextBlockCell,
RowColContainer as NextRowColContainer,
Row as NextRow,
Col as NextCol,
PageHeader as NextPageHeader,
P as NextP,
} from '@alifd/pro-layout/lib/index.js';`
**修改为**
`import {
Page,
Block,
BlockCell,
RowColContainer,
Row,
Col,
PageHeader,
P,
} from '@alifd/pro-layout/lib/index.js`;
5. 安装依赖后,运行Rax项目代码,会得到如下错误。
![image](https://user-images.githubusercontent.com/51012898/183361236-5631d28f-793c-47b1-9267-f779445e176a.png)

## **Expected behavior (required)** / **预期行为(必填,非常重要)**
**希望采用Rax出码方案产出的代码可以正常运行。**

---

## **Environments (please complete the following information) (required):** / **请提供如下信息(必填)**
- @alilc/lowcode-code-generator version: [1.0.4] / 出码引擎版本(目前只用到了这个。)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.