mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 05:48:17 +00:00
feat: assset.json package 对象支持 exportName, 用来适配 umd 导出的 name
This commit is contained in:
parent
4fb91ce33b
commit
6a1af9d729
@ -108,6 +108,7 @@ const defaultEnvironment = [
|
|||||||
AssetType.JSText,
|
AssetType.JSText,
|
||||||
'window.PropTypes=parent.PropTypes;React.PropTypes=parent.PropTypes; window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;',
|
'window.PropTypes=parent.PropTypes;React.PropTypes=parent.PropTypes; window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;',
|
||||||
),
|
),
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const defaultRaxEnvironment = [
|
const defaultRaxEnvironment = [
|
||||||
@ -265,21 +266,43 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
private _iframe?: HTMLIFrameElement;
|
private _iframe?: HTMLIFrameElement;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {
|
||||||
|
* "title":"BizCharts",
|
||||||
|
* "package":"bizcharts",
|
||||||
|
* "exportName":"bizcharts",
|
||||||
|
* "version":"4.0.14",
|
||||||
|
* "urls":[
|
||||||
|
* "https://g.alicdn.com/code/lib/bizcharts/4.0.14/BizCharts.js"
|
||||||
|
* ],
|
||||||
|
* "library":"BizCharts"
|
||||||
|
* }
|
||||||
|
* package:String 资源npm包名
|
||||||
|
* exportName:String umd包导出名字,用于适配部分物料包define name不一致的问题,例如把BizCharts改成bizcharts,用来兼容物料用define声明的bizcharts
|
||||||
|
* version:String 版本号
|
||||||
|
* urls:Array 资源cdn地址,必须是umd类型,可以是.js或者.css
|
||||||
|
* library:String umd包直接导出的name
|
||||||
|
*/
|
||||||
buildLibrary(library) {
|
buildLibrary(library) {
|
||||||
library = library || this.get('library') as LibraryItem[];
|
library = library || this.get('library') as LibraryItem[];
|
||||||
const libraryAsset: AssetList = [];
|
const libraryAsset: AssetList = [];
|
||||||
|
const libraryExportList = [];
|
||||||
|
|
||||||
if (library) {
|
if (library) {
|
||||||
library.forEach((item) => {
|
library.forEach((item) => {
|
||||||
this.libraryMap[item.package] = item.library;
|
this.libraryMap[item.package] = item.library;
|
||||||
if (item.async) {
|
if (item.async) {
|
||||||
this.asyncLibraryMap[item.package] = item;
|
this.asyncLibraryMap[item.package] = item;
|
||||||
}
|
}
|
||||||
|
if (item.exportName && item.library) {
|
||||||
|
libraryExportList.push(`Object.defineProperty(window,'${item.exportName}',{get:()=>window.${item.library}});`);
|
||||||
|
}
|
||||||
if (item.urls) {
|
if (item.urls) {
|
||||||
|
|
||||||
libraryAsset.push(item.urls);
|
libraryAsset.push(item.urls);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
libraryAsset.unshift(assetItem(AssetType.JSText, libraryExportList.join('')));
|
||||||
|
|
||||||
return libraryAsset;
|
return libraryAsset;
|
||||||
}
|
}
|
||||||
@ -304,6 +327,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
|||||||
),
|
),
|
||||||
// required & use once
|
// required & use once
|
||||||
assetBundle(this.get('extraEnvironment'), AssetLevel.Environment),
|
assetBundle(this.get('extraEnvironment'), AssetLevel.Environment),
|
||||||
|
|
||||||
// required & use once
|
// required & use once
|
||||||
assetBundle(libraryAsset, AssetLevel.Library),
|
assetBundle(libraryAsset, AssetLevel.Library),
|
||||||
// required & TODO: think of update
|
// required & TODO: think of update
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user