@cloudbase/lowcode-builder 1.8.108 → 1.8.110
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/utils/transform.js
CHANGED
|
@@ -4,8 +4,38 @@ exports.BabelTransform = void 0;
|
|
|
4
4
|
/* eslint-disable no-new-func */
|
|
5
5
|
const core_1 = require("@babel/core");
|
|
6
6
|
function BabelTransform(code, options = {}) {
|
|
7
|
-
var _a, _b, _c;
|
|
7
|
+
var _a, _b, _c, _d, _e;
|
|
8
8
|
const { IIFE = false } = options;
|
|
9
|
+
const funTransformParams = {
|
|
10
|
+
cwd: __dirname,
|
|
11
|
+
sourceType: 'script',
|
|
12
|
+
comments: false,
|
|
13
|
+
// minified: true,
|
|
14
|
+
presets: [
|
|
15
|
+
[
|
|
16
|
+
'@babel/preset-env',
|
|
17
|
+
{
|
|
18
|
+
targets: {
|
|
19
|
+
/**
|
|
20
|
+
* 支持 proxy 的版本
|
|
21
|
+
* 低于这个版本完全无法支持
|
|
22
|
+
*/
|
|
23
|
+
// browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
|
|
24
|
+
/**
|
|
25
|
+
* 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
|
|
26
|
+
* 但是不包涵 options chain
|
|
27
|
+
* 基本上是 es2019
|
|
28
|
+
*/
|
|
29
|
+
browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
|
|
30
|
+
},
|
|
31
|
+
include: [
|
|
32
|
+
// es2015
|
|
33
|
+
'@babel/plugin-transform-arrow-functions',
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
],
|
|
38
|
+
};
|
|
9
39
|
/**
|
|
10
40
|
* 如果 trim 完为空
|
|
11
41
|
* 则原样不用再编译了
|
|
@@ -25,37 +55,15 @@ function BabelTransform(code, options = {}) {
|
|
|
25
55
|
catch (e) { }
|
|
26
56
|
try {
|
|
27
57
|
const simpleWrapped = `(\n${code || 'undefined'}\n)`;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
targets: {
|
|
38
|
-
/**
|
|
39
|
-
* 支持 proxy 的版本
|
|
40
|
-
* 低于这个版本完全无法支持
|
|
41
|
-
*/
|
|
42
|
-
// browsers: ['chrome >= 49', 'iOS >= 10', 'safari >= 10'],
|
|
43
|
-
/**
|
|
44
|
-
* 一个相对较高的版本,包涵解构赋值,这样不用注入太多 polifill
|
|
45
|
-
* 但是不包涵 options chain
|
|
46
|
-
* 基本上是 es2019
|
|
47
|
-
*/
|
|
48
|
-
browsers: ['chrome >= 67', 'iOS >= 12', 'safari >= 12'],
|
|
49
|
-
},
|
|
50
|
-
include: [
|
|
51
|
-
// es2015
|
|
52
|
-
'@babel/plugin-transform-arrow-functions',
|
|
53
|
-
],
|
|
54
|
-
},
|
|
55
|
-
],
|
|
56
|
-
],
|
|
57
|
-
}) || {};
|
|
58
|
-
const res = ((_c = expression === null || expression === void 0 ? void 0 : expression.replace) === null || _c === void 0 ? void 0 : _c.call(expression, /;$/, '')) || code;
|
|
58
|
+
let { code: expression } = (0, core_1.transformSync)(simpleWrapped, funTransformParams) || {};
|
|
59
|
+
let res = (_c = expression === null || expression === void 0 ? void 0 : expression.replace) === null || _c === void 0 ? void 0 : _c.call(expression, /;(\s*)$/g, '');
|
|
60
|
+
const formatPattern = /^\(|\)$|\n|\s/g;
|
|
61
|
+
const formatRes = res === null || res === void 0 ? void 0 : res.replace(formatPattern, '');
|
|
62
|
+
const formatCode = code === null || code === void 0 ? void 0 : code.replace(formatPattern, '');
|
|
63
|
+
if (formatRes !== formatCode && IIFE) {
|
|
64
|
+
expression = (_d = ((0, core_1.transformSync)(`(()=>${simpleWrapped})()`, funTransformParams) || {})) === null || _d === void 0 ? void 0 : _d.code;
|
|
65
|
+
res = ((_e = expression === null || expression === void 0 ? void 0 : expression.replace) === null || _e === void 0 ? void 0 : _e.call(expression, /;$/, '')) || code;
|
|
66
|
+
}
|
|
59
67
|
if (expression) {
|
|
60
68
|
new Function(`return (\n${res}\n)`);
|
|
61
69
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.110",
|
|
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",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/core": "7.21.4",
|
|
49
49
|
"@babel/preset-env": "7.21.4",
|
|
50
|
-
"@cloudbase/cals": "
|
|
51
|
-
"@cloudbase/lowcode-generator": "
|
|
50
|
+
"@cloudbase/cals": "^1.1.10",
|
|
51
|
+
"@cloudbase/lowcode-generator": "^1.8.34",
|
|
52
52
|
"axios": "^0.21.0",
|
|
53
53
|
"browserfs": "^1.4.3",
|
|
54
54
|
"browserify-zlib": "^0.2.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@types/lodash.get": "^4.4.6",
|
|
77
77
|
"@types/lodash.template": "^4.5.0",
|
|
78
78
|
"@types/node": "^13.9.8",
|
|
79
|
-
"@types/react": "
|
|
79
|
+
"@types/react": "17.0.45",
|
|
80
80
|
"@types/webpack": "^4.41.22",
|
|
81
81
|
"@types/weixin-app": "^2.9.0",
|
|
82
82
|
"cross-env": "^7.0.3",
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"ts-loader": "^8.3.0",
|
|
85
85
|
"ts-node": "^10.4.0",
|
|
86
86
|
"tsc-watch": "^6.0.4",
|
|
87
|
-
"typescript": "
|
|
87
|
+
"typescript": "4.7.4",
|
|
88
88
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
|
89
89
|
"webpack-cli": "^4.9.1",
|
|
90
90
|
"webpack-dev-server": "^4.7.3",
|
|
91
91
|
"worker-loader": "^3.0.8"
|
|
92
92
|
}
|
|
93
|
-
}
|
|
93
|
+
}
|