xhs-mp-compiler-cli 2.0.2 → 2.0.4-beta.0

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.
@@ -35,7 +35,6 @@ export declare const PROD_TARGETS: {
35
35
  ios: string;
36
36
  };
37
37
  export declare const ENTRY_CSS_NAME = "app";
38
- export declare const FULL_PKG = "xhs-full";
39
38
  export declare const MAIN_PKG = "xhs-main";
40
39
  export declare const SUB_PKG = "xhs-sub";
41
40
  export declare const BUILD_REASON: {
@@ -49,3 +48,7 @@ export declare const PACK_MODE: {
49
48
  MPPACK: string;
50
49
  WEBPACK: string;
51
50
  };
51
+ export declare const CSS_REG: RegExp;
52
+ export declare const SKETCH_CSS_REG: RegExp;
53
+ export declare const ML_REG: RegExp;
54
+ export declare const SKETCH_ML_REG: RegExp;
@@ -9,7 +9,7 @@
9
9
  })(function (require, exports) {
10
10
  "use strict";
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PACK_MODE = exports.ASSETS_EXTS = exports.BUILD_REASON = exports.SUB_PKG = exports.MAIN_PKG = exports.FULL_PKG = exports.ENTRY_CSS_NAME = exports.PROD_TARGETS = exports.DEV_TARGETS = exports.DEV_BROWSERSLIST = exports.PROD_BROWSERSLIST = exports.COMPILE_SUB_PKG = exports.COMPILE_MAIN_PKG = exports.COMPILE_FULL_PKG = exports.PKG_ROOT_SEP = exports.MiniMode = exports.COMPILE_ENTRY = exports.COMPILE_TYPE = exports.COMPILER_TYPE = exports.MAIN_PKG_ROOT = void 0;
12
+ exports.SKETCH_ML_REG = exports.ML_REG = exports.SKETCH_CSS_REG = exports.CSS_REG = exports.PACK_MODE = exports.ASSETS_EXTS = exports.BUILD_REASON = exports.SUB_PKG = exports.MAIN_PKG = exports.ENTRY_CSS_NAME = exports.PROD_TARGETS = exports.DEV_TARGETS = exports.DEV_BROWSERSLIST = exports.PROD_BROWSERSLIST = exports.COMPILE_SUB_PKG = exports.COMPILE_MAIN_PKG = exports.COMPILE_FULL_PKG = exports.PKG_ROOT_SEP = exports.MiniMode = exports.COMPILE_ENTRY = exports.COMPILE_TYPE = exports.COMPILER_TYPE = exports.MAIN_PKG_ROOT = void 0;
13
13
  exports.MAIN_PKG_ROOT = 'xhs-main';
14
14
  exports.COMPILER_TYPE = {
15
15
  dev: 'dev',
@@ -47,7 +47,6 @@
47
47
  ios: '10'
48
48
  };
49
49
  exports.ENTRY_CSS_NAME = 'app';
50
- exports.FULL_PKG = 'xhs-full';
51
50
  exports.MAIN_PKG = 'xhs-main';
52
51
  exports.SUB_PKG = 'xhs-sub';
53
52
  exports.BUILD_REASON = {
@@ -79,4 +78,9 @@
79
78
  MPPACK: 'mp-pack',
80
79
  WEBPACK: 'webpack'
81
80
  };
81
+ // loader 规则使用下面变量
82
+ exports.CSS_REG = /(?<!\.skeleton)\.(wxss|css)$/;
83
+ exports.SKETCH_CSS_REG = /\.skeleton\.(wxss|css)$/;
84
+ exports.ML_REG = /(?<!\.skeleton)\.(wx|xhs)ml$/;
85
+ exports.SKETCH_ML_REG = /\.skeleton\.(wx|xhs)ml$/;
82
86
  });
package/dist/index.d.ts CHANGED
@@ -2,46 +2,54 @@ import { COMPILE_ENTRY } from './config/constant.config';
2
2
  import { Project } from 'xhs-mp-project';
3
3
  import EventEmitter from 'events';
4
4
  import { Logger } from 'xhs-mp-shared';
5
- import { getProjectCompilerClass, prepareDevPool } from './compiler';
5
+ import { prepareDevPool } from './compiler';
6
+ export { COMPILE_ENTRY, prepareDevPool };
6
7
  interface ILibFeatures {
7
8
  supportV2?: boolean;
8
- supportVdom?: boolean;
9
+ supportVDom?: boolean;
9
10
  }
