@cloudbase/lowcode-builder 1.9.0 → 1.9.1
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/config/dependencies.js +3 -3
- package/lib/builder/h5/index.js +45 -0
- package/lib/builder/h5/npm.d.ts +3 -2
- package/lib/builder/h5/npm.js +4 -3
- package/lib/builder/h5/webpack.d.ts +2 -1
- package/lib/builder/h5/webpack.js +2 -1
- package/lib/builder/service/webpack.d.ts +3 -2
- package/lib/builder/service/webpack.js +4 -3
- package/lib/builder.web.js +3 -3
- package/package.json +3 -3
- package/template/html/index.html.ejs +7 -1
- package/template/mp/common/util.js +5 -1
- package/template/package.json +3 -1
- package/template/webpack/web.prod.js +76 -59
|
@@ -12,14 +12,14 @@ const BASE_DEPS = {
|
|
|
12
12
|
* 注意锁版本
|
|
13
13
|
*/
|
|
14
14
|
const CLOUDBASE_DEPS = {
|
|
15
|
-
'@cloudbase/oauth': '0.1.1-alpha.
|
|
16
|
-
'@cloudbase/weda-client': '1.1.
|
|
15
|
+
'@cloudbase/oauth': '0.1.1-alpha.15',
|
|
16
|
+
'@cloudbase/weda-client': '1.1.6',
|
|
17
17
|
'@cloudbase/weda-cloud-sdk': '1.0.68',
|
|
18
18
|
};
|
|
19
19
|
function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, uin, }) {
|
|
20
20
|
const deps = {};
|
|
21
21
|
if (importJSSDK) {
|
|
22
|
-
deps['@cloudbase/js-sdk'] = '2.5.
|
|
22
|
+
deps['@cloudbase/js-sdk'] = '2.5.47-beta.0';
|
|
23
23
|
}
|
|
24
24
|
const mod = uin ? Number(uin) % 10 : undefined;
|
|
25
25
|
if (mode === 'lib') {
|
package/lib/builder/h5/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const config_1 = require("../config");
|
|
|
45
45
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
46
46
|
const junk = __importStar(require("../util/junk"));
|
|
47
47
|
const url_1 = require("url");
|
|
48
|
+
const semver = __importStar(require("semver"));
|
|
48
49
|
let BabelTransform = (code, options) => code;
|
|
49
50
|
if (!process.env.IS_WEB_WORKER) {
|
|
50
51
|
let transform = require('../../utils/transform');
|
|
@@ -106,6 +107,45 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
106
107
|
// 注意需要包涵官方的(gsd),部分平台方法需要由其补充
|
|
107
108
|
return lib.name === config_1.OFFICIAL_LIB_KEY || !!(((_a = used.component) === null || _a === void 0 ? void 0 : _a[lib.name]) || ((_b = used.action) === null || _b === void 0 ? void 0 : _b[lib.name]));
|
|
108
109
|
}), materialsDir, runtime, ignoreInstall);
|
|
110
|
+
const h5LibDirPath = path_1.default.resolve(h5BuildDir, 'src', 'libraries');
|
|
111
|
+
const libNames = fs_extra_1.default.readdirSync(h5LibDirPath).filter((name) => name !== '.DS_Store');
|
|
112
|
+
let libNameWithVue;
|
|
113
|
+
const vueVersions = libNames.map((libName) => {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
try {
|
|
116
|
+
const v = (_b = (_a = require(path_1.default.resolve(h5LibDirPath, libName, 'package.json'))) === null || _a === void 0 ? void 0 : _a.dependencies) === null || _b === void 0 ? void 0 : _b.vue;
|
|
117
|
+
if (v == null) {
|
|
118
|
+
return 0;
|
|
119
|
+
}
|
|
120
|
+
const minValidVersion = semver.valid(semver.minVersion(v));
|
|
121
|
+
if (minValidVersion == null) {
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
libNameWithVue = libName;
|
|
125
|
+
return semver.gt(minValidVersion, '2.7.16') ? 3 : 2;
|
|
126
|
+
}
|
|
127
|
+
catch (e) {
|
|
128
|
+
console.log(e, `no package.json for ${libName}`);
|
|
129
|
+
return 0;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
let vueVersion;
|
|
133
|
+
const vueVersionSet = new Set(vueVersions.filter((v) => v !== 0));
|
|
134
|
+
if (vueVersionSet.size === 0) {
|
|
135
|
+
vueVersion = 0;
|
|
136
|
+
}
|
|
137
|
+
else if (vueVersionSet.size === 1) {
|
|
138
|
+
vueVersion = vueVersionSet.has(3) ? 3 : 2;
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
const lib2vueVersionMap = libNames.reduce((map, libName, index) => {
|
|
142
|
+
map[libName] = vueVersions[index];
|
|
143
|
+
return map;
|
|
144
|
+
}, {});
|
|
145
|
+
throw new Error(`Libraries' vue versions conflict!
|
|
146
|
+
Vue2 and Vue3 should not be present at the same time!
|
|
147
|
+
detail: ${JSON.stringify(lib2vueVersionMap, null, 2)}`);
|
|
148
|
+
}
|
|
109
149
|
console.timeEnd(runHandleMaterialTag);
|
|
110
150
|
// // 获取 generate 需要的构建文件
|
|
111
151
|
const runGenerateTag = '🚥 buildWebApp-generateProjectFiles';
|
|
@@ -142,6 +182,7 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
142
182
|
mode,
|
|
143
183
|
devTool,
|
|
144
184
|
ignoreInstall,
|
|
185
|
+
vueVersion,
|
|
145
186
|
});
|
|
146
187
|
// 生成主题文件
|
|
147
188
|
await (0, generate_1.generateThemeVarsFile)(mainAppData.themeVars, h5BuildDir);
|
|
@@ -160,7 +201,11 @@ async function buildH5App({ buildContext, i18nConfig, extraData, cals: _cals, bu
|
|
|
160
201
|
publicPath,
|
|
161
202
|
domain,
|
|
162
203
|
cdnEndpoints,
|
|
204
|
+
vueVersion,
|
|
163
205
|
});
|
|
206
|
+
if (typeof libNameWithVue === 'string' && !fs_extra_1.default.existsSync(path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'))) {
|
|
207
|
+
fs_extra_1.default.symlinkSync(path_1.default.resolve(h5BuildDir, 'src', 'libraries', libNameWithVue, 'node_modules', 'vue'), path_1.default.resolve(h5BuildDir, 'node_modules', 'vue'));
|
|
208
|
+
}
|
|
164
209
|
await new Promise((resolve, reject) => {
|
|
165
210
|
// 开始编译前清理一下 lowcode 内容
|
|
166
211
|
(0, compile_1.startCompile)({
|
package/lib/builder/h5/npm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IMaterialItem, IWebRuntimeAppData } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
|
-
export declare function handleNPM({ mainAppData, subAppDataList, dependencies, appKey, appBuildDir, mode, devTool, ignoreInstall, }: {
|
|
2
|
+
export declare function handleNPM({ mainAppData, subAppDataList, dependencies, appKey, appBuildDir, mode, devTool, ignoreInstall, vueVersion, }: {
|
|
3
3
|
appKey: string;
|
|
4
4
|
appBuildDir: string;
|
|
5
5
|
mode: string;
|
|
@@ -8,5 +8,6 @@ export declare function handleNPM({ mainAppData, subAppDataList, dependencies, a
|
|
|
8
8
|
dependencies: IMaterialItem[];
|
|
9
9
|
devTool: string;
|
|
10
10
|
ignoreInstall?: boolean;
|
|
11
|
+
vueVersion?: number;
|
|
11
12
|
}): Promise<void>;
|
|
12
|
-
export declare function generatePackageJSON(dependencies: object | undefined, appBuildDir: string, appKey: string, mode: string, devTool: string): Promise<boolean>;
|
|
13
|
+
export declare function generatePackageJSON(dependencies: object | undefined, appBuildDir: string, appKey: string, mode: string, devTool: string, vueVersion?: number): Promise<boolean>;
|
package/lib/builder/h5/npm.js
CHANGED
|
@@ -12,7 +12,7 @@ const config_1 = require("../config");
|
|
|
12
12
|
const generateFiles_1 = require("../util/generateFiles");
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
14
|
const util_1 = require("../util");
|
|
15
|
-
async function handleNPM({ mainAppData, subAppDataList = [], dependencies = [], appKey, appBuildDir, mode, devTool, ignoreInstall = false, }) {
|
|
15
|
+
async function handleNPM({ mainAppData, subAppDataList = [], dependencies = [], appKey, appBuildDir, mode, devTool, ignoreInstall = false, vueVersion = 0, }) {
|
|
16
16
|
const allAppDataList = subAppDataList.concat(mainAppData);
|
|
17
17
|
// 安装 NPM 依赖
|
|
18
18
|
const deps = {};
|
|
@@ -37,7 +37,7 @@ async function handleNPM({ mainAppData, subAppDataList = [], dependencies = [],
|
|
|
37
37
|
// Object.assign(deps, comp.npmDependencies);
|
|
38
38
|
// });
|
|
39
39
|
// });
|
|
40
|
-
const isChange = await generatePackageJSON(deps, appBuildDir, appKey, mode, devTool);
|
|
40
|
+
const isChange = await generatePackageJSON(deps, appBuildDir, appKey, mode, devTool, vueVersion);
|
|
41
41
|
if (!isChange) {
|
|
42
42
|
(0, console_1.notice)('package.json dependencies 已经安装,如出现未安装成功或找不到依赖,请重启wa watch');
|
|
43
43
|
}
|
|
@@ -47,7 +47,7 @@ async function handleNPM({ mainAppData, subAppDataList = [], dependencies = [],
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
exports.handleNPM = handleNPM;
|
|
50
|
-
async function generatePackageJSON(dependencies = {}, appBuildDir, appKey, mode, devTool) {
|
|
50
|
+
async function generatePackageJSON(dependencies = {}, appBuildDir, appKey, mode, devTool, vueVersion = 0) {
|
|
51
51
|
const templatePath = path_1.default.join(config_1.appTemplateDir, 'package.json');
|
|
52
52
|
const dstFilePath = path_1.default.join(appBuildDir, 'package.json');
|
|
53
53
|
const dstTempPath = path_1.default.join(appBuildDir, '.temp', 'package.json');
|
|
@@ -57,6 +57,7 @@ async function generatePackageJSON(dependencies = {}, appBuildDir, appKey, mode,
|
|
|
57
57
|
canUseVite: (0, util_1.canUseVite)(mode, devTool),
|
|
58
58
|
appKey,
|
|
59
59
|
appId: appKey,
|
|
60
|
+
vueVersion: vueVersion === 3 ? '^3' : '^2',
|
|
60
61
|
}));
|
|
61
62
|
const packageInfo = await fs_extra_1.default.readJSON(dstTempPath);
|
|
62
63
|
// weapps-sdk 要与 builder template 版本一致
|
|
@@ -11,6 +11,7 @@ interface IWebpackCoreProps extends BuildAppProps {
|
|
|
11
11
|
subAppDataList: IWebRuntimeAppData[];
|
|
12
12
|
assets: string[];
|
|
13
13
|
cdnEndpoints?: ICDN_ENDPOINTS_COFIG;
|
|
14
|
+
vueVersion?: number;
|
|
14
15
|
}
|
|
15
|
-
export declare function runWebpackCore({ buildContext, cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, assets, devTool, generateMpType, cdnEndpoints, }: IWebpackCoreProps): Promise<string>;
|
|
16
|
+
export declare function runWebpackCore({ buildContext, cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode, appKey, buildTypeList, assets, devTool, generateMpType, cdnEndpoints, vueVersion, }: IWebpackCoreProps): Promise<string>;
|
|
16
17
|
export {};
|
|
@@ -5,7 +5,7 @@ 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({ buildContext, cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP, cdnEndpoints, }) {
|
|
8
|
+
async function runWebpackCore({ buildContext, cals, mainAppData, subAppDataList, appBuildDir, publicPath, mode = common_1.WebpackModeType.NONE, appKey, buildTypeList = [common_1.BuildType.WEB], assets = [], devTool = 'vite', generateMpType = common_1.GenerateMpType.APP, cdnEndpoints, vueVersion = 0, }) {
|
|
9
9
|
var _a;
|
|
10
10
|
console.time('runWebpackCore');
|
|
11
11
|
console.time('webpackGenerate');
|
|
@@ -18,6 +18,7 @@ async function runWebpackCore({ buildContext, cals, mainAppData, subAppDataList,
|
|
|
18
18
|
mode,
|
|
19
19
|
buildTypeList,
|
|
20
20
|
assets,
|
|
21
|
+
vueVersion,
|
|
21
22
|
});
|
|
22
23
|
console.timeEnd('webpackGenerate');
|
|
23
24
|
await (0, generate_1.generateHTML)({
|
|
@@ -31,7 +31,7 @@ export interface IMpConfig {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
export declare function fixAppJson(appBuildDir: string): Promise<void>;
|
|
34
|
-
export declare function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBuildDir, publicPath, mode, buildTypeList, assets, }: {
|
|
34
|
+
export declare function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBuildDir, publicPath, mode, buildTypeList, assets, vueVersion, }: {
|
|
35
35
|
appId: string;
|
|
36
36
|
allAppDataList: IWebRuntimeAppData[];
|
|
37
37
|
appBuildDir: string;
|
|
@@ -39,6 +39,7 @@ export declare function generateWebpackWebBuildParamsFile({ appId, allAppDataLis
|
|
|
39
39
|
mode: WebpackModeType;
|
|
40
40
|
buildTypeList: BuildType[];
|
|
41
41
|
assets: string[];
|
|
42
|
+
vueVersion?: number;
|
|
42
43
|
}): Promise<string>;
|
|
43
44
|
export interface IGenerateMpJsonConfigFileOpts {
|
|
44
45
|
appKey?: string;
|
|
@@ -49,7 +50,7 @@ export declare function downloadAndWriteTabBarIcon(iconPath: any, pagePath: any,
|
|
|
49
50
|
export declare function getMainAppDataByList(allAppDataList: IWebRuntimeAppData[]): IWebRuntimeAppData | undefined;
|
|
50
51
|
export declare function getHomePageInstance(pageInstanceList: any): any;
|
|
51
52
|
export declare function getPageName(name: string): string;
|
|
52
|
-
export declare function getWebpackWebBuildParams(appId: string, appBuildDir: string, publicPath?: string, mode?: WebpackModeType, buildTypeList?: BuildType[], extraDefine?: {}, assets?: string[]): any;
|
|
53
|
+
export declare function getWebpackWebBuildParams(appId: string, appBuildDir: string, publicPath?: string, mode?: WebpackModeType, buildTypeList?: BuildType[], extraDefine?: {}, assets?: string[], vueVersion?: number): any;
|
|
53
54
|
export declare function downloadAndInstallDependencies(dependencies: IMaterialItem[] | undefined, materialsDir: string, installOptions?: IInstallOpts): Promise<void>;
|
|
54
55
|
export declare function downloadDependencies(targetDir: string, srcZipUrl: string): Promise<void>;
|
|
55
56
|
/**
|
|
@@ -39,12 +39,12 @@ async function fixAppJson(appBuildDir) {
|
|
|
39
39
|
await fs_extra_1.default.writeFile(appJsonPath, JSON.stringify(appJson, null, 2));
|
|
40
40
|
}
|
|
41
41
|
exports.fixAppJson = fixAppJson;
|
|
42
|
-
async function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBuildDir, publicPath, mode, buildTypeList, assets = [], }) {
|
|
42
|
+
async function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBuildDir, publicPath, mode, buildTypeList, assets = [], vueVersion = 0, }) {
|
|
43
43
|
let mainAppData = getMainAppDataByList(allAppDataList);
|
|
44
44
|
let extraDefine = {
|
|
45
45
|
'process.env.historyType': `"${mainAppData.historyType || types_1.HISTORY_TYPE.BROWSER}"`,
|
|
46
46
|
};
|
|
47
|
-
const params = getWebpackWebBuildParams(appId, appBuildDir, publicPath, mode, buildTypeList, extraDefine, assets);
|
|
47
|
+
const params = getWebpackWebBuildParams(appId, appBuildDir, publicPath, mode, buildTypeList, extraDefine, assets, vueVersion);
|
|
48
48
|
const webpackConfigPath = path_1.default.resolve(appBuildDir, './webpack/webpack.web.prod.js');
|
|
49
49
|
const paramsString = JSON.stringify(params, null, 2);
|
|
50
50
|
const webpackConfigContent = `const params = ${paramsString};\nmodule.exports = require('./web.prod.js')(params);`;
|
|
@@ -119,7 +119,7 @@ function getPageName(name) {
|
|
|
119
119
|
return `${name}`;
|
|
120
120
|
}
|
|
121
121
|
exports.getPageName = getPageName;
|
|
122
|
-
function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = common_1.WebpackModeType.NONE, buildTypeList = [common_1.BuildType.WEB], extraDefine = {}, assets = []) {
|
|
122
|
+
function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = common_1.WebpackModeType.NONE, buildTypeList = [common_1.BuildType.WEB], extraDefine = {}, assets = [], vueVersion = 0) {
|
|
123
123
|
return {
|
|
124
124
|
context: appBuildDir,
|
|
125
125
|
mode: mode !== common_1.WebpackModeType.PRODUCTION ? 'development' : mode,
|
|
@@ -155,6 +155,7 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
|
|
|
155
155
|
: mode !== common_1.WebpackModeType.PRODUCTION
|
|
156
156
|
? 'eval'
|
|
157
157
|
: false,
|
|
158
|
+
vueVersion,
|
|
158
159
|
};
|
|
159
160
|
}
|
|
160
161
|
exports.getWebpackWebBuildParams = getWebpackWebBuildParams;
|