@cloudbase/lowcode-builder 1.8.45 → 1.8.48
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/index.d.ts +1 -1
- package/lib/builder/config/index.js +1 -1
- package/lib/builder/core/index.js +13 -2
- package/lib/builder/h5/index.js +6 -5
- package/lib/builder/h5/webpack.d.ts +1 -2
- package/lib/builder/h5/webpack.js +1 -8
- package/lib/builder/mp/BuildContext.d.ts +8 -0
- package/lib/builder/mp/index.js +30 -15
- package/lib/builder/mp/lowcode.js +1 -1
- package/lib/builder/mp/materials.js +2 -1
- package/lib/builder/mp/mixMode.js +3 -3
- package/lib/builder/mp/mp_config.js +5 -4
- package/lib/builder/mp/wxml.d.ts +1 -1
- package/lib/builder/mp/wxml.js +102 -80
- package/lib/builder/service/webpack.d.ts +0 -7
- package/lib/builder/service/webpack.js +1 -191
- package/lib/builder/util/common.d.ts +1 -0
- package/lib/builder/util/common.js +12 -1
- package/lib/builder.web.js +1 -1
- package/package.json +5 -4
- package/template/html/index.html.ejs +3 -3
- package/template/mp/common/info/index.js +52 -8
- package/template/mp/common/info/index.wxml +29 -12
- package/template/mp/common/info/index.wxss +27 -10
- package/template/mp/common/util.js +18 -5
- package/template/mp/common/weapp-page.js +19 -1
- package/template/mp/package.json +2 -2
- package/dist/builder.web.js +0 -71
- package/template/.DS_Store +0 -0
- package/template/mp/.DS_Store +0 -0
- package/template/mp/common/.DS_Store +0 -0
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.downloadAssets = exports.generateWebpackWebDevServerFile = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.
|
|
6
|
+
exports.downloadAssets = exports.generateWebpackWebDevServerFile = exports.getMaterialNodeModulesPathList = exports.installDependencies = exports.downloadDependencies = exports.downloadAndInstallDependencies = exports.getWebpackWebBuildParams = exports.getPageName = exports.getHomePageInstance = exports.getMainAppDataByList = exports.downloadAndWriteTabBarIcon = exports.generateKboneTabBarConfig = exports.generateWebpackWebBuildParamsFile = exports.fixAppJson = exports.OUTPUT_DIR = exports.PERSISTENT_DEPENDIENCES_MAP = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const lodash_1 = require("lodash");
|
|
@@ -52,28 +52,6 @@ async function generateWebpackWebBuildParamsFile({ appId, allAppDataList, appBui
|
|
|
52
52
|
return webpackConfigPath;
|
|
53
53
|
}
|
|
54
54
|
exports.generateWebpackWebBuildParamsFile = generateWebpackWebBuildParamsFile;
|
|
55
|
-
async function generateAppConfig(mainAppData, subAppDataList, appBuildDir) {
|
|
56
|
-
let originMpConfig = {};
|
|
57
|
-
// 如果有 mp_config 则读取内容合并。
|
|
58
|
-
const configMod = mainAppData.codeModules.find((p) => p.name === config_1.MP_CONFIG_MODULE_NAME);
|
|
59
|
-
if (configMod) {
|
|
60
|
-
const code = configMod.code.replace(/export\s+default/, '');
|
|
61
|
-
try {
|
|
62
|
-
originMpConfig = eval(`(${code})`);
|
|
63
|
-
}
|
|
64
|
-
catch (e) {
|
|
65
|
-
console.error('Kbone config file error', e);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
// app 配置
|
|
69
|
-
generateKboneAppConfig(originMpConfig, mainAppData);
|
|
70
|
-
// 页面配置
|
|
71
|
-
originMpConfig = generateKbonePageConfig(originMpConfig, mainAppData, subAppDataList);
|
|
72
|
-
// tabbar 配置
|
|
73
|
-
await generateKboneTabBarConfig(originMpConfig, appBuildDir);
|
|
74
|
-
return originMpConfig;
|
|
75
|
-
}
|
|
76
|
-
exports.generateAppConfig = generateAppConfig;
|
|
77
55
|
async function generateKboneTabBarConfig(mpConfig, appBuildDir) {
|
|
78
56
|
mpConfig.appExtraConfig = mpConfig.appExtraConfig || {};
|
|
79
57
|
if (mpConfig.appExtraConfig.tabBar) {
|
|
@@ -120,109 +98,6 @@ async function downloadAndWriteTabBarIcon(iconPath, pagePath, appBuildDir, fileN
|
|
|
120
98
|
});
|
|
121
99
|
}
|
|
122
100
|
exports.downloadAndWriteTabBarIcon = downloadAndWriteTabBarIcon;
|
|
123
|
-
// 将 weapps 配置的 page-data 转换到 mp_config
|
|
124
|
-
function generateKbonePageConfig(mpConfig, mainAppData, subAppDataList = []) {
|
|
125
|
-
mpConfig.pages = mpConfig.pages || {};
|
|
126
|
-
const allAppDataList = subAppDataList.concat(mainAppData);
|
|
127
|
-
allAppDataList.map((appData) => {
|
|
128
|
-
appData.pageInstanceList.forEach((item) => {
|
|
129
|
-
const pageId = [appData.rootPath, item.id].filter((i) => i).join('_');
|
|
130
|
-
if (!mpConfig.pages[pageId]) {
|
|
131
|
-
mpConfig.pages[pageId] = {};
|
|
132
|
-
}
|
|
133
|
-
const navigationBarTitleText = item.data.navigationBarTitleText || item.data.title;
|
|
134
|
-
// 去除部分 mp 不认的属性
|
|
135
|
-
delete item.data.title;
|
|
136
|
-
delete item.data.params;
|
|
137
|
-
delete item.data.scene;
|
|
138
|
-
// page 配置
|
|
139
|
-
config_1.KBONE_PAGE_KEYS.forEach((key) => {
|
|
140
|
-
if (item.data[key]) {
|
|
141
|
-
mpConfig.pages[pageId][key] = item.data[key];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
// extra 配置
|
|
145
|
-
mpConfig.pages[pageId].extra = {
|
|
146
|
-
...item.data,
|
|
147
|
-
navigationBarTitleText,
|
|
148
|
-
};
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
return mpConfig;
|
|
152
|
-
}
|
|
153
|
-
exports.generateKbonePageConfig = generateKbonePageConfig;
|
|
154
|
-
function generateKboneAppConfig(mpConfig, mainAppData) {
|
|
155
|
-
if (mainAppData === null || mainAppData === void 0 ? void 0 : mainAppData.appConfig) {
|
|
156
|
-
if (mainAppData.appConfig.window) {
|
|
157
|
-
mpConfig.app = mpConfig.app || {};
|
|
158
|
-
mpConfig.app = {
|
|
159
|
-
...mainAppData.appConfig.window,
|
|
160
|
-
...mpConfig.app,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
exports.generateKboneAppConfig = generateKboneAppConfig;
|
|
166
|
-
// 生成 kbone mp 配置文件
|
|
167
|
-
async function generateMpJsonConfigFile(allAppDataList, userConfig, appBuildDir, options) {
|
|
168
|
-
const mainAppData = getMainAppDataByList(allAppDataList);
|
|
169
|
-
const subAppDataList = allAppDataList.filter((i) => i.rootPath);
|
|
170
|
-
const homeId = getHomePageInstance(mainAppData.pageInstanceList).id;
|
|
171
|
-
userConfig = userConfig || {};
|
|
172
|
-
const kbConfig = {
|
|
173
|
-
origin: 'https://weapps.tencent.com',
|
|
174
|
-
entry: `/${homeId}`,
|
|
175
|
-
redirect: {
|
|
176
|
-
notFound: `${homeId}`,
|
|
177
|
-
accessDenied: `${homeId}`,
|
|
178
|
-
},
|
|
179
|
-
generate: {
|
|
180
|
-
autoBuildNpm: true,
|
|
181
|
-
appEntry: 'miniprogram-app',
|
|
182
|
-
appWxss: 'display',
|
|
183
|
-
subpackages: {},
|
|
184
|
-
globalVars: [['__injectProxy', '(window.Proxy = Proxy)']],
|
|
185
|
-
},
|
|
186
|
-
app: {
|
|
187
|
-
navigationBarTitleText: `WeApps-${options.appKey}`,
|
|
188
|
-
},
|
|
189
|
-
projectConfig: {
|
|
190
|
-
appid: 'touristappid',
|
|
191
|
-
projectname: `WeApps-${options.appKey}`,
|
|
192
|
-
},
|
|
193
|
-
packageConfig: {
|
|
194
|
-
author: 'weapps',
|
|
195
|
-
},
|
|
196
|
-
...userConfig,
|
|
197
|
-
global: {
|
|
198
|
-
...userConfig.global,
|
|
199
|
-
rem: true, // rem 必须为 true
|
|
200
|
-
},
|
|
201
|
-
router: getMpAllRouterConfig(allAppDataList),
|
|
202
|
-
__homePath__: getMpAllRouterConfig(allAppDataList, true),
|
|
203
|
-
};
|
|
204
|
-
if (subAppDataList === null || subAppDataList === void 0 ? void 0 : subAppDataList.length) {
|
|
205
|
-
const subpackages = {};
|
|
206
|
-
subAppDataList.map((appData) => {
|
|
207
|
-
const { rootPath } = appData;
|
|
208
|
-
subpackages[rootPath] = Object.keys(getMpAllRouterConfig([appData]));
|
|
209
|
-
});
|
|
210
|
-
kbConfig.generate = {
|
|
211
|
-
...kbConfig.generate,
|
|
212
|
-
subpackages,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
// kbone 生成子包模式
|
|
216
|
-
if (options.generateMpType === 'subpackage') {
|
|
217
|
-
kbConfig.generate = {
|
|
218
|
-
...kbConfig.generate,
|
|
219
|
-
app: 'noemit',
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
const templateStr = JSON.stringify(kbConfig, null, 2);
|
|
223
|
-
await fs_extra_1.default.writeFile(path_1.default.resolve(appBuildDir, 'webpack/miniprogram.config.js'), `export default = ${templateStr}`);
|
|
224
|
-
}
|
|
225
|
-
exports.generateMpJsonConfigFile = generateMpJsonConfigFile;
|
|
226
101
|
function getMainAppDataByList(allAppDataList) {
|
|
227
102
|
return allAppDataList.find((item) => !item.rootPath);
|
|
228
103
|
}
|
|
@@ -244,29 +119,6 @@ function getPageName(name) {
|
|
|
244
119
|
return `${name}`;
|
|
245
120
|
}
|
|
246
121
|
exports.getPageName = getPageName;
|
|
247
|
-
function getMpAllRouterConfig(allAppDataList, getHome = false) {
|
|
248
|
-
const router = {};
|
|
249
|
-
let homePath = '';
|
|
250
|
-
allAppDataList.map((appData) => {
|
|
251
|
-
const { pageInstanceList, rootPath = '' } = appData;
|
|
252
|
-
(0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
|
|
253
|
-
const name = [rootPath, pageInstance.id].filter((i) => i).join('_');
|
|
254
|
-
const path = `/${name}`;
|
|
255
|
-
if (!homePath) {
|
|
256
|
-
homePath = name;
|
|
257
|
-
}
|
|
258
|
-
if (pageInstance.isHome && !rootPath) {
|
|
259
|
-
homePath = name;
|
|
260
|
-
}
|
|
261
|
-
router[name] = [path];
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
if (getHome) {
|
|
265
|
-
return homePath;
|
|
266
|
-
}
|
|
267
|
-
return router;
|
|
268
|
-
}
|
|
269
|
-
exports.getMpAllRouterConfig = getMpAllRouterConfig;
|
|
270
122
|
function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = common_1.WebpackModeType.NONE, buildTypeList = [common_1.BuildType.WEB], extraDefine = {}, assets = []) {
|
|
271
123
|
return {
|
|
272
124
|
context: appBuildDir,
|
|
@@ -306,48 +158,6 @@ function getWebpackWebBuildParams(appId, appBuildDir, publicPath = '/', mode = c
|
|
|
306
158
|
};
|
|
307
159
|
}
|
|
308
160
|
exports.getWebpackWebBuildParams = getWebpackWebBuildParams;
|
|
309
|
-
function getWebpackMpBuildParams(appBuildDir, materialsDir, dependencies = [], nodeModulesPath, allAppDataList, mode, watch, options) {
|
|
310
|
-
return {
|
|
311
|
-
context: appBuildDir,
|
|
312
|
-
mode,
|
|
313
|
-
watch,
|
|
314
|
-
entry: getAllPageMpEntryPath(allAppDataList, appBuildDir),
|
|
315
|
-
outputPath: path_1.default.resolve(appBuildDir, 'dist/mp/common'),
|
|
316
|
-
resolveModules: [
|
|
317
|
-
appBuildDir,
|
|
318
|
-
path_1.default.resolve(appBuildDir, 'node_modules'),
|
|
319
|
-
path_1.default.resolve(appBuildDir, 'src'),
|
|
320
|
-
...getMaterialNodeModulesPathList(dependencies, materialsDir, appBuildDir),
|
|
321
|
-
'node_modules',
|
|
322
|
-
],
|
|
323
|
-
watchOptions: {
|
|
324
|
-
ignored: /node_modules/,
|
|
325
|
-
aggregateTimeout: 600,
|
|
326
|
-
poll: 1000,
|
|
327
|
-
},
|
|
328
|
-
cache: {
|
|
329
|
-
type: 'memory',
|
|
330
|
-
},
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
exports.getWebpackMpBuildParams = getWebpackMpBuildParams;
|
|
334
|
-
function getAllPageMpEntryPath(allAppDataList, appBuildDir) {
|
|
335
|
-
const entry = {};
|
|
336
|
-
// 优先填首页
|
|
337
|
-
const mainAppData = getMainAppDataByList(allAppDataList);
|
|
338
|
-
const homePageInstance = getHomePageInstance(mainAppData.pageInstanceList);
|
|
339
|
-
entry[homePageInstance.id] = path_1.default.resolve(appBuildDir, `src/pages/${getPageName(homePageInstance.id)}/main.mp.jsx`);
|
|
340
|
-
allAppDataList.map((app) => {
|
|
341
|
-
const { pageInstanceList, rootPath } = app;
|
|
342
|
-
const packagePathStr = rootPath ? `packages/${rootPath}` : '';
|
|
343
|
-
(0, weapps_core_1.loopDealWithFn)(pageInstanceList, (pageInstance) => {
|
|
344
|
-
const pageName = rootPath ? `${rootPath}_${pageInstance.id}` : pageInstance.id;
|
|
345
|
-
entry[pageName] = path_1.default.resolve(appBuildDir, path_1.default.join('src', packagePathStr, `pages/${getPageName(pageInstance.id)}/main.mp.jsx`));
|
|
346
|
-
});
|
|
347
|
-
});
|
|
348
|
-
return entry;
|
|
349
|
-
}
|
|
350
|
-
exports.getAllPageMpEntryPath = getAllPageMpEntryPath;
|
|
351
161
|
async function downloadAndInstallDependencies(dependencies = [], materialsDir, installOptions = {}) {
|
|
352
162
|
const localPkg = (0, util_1.getCurrentPackageJson)();
|
|
353
163
|
await Promise.all(dependencies.map(async (item) => {
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
6
|
+
exports.normalizePackageName = exports.generateLowcodeImportor = exports.getCompileDirs = exports.deepDealComponentSchemaJson = exports.canUseVite = exports.isOfficialComponentLib = exports.readComponentLibMata = exports.writeLibCommonRes2file = exports.getYyptConfigInfo = exports.getComponentsInfo = exports.getInputProps = exports.removeRequireUncached = exports.requireUncached = exports.JsonToStringWithVariableName = exports.getSelfPackageJson = exports.getCurrentPackageJson = exports.promiseWrapper = exports.getFileNameByUrl = exports.deepDealSchema = exports.simpleDeepClone = exports.deepDeal = exports.isPlainObject = exports.isArray = exports.getMetaInfoBySourceKey = void 0;
|
|
7
7
|
// import * as R from 'ramda'
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
@@ -290,3 +290,14 @@ function generateLowcodeImportor(lowcodes = []) {
|
|
|
290
290
|
return importor;
|
|
291
291
|
}
|
|
292
292
|
exports.generateLowcodeImportor = generateLowcodeImportor;
|
|
293
|
+
function normalizePackageName(packageName) {
|
|
294
|
+
if (!packageName) {
|
|
295
|
+
return packageName;
|
|
296
|
+
}
|
|
297
|
+
const matched = packageName.match(/packages\/(.*)?/);
|
|
298
|
+
if (matched) {
|
|
299
|
+
return matched[1];
|
|
300
|
+
}
|
|
301
|
+
return packageName;
|
|
302
|
+
}
|
|
303
|
+
exports.normalizePackageName = normalizePackageName;
|