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