10
- export { COMPILE_ENTRY, getProjectCompilerClass, prepareDevPool };
11
+ export type IArchType = 'v0' | 'v1' | 'v2';
12
+ export type IZipResult = {
13
+ type: IArchType;
14
+ zipPath: string;
15
+ zipSize: number;
16
+ root: string;
17
+ originSize: number;
18
+ };
11
19
  export type ICompileOpts = {
12
20
  logger?: any;
13
- compileDir?: string;
21
+ report?: (key: string, data?: any) => void;
22
+ compileDistDir?: string;
23
+ compileCacheDir?: string;
14
24
  nodeJsPath?: string;
15
- mpDevJsonPath?: string;
16
- libFeatures?: ILibFeatures;
25
+ getLibFeatures?: () => Promise<ILibFeatures>;
17
26
  };
18
- export type ICompilerProps = ({
19
- projectPath: string;
20
- } | {
21
- project: Project;
22
- }) & ICompileOpts;
27
+ export type ICompilerProps = {
28
+ projectPath?: string;
29
+ project?: Project;
30
+ } & ICompileOpts;
23
31
  interface ICompileBaseConfig {
24
32
  compressCss?: boolean;
25
33
  compressJs?: boolean;
26
34
  enableSourcemap?: boolean;
27
35
  appendSourcemapComment?: boolean;
28
36
  runInServiceSandbox?: boolean;
29
- enableV2: boolean;
30
- enableV1: boolean;
31
- enableVDom: boolean;
37
+ enableV2?: boolean;
38
+ enableV1?: boolean;
39
+ enableVDom?: boolean;
32
40
  }
33
41
  type IMakePkgsReadyConfig = ICompileBaseConfig & {
34
- compilePkgs: any;
42
+ compilePkgs?: string[];
35
43
  };
36
44
  type ICompilePkgsConfig = ICompileBaseConfig & {
37
- compilePkgs: any;
45
+ compilePkgs?: string[];
38
46
  };
39
- type ICompileBuildConfig = ICompileBaseConfig & {
40
- entryType: string;
47
+ type ICompileProjectConfig = ICompileBaseConfig & {
48
+ entryType?: string;
41
49
  mpUploadOptions?: ICompileAndZipOptions | false;
42
50
  };
43
51
  export interface ICompileAndZipOptions {
44
- entryType: string;
52
+ entryType?: string;
45
53
  can_upload_ext_json?: boolean;
46
54
  upload_app_id?: string;
47
55
  pkgInfo?: {
@@ -52,35 +60,36 @@ export interface ISubPackages {
52
60
  root: string;
53
61
  pages: string;
54
62
  }
55
- export declare class ProjectCompiler extends EventEmitter {
56
- projectPath: string;
63
+ export declare class ProjectCompilerManager extends EventEmitter {
57
64
  compilerProps: ICompilerProps;
58
65
  project: Project;
59
66
  compilerImplMap: {};
60
67
  logger: Logger;
68
+ report?: (key: string, data?: any) => void;
61
69
  constructor(props: ICompilerProps);
62
- createProject(props: any): any;
63
- private getCompilerDir;
64
- private initSimulatorCompiler;
65
- private initBuildCompiler;
66
- getUsingPackageType(entryType?: string): Promise<{
67
- enableV1: boolean;
68
- enableV2: boolean;
69
- enableVDom: boolean;
70
- }>;
70
+ bindProject(props: any): void;
71
71
  private getCompilerType;
72
72
  getDistDir(entryType?: string): string;
73
73
  removeDistDir(entryType?: string): void;
74
74
  getCacheDir(entryType?: string): string;
75
75
  removeCacheDir(entryType?: string): void;
76
- private createCompilerImpl;
77
- private getComilerImpl;
78
- makePkgsReady(config: IMakePkgsReadyConfig): Promise<void>;
79
- reCompilePkgs(config: ICompilePkgsConfig): Promise<void>;
80
- compileProject(config: ICompileBuildConfig): Promise<void>;
81
- compileAndZip(opts: ICompileAndZipOptions): Promise<any>;
76
+ removeAllCacheDir(): void;
77
+ private createCompiler;
78
+ private getCompiler;
79
+ getUsingPackageType(entryType?: string): Promise<{
80
+ enableV1: boolean;
81
+ enableV2: boolean;
82
+ enableVDom: boolean;
83
+ }>;
84
+ private initSimulatorCompiler;
85
+ private initBuildCompiler;
86
+ makePkgsReady(opts: IMakePkgsReadyConfig): Promise<void>;
87
+ reCompilePkgs(opts: ICompilePkgsConfig): Promise<void>;
88
+ compileProject(config: ICompileProjectConfig): Promise<void>;
89
+ compileAndZip(opts: ICompileAndZipOptions): Promise<IZipResult[]>;
90
+ closeCompiler(entryType?: string): void;
91
+ killCompiler(entryType?: string): void;
92
+ killAll(): void;
82
93
  private zipWithFullPackage;
83
94
  private zipWithSubPackage;
84
- close(entryType?: string): void;
85
- kill(entryType?: string): void;
86
95
  }