mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
fix: merge problems & deps bugs
This commit is contained in:
parent
533e09acb1
commit
7a36eab5e6
@ -10,7 +10,6 @@ es
|
||||
lib
|
||||
.*
|
||||
~*
|
||||
test-cases
|
||||
|
||||
# 忽略文件
|
||||
**/*.min.js
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"start": "ava --watch",
|
||||
"build": "npm run build:tsc",
|
||||
"build": "npm run build:bs",
|
||||
"build:bs": "rimraf lib && rimraf es && build-scripts build --skip-demo",
|
||||
"build:tsc": "rimraf lib && tsc",
|
||||
"demo": "node ./demo/demo.js",
|
||||
@ -21,7 +21,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@ali/am-eslint-config": "*",
|
||||
"@ali/lowcode-types": "^0.8.14",
|
||||
"@ali/lowcode-types": "^1.0.0",
|
||||
"@ali/my-prettier": "^1.0.0",
|
||||
"@babel/generator": "^7.9.5",
|
||||
"@babel/parser": "^7.9.4",
|
||||
|
||||
@ -34,6 +34,18 @@ const defaultContainer: IContainerInfo = {
|
||||
props: {},
|
||||
};
|
||||
|
||||
function getRootComponentName(typeName: string, maps: Record<string, IExternalDependency>): string {
|
||||
if (maps[typeName]) {
|
||||
const rec = maps[typeName];
|
||||
const peerName = Object.keys(maps).find((depName: string) => {
|
||||
const depInfo = maps[depName];
|
||||
return depName !== typeName && depInfo.package === rec.package && depInfo.version === rec.version;
|
||||
});
|
||||
return peerName || typeName;
|
||||
}
|
||||
return typeName;
|
||||
}
|
||||
|
||||
class SchemaParser implements ISchemaParser {
|
||||
validate(schema: ProjectSchema): boolean {
|
||||
if (SUPPORT_SCHEMA_VERSION_LIST.indexOf(schema.version) < 0) {
|
||||
@ -92,6 +104,7 @@ class SchemaParser implements ISchemaParser {
|
||||
const subRoot = n as ContainerSchema;
|
||||
const container: IContainerInfo = {
|
||||
...subRoot,
|
||||
componentName: getRootComponentName(subRoot.componentName, compDeps),
|
||||
containerType: subRoot.componentName,
|
||||
moduleName: changeCase.pascalCase(subRoot.fileName),
|
||||
};
|
||||
@ -159,13 +172,12 @@ class SchemaParser implements ISchemaParser {
|
||||
|
||||
// 分析容器内部组件依赖
|
||||
containers.forEach((container) => {
|
||||
if (container.children) {
|
||||
const depNames = this.getComponentNames(container.children);
|
||||
container.deps = uniqueArray<string>(depNames, (i: string) => i)
|
||||
.map((depName) => internalDeps[depName] || compDeps[depName])
|
||||
.filter((dep) => !!dep);
|
||||
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
|
||||
}
|
||||
const depNames = this.getComponentNames(container);
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
container.deps = uniqueArray<string>(depNames, (i: string) => i)
|
||||
.map((depName) => internalDeps[depName] || compDeps[depName])
|
||||
.filter(Boolean);
|
||||
// container.deps = Object.keys(compDeps).map((depName) => compDeps[depName]);
|
||||
});
|
||||
|
||||
// 分析路由配置
|
||||
@ -210,14 +222,20 @@ class SchemaParser implements ISchemaParser {
|
||||
})
|
||||
.filter((dep) => dep !== null);
|
||||
const npmInfos: INpmPackage[] = p
|
||||
.filter((i) => Boolean(i))
|
||||
.filter(Boolean)
|
||||
.map((i) => ({
|
||||
package: (i as IExternalDependency).package,
|
||||
version: (i as IExternalDependency).version,
|
||||
}));
|
||||
npms.push(...npmInfos);
|
||||
});
|
||||
npms = uniqueArray<INpmPackage>(npms, (i) => i.package);
|
||||
|
||||
npms.push(...(utilsDeps.map(utilsDep => ({
|
||||
package: utilsDep.package,
|
||||
version: utilsDep.version,
|
||||
}))));
|
||||
|
||||
npms = uniqueArray<INpmPackage>(npms, (i) => i.package).filter(Boolean);
|
||||
|
||||
return {
|
||||
containers,
|
||||
@ -238,7 +256,7 @@ class SchemaParser implements ISchemaParser {
|
||||
i18n: schema.i18n,
|
||||
containersDeps,
|
||||
utilsDeps,
|
||||
packages: npms,
|
||||
packages: npms || [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@ -38,6 +38,9 @@ function groupDepsByPack(deps: IDependency[]): Record<string, IDependency[]> {
|
||||
if (dep.main && depMainBlackList.indexOf(dep.main) < 0) {
|
||||
depMain = dep.main;
|
||||
}
|
||||
if (depMain.substring(0, 1) === '/') {
|
||||
depMain = depMain.substring(1);
|
||||
}
|
||||
addDep(`${(dep as IExternalDependency).package}${depMain ? `/${depMain}` : ''}`, dep);
|
||||
}
|
||||
});
|
||||
|
||||
@ -63,6 +63,7 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
});
|
||||
|
||||
// 注意:这里其实隐含了一个假设:schema 中的 componentName 应该是一个有效的 JS 标识符,而且是大写字母打头的
|
||||
// FIXME: 为了快速修复临时加的逻辑,需要用 pre-process 的方式替代处理。
|
||||
const mapComponentNameToAliasOrKeepIt = (componentName: string) => componentsNameAliasMap.get(componentName) || componentName;
|
||||
|
||||
// 然后过滤掉所有的别名 chunks
|
||||
|
||||
@ -74,6 +74,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
originTemplate: '@alifd/scaffold-lite-js',
|
||||
};
|
||||
|
||||
console.log(ir.packages);
|
||||
ir.packages.forEach((packageInfo) => {
|
||||
packageJson.dependencies[packageInfo.package] = packageInfo.version;
|
||||
});
|
||||
|
||||
@ -49,7 +49,9 @@ export function handleSubNodes<T>(
|
||||
|
||||
let result: T | undefined;
|
||||
const childrenRes: T[] = [];
|
||||
if (isDOMText(children)) {
|
||||
if (children === null || children === undefined) {
|
||||
return [];
|
||||
} else if (isDOMText(children)) {
|
||||
const handler = handlers.string || noop;
|
||||
result = handler(children as string);
|
||||
} else if (isJSExpression(children)) {
|
||||
|
||||
@ -1,3 +1 @@
|
||||
module.exports = {
|
||||
extends: ['rax'],
|
||||
};
|
||||
module.exports = {};
|
||||
|
||||
@ -25,7 +25,9 @@ class Home$$Page extends Component {
|
||||
_context = this._createContext();
|
||||
|
||||
_dataSourceConfig = this._defineDataSourceConfig();
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, { runtimeConfig: true });
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
});
|
||||
|
||||
_utils = this._defineUtils();
|
||||
|
||||
|
||||
@ -1,3 +1 @@
|
||||
module.exports = {
|
||||
extends: ['rax'],
|
||||
};
|
||||
module.exports = {};
|
||||
|
||||
@ -28,7 +28,11 @@ import './index.css';
|
||||
class Home$$Page extends Component {
|
||||
state = {
|
||||
clickCount: 0,
|
||||
user: { name: '张三', age: 18, avatar: 'https://gw.alicdn.com/tfs/TB1Ui9BMkY2gK0jSZFgXXc5OFXa-50-50.png' },
|
||||
user: {
|
||||
name: '张三',
|
||||
age: 18,
|
||||
avatar: 'https://gw.alicdn.com/tfs/TB1Ui9BMkY2gK0jSZFgXXc5OFXa-50-50.png',
|
||||
},
|
||||
orders: [
|
||||
{
|
||||
title: '【小米智能生活】米家扫地机器人家用全自动扫拖一体机拖地吸尘器',
|
||||
@ -108,7 +112,7 @@ class Home$$Page extends Component {
|
||||
<View>
|
||||
<Text>=== Orders: ===</Text>
|
||||
</View>
|
||||
{__$$evalArray(() => __$$context.state.orders).map((order, index) => (
|
||||
{__$$evalArray(() => __$$eval(() => __$$context.state.orders)).map((order, index) => (
|
||||
<View
|
||||
style={{ flexDirection: 'row' }}
|
||||
data-order={order}
|
||||
@ -127,7 +131,10 @@ class Home$$Page extends Component {
|
||||
}}
|
||||
>
|
||||
<View>
|
||||
<Image source={{ uri: __$$eval(() => order.coverUrl) }} style={{ width: '80px', height: '60px' }} />
|
||||
<Image
|
||||
source={{ uri: __$$eval(() => order.coverUrl) }}
|
||||
style={{ width: '80px', height: '60px' }}
|
||||
/>
|
||||
</View>
|
||||
<View>
|
||||
<Text>{__$$eval(() => order.title)}</Text>
|
||||
|
||||
@ -1,3 +1 @@
|
||||
module.exports = {
|
||||
extends: ['rax'],
|
||||
};
|
||||
module.exports = {};
|
||||
|
||||
@ -20,8 +20,7 @@
|
||||
"rax-document": "^0.1.0",
|
||||
"rax-view": "^1.0.0",
|
||||
"rax-text": "^1.0.0",
|
||||
"rax-link": "^1.0.0",
|
||||
"rax-image": "^1.0.0"
|
||||
"rax-link": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"build-plugin-rax-app": "^5.0.0",
|
||||
|
||||
@ -9,8 +9,6 @@ import Text from 'rax-text';
|
||||
|
||||
import Link from 'rax-link';
|
||||
|
||||
import Image from 'rax-image';
|
||||
|
||||
import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-engine/runtime';
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
@ -31,7 +29,9 @@ class Detail$$Page extends Component {
|
||||
_context = this._createContext();
|
||||
|
||||
_dataSourceConfig = this._defineDataSourceConfig();
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, { runtimeConfig: true });
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
});
|
||||
|
||||
_utils = this._defineUtils();
|
||||
|
||||
|
||||
@ -9,8 +9,6 @@ import Text from 'rax-text';
|
||||
|
||||
import Link from 'rax-link';
|
||||
|
||||
import Image from 'rax-image';
|
||||
|
||||
import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-engine/runtime';
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
@ -31,7 +29,9 @@ class Home$$Page extends Component {
|
||||
_context = this._createContext();
|
||||
|
||||
_dataSourceConfig = this._defineDataSourceConfig();
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, { runtimeConfig: true });
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
});
|
||||
|
||||
_utils = this._defineUtils();
|
||||
|
||||
|
||||
@ -9,8 +9,6 @@ import Text from 'rax-text';
|
||||
|
||||
import Link from 'rax-link';
|
||||
|
||||
import Image from 'rax-image';
|
||||
|
||||
import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-engine/runtime';
|
||||
|
||||
import { isMiniApp as __$$isMiniApp } from 'universal-env';
|
||||
@ -31,7 +29,9 @@ class List$$Page extends Component {
|
||||
_context = this._createContext();
|
||||
|
||||
_dataSourceConfig = this._defineDataSourceConfig();
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, { runtimeConfig: true });
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
});
|
||||
|
||||
_utils = this._defineUtils();
|
||||
|
||||
|
||||
@ -1,3 +1 @@
|
||||
module.exports = {
|
||||
extends: ['rax'],
|
||||
};
|
||||
module.exports = {};
|
||||
|
||||
@ -18,10 +18,9 @@
|
||||
"rax": "^1.1.0",
|
||||
"rax-app": "^2.0.0",
|
||||
"rax-document": "^0.1.0",
|
||||
"@alife/right-design-card": "*",
|
||||
"rax-view": "^1.0.0",
|
||||
"rax-text": "^1.0.0",
|
||||
"rax-image": "^1.0.0"
|
||||
"@alife/right-design-card": "*",
|
||||
"rax-text": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"build-plugin-rax-app": "^5.0.0",
|
||||
|
||||
@ -3,13 +3,11 @@
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
|
||||
import Card from '@alife/right-design-card';
|
||||
|
||||
import View from 'rax-view';
|
||||
|
||||
import Text from 'rax-text';
|
||||
import Card from '@alife/right-design-card';
|
||||
|
||||
import Image from 'rax-image';
|
||||
import Text from 'rax-text';
|
||||
|
||||
import { create as __$$createDataSourceEngine } from '@ali/lowcode-datasource-engine/runtime';
|
||||
|
||||
@ -31,7 +29,9 @@ class Home$$Page extends Component {
|
||||
_context = this._createContext();
|
||||
|
||||
_dataSourceConfig = this._defineDataSourceConfig();
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, { runtimeConfig: true });
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
});
|
||||
|
||||
_utils = this._defineUtils();
|
||||
|
||||
|
||||
@ -1,3 +1 @@
|
||||
module.exports = {
|
||||
extends: ['rax'],
|
||||
};
|
||||
module.exports = {};
|
||||
|
||||
@ -25,7 +25,9 @@ class Home$$Page extends Component {
|
||||
_context = this._createContext();
|
||||
|
||||
_dataSourceConfig = this._defineDataSourceConfig();
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, { runtimeConfig: true });
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
});
|
||||
|
||||
_utils = this._defineUtils();
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
tnpm i -g lerna @ali/tyarn tsc
|
||||
tnpm i -g lerna @ali/tyarn
|
||||
|
||||
rm -rf node_modules package-lock.json yarn.lock
|
||||
lerna clean -y
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user