xhs-mp-compiler-cli 2.0.0-beta.3 → 2.0.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.
- package/dist/bin/xhs-mp-cli-build.js +48 -34
- package/dist/bin/xhs-mp-cli-dev.js +44 -44
- package/dist/bin/xhs-mp-cli.js +22 -12
- package/dist/compiler.d.ts +21 -28
- package/dist/compiler.js +327 -327
- package/dist/compilerImpl.d.ts +19 -0
- package/dist/compilerImpl.js +173 -0
- package/dist/config/constant.config.d.ts +24 -0
- package/dist/config/constant.config.js +82 -30
- package/dist/config/dir.config.js +23 -13
- package/dist/index.d.ts +9 -9
- package/dist/index.js +454 -408
- package/dist/packs/index.d.ts +4 -4
- package/dist/packs/index.js +38 -30
- package/dist/packs/mp-pack/index.js +38 -30
- package/dist/packs/webpack/dev-server/index.js +61 -50
- package/dist/packs/webpack/dev-server/lib/ensurePort.js +33 -23
- package/dist/packs/webpack/dev-server/lib/openBrowser.js +28 -18
- package/dist/packs/webpack/index.d.ts +1 -1
- package/dist/packs/webpack/index.js +99 -90
- package/dist/packs/webpack/webpack.d.ts +2 -1
- package/dist/packs/webpack/webpack.js +81 -63
- package/dist/presets/babel.d.ts +0 -1
- package/dist/presets/babel.js +64 -58
- package/dist/presets/common.js +42 -45
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.js +50 -40
- package/dist/presets/configs/minigame/assets/index.js +62 -52
- package/dist/presets/configs/minigame/service/index.js +49 -30
- package/dist/presets/configs/minigame/service/resolveLimitPlugin.js +33 -23
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.d.ts +2 -2
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.js +69 -60
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.d.ts +3 -3
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.js +39 -29
- package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.js +120 -113
- package/dist/presets/configs/miniprogram/assets/index.js +45 -43
- package/dist/presets/configs/miniprogram/render/component.js +51 -41
- package/dist/presets/configs/miniprogram/render/index.d.ts +2 -3
- package/dist/presets/configs/miniprogram/render/index.js +85 -68
- package/dist/presets/configs/miniprogram/render/render.js +53 -43
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.js +84 -49
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.d.ts +15 -0
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.js +164 -126
- package/dist/presets/configs/miniprogram/service/index.js +82 -65
- package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.js +60 -50
- package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.js +93 -55
- package/dist/presets/index.js +100 -90
- package/dist/presets/loaders/mg-entry-loader.js +32 -22
- package/dist/presets/loaders/mini-style-loader.js +79 -55
- package/dist/presets/loaders/mp-entry-loader.js +149 -140
- package/dist/presets/loaders/wxss-loader.js +73 -63
- package/dist/presets/plugins/InjectorPlugin.js +23 -13
- package/dist/presets/plugins/SourceMapDevToolPlugin.d.ts +1 -0
- package/dist/presets/plugins/SourceMapDevToolPlugin.js +23 -0
- package/dist/presets/prod.js +88 -78
- package/dist/sharedFs.d.ts +2 -0
- package/dist/sharedFs.js +24 -0
- package/dist/types/index.d.ts +11 -37
- package/dist/types/index.js +23 -13
- package/dist/utils/{apm/index.d.ts → apm.d.ts} +5 -3
- package/dist/utils/apm.js +245 -0
- package/dist/utils/cache.d.ts +28 -0
- package/dist/utils/cache.js +49 -0
- package/dist/utils/common.js +42 -32
- package/dist/utils/css.d.ts +1 -1
- package/dist/utils/css.js +43 -35
- package/dist/utils/depenedHelper.js +95 -85
- package/dist/utils/file.js +39 -29
- package/dist/utils/loader-utils.js +63 -53
- package/dist/utils/postcssRpx2Vw.js +43 -33
- package/dist/utils/project.d.ts +3 -2
- package/dist/utils/project.js +129 -119
- package/dist/utils/projectConfig.js +24 -15
- package/dist/utils/utils.js +51 -42
- package/dist/utils/workerPool.d.ts +29 -0
- package/dist/utils/workerPool.js +125 -0
- package/dist/utils/zip.js +239 -229
- package/package.json +33 -14
- package/dist/compilerCP.d.ts +0 -1
- package/dist/compilerCP.js +0 -175
- package/dist/presets/loaders/sjs-loader/index.d.ts +0 -12
- package/dist/presets/loaders/sjs-loader/index.js +0 -605
- package/dist/presets/loaders/sjs-loader/scope.d.ts +0 -36
- package/dist/presets/loaders/sjs-loader/scope.js +0 -122
- package/dist/presets/loaders/sjs-loader/tranform.d.ts +0 -2
- package/dist/presets/loaders/sjs-loader/tranform.js +0 -31
- package/dist/utils/apm/index.js +0 -198
- package/dist/utils/asyncWebpack.d.ts +0 -3
- package/dist/utils/asyncWebpack.js +0 -38
- package/dist/utils/const.d.ts +0 -27
- package/dist/utils/const.js +0 -47
- package/dist/utils/getSuffixName.d.ts +0 -3
- package/dist/utils/getSuffixName.js +0 -18
- package/dist/utils/tagTransformMap.d.ts +0 -36
- package/dist/utils/tagTransformMap.js +0 -39
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const workerpool: any;
|
|
2
|
+
declare const createPacker: any;
|
|
3
|
+
declare let globalConfig: any;
|
|
4
|
+
declare let projectPacker: any;
|
|
5
|
+
declare function formatOutputMessages(err: any, stats: any): {
|
|
6
|
+
errors: any;
|
|
7
|
+
warnings: any;
|
|
8
|
+
};
|
|
9
|
+
declare function sendMessage(data: any): void;
|
|
10
|
+
declare function sendBuildInfoMessage(type: any, message: any): void;
|
|
11
|
+
declare function createProjectPacker(data: any): any;
|
|
12
|
+
declare const handlers: {
|
|
13
|
+
runWatch: (data: any) => Promise<any>;
|
|
14
|
+
changeCompileOptions(data: any): void;
|
|
15
|
+
activatePkgs: (data: any) => Promise<void>;
|
|
16
|
+
runBuild: (data: any) => Promise<unknown>;
|
|
17
|
+
runTask: (data?: any) => Promise<void>;
|
|
18
|
+
close(): void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
const workerpool = require('xhs-mp-workerpool');
|
|
12
|
+
sendBuildInfoMessage('load-packer', '开始加载compiler');
|
|
13
|
+
const { createPacker } = require('./packs');
|
|
14
|
+
sendBuildInfoMessage('load-packer', '加载compiler完成');
|
|
15
|
+
let globalConfig = {};
|
|
16
|
+
let projectPacker;
|
|
17
|
+
function formatOutputMessages(err, stats) {
|
|
18
|
+
if (err) {
|
|
19
|
+
return { errors: [err.message], warnings: [] };
|
|
20
|
+
}
|
|
21
|
+
const json = stats.toJson({ warnings: true, errors: true, all: false });
|
|
22
|
+
const formattedErrors = json.errors.map(item => item.message);
|
|
23
|
+
const formattedWarnings = json.warnings.map(item => item.message);
|
|
24
|
+
const result = { errors: formattedErrors, warnings: formattedWarnings };
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
// workerpool 只支持在exec期间发送event
|
|
28
|
+
// 这里自己实现sendMessage
|
|
29
|
+
function sendMessage(data) {
|
|
30
|
+
const msg = Object.assign(Object.assign({}, data), { customMessage: true });
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
if (typeof self !== 'undefined' && typeof postMessage === 'function') {
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
postMessage(msg);
|
|
35
|
+
}
|
|
36
|
+
else if (typeof process !== 'undefined') {
|
|
37
|
+
// node.js
|
|
38
|
+
var WorkerThreads;
|
|
39
|
+
try {
|
|
40
|
+
WorkerThreads = require('worker_threads');
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (typeof error === 'object' && error !== null && error.code === 'MODULE_NOT_FOUND') {
|
|
44
|
+
// no worker_threads, fallback to sub-process based workers
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (WorkerThreads &&
|
|
51
|
+
/* if there is a parentPort, we are in a WorkerThread */
|
|
52
|
+
WorkerThreads.parentPort !== null) {
|
|
53
|
+
var parentPort = WorkerThreads.parentPort;
|
|
54
|
+
parentPort.postMessage(msg);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
process.send(msg);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new Error('Script must be executed as a worker');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function sendBuildInfoMessage(type, message) {
|
|
66
|
+
sendMessage({
|
|
67
|
+
event: 'compileInfo',
|
|
68
|
+
data: {
|
|
69
|
+
type,
|
|
70
|
+
message
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function createProjectPacker(data) {
|
|
75
|
+
if (!projectPacker) {
|
|
76
|
+
projectPacker = createPacker(data);
|
|
77
|
+
projectPacker.on('progress', data => {
|
|
78
|
+
sendMessage({
|
|
79
|
+
event: 'compilePercent',
|
|
80
|
+
data
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
projectPacker.on('buildInfo', data => {
|
|
84
|
+
sendMessage({
|
|
85
|
+
event: 'compileInfo',
|
|
86
|
+
data
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return projectPacker;
|
|
91
|
+
}
|
|
92
|
+
const handlers = {
|
|
93
|
+
runWatch: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
console.log('[compiler] create compiler');
|
|
95
|
+
createProjectPacker(data);
|
|
96
|
+
sendBuildInfoMessage('run-watch', '执行编译');
|
|
97
|
+
const { err, stats } = (yield projectPacker.watch({
|
|
98
|
+
scene: data.scene
|
|
99
|
+
}, (err, stats) => {
|
|
100
|
+
var _a;
|
|
101
|
+
console.log('[compiler] file change...', err, stats);
|
|
102
|
+
// 修改文件时构建
|
|
103
|
+
const hasError = err || ((_a = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _a === void 0 ? void 0 : _a.call(stats));
|
|
104
|
+
if (hasError) {
|
|
105
|
+
sendMessage({
|
|
106
|
+
event: 'emitCompileStats',
|
|
107
|
+
data: {
|
|
108
|
+
stats: formatOutputMessages(err, stats)
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
sendMessage({
|
|
114
|
+
event: 'compileFinishWhenFileChange'
|
|
115
|
+
});
|
|
116
|
+
}));
|
|
117
|
+
console.log('[compiler] it is watching...', err, stats);
|
|
118
|
+
const hasError = err || stats.hasErrors();
|
|
119
|
+
if (hasError) {
|
|
120
|
+
const error = formatOutputMessages(err, stats);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
return stats;
|
|
124
|
+
}),
|
|
125
|
+
changeCompileOptions(data) {
|
|
126
|
+
projectPacker === null || projectPacker === void 0 ? void 0 : projectPacker.changeCompileOptions(data);
|
|
127
|
+
},
|
|
128
|
+
activatePkgs: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
var _a, _b, _c;
|
|
130
|
+
const { compilePkgs } = data;
|
|
131
|
+
console.log('run activate start', compilePkgs);
|
|
132
|
+
sendBuildInfoMessage('run-activatePkgs', '执行编译');
|
|
133
|
+
const { err, stats } = (yield ((_b = (_a = projectPacker).activatePkgs) === null || _b === void 0 ? void 0 : _b.call(_a, compilePkgs)));
|
|
134
|
+
console.log('run activate finish', err, stats);
|
|
135
|
+
const hasError = err || ((_c = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _c === void 0 ? void 0 : _c.call(stats));
|
|
136
|
+
if (hasError) {
|
|
137
|
+
throw stats;
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
runBuild: data => {
|
|
141
|
+
return new Promise((resolve, reject) => {
|
|
142
|
+
createProjectPacker(data);
|
|
143
|
+
sendBuildInfoMessage('run-build', '执行编译');
|
|
144
|
+
projectPacker.build((err, stats) => {
|
|
145
|
+
var _a;
|
|
146
|
+
const hasError = err || ((_a = stats === null || stats === void 0 ? void 0 : stats.hasErrors) === null || _a === void 0 ? void 0 : _a.call(stats));
|
|
147
|
+
if (hasError) {
|
|
148
|
+
const statsInfo = formatOutputMessages(err, stats);
|
|
149
|
+
reject(statsInfo);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
resolve(null);
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
},
|
|
156
|
+
runTask: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
157
|
+
if (data) {
|
|
158
|
+
globalConfig = Object.assign(Object.assign({}, globalConfig), data);
|
|
159
|
+
}
|
|
160
|
+
if (data.action === 'dev') {
|
|
161
|
+
yield handlers.runWatch(data);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
yield handlers.runBuild(data);
|
|
165
|
+
}
|
|
166
|
+
}),
|
|
167
|
+
close() {
|
|
168
|
+
var _a;
|
|
169
|
+
(_a = projectPacker === null || projectPacker === void 0 ? void 0 : projectPacker.close) === null || _a === void 0 ? void 0 : _a.call(projectPacker, () => { });
|
|
170
|
+
projectPacker = null;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
workerpool.worker(handlers);
|
|
@@ -25,3 +25,27 @@ export declare const PKG_ROOT_SEP = "_XHSPKG_";
|
|
|
25
25
|
export declare const COMPILE_FULL_PKG = "xhs-full";
|
|
26
26
|
export declare const COMPILE_MAIN_PKG = "xhs-main";
|
|
27
27
|
export declare const COMPILE_SUB_PKG = "xhs-sub";
|
|
28
|
+
export declare const PROD_BROWSERSLIST: string[];
|
|
29
|
+
export declare const DEV_BROWSERSLIST: string[];
|
|
30
|
+
export declare const DEV_TARGETS: {
|
|
31
|
+
chrome: string;
|
|
32
|
+
};
|
|
33
|
+
export declare const PROD_TARGETS: {
|
|
34
|
+
chrome: string;
|
|
35
|
+
ios: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const ENTRY_CSS_NAME = "app";
|
|
38
|
+
export declare const FULL_PKG = "xhs-full";
|
|
39
|
+
export declare const MAIN_PKG = "xhs-main";
|
|
40
|
+
export declare const SUB_PKG = "xhs-sub";
|
|
41
|
+
export declare const BUILD_REASON: {
|
|
42
|
+
INIT: string;
|
|
43
|
+
FILE_CHANGE: string;
|
|
44
|
+
ACTIVATE_PKG: string;
|
|
45
|
+
RECOMPILE: string;
|
|
46
|
+
};
|
|
47
|
+
export declare const ASSETS_EXTS: string[];
|
|
48
|
+
export declare const PACK_MODE: {
|
|
49
|
+
MPPACK: string;
|
|
50
|
+
WEBPACK: string;
|
|
51
|
+
};
|
|
@@ -1,30 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
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;
|
|
13
|
+
exports.MAIN_PKG_ROOT = 'xhs-main';
|
|
14
|
+
exports.COMPILER_TYPE = {
|
|
15
|
+
dev: 'dev',
|
|
16
|
+
build: 'build',
|
|
17
|
+
legacy_dev: 'legacy_dev',
|
|
18
|
+
legacy_build: 'legacy_build'
|
|
19
|
+
};
|
|
20
|
+
exports.COMPILE_TYPE = {
|
|
21
|
+
mp: 'mp',
|
|
22
|
+
component: 'component',
|
|
23
|
+
service: 'service',
|
|
24
|
+
render: 'render'
|
|
25
|
+
};
|
|
26
|
+
exports.COMPILE_ENTRY = {
|
|
27
|
+
simulator: 'simulator',
|
|
28
|
+
preview: 'preview',
|
|
29
|
+
remotedebug: 'remotedebug',
|
|
30
|
+
upload: 'upload'
|
|
31
|
+
};
|
|
32
|
+
exports.MiniMode = {
|
|
33
|
+
miniprogram: 'miniprogram',
|
|
34
|
+
minigame: 'minigame'
|
|
35
|
+
};
|
|
36
|
+
exports.PKG_ROOT_SEP = '_XHSPKG_';
|
|
37
|
+
exports.COMPILE_FULL_PKG = 'xhs-full';
|
|
38
|
+
exports.COMPILE_MAIN_PKG = 'xhs-main';
|
|
39
|
+
exports.COMPILE_SUB_PKG = 'xhs-sub';
|
|
40
|
+
exports.PROD_BROWSERSLIST = ['ios_saf >= 10', 'chrome >= 83'];
|
|
41
|
+
exports.DEV_BROWSERSLIST = ['last 2 chrome version'];
|
|
42
|
+
exports.DEV_TARGETS = {
|
|
43
|
+
chrome: '90'
|
|
44
|
+
};
|
|
45
|
+
exports.PROD_TARGETS = {
|
|
46
|
+
chrome: '83',
|
|
47
|
+
ios: '10'
|
|
48
|
+
};
|
|
49
|
+
exports.ENTRY_CSS_NAME = 'app';
|
|
50
|
+
exports.FULL_PKG = 'xhs-full';
|
|
51
|
+
exports.MAIN_PKG = 'xhs-main';
|
|
52
|
+
exports.SUB_PKG = 'xhs-sub';
|
|
53
|
+
exports.BUILD_REASON = {
|
|
54
|
+
INIT: 'INIT',
|
|
55
|
+
FILE_CHANGE: 'FILE_CHANGE',
|
|
56
|
+
ACTIVATE_PKG: 'ACTIVATE_PKG',
|
|
57
|
+
RECOMPILE: 'RECOMPILE'
|
|
58
|
+
};
|
|
59
|
+
exports.ASSETS_EXTS = [
|
|
60
|
+
'png',
|
|
61
|
+
'jpg',
|
|
62
|
+
'jpeg',
|
|
63
|
+
'gif',
|
|
64
|
+
'svg',
|
|
65
|
+
'webp',
|
|
66
|
+
'cer',
|
|
67
|
+
'mp3',
|
|
68
|
+
'aac',
|
|
69
|
+
'm4a',
|
|
70
|
+
'mp4',
|
|
71
|
+
'wav',
|
|
72
|
+
'ogg',
|
|
73
|
+
'silk',
|
|
74
|
+
'wasm',
|
|
75
|
+
'br',
|
|
76
|
+
'plist'
|
|
77
|
+
];
|
|
78
|
+
exports.PACK_MODE = {
|
|
79
|
+
MPPACK: 'mp-pack',
|
|
80
|
+
WEBPACK: 'webpack'
|
|
81
|
+
};
|
|
82
|
+
});
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
2
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
3
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
(function (factory) {
|
|
5
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
|
+
var v = factory(require, exports);
|
|
7
|
+
if (v !== undefined) module.exports = v;
|
|
8
|
+
}
|
|
9
|
+
else if (typeof define === "function" && define.amd) {
|
|
10
|
+
define(["require", "exports", "../utils/utils", "fs-extra", "path", "os"], factory);
|
|
11
|
+
}
|
|
12
|
+
})(function (require, exports) {
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.mpCompileCachePath = exports.mpCompileDirPath = exports.baseDirPath = void 0;
|
|
16
|
+
const utils_1 = require("../utils/utils");
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const os_1 = __importDefault(require("os"));
|
|
20
|
+
exports.baseDirPath = (0, utils_1.normalizePath)(path_1.default.join(os_1.default.tmpdir(), '@xhs-toolkit'));
|
|
21
|
+
fs_extra_1.default.ensureDirSync(exports.baseDirPath);
|
|
22
|
+
exports.mpCompileDirPath = (0, utils_1.normalizePath)(path_1.default.join(exports.baseDirPath, 'xhs-mp-baba'));
|
|
23
|
+
fs_extra_1.default.ensureDirSync(exports.mpCompileDirPath);
|
|
24
|
+
exports.mpCompileCachePath = (0, utils_1.normalizePath)(path_1.default.join(exports.baseDirPath, 'xhs-compile-cache'));
|
|
25
|
+
fs_extra_1.default.ensureDirSync(exports.mpCompileCachePath);
|
|
26
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
/// <reference types="node/events" />
|
|
2
|
-
/// <reference types=".pnpm/artifactory.devops.xiaohongshu.com+@types+node@20.12.2/node_modules/@types/node/events" />
|
|
3
1
|
import { COMPILE_ENTRY } from './config/constant.config';
|
|
4
2
|
import { Project } from 'xhs-mp-project';
|
|
5
3
|
import EventEmitter from 'events';
|
|
6
|
-
import { Logger } from 'xhs-mp-
|
|
7
|
-
import {
|
|
4
|
+
import { Logger } from 'xhs-mp-shared';
|
|
5
|
+
import { getProjectCompilerClass, prepareDevPool } from './compiler';
|
|
8
6
|
interface ILibFeatures {
|
|
9
7
|
supportV2?: boolean;
|
|
10
8
|
supportVdom?: boolean;
|
|
11
9
|
}
|
|
12
|
-
export { COMPILE_ENTRY,
|
|
10
|
+
export { COMPILE_ENTRY, getProjectCompilerClass, prepareDevPool };
|
|
13
11
|
export type ICompileOpts = {
|
|
14
12
|
logger?: any;
|
|
15
13
|
compileDir?: string;
|
|
@@ -23,8 +21,11 @@ export type ICompilerProps = ({
|
|
|
23
21
|
project: Project;
|
|
24
22
|
}) & ICompileOpts;
|
|
25
23
|
interface ICompileBaseConfig {
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
compressCss?: boolean;
|
|
25
|
+
compressJs?: boolean;
|
|
26
|
+
enableSourcemap?: boolean;
|
|
27
|
+
appendSourcemapComment?: boolean;
|
|
28
|
+
runInServiceSandbox?: boolean;
|
|
28
29
|
enableV2: boolean;
|
|
29
30
|
enableV1: boolean;
|
|
30
31
|
enableVDom: boolean;
|
|
@@ -51,7 +52,7 @@ export interface ISubPackages {
|
|
|
51
52
|
root: string;
|
|
52
53
|
pages: string;
|
|
53
54
|
}
|
|
54
|
-
export declare class
|
|
55
|
+
export declare class ProjectCompiler extends EventEmitter {
|
|
55
56
|
projectPath: string;
|
|
56
57
|
compilerProps: ICompilerProps;
|
|
57
58
|
project: Project;
|
|
@@ -78,7 +79,6 @@ export declare class Compiler extends EventEmitter {
|
|
|
78
79
|
reCompilePkgs(config: ICompilePkgsConfig): Promise<void>;
|
|
79
80
|
compileProject(config: ICompileBuildConfig): Promise<void>;
|
|
80
81
|
compileAndZip(opts: ICompileAndZipOptions): Promise<any>;
|
|
81
|
-
private zipWithFullPackageWithAppId;
|
|
82
82
|
private zipWithFullPackage;
|
|
83
83
|
private zipWithSubPackage;
|
|
84
84
|
close(entryType?: string): void;
|