xhs-mp-compiler-cli 2.0.20 → 2.0.21

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.
Files changed (2) hide show
  1. package/dist/compilerImpl.js +28 -12
  2. package/package.json +11 -11
@@ -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' && babelLoaderReg.test(i.moduleIdentifier) && (match = (_a = i.moduleName) === null || _a === void 0 ? void 0 : _a.match(jsScriptReg))) {
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.split('\n').filter(Boolean).map(text => {
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
- }).filter(Boolean);
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' && swcLoaderReg.test(i.moduleIdentifier) && (match = (_b = i.moduleName) === null || _b === void 0 ? void 0 : _b.match(jsScriptReg))) {
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.split('\n').filter(Boolean).map(text => {
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
- }).filter(Boolean);
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,10 +227,10 @@ 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] create compiler');
230
+ console.log('[compiler] runWatch');
219
231
  createProjectPacker(data);
220
232
  sendBuildInfoMessage('run-watch', '执行编译');
221
- const { err, stats } = (yield projectPacker.watch({}, (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
  // 修改文件时构建
@@ -234,7 +246,7 @@ const handlers = {
234
246
  sendMessage({
235
247
  event: 'compileFinishWhenFileChange'
236
248
  });
237
- }));
249
+ });
238
250
  console.log('[compiler] it is watching...', err, stats);
239
251
  const hasError = err || stats.hasErrors();
240
252
  if (hasError) {
@@ -289,4 +301,8 @@ const handlers = {
289
301
  globalConfig = null;
290
302
  }
291
303
  };
304
+ // try {
292
305
  workerPool.worker(handlers);
306
+ // } catch (error) {
307
+ // console.error('workerPool error:', error)
308
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xhs-mp-compiler-cli",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
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.20",
92
- "xhs-mp-compiler-utils": "2.0.20",
93
- "xhs-mp-pack": "2.0.20",
94
- "xhs-mp-project": "2.0.20",
95
- "xhs-mp-shared": "2.0.20",
96
- "xhs-mp-shared-fs": "2.0.20",
97
- "xhs-mp-sjs-loader": "2.0.20",
98
- "xhs-mp-sketch-loader": "2.0.20",
91
+ "xhs-mp-ml-loader": "2.0.21",
92
+ "xhs-mp-compiler-utils": "2.0.21",
93
+ "xhs-mp-pack": "2.0.21",
94
+ "xhs-mp-project": "2.0.21",
95
+ "xhs-mp-shared": "2.0.21",
96
+ "xhs-mp-shared-fs": "2.0.21",
97
+ "xhs-mp-sjs-loader": "2.0.21",
98
+ "xhs-mp-sketch-loader": "2.0.21",
99
99
  "yauzl": "^2.10.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "xhs-mp-ml-parser": "2.0.20"
102
+ "xhs-mp-ml-parser": "2.0.21"
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.20"
125
+ "xhs-mp-ml-parser": "2.0.21"
126
126
  },
127
127
  "scripts": {
128
128
  "version": "formula changelog && git add .",