xhs-mp-compiler-cli 2.0.12 → 2.0.14

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.
@@ -8,7 +8,7 @@ interface ILibFeatures {
8
8
  supportV2?: boolean;
9
9
  supportVDom?: boolean;
10
10
  }
11
- export type IArchType = 'v0' | 'v1' | 'v2';
11
+ export type IArchType = 'v1' | 'v2';
12
12
  export type IZipResult = {
13
13
  type: IArchType;
14
14
  zipPath: string;
@@ -90,6 +90,5 @@ export declare class ProjectCompilerManager extends EventEmitter {
90
90
  closeCompiler(entryType?: string): void;
91
91
  killCompiler(entryType?: string): void;
92
92
  killAll(): void;
93
- private zipWithFullPackage;
94
93
  private zipWithSubPackage;
95
94
  }
@@ -386,7 +386,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
386
386
  let entryZips = [];
387
387
  if (entryType === constant_config_1.COMPILE_ENTRY.preview) {
388
388
  entryZips = [
389
- this.zipWithFullPackage(opts, subPackages, 'v0'),
390
389
  this.zipWithSubPackage(opts, subPackages, 'v1'),
391
390
  // 小程序模式有v2包
392
391
  buildConfig.enableV2 && this.zipWithSubPackage(opts, subPackages, 'v2')
@@ -394,7 +393,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
394
393
  }
395
394
  else if (entryType === constant_config_1.COMPILE_ENTRY.upload) {
396
395
  entryZips = [
397
- this.zipWithFullPackage(opts, subPackages, 'v0', true),
398
396
  this.zipWithSubPackage(opts, subPackages, 'v1', true),
399
397
  // 小程序模式有v2包
400
398
  enableV2 && this.zipWithSubPackage(opts, subPackages, 'v2', true)
@@ -434,52 +432,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
434
432
  });
435
433
  this.compilerImplMap = {};
436
434
  }
437
- /* 使用v0的入口,zip整包 */
438
- zipWithFullPackage(opts_1) {
439
- return __awaiter(this, arguments, void 0, function* (opts, subPackages = [], type, excludeSourcemap) {
440
- const { upload_app_id, can_upload_ext_json, pkgInfo, entryType } = opts;
441
- const buildDir = this.getDistDir(entryType);
442
- const appendFile = [];
443
- const appendBuffer = [];
444
- appendFile.push(this.project.projectJsonPath); // zip添加project.config.json
445
- /* 是否需要上传ext.json */
446
- if (can_upload_ext_json && fs_extra_1.default.existsSync(this.project.extJsonPath)) {
447
- appendFile.push(this.project.extJsonPath);
448
- }
449
- if (pkgInfo) {
450
- /* 是否需要额外添加pkgInfo.json信息 */
451
- const content = { version: pkgInfo.version };
452
- const contentStr = JSON.stringify(content);
453
- appendBuffer.push({
454
- name: 'pkgInfo.json',
455
- buffer: Buffer.from(contentStr, 'utf-8')
456
- });
457
- }
458
- let ignore = [];
459
- if (excludeSourcemap) {
460
- ignore = ['**/*.map'];
461
- }
462
- const tasks = [];
463
- const baseZipConfig = {
464
- inputDir: path_1.default.resolve(buildDir, !subPackages.length ? 'v1' : 'v0' // 如果没有开启分包,则把v1包当作v0包
465
- ), // 输入的路径
466
- type,
467
- prefix: upload_app_id,
468
- meta: {
469
- root: ''
470
- }
471
- };
472
- tasks.push((0, project_1.zipFactory)(Object.assign(Object.assign({}, baseZipConfig), { pattern: '**/*', ignore,
473
- appendFile,
474
- appendBuffer, outputDir: path_1.default.resolve(buildDir, `${type}-full-pack.zip`) // 输出的路径
475
- })));
476
- if (excludeSourcemap) {
477
- tasks.push((0, project_1.zipFactory)(Object.assign(Object.assign({}, baseZipConfig), { pattern: '**/*.map', ignore: [], appendFile: [], appendBuffer: [], outputDir: path_1.default.resolve(buildDir, `${type}-full-pack-sourcemap.zip`) // 输出的路径
478
- })));
479
- }
480
- return Promise.all(tasks);
481
- });
482
- }
483
435
  /* 使用v1的入口。zip主包和分包 */
484
436
  zipWithSubPackage(opts, subPackages, type, excludeSourcemap) {
485
437
  return __awaiter(this, void 0, void 0, function* () {
@@ -5,6 +5,5 @@ declare class MpEntryPlugin {
5
5
  constructor(options: IPresetOptions);
6
6
  apply(compiler: ICompiler): void;
7
7
  getAppJson(appJSON: any): Record<string, RawSource>;
8
- getLegacyAppJSON(appJSON: any): RawSource;
9
8
  }
10
9
  export default MpEntryPlugin;
@@ -29,15 +29,13 @@
29
29
  const { appJSON } = this.options.project;
30
30
  if (assets) {
31
31
  Object.assign(assets, this.getAppJson((0, lodash_1.cloneDeep)(appJSON)));
32
- // 兼容服务端,始终创建 v0/app.json
33
- assets['v0/app.json'] = this.getLegacyAppJSON((0, lodash_1.cloneDeep)(appJSON));
34
32
  }
35
33
  });
36
34
  });
37
35
  }
