xhs-mp-compiler-cli 1.9.2 → 1.9.4

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.
@@ -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;
@@ -12,7 +12,9 @@ declare class Reporter implements FeatureReporter.IReporter {
12
12
  reportMlWebComponent(value: string): void;
13
13
  reportJSONComponent(name: FeatureReporter.JSONComponent): void;
14
14
  reportStyleIsolation(value: string): void;
15
- reportJSONApp(name: FeatureReporter.JSONApp): void;
15
+ reportAppJSON(name: FeatureReporter.AppExtJSON): void;
16
+ reportExtJSON(name: FeatureReporter.AppExtJSON): void;
17
+ reportDevelopMode(name: FeatureReporter.DevelopMode): void;
16
18
  }
17
19
  export declare function createReporter(project: Project, option: ICompileAndZipOptions): Reporter | undefined;
18
20
  export {};
package/dist/utils/apm.js CHANGED
@@ -13,13 +13,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  if (v !== undefined) module.exports = v;
14
14
  }
15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "path", "xhs-mp-utils", "fs-extra"], factory);
16
+ define(["require", "exports", "path", "lodash", "xhs-mp-utils", "fs-extra"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.createReporter = createReporter;
22
22
  const path_1 = __importDefault(require("path"));
23
+ const lodash_1 = require("lodash");
23
24
  const xhs_mp_utils_1 = require("xhs-mp-utils");
24
25
  const fs_extra_1 = require("fs-extra");
25
26
  const pkg = require('../../package.json');
@@ -91,13 +92,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
91
92
  value,
92
93
  });
93
94
  }
94
- reportJSONApp(name) {
95
+ reportAppJSON(name) {
95
96
  var _a, _b;
96
97
  (_b = (_a = this.apm) === null || _a === void 0 ? void 0 : _a.report) === null || _b === void 0 ? void 0 : _b.call(_a, APMKEY, {
97
98
  type: xhs_mp_utils_1.FeatureReporter.MODULE.appJSON,
98
99
  name,
99
100
  });
100
101
  }
102
+ reportExtJSON(name) {
103
+ var _a, _b;
104
+ (_b = (_a = this.apm) === null || _a === void 0 ? void 0 : _a.report) === null || _b === void 0 ? void 0 : _b.call(_a, APMKEY, {
105
+ type: xhs_mp_utils_1.FeatureReporter.MODULE.extJSON,
106
+ name,
107
+ });
108
+ }
109
+ reportDevelopMode(name) {
110
+ var _a, _b;
111
+ (_b = (_a = this.apm) === null || _a === void 0 ? void 0 : _a.report) === null || _b === void 0 ? void 0 : _b.call(_a, APMKEY, {
112
+ type: xhs_mp_utils_1.FeatureReporter.MODULE.developMode,
113
+ name,
114
+ });
115
+ }
101
116
  }
102
117
  __decorate([
103
118
  onceByParams
@@ -116,19 +131,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
116
131
  ], Reporter.prototype, "reportStyleIsolation", null);
117
132
  __decorate([
118
133
  onceByParams
119
- ], Reporter.prototype, "reportJSONApp", null);
120
- function isObject(t) {
121
- return t != null && typeof t === 'object';
122
- }
123
- function isEmpty(t) {
124
- if (Array.isArray(t)) {
125
- return t.length === 0;
126
- }
127
- if (isObject(t)) {
128
- return Object.keys(t).length === 0;
129
- }
130
- return true;
131
- }
134
+ ], Reporter.prototype, "reportAppJSON", null);
135
+ __decorate([
136
+ onceByParams
137
+ ], Reporter.prototype, "reportExtJSON", null);
138
+ __decorate([
139
+ onceByParams
140
+ ], Reporter.prototype, "reportDevelopMode", null);
132
141
  function createReporter(project, option) {
133
142
  var _a, _b, _c;
134
143
  try {
@@ -150,26 +159,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
150
159
  base_version: ((_c = project.projectJsonContent) === null || _c === void 0 ? void 0 : _c.libVersion) || ''
151
160
  });
152
161
  const reporter = new Reporter(apm);
