xhs-mp-compiler-cli 1.1.1 → 1.1.2
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/bin/xhs-mp-cli-build.js +2 -2
- package/dist/bin/xhs-mp-cli-dev.js +3 -3
- package/dist/compilerCP.js +3 -3
- package/dist/config/constant.config.d.ts +20 -0
- package/dist/config/constant.config.js +25 -5
- package/dist/config/dir.config.d.ts +3 -0
- package/dist/config/dir.config.js +16 -0
- package/dist/index.d.ts +84 -1
- package/dist/index.js +452 -3
- package/dist/packs/mp-pack/index.js +1 -1
- package/dist/{dev-server → packs/webpack/dev-server}/index.d.ts +1 -1
- package/dist/{dev-server → packs/webpack/dev-server}/index.js +1 -1
- package/dist/packs/webpack/index.d.ts +1 -1
- package/dist/packs/webpack/index.js +1 -1
- package/dist/presets/common.js +13 -11
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.d.ts +2 -2
- package/dist/presets/configs/minigame/assets/index.d.ts +1 -0
- package/dist/presets/configs/miniprogram/render/index.js +6 -5
- package/dist/presets/configs/miniprogram/service/index.js +7 -7
- package/dist/presets/index.d.ts +1 -1
- package/dist/utils/file.d.ts +2 -0
- package/dist/utils/file.js +67 -0
- package/dist/utils/project.d.ts +27 -0
- package/dist/utils/project.js +164 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.js +13 -0
- package/dist/utils/zip.d.ts +28 -0
- package/dist/utils/zip.js +287 -0
- package/package.json +11 -5
- /package/dist/{dev-server → packs/webpack/dev-server}/lib/ensurePort.d.ts +0 -0
- /package/dist/{dev-server → packs/webpack/dev-server}/lib/ensurePort.js +0 -0
- /package/dist/{dev-server → packs/webpack/dev-server}/lib/openBrowser.d.ts +0 -0
- /package/dist/{dev-server → packs/webpack/dev-server}/lib/openBrowser.js +0 -0
- /package/dist/{dev-server → packs/webpack/dev-server}/lib/openChrome.applescript +0 -0
|
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const
|
|
9
|
+
const packs_1 = require("../packs");
|
|
10
10
|
const commander = new commander_1.Command();
|
|
11
11
|
commander.usage('[options]').option('-d, --mpDir <path>', 'set workdir [default: ./]');
|
|
12
12
|
commander.usage('[options]').option('-p, --platform <string>', 'set platform [default: xhs]');
|
|
@@ -22,7 +22,7 @@ const enableV1 = commander.opts().enableV1 === "true";
|
|
|
22
22
|
const enableV2 = commander.opts().enableV2 === "true";
|
|
23
23
|
const enableVDom = commander.opts().enableVDom === "true";
|
|
24
24
|
const compressJs = commander.opts().compressJs === "true";
|
|
25
|
-
const multiCompiler = (0,
|
|
25
|
+
const multiCompiler = (0, packs_1.createCompiler)({
|
|
26
26
|
projectPath,
|
|
27
27
|
action: 'build',
|
|
28
28
|
platform,
|
|
@@ -6,7 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const commander_1 = require("commander");
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const
|
|
9
|
+
const packs_1 = require("../packs");
|
|
10
10
|
const commander = new commander_1.Command();
|
|
11
11
|
commander.usage('[options]').option('-d, --mpDir <path>', 'set workdir [default: ./]');
|
|
12
12
|
commander.usage('[options]').option('-p, --platform <string>', 'set platform [default: xhs]');
|
|
@@ -26,7 +26,7 @@ const enableV2 = commander.opts().enableV2 === "true";
|
|
|
26
26
|
const enableVDom = commander.opts().enableVDom === "true";
|
|
27
27
|
process.env.PRETTIER_XHSML = "true";
|
|
28
28
|
if (out) {
|
|
29
|
-
const multiCompiler = (0,
|
|
29
|
+
const multiCompiler = (0, packs_1.createCompiler)({
|
|
30
30
|
projectPath,
|
|
31
31
|
action: 'dev',
|
|
32
32
|
platform,
|
|
@@ -44,7 +44,7 @@ if (out) {
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
47
|
-
(0,
|
|
47
|
+
(0, packs_1.createCompiler)({
|
|
48
48
|
projectPath,
|
|
49
49
|
action: 'dev',
|
|
50
50
|
enableDevServer: true,
|
package/dist/compilerCP.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
12
|
+
const packs_1 = require("./packs");
|
|
13
13
|
let globalConfig = JSON.parse(process.argv[2]);
|
|
14
14
|
let hadWatchBuilt = false;
|
|
15
15
|
let projectCompiler;
|
|
@@ -37,7 +37,7 @@ const handlers = {
|
|
|
37
37
|
runWatch: (msg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
38
|
const { uuid, data } = msg;
|
|
39
39
|
if (!projectCompiler) {
|
|
40
|
-
projectCompiler = (0,
|
|
40
|
+
projectCompiler = (0, packs_1.createCompiler)(data);
|
|
41
41
|
}
|
|
42
42
|
sendToMaster('run watch start');
|
|
43
43
|
const { err, stats } = (yield projectCompiler.watch({
|
|
@@ -102,7 +102,7 @@ const handlers = {
|
|
|
102
102
|
console.log('sp run build', msg);
|
|
103
103
|
const { uuid, data } = msg;
|
|
104
104
|
if (!projectCompiler) {
|
|
105
|
-
projectCompiler = (0,
|
|
105
|
+
projectCompiler = (0, packs_1.createCompiler)(data);
|
|
106
106
|
}
|
|
107
107
|
projectCompiler.on('progress', progress => {
|
|
108
108
|
sendToMaster('compilePercent', {
|
|
@@ -5,3 +5,23 @@ export declare const COMPILER_TYPE: {
|
|
|
5
5
|
legacy_dev: string;
|
|
6
6
|
legacy_build: string;
|
|
7
7
|
};
|
|
8
|
+
export declare const COMPILE_TYPE: {
|
|
9
|
+
mp: string;
|
|
10
|
+
component: string;
|
|
11
|
+
service: string;
|
|
12
|
+
render: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const COMPILE_ENTRY: {
|
|
15
|
+
simulator: string;
|
|
16
|
+
preview: string;
|
|
17
|
+
remotedebug: string;
|
|
18
|
+
upload: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const MiniMode: {
|
|
21
|
+
miniprogram: string;
|
|
22
|
+
minigame: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const PKG_ROOT_SEP = "_XHSPKG_";
|
|
25
|
+
export declare const COMPILE_FULL_PKG = "xhs-full";
|
|
26
|
+
export declare const COMPILE_MAIN_PKG = "xhs-main";
|
|
27
|
+
export declare const COMPILE_SUB_PKG = "xhs-sub";
|
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.COMPILER_TYPE = exports.MAIN_PKG_ROOT = void 0;
|
|
3
|
+
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;
|
|
4
4
|
exports.MAIN_PKG_ROOT = 'xhs-main';
|
|
5
5
|
exports.COMPILER_TYPE = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
dev: 'dev',
|
|
7
|
+
build: 'build',
|
|
8
|
+
legacy_dev: 'legacy_dev',
|
|
9
|
+
legacy_build: 'legacy_build'
|
|
10
10
|
};
|
|
11
|
+
exports.COMPILE_TYPE = {
|
|
12
|
+
mp: 'mp',
|
|
13
|
+
component: 'component',
|
|
14
|
+
service: 'service',
|
|
15
|
+
render: 'render'
|
|
16
|
+
};
|
|
17
|
+
exports.COMPILE_ENTRY = {
|
|
18
|
+
simulator: 'simulator',
|
|
19
|
+
preview: 'preview',
|
|
20
|
+
remotedebug: 'remotedebug',
|
|
21
|
+
upload: 'upload'
|
|
22
|
+
};
|
|
23
|
+
exports.MiniMode = {
|
|
24
|
+
miniprogram: 'miniprogram',
|
|
25
|
+
minigame: 'minigame'
|
|
26
|
+
};
|
|
27
|
+
exports.PKG_ROOT_SEP = '_XHSPKG_';
|
|
28
|
+
exports.COMPILE_FULL_PKG = 'xhs-full';
|
|
29
|
+
exports.COMPILE_MAIN_PKG = 'xhs-main';
|
|
30
|
+
exports.COMPILE_SUB_PKG = 'xhs-sub';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mpCompileCachePath = exports.mpCompileDirPath = exports.baseDirPath = void 0;
|
|
7
|
+
const utils_1 = require("../utils/utils");
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const os_1 = __importDefault(require("os"));
|
|
11
|
+
exports.baseDirPath = (0, utils_1.normalizePath)(path_1.default.join(os_1.default.tmpdir(), '@xhs-toolkit'));
|
|
12
|
+
fs_extra_1.default.ensureDirSync(exports.baseDirPath);
|
|
13
|
+
exports.mpCompileDirPath = (0, utils_1.normalizePath)(path_1.default.join(exports.baseDirPath, 'xhs-mp-baba'));
|
|
14
|
+
fs_extra_1.default.ensureDirSync(exports.mpCompileDirPath);
|
|
15
|
+
exports.mpCompileCachePath = (0, utils_1.normalizePath)(path_1.default.join(exports.baseDirPath, 'xhs-compile-cache'));
|
|
16
|
+
fs_extra_1.default.ensureDirSync(exports.mpCompileCachePath);
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node/events" />
|
|
2
|
+
import { COMPILE_ENTRY } from './config/constant.config';
|
|
3
|
+
import { Project } from 'xhs-mp-project';
|
|
4
|
+
import EventEmitter from 'events';
|
|
5
|
+
import { Logger } from 'xhs-mp-utils';
|
|
6
|
+
import { getProcessCompilerClass } from './compiler';
|
|
7
|
+
interface ILibFeatures {
|
|
8
|
+
supportV2?: boolean;
|
|
9
|
+
supportVdom?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export { COMPILE_ENTRY, getProcessCompilerClass };
|
|
12
|
+
export type ICompileOpts = {
|
|
13
|
+
logger?: any;
|
|
14
|
+
compileDir?: string;
|
|
15
|
+
nodeJsPath?: string;
|
|
16
|
+
mpDevJsonPath?: string;
|
|
17
|
+
libFeatures?: ILibFeatures;
|
|
18
|
+
};
|
|
19
|
+
export type ICompilerProps = ({
|
|
20
|
+
projectPath: string;
|
|
21
|
+
} | {
|
|
22
|
+
project: Project;
|
|
23
|
+
}) & ICompileOpts;
|
|
24
|
+
interface ICompileBaseConfig {
|
|
25
|
+
compressJs: boolean;
|
|
26
|
+
enableSourcemap: boolean;
|
|
27
|
+
enableV2: boolean;
|
|
28
|
+
enableV1: boolean;
|
|
29
|
+
enableVDom: boolean;
|
|
30
|
+
}
|
|
31
|
+
type IMakePkgsReadyConfig = ICompileBaseConfig & {
|
|
32
|
+
compilePkgs: any;
|
|
33
|
+
};
|
|
34
|
+
type ICompilePkgsConfig = ICompileBaseConfig & {
|
|
35
|
+
compilePkgs: any;
|
|
36
|
+
};
|
|
37
|
+
type ICompileBuildConfig = ICompileBaseConfig & {
|
|
38
|
+
entryType: string;
|
|
39
|
+
};
|
|
40
|
+
export interface ICompileAndZipOptions {
|
|
41
|
+
entryType: string;
|
|
42
|
+
can_upload_ext_json?: boolean;
|
|
43
|
+
upload_app_id?: string;
|
|
44
|
+
pkgInfo?: {
|
|
45
|
+
version: string;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export interface ISubPackages {
|
|
49
|
+
root: string;
|
|
50
|
+
pages: string;
|
|
51
|
+
}
|
|
52
|
+
export declare class Compiler extends EventEmitter {
|
|
53
|
+
projectPath: string;
|
|
54
|
+
compilerProps: ICompilerProps;
|
|
55
|
+
project: Project;
|
|
56
|
+
compilerImplMap: {};
|
|
57
|
+
logger: Logger;
|
|
58
|
+
constructor(props: ICompilerProps);
|
|
59
|
+
createProject(props: any): any;
|
|
60
|
+
private getCompilerDir;
|
|
61
|
+
private initSimulatorCompiler;
|
|
62
|
+
private initBuildCompiler;
|
|
63
|
+
getUsingPackageType(entryType?: string): Promise<{
|
|
64
|
+
enableV1: boolean;
|
|
65
|
+
enableV2: boolean;
|
|
66
|
+
enableVDom: boolean;
|
|
67
|
+
}>;
|
|
68
|
+
private getCompilerType;
|
|
69
|
+
getDistDir(entryType?: string): string;
|
|
70
|
+
removeDistDir(entryType?: string): void;
|
|
71
|
+
getCacheDir(entryType?: string): string;
|
|
72
|
+
removeCacheDir(entryType?: string): void;
|
|
73
|
+
private createCompilerImpl;
|
|
74
|
+
private getComilerImpl;
|
|
75
|
+
makePkgsReady(config: IMakePkgsReadyConfig): Promise<void>;
|
|
76
|
+
reCompilePkgs(config: ICompilePkgsConfig): Promise<void>;
|
|
77
|
+
compileProject(config: ICompileBuildConfig): Promise<void>;
|
|
78
|
+
compileAndZip(opts: ICompileAndZipOptions): Promise<any>;
|
|
79
|
+
private zipWithFullPackageWithAppId;
|
|
80
|
+
private zipWithFullPackage;
|
|
81
|
+
private zipWithSubPackage;
|
|
82
|
+
close(entryType?: string): void;
|
|
83
|
+
kill(entryType?: string): void;
|
|
84
|
+
}
|