@aiot-toolkit/aiotpack 2.0.2-beta.4 → 2.0.2-beta.6
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/compiler/javascript/interface/IJavascriptCompileOption.d.ts +4 -0
- package/lib/compiler/javascript/vela/VelaWebpackConfigurator.js +11 -2
- package/lib/compiler/javascript/vela/utils/UxCompileUtil.js +1 -1
- package/lib/config/UxConfig.d.ts +3 -22
- package/lib/config/UxConfig.js +25 -1
- package/lib/config/XtsConfig.d.ts +2 -1
- package/lib/config/XtsConfig.js +1 -2
- package/lib/loader/ux/AppUxLoader.js +14 -2
- package/lib/loader/ux/HmlLoader.d.ts +24 -0
- package/lib/loader/ux/HmlLoader.js +63 -0
- package/lib/loader/ux/JsLoader.js +1 -0
- package/lib/loader/ux/UxLoader.js +2 -2
- package/lib/utils/PreWorkUtils.js +6 -4
- package/lib/utils/ux/UxLoaderUtils.d.ts +4 -1
- package/lib/utils/ux/UxLoaderUtils.js +28 -9
- package/package.json +7 -5
|
@@ -10,10 +10,20 @@ const WrapPlugin_1 = __importDefault(require("./plugin/WrapPlugin"));
|
|
|
10
10
|
const UxCompileUtil_1 = __importDefault(require("./utils/UxCompileUtil"));
|
|
11
11
|
class VelaWebpackConfigurator {
|
|
12
12
|
createPlugins() {
|
|
13
|
-
|
|
13
|
+
const result = [
|
|
14
14
|
// 给 入口js 添加包裹
|
|
15
15
|
new WrapPlugin_1.default()
|
|
16
16
|
];
|
|
17
|
+
// 如果开启 stats 参数,则添加 webpack-bundle-analyzer 插件
|
|
18
|
+
if (this.param.enableStats) {
|
|
19
|
+
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
20
|
+
result.push(new BundleAnalyzerPlugin({
|
|
21
|
+
analyzerMode: 'static',
|
|
22
|
+
openAnalyzer: false,
|
|
23
|
+
excludeAssets: /^@(system|service)\./
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
17
27
|
}
|
|
18
28
|
/**
|
|
19
29
|
* 通过读取 manifest.json 生成 entry
|
|
@@ -40,7 +50,6 @@ class VelaWebpackConfigurator {
|
|
|
40
50
|
{
|
|
41
51
|
loader: require.resolve('babel-loader'),
|
|
42
52
|
options: {
|
|
43
|
-
// configFile: getBabelConfigJsPath(cwd),
|
|
44
53
|
cwd: this.param.projectPath,
|
|
45
54
|
cacheDirectory: true
|
|
46
55
|
}
|
package/lib/config/UxConfig.d.ts
CHANGED
|
@@ -1,32 +1,13 @@
|
|
|
1
1
|
import { IFileLaneConfig } from 'file-lane';
|
|
2
2
|
import IJavascriptCompileOption from '../compiler/javascript/interface/IJavascriptCompileOption';
|
|
3
|
-
import
|
|
4
|
-
import JsLoader from '../loader/ux/JsLoader';
|
|
5
|
-
import PngLoader from '../loader/ux/PngLoader';
|
|
6
|
-
import UxLoader from '../loader/ux/UxLoader';
|
|
3
|
+
import { IRule } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
7
4
|
declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
|
|
8
5
|
readonly projectPath: string;
|
|
9
6
|
constructor(projectPath: string);
|
|
10
|
-
exclude: RegExp[];
|
|
7
|
+
exclude: (RegExp | ((filePath: string) => boolean))[];
|
|
11
8
|
get output(): string;
|
|
12
9
|
module: {
|
|
13
|
-
rules:
|
|
14
|
-
test: string[];
|
|
15
|
-
loader: (typeof AppUxLoader)[];
|
|
16
|
-
exclude?: undefined;
|
|
17
|
-
} | {
|
|
18
|
-
test: RegExp[];
|
|
19
|
-
exclude: RegExp[];
|
|
20
|
-
loader: (typeof UxLoader)[];
|
|
21
|
-
} | {
|
|
22
|
-
test: RegExp[];
|
|
23
|
-
loader: (typeof JsLoader)[];
|
|
24
|
-
exclude?: undefined;
|
|
25
|
-
} | {
|
|
26
|
-
test: RegExp[];
|
|
27
|
-
loader: (typeof PngLoader)[];
|
|
28
|
-
exclude?: undefined;
|
|
29
|
-
})[];
|
|
10
|
+
rules: IRule[];
|
|
30
11
|
};
|
|
31
12
|
preWorks: import("file-lane/lib/interface/IFileLaneConfig").PreWork<IJavascriptCompileOption>[];
|
|
32
13
|
followWorks: {
|
package/lib/config/UxConfig.js
CHANGED
|
@@ -11,10 +11,30 @@ const UxLoader_1 = __importDefault(require("../loader/ux/UxLoader"));
|
|
|
11
11
|
const PreWorkUtils_1 = __importDefault(require("../utils/PreWorkUtils"));
|
|
12
12
|
const UxFollowWorks_1 = __importDefault(require("../followWorks/ux/UxFollowWorks"));
|
|
13
13
|
const UxPreWorks_1 = __importDefault(require("../preWorks/ux/UxPreWorks"));
|
|
14
|
+
const HmlLoader_1 = __importDefault(require("../loader/ux/HmlLoader"));
|
|
15
|
+
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
14
18
|
class UxConfig {
|
|
15
19
|
constructor(projectPath) {
|
|
16
20
|
this.projectPath = projectPath;
|
|
17
|
-
this.exclude = [
|
|
21
|
+
this.exclude = [
|
|
22
|
+
/node_modules/,
|
|
23
|
+
/dist/,
|
|
24
|
+
/build/,
|
|
25
|
+
(filePath) => {
|
|
26
|
+
// 如果 是 script, style文件,且同路径下存在同名 hml,则忽略
|
|
27
|
+
const { ext, name } = path_1.default.parse(filePath);
|
|
28
|
+
if (![...parser_1.ExtensionConfig.SCRIPTS, ...parser_1.ExtensionConfig.STYLES].includes(ext)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const hmlPath = FileUtil_1.default.updatePath(filePath, `${name}${parser_1.ExtensionConfig.HML}`);
|
|
32
|
+
if (fs_1.default.existsSync(hmlPath)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
];
|
|
18
38
|
this.module = {
|
|
19
39
|
rules: [
|
|
20
40
|
{
|
|
@@ -26,6 +46,10 @@ class UxConfig {
|
|
|
26
46
|
exclude: [/app\.ux/],
|
|
27
47
|
loader: [UxLoader_1.default]
|
|
28
48
|
},
|
|
49
|
+
{
|
|
50
|
+
test: [/.+\.hml$/],
|
|
51
|
+
loader: [HmlLoader_1.default, UxLoader_1.default]
|
|
52
|
+
},
|
|
29
53
|
{
|
|
30
54
|
test: [/.+\.js$/],
|
|
31
55
|
loader: [JsLoader_1.default]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IFileLaneConfig } from 'file-lane';
|
|
2
2
|
import XtsLoader from '../loader/xts/XtsLoader';
|
|
3
|
+
import { PreWork } from 'file-lane/lib/interface/IFileLaneConfig';
|
|
3
4
|
/**
|
|
4
5
|
* XtsConfig
|
|
5
6
|
*/
|
|
@@ -12,7 +13,7 @@ declare class XtsConfig implements IFileLaneConfig {
|
|
|
12
13
|
loader: (typeof XtsLoader)[];
|
|
13
14
|
}[];
|
|
14
15
|
};
|
|
15
|
-
preWorks:
|
|
16
|
+
preWorks: PreWork[];
|
|
16
17
|
followWorks: {
|
|
17
18
|
worker: import("file-lane/lib/interface/IFileLaneConfig").FollowWork<import("../interface/ICompileOptions").IXtsCompileOptions>;
|
|
18
19
|
}[];
|
package/lib/config/XtsConfig.js
CHANGED
|
@@ -7,7 +7,6 @@ const entryTemplate_1 = require("../followWorks/xts/entryTemplate");
|
|
|
7
7
|
const generateRpk_1 = require("../followWorks/xts/generateRpk");
|
|
8
8
|
const ts2wasm_1 = require("../followWorks/xts/ts2wasm");
|
|
9
9
|
const XtsLoader_1 = __importDefault(require("../loader/xts/XtsLoader"));
|
|
10
|
-
const preInstall_1 = require("../preWorks/xts/preInstall");
|
|
11
10
|
/**
|
|
12
11
|
* XtsConfig
|
|
13
12
|
*/
|
|
@@ -23,7 +22,7 @@ class XtsConfig {
|
|
|
23
22
|
}
|
|
24
23
|
]
|
|
25
24
|
};
|
|
26
|
-
this.preWorks = [
|
|
25
|
+
this.preWorks = [];
|
|
27
26
|
this.followWorks = [
|
|
28
27
|
{
|
|
29
28
|
worker: entryTemplate_1.generateEntryFile
|
|
@@ -13,6 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"));
|
|
16
|
+
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
17
|
+
const path_1 = __importDefault(require("path"));
|
|
18
|
+
const shared_utils_1 = require("@aiot-toolkit/shared-utils");
|
|
16
19
|
/**
|
|
17
20
|
* 处理app.ux的Loader
|
|
18
21
|
* AppUxLoader
|
|
@@ -20,8 +23,17 @@ const UxLoaderUtils_1 = __importDefault(require("../../utils/ux/UxLoaderUtils"))
|
|
|
20
23
|
class AppUxLoader {
|
|
21
24
|
parser(files) {
|
|
22
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const
|
|
24
|
-
yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0],
|
|
26
|
+
const { projectPath } = this.context;
|
|
27
|
+
const { files: resultFiles, logs } = yield UxLoaderUtils_1.default.compileAppUxToJavascript(files[0], this.context, this.compilerOption);
|
|
28
|
+
if (logs) {
|
|
29
|
+
logs.forEach((item) => {
|
|
30
|
+
ColorConsole_1.default.logger(Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' }));
|
|
31
|
+
});
|
|
32
|
+
// 如果有 error throw,则停止
|
|
33
|
+
if (logs.some((item) => item.level && [shared_utils_1.LOG_LEVEL.Throw].includes(item.level))) {
|
|
34
|
+
throw new Error('stop!');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
25
37
|
return resultFiles;
|
|
26
38
|
});
|
|
27
39
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
|
|
2
|
+
/**
|
|
3
|
+
* HmlLoader
|
|
4
|
+
*/
|
|
5
|
+
declare class HmlLoader implements ILoader {
|
|
6
|
+
context?: IFileLaneContext | undefined;
|
|
7
|
+
compilerOption?: any;
|
|
8
|
+
parser(files: IFileParam<any>[]): IFileParam<any>[] | Promise<IFileParam<any>[]>;
|
|
9
|
+
/**
|
|
10
|
+
* 包裹 hml 文件
|
|
11
|
+
*
|
|
12
|
+
* # 路径
|
|
13
|
+
* 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
|
|
14
|
+
*
|
|
15
|
+
* # 内容
|
|
16
|
+
* 1. 给hml的内容加上<template></template>
|
|
17
|
+
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
18
|
+
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
19
|
+
*
|
|
20
|
+
* @param file
|
|
21
|
+
*/
|
|
22
|
+
private wrapHml;
|
|
23
|
+
}
|
|
24
|
+
export default HmlLoader;
|
|
@@ -0,0 +1,63 @@
|
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
9
|
+
/**
|
|
10
|
+
* HmlLoader
|
|
11
|
+
*/
|
|
12
|
+
class HmlLoader {
|
|
13
|
+
parser(files) {
|
|
14
|
+
return files.map((file) => {
|
|
15
|
+
return this.wrapHml(file);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 包裹 hml 文件
|
|
20
|
+
*
|
|
21
|
+
* # 路径
|
|
22
|
+
* 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
|
|
23
|
+
*
|
|
24
|
+
* # 内容
|
|
25
|
+
* 1. 给hml的内容加上<template></template>
|
|
26
|
+
* 2. 如果存在同路径同名的 script文件,则加到<script></script>中
|
|
27
|
+
* 3. 如果存在同路径同名的 style文件,则加到<style></style>中
|
|
28
|
+
*
|
|
29
|
+
* @param file
|
|
30
|
+
*/
|
|
31
|
+
wrapHml(file) {
|
|
32
|
+
const { path, content } = file;
|
|
33
|
+
const uxExt = parser_1.ExtensionConfig.UX;
|
|
34
|
+
const getFilePath = (ext) => {
|
|
35
|
+
const pathParsed = path_1.default.parse(path);
|
|
36
|
+
pathParsed.ext = ext;
|
|
37
|
+
pathParsed.base = pathParsed.name + ext;
|
|
38
|
+
return path_1.default.format(pathParsed);
|
|
39
|
+
};
|
|
40
|
+
const uxPath = getFilePath(uxExt);
|
|
41
|
+
if (fs_1.default.existsSync(uxPath)) {
|
|
42
|
+
throw new Error(`${uxPath} already exists`);
|
|
43
|
+
}
|
|
44
|
+
const scriptExts = parser_1.ExtensionConfig.SCRIPTS;
|
|
45
|
+
const styleExts = parser_1.ExtensionConfig.STYLES;
|
|
46
|
+
const scriptPath = scriptExts
|
|
47
|
+
.map((item) => getFilePath(item))
|
|
48
|
+
.find((item) => fs_1.default.existsSync(item));
|
|
49
|
+
const stylePath = styleExts.map((item) => getFilePath(item)).find((item) => fs_1.default.existsSync(item));
|
|
50
|
+
let uxContent = ['<template>', content, '</template>'].join('\n');
|
|
51
|
+
if (scriptPath) {
|
|
52
|
+
uxContent += ['<script>', fs_1.default.readFileSync(scriptPath, 'utf-8'), '</script>'].join('\n');
|
|
53
|
+
}
|
|
54
|
+
if (stylePath) {
|
|
55
|
+
uxContent += ['<style>', fs_1.default.readFileSync(stylePath, 'utf-8'), '</style>'].join('\n');
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
path,
|
|
59
|
+
content: uxContent
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.default = HmlLoader;
|
|
@@ -23,7 +23,7 @@ class UxLoader {
|
|
|
23
23
|
const { projectPath } = this.context;
|
|
24
24
|
for (const file of files) {
|
|
25
25
|
// 转换每个文件
|
|
26
|
-
const { files, logs } = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
|
|
26
|
+
const { files: compiledFiles, logs } = yield UxLoaderUtils_1.default.compileUxToJavascript(file, this.context, false, this.compilerOption);
|
|
27
27
|
if (logs) {
|
|
28
28
|
logs.forEach((item) => {
|
|
29
29
|
ColorConsole_1.default.logger(Object.assign(Object.assign({}, item), { filePath: item.filePath ? path_1.default.relative(projectPath, item.filePath) : '' }));
|
|
@@ -33,7 +33,7 @@ class UxLoader {
|
|
|
33
33
|
throw new Error('stop!');
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
resultFiles.push(...
|
|
36
|
+
resultFiles.push(...compiledFiles);
|
|
37
37
|
}
|
|
38
38
|
return resultFiles;
|
|
39
39
|
});
|
|
@@ -19,6 +19,7 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
19
19
|
const path_1 = __importDefault(require("path"));
|
|
20
20
|
const TranslateCache_1 = __importDefault(require("../../../parser/lib/ux/translate/vela/TranslateCache"));
|
|
21
21
|
const UxFileUtils_1 = __importDefault(require("./ux/UxFileUtils"));
|
|
22
|
+
const parser_1 = require("@aiot-toolkit/parser");
|
|
22
23
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
23
24
|
/**
|
|
24
25
|
* PreWorkUtils
|
|
@@ -51,13 +52,14 @@ class PreWorkUtils {
|
|
|
51
52
|
Object.keys(pages).map((page) => {
|
|
52
53
|
const pageContent = pages[page];
|
|
53
54
|
const entryDir = path_1.default.join(srcPath, page);
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
const entryPages = parser_1.ExtensionConfig.TEMPLATES.map((item) => `${pageContent.component}${item}`);
|
|
56
|
+
const entry = entryPages.find((item) => fs_extra_1.default.existsSync(path_1.default.join(entryDir, item)));
|
|
57
|
+
if (entry) {
|
|
58
|
+
entryList.push(path_1.default.join(entryDir, entry));
|
|
57
59
|
}
|
|
58
60
|
else {
|
|
59
61
|
// 路径不存在
|
|
60
|
-
ColorConsole_1.default.throw(`### manifest ### path '${
|
|
62
|
+
ColorConsole_1.default.throw(`### manifest ### path '${entryPages.join(' | ')}' does not exist`);
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
context['entries'] = entryList;
|
|
@@ -24,7 +24,10 @@ declare class UxLoaderUtils {
|
|
|
24
24
|
* @param resultFiles
|
|
25
25
|
* @param context
|
|
26
26
|
*/
|
|
27
|
-
static compileAppUxToJavascript(file: IFileParam,
|
|
27
|
+
static compileAppUxToJavascript(file: IFileParam, context: IFileLaneContext, compileOption: IJavascriptCompileOption): Promise<{
|
|
28
|
+
files: IFileParam<any>[];
|
|
29
|
+
logs: ILog[];
|
|
30
|
+
}>;
|
|
28
31
|
/**
|
|
29
32
|
* 判断是否为src/app.ux
|
|
30
33
|
* @param filePath
|
|
@@ -40,10 +40,11 @@ const UxParser_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/parser/U
|
|
|
40
40
|
const UxToTypescript_1 = __importDefault(require("@aiot-toolkit/parser/lib/ux/translate/vela/UxToTypescript"));
|
|
41
41
|
const ColorConsole_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/ColorConsole"));
|
|
42
42
|
const FileUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/FileUtil"));
|
|
43
|
-
const
|
|
44
|
-
const parse5 = __importStar(require("parse5"));
|
|
43
|
+
const parse5 = __importStar(require("aiot-parse5"));
|
|
45
44
|
const path_1 = __importDefault(require("path"));
|
|
45
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
46
46
|
const ts_morph_1 = require("ts-morph");
|
|
47
|
+
const CommonUtil_1 = __importDefault(require("@aiot-toolkit/shared-utils/lib/utils/CommonUtil"));
|
|
47
48
|
const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
|
|
48
49
|
const { extractFunctions } = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/protobufControl');
|
|
49
50
|
/**
|
|
@@ -81,13 +82,30 @@ class UxLoaderUtils {
|
|
|
81
82
|
projectPath: context.projectPath,
|
|
82
83
|
filePath,
|
|
83
84
|
fileType: isAppUx ? 'app' : isPageUx ? 'page' : '',
|
|
85
|
+
content: content.toString(),
|
|
84
86
|
onLog: (log) => {
|
|
85
87
|
logs.push(log);
|
|
86
88
|
}
|
|
87
89
|
};
|
|
90
|
+
// 收集图片资源
|
|
91
|
+
const ImageResources = [];
|
|
92
|
+
const collectImageResource = (originFilePath) => {
|
|
93
|
+
const assetDir = 'dynamicAssets';
|
|
94
|
+
const sourcePath = path_1.default.resolve(options.projectPath, compilerOption.sourceRoot);
|
|
95
|
+
const assetPath = path_1.default.resolve(sourcePath, assetDir);
|
|
96
|
+
const { name, ext } = path_1.default.parse(originFilePath);
|
|
97
|
+
const hashName = CommonUtil_1.default.calcImageDigest(originFilePath);
|
|
98
|
+
const newFilePath = path_1.default.join(assetPath, `${name}-${hashName}${ext}`);
|
|
99
|
+
const relativePath = path_1.default.posix.sep + path_1.default.relative(sourcePath, newFilePath).split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
100
|
+
ImageResources.push({
|
|
101
|
+
path: newFilePath,
|
|
102
|
+
content: fs_extra_1.default.readFileSync(originFilePath)
|
|
103
|
+
});
|
|
104
|
+
return relativePath;
|
|
105
|
+
};
|
|
88
106
|
// 开始转换
|
|
89
107
|
const globalVar = ('globalVar' in context && context.globalVar) || {};
|
|
90
|
-
const parserResult = yield new UxParser_1.default(options, globalVar).parser(
|
|
108
|
+
const parserResult = yield new UxParser_1.default(options, compilerOption, globalVar, collectImageResource).parser();
|
|
91
109
|
// 区分app.ux和一般ux
|
|
92
110
|
// app.ux解析结果中加上manifest.json的内容
|
|
93
111
|
const manifestJson = `require('./manifest.json')`;
|
|
@@ -96,7 +114,7 @@ class UxLoaderUtils {
|
|
|
96
114
|
return isAppUx
|
|
97
115
|
? [
|
|
98
116
|
`${appImport.join('\n')}`,
|
|
99
|
-
`var $app_style$ = ${UxLoaderUtils.wrapStyle(
|
|
117
|
+
`var $app_style$ = ${UxLoaderUtils.wrapStyle(JSON.stringify(appStyleTree), file, compilerOption)}`,
|
|
100
118
|
`var $app_script$ = ${UxLoaderUtils.handleScriptContent(false, appScriptTree)}\n`,
|
|
101
119
|
`$app_script$({}, $app_exports$, $app_require$);\n\n`,
|
|
102
120
|
`$app_exports$.default.style = $app_style$;`,
|
|
@@ -104,7 +122,7 @@ class UxLoaderUtils {
|
|
|
104
122
|
]
|
|
105
123
|
: [
|
|
106
124
|
`${appImport.join('\n')}`,
|
|
107
|
-
`var $app_style$ = ${UxLoaderUtils.wrapStyle(
|
|
125
|
+
`var $app_style$ = ${UxLoaderUtils.wrapStyle(JSON.stringify(appStyleTree), file, compilerOption)}\n`,
|
|
108
126
|
`var $app_script$ = ${UxLoaderUtils.handleScriptContent(isPageUx, appScriptTree)}`,
|
|
109
127
|
`var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}\n`,
|
|
110
128
|
`${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`,
|
|
@@ -125,13 +143,14 @@ class UxLoaderUtils {
|
|
|
125
143
|
return {
|
|
126
144
|
files: [
|
|
127
145
|
{
|
|
128
|
-
path:
|
|
146
|
+
path: filePath,
|
|
129
147
|
content: code
|
|
130
148
|
},
|
|
131
149
|
{
|
|
132
150
|
path: FileUtil_1.default.updatePath(filePath, `${name}.js.map`),
|
|
133
151
|
content: sourceMap.toString()
|
|
134
|
-
}
|
|
152
|
+
},
|
|
153
|
+
...ImageResources
|
|
135
154
|
],
|
|
136
155
|
logs
|
|
137
156
|
};
|
|
@@ -143,7 +162,7 @@ class UxLoaderUtils {
|
|
|
143
162
|
* @param resultFiles
|
|
144
163
|
* @param context
|
|
145
164
|
*/
|
|
146
|
-
static compileAppUxToJavascript(file,
|
|
165
|
+
static compileAppUxToJavascript(file, context, compileOption) {
|
|
147
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
148
167
|
const { path: filePath, content } = file;
|
|
149
168
|
let appContent = content;
|
|
@@ -154,7 +173,7 @@ class UxLoaderUtils {
|
|
|
154
173
|
}
|
|
155
174
|
// 解析script和style两部分
|
|
156
175
|
const compileResult = yield UxLoaderUtils.compileUxToJavascript({ path: filePath, content: appContent }, context, isAppUx, compileOption);
|
|
157
|
-
|
|
176
|
+
return compileResult;
|
|
158
177
|
});
|
|
159
178
|
}
|
|
160
179
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.0.2-beta.
|
|
3
|
+
"version": "2.0.2-beta.6",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.0.2-beta.
|
|
23
|
-
"@aiot-toolkit/parser": "2.0.2-beta.
|
|
22
|
+
"@aiot-toolkit/generator": "2.0.2-beta.6",
|
|
23
|
+
"@aiot-toolkit/parser": "2.0.2-beta.6",
|
|
24
24
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
25
25
|
"babel-loader": "^9.1.3",
|
|
26
26
|
"del": "^4.1.0",
|
|
27
27
|
"fast-glob": "^3.3.2",
|
|
28
|
-
"file-lane": "2.0.2-beta.
|
|
28
|
+
"file-lane": "2.0.2-beta.6",
|
|
29
29
|
"file-loader": "^6.2.0",
|
|
30
30
|
"fs-extra": "^11.2.0",
|
|
31
31
|
"jsrsasign": "^7.2.2",
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"source-map": "^0.7.4",
|
|
34
34
|
"url-loader": "^4.1.1",
|
|
35
35
|
"webpack": "^5.89.0",
|
|
36
|
+
"webpack-bundle-analyzer": "^4.10.1",
|
|
36
37
|
"webpack-sources": "^3.2.3"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
40
|
+
"@types/fs-extra": "^11.0.4",
|
|
39
41
|
"@types/jsrsasign": "^10.5.12",
|
|
40
42
|
"@types/webpack-sources": "^3.2.3"
|
|
41
43
|
},
|
|
42
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "b9b99afff176075380c2ec95b43797d696c393c1"
|
|
43
45
|
}
|