@cloudbase/lowcode-builder 1.2.1-alpha.1 → 1.2.2
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/core/index.js +7 -1
- package/lib/builder/h5/material.js +0 -28
- package/lib/builder/mp/BuildContext.d.ts +1 -0
- package/lib/builder/mp/index.d.ts +2 -3
- package/lib/builder/mp/index.js +21 -21
- package/lib/builder/mp/lowcode.d.ts +2 -2
- package/lib/builder/mp/lowcode.js +2 -2
- package/lib/builder/mp/materials.js +17 -12
- package/lib/builder/mp/util.d.ts +6 -7
- package/lib/builder/mp/util.js +11 -11
- package/lib/builder/service/webpack.js +0 -1
- package/lib/builder/util/generateFiles.d.ts +1 -1
- package/lib/builder/util/generateFiles.js +1 -1
- package/package.json +2 -2
- package/template/html/index.html.ejs +1 -1
- package/template/mp/common/util.js +80 -57
- package/template/mp/common/weapp-component.js +1 -1
- package/template/package.json +2 -2
- package/template/webpack/web.prod.js +3 -39
|
@@ -15,6 +15,7 @@ const mixMode_1 = require("../mp/mixMode");
|
|
|
15
15
|
const index_2 = require("../h5/index");
|
|
16
16
|
const common_2 = require("../../utils/common");
|
|
17
17
|
const postProcess_1 = require("../../utils/postProcess");
|
|
18
|
+
const cals_1 = require("@cloudbase/cals");
|
|
18
19
|
const net_1 = require("../util/net");
|
|
19
20
|
const pkg = require('../../../package.json');
|
|
20
21
|
async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appKey = 'test', runtime = types_1.RUNTIME.NONE, ignoreInstall = false, buildTypeList = [common_1.BuildType.WEB], mode = common_1.WebpackModeType.PRODUCTION, devTool = 'webpack', deployOptions = { mode: types_1.DEPLOY_MODE.PREVIEW }, generateMpType = common_1.GenerateMpType.APP, plugins = [], extraData = {
|
|
@@ -58,6 +59,12 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
58
59
|
...buildContext,
|
|
59
60
|
projDir: (output === null || output === void 0 ? void 0 : output.path) || path_1.default.join(appBuildDir, 'mp'),
|
|
60
61
|
mainAppData: mainAppSerializeData,
|
|
62
|
+
processCssUnit: ([cals, ...subAppCalsList].find((cals) => {
|
|
63
|
+
const FEATURE_MAP = (0, cals_1.parseVersion)(cals.schemaVersion);
|
|
64
|
+
return !FEATURE_MAP.defaultDynamicCssUnit;
|
|
65
|
+
})
|
|
66
|
+
? 'px'
|
|
67
|
+
: 'rpx'),
|
|
61
68
|
};
|
|
62
69
|
const result = await (0, index_1.generateWxMp)({
|
|
63
70
|
weapps: apps,
|
|
@@ -70,7 +77,6 @@ async function buildWedaApp({ cals, subAppCalsList = [], dependencies = [], appK
|
|
|
70
77
|
resourceAppId,
|
|
71
78
|
},
|
|
72
79
|
buildTypeList,
|
|
73
|
-
isBrowserMpBuilder,
|
|
74
80
|
ignoreInstall,
|
|
75
81
|
});
|
|
76
82
|
// 如果是混合模式,则将特定的目录复制到工程下
|
|
@@ -143,31 +143,3 @@ async function handleNormalMaterial({ dependencies: normalDependencies, material
|
|
|
143
143
|
};
|
|
144
144
|
}));
|
|
145
145
|
}
|
|
146
|
-
// async function handleCompositeComponent({ dependencies, appBuildDir }) {
|
|
147
|
-
// console.time('handleCompositeComponent');
|
|
148
|
-
// const compositeDependencies: IMaterialItem[] = dependencies.filter(
|
|
149
|
-
// (item) => item.isComposite
|
|
150
|
-
// );
|
|
151
|
-
// const materialGroupInfoMap = {};
|
|
152
|
-
// dependencies.forEach(
|
|
153
|
-
// (item) =>
|
|
154
|
-
// (materialGroupInfoMap[item.name] = {
|
|
155
|
-
// isComposite: item.isComposite,
|
|
156
|
-
// version: item.version,
|
|
157
|
-
// entries: item.entries,
|
|
158
|
-
// schemaVersion: item.schemaVersion,
|
|
159
|
-
// })
|
|
160
|
-
// );
|
|
161
|
-
// const componentsMeta = await getComponentsInfo(
|
|
162
|
-
// path.join(appBuildDir, 'src'),
|
|
163
|
-
// dependencies
|
|
164
|
-
// );
|
|
165
|
-
// await writeLowCodeFilesForCompositeComp(compositeDependencies, appBuildDir);
|
|
166
|
-
// await genCompositeComponentLibraries(
|
|
167
|
-
// compositeDependencies,
|
|
168
|
-
// appBuildDir,
|
|
169
|
-
// materialGroupInfoMap,
|
|
170
|
-
// componentsMeta
|
|
171
|
-
// );
|
|
172
|
-
// console.timeEnd('handleCompositeComponent');
|
|
173
|
-
// }
|
|
@@ -2,7 +2,7 @@ import { IWeAppData, IPlugin } from '@cloudbase/lowcode-generator/lib/weapps-cor
|
|
|
2
2
|
import { IBuildContext } from './BuildContext';
|
|
3
3
|
import { DEPLOY_MODE } from '../../types';
|
|
4
4
|
import { BuildType, IAppUsedComp, IUsedComps } from '../types/common';
|
|
5
|
-
export declare function generateWxMp({ buildContext, weapps, plugins, deployMode, options, buildTypeList,
|
|
5
|
+
export declare function generateWxMp({ buildContext, weapps, plugins, deployMode, options, buildTypeList, ignoreInstall, }: {
|
|
6
6
|
buildContext: IBuildContext;
|
|
7
7
|
weapps: IWeAppData[];
|
|
8
8
|
plugins: IPlugin[];
|
|
@@ -13,12 +13,11 @@ export declare function generateWxMp({ buildContext, weapps, plugins, deployMode
|
|
|
13
13
|
isCrossAccount: boolean;
|
|
14
14
|
};
|
|
15
15
|
buildTypeList: BuildType[];
|
|
16
|
-
isBrowserMpBuilder: boolean;
|
|
17
16
|
ignoreInstall: boolean;
|
|
18
17
|
}): Promise<{
|
|
19
18
|
miniprogramRoot: string;
|
|
20
19
|
}>;
|
|
21
|
-
export declare function writeLowCodeFiles(appData: IWeAppData, outDir: string
|
|
20
|
+
export declare function writeLowCodeFiles(ctx: IBuildContext, appData: IWeAppData, outDir: string): Promise<void>;
|
|
22
21
|
/**
|
|
23
22
|
* TODO: 与 cals 里的实现进行整合
|
|
24
23
|
* 关键点在于 appUsedComps 分组, 与 generic componen 的实现
|
package/lib/builder/mp/index.js
CHANGED
|
@@ -54,9 +54,9 @@ const cals_1 = require("@cloudbase/cals");
|
|
|
54
54
|
const templateDir = `${config_1.appTemplateDir}/mp/`;
|
|
55
55
|
const em = chalk_1.default.blue.bold;
|
|
56
56
|
const error = chalk_1.default.redBright;
|
|
57
|
-
async function generateWxMp({ buildContext, weapps, plugins, deployMode, options, buildTypeList,
|
|
57
|
+
async function generateWxMp({ buildContext, weapps, plugins, deployMode, options, buildTypeList, ignoreInstall = false, }) {
|
|
58
58
|
var _a;
|
|
59
|
-
const { appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', } = buildContext;
|
|
59
|
+
const { appId, projDir, materialLibs: materials, isProduction, mainAppData, domain, isPrivateMode = false, endpointType = '', isBrowserMpBuilder = false, } = buildContext;
|
|
60
60
|
const operationLabel = em('Wexin MiniProgram Generated');
|
|
61
61
|
console.time(operationLabel);
|
|
62
62
|
console.log(`Generating ${em('Wexin MiniProgram')} to ${projDir}`);
|
|
@@ -72,10 +72,10 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
72
72
|
'project.config.json': { content: projConfig },
|
|
73
73
|
};
|
|
74
74
|
console.log(`Generating ${em('project')} files`);
|
|
75
|
-
await (0, generateFiles_1.default)(projectFileData, templateDir, projDir
|
|
75
|
+
await (0, generateFiles_1.default)(buildContext, projectFileData, templateDir, projDir);
|
|
76
76
|
}
|
|
77
77
|
// #2 生成主包
|
|
78
|
-
await generatePkg(mainAppData, path_1.default.join(projDir, '/'),
|
|
78
|
+
await generatePkg({ ...buildContext, rootPath: mainAppData.rootPath }, mainAppData, path_1.default.join(projDir, '/'), pageConfigs[0]);
|
|
79
79
|
const projectConfigJsonPath = path_1.default.join(projDir, mainAppData.rootPath || '', 'project.config.json');
|
|
80
80
|
let projectConfigJson = await fs.readJSON(projectConfigJsonPath);
|
|
81
81
|
const miniprogramRoot = path_1.default.join(projDir, projectConfigJson.miniprogramRoot || '/');
|
|
@@ -155,7 +155,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
console.log(`Generating ${em('miniprogramRoot')} files`);
|
|
158
|
-
await (0, generateFiles_1.default)(appFileData, templateDir, miniprogramRoot
|
|
158
|
+
await (0, generateFiles_1.default)(buildContext, appFileData, templateDir, miniprogramRoot);
|
|
159
159
|
// 若项目目录与小程序根目录不同,则拷贝素材到小程序根目录
|
|
160
160
|
if (miniprogramRoot !== path_1.default.join(projDir, '/') && fs.existsSync(path_1.default.join(projDir, config_1.materialsDirName))) {
|
|
161
161
|
console.log(`Move ${em(config_1.materialsDirName)} from` + `${projDir} to ${miniprogramRoot}`);
|
|
@@ -187,7 +187,7 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
187
187
|
},
|
|
188
188
|
};
|
|
189
189
|
console.log(`Generating ${em('datasources')} files`);
|
|
190
|
-
await (0, generateFiles_1.default)(datasourceFileData, templateDir, miniprogramRoot
|
|
190
|
+
await (0, generateFiles_1.default)(buildContext, datasourceFileData, templateDir, miniprogramRoot);
|
|
191
191
|
}
|
|
192
192
|
// 生成子包
|
|
193
193
|
await Promise.all(weapps.map(async (app, index) => {
|
|
@@ -200,18 +200,18 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
200
200
|
...buildContext,
|
|
201
201
|
rootPath: app.rootPath,
|
|
202
202
|
};
|
|
203
|
-
await generatePkg(app, subpackageRootPath,
|
|
203
|
+
await generatePkg(subpackageBuildCtx, app, subpackageRootPath, pageConfigs[index]);
|
|
204
204
|
await generateFramework(app, subpackageRootPath, subpackageBuildCtx);
|
|
205
205
|
// 生成package.json
|
|
206
206
|
let packageJsonPath = path_1.default.join(subpackageRootPath, 'package.json');
|
|
207
207
|
if (!fs.existsSync(packageJsonPath)) {
|
|
208
|
-
await (0, generateFiles_1.default)({
|
|
208
|
+
await (0, generateFiles_1.default)(buildContext, {
|
|
209
209
|
'package.json': {
|
|
210
210
|
appId,
|
|
211
211
|
importJSSDK: endpointType === 'tcb-api',
|
|
212
212
|
extraDeps: resolveNpmDeps(),
|
|
213
213
|
},
|
|
214
|
-
}, templateDir, subpackageRootPath
|
|
214
|
+
}, templateDir, subpackageRootPath);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}));
|
|
@@ -274,9 +274,10 @@ async function generateWxMp({ buildContext, weapps, plugins, deployMode, options
|
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
exports.generateWxMp = generateWxMp;
|
|
277
|
-
async function generatePkg(weapp, appRoot,
|
|
277
|
+
async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
|
|
278
278
|
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
|
|
279
279
|
console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
|
|
280
|
+
const { processCssUnit = 'rpx' } = ctx;
|
|
280
281
|
if (weapp.mpPkgUrl) {
|
|
281
282
|
// 清空历史文件,使用zip覆盖
|
|
282
283
|
console.log(`Removing ${appRoot}`);
|
|
@@ -302,12 +303,12 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
302
303
|
const pageFileData = {
|
|
303
304
|
[`api.js|api.js`]: {},
|
|
304
305
|
[`index.js|${pageFileName}.js`]: {
|
|
305
|
-
widgetProps: (0, util_2.createWidgetProps)(page.componentInstances
|
|
306
|
+
widgetProps: (0, util_2.createWidgetProps)(ctx, page.componentInstances),
|
|
306
307
|
pageUUID: rootPath ? `${rootPath}/${page.id}` : page.id,
|
|
307
308
|
pageName: page.id,
|
|
308
309
|
pageSource: page.data.src || '',
|
|
309
|
-
eventHanlders: (0, util_2.createEventHanlders)(page.componentInstances, 'this',
|
|
310
|
-
dataBinds: (0, util_2.createDataBinds)(page.componentInstances
|
|
310
|
+
eventHanlders: (0, util_2.createEventHanlders)(ctx, page.componentInstances, 'this', page),
|
|
311
|
+
dataBinds: (0, util_2.createDataBinds)(ctx, page.componentInstances),
|
|
311
312
|
pageAttributes: {
|
|
312
313
|
...(((_a = page.data) === null || _a === void 0 ? void 0 : _a.appShareMessage) ? { appShareMessage: page.data.appShareMessage.value } : {}),
|
|
313
314
|
},
|
|
@@ -330,17 +331,16 @@ async function generatePkg(weapp, appRoot, ctx, pageConfigs) {
|
|
|
330
331
|
? `@import "${path_1.default.posix.relative(`/${rootPath}/pages/${page.id}`, '/lowcode')}/style.wxss";`
|
|
331
332
|
: '',
|
|
332
333
|
content: (0, weapps_core_1.toCssText)((0, cals_1.processCommonStyle2CSSProperties)(page.commonStyle, {
|
|
333
|
-
|
|
334
|
-
toRpx: true,
|
|
334
|
+
defaultUnit: processCssUnit,
|
|
335
335
|
}), 'page'),
|
|
336
336
|
pageWxss: importor.styles.length ? `@import "../../lowcode/${page.id}/style.wxss"` : '',
|
|
337
337
|
},
|
|
338
338
|
};
|
|
339
339
|
// Generating file by template and data
|
|
340
|
-
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id)
|
|
340
|
+
await (0, generateFiles_1.default)(ctx, pageFileData, `${templateDir}/page`, path_1.default.join(appRoot, 'pages', page.id));
|
|
341
341
|
}));
|
|
342
342
|
// #3 writing lowcode files
|
|
343
|
-
await writeLowCodeFiles(weapp, appRoot
|
|
343
|
+
await writeLowCodeFiles(ctx, weapp, appRoot);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
async function generateFramework(appData, outDir, ctx) {
|
|
@@ -408,9 +408,9 @@ async function generateFramework(appData, outDir, ctx) {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
console.log('Generate app framework');
|
|
411
|
-
await (0, generateFiles_1.default)(fileData, templateDir, outDir
|
|
411
|
+
await (0, generateFiles_1.default)(ctx, fileData, templateDir, outDir);
|
|
412
412
|
}
|
|
413
|
-
async function writeLowCodeFiles(appData, outDir
|
|
413
|
+
async function writeLowCodeFiles(ctx, appData, outDir) {
|
|
414
414
|
console.log(`Writing ${em('lowcode')} files:`);
|
|
415
415
|
const lowcodeRootDir = path_1.default.join(outDir, 'lowcode');
|
|
416
416
|
const lowCodes = (0, cals_1.processRuntimeCodeResources)({ id: 'global' }, appData.lowCodes || appData.codeModules, 'app');
|
|
@@ -420,7 +420,7 @@ async function writeLowCodeFiles(appData, outDir, ctx) {
|
|
|
420
420
|
await Promise.all(lowCodes
|
|
421
421
|
.filter((mod) => mod.type !== cals_1.ECodeType.RENDERER)
|
|
422
422
|
.map((m) => {
|
|
423
|
-
(0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { appDir: outDir }, themeStyle.code);
|
|
423
|
+
(0, lowcode_1.writeCode2file)(ctx, m, lowcodeRootDir, { appDir: outDir }, themeStyle.code);
|
|
424
424
|
}));
|
|
425
425
|
}
|
|
426
426
|
await Promise.all((0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList, async (page) => {
|
|
@@ -428,7 +428,7 @@ async function writeLowCodeFiles(appData, outDir, ctx) {
|
|
|
428
428
|
await codes
|
|
429
429
|
.filter((mod) => mod.type !== cals_1.ECodeType.RENDERER)
|
|
430
430
|
.forEach((m) => {
|
|
431
|
-
(0, lowcode_1.writeCode2file)(m, lowcodeRootDir, { pageId: page.id, appDir: outDir }, themeStyle.code
|
|
431
|
+
(0, lowcode_1.writeCode2file)(ctx, m, lowcodeRootDir, { pageId: page.id, appDir: outDir }, themeStyle.code);
|
|
432
432
|
});
|
|
433
433
|
}));
|
|
434
434
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { IWeAppCode, ICompositedComponent } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { IBuildContext } from './BuildContext';
|
|
3
|
-
export declare function writeCode2file(mod: IWeAppCode, lowcodeRootDir: string, opts?: {
|
|
3
|
+
export declare function writeCode2file(ctx: IBuildContext, mod: IWeAppCode, lowcodeRootDir: string, opts?: {
|
|
4
4
|
pageId?: string;
|
|
5
5
|
appDir?: string;
|
|
6
6
|
comp?: ICompositedComponent;
|
|
7
|
-
}, themeCode?: ''
|
|
7
|
+
}, themeCode?: ''): Promise<void>;
|
|
8
8
|
export declare function handle$page(code: string): string;
|
|
9
9
|
export declare function handle$comp(code: string): string;
|
|
@@ -9,7 +9,7 @@ const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
|
9
9
|
const style_1 = require("@cloudbase/lowcode-generator/lib/generator/util/style");
|
|
10
10
|
const generateFiles_1 = require("../util/generateFiles");
|
|
11
11
|
const cals_1 = require("@cloudbase/cals");
|
|
12
|
-
async function writeCode2file(mod, lowcodeRootDir, opts = {}, themeCode
|
|
12
|
+
async function writeCode2file(ctx, mod, lowcodeRootDir, opts = {}, themeCode) {
|
|
13
13
|
const { pageId = 'global', appDir, comp } = opts;
|
|
14
14
|
const file = path_1.default.join(lowcodeRootDir, (0, weapps_core_1.getCodeModuleFilePath)(pageId || 'global', mod, { style: '.wxss' }));
|
|
15
15
|
let { code } = mod;
|
|
@@ -40,7 +40,7 @@ async function writeCode2file(mod, lowcodeRootDir, opts = {}, themeCode, ctx) {
|
|
|
40
40
|
code = `.${(0, weapps_core_1.getCompositedComponentClass)(comp)} {\n${code}\n}`;
|
|
41
41
|
}
|
|
42
42
|
try {
|
|
43
|
-
code = await (0, style_1.
|
|
43
|
+
code = await (0, style_1.processMpLess)(`${code}`, ctx.processCssUnit);
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
46
|
console.error('processLess Error', e);
|
|
@@ -172,11 +172,12 @@ async function installMaterials(projDir, usedComps, weapps, ctx) {
|
|
|
172
172
|
console.log(`Generate composited library ${lib.name}`);
|
|
173
173
|
await (0, util_2.writeLibCommonRes2file)(lib, path.join(ctx.projDir, config_1.materialsDirName, lib.name, 'libCommonRes'));
|
|
174
174
|
await Promise.all(lib.components.map(async (cmp) => {
|
|
175
|
-
return generateCompositeComponent(
|
|
175
|
+
return generateCompositeComponent({
|
|
176
176
|
...ctx,
|
|
177
|
+
processCssUnit: 'rpx',
|
|
177
178
|
// 只生成在主目录中,减少冗余
|
|
178
179
|
// rootPath: app.rootPath || '', // 主包是没有 rootPath 的
|
|
179
|
-
}, lib.compLibCommonResource);
|
|
180
|
+
}, cmp, lib.compLibCommonResource);
|
|
180
181
|
}));
|
|
181
182
|
}));
|
|
182
183
|
}
|
|
@@ -231,18 +232,22 @@ async function downloadMaterial(zipUrl, dstFolder, isBrowser = false) {
|
|
|
231
232
|
return;
|
|
232
233
|
await (0, net_1.downloadZip)(zipUrl, dstFolder, isBrowser);
|
|
233
234
|
}
|
|
234
|
-
async function generateCompositeComponent(
|
|
235
|
+
async function generateCompositeComponent(ctx, compositedComp, compLibCommonResource) {
|
|
236
|
+
const compositeCtx = {
|
|
237
|
+
...ctx,
|
|
238
|
+
isPage: false,
|
|
239
|
+
};
|
|
235
240
|
const { materialName } = compositedComp;
|
|
236
|
-
const outDir = path.join(
|
|
241
|
+
const outDir = path.join(compositeCtx.projDir, compositeCtx.rootPath || '', // 混合模式下,可能会有 rootPath
|
|
237
242
|
config_1.materialsDirName, materialName, compositedComp.name);
|
|
238
243
|
const LOWCODE_DIR_NAME = 'lowcode';
|
|
239
244
|
console.log(`Generating composited component ${materialName}:${compositedComp.name} to ${outDir}`);
|
|
240
|
-
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!
|
|
245
|
+
const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!compositeCtx.isProduction);
|
|
241
246
|
// # Generating page
|
|
242
247
|
const usingComponents = {};
|
|
243
248
|
const componentGenerics = {};
|
|
244
249
|
const cmpContainer = Object.values(compositedComp.componentInstances)[0];
|
|
245
|
-
const wxml = (0, wxml_1.generateWxml)(compositedComp.componentInstances, `Component ${materialName}:${compositedComp.name}`, wxmlDataPrefix,
|
|
250
|
+
const wxml = (0, wxml_1.generateWxml)(compositedComp.componentInstances, `Component ${materialName}:${compositedComp.name}`, wxmlDataPrefix, compositeCtx, usingComponents, componentGenerics, (cmp, node) => {
|
|
246
251
|
if (cmp === cmpContainer) {
|
|
247
252
|
// Set className & style passed from parent for root component
|
|
248
253
|
const { attributes } = node;
|
|
@@ -279,15 +284,15 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
279
284
|
handlers: compositedComp.lowCodes
|
|
280
285
|
.filter((m) => m.type === cals_1.ECodeType.HANDLER_FN && m.name !== cals_1.ECodeName.PLACEHOLDER)
|
|
281
286
|
.map((m) => m.name),
|
|
282
|
-
eventHandlers: (0, util_3.createEventHanlders)(compositedComp.componentInstances, weapps_core_1.COMPONENT_API_PREFIX
|
|
287
|
+
eventHandlers: (0, util_3.createEventHanlders)(compositeCtx, compositedComp.componentInstances, weapps_core_1.COMPONENT_API_PREFIX),
|
|
283
288
|
// protectEventKeys: builtinMpEvents,
|
|
284
289
|
emitEvents: compositedComp.emitEvents.map((evt) => evt.eventName),
|
|
285
|
-
widgetProps: (0, util_3.createWidgetProps)(compositedComp.componentInstances
|
|
290
|
+
widgetProps: (0, util_3.createWidgetProps)(compositeCtx, compositedComp.componentInstances),
|
|
286
291
|
compApi: weapps_core_1.COMPONENT_API_PREFIX,
|
|
287
292
|
jsonSchemaType2jsClass: mp_1.jsonSchemaType2jsClass,
|
|
288
293
|
key: `${compositedComp.materialName}:${compositedComp.name}`,
|
|
289
|
-
dataBinds: (0, util_3.createDataBinds)(compositedComp.componentInstances
|
|
290
|
-
debug: !
|
|
294
|
+
dataBinds: (0, util_3.createDataBinds)(compositeCtx, compositedComp.componentInstances),
|
|
295
|
+
debug: !compositeCtx.isProduction,
|
|
291
296
|
stringifyObj: util_1.inspect,
|
|
292
297
|
// dataPropNames: wxmlDataPrefix,
|
|
293
298
|
formEvents: Object.keys(formEvents).length > 0 ? formEvents : null,
|
|
@@ -305,7 +310,7 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
305
310
|
},
|
|
306
311
|
};
|
|
307
312
|
// Generating file by template and data
|
|
308
|
-
await (0, generateFiles_1.default)(pageFileData, `${templateDir}/component`, outDir
|
|
313
|
+
await (0, generateFiles_1.default)(compositeCtx, pageFileData, `${templateDir}/component`, outDir);
|
|
309
314
|
// #3 writing lowcode files
|
|
310
315
|
/**
|
|
311
316
|
* 低码没有开放 index 类别,直接去掉
|
|
@@ -333,7 +338,7 @@ async function generateCompositeComponent(compositedComp, ctx, compLibCommonReso
|
|
|
333
338
|
if (mod.name === 'index') {
|
|
334
339
|
return;
|
|
335
340
|
}
|
|
336
|
-
return (0, lowcode_1.writeCode2file)(mod, path.join(outDir, LOWCODE_DIR_NAME), { comp: compositedComp }, themeCode
|
|
341
|
+
return (0, lowcode_1.writeCode2file)(compositeCtx, mod, path.join(outDir, LOWCODE_DIR_NAME), { comp: compositedComp }, themeCode);
|
|
337
342
|
});
|
|
338
343
|
// await writeLowCodeFiles(weapp, appRoot)
|
|
339
344
|
// await generateFramework(weapp, appRoot)
|
package/lib/builder/mp/util.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { IDynamicValue, IWeAppComponentInstance, ICompositedComponent, IWeAppPage } from '@cloudbase/lowcode-generator/lib/weapps-core';
|
|
2
2
|
import { IBuildContext } from './BuildContext';
|
|
3
|
-
export declare function extractWidgetProps(props: Required<IWeAppComponentInstance>['xProps'], compInfo: ICompositedComponent): any;
|
|
4
3
|
export declare function generatedDynamicData(data: {
|
|
5
4
|
[key: string]: IDynamicValue;
|
|
6
5
|
}, compInfo?: ICompositedComponent): {
|
|
7
6
|
staticProps: {};
|
|
8
7
|
boundProps: {};
|
|
9
8
|
};
|
|
10
|
-
export declare function createWidgetProps(widgets: {
|
|
9
|
+
export declare function createWidgetProps(ctx: IBuildContext, widgets: {
|
|
11
10
|
[key: string]: IWeAppComponentInstance;
|
|
12
|
-
}
|
|
13
|
-
export declare function createEventHanlders(widgets: {
|
|
11
|
+
}): {};
|
|
12
|
+
export declare function createEventHanlders(ctx: IBuildContext, widgets: {
|
|
14
13
|
[key: string]: IWeAppComponentInstance;
|
|
15
|
-
}, componentApi: string,
|
|
16
|
-
export declare function createDataBinds(widgets: {
|
|
14
|
+
}, componentApi: string, page?: IWeAppPage): {};
|
|
15
|
+
export declare function createDataBinds(ctx: IBuildContext, widgets: {
|
|
17
16
|
[key: string]: IWeAppComponentInstance;
|
|
18
|
-
}
|
|
17
|
+
}): {};
|
package/lib/builder/mp/util.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDataBinds = exports.createEventHanlders = exports.createWidgetProps = exports.generatedDynamicData =
|
|
3
|
+
exports.createDataBinds = exports.createEventHanlders = exports.createWidgetProps = exports.generatedDynamicData = void 0;
|
|
4
4
|
const weapps_core_1 = require("@cloudbase/lowcode-generator/lib/weapps-core");
|
|
5
5
|
const lowcode_generator_1 = require("@cloudbase/lowcode-generator");
|
|
6
6
|
const weapp_1 = require("@cloudbase/lowcode-generator/lib/generator/util/weapp");
|
|
7
7
|
const wxml_1 = require("./wxml");
|
|
8
8
|
const mp_1 = require("@cloudbase/lowcode-generator/lib/generator/config/mp");
|
|
9
9
|
const cals_1 = require("@cloudbase/cals");
|
|
10
|
-
function extractWidgetProps(props, compInfo) {
|
|
10
|
+
function extractWidgetProps(props, compInfo, processCssUnit = 'rpx') {
|
|
11
11
|
var _a, _b;
|
|
12
12
|
const { classList } = props;
|
|
13
13
|
const staticProps = {
|
|
14
14
|
style: (0, cals_1.processCommonStyle2CSSProperties)(props.commonStyle, {
|
|
15
|
-
|
|
16
|
-
toRem: false,
|
|
15
|
+
defaultUnit: processCssUnit,
|
|
17
16
|
}),
|
|
18
17
|
classList: classList || [],
|
|
19
18
|
};
|
|
@@ -24,7 +23,6 @@ function extractWidgetProps(props, compInfo) {
|
|
|
24
23
|
}
|
|
25
24
|
return staticProps;
|
|
26
25
|
}
|
|
27
|
-
exports.extractWidgetProps = extractWidgetProps;
|
|
28
26
|
function generatedDynamicData(data, compInfo) {
|
|
29
27
|
const staticProps = {};
|
|
30
28
|
const boundProps = {};
|
|
@@ -108,7 +106,7 @@ function generateDataBindMeta(bind) {
|
|
|
108
106
|
}
|
|
109
107
|
return { imports, expression: expr };
|
|
110
108
|
}
|
|
111
|
-
function createWidgetProps(
|
|
109
|
+
function createWidgetProps(ctx, widgets) {
|
|
112
110
|
const widgetProps = {};
|
|
113
111
|
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
|
|
114
112
|
var _a;
|
|
@@ -129,7 +127,7 @@ function createWidgetProps(widgets, ctx) {
|
|
|
129
127
|
console.error('Component not found in lib', widegetComp);
|
|
130
128
|
return;
|
|
131
129
|
}
|
|
132
|
-
widgetProps[id] = extractWidgetProps(xProps, widegetComp);
|
|
130
|
+
widgetProps[id] = extractWidgetProps(xProps, widegetComp, ctx.processCssUnit);
|
|
133
131
|
widgetProps[id]._parentId = parentId;
|
|
134
132
|
widgetProps[id]._order = widget.xIndex;
|
|
135
133
|
widgetProps[id].widgetType = `${xComponent.moduleName}:${xComponent.name}`;
|
|
@@ -137,7 +135,7 @@ function createWidgetProps(widgets, ctx) {
|
|
|
137
135
|
return widgetProps;
|
|
138
136
|
}
|
|
139
137
|
exports.createWidgetProps = createWidgetProps;
|
|
140
|
-
function createEventHanlders(widgets, componentApi,
|
|
138
|
+
function createEventHanlders(ctx, widgets, componentApi, page) {
|
|
141
139
|
let eventHandlers = {};
|
|
142
140
|
const { listeners: pageListeners = [], id: pageId = '' } = page || {};
|
|
143
141
|
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
|
|
@@ -240,8 +238,9 @@ function getListenersHandlers(listeners, id, componentApi) {
|
|
|
240
238
|
});
|
|
241
239
|
return eventHandlers;
|
|
242
240
|
}
|
|
243
|
-
function createDataBinds(
|
|
241
|
+
function createDataBinds(ctx, widgets) {
|
|
244
242
|
const dataBinds = {};
|
|
243
|
+
const { processCssUnit = 'rpx' } = ctx;
|
|
245
244
|
(0, weapp_1.walkThroughWidgets)(widgets, (id, widget, parentId) => {
|
|
246
245
|
var _a;
|
|
247
246
|
const { xComponent } = widget;
|
|
@@ -268,13 +267,14 @@ function createDataBinds(widgets, ctx) {
|
|
|
268
267
|
if (classList) {
|
|
269
268
|
dataBinds[id].classList = {
|
|
270
269
|
...classList,
|
|
271
|
-
expression: `concatClassList(${classList === null || classList === void 0 ? void 0 : classList.expression}, widgetProps.${id}.classList)`,
|
|
270
|
+
expression: `concatClassList(\n${classList === null || classList === void 0 ? void 0 : classList.expression}\n, widgetProps.${id}.classList)`,
|
|
272
271
|
};
|
|
273
272
|
}
|
|
274
273
|
if (style) {
|
|
274
|
+
const styleExpression = `{...widgetProps.${id}.style, ...(\n${style === null || style === void 0 ? void 0 : style.expression}\n)}`;
|
|
275
275
|
dataBinds[id].style = {
|
|
276
276
|
...style,
|
|
277
|
-
expression:
|
|
277
|
+
expression: processCssUnit === 'rpx' ? `px2rpx(${styleExpression})` : styleExpression,
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
280
|
if (Object.keys(dataBinds[id]).length === 0) {
|
|
@@ -507,7 +507,6 @@ async function installDependencies(targetDir, options = {}) {
|
|
|
507
507
|
if (installprocess.status) {
|
|
508
508
|
throw new Error(`安装依赖失败 ${installprocess.error || ''}`);
|
|
509
509
|
}
|
|
510
|
-
console.log('fixNodeModules(targetDir, options?.fixNodeModulesMap)');
|
|
511
510
|
fixNodeModules(targetDir, options === null || options === void 0 ? void 0 : options.fixNodeModulesMap);
|
|
512
511
|
try {
|
|
513
512
|
await fs_extra_1.default.remove(path_1.default.join(path_1.default.join(targetDir, 'package-lock.json')));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { IBuildContext } from '../mp/BuildContext';
|
|
3
3
|
import { OutputType } from 'jszip';
|
|
4
4
|
export declare const generatedFileContents: {};
|
|
5
|
-
export default function generateFiles(appFileData: any, srcDir: string, dstDir: string
|
|
5
|
+
export default function generateFiles(ctx: IBuildContext, appFileData: any, srcDir: string, dstDir: string): Promise<string[]>;
|
|
6
6
|
export declare function writeFile(outFile: string, content: string): Promise<boolean>;
|
|
7
7
|
export declare function removeFile(file: string): void;
|
|
8
8
|
/**
|
|
@@ -35,7 +35,7 @@ const glob_1 = __importDefault(require("glob"));
|
|
|
35
35
|
const jszip_1 = __importDefault(require("jszip"));
|
|
36
36
|
const buffer_1 = require("buffer");
|
|
37
37
|
exports.generatedFileContents = {}; // generated files for incrmental build
|
|
38
|
-
async function generateFiles(appFileData, srcDir, dstDir
|
|
38
|
+
async function generateFiles(ctx, appFileData, srcDir, dstDir) {
|
|
39
39
|
const filesGenerated = [];
|
|
40
40
|
// Generating file by template and data
|
|
41
41
|
for (const file in appFileData) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@cloudbase/cals": "^0.5.2",
|
|
42
|
-
"@cloudbase/lowcode-generator": "1.2.
|
|
42
|
+
"@cloudbase/lowcode-generator": "^1.2.2",
|
|
43
43
|
"axios": "^0.21.0",
|
|
44
44
|
"browserfs": "^1.4.3",
|
|
45
45
|
"browserify-zlib": "^0.2.0",
|
|
@@ -475,7 +475,7 @@
|
|
|
475
475
|
crossorigin
|
|
476
476
|
src="<%=
|
|
477
477
|
cdnEndpoints.cdngo
|
|
478
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
478
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.278e23310078ecd6e0a8.bundle.js"
|
|
479
479
|
></script>
|
|
480
480
|
</body>
|
|
481
481
|
</html>
|
|
@@ -44,10 +44,16 @@ export function generateDataContext(widget) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
47
|
* @param evtListeners
|
|
48
|
+
* @param [options]
|
|
49
49
|
*/
|
|
50
|
-
export function createEventHandlers(
|
|
50
|
+
export function createEventHandlers(
|
|
51
|
+
evtListeners,
|
|
52
|
+
options = {
|
|
53
|
+
looseError: false,
|
|
54
|
+
},
|
|
55
|
+
) {
|
|
56
|
+
const { looseError = false } = options;
|
|
51
57
|
const evtHandlers = {};
|
|
52
58
|
for (const name in evtListeners) {
|
|
53
59
|
const listeners = evtListeners[name];
|
|
@@ -60,45 +66,47 @@ export function createEventHandlers(evtListeners) {
|
|
|
60
66
|
event.currentTarget = currentTarget;
|
|
61
67
|
const [prefix = ''] = name.split('$');
|
|
62
68
|
// The page event handler
|
|
63
|
-
const { lists = [], itemsById = {} } = !!currentTarget && findForItemsOfWidget(currentTarget) || {}
|
|
64
|
-
const dataContext = untracked(() => generateDataContext(currentTarget))
|
|
69
|
+
const { lists = [], itemsById = {} } = (!!currentTarget && findForItemsOfWidget(currentTarget)) || {};
|
|
70
|
+
const dataContext = untracked(() => generateDataContext(currentTarget));
|
|
65
71
|
|
|
66
|
-
listeners.forEach(async l => {
|
|
72
|
+
listeners.forEach(async (l) => {
|
|
67
73
|
let { data = {}, boundData = {} } = l;
|
|
68
74
|
data = { ...data };
|
|
69
75
|
try {
|
|
70
76
|
for (const k in boundData) {
|
|
71
|
-
set(data, k, boundData[k].call(owner, owner, lists, itemsById, event, dataContext))
|
|
77
|
+
set(data, k, boundData[k].call(owner, owner, lists, itemsById, event, dataContext));
|
|
72
78
|
}
|
|
73
79
|
let res = await l.handler.call(owner, { event, lists, forItems: itemsById, data });
|
|
74
80
|
let eventName = prefix && l.key ? `${prefix}$${l.key}_success` : '';
|
|
75
|
-
self[eventName] &&
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
self[eventName] &&
|
|
82
|
+
self[eventName]({
|
|
83
|
+
...event,
|
|
84
|
+
detail: res,
|
|
85
|
+
});
|
|
79
86
|
} catch (e) {
|
|
80
87
|
let eventName = l.key ? `${prefix}$${l.key}_fail` : '';
|
|
81
88
|
if (self[eventName]) {
|
|
82
89
|
console.error(`事件响应失败`, e);
|
|
83
90
|
await self[eventName]({
|
|
84
91
|
...event,
|
|
85
|
-
detail: e
|
|
92
|
+
detail: e,
|
|
86
93
|
});
|
|
87
94
|
} else {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
if (!looseError) {
|
|
96
|
+
app.showToast({
|
|
97
|
+
icon: 'error',
|
|
98
|
+
title: `事件响应失败`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
92
101
|
throw e;
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
|
-
})
|
|
96
|
-
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
97
106
|
}
|
|
98
107
|
|
|
99
|
-
return evtHandlers
|
|
108
|
+
return evtHandlers;
|
|
100
109
|
}
|
|
101
|
-
|
|
102
110
|
export function getDeep(target, key, keySeparator = '.') {
|
|
103
111
|
if (key == null) {
|
|
104
112
|
return target
|
|
@@ -290,24 +298,21 @@ async function getAccessPermission(app, appId, pageId) {
|
|
|
290
298
|
return _AUTH_CACHE_MAP[cacheKey];
|
|
291
299
|
}
|
|
292
300
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (Array.isArray(res) && res.length > 0) {
|
|
304
|
-
isAccess = !!res[0].IsAccess;
|
|
305
|
-
}
|
|
301
|
+
const res = await app.cloud.callWedaApi({
|
|
302
|
+
action: 'DescribeResourcesPermission',
|
|
303
|
+
data: {
|
|
304
|
+
ResourceType: `<%= isAdminPortal? 'modelApp' : 'app'%>`,
|
|
305
|
+
ResourceIdList: [cacheKey],
|
|
306
|
+
AppResourceId: appId,
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
if (Array.isArray(res) && res.length > 0) {
|
|
310
|
+
const isAccess = !!res[0].IsAccess;
|
|
306
311
|
_AUTH_CACHE_MAP[cacheKey] = isAccess;
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
return isAccess;
|
|
313
|
+
} else {
|
|
314
|
+
throw new Error(`鉴权接口返回参数不正确 - ${JSON.stringify(res)}`);
|
|
309
315
|
}
|
|
310
|
-
return isAccess
|
|
311
316
|
}
|
|
312
317
|
|
|
313
318
|
export async function checkAnonymous() {
|
|
@@ -325,6 +330,16 @@ export async function checkAnonymous() {
|
|
|
325
330
|
return isAnonymous;
|
|
326
331
|
}
|
|
327
332
|
|
|
333
|
+
export function formatErrorMsg(e) {
|
|
334
|
+
let msg = e?.errMsg || e?.error_description || e?.message;
|
|
335
|
+
const uri = e?.error_uri;
|
|
336
|
+
msg = `${msg}${uri ? '-' + uri : ''}`;
|
|
337
|
+
if (msg.startsWith('request:fail')) {
|
|
338
|
+
msg = `网络故障, 请检查本地网络连接是否正常(${msg})`;
|
|
339
|
+
}
|
|
340
|
+
return msg;
|
|
341
|
+
}
|
|
342
|
+
|
|
328
343
|
/**
|
|
329
344
|
* 检查页面权限
|
|
330
345
|
**/
|
|
@@ -339,31 +354,40 @@ export async function checkAuth(app, appId, $page) {
|
|
|
339
354
|
if (loginPage) {
|
|
340
355
|
requestList.push(getAuthConfig(app));
|
|
341
356
|
}
|
|
342
|
-
|
|
343
|
-
|
|
357
|
+
try {
|
|
358
|
+
const [isAccess, authConfig] = await Promise.all(requestList);
|
|
359
|
+
app.hideNavigationBarLoading();
|
|
344
360
|
|
|
345
|
-
|
|
361
|
+
const isAnonymousUser = await checkAnonymous();
|
|
346
362
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
363
|
+
if (!isAccess) {
|
|
364
|
+
if (isAnonymousUser && loginPage && (authConfig.NeedLogin || authConfig.RejectStrategy == 'to_login')) {
|
|
365
|
+
redirectToLogin($page);
|
|
366
|
+
} else {
|
|
367
|
+
app.showToast({
|
|
368
|
+
title: '页面无访问权限',
|
|
369
|
+
icon: 'error',
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
} else if (loginPage && authConfig.NeedLogin) {
|
|
373
|
+
// 此分支逻辑本不应该前端判断是否登录,历史原因后端短期内搞不定,后续后端优化后删除
|
|
374
|
+
try {
|
|
375
|
+
if (isAnonymousUser) {
|
|
376
|
+
redirectToLogin($page);
|
|
377
|
+
}
|
|
378
|
+
} catch (e) {
|
|
360
379
|
redirectToLogin($page);
|
|
361
380
|
}
|
|
362
|
-
} catch (e) {
|
|
363
|
-
redirectToLogin($page);
|
|
364
381
|
}
|
|
382
|
+
return isAccess;
|
|
383
|
+
} catch (e) {
|
|
384
|
+
app.showModal({
|
|
385
|
+
title: '页面鉴权失败',
|
|
386
|
+
content: formatErrorMsg(e),
|
|
387
|
+
showCancel: false,
|
|
388
|
+
});
|
|
389
|
+
return false;
|
|
365
390
|
}
|
|
366
|
-
return isAccess;
|
|
367
391
|
}
|
|
368
392
|
|
|
369
393
|
export function redirectToLogin(currentPage) {
|
|
@@ -441,9 +465,8 @@ async function getGeneralOptions(optionName) {
|
|
|
441
465
|
|
|
442
466
|
export function getMpEventHandlerName(widgetId, evtName, modifier = {}) {
|
|
443
467
|
// Only builtin events have will bubble
|
|
444
|
-
return `on${widgetId}$${evtName.replace(/\./g, '_')}${modifier.isCapturePhase ? '$cap' : ''}${
|
|
445
|
-
|
|
446
|
-
}`;
|
|
468
|
+
return `on${widgetId}$${evtName.replace(/\./g, '_')}${modifier.isCapturePhase ? '$cap' : ''}${modifier.noPropagation ? '$cat' : ''
|
|
469
|
+
}`;
|
|
447
470
|
}
|
|
448
471
|
|
|
449
472
|
function isPlainObject(src) {
|
|
@@ -122,7 +122,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
|
|
|
122
122
|
},
|
|
123
123
|
|
|
124
124
|
methods: {
|
|
125
|
-
...createEventHandlers(evtListeners),
|
|
125
|
+
...createEventHandlers(evtListeners, { looseError: true }),
|
|
126
126
|
...mergeRenderer,
|
|
127
127
|
getWeAppInst() {
|
|
128
128
|
const $comp = this.$WEAPPS_COMP
|
package/template/package.json
CHANGED
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"html-webpack-plugin": "^3.2.0",
|
|
56
56
|
"ts-loader": "^8.3.0",
|
|
57
57
|
"typescript": "^4.4.4",
|
|
58
|
-
"vue-loader": "
|
|
59
|
-
"vue-template-compiler": "
|
|
58
|
+
"vue-loader": "15.9.8",
|
|
59
|
+
"vue-template-compiler": "2.6.14",
|
|
60
60
|
"webpack": "^4.41.4",
|
|
61
61
|
"webpack-cli": "^4.2.0",
|
|
62
62
|
"webpack-dev-server": "^3.11.0"
|
|
@@ -5,6 +5,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
5
5
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
6
6
|
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
|
|
7
7
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
8
|
+
const { VueLoaderPlugin } = require('vue-loader');
|
|
8
9
|
const themeVars = require('./themeVars');
|
|
9
10
|
const getCSSModuleLocalIdent = require('./getCSSModuleLocalIdent');
|
|
10
11
|
const HappyPack = require('happypack');
|
|
@@ -78,26 +79,6 @@ module.exports = function (options) {
|
|
|
78
79
|
};
|
|
79
80
|
|
|
80
81
|
let plugins = [
|
|
81
|
-
new HappyPack({
|
|
82
|
-
id: 'vue',
|
|
83
|
-
cache: true,
|
|
84
|
-
verbose: true,
|
|
85
|
-
loaders: [
|
|
86
|
-
babelLoader,
|
|
87
|
-
typescriptLoader,
|
|
88
|
-
{
|
|
89
|
-
loader: 'vue-loader',
|
|
90
|
-
options: {
|
|
91
|
-
threadMode: true,
|
|
92
|
-
loaders: {
|
|
93
|
-
js: [babelLoader],
|
|
94
|
-
ts: [babelLoader, typescriptLoader],
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
threadPool: happyThreadPool,
|
|
100
|
-
}),
|
|
101
82
|
new HappyPack({
|
|
102
83
|
id: TS_LOADER_ID,
|
|
103
84
|
loaders: [babelLoader, typescriptLoader],
|
|
@@ -145,6 +126,7 @@ module.exports = function (options) {
|
|
|
145
126
|
SSR: false,
|
|
146
127
|
WEBPACK_ENV: 'production',
|
|
147
128
|
}),
|
|
129
|
+
new VueLoaderPlugin(),
|
|
148
130
|
];
|
|
149
131
|
|
|
150
132
|
const commonCSSLoaders = [
|
|
@@ -159,24 +141,6 @@ module.exports = function (options) {
|
|
|
159
141
|
importLoaders: 2,
|
|
160
142
|
},
|
|
161
143
|
},
|
|
162
|
-
{
|
|
163
|
-
loader: 'postcss-loader',
|
|
164
|
-
options: {
|
|
165
|
-
postcssOptions: {
|
|
166
|
-
plugins: [
|
|
167
|
-
[
|
|
168
|
-
'postcss-pxtorem',
|
|
169
|
-
{
|
|
170
|
-
rootValue: 14,
|
|
171
|
-
propList: ['*'],
|
|
172
|
-
// todo
|
|
173
|
-
selectorBlackList: ['.weui-picker__indicator'],
|
|
174
|
-
},
|
|
175
|
-
],
|
|
176
|
-
],
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
144
|
];
|
|
181
145
|
|
|
182
146
|
return {
|
|
@@ -206,7 +170,7 @@ module.exports = function (options) {
|
|
|
206
170
|
rules: [
|
|
207
171
|
{
|
|
208
172
|
test: /\.vue$/,
|
|
209
|
-
loader: '
|
|
173
|
+
loader: require.resolve('vue-loader'),
|
|
210
174
|
},
|
|
211
175
|
{
|
|
212
176
|
test: /\.tsx?$/,
|