xhs-mp-compiler-cli 1.9.1 → 1.9.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/dist/compiler.js +12 -1
- package/dist/compilerImpl.d.ts +2 -1
- package/dist/compilerImpl.js +15 -4
- package/package.json +8 -8
package/dist/compiler.js
CHANGED
|
@@ -57,10 +57,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
57
57
|
const pool = xhs_mp_workerpool_1.default.pool(__dirname + '/compilerImpl.js', Object.assign({ workerType: workerType, workerThreadOpts,
|
|
58
58
|
forkOpts,
|
|
59
59
|
workerOpts }, poolOpts));
|
|
60
|
+
let messageBuffers = [];
|
|
60
61
|
const handlerWorker = workerIns => {
|
|
61
62
|
workerIns.worker.on('message', payload => {
|
|
62
63
|
if (payload === null || payload === void 0 ? void 0 : payload.customMessage) {
|
|
63
|
-
pool.emitWorkerMessage
|
|
64
|
+
if (!pool.emitWorkerMessage) {
|
|
65
|
+
messageBuffers.push(payload);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (messageBuffers.length) {
|
|
69
|
+
messageBuffers.forEach(payload => {
|
|
70
|
+
pool === null || pool === void 0 ? void 0 : pool.emitWorkerMessage(payload.event, payload.data);
|
|
71
|
+
});
|
|
72
|
+
messageBuffers = [];
|
|
73
|
+
}
|
|
74
|
+
pool === null || pool === void 0 ? void 0 : pool.emitWorkerMessage(payload.event, payload.data);
|
|
64
75
|
}
|
|
65
76
|
});
|
|
66
77
|
};
|
package/dist/compilerImpl.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
declare const createPacker: any;
|
|
2
1
|
declare const workerpool: any;
|
|
2
|
+
declare const createPacker: any;
|
|
3
3
|
declare let globalConfig: any;
|
|
4
4
|
declare let projectPacker: any;
|
|
5
5
|
declare function formatOutputMessages(err: any, stats: any): {
|
|
@@ -7,6 +7,7 @@ declare function formatOutputMessages(err: any, stats: any): {
|
|
|
7
7
|
warnings: any;
|
|
8
8
|
};
|
|
9
9
|
declare function sendMessage(data: any): void;
|
|
10
|
+
declare function sendBuildInfoMessage(type: any, message: any): void;
|
|
10
11
|
declare function createProjectPacker(data: any): any;
|
|
11
12
|
declare const handlers: {
|
|
12
13
|
runWatch: (data: any) => Promise<any>;
|
package/dist/compilerImpl.js
CHANGED
|
@@ -8,10 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
// console.log('[compiler] load packer start')
|
|
12
|
-
const { createPacker } = require('./packs');
|
|
13
11
|
const workerpool = require('xhs-mp-workerpool');
|
|
14
|
-
|
|
12
|
+
sendBuildInfoMessage('load-packer', '开始加载compiler');
|
|
13
|
+
const { createPacker } = require('./packs');
|
|
14
|
+
sendBuildInfoMessage('load-packer', '加载compiler完成');
|
|
15
15
|
let globalConfig = {};
|
|
16
16
|
let projectPacker;
|
|
17
17
|
function formatOutputMessages(err, stats) {
|
|
@@ -62,6 +62,15 @@ function sendMessage(data) {
|
|
|
62
62
|
throw new Error('Script must be executed as a worker');
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
+
function sendBuildInfoMessage(type, message) {
|
|
66
|
+
sendMessage({
|
|
67
|
+
event: 'compileInfo',
|
|
68
|
+
data: {
|
|
69
|
+
type,
|
|
70
|
+
message
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
65
74
|
function createProjectPacker(data) {
|
|
66
75
|
if (!projectPacker) {
|
|
67
76
|
projectPacker = createPacker(data);
|
|
@@ -84,7 +93,7 @@ const handlers = {
|
|
|
84
93
|
runWatch: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
94
|
console.log('[compiler] create compiler');
|
|
86
95
|
createProjectPacker(data);
|
|
87
|
-
|
|
96
|
+
sendBuildInfoMessage('run-watch', '执行编译');
|
|
88
97
|
const { err, stats } = (yield projectPacker.watch({
|
|
89
98
|
scene: data.scene
|
|
90
99
|
}, (err, stats) => {
|
|
@@ -120,6 +129,7 @@ const handlers = {
|
|
|
120
129
|
var _a, _b, _c;
|
|
121
130
|
const { compilePkgs } = data;
|
|
122
131
|
console.log('run activate start', compilePkgs);
|
|
132
|
+
sendBuildInfoMessage('run-activatePkgs', '执行编译');
|
|
123
133
|
const { err, stats } = (yield ((_b = (_a = projectPacker).activatePkgs) === null || _b === void 0 ? void 0 : _b.call(_a, compilePkgs)));
|
|
124
134
|
console.log('run activate finish', err, stats);
|
|
125
135
|
const hasError = err || ((_c = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _c === void 0 ? void 0 : _c.call(stats));
|
|
@@ -130,6 +140,7 @@ const handlers = {
|
|
|
130
140
|
runBuild: data => {
|
|
131
141
|
return new Promise((resolve, reject) => {
|
|
132
142
|
createProjectPacker(data);
|
|
143
|
+
sendBuildInfoMessage('run-build', '执行编译');
|
|
133
144
|
projectPacker.build((err, stats) => {
|
|
134
145
|
var _a;
|
|
135
146
|
const hasError = err || ((_a = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _a === void 0 ? void 0 : _a.call(stats));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xhs-mp-compiler-cli",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -94,13 +94,13 @@
|
|
|
94
94
|
"webpack-chain": "^6.5.1",
|
|
95
95
|
"webpack-sources": "^3.2.2",
|
|
96
96
|
"xhs-mp-workerpool": "^9.1.3",
|
|
97
|
-
"xhs-mp-compiler-ml-loader": "3.0.
|
|
98
|
-
"xhs-mp-compiler-utils": "1.9.
|
|
99
|
-
"xhs-mp-pack": "1.9.
|
|
100
|
-
"xhs-mp-project": "1.9.
|
|
101
|
-
"xhs-mp-utils": "1.9.
|
|
102
|
-
"xhs-mp-shared-fs": "1.4.
|
|
103
|
-
"xhs-mp-compiler-sjs-loader": "1.9.
|
|
97
|
+
"xhs-mp-compiler-ml-loader": "3.0.2",
|
|
98
|
+
"xhs-mp-compiler-utils": "1.9.2",
|
|
99
|
+
"xhs-mp-pack": "1.9.2",
|
|
100
|
+
"xhs-mp-project": "1.9.2",
|
|
101
|
+
"xhs-mp-utils": "1.9.2",
|
|
102
|
+
"xhs-mp-shared-fs": "1.4.2",
|
|
103
|
+
"xhs-mp-compiler-sjs-loader": "1.9.2",
|
|
104
104
|
"yauzl": "^2.10.0"
|
|
105
105
|
},
|
|
106
106
|
"devDependencies": {
|