@aiot-toolkit/aiotpack 2.0.2-dev.8 → 2.0.3-beta.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/{utils/ux/UxFollowWorks.d.ts → afterCompile/ux/UxAfterCompile.d.ts} +11 -4
- package/lib/{utils/ux/UxFollowWorks.js → afterCompile/ux/UxAfterCompile.js} +95 -44
- package/lib/{followWorks → afterCompile}/xts/entryTemplate.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/entryTemplate.js +14 -13
- package/lib/{followWorks → afterCompile}/xts/generateRpk.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/generateRpk.js +5 -4
- package/lib/{followWorks → afterCompile}/xts/ts2wasm.d.ts +1 -1
- package/lib/{followWorks → afterCompile}/xts/ts2wasm.js +7 -6
- package/lib/afterWorks/ux/UxAfterWorks.d.ts +5 -0
- package/lib/afterWorks/ux/UxAfterWorks.js +22 -0
- package/lib/{utils/ux/UxPreWorks.d.ts → beforeCompile/ux/UxBeforeCompile.d.ts} +4 -4
- package/lib/{utils/ux/UxPreWorks.js → beforeCompile/ux/UxBeforeCompile.js} +11 -8
- package/lib/{preWorks → beforeCompile}/xts/preInstall.d.ts +1 -1
- package/lib/{preWorks → beforeCompile}/xts/preInstall.js +6 -5
- package/lib/beforeWorks/ux/UxBeforeWorks.d.ts +5 -0
- package/lib/beforeWorks/ux/UxBeforeWorks.js +22 -0
- package/lib/compiler/interface/ICompileParam.d.ts +1 -1
- package/lib/compiler/interface/ISignConfig.d.ts +6 -1
- package/lib/compiler/javascript/JavascriptCompiler.js +45 -12
- package/lib/compiler/javascript/JavascriptDefaultCompileOption.js +1 -2
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.d.ts +9 -0
- package/lib/compiler/javascript/android/AndroidWebpackConfigurator.js +16 -0
- package/lib/compiler/javascript/android/plugin/WrapPlugin.d.ts +20 -0
- package/lib/compiler/javascript/android/plugin/WrapPlugin.js +91 -0
- package/lib/compiler/javascript/interface/IJavascriptCompileOption.d.ts +16 -1
- package/lib/compiler/javascript/interface/IWebpackConfigurator.d.ts +4 -4
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.d.ts +4 -2
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +18 -5
- package/lib/compiler/javascript/vela/interface/IChunk.d.ts +6 -1
- package/lib/compiler/javascript/vela/interface/IManifest.d.ts +1 -1
- package/lib/compiler/javascript/vela/interface/IQuickAppConfig.d.ts +1 -1
- package/lib/compiler/javascript/vela/model/Package.d.ts +2 -2
- package/lib/compiler/javascript/vela/model/Package.js +5 -5
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.d.ts +1 -1
- package/lib/compiler/javascript/vela/plugin/WrapPlugin.js +16 -2
- package/lib/compiler/javascript/vela/utils/Jsc.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/Jsc.js +19 -11
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.d.ts +1 -1
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +4 -4
- package/lib/compiler/javascript/vela/utils/ZipUtil.d.ts +29 -5
- package/lib/compiler/javascript/vela/utils/ZipUtil.js +45 -31
- package/lib/compiler/javascript/vela/utils/signature/Base64.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.d.ts +23 -7
- package/lib/compiler/javascript/vela/utils/signature/SignUtil.js +94 -45
- package/lib/compiler/javascript/vela/utils/signature/Signer.d.ts +0 -1
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/addColSourceMap.js +56 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/extractMapData.d.ts +3 -0
- package/lib/compiler/javascript/vela/utils/webpackLoader/{splitMap.js → extractMapData.js} +2 -2
- package/lib/config/UxConfig.d.ts +45 -7
- package/lib/config/UxConfig.js +156 -40
- package/lib/config/XtsConfig.d.ts +8 -4
- package/lib/config/XtsConfig.js +24 -8
- package/lib/index.d.ts +9 -1
- package/lib/index.js +35 -1
- package/lib/loader/ux/JsLoader.d.ts +2 -0
- package/lib/loader/ux/JsLoader.js +6 -9
- package/lib/loader/ux/PngLoader.js +4 -5
- package/lib/loader/ux/android/UxLoader.d.ts +13 -0
- package/lib/loader/ux/android/UxLoader.js +38 -0
- package/lib/loader/ux/{AppUxLoader.d.ts → vela/AppUxLoader.d.ts} +3 -1
- package/lib/loader/ux/{AppUxLoader.js → vela/AppUxLoader.js} +5 -3
- package/lib/loader/ux/vela/HmlLoader.d.ts +24 -0
- package/lib/loader/ux/vela/HmlLoader.js +63 -0
- package/lib/loader/ux/{UxLoader.d.ts → vela/UxLoader.d.ts} +3 -1
- package/lib/loader/ux/{UxLoader.js → vela/UxLoader.js} +11 -14
- package/lib/loader/xts/XtsLoader.js +6 -7
- package/lib/utils/BeforeCompileUtils.d.ts +21 -0
- package/lib/utils/BeforeCompileUtils.js +118 -0
- package/lib/utils/ux/ManifestSchema.d.ts +1 -1
- package/lib/utils/ux/UxFileUtils.d.ts +16 -3
- package/lib/utils/ux/UxFileUtils.js +53 -17
- package/lib/utils/ux/UxLoaderUtils.d.ts +7 -4
- package/lib/utils/ux/UxLoaderUtils.js +43 -25
- package/lib/utils/ux/android/AndroidUx.d.ts +27 -0
- package/lib/utils/ux/android/AndroidUx.js +98 -0
- package/lib/utils/xts/XtsFileLaneUtils.d.ts +10 -0
- package/lib/utils/xts/XtsFileLaneUtils.js +68 -0
- package/lib/utils/xts/XtsFollowWorks.js +8 -8
- package/package.json +15 -8
- package/lib/compiler/javascript/vela/utils/webpackLoader/splitMap.d.ts +0 -3
- package/lib/utils/PreWorkUtils.d.ts +0 -22
- package/lib/utils/PreWorkUtils.js +0 -106
|
@@ -12,10 +12,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const
|
|
15
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
|
+
const core_1 = require("@rspack/core");
|
|
16
17
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
18
|
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const
|
|
19
|
+
const AndroidWebpackConfigurator_1 = __importDefault(require("./android/AndroidWebpackConfigurator"));
|
|
19
20
|
const VelaWebpackConfigurator_1 = __importDefault(require("./vela/VelaWebpackConfigurator"));
|
|
20
21
|
const UxCompileUtil_1 = __importDefault(require("./vela/utils/UxCompileUtil"));
|
|
21
22
|
class JavascriptCompiler {
|
|
@@ -27,12 +28,12 @@ class JavascriptCompiler {
|
|
|
27
28
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
28
29
|
yield this.clean(param);
|
|
29
30
|
const config = this.createWebpackConfig(param);
|
|
30
|
-
(0,
|
|
31
|
+
(0, core_1.rspack)(config, (error, stats) => {
|
|
31
32
|
if (error) {
|
|
32
|
-
reject([error]);
|
|
33
|
+
reject({ errors: [error] });
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
const statsObj = stats === null || stats === void 0 ? void 0 : stats.toJson();
|
|
36
|
+
const statsObj = stats === null || stats === void 0 ? void 0 : stats.toJson({});
|
|
36
37
|
if (statsObj) {
|
|
37
38
|
const { errors, warnings } = statsObj;
|
|
38
39
|
if ((errors === null || errors === void 0 ? void 0 : errors.length) || (warnings === null || warnings === void 0 ? void 0 : warnings.length)) {
|
|
@@ -51,7 +52,7 @@ class JavascriptCompiler {
|
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
54
|
createWebpackConfig(param) {
|
|
54
|
-
const configurator = this.getConfigurator();
|
|
55
|
+
const configurator = this.getConfigurator(param);
|
|
55
56
|
if (!configurator) {
|
|
56
57
|
throw new Error(`This project is not supported`);
|
|
57
58
|
}
|
|
@@ -63,11 +64,11 @@ class JavascriptCompiler {
|
|
|
63
64
|
}
|
|
64
65
|
const { projectPath, mode, devtool, outputPath } = param;
|
|
65
66
|
const buildPath = path_1.default.resolve(projectPath, outputPath);
|
|
66
|
-
const quickAppConfig =
|
|
67
|
+
const quickAppConfig = shared_utils_1.CommonUtil.requireModule(path_1.default.join(param.projectPath, this.QUICKAPP_CONFIG));
|
|
67
68
|
const result = {
|
|
68
69
|
context: projectPath,
|
|
69
70
|
mode,
|
|
70
|
-
devtool,
|
|
71
|
+
devtool: devtool,
|
|
71
72
|
output: {
|
|
72
73
|
globalObject: 'window',
|
|
73
74
|
filename: '[name].js',
|
|
@@ -77,15 +78,27 @@ class JavascriptCompiler {
|
|
|
77
78
|
module: {
|
|
78
79
|
rules: [
|
|
79
80
|
{
|
|
80
|
-
test: /\.
|
|
81
|
+
test: /\.ux$/, // 匹配以 .ux 结尾的文件
|
|
81
82
|
use: [
|
|
82
83
|
{
|
|
83
|
-
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/
|
|
84
|
+
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/extractMapData.js')
|
|
84
85
|
}
|
|
85
86
|
]
|
|
86
87
|
}
|
|
87
88
|
]
|
|
88
89
|
},
|
|
90
|
+
optimization: {
|
|
91
|
+
minimizer: [
|
|
92
|
+
new core_1.rspack.SwcJsMinimizerRspackPlugin({
|
|
93
|
+
minimizerOptions: {
|
|
94
|
+
module: true
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
resolve: {
|
|
100
|
+
extensions: ['.js', '.ts', '.ux']
|
|
101
|
+
},
|
|
89
102
|
stats: {
|
|
90
103
|
builtAt: false,
|
|
91
104
|
entrypoints: false,
|
|
@@ -108,6 +121,17 @@ class JavascriptCompiler {
|
|
|
108
121
|
Array.isArray(readyRules) && readyRules.length > 0
|
|
109
122
|
? [...configuratorRules, ...readyRules]
|
|
110
123
|
: configuratorRules;
|
|
124
|
+
// 判断devtool类型 inline-source-map时,添加第0列关系映射
|
|
125
|
+
if (devtool === 'inline-source-map') {
|
|
126
|
+
result.module.rules.unshift({
|
|
127
|
+
test: /\.ux$/, // 匹配以 .ux 结尾的文件
|
|
128
|
+
use: [
|
|
129
|
+
{
|
|
130
|
+
loader: path_1.default.join(__dirname, '../javascript/vela/utils/webpackLoader/addColSourceMap.js')
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
111
135
|
}
|
|
112
136
|
if (configurator.createPlugins) {
|
|
113
137
|
result.plugins = configurator.createPlugins();
|
|
@@ -117,8 +141,17 @@ class JavascriptCompiler {
|
|
|
117
141
|
}
|
|
118
142
|
return lodash_1.default.merge({}, result, quickAppConfig === null || quickAppConfig === void 0 ? void 0 : quickAppConfig.webpack);
|
|
119
143
|
}
|
|
120
|
-
getConfigurator() {
|
|
121
|
-
|
|
144
|
+
getConfigurator(param) {
|
|
145
|
+
const { projectPath, sourceRoot } = param;
|
|
146
|
+
const projectType = shared_utils_1.ProjectType.getProjectType(projectPath, sourceRoot);
|
|
147
|
+
switch (projectType) {
|
|
148
|
+
case shared_utils_1.ProjectType.VELA_UX:
|
|
149
|
+
return new VelaWebpackConfigurator_1.default();
|
|
150
|
+
case shared_utils_1.ProjectType.ANDDROID_UX:
|
|
151
|
+
return new AndroidWebpackConfigurator_1.default();
|
|
152
|
+
default:
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
122
155
|
}
|
|
123
156
|
clean(param) {
|
|
124
157
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -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.setServerPort =
|
|
6
|
+
exports.setServerPort = setServerPort;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const clientRecordPath = path_1.default.join(os_1.default.homedir(), 'hap-toolkit-client-records.json');
|
|
@@ -19,5 +19,4 @@ const JavascriptDefaultCompileOption = {
|
|
|
19
19
|
function setServerPort(port) {
|
|
20
20
|
JavascriptDefaultCompileOption.server.port = port;
|
|
21
21
|
}
|
|
22
|
-
exports.setServerPort = setServerPort;
|
|
23
22
|
exports.default = JavascriptDefaultCompileOption;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import VelaWebpackConfigurator from '../vela/VelaWebpackConfigurator';
|
|
2
|
+
import WrapPlugin from './plugin/WrapPlugin';
|
|
3
|
+
/**
|
|
4
|
+
* AndroidWebpackConfigurator
|
|
5
|
+
*/
|
|
6
|
+
declare class AndroidWebpackConfigurator extends VelaWebpackConfigurator {
|
|
7
|
+
protected createWrapPlugin(): WrapPlugin;
|
|
8
|
+
}
|
|
9
|
+
export default AndroidWebpackConfigurator;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const VelaWebpackConfigurator_1 = __importDefault(require("../vela/VelaWebpackConfigurator"));
|
|
7
|
+
const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
|
|
8
|
+
/**
|
|
9
|
+
* AndroidWebpackConfigurator
|
|
10
|
+
*/
|
|
11
|
+
class AndroidWebpackConfigurator extends VelaWebpackConfigurator_1.default {
|
|
12
|
+
createWrapPlugin() {
|
|
13
|
+
return new WrapPlugin_1.default(this.param);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = AndroidWebpackConfigurator;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Compiler } from '@rspack/core';
|
|
2
|
+
import IJavascriptCompileOption from '../../interface/IJavascriptCompileOption';
|
|
3
|
+
/**
|
|
4
|
+
* WrapPlugin
|
|
5
|
+
*/
|
|
6
|
+
declare class WrapPlugin {
|
|
7
|
+
private readonly param;
|
|
8
|
+
constructor(param: IJavascriptCompileOption);
|
|
9
|
+
apply(compiler: Compiler): void;
|
|
10
|
+
/**
|
|
11
|
+
* 添加包含代码
|
|
12
|
+
*
|
|
13
|
+
* 1. 仅 page 文件添加
|
|
14
|
+
* @param compilation
|
|
15
|
+
*/
|
|
16
|
+
private wrap;
|
|
17
|
+
private wrapPage;
|
|
18
|
+
private wrapApp;
|
|
19
|
+
}
|
|
20
|
+
export default WrapPlugin;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const core_1 = require("@rspack/core");
|
|
7
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
8
|
+
const UxFileUtils_1 = __importDefault(require("../../../../utils/ux/UxFileUtils"));
|
|
9
|
+
/**
|
|
10
|
+
* WrapPlugin
|
|
11
|
+
*/
|
|
12
|
+
class WrapPlugin {
|
|
13
|
+
constructor(param) {
|
|
14
|
+
this.param = param;
|
|
15
|
+
}
|
|
16
|
+
apply(compiler) {
|
|
17
|
+
compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {
|
|
18
|
+
compilation.hooks.processAssets.tap({
|
|
19
|
+
name: 'WrapPlugin',
|
|
20
|
+
stage: core_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
21
|
+
}, () => {
|
|
22
|
+
this.wrap(compilation);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 添加包含代码
|
|
28
|
+
*
|
|
29
|
+
* 1. 仅 page 文件添加
|
|
30
|
+
* @param compilation
|
|
31
|
+
*/
|
|
32
|
+
wrap(compilation) {
|
|
33
|
+
// 获取入口文件
|
|
34
|
+
const entrys = Object.keys(compilation.options.entry).map((item) => `${item}.js`);
|
|
35
|
+
entrys.forEach((entry) => {
|
|
36
|
+
if (compilation.assets[entry]) {
|
|
37
|
+
const source = compilation.assets[entry];
|
|
38
|
+
const isApp = entry === 'app.js';
|
|
39
|
+
compilation.assets[entry] = isApp
|
|
40
|
+
? this.wrapApp(source)
|
|
41
|
+
: this.wrapPage(source);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
wrapPage(source) {
|
|
46
|
+
return new webpack_sources_1.ConcatSource(`
|
|
47
|
+
(function () {
|
|
48
|
+
var createPageHandler = function () {
|
|
49
|
+
// 转换动态 style 的函数
|
|
50
|
+
var $translateStyle$ = function (value) {
|
|
51
|
+
if (typeof value === 'string') {
|
|
52
|
+
return Object.fromEntries(value.split(';').filter(item => Boolean(item && item.trim())).map(
|
|
53
|
+
item => {
|
|
54
|
+
const matchs = item.match(/([^:]+):(.*)/)
|
|
55
|
+
if (matchs && matchs.lenth> 2) {
|
|
56
|
+
return [matchs[1].trim().replace(/-([a-z])/g, (_, match) => match.toUpperCase()), matchs[2].trim()]
|
|
57
|
+
}
|
|
58
|
+
return []
|
|
59
|
+
}))}
|
|
60
|
+
return value
|
|
61
|
+
}
|
|
62
|
+
return`, source, `;
|
|
63
|
+
};
|
|
64
|
+
if (typeof window === "undefined") {
|
|
65
|
+
return createPageHandler();
|
|
66
|
+
} else {
|
|
67
|
+
window.createPageHandler = createPageHandler;
|
|
68
|
+
}
|
|
69
|
+
})();`);
|
|
70
|
+
}
|
|
71
|
+
wrapApp(source) {
|
|
72
|
+
const { projectPath, sourceRoot } = this.param;
|
|
73
|
+
return new webpack_sources_1.ConcatSource(`
|
|
74
|
+
(function () {
|
|
75
|
+
var $app_define_wrap$ = $app_define_wrap$ || function () {};
|
|
76
|
+
var manifestJson =${JSON.stringify(UxFileUtils_1.default.getMainfestInfo(projectPath, sourceRoot))}
|
|
77
|
+
var createAppHandler = function () {
|
|
78
|
+
`, source, `
|
|
79
|
+
}
|
|
80
|
+
if (typeof window === "undefined") {
|
|
81
|
+
return createAppHandler();
|
|
82
|
+
} else {
|
|
83
|
+
window.createAppHandler = createAppHandler;
|
|
84
|
+
// H5注入manifest以获取features
|
|
85
|
+
global.manifest = manifestJson;
|
|
86
|
+
}
|
|
87
|
+
})();
|
|
88
|
+
`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.default = WrapPlugin;
|
|
@@ -22,6 +22,9 @@ export default interface IJavascriptCompileOption extends ICompileParam {
|
|
|
22
22
|
* 项目运行的代码覆盖率数据
|
|
23
23
|
*/
|
|
24
24
|
dataCoverage: string;
|
|
25
|
+
/**
|
|
26
|
+
* 记录“连接过的设备信息”的文件地址
|
|
27
|
+
*/
|
|
25
28
|
clientRecordPath: string;
|
|
26
29
|
/**
|
|
27
30
|
* 运行端口
|
|
@@ -36,9 +39,21 @@ export default interface IJavascriptCompileOption extends ICompileParam {
|
|
|
36
39
|
/**
|
|
37
40
|
* 禁用 jsc
|
|
38
41
|
*/
|
|
39
|
-
|
|
42
|
+
enableJsc?: boolean;
|
|
40
43
|
/**
|
|
41
44
|
* 启用 protobuf
|
|
42
45
|
*/
|
|
43
46
|
enableProtobuf?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 启用应用自动化测试
|
|
49
|
+
*/
|
|
50
|
+
enableE2e?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 启用代码体积分析,会生成 report.html 文件,可查看打包后各模块占用体积
|
|
53
|
+
*/
|
|
54
|
+
enableStats?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* 是否自动补全 manifest.json 中的 features 配置
|
|
57
|
+
*/
|
|
58
|
+
completeFeature?: boolean;
|
|
44
59
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Configuration, EntryObject,
|
|
2
|
-
import ICompileParam from
|
|
1
|
+
import { Configuration, EntryObject, RspackOptions, RspackPluginInstance, RuleSetRule } from '@rspack/core';
|
|
2
|
+
import ICompileParam from '../../interface/ICompileParam';
|
|
3
3
|
/**
|
|
4
4
|
* webpack配置器
|
|
5
5
|
*
|
|
@@ -18,11 +18,11 @@ interface IWebpackConfigurator {
|
|
|
18
18
|
*
|
|
19
19
|
* 如实现此函数,则其它函数无效
|
|
20
20
|
*/
|
|
21
|
-
create?():
|
|
21
|
+
create?(): RspackOptions;
|
|
22
22
|
/**
|
|
23
23
|
* 创建 webpack 的 plugins
|
|
24
24
|
*/
|
|
25
|
-
createPlugins?():
|
|
25
|
+
createPlugins?(): RspackPluginInstance[];
|
|
26
26
|
/**
|
|
27
27
|
* 创建 webpack 的 entry
|
|
28
28
|
*/
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { EntryObject, RuleSetRule, WebpackPluginInstance } from 'webpack';
|
|
2
1
|
import ICompileParam from '../../interface/ICompileParam';
|
|
3
2
|
import IJavascriptCompileOption from '../interface/IJavascriptCompileOption';
|
|
4
3
|
import IWebpackConfigurator from '../interface/IWebpackConfigurator';
|
|
4
|
+
import { EntryObject, RuleSetRule, RspackPluginInstance } from '@rspack/core';
|
|
5
5
|
declare class VelaWebpackConfigurator implements IWebpackConfigurator {
|
|
6
6
|
param: ICompileParam & IJavascriptCompileOption;
|
|
7
|
-
createPlugins():
|
|
7
|
+
createPlugins(): RspackPluginInstance[];
|
|
8
|
+
protected createWrapPlugin(): RspackPluginInstance;
|
|
9
|
+
protected createBundleAnalyzerPlugin(): any;
|
|
8
10
|
/**
|
|
9
11
|
* 通过读取 manifest.json 生成 entry
|
|
10
12
|
* @returns
|
|
@@ -10,10 +10,24 @@ const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
|
|
|
10
10
|
const UxCompileUtil_1 = __importDefault(require("./utils/UxCompileUtil"));
|
|
11
11
|
class VelaWebpackConfigurator {
|
|
12
12
|
createPlugins() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
// 包裹代码的插件
|
|
14
|
+
const result = [this.createWrapPlugin()];
|
|
15
|
+
// 如果开启 stats 参数,则添加 webpack-bundle-analyzer 插件
|
|
16
|
+
if (this.param.enableStats) {
|
|
17
|
+
result.push(this.createBundleAnalyzerPlugin());
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
createWrapPlugin() {
|
|
22
|
+
return new WrapPlugin_1.default();
|
|
23
|
+
}
|
|
24
|
+
createBundleAnalyzerPlugin() {
|
|
25
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
26
|
+
return new BundleAnalyzerPlugin({
|
|
27
|
+
analyzerMode: 'static',
|
|
28
|
+
openAnalyzer: false,
|
|
29
|
+
excludeAssets: /^@(system|service)\./
|
|
30
|
+
});
|
|
17
31
|
}
|
|
18
32
|
/**
|
|
19
33
|
* 通过读取 manifest.json 生成 entry
|
|
@@ -40,7 +54,6 @@ class VelaWebpackConfigurator {
|
|
|
40
54
|
{
|
|
41
55
|
loader: require.resolve('babel-loader'),
|
|
42
56
|
options: {
|
|
43
|
-
// configFile: getBabelConfigJsPath(cwd),
|
|
44
57
|
cwd: this.param.projectPath,
|
|
45
58
|
cacheDirectory: true
|
|
46
59
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { Dictionary } from '@aiot-toolkit/shared-utils/lib/type/Type';
|
|
1
|
+
import { Dictionary } from '@aiot-toolkit/shared-utils';
|
|
3
2
|
/**
|
|
4
3
|
* 文件资源
|
|
5
4
|
*/
|
|
@@ -64,6 +63,7 @@ declare class Package {
|
|
|
64
63
|
* @returns
|
|
65
64
|
*/
|
|
66
65
|
include(filePath: string): boolean;
|
|
66
|
+
getResource(filePath: string): IFileResource | undefined;
|
|
67
67
|
/**
|
|
68
68
|
* 添加资源
|
|
69
69
|
* @param data
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
7
4
|
/**
|
|
8
5
|
* 定义文件包
|
|
9
6
|
*
|
|
@@ -30,6 +27,9 @@ class Package {
|
|
|
30
27
|
include(filePath) {
|
|
31
28
|
return this.resourceDic[filePath];
|
|
32
29
|
}
|
|
30
|
+
getResource(filePath) {
|
|
31
|
+
return this.resourceList.find((item) => item.fileBuildPath === filePath);
|
|
32
|
+
}
|
|
33
33
|
/**
|
|
34
34
|
* 添加资源
|
|
35
35
|
* @param data
|
|
@@ -38,7 +38,7 @@ class Package {
|
|
|
38
38
|
addResource(data) {
|
|
39
39
|
const { fileBuildPath } = data;
|
|
40
40
|
if (this.include(fileBuildPath)) {
|
|
41
|
-
|
|
41
|
+
shared_utils_1.ColorConsole.throw(`File ${fileBuildPath} is added repeatedly`);
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
this._resourceDic[fileBuildPath] = true;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const core_1 = require("@rspack/core");
|
|
4
4
|
const webpack_sources_1 = require("webpack-sources");
|
|
5
5
|
class WrapPlugin {
|
|
6
6
|
apply(compiler) {
|
|
@@ -8,7 +8,7 @@ class WrapPlugin {
|
|
|
8
8
|
compiler.hooks.compilation.tap('WrapPlugin', (compilation) => {
|
|
9
9
|
compilation.hooks.processAssets.tap({
|
|
10
10
|
name: 'WrapPlugin',
|
|
11
|
-
stage:
|
|
11
|
+
stage: core_1.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12
12
|
}, () => {
|
|
13
13
|
this.wrap(compilation);
|
|
14
14
|
});
|
|
@@ -31,6 +31,20 @@ class WrapPlugin {
|
|
|
31
31
|
var clearTimeout = global.clearTimeout;
|
|
32
32
|
var clearInterval = global.clearInterval;
|
|
33
33
|
var $app_require$ = global.$app_require$ || org_app_require
|
|
34
|
+
|
|
35
|
+
// 转换动态 style 的函数
|
|
36
|
+
var $translateStyle$ = function (value) {
|
|
37
|
+
if (typeof value === 'string') {
|
|
38
|
+
return Object.fromEntries(value.split(';').filter(item => Boolean(item && item.trim())).map(
|
|
39
|
+
item => {
|
|
40
|
+
const matchs = item.match(/([^:]+):(.*)/)
|
|
41
|
+
if (matchs && matchs.lenth> 2) {
|
|
42
|
+
return [matchs[1].trim().replace(/-([a-z])/g, (_, match) => match.toUpperCase()), matchs[2].trim()]
|
|
43
|
+
}
|
|
44
|
+
return []
|
|
45
|
+
}))}
|
|
46
|
+
return value
|
|
47
|
+
}
|
|
34
48
|
|
|
35
49
|
var createPageHandler = function() {
|
|
36
50
|
return `, source, `
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
4
10
|
};
|
|
5
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
7
|
-
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
8
|
-
const del_1 = __importDefault(require("del"));
|
|
12
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
9
13
|
/**
|
|
10
14
|
* Jsc
|
|
11
15
|
*/
|
|
@@ -16,15 +20,19 @@ class Jsc {
|
|
|
16
20
|
}
|
|
17
21
|
jsc() {
|
|
18
22
|
const { projectPath, buildPath } = this;
|
|
19
|
-
return
|
|
20
|
-
.then((module) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
return shared_utils_1.CommonUtil.requireNodeModule(projectPath, `@aiot-toolkit/jsc`)
|
|
24
|
+
.then((module) => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const msg = yield module.default(buildPath);
|
|
26
|
+
if (msg) {
|
|
27
|
+
shared_utils_1.ColorConsole.success({ word: 'jsc command' }, msg);
|
|
28
|
+
}
|
|
29
|
+
}))
|
|
23
30
|
.then(() => {
|
|
24
|
-
return
|
|
31
|
+
return shared_utils_1.FileUtil.del(`${buildPath}/**/*.js`);
|
|
25
32
|
})
|
|
26
33
|
.catch((error) => {
|
|
27
|
-
|
|
34
|
+
shared_utils_1.ColorConsole.throw(error.message);
|
|
35
|
+
return Promise.reject(error);
|
|
28
36
|
});
|
|
29
37
|
}
|
|
30
38
|
}
|
|
@@ -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
|
-
const
|
|
6
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
7
7
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const EntryType_1 = __importDefault(require("../enum/EntryType"));
|
|
@@ -18,7 +18,7 @@ class UxCompileUtil {
|
|
|
18
18
|
fs_extra_1.default.unlinkSync(item);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
21
|
-
fs_extra_1.default.
|
|
21
|
+
fs_extra_1.default.rmSync(item, { recursive: true, force: true });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -37,7 +37,7 @@ class UxCompileUtil {
|
|
|
37
37
|
}
|
|
38
38
|
const appFile = this.resolveFile(path_1.default.join(codeDir, 'app'));
|
|
39
39
|
if (!fs_extra_1.default.existsSync(appFile)) {
|
|
40
|
-
|
|
40
|
+
shared_utils_1.ColorConsole.throw(`App file does not exist`);
|
|
41
41
|
}
|
|
42
42
|
const { pages = {}, widgets = {}, floatingWindows = {} } = router;
|
|
43
43
|
const confsList = [
|
|
@@ -130,7 +130,7 @@ class UxCompileUtil {
|
|
|
130
130
|
* @returns
|
|
131
131
|
*/
|
|
132
132
|
static getExtensionList(withDot = true) {
|
|
133
|
-
const result = ['
|
|
133
|
+
const result = ['ux', 'hml'];
|
|
134
134
|
if (withDot) {
|
|
135
135
|
return result.map((item) => `.${item}`);
|
|
136
136
|
}
|