153
- function reportJSON() {
154
- var _a, _b, _c, _d;
162
+ function reportAppJSON() {
163
+ var _a, _b, _c, _d, _e;
155
164
  // 分包
156
- if ((_a = project.getSubPackages()) === null || _a === void 0 ? void 0 : _a.length) {
157
- reporter.reportJSONApp(xhs_mp_utils_1.FeatureReporter.JSONApp.subPackages);
165
+ if (!(0, lodash_1.isEmpty)(((_a = project.appJsonContent) === null || _a === void 0 ? void 0 : _a.subPackages) || ((_b = project.appJsonContent) === null || _b === void 0 ? void 0 : _b.subpackages))) {
166
+ reporter.reportAppJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.subPackages);
158
167
  }
159
168
  // tabbar
160
- if (!isEmpty((_b = project.appJSON) === null || _b === void 0 ? void 0 : _b.tabBar)) {
161
- reporter.reportJSONApp(xhs_mp_utils_1.FeatureReporter.JSONApp.tabBar);
169
+ if (!(0, lodash_1.isEmpty)((_c = project.appJsonContent) === null || _c === void 0 ? void 0 : _c.tabBar)) {
170
+ reporter.reportAppJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.tabBar);
162
171
  }
163
172
  // 按需注入
164
- if ((_c = project.appJSON) === null || _c === void 0 ? void 0 : _c.lazyCodeLoading) {
165
- reporter.reportJSONApp(xhs_mp_utils_1.FeatureReporter.JSONApp.lazyCodeLoading);
173
+ if ((_d = project.appJsonContent) === null || _d === void 0 ? void 0 : _d.lazyCodeLoading) {
174
+ reporter.reportAppJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.lazyCodeLoading);
166
175
  }
167
176
  // 预载
168
- if (!isEmpty((_d = project.appJSON) === null || _d === void 0 ? void 0 : _d.preloadRule)) {
169
- reporter.reportJSONApp(xhs_mp_utils_1.FeatureReporter.JSONApp.preloadRule);
177
+ if (!(0, lodash_1.isEmpty)((_e = project.appJsonContent) === null || _e === void 0 ? void 0 : _e.preloadRule)) {
178
+ reporter.reportAppJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.preloadRule);
170
179
  }
171
180
  const componentsMap = project.getComponentsMap();
172
- if (!isEmpty(componentsMap)) {
181
+ if (!(0, lodash_1.isEmpty)(componentsMap)) {
173
182
  // debug(componentsMap)
174
183
  for (let key in componentsMap) {
175
184
  const style = componentsMap[key].styleIsolation;
@@ -179,13 +188,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
179
188
  }
180
189
  // 占位组件
181
190
  const componentPlaceholder = componentsMap[key].componentPlaceholder;
182
- if (!isEmpty(componentPlaceholder)) {
191
+ if (!(0, lodash_1.isEmpty)(componentPlaceholder)) {
183
192
  reporter.reportJSONComponent(xhs_mp_utils_1.FeatureReporter.JSONComponent.componentPlaceholder);
184
193
  }
185
194
  }
186
195
  }
187
196
  }
188
- reportJSON();
197
+ function reportExtJSON() {
198
+ var _a, _b, _c, _d, _e, _f, _g, _h;
199
+ if ((0, lodash_1.isEmpty)(project.extJsonContent) || !((_a = project.extJsonContent) === null || _a === void 0 ? void 0 : _a.extEnable)) {
200
+ return;
201
+ }
202
+ // pages
203
+ if (!(0, lodash_1.isEmpty)((_b = project.extJsonContent) === null || _b === void 0 ? void 0 : _b.pages)) {
204
+ reporter.reportExtJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.pages);
205
+ }
206
+ // 分包
207
+ if (!(0, lodash_1.isEmpty)(((_c = project.extJsonContent) === null || _c === void 0 ? void 0 : _c.subPackages) || ((_d = project.extJsonContent) === null || _d === void 0 ? void 0 : _d.subpackages))) {
208
+ reporter.reportExtJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.subPackages);
209
+ }
210
+ // tabbar
211
+ if (!(0, lodash_1.isEmpty)((_e = project.extJsonContent) === null || _e === void 0 ? void 0 : _e.tabBar)) {
212
+ reporter.reportExtJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.tabBar);
213
+ }
214
+ // extPages
215
+ if (!(0, lodash_1.isEmpty)((_f = project.extJsonContent) === null || _f === void 0 ? void 0 : _f.extPages)) {
216
+ reporter.reportExtJSON(xhs_mp_utils_1.FeatureReporter.AppExtJSON.extPages);
217
+ }
218
+ if ((_g = project.extJsonContent) === null || _g === void 0 ? void 0 : _g.extEnable) {
219
+ // 开发模式
220
+ reporter.reportDevelopMode(((_h = project.extJsonContent) === null || _h === void 0 ? void 0 : _h.directCommit)
221
+ ? xhs_mp_utils_1.FeatureReporter.DevelopMode.customDevelopment
222
+ : xhs_mp_utils_1.FeatureReporter.DevelopMode.templateDevelopment);
223
+ }
224
+ }
225
+ reportAppJSON();
226
+ reportExtJSON();
189
227
  // 统计taro版本
190
228
  const vendor = path_1.default.join(project.miniprogramDir, 'vendors.js.LICENSE.txt');
191
229
  const taro = path_1.default.join(project.miniprogramDir, 'taro.js');
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.2",
3
+ "version": "1.9.4",
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.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",
97
+ "xhs-mp-compiler-ml-loader": "3.0.4",
98
+ "xhs-mp-compiler-utils": "1.9.4",
99
+ "xhs-mp-pack": "1.9.4",
100
+ "xhs-mp-project": "1.9.4",
101
+ "xhs-mp-utils": "1.9.4",
102
+ "xhs-mp-shared-fs": "1.4.4",
103
+ "xhs-mp-compiler-sjs-loader": "1.9.4",
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
- });