38
36
  getAppJson(appJSON) {
39
37
  const assets = {};
40
- const appJsonSource = new packs_1.RawSource(JSON.stringify(xhs_mp_project_1.utils.pureAppJSON(appJSON)));
38
+ const appJsonSource = new packs_1.RawSource(JSON.stringify(xhs_mp_project_1.utils.formatGameAppJSON(appJSON)));
41
39
  assets['v1/app.json'] = appJsonSource;
42
40
  for (const subpackage of appJSON.subPackages) {
43
41
  if (subpackage.independent) {
@@ -46,11 +44,6 @@
46
44
  }
47
45
  return assets;
48
46
  }
49
- getLegacyAppJSON(appJSON) {
50
- // 兼容的整包,将 subPackages 合并到 pages 内
51
- appJSON = xhs_mp_project_1.utils.pureAppJSON(appJSON, 'v0');
52
- return new packs_1.RawSource(JSON.stringify(appJSON));
53
- }
54
47
  }
55
48
  exports.default = MpEntryPlugin;
56
49
  });
@@ -6,7 +6,6 @@ declare class XhsAssetsPlugin {
6
6
  constructor(options: IPresetOptions);
7
7
  apply(compiler: ICompiler): void;
8
8
  emitAppJson(compilation: any, appJSON: any): void;
9
- emitLegacyAppJSON(compilation: any, legacyAppJSON: any): void;
10
9
  emitJson(compilation: any, path: string, json: RawSource): void;
11
10
  }
12
11
  export default XhsAssetsPlugin;
@@ -28,13 +28,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
28
28
  apply(compiler) {
29
29
  compiler.hooks.compilation.tap('XhsMpAssetsPlugin', compilation => {
30
30
  const { project, packSetting } = this.options;
31
- const { appJSON, legacyAppJSON } = project;
31
+ const { appJSON } = project;
32
32
  const usingPackageType = packSetting.usingPackageType;
33
33
  // app.json
34
34
  if (compilation) {
35
35
  this.emitAppJson(compilation, JSON.parse(JSON.stringify(appJSON)));
36
- // 兼容服务端,始终创建 v0/app.json
37
- this.emitLegacyAppJSON(compilation, legacyAppJSON);
38
36
  }
39
37
  // app.css 复用
40
38
  compilation.hooks.processAssets.tap({
@@ -128,9 +126,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
128
126
  }
129
127
  });
130
128
  }
131
- emitLegacyAppJSON(compilation, legacyAppJSON) {
132
- this.emitJson(compilation, 'v0/app.json', new packs_1.RawSource(JSON.stringify(legacyAppJSON)));
133
- }
134
129
  emitJson(compilation, path, json) {
135
130
  compilation.emitAsset(path, json);
136
131
  }
@@ -30,7 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
30
30
  throw new Error(`${absolutePath}.(js|ts) 不存在`);
31
31
  };
32
32
  return `
33
- ;globalThis['__MP_APP_JSON__'] = ${JSON.stringify(xhs_mp_project_1.utils.pureAppJSON(appJSON))};
33
+ ;globalThis['__MP_APP_JSON__'] = ${JSON.stringify(xhs_mp_project_1.utils.formatGameAppJSON(appJSON))};
34
34
  ${addAppJs()}`;
35
35
  }
36
36
  module.exports = entryLoader;
@@ -4,7 +4,7 @@ export interface IZipFactory {
4
4
  pattern?: string;
5
5
  prefix: string;
6
6
  inputDir: string;
7
- type: "v0" | "v1" | "v2";
7
+ type: "v1" | "v2";
8
8
  appendFile?: string[];
9
9
  appendBuffer?: {
10
10
  buffer: Buffer;
@@ -20,7 +20,7 @@ export declare const checkSubPackagesLegality: ({ appJsonContent, rootPath, dist
20
20
  distDir: string;
21
21
  }) => Promise<any[]>;
22
22
  export declare const zipFactory: ({ outputDir, ignore, prefix, pattern, inputDir, type, appendFile, appendBuffer, meta, }: IZipFactory) => Promise<{
23
- type: "v0" | "v1" | "v2";
23
+ type: "v1" | "v2";
24
24
  zipPath: string;
25
25
  zipSize: number;
26
26
  root: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xhs-mp-compiler-cli",
3
- "version": "2.0.12",
3
+ "version": "2.0.14",
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.12",
92
- "xhs-mp-compiler-utils": "2.0.12",
93
- "xhs-mp-pack": "2.0.12",
94
- "xhs-mp-project": "2.0.12",
95
- "xhs-mp-shared": "2.0.12",
96
- "xhs-mp-shared-fs": "2.0.12",
97
- "xhs-mp-sjs-loader": "2.0.12",
98
- "xhs-mp-sketch-loader": "2.0.12",
91
+ "xhs-mp-ml-loader": "2.0.14",
92
+ "xhs-mp-compiler-utils": "2.0.14",
93
+ "xhs-mp-pack": "2.0.14",
94
+ "xhs-mp-project": "2.0.14",
95
+ "xhs-mp-shared": "2.0.14",
96
+ "xhs-mp-shared-fs": "2.0.14",
97
+ "xhs-mp-sjs-loader": "2.0.14",
98
+ "xhs-mp-sketch-loader": "2.0.14",
99
99
  "yauzl": "^2.10.0"
100
100
  },
101
101
  "peerDependencies": {
102
- "xhs-mp-ml-parser": "2.0.12"
102
+ "xhs-mp-ml-parser": "2.0.14"
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.12"
126
+ "xhs-mp-ml-parser": "2.0.14"
127
127
  },
128
128
  "scripts": {
129
129
  "version": "formula changelog && git add .",