xhs-mp-compiler-cli 2.0.8-beta.0 → 2.0.9

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.
@@ -51,7 +51,7 @@ export declare class MPPackDevCompiler extends AbstractCompiler {
51
51
  constructor(props: any, args: any);
52
52
  makePoolReady(): void;
53
53
  reset(): void;
54
- doCompilePkgs(opts: ICheckOptions): Promise<unknown>;
54
+ private doCompilePkgs;
55
55
  private compilePkgsAndWatch;
56
56
  private addPkgsToWatch;
57
57
  changeCompileOptions(options: any): void;
@@ -63,7 +63,8 @@ export declare class WebPackDevCompiler extends AbstractCompiler {
63
63
  private pendingTask?;
64
64
  constructor(props: any, args: any);
65
65
  makePoolReady(args: any): void;
66
- makePkgsReady(opts: any): Promise<unknown>;
66
+ private doCompilePkgs;
67
+ makePkgsReady(opts: any): Promise<void>;
67
68
  reCompilePkgs(opts: any): Promise<void>;
68
69
  }
69
70
  export declare class BuildCompiler extends AbstractCompiler {
package/dist/compiler.js CHANGED
@@ -265,10 +265,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
265
265
  reCompilePkgs(options) {
266
266
  return __awaiter(this, void 0, void 0, function* () {
267
267
  this.readyPkgs = [];
268
- this.changeCompileOptions(options);
269
- if (!this.pending && !this.watching) {
270
- this.pendingPkgs = {};
271
- }
268
+ this.pendingPkgs = {};
269
+ this.pending = false;
270
+ this.watching = false;
271
+ this.close();
272
272
  yield this.doCompilePkgs(options);
273
273
  });
274
274
  }
@@ -294,7 +294,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
294
294
  }
295
295
  this.pool.emitWorkerMessage = this.emit.bind(this);
296
296
  }
297
- makePkgsReady(opts) {
297
+ doCompilePkgs(opts) {
298
298
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
299
299
  var _a, _b, _c, _d;
300
300
  if (this.watching) {
@@ -327,21 +327,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
327
327
  }
328
328
  }));
329
329
  }
330
+ makePkgsReady(opts) {
331
+ return __awaiter(this, void 0, void 0, function* () {
332
+ yield this.doCompilePkgs(opts);
333
+ });
334
+ }
330
335
  reCompilePkgs(opts) {
331
336
  return __awaiter(this, void 0, void 0, function* () {
332
- if (!this.watching) {
333
- yield this.makePkgsReady(opts);
334
- return;
335
- }
336
- try {
337
- this.emit('buildStart');
338
- yield this.call('runTask', Object.assign({ action: 'dev' }, opts));
339
- this.emit('buildSuccess');
340
- }
341
- catch (error) {
342
- this.emit('buildError', { errors: [error.message] });
343
- throw error;
344
- }
337
+ this.pendingTask = undefined;
338
+ this.watching = false;
339
+ this.close();
340
+ yield this.doCompilePkgs(opts);
345
341
  });
346
342
  }
347
343
  }
@@ -166,6 +166,7 @@ const handlers = {
166
166
  var _a;
167
167
  (_a = projectPacker === null || projectPacker === void 0 ? void 0 : projectPacker.close) === null || _a === void 0 ? void 0 : _a.call(projectPacker, () => { });
168
168
  projectPacker = null;
169
+ globalConfig = null;
169
170
  }
170
171
  };
171
172
  workerpool.worker(handlers);
@@ -167,12 +167,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
167
167
  if (fs_extra_1.default.existsSync(parenCacheDir)) {
168
168
  fs_extra_1.default.removeSync(parenCacheDir);
169
169
  }
170
- // 移除编译产物
171
- const distDir = this.getDistDir();
172
- const parentDistDir = path_1.default.dirname(distDir);
173
- if (fs_extra_1.default.existsSync(parentDistDir)) {
174
- fs_extra_1.default.removeSync(parentDistDir);
175
- }
176
170
  }
