xhs-mp-compiler-cli 1.9.1 → 1.9.3

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 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(payload.event, payload.data);
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
  };
@@ -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>;
@@ -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
- // console.log('[compiler] load packer end')
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
- // console.log('[compiler] watch start')
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));
@@ -37,14 +37,14 @@
37
37
  exports.COMPILE_FULL_PKG = 'xhs-full';
38
38
  exports.COMPILE_MAIN_PKG = 'xhs-main';
39
39
  exports.COMPILE_SUB_PKG = 'xhs-sub';
40
- exports.PROD_BROWSERSLIST = ['ios_saf >= 12', 'chrome >= 83'];
40
+ exports.PROD_BROWSERSLIST = ['ios_saf >= 10', 'chrome >= 83'];
41
41
  exports.DEV_BROWSERSLIST = ['last 2 chrome version'];
42
42
  exports.DEV_TARGETS = {
43
43
  chrome: '90'
44
44
  };
45
45
  exports.PROD_TARGETS = {
46
46
  chrome: '83',
47
- ios: '12'
47
+ ios: '10'
48
48
  };
49
49
  exports.ENTRY_CSS_NAME = 'app';
50
50
  exports.FULL_PKG = 'xhs-full';
package/dist/index.d.ts CHANGED
@@ -76,7 +76,6 @@ export declare class ProjectCompiler extends EventEmitter {
76
76
  reCompilePkgs(config: ICompilePkgsConfig): Promise<void>;
77
77
  compileProject(config: ICompileBuildConfig): Promise<void>;
78
78
  compileAndZip(opts: ICompileAndZipOptions): Promise<any>;
79
- private zipWithFullPackageWithAppId;
80
79
  private zipWithFullPackage;
81
80
  private zipWithSubPackage;
82
81
  close(entryType?: string): void;
package/dist/index.js CHANGED
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  if (v !== undefined) module.exports = v;
17
17
  }
18
18
  else if (typeof define === "function" && define.amd) {
19
- define(["require", "exports", "./config/constant.config", "xhs-mp-project", "events", "fs-extra", "path", "./utils/utils", "./utils/zip", "./utils/project", "./config/dir.config", "./compiler", "./config/constant.config"], factory);
19
+ define(["require", "exports", "./config/constant.config", "xhs-mp-project", "events", "fs-extra", "path", "./utils/utils", "./utils/project", "./config/dir.config", "./compiler", "./config/constant.config"], factory);
20
20
  }
21
21
  })(function (require, exports) {
22
22
  "use strict";
@@ -29,7 +29,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  const fs_extra_1 = __importDefault(require("fs-extra"));
30
30
  const path_1 = __importDefault(require("path"));
31
31
  const utils_1 = require("./utils/utils");
32
- const zip_1 = require("./utils/zip");
33
32
  const project_1 = require("./utils/project");
34
33
  const dir_config_1 = require("./config/dir.config");
35
34
  const compiler_1 = require("./compiler");
@@ -323,20 +322,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
323
322
  }
324
323
  else {
325
324
  // 真机调试
326
- // eslint-disable-next-line no-lonely-if
327
- if (!subPackages.length) {
328
- // 真机调试整包zip内产物文件需要放在appid目录下
329
- entryZips = [this.zipWithFullPackageWithAppId(opts, subPackages, 'v0')];
330
- }
331
- else {
332
- // eslint-disable-next-line no-lonely-if
333
- if (enableV2) {
334
- entryZips = [this.zipWithSubPackage(opts, subPackages, 'v2')];
335
- }
336
- else {
337
- entryZips = [this.zipWithSubPackage(opts, subPackages, 'v1')];
338
- }
339
- }
325
+ entryZips = [this.zipWithSubPackage(opts, subPackages, enableV2 ? 'v2' : 'v1')];
340
326
  }
341
327
  const zipTask = yield Promise.all(entryZips.filter(Boolean));
342
328
  const zipResult = zipTask.flat(2);
@@ -352,15 +338,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
352
338
  }
353
339
  }));
354
340
  }
355
- zipWithFullPackageWithAppId(opts_1) {
356
- return __awaiter(this, arguments, void 0, function* (opts, subPackages = [], type) {
357
- const { entryType } = opts;
358
- const buildDir = this.getDistDir(entryType);
359
- const distFullZip = path_1.default.resolve(buildDir, 'v0-full-pack.zip');
360
- const srcDirPath = path_1.default.resolve(buildDir, !subPackages.length ? 'v1' : 'v0'); // 如果没有开启分包,则把v1包当作v0包
361
- return (0, zip_1.genZip)(srcDirPath, distFullZip, this.project.projectAppId);
362
- });
363
- }
364
341
  /* 使用v0的入口,zip整包 */
