@cloudbase/lowcode-builder 1.1.9 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/builder/h5/generate.d.ts +3 -2
- package/lib/builder/h5/generate.js +18 -2
- package/lib/builder/h5/index.js +1 -0
- package/lib/builder/h5/webpack.d.ts +3 -1
- package/lib/builder/h5/webpack.js +6 -2
- package/lib/builder/types/common.d.ts +1 -1
- package/lib/builder/util/common.d.ts +1 -1
- package/lib/builder.web.js +13 -39
- package/package.json +4 -4
- package/template/html/index.html.ejs +9 -5
- package/dist/builder.web.js +0 -97
- package/template/template_20221202.zip +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { BuildAppProps } from '@cloudbase/lowcode-generator';
|
|
2
|
+
import { IPlatformApp } from '@cloudbase/cals';
|
|
2
3
|
import { BuildType } from '../types/common';
|
|
3
4
|
/**
|
|
4
5
|
* 该函数从 @govcloud/generate 取到需要的模版文件
|
|
5
6
|
*/
|
|
6
7
|
export declare function generateProjectFiles(buildData: BuildAppProps): Promise<void>;
|
|
7
|
-
export declare function generateHTML({ appId, appBuildDir,
|
|
8
|
+
export declare function generateHTML({ appId, appBuildDir, externalResources, mode, devTool, isBuildApp, buildTypeList, }: {
|
|
8
9
|
appId: string;
|
|
9
|
-
|
|
10
|
+
externalResources: Required<IPlatformApp>['externalResources'];
|
|
10
11
|
appBuildDir: string;
|
|
11
12
|
mode: string;
|
|
12
13
|
devTool: string;
|
|
@@ -7,6 +7,7 @@ exports.generateThemeVarsFile = exports.handleAssets = exports.generateHTML = ex
|
|
|
7
7
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
8
8
|
const generateFiles_1 = require("../util/generateFiles");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const cals_1 = require("@cloudbase/cals");
|
|
10
11
|
const util_1 = require("../util");
|
|
11
12
|
const common_1 = require("../util/common");
|
|
12
13
|
const webpack_1 = require("../service/webpack");
|
|
@@ -24,16 +25,31 @@ async function generateProjectFiles(buildData) {
|
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
26
27
|
exports.generateProjectFiles = generateProjectFiles;
|
|
27
|
-
async function generateHTML({ appId, appBuildDir,
|
|
28
|
+
async function generateHTML({ appId, appBuildDir, externalResources = [], mode, devTool, isBuildApp, buildTypeList, }) {
|
|
28
29
|
const templatePath = path_1.default.join(config_1.appTemplateDir, 'html', 'index.html.ejs');
|
|
29
30
|
const dstFilePath = path_1.default.join(appBuildDir, 'index.html');
|
|
30
31
|
const packageTpl = await fs_extra_1.default.readFile(templatePath, { encoding: 'utf8' });
|
|
32
|
+
const jsApis = [];
|
|
33
|
+
const cssStyles = [];
|
|
34
|
+
for (let externalResource of externalResources) {
|
|
35
|
+
switch (externalResource.type) {
|
|
36
|
+
case cals_1.EExternalResourceType.JSUrl: {
|
|
37
|
+
jsApis.push(externalResource.url || '');
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
case cals_1.EExternalResourceType.CSSUrl: {
|
|
41
|
+
cssStyles.push(externalResource.url || '');
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
31
46
|
await fs_extra_1.default.writeFile(dstFilePath, (0, lodash_1.template)(packageTpl)({
|
|
32
47
|
appId,
|
|
33
48
|
title: '',
|
|
34
49
|
desc: 'WeDa构建的应用',
|
|
35
50
|
canUseVite: (0, util_1.canUseVite)(mode, devTool),
|
|
36
|
-
jsApis: (
|
|
51
|
+
jsApis: Array.from(new Set(jsApis.filter((item) => !!item))),
|
|
52
|
+
cssStyles: Array.from(new Set(cssStyles.filter((item) => !!item))),
|
|
37
53
|
mode,
|
|
38
54
|
isBuildApp,
|
|
39
55
|
isAdminPortal: (0, common_2.buildAsAdminPortalByBuildType)(buildTypeList),
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -105,6 +105,7 @@ async function buildH5App({ appKey, buildDir, dependencies, i18nConfig, extraDat
|
|
|
105
105
|
await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
|
|
106
106
|
// 生成 webpack 配置
|
|
107
107
|
const webpackConfigPath = await (0, webpack_1.runWebpackCore)({
|
|
108
|
+
cals,
|
|
108
109
|
appKey,
|
|
109
110
|
mainAppData,
|
|
110
111
|
subAppDataList,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { BuildAppProps } from '../core/index';
|
|
3
|
+
import { IPlatformApp } from '@cloudbase/cals';
|
|
3
4
|
interface IWebpackCoreProps extends BuildAppProps {
|
|
5
|
+
cals: IPlatformApp;
|
|
4
6
|
appBuildDir: string;
|
|
5
7
|
mpConfig: any;
|
|
6
8
|
mainAppData: IWebRuntimeAppData;
|
|
7
9
|
subAppDataList: IWebRuntimeAppData[];
|
|
8
10
|
assets: string[];
|
|
9
11
|
}
|
|
10
|
-
export declare function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, }: IWebpackCoreProps): Promise<string>;
|
|
12
|
+
export declare function runWebpackCore({ cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, mpConfig, assets, devTool, generateMpType, }: IWebpackCoreProps): Promise<string>;
|
|
11
13
|
export {};
|
|
@@ -4,7 +4,8 @@ exports.runWebpackCore = void 0;
|
|
|
4
4
|
const common_1 = require("../types/common");
|
|
5
5
|
const webpack_1 = require("../service/webpack");
|
|
6
6
|
const generate_1 = require("./generate");
|
|
7
|
-
|
|
7
|
+
const cals_1 = require("@cloudbase/cals");
|
|
8
|
+
async function runWebpackCore({ cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], mpConfig, assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP, }) {
|
|
8
9
|
console.time('runWebpackCore');
|
|
9
10
|
console.time('webpackGenerate');
|
|
10
11
|
const allAppDataList = subAppDataList.concat(mainAppData);
|
|
@@ -28,7 +29,10 @@ async function runWebpackCore({ mainAppData, subAppDataList, appBuildDir, public
|
|
|
28
29
|
await (0, generate_1.generateHTML)({
|
|
29
30
|
appId: mainAppData.id || appKey,
|
|
30
31
|
appBuildDir,
|
|
31
|
-
|
|
32
|
+
externalResources: (cals.externalResources || []).concat(assets.map((url) => ({
|
|
33
|
+
type: cals_1.EExternalResourceType.CSSUrl,
|
|
34
|
+
url,
|
|
35
|
+
}))),
|
|
32
36
|
mode,
|
|
33
37
|
devTool,
|
|
34
38
|
isBuildApp: buildTypeList.includes(common_1.BuildType.APP),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BuildType, GenerateMpType, WebpackModeType, WebpackBuildCallBack, IPackageJson, buildAsWebByBuildType, buildAsAdminPortalByBuildType, buildAsXPageByBuildType, IAppUsedComp, IUsedComps, ISyncProp, IComponentInputProps, IFileCodeMap, } from '@cloudbase/lowcode-generator/lib/generator/types/common';
|
|
2
2
|
import { IComponentMeta, ICompositedComponent } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
|
-
export type IComponentsInfoMap = {
|
|
3
|
+
export declare type IComponentsInfoMap = {
|
|
4
4
|
[componentSourceKey: string]: ({
|
|
5
5
|
meta: IComponentMeta;
|
|
6
6
|
} & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IComponentInputProps, IComponentsInfoMap, IPackageJson } from '../types/common';
|
|
2
2
|
import { IMaterialItem, IWeAppComponentInstance, IWeAppCode } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
3
3
|
export { getMetaInfoBySourceKey, isArray, isPlainObject, deepDeal, simpleDeepClone, deepDealSchema, getFileNameByUrl, } from '@cloudbase/lowcode-generator/lib/generator/util/common';
|
|
4
|
-
export type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
4
|
+
export declare type PromiseResult<T> = Promise<[null, T] | [Error, null]>;
|
|
5
5
|
export declare function promiseWrapper<T>(p: Promise<T>): PromiseResult<T>;
|
|
6
6
|
export declare function getCurrentPackageJson(): {
|
|
7
7
|
name: any;
|