xhs-mp-compiler-cli 2.0.20 → 2.0.22
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 +0 -1
- package/dist/compilerImpl.js +37 -18
- package/package.json +11 -11
package/dist/compiler.js
CHANGED
|
@@ -320,7 +320,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
320
320
|
catch (error) {
|
|
321
321
|
this.watching = false;
|
|
322
322
|
(_d = this.pendingTask.reject) === null || _d === void 0 ? void 0 : _d.forEach(fn => fn(error));
|
|
323
|
-
throw error;
|
|
324
323
|
}
|
|
325
324
|
finally {
|
|
326
325
|
this.pendingTask = undefined;
|
package/dist/compilerImpl.js
CHANGED
|
@@ -52,12 +52,17 @@ function formatOutputError(err, stats) {
|
|
|
52
52
|
var _a, _b, _c, _d;
|
|
53
53
|
let match;
|
|
54
54
|
try {
|
|
55
|
-
if (typeof i.moduleIdentifier === 'string' &&
|
|
55
|
+
if (typeof i.moduleIdentifier === 'string' &&
|
|
56
|
+
babelLoaderReg.test(i.moduleIdentifier) &&
|
|
57
|
+
(match = (_a = i.moduleName) === null || _a === void 0 ? void 0 : _a.match(jsScriptReg))) {
|
|
56
58
|
// babel-loader 错误
|
|
57
59
|
const [_, filePath] = match;
|
|
58
60
|
const file = path.resolve(CWD, filePath);
|
|
59
61
|
let errorType, message, line, column;
|
|
60
|
-
const errorLines = i.message
|
|
62
|
+
const errorLines = i.message
|
|
63
|
+
.split('\n')
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.map(text => {
|
|
61
66
|
if (text.match(startLine) || text.match(at))
|
|
62
67
|
return;
|
|
63
68
|
const match1 = text.match(babelSyntaxError);
|
|
@@ -70,7 +75,8 @@ function formatOutputError(err, stats) {
|
|
|
70
75
|
return;
|
|
71
76
|
}
|
|
72
77
|
return text;
|
|
73
|
-
})
|
|
78
|
+
})
|
|
79
|
+
.filter(Boolean);
|
|
74
80
|
return {
|
|
75
81
|
file,
|
|
76
82
|
line: Number(line),
|
|
@@ -83,15 +89,20 @@ function formatOutputError(err, stats) {
|
|
|
83
89
|
file,
|
|
84
90
|
line: Number(line),
|
|
85
91
|
column: Number(column)
|
|
86
|
-
})
|
|
92
|
+
})
|
|
87
93
|
};
|
|
88
94
|
}
|
|
89
|
-
else if (typeof i.moduleIdentifier === 'string' &&
|
|
95
|
+
else if (typeof i.moduleIdentifier === 'string' &&
|
|
96
|
+
swcLoaderReg.test(i.moduleIdentifier) &&
|
|
97
|
+
(match = (_b = i.moduleName) === null || _b === void 0 ? void 0 : _b.match(jsScriptReg))) {
|
|
90
98
|
// swc-loader 错误
|
|
91
99
|
const [_, filePath] = match;
|
|
92
100
|
const file = path.resolve(CWD, filePath);
|
|
93
101
|
let line, column;
|
|
94
|
-
const errorLines = i.message
|
|
102
|
+
const errorLines = i.message
|
|
103
|
+
.split('\n')
|
|
104
|
+
.filter(Boolean)
|
|
105
|
+
.map(text => {
|
|
95
106
|
if (text.match(startLine) || text.match(at))
|
|
96
107
|
return;
|
|
97
108
|
const match1 = text.match(swcSyntaxError);
|
|
@@ -102,7 +113,8 @@ function formatOutputError(err, stats) {
|
|
|
102
113
|
return text.replace(swcSyntaxError, '───');
|
|
103
114
|
}
|
|
104
115
|
return text;
|
|
105
|
-
})
|
|
116
|
+
})
|
|
117
|
+
.filter(Boolean);
|
|
106
118
|
return {
|
|
107
119
|
file,
|
|
108
120
|
line: Number(line),
|
|
@@ -114,8 +126,8 @@ function formatOutputError(err, stats) {
|
|
|
114
126
|
errorLines: [],
|
|
115
127
|
file,
|
|
116
128
|
line: Number(line),
|
|
117
|
-
column: Number(column)
|
|
118
|
-
})
|
|
129
|
+
column: Number(column)
|
|
130
|
+
})
|
|
119
131
|
};
|
|
120
132
|
}
|
|
121
133
|
else if (i.file && (match = (_d = (_c = i.file) === null || _c === void 0 ? void 0 : _c.match) === null || _d === void 0 ? void 0 : _d.call(_c, scriptRegWithLineCol))) {
|
|
@@ -215,26 +227,25 @@ function createProjectPacker(data) {
|
|
|
215
227
|
}
|
|
216
228
|
const handlers = {
|
|
217
229
|
runWatch: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
218
|
-
console.log('[compiler]
|
|
230
|
+
console.log('[compiler] runWatch');
|
|
219
231
|
createProjectPacker(data);
|
|
220
232
|
sendBuildInfoMessage('run-watch', '执行编译');
|
|
221
|
-
const { err, stats } =
|
|
233
|
+
const { err, stats } = yield projectPacker.watch({}, (err, stats) => {
|
|
222
234
|
var _a;
|
|
223
235
|
console.log('[compiler] file change...', err, stats);
|
|
224
236
|
// 修改文件时构建
|
|
225
237
|
const hasError = err || ((_a = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _a === void 0 ? void 0 : _a.call(stats));
|
|
226
238
|
if (hasError) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// return
|
|
239
|
+
sendMessage({
|
|
240
|
+
event: 'compileErrorWhenFileChange',
|
|
241
|
+
data: formatOutputError(err, stats)
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
233
244
|
}
|
|
234
245
|
sendMessage({
|
|
235
246
|
event: 'compileFinishWhenFileChange'
|
|
236
247
|
});
|
|
237
|
-
})
|
|
248
|
+
});
|
|
238
249
|
console.log('[compiler] it is watching...', err, stats);
|
|
239
250
|
const hasError = err || stats.hasErrors();
|
|
240
251
|
if (hasError) {
|
|
@@ -289,4 +300,12 @@ const handlers = {
|
|
|
289
300
|
globalConfig = null;
|
|
290
301
|
}
|
|
291
302
|
};
|
|
303
|
+
// try {
|
|
292
304
|
workerPool.worker(handlers);
|
|
305
|
+
// } catch (error) {
|
|
306
|
+
// console.error('workerPool error:', error)
|
|
307
|
+
// }
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
globalThis.addEventListener('unhandledrejection', (err) => {
|
|
310
|
+
console.log(111, 'err', err);
|
|
311
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xhs-mp-compiler-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.22",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -88,18 +88,18 @@
|
|
|
88
88
|
"webpack-chain": "^6.5.1",
|
|
89
89
|
"webpack-sources": "^3.2.2",
|
|
90
90
|
"xhs-mp-workerpool": "^9.2.0",
|
|
91
|
-
"xhs-mp-ml-loader": "2.0.
|
|
92
|
-
"xhs-mp-compiler-utils": "2.0.
|
|
93
|
-
"xhs-mp-pack": "2.0.
|
|
94
|
-
"xhs-mp-project": "2.0.
|
|
95
|
-
"xhs-mp-shared": "2.0.
|
|
96
|
-
"xhs-mp-shared-fs": "2.0.
|
|
97
|
-
"xhs-mp-sjs-loader": "2.0.
|
|
98
|
-
"xhs-mp-sketch-loader": "2.0.
|
|
91
|
+
"xhs-mp-ml-loader": "2.0.22",
|
|
92
|
+
"xhs-mp-compiler-utils": "2.0.22",
|
|
93
|
+
"xhs-mp-pack": "2.0.22",
|
|
94
|
+
"xhs-mp-project": "2.0.22",
|
|
95
|
+
"xhs-mp-shared": "2.0.22",
|
|
96
|
+
"xhs-mp-shared-fs": "2.0.22",
|
|
97
|
+
"xhs-mp-sjs-loader": "2.0.22",
|
|
98
|
+
"xhs-mp-sketch-loader": "2.0.22",
|
|
99
99
|
"yauzl": "^2.10.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
|
-
"xhs-mp-ml-parser": "2.0.
|
|
102
|
+
"xhs-mp-ml-parser": "2.0.22"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@types/babel__generator": "7.6.3",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@types/node": "14",
|
|
123
123
|
"typescript": "5.1.6",
|
|
124
124
|
"webpack-dev-server": "4.0.0-beta.3",
|
|
125
|
-
"xhs-mp-ml-parser": "2.0.
|
|
125
|
+
"xhs-mp-ml-parser": "2.0.22"
|
|
126
126
|
},
|
|
127
127
|
"scripts": {
|
|
128
128
|
"version": "formula changelog && git add .",
|