365
342
  zipWithFullPackage(opts_1) {
366
343
  return __awaiter(this, arguments, void 0, function* (opts, subPackages = [], type) {
@@ -2,7 +2,6 @@ import { Config } from '../packs';
2
2
  import { IPresetOptions } from '../types';
3
3
  /**
4
4
  * babel 仅关注语法转换,polyfill 在 js-core 中已经内置
5
- * 目前 polyfill 仅支持到 'ios_saf >= 10', 'chrome >= 83'。语法构建中,会默认支持。
6
5
  */
7
6
  declare const getBaseConfig: (chain: Config, options: IPresetOptions) => void;
8
7
  export default getBaseConfig;
@@ -13,7 +13,6 @@
13
13
  const types_1 = require("../types");
14
14
  /**
15
15
  * babel 仅关注语法转换,polyfill 在 js-core 中已经内置
16
- * 目前 polyfill 仅支持到 'ios_saf >= 10', 'chrome >= 83'。语法构建中,会默认支持。
17
16
  */
18
17
  const getBaseConfig = (chain, options) => {
19
18
  const { packSetting } = options;
package/dist/utils/css.js CHANGED
@@ -7,20 +7,18 @@ 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", "postcss-preset-env", "./postcssRpx2Vw", "./const", "../types"], factory);
10
+ define(["require", "exports", "postcss-preset-env", "./postcssRpx2Vw", "../types", "../config/constant.config"], factory);
11
11
  }
12
12
  })(function (require, exports) {
13
13
  "use strict";
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- // @ts-nocheck
16
15
  const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
17
16
  const postcssRpx2Vw_1 = __importDefault(require("./postcssRpx2Vw"));
18
- const const_1 = __importDefault(require("./const"));
19
17
  const types_1 = require("../types");
20
- const { DEV_BROWSERSLIST, PROD_BROWSERSLIST } = const_1.default;
18
+ const constant_config_1 = require("../config/constant.config");
21
19
  const getCssConfig = (options, presets) => {
22
20
  const isDev = options.env === types_1.ENV.development;
23
- const browsers = isDev ? DEV_BROWSERSLIST : PROD_BROWSERSLIST;
21
+ const browsers = isDev ? constant_config_1.DEV_BROWSERSLIST : constant_config_1.PROD_BROWSERSLIST;
24
22
  const loaders = {
25
23
  'mini-style-loader': {
26
24
  loader: require.resolve('../presets/loaders/mini-style-loader'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xhs-mp-compiler-cli",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
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.1",
98
- "xhs-mp-compiler-utils": "1.9.1",
99
- "xhs-mp-pack": "1.9.1",
100
- "xhs-mp-project": "1.9.1",
101
- "xhs-mp-utils": "1.9.1",
102
- "xhs-mp-shared-fs": "1.4.1",
103
- "xhs-mp-compiler-sjs-loader": "1.9.1",
97
+ "xhs-mp-compiler-ml-loader": "3.0.3",
98
+ "xhs-mp-compiler-utils": "1.9.3",
99
+ "xhs-mp-pack": "1.9.3",
100
+ "xhs-mp-project": "1.9.3",
101
+ "xhs-mp-utils": "1.9.3",
102
+ "xhs-mp-shared-fs": "1.4.3",
103
+ "xhs-mp-compiler-sjs-loader": "1.9.3",
104
104
  "yauzl": "^2.10.0"
105
105
  },
106
106
  "devDependencies": {
@@ -1,27 +0,0 @@
1
- declare const CONSTANTS: {
2
- PROD_BROWSERSLIST: string[];
3
- DEV_BROWSERSLIST: string[];
4
- DEV_TARGETS: {
5
- chrome: string;
6
- };
7
- PROD_TARGETS: {
8
- chrome: string;
9
- ios: string;
10
- };
11
- ENTRY_CSS_NAME: string;
12
- FULL_PKG: string;
13
- MAIN_PKG: string;
14
- SUB_PKG: string;
15
- BUILD_REASON: {
16
- INIT: string;
17
- FILE_CHANGE: string;
18
- ACTIVATE_PKG: string;
19
- RECOMPILE: string;
20
- };
21
- ASSETS_EXTS: string[];
22
- PACK_MODE: {
23
- MPPACK: string;
24
- WEBPACK: string;
25
- };
26
- };
27
- export default CONSTANTS;
@@ -1,57 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const CONSTANTS = {
13
- PROD_BROWSERSLIST: ['ios_saf >= 12', 'chrome >= 83'],
14
- DEV_BROWSERSLIST: ['last 2 chrome version'],
15
- DEV_TARGETS: {
16
- chrome: '90',
17
- },
18
- PROD_TARGETS: {
19
- chrome: '83',
20
- ios: '12'
21
- },
22
- ENTRY_CSS_NAME: 'app',
23
- FULL_PKG: 'xhs-full',
24
- MAIN_PKG: 'xhs-main',
25
- SUB_PKG: 'xhs-sub',
26
- BUILD_REASON: {
27
- INIT: 'INIT',
28
- FILE_CHANGE: 'FILE_CHANGE',
29
- ACTIVATE_PKG: 'ACTIVATE_PKG',
30
- RECOMPILE: 'RECOMPILE',
31
- },
32
- ASSETS_EXTS: [
33
- 'png',
34
- 'jpg',
35
- 'jpeg',
36
- 'gif',
37
- 'svg',
38
- 'webp',
39
- 'cer',
40
- 'mp3',
41
- 'aac',
42
- 'm4a',
43
- 'mp4',
44
- 'wav',
45
- 'ogg',
46
- 'silk',
47
- 'wasm',
48
- 'br',
49
- 'plist',
50
- ],
51
- PACK_MODE: {
52
- MPPACK: 'mp-pack',
53
- WEBPACK: 'webpack'
54
- }
55
- };
56
- exports.default = CONSTANTS;
57
- });