xhs-mp-compiler-cli 1.0.1-beta.3 → 1.0.2-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.
- package/package.json +4 -4
- package/dist/bin/xhs-mp-cli-build.d.ts +0 -2
- package/dist/bin/xhs-mp-cli-build.js +0 -40
- package/dist/bin/xhs-mp-cli-dev.d.ts +0 -2
- package/dist/bin/xhs-mp-cli-dev.js +0 -81
- package/dist/bin/xhs-mp-cli.d.ts +0 -2
- package/dist/bin/xhs-mp-cli.js +0 -16
- package/dist/build/index.d.ts +0 -3
- package/dist/build/index.js +0 -22
- package/dist/dev-server/index.d.ts +0 -3
- package/dist/dev-server/index.js +0 -62
- package/dist/dev-server/lib/ensurePort.d.ts +0 -2
- package/dist/dev-server/lib/ensurePort.js +0 -32
- package/dist/dev-server/lib/openBrowser.d.ts +0 -2
- package/dist/dev-server/lib/openBrowser.js +0 -23
- package/dist/dev-server/lib/openChrome.applescript +0 -78
- package/dist/globalData/SjsModule.d.ts +0 -32
- package/dist/globalData/SjsModule.js +0 -34
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -114
- package/dist/types/index.d.ts +0 -106
- package/dist/types/index.js +0 -13
- package/dist/utils/asyncWebpack.d.ts +0 -3
- package/dist/utils/asyncWebpack.js +0 -38
- package/dist/utils/combineExtJson.d.ts +0 -3
- package/dist/utils/combineExtJson.js +0 -74
- package/dist/utils/common.d.ts +0 -7
- package/dist/utils/common.js +0 -35
- package/dist/utils/depenedHelper.d.ts +0 -31
- package/dist/utils/depenedHelper.js +0 -89
- package/dist/utils/getCssSuffixName.d.ts +0 -1
- package/dist/utils/getCssSuffixName.js +0 -9
- package/dist/utils/getMlSuffixName.d.ts +0 -1
- package/dist/utils/getMlSuffixName.js +0 -6
- package/dist/utils/getPrefixName.d.ts +0 -1
- package/dist/utils/getPrefixName.js +0 -6
- package/dist/utils/projectConfig.d.ts +0 -1
- package/dist/utils/projectConfig.js +0 -20
- package/dist/utils/transformAppJson.d.ts +0 -16
- package/dist/utils/transformAppJson.js +0 -199
- package/dist/utils/validateAppJson.d.ts +0 -4
- package/dist/utils/validateAppJson.js +0 -111
- package/dist/webpack-config/index.d.ts +0 -4
- package/dist/webpack-config/index.js +0 -41
- package/dist/webpack-config/lib/const.d.ts +0 -13
- package/dist/webpack-config/lib/const.js +0 -15
- package/dist/webpack-config/lib/css.d.ts +0 -2
- package/dist/webpack-config/lib/css.js +0 -41
- package/dist/webpack-config/lib/postcssRpx2Vw.d.ts +0 -12
- package/dist/webpack-config/lib/postcssRpx2Vw.js +0 -35
- package/dist/webpack-config/lib/tagTransformMap.d.ts +0 -35
- package/dist/webpack-config/lib/tagTransformMap.js +0 -38
- package/dist/webpack-config/lib/utils.d.ts +0 -5
- package/dist/webpack-config/lib/utils.js +0 -37
- package/dist/webpack-config/loaders/component-entry-loader.d.ts +0 -1
- package/dist/webpack-config/loaders/component-entry-loader.js +0 -31
- package/dist/webpack-config/loaders/component-entry-requirements-loader.d.ts +0 -1
- package/dist/webpack-config/loaders/component-entry-requirements-loader.js +0 -24
- package/dist/webpack-config/loaders/mini-style-loader.d.ts +0 -1
- package/dist/webpack-config/loaders/mini-style-loader.js +0 -69
- package/dist/webpack-config/loaders/render-entry-loader.d.ts +0 -1
- package/dist/webpack-config/loaders/render-entry-loader.js +0 -50
- package/dist/webpack-config/loaders/service-entry-loader.d.ts +0 -1
- package/dist/webpack-config/loaders/service-entry-loader.js +0 -51
- package/dist/webpack-config/loaders/sjs-loader/index.d.ts +0 -12
- package/dist/webpack-config/loaders/sjs-loader/index.js +0 -609
- package/dist/webpack-config/loaders/sjs-loader/scope.d.ts +0 -36
- package/dist/webpack-config/loaders/sjs-loader/scope.js +0 -122
- package/dist/webpack-config/loaders/sjs-loader/tranform.d.ts +0 -2
- package/dist/webpack-config/loaders/sjs-loader/tranform.js +0 -31
- package/dist/webpack-config/loaders/utils.d.ts +0 -13
- package/dist/webpack-config/loaders/utils.js +0 -41
- package/dist/webpack-config/loaders/wxss-loader.d.ts +0 -1
- package/dist/webpack-config/loaders/wxss-loader.js +0 -76
- package/dist/webpack-config/plugins/VueLoaderPlugin.d.ts +0 -19
- package/dist/webpack-config/plugins/VueLoaderPlugin.js +0 -205
- package/dist/webpack-config/plugins/XhsMpErrorTransformPlugin.d.ts +0 -8
- package/dist/webpack-config/plugins/XhsMpErrorTransformPlugin.js +0 -40
- package/dist/webpack-config/plugins/XhsMpJsonPlugin.d.ts +0 -36
- package/dist/webpack-config/plugins/XhsMpJsonPlugin.js +0 -71
- package/dist/webpack-config/presets/babel.d.ts +0 -8
- package/dist/webpack-config/presets/babel.js +0 -57
- package/dist/webpack-config/presets/common.d.ts +0 -4
- package/dist/webpack-config/presets/common.js +0 -40
- package/dist/webpack-config/presets/mp/MpEntryPlugin.d.ts +0 -23
- package/dist/webpack-config/presets/mp/MpEntryPlugin.js +0 -87
- package/dist/webpack-config/presets/mp/index.d.ts +0 -4
- package/dist/webpack-config/presets/mp/index.js +0 -48
- package/dist/webpack-config/presets/prod.d.ts +0 -4
- package/dist/webpack-config/presets/prod.js +0 -83
- package/dist/webpack-config/presets/render/ComponentEntryPlugin.d.ts +0 -18
- package/dist/webpack-config/presets/render/ComponentEntryPlugin.js +0 -77
- package/dist/webpack-config/presets/render/RenderChunkPlugin.d.ts +0 -5
- package/dist/webpack-config/presets/render/RenderChunkPlugin.js +0 -50
- package/dist/webpack-config/presets/render/RenderEntryPlugin.d.ts +0 -14
- package/dist/webpack-config/presets/render/RenderEntryPlugin.js +0 -42
- package/dist/webpack-config/presets/render/SjsEntryPlugin.d.ts +0 -31
- package/dist/webpack-config/presets/render/SjsEntryPlugin.js +0 -160
- package/dist/webpack-config/presets/render/index.d.ts +0 -4
- package/dist/webpack-config/presets/render/index.js +0 -62
- package/dist/webpack-config/presets/service/ServiceEntryPlugin.d.ts +0 -8
- package/dist/webpack-config/presets/service/ServiceEntryPlugin.js +0 -36
- package/dist/webpack-config/presets/service/XhsMpServiceChunkPlugin.d.ts +0 -6
- package/dist/webpack-config/presets/service/XhsMpServiceChunkPlugin.js +0 -46
- package/dist/webpack-config/presets/service/XhsResolveLimitPlugin.d.ts +0 -8
- package/dist/webpack-config/presets/service/XhsResolveLimitPlugin.js +0 -65
- package/dist/webpack-config/presets/service/XhsV2AssetsPlugin.d.ts +0 -5
- package/dist/webpack-config/presets/service/XhsV2AssetsPlugin.js +0 -27
- package/dist/webpack-config/presets/service/index.d.ts +0 -4
- package/dist/webpack-config/presets/service/index.js +0 -39
package/dist/types/index.d.ts
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
export declare enum ENV {
|
|
2
|
-
development = 0,
|
|
3
|
-
production = 1
|
|
4
|
-
}
|
|
5
|
-
export interface Component {
|
|
6
|
-
index?: number;
|
|
7
|
-
usingComponents?: {
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
10
|
-
componentPlaceholder?: {
|
|
11
|
-
[key: string]: string;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export interface Page {
|
|
15
|
-
path: string;
|
|
16
|
-
usingComponents?: {
|
|
17
|
-
[key: string]: string;
|
|
18
|
-
};
|
|
19
|
-
componentPlaceholder?: {
|
|
20
|
-
[key: string]: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export interface SubPackage {
|
|
24
|
-
root: string;
|
|
25
|
-
pages: Page[];
|
|
26
|
-
independent?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export declare enum CodePackageMode {
|
|
29
|
-
default = "default",
|
|
30
|
-
requiredComponents = "requiredComponents"
|
|
31
|
-
}
|
|
32
|
-
export interface AppJSON {
|
|
33
|
-
pages: Page[];
|
|
34
|
-
subPackages: SubPackage[];
|
|
35
|
-
subpackages: SubPackage[];
|
|
36
|
-
usingComponents?: {
|
|
37
|
-
[key: string]: string;
|
|
38
|
-
};
|
|
39
|
-
lazyCodeLoading?: CodePackageMode;
|
|
40
|
-
componentsMap: {
|
|
41
|
-
[key: string]: Component;
|
|
42
|
-
};
|
|
43
|
-
xhsVersionStrategy: {
|
|
44
|
-
[key: string]: string | boolean;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface CliConfig {
|
|
48
|
-
/**
|
|
49
|
-
* 小程序入口目录
|
|
50
|
-
*/
|
|
51
|
-
mpDir: string;
|
|
52
|
-
miniprogramDir: string;
|
|
53
|
-
/**
|
|
54
|
-
* 构建产物目录
|
|
55
|
-
*/
|
|
56
|
-
distDir?: string;
|
|
57
|
-
watch?: boolean;
|
|
58
|
-
env: ENV;
|
|
59
|
-
tsConfigPath?: string;
|
|
60
|
-
/**
|
|
61
|
-
* ext json path
|
|
62
|
-
*/
|
|
63
|
-
extJsonPath?: string;
|
|
64
|
-
cacheDirectory?: string;
|
|
65
|
-
/**
|
|
66
|
-
* 是否开启 Js 编译压缩
|
|
67
|
-
*/
|
|
68
|
-
compressJs?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* 打包是否包含 js 文件
|
|
71
|
-
*/
|
|
72
|
-
noJs?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* dev 模式是否开启 sourcemap,默认开启
|
|
75
|
-
*/
|
|
76
|
-
enableSourcemap?: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* 服务端口
|
|
79
|
-
*/
|
|
80
|
-
port?: number;
|
|
81
|
-
enableV1?: boolean;
|
|
82
|
-
enableV2?: boolean;
|
|
83
|
-
enableVDom?: boolean;
|
|
84
|
-
}
|
|
85
|
-
type CliPick = 'mpDir' | 'distDir' | 'watch' | 'tsConfigPath' | 'extJsonPath' | 'cacheDirectory' | 'compressJs' | 'enableSourcemap' | 'enableV1' | 'enableV2' | 'enableVDom';
|
|
86
|
-
export interface IStart extends Pick<CliConfig, CliPick> {
|
|
87
|
-
/**
|
|
88
|
-
* 调用的能力,dev 还是 build
|
|
89
|
-
*/
|
|
90
|
-
action: 'dev' | 'build';
|
|
91
|
-
/**
|
|
92
|
-
* 每次构建完毕的回调函数
|
|
93
|
-
*/
|
|
94
|
-
callback?: () => void;
|
|
95
|
-
/**
|
|
96
|
-
* 构建产物目录
|
|
97
|
-
*/
|
|
98
|
-
distDir?: string;
|
|
99
|
-
platform?: 'wx' | 'xhs';
|
|
100
|
-
/**
|
|
101
|
-
* 服务端口
|
|
102
|
-
*/
|
|
103
|
-
port?: number;
|
|
104
|
-
}
|
|
105
|
-
export type WebpackPresetOptions = CliConfig;
|
|
106
|
-
export {};
|
package/dist/types/index.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CodePackageMode = exports.ENV = void 0;
|
|
4
|
-
var ENV;
|
|
5
|
-
(function (ENV) {
|
|
6
|
-
ENV[ENV["development"] = 0] = "development";
|
|
7
|
-
ENV[ENV["production"] = 1] = "production";
|
|
8
|
-
})(ENV || (exports.ENV = ENV = {}));
|
|
9
|
-
var CodePackageMode;
|
|
10
|
-
(function (CodePackageMode) {
|
|
11
|
-
CodePackageMode["default"] = "default";
|
|
12
|
-
CodePackageMode["requiredComponents"] = "requiredComponents";
|
|
13
|
-
})(CodePackageMode || (exports.CodePackageMode = CodePackageMode = {}));
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const webpack_1 = __importDefault(require("webpack"));
|
|
16
|
-
const webpackCompile = (config, callback) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
-
return new Promise((res, rej) => {
|
|
18
|
-
(0, webpack_1.default)(config, (err, stats) => {
|
|
19
|
-
if (err) {
|
|
20
|
-
// eslint-disable-next-line
|
|
21
|
-
console.log(err);
|
|
22
|
-
rej(err);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// eslint-disable-next-line
|
|
26
|
-
console.log(stats === null || stats === void 0 ? void 0 : stats.toString({
|
|
27
|
-
modules: true,
|
|
28
|
-
chunks: true,
|
|
29
|
-
children: false,
|
|
30
|
-
colors: true,
|
|
31
|
-
}));
|
|
32
|
-
callback === null || callback === void 0 ? void 0 : callback();
|
|
33
|
-
res(stats);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
exports.default = webpackCompile;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const webpack_1 = require("webpack");
|
|
4
|
-
const validateExtJson = (appJSON, extJson, compilation) => {
|
|
5
|
-
var _a;
|
|
6
|
-
const emitError = (details) => {
|
|
7
|
-
const err = new webpack_1.WebpackError(`[ ext.json 内容错误 ]: ${details}`);
|
|
8
|
-
err.file = 'ext.json';
|
|
9
|
-
err.stack = undefined;
|
|
10
|
-
compilation === null || compilation === void 0 ? void 0 : compilation.errors.push(err);
|
|
11
|
-
};
|
|
12
|
-
const limitedPages = appJSON.pages;
|
|
13
|
-
if (extJson.pages) {
|
|
14
|
-
for (const page of extJson.pages) {
|
|
15
|
-
if (!limitedPages.includes(page)) {
|
|
16
|
-
emitError(`page 错误: "${page}" 不在 app.json 内`);
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (extJson.extPages) {
|
|
22
|
-
for (const page of Object.keys(extJson.extPages)) {
|
|
23
|
-
if (!limitedPages.includes(page)) {
|
|
24
|
-
emitError(`extPages 错误: "${page}" 不在 app.json 内`);
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if ((_a = extJson === null || extJson === void 0 ? void 0 : extJson.tabBar) === null || _a === void 0 ? void 0 : _a.list) {
|
|
30
|
-
if (extJson.tabBar.list.length < 2) {
|
|
31
|
-
emitError(`tabBar.list 错误: tabBar.list 需至少包含 2 项`);
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
for (const { pagePath } of extJson.tabBar.list) {
|
|
35
|
-
if (!pagePath) {
|
|
36
|
-
emitError(`tabBar.list 错误: "pagePath" 不能为空`);
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
if (!limitedPages.includes(pagePath)) {
|
|
40
|
-
emitError(`tabBar.list 错误: "${pagePath}" 不在 app.json 内`);
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* https://wiki.xiaohongshu.com/pages/viewpage.action?pageId=127531115
|
|
49
|
-
*/
|
|
50
|
-
const mergeList = ['window', 'networkTimeout', 'tabBar'];
|
|
51
|
-
const combineExtJson = (appJSON, extJson, compilation) => {
|
|
52
|
-
if (!validateExtJson(appJSON, extJson, compilation)) {
|
|
53
|
-
return appJSON;
|
|
54
|
-
}
|
|
55
|
-
for (const [key, val] of Object.entries(extJson)) {
|
|
56
|
-
if (key === 'extPages') {
|
|
57
|
-
// extPages 字段作用于每个页面的 json 文件,在 transformAppJson 中处理
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
else if (typeof val === 'object' && mergeList.includes(key)) {
|
|
61
|
-
// 对需要 merge 的字段进行 merge
|
|
62
|
-
const isArray = Array.isArray(val);
|
|
63
|
-
appJSON[`${key}`] = appJSON[`${key}`] || (isArray ? [] : {});
|
|
64
|
-
// @ts-ignore
|
|
65
|
-
appJSON[`${key}`] = isArray ? [...new Set([...appJSON[`${key}`], ...val])] : Object.assign(Object.assign({}, appJSON[`${key}`]), val);
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
// 除此之外直接用 ext.json 的内容覆盖
|
|
69
|
-
appJSON[`${key}`] = val;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return appJSON;
|
|
73
|
-
};
|
|
74
|
-
exports.default = combineExtJson;
|
package/dist/utils/common.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const getTsConfigPath: (mpDir: string) => string | undefined;
|
|
2
|
-
export declare const isString: (val: unknown) => val is string;
|
|
3
|
-
export declare const toUnixPath: (pathStr?: string) => string;
|
|
4
|
-
export declare const unixJoin: (...paths: string[]) => string;
|
|
5
|
-
export declare const unixResolve: (...paths: string[]) => string;
|
|
6
|
-
export declare const getShortPath: (miniprogramDir: string, rootContext: string) => string;
|
|
7
|
-
export declare const md5: (str: string) => string;
|
package/dist/utils/common.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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.md5 = exports.getShortPath = exports.unixResolve = exports.unixJoin = exports.toUnixPath = exports.isString = exports.getTsConfigPath = void 0;
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
10
|
-
const getMlSuffixName_1 = __importDefault(require("./getMlSuffixName"));
|
|
11
|
-
const getTsConfigPath = (mpDir) => {
|
|
12
|
-
if (fs_extra_1.default.existsSync(`${mpDir}/tsconfig.json`)) {
|
|
13
|
-
return `${mpDir}/tsconfig.json`;
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
};
|
|
17
|
-
exports.getTsConfigPath = getTsConfigPath;
|
|
18
|
-
const isString = (val) => typeof val === 'string';
|
|
19
|
-
exports.isString = isString;
|
|
20
|
-
const toUnixPath = (pathStr = '') => pathStr.split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
21
|
-
exports.toUnixPath = toUnixPath;
|
|
22
|
-
const unixJoin = (...paths) => (0, exports.toUnixPath)(path_1.default.join(...paths));
|
|
23
|
-
exports.unixJoin = unixJoin;
|
|
24
|
-
const unixResolve = (...paths) => (0, exports.toUnixPath)(path_1.default.resolve(...paths));
|
|
25
|
-
exports.unixResolve = unixResolve;
|
|
26
|
-
const getShortPath = (miniprogramDir, rootContext) => {
|
|
27
|
-
const suffix = (0, getMlSuffixName_1.default)();
|
|
28
|
-
miniprogramDir = (0, exports.toUnixPath)(miniprogramDir);
|
|
29
|
-
miniprogramDir = miniprogramDir.endsWith('/') ? miniprogramDir : `${miniprogramDir}/`;
|
|
30
|
-
const reg = new RegExp(`.${suffix}$`, 'g');
|
|
31
|
-
return (0, exports.toUnixPath)(rootContext).replace(reg, '').replace(miniprogramDir, '');
|
|
32
|
-
};
|
|
33
|
-
exports.getShortPath = getShortPath;
|
|
34
|
-
const md5 = (str) => crypto_1.default.createHash('md5').update(str).digest('hex');
|
|
35
|
-
exports.md5 = md5;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AppJSON } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* get _mp_app_json page depend components map
|
|
4
|
-
* @param pageUri
|
|
5
|
-
* @returns {usingComponents} object
|
|
6
|
-
*/
|
|
7
|
-
export declare const getPageDependComponents: (appJson: AppJSON, pageUri: string) => {
|
|
8
|
-
[key: string]: string;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* get _mp_app_json subPackage page components map
|
|
12
|
-
* @param pageUri
|
|
13
|
-
* @returns {usingComponents} object
|
|
14
|
-
*/
|
|
15
|
-
export declare const getSubPageComponents: (appJson: AppJSON, pageUri: string) => {
|
|
16
|
-
[key: string]: string;
|
|
17
|
-
};
|
|
18
|
-
export declare const getGlobalComponents: (appJson: AppJSON) => {
|
|
19
|
-
[key: string]: string;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* 老版本基础库上传的包可能包含 subPackages 字段,但下载的构建产物确是按照整包处理
|
|
23
|
-
* 通过下面的逻辑来决定是否走分包的逻辑(与 native 侧一致)
|
|
24
|
-
*
|
|
25
|
-
* @returns { boolean } 是否走分包
|
|
26
|
-
*/
|
|
27
|
-
export declare function shouldEnableSubPackage(appJson: any): boolean;
|
|
28
|
-
export declare const getIndependComponents: (appJson: AppJSON, componentPath: string) => {
|
|
29
|
-
[key: string]: string;
|
|
30
|
-
};
|
|
31
|
-
export declare const getPageDependComponentPaths: (pageUri: string, appJson: AppJSON, isIndependent?: boolean, enableSubPackage?: boolean) => string[];
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPageDependComponentPaths = exports.getIndependComponents = exports.shouldEnableSubPackage = exports.getGlobalComponents = exports.getSubPageComponents = exports.getPageDependComponents = void 0;
|
|
4
|
-
const common_1 = require("./common");
|
|
5
|
-
/**
|
|
6
|
-
* get _mp_app_json page depend components map
|
|
7
|
-
* @param pageUri
|
|
8
|
-
* @returns {usingComponents} object
|
|
9
|
-
*/
|
|
10
|
-
const getPageDependComponents = (appJson, pageUri) => {
|
|
11
|
-
const matchPage = appJson.pages.find(page => page.path === pageUri) || {};
|
|
12
|
-
return (matchPage === null || matchPage === void 0 ? void 0 : matchPage.usingComponents) ? matchPage.usingComponents : {};
|
|
13
|
-
};
|
|
14
|
-
exports.getPageDependComponents = getPageDependComponents;
|
|
15
|
-
/**
|
|
16
|
-
* get _mp_app_json subPackage page components map
|
|
17
|
-
* @param pageUri
|
|
18
|
-
* @returns {usingComponents} object
|
|
19
|
-
*/
|
|
20
|
-
const getSubPageComponents = (appJson, pageUri) => {
|
|
21
|
-
let subPackagesPages = [];
|
|
22
|
-
((appJson === null || appJson === void 0 ? void 0 : appJson.subPackages) || []).forEach(subPackage => {
|
|
23
|
-
subPackagesPages = subPackagesPages.concat(subPackage.pages);
|
|
24
|
-
});
|
|
25
|
-
const matchPage = subPackagesPages.find(page => page.path === pageUri) || {};
|
|
26
|
-
return (matchPage === null || matchPage === void 0 ? void 0 : matchPage.usingComponents) || {};
|
|
27
|
-
};
|
|
28
|
-
exports.getSubPageComponents = getSubPageComponents;
|
|
29
|
-
const getGlobalComponents = (appJson) => (appJson === null || appJson === void 0 ? void 0 : appJson.usingComponents) || {};
|
|
30
|
-
exports.getGlobalComponents = getGlobalComponents;
|
|
31
|
-
/**
|
|
32
|
-
* 老版本基础库上传的包可能包含 subPackages 字段,但下载的构建产物确是按照整包处理
|
|
33
|
-
* 通过下面的逻辑来决定是否走分包的逻辑(与 native 侧一致)
|
|
34
|
-
*
|
|
35
|
-
* @returns { boolean } 是否走分包
|
|
36
|
-
*/
|
|
37
|
-
function shouldEnableSubPackage(appJson) {
|
|
38
|
-
var _a, _b;
|
|
39
|
-
if (!(appJson === null || appJson === void 0 ? void 0 : appJson.subPackages) || !(appJson === null || appJson === void 0 ? void 0 : appJson.subPackages.length))
|
|
40
|
-
return false;
|
|
41
|
-
let enableFlag = false;
|
|
42
|
-
try {
|
|
43
|
-
enableFlag = !(0, common_1.isString)((_b = (_a = appJson === null || appJson === void 0 ? void 0 : appJson.subPackages) === null || _a === void 0 ? void 0 : _a[0].pages) === null || _b === void 0 ? void 0 : _b[0]);
|
|
44
|
-
}
|
|
45
|
-
catch (_) { /** eslint-disabled */ }
|
|
46
|
-
return enableFlag;
|
|
47
|
-
}
|
|
48
|
-
exports.shouldEnableSubPackage = shouldEnableSubPackage;
|
|
49
|
-
const getIndependComponents = (appJson, componentPath) => {
|
|
50
|
-
var _a;
|
|
51
|
-
const componentsMap = appJson.componentsMap || {};
|
|
52
|
-
return ((_a = componentsMap === null || componentsMap === void 0 ? void 0 : componentsMap[componentPath]) === null || _a === void 0 ? void 0 : _a.usingComponents) || {};
|
|
53
|
-
};
|
|
54
|
-
exports.getIndependComponents = getIndependComponents;
|
|
55
|
-
const getPageDependComponentPaths = (pageUri, appJson, isIndependent = false, enableSubPackage = true) => {
|
|
56
|
-
try {
|
|
57
|
-
const loadPathList = new Set();
|
|
58
|
-
let pageUsingComponents = {};
|
|
59
|
-
if (enableSubPackage) {
|
|
60
|
-
pageUsingComponents = Object.assign(Object.assign(Object.assign({}, (isIndependent ? {} : (0, exports.getGlobalComponents)(appJson))), (0, exports.getPageDependComponents)(appJson, pageUri)), (0, exports.getSubPageComponents)(appJson, pageUri));
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
pageUsingComponents = Object.assign(Object.assign({}, (0, exports.getGlobalComponents)(appJson)), (0, exports.getPageDependComponents)(appJson, pageUri));
|
|
64
|
-
}
|
|
65
|
-
const loadComponent = (components) => {
|
|
66
|
-
for (const componentName in components) {
|
|
67
|
-
if (components[componentName]) {
|
|
68
|
-
const componentPath = components[componentName];
|
|
69
|
-
if (loadPathList.has(componentPath)) {
|
|
70
|
-
// eslint-disable-next-line no-continue
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
loadPathList.add(componentPath);
|
|
74
|
-
const inDependComponents = (0, exports.getIndependComponents)(appJson, componentPath);
|
|
75
|
-
if (inDependComponents && Object.keys(inDependComponents).length) {
|
|
76
|
-
loadComponent(inDependComponents);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
loadComponent(pageUsingComponents);
|
|
82
|
-
return Array.from(loadPathList);
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
console.error(`parse page depend components has error happen`);
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
exports.getPageDependComponentPaths = getPageDependComponentPaths;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getCssSuffixName(): "css" | "wxss";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getMlSuffixName(): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getPrefixName(): string | undefined;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getProjectConfig(mpDir: any): any;
|
|
@@ -1,20 +0,0 @@
|
|
|
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.getProjectConfig = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
-
function getProjectConfig(mpDir) {
|
|
10
|
-
const projectJsonPath = path_1.default.join(mpDir, 'project.config.json');
|
|
11
|
-
let projectJson = {};
|
|
12
|
-
try {
|
|
13
|
-
projectJson = fs_extra_1.default.readJSONSync(projectJsonPath);
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
// do something
|
|
17
|
-
}
|
|
18
|
-
return projectJson;
|
|
19
|
-
}
|
|
20
|
-
exports.getProjectConfig = getProjectConfig;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Compilation } from 'webpack';
|
|
2
|
-
import { AppJSON } from '../types';
|
|
3
|
-
export declare const PATH_REG: RegExp;
|
|
4
|
-
/**
|
|
5
|
-
* wx: https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html
|
|
6
|
-
* bilibili: http://miniapp.bilibili.com/small-app-doc/framework/global-config/
|
|
7
|
-
* 对于小程序开发者,按照 wx 的文档格式来定义 json 文件
|
|
8
|
-
* 根据端侧需求将 json 文件的 pages 字段转换为 bilibili 格式
|
|
9
|
-
* @param miniprogramDir 小程序目录(带miniprogramRoot)
|
|
10
|
-
* @returns 转换后的 bilibili 格式的 app.json
|
|
11
|
-
*/
|
|
12
|
-
declare const transformAppJson: (mpDir: string, miniprogramDir: string, extJsonPath?: string, compilation?: Compilation) => {
|
|
13
|
-
legacyAppJSON: any;
|
|
14
|
-
appJSON: AppJSON;
|
|
15
|
-
};
|
|
16
|
-
export default transformAppJson;
|