177
171
  createCompiler(entryType = constant_config_1.COMPILE_ENTRY.simulator) {
178
172
  const { nodeJsPath } = this.compilerProps;
@@ -204,38 +198,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
204
198
  // 使用的编译目标包类型
205
199
  getUsingPackageType() {
206
200
  return __awaiter(this, arguments, void 0, function* (entryType = constant_config_1.COMPILE_ENTRY.simulator) {
207
- let enableV1 = false;
208
- let enableV2 = true;
201
+ let enableV1 = true;
202
+ // let enableV2 = false
209
203
  let enableVDom = false;
210
204
  const settings = this.project.settings || {};
211
205
  const isUpload = entryType === constant_config_1.COMPILE_ENTRY.upload;
212
206
  if (this.project.appMode === constant_config_1.MiniMode.minigame) {
213
- enableV1 = true;
214
- enableV2 = false;
207
+ // enableV1 = true
208
+ // enableV2 = false
215
209
  enableVDom = false;
216
210
  }
217
211
  else if (entryType === constant_config_1.COMPILE_ENTRY.simulator) {
218
212
  if (this.compilerProps.getLibFeatures) {
219
213
  const libFeatures = yield this.compilerProps.getLibFeatures();
220
- enableV2 = libFeatures.supportV2 && settings.enableV2;
221
- enableVDom = !enableV2 && libFeatures.supportVDom && settings.enableVDom;
214
+ // enableV2 = libFeatures.supportV2 && settings.enableV2
215
+ enableVDom = libFeatures.supportVDom && settings.enableVDom;
222
216
  }
223
217
  else {
224
- enableV2 = settings.enableV2;
225
- enableVDom = !enableV2 && settings.enableVDom;
218
+ // enableV2 = settings.enableV2
219
+ enableVDom = settings.enableVDom;
226
220
  }
227
221
  // enableVDom = !enableV2 && settings.enableVDom
228
- enableV1 = !enableV2;
222
+ // enableV1 = !enableV2
229
223
  }
230
224
  else {
231
225
  // 上传模式下按照勾选开启
232
226
  enableVDom = settings.enableVDom;
233
- enableV2 = settings.enableV2;
234
- enableV1 = true;
227
+ // enableV2 = settings.enableV2
228
+ // enableV1 = true
235
229
  }
236
230
  return {
237
231
  enableV1,
238
- enableV2,
232
+ // 下掉v2 按需注入包
233
+ enableV2: false,
239
234
  enableVDom
240
235
  };
241
236
  });
@@ -284,7 +279,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
284
279
  }
285
280
  reCompilePkgs(opts) {
286
281
  return __awaiter(this, void 0, void 0, function* () {
287
- var _a, _b;
282
+ var _a, _b, _c;
288
283
  const { compilePkgs } = opts;
289
284
  const entryType = constant_config_1.COMPILE_ENTRY.simulator;
290
285
  const compiler = this.getCompiler(entryType);
@@ -294,10 +289,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
294
289
  console.log('[compiler]reCompilePkgs', config);
295
290
  try {
296
291
  this.emit('recompile-pkgs-start', { config });
297
- // getSharedFs(true)?.clear()
292
+ this.removeCacheDir();
293
+ this.removeDistDir();
294
+ (_a = (0, sharedFs_1.default)(true)) === null || _a === void 0 ? void 0 : _a.clear();
298
295
  yield compiler.reCompilePkgs(config);
299
296
  this.emit('recompile-pkgs-end', { config });
300
- (_a = this.report) === null || _a === void 0 ? void 0 : _a.call(this, 'compile', {
297
+ (_b = this.report) === null || _b === void 0 ? void 0 : _b.call(this, 'compile', {
301
298
  result: 'success',
302
299
  entryType,
303
300
  config: JSON.stringify(config),
@@ -306,7 +303,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
306
303
  }
307
304
  catch (error) {
308
305
  this.emit('recompile-pkgs-error', { config, error });
309
- (_b = this.report) === null || _b === void 0 ? void 0 : _b.call(this, 'compile', {
306
+ (_c = this.report) === null || _c === void 0 ? void 0 : _c.call(this, 'compile', {
310
307
  result: 'fail',
311
308
  entryType,
312
309
  config: JSON.stringify(config),
@@ -37,7 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  });
38
38
  chain.watch(action === 'dev');
39
39
  chain.mode('development');
40
- chain.devtool(enableSourcemap ? 'source-map' : false);
40
+ chain.devtool(false);
41
41
  // @ts-ignore
42
42
  chain.target(['web', 'es5']);
43
43
  };
@@ -31,6 +31,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
31
31
  chain.plugin('InjectorPlugin').use(InjectorPlugin_1.InjectorPlugin, [options]);
32
32
  chain.plugin('ServiceEntryPlugin').use(serviceEntryPlugin_1.default, [options]);
33
33
  chain.plugin('ServiceChunkPlugin').use(serviceChunkPlugin_1.default, [options]);
34
+ // sourcemap
35
+ chain.devtool(enableSourcemap ? 'source-map' : false);
34
36
  if (enableSourcemap && !appendSourcemapComment) {
35
37
  const SourceMapDevToolPlugin = (0, SourceMapDevToolPlugin_1.getSourceMapDevtoolPlugin)(options.packMode);
36
38
  chain.plugin('SourceMapDevToolPlugin').use(SourceMapDevToolPlugin, [{
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
7
7
  if (v !== undefined) module.exports = v;
8
8
  }
9
9
  else if (typeof define === "function" && define.amd) {
10
- define(["require", "exports", "path", "./sjsEntryPlugin", "./render", "./component", "./sketch", "./renderChunkPlugin", "../../../../types", "../../../plugins/InjectorPlugin", "../../../plugins/SourceMapDevToolPlugin", "../../../../utils/cache", "../../../../config/constant.config"], factory);
10
+ define(["require", "exports", "path", "./sjsEntryPlugin", "./render", "./component", "./sketch", "./renderChunkPlugin", "../../../../types", "../../../plugins/InjectorPlugin", "../../../../utils/cache", "../../../../config/constant.config"], factory);
11
11
  }
12
12
  })(function (require, exports) {
13
13
  "use strict";
@@ -21,7 +21,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
21
21
  const renderChunkPlugin_1 = __importDefault(require("./renderChunkPlugin"));
22
22
  const types_1 = require("../../../../types");
23
23
  const InjectorPlugin_1 = require("../../../plugins/InjectorPlugin");
24
- const SourceMapDevToolPlugin_1 = require("../../../plugins/SourceMapDevToolPlugin");
25
24
  const cache_1 = require("../../../../utils/cache");
26
25
  const constant_config_1 = require("../../../../config/constant.config");
27
26
  const getRenderEntry = (options) => () => {
@@ -107,13 +106,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
107
106
  chain.plugin('InjectorPlugin').use(InjectorPlugin_1.InjectorPlugin, [options]);
108
107
  chain.plugin('SjsEntryPlugin').use(sjsEntryPlugin_1.default, [options]);
109
108
  chain.plugin("RenderChunkPlugin").use(renderChunkPlugin_1.default, [options]);
110
- if (enableSourcemap && !appendSourcemapComment) {
111
- const SourceMapDevToolPlugin = (0, SourceMapDevToolPlugin_1.getSourceMapDevtoolPlugin)(options.packMode);
112
- chain.plugin('SourceMapDevToolPlugin').use(SourceMapDevToolPlugin, [{
113
- filename: '[file].map',
114
- append: false
115
- }]);
116
- }
117
109
  };
118
110
  exports.presetRender = presetRender;
119
111
  });
@@ -65,6 +65,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
65
65
  } }, (0, cache_1.getCacheConfig)(absCacheDirectory, options)));
66
66
  chain.plugin('InjectorPlugin').use(InjectorPlugin_1.InjectorPlugin, [options]);
67
67
  chain.plugin('ServiceChunkPlugin').use(serviceChunkPlugin_1.default, [options]);
68
+ // sourcemap
69
+ chain.devtool(enableSourcemap ? 'source-map' : false);
68
70
  if (enableSourcemap && !appendSourcemapComment) {
69
71
  const SourceMapDevToolPlugin = (0, SourceMapDevToolPlugin_1.getSourceMapDevtoolPlugin)(options.packMode);
70
72
  chain.plugin('SourceMapDevToolPlugin').use(SourceMapDevToolPlugin, [{
@@ -32,9 +32,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
32
32
  const assetsChain = new xhs_mp_pack_1.Config();
33
33
  const serviceChain = new xhs_mp_pack_1.Config();
34
34
  const renderChain = new xhs_mp_pack_1.Config();
35
- const assetsPresets = [assets_1.presetAssets, common_1.default];
36
- const servicePresets = [service_1.presetService, common_1.default, babel_1.default];
37
- const renderPresets = [render_1.presetRender, common_1.default, babel_1.default];
35
+ const assetsPresets = [common_1.default, assets_1.presetAssets];
36
+ const servicePresets = [common_1.default, service_1.presetService, babel_1.default];
37
+ const renderPresets = [common_1.default, render_1.presetRender, babel_1.default];
38
38
  if (env === xhs_mp_pack_1.ENV.production) {
39
39
  assetsPresets.push(prod_1.default);
40
40
  servicePresets.push(prod_1.default);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xhs-mp-compiler-cli",
3
- "version": "2.0.8-beta.0",
3
+ "version": "2.0.9",
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.1.3",
91
- "xhs-mp-ml-loader": "2.0.8-beta.0",
92
- "xhs-mp-compiler-utils": "2.0.8-beta.0",
93
- "xhs-mp-pack": "2.0.8-beta.0",
94
- "xhs-mp-project": "2.0.8-beta.0",
95
- "xhs-mp-shared": "2.0.8-beta.0",
96
- "xhs-mp-shared-fs": "2.0.8-beta.0",
97
- "xhs-mp-sjs-loader": "2.0.8-beta.0",
98
- "xhs-mp-sketch-loader": "2.0.8-beta.0",
91
+ "xhs-mp-ml-loader": "2.0.9",
92
+ "xhs-mp-compiler-utils": "2.0.9",
93
+ "xhs-mp-pack": "2.0.9",
94
+ "xhs-mp-project": "2.0.9",
95
+ "xhs-mp-shared": "2.0.9",
96
+ "xhs-mp-shared-fs": "2.0.9",
97
+ "xhs-mp-sjs-loader": "2.0.9",
98
+ "xhs-mp-sketch-loader": "2.0.9",
99
99
  "yauzl": "^2.10.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "xhs-mp-ml-parser": "2.0.8-beta.0"
102
+ "xhs-mp-ml-parser": "2.0.9"
103
103
  },
104
104
  "devDependencies": {
105
105
  "@types/babel__generator": "7.6.3",
@@ -123,7 +123,7 @@
123
123
  "typescript": "5.1.6",
124
124
  "vue3-jest": "27.0.0-alpha.2",
125
125
  "webpack-dev-server": "4.0.0-beta.3",
126
- "xhs-mp-ml-parser": "2.0.8-beta.0"
126
+ "xhs-mp-ml-parser": "2.0.9"
127
127
  },
128
128
  "scripts": {
129
129
  "version": "formula changelog && git add .",