xhs-mp-compiler-cli 1.1.2 → 1.1.3
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 +2 -2
- 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 -59
- package/dist/bin/xhs-mp-cli.d.ts +0 -2
- package/dist/bin/xhs-mp-cli.js +0 -16
- package/dist/compiler.d.ts +0 -76
- package/dist/compiler.js +0 -361
- package/dist/compilerCP.d.ts +0 -1
- package/dist/compilerCP.js +0 -175
- package/dist/config/constant.config.d.ts +0 -27
- package/dist/config/constant.config.js +0 -30
- package/dist/config/dir.config.d.ts +0 -3
- package/dist/config/dir.config.js +0 -16
- package/dist/index.d.ts +0 -84
- package/dist/index.js +0 -454
- package/dist/packs/index.d.ts +0 -14
- package/dist/packs/index.js +0 -31
- package/dist/packs/mp-pack/index.d.ts +0 -3
- package/dist/packs/mp-pack/index.js +0 -32
- package/dist/packs/webpack/dev-server/index.d.ts +0 -3
- package/dist/packs/webpack/dev-server/index.js +0 -64
- package/dist/packs/webpack/dev-server/lib/ensurePort.d.ts +0 -2
- package/dist/packs/webpack/dev-server/lib/ensurePort.js +0 -32
- package/dist/packs/webpack/dev-server/lib/openBrowser.d.ts +0 -2
- package/dist/packs/webpack/dev-server/lib/openBrowser.js +0 -23
- package/dist/packs/webpack/dev-server/lib/openChrome.applescript +0 -78
- package/dist/packs/webpack/index.d.ts +0 -3
- package/dist/packs/webpack/index.js +0 -92
- package/dist/packs/webpack/webpack.d.ts +0 -21
- package/dist/packs/webpack/webpack.js +0 -79
- package/dist/presets/babel.d.ts +0 -8
- package/dist/presets/babel.js +0 -59
- package/dist/presets/common.d.ts +0 -4
- package/dist/presets/common.js +0 -48
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.d.ts +0 -10
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.js +0 -46
- package/dist/presets/configs/minigame/assets/index.d.ts +0 -3
- package/dist/presets/configs/minigame/assets/index.js +0 -65
- package/dist/presets/configs/minigame/service/index.d.ts +0 -3
- package/dist/presets/configs/minigame/service/index.js +0 -34
- package/dist/presets/configs/minigame/service/resolveLimitPlugin.d.ts +0 -8
- package/dist/presets/configs/minigame/service/resolveLimitPlugin.js +0 -35
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.d.ts +0 -9
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.js +0 -69
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.d.ts +0 -10
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.js +0 -32
- package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.d.ts +0 -12
- package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.js +0 -132
- package/dist/presets/configs/miniprogram/assets/index.d.ts +0 -4
- package/dist/presets/configs/miniprogram/assets/index.js +0 -47
- package/dist/presets/configs/miniprogram/render/component.d.ts +0 -3
- package/dist/presets/configs/miniprogram/render/component.js +0 -47
- package/dist/presets/configs/miniprogram/render/index.d.ts +0 -5
- package/dist/presets/configs/miniprogram/render/index.js +0 -71
- package/dist/presets/configs/miniprogram/render/render.d.ts +0 -3
- package/dist/presets/configs/miniprogram/render/render.js +0 -49
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.d.ts +0 -8
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.js +0 -55
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.d.ts +0 -15
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.js +0 -163
- package/dist/presets/configs/miniprogram/service/index.d.ts +0 -5
- package/dist/presets/configs/miniprogram/service/index.js +0 -72
- package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.d.ts +0 -8
- package/dist/presets/configs/miniprogram/service/resolveLimitPlugin.js +0 -66
- package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.d.ts +0 -9
- package/dist/presets/configs/miniprogram/service/serviceChunkPlugin.js +0 -65
- package/dist/presets/index.d.ts +0 -2
- package/dist/presets/index.js +0 -95
- package/dist/presets/loaders/mg-entry-loader.d.ts +0 -1
- package/dist/presets/loaders/mg-entry-loader.js +0 -27
- package/dist/presets/loaders/mini-style-loader.d.ts +0 -1
- package/dist/presets/loaders/mini-style-loader.js +0 -72
- package/dist/presets/loaders/mp-entry-loader.d.ts +0 -1
- package/dist/presets/loaders/mp-entry-loader.js +0 -196
- 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/presets/loaders/wxss-loader.d.ts +0 -1
- package/dist/presets/loaders/wxss-loader.js +0 -77
- package/dist/presets/plugins/InjectorPlugin.d.ts +0 -7
- package/dist/presets/plugins/InjectorPlugin.js +0 -14
- package/dist/presets/prod.d.ts +0 -4
- package/dist/presets/prod.js +0 -80
- package/dist/types/index.d.ts +0 -118
- 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/common.d.ts +0 -8
- package/dist/utils/common.js +0 -36
- package/dist/utils/const.d.ts +0 -27
- package/dist/utils/const.js +0 -47
- package/dist/utils/css.d.ts +0 -2
- package/dist/utils/css.js +0 -41
- package/dist/utils/depenedHelper.d.ts +0 -31
- package/dist/utils/depenedHelper.js +0 -89
- package/dist/utils/file.d.ts +0 -2
- package/dist/utils/file.js +0 -67
- package/dist/utils/getSuffixName.d.ts +0 -3
- package/dist/utils/getSuffixName.js +0 -18
- package/dist/utils/loader-utils.d.ts +0 -15
- package/dist/utils/loader-utils.js +0 -59
- package/dist/utils/postcssRpx2Vw.d.ts +0 -12
- package/dist/utils/postcssRpx2Vw.js +0 -35
- package/dist/utils/project.d.ts +0 -27
- package/dist/utils/project.js +0 -164
- package/dist/utils/projectConfig.d.ts +0 -1
- package/dist/utils/projectConfig.js +0 -20
- package/dist/utils/tagTransformMap.d.ts +0 -35
- package/dist/utils/tagTransformMap.js +0 -38
- package/dist/utils/utils.d.ts +0 -7
- package/dist/utils/utils.js +0 -50
- package/dist/utils/zip.d.ts +0 -28
- package/dist/utils/zip.js +0 -287
package/dist/utils/css.js
DELETED
|
@@ -1,41 +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
|
-
// @ts-nocheck
|
|
7
|
-
const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
|
|
8
|
-
const postcssRpx2Vw_1 = __importDefault(require("./postcssRpx2Vw"));
|
|
9
|
-
const const_1 = __importDefault(require("./const"));
|
|
10
|
-
const types_1 = require("../types");
|
|
11
|
-
const { DEV_BROWSERSLIST, PROD_BROWSERSLIST } = const_1.default;
|
|
12
|
-
const getCssConfig = (options, presets) => {
|
|
13
|
-
const isDev = options.env === types_1.ENV.development;
|
|
14
|
-
const browsers = isDev ? DEV_BROWSERSLIST : PROD_BROWSERSLIST;
|
|
15
|
-
const loaders = {
|
|
16
|
-
'mini-style-loader': {
|
|
17
|
-
loader: require.resolve('../presets/loaders/mini-style-loader'),
|
|
18
|
-
options: Object.assign(Object.assign({}, options), { independent: true })
|
|
19
|
-
},
|
|
20
|
-
'postcss-loader': {
|
|
21
|
-
loader: require.resolve('postcss-loader'),
|
|
22
|
-
options: {
|
|
23
|
-
sourceMap: options.env !== types_1.ENV.production,
|
|
24
|
-
postcssOptions: {
|
|
25
|
-
config: false,
|
|
26
|
-
plugins: [(0, postcssRpx2Vw_1.default)({ baseWidth: 750 }), (0, postcss_preset_env_1.default)({ browsers })],
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
'wxss-loader': {
|
|
31
|
-
loader: require.resolve('../presets/loaders/wxss-loader'),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
return presets.flat().reduce((acc, cur) => {
|
|
35
|
-
if (typeof cur === "string" && loaders[cur]) {
|
|
36
|
-
Reflect.set(acc, cur, loaders[cur]);
|
|
37
|
-
}
|
|
38
|
-
return acc;
|
|
39
|
-
}, {});
|
|
40
|
-
};
|
|
41
|
-
exports.default = getCssConfig;
|
|
@@ -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;
|
package/dist/utils/file.d.ts
DELETED
package/dist/utils/file.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.getFolderSize = exports.fileSize = void 0;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const globby_1 = __importDefault(require("globby"));
|
|
41
|
-
const fileSize = (size) => {
|
|
42
|
-
if (!size)
|
|
43
|
-
return '';
|
|
44
|
-
const base = 1024;
|
|
45
|
-
if (size < base) {
|
|
46
|
-
return `${size}B`;
|
|
47
|
-
}
|
|
48
|
-
if (size < Math.pow(base, 2)) {
|
|
49
|
-
return `${(size / base).toFixed(2)}KB`;
|
|
50
|
-
}
|
|
51
|
-
if (size < Math.pow(base, 3)) {
|
|
52
|
-
return `${(size / Math.pow(base, 2)).toFixed(2)}MB`;
|
|
53
|
-
}
|
|
54
|
-
if (size < Math.pow(base, 4)) {
|
|
55
|
-
return `${(size / Math.pow(base, 3)).toFixed(2)}GB`;
|
|
56
|
-
}
|
|
57
|
-
return `${(size / Math.pow(base, 4)).toFixed(2)}T`;
|
|
58
|
-
};
|
|
59
|
-
exports.fileSize = fileSize;
|
|
60
|
-
const getFolderSize = (folder) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
-
const _folder = folder.map(f => f.replace(/\\/g, '/')); // 修复windows的路径
|
|
62
|
-
const folders = yield (0, globby_1.default)(_folder);
|
|
63
|
-
// eslint-disable-next-line no-return-assign
|
|
64
|
-
const totalSize = folders.reduce((pre, cur) => (pre += fs.statSync(cur).size), 0);
|
|
65
|
-
return totalSize;
|
|
66
|
-
});
|
|
67
|
-
exports.getFolderSize = getFolderSize;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPrefixName = exports.getCssSuffixName = exports.getMlSuffixName = void 0;
|
|
4
|
-
function getMlSuffixName() {
|
|
5
|
-
return `${process.env.__platform}ml`.trim();
|
|
6
|
-
}
|
|
7
|
-
exports.getMlSuffixName = getMlSuffixName;
|
|
8
|
-
function getCssSuffixName() {
|
|
9
|
-
if (process.env.__platform === 'xhs') {
|
|
10
|
-
return 'css';
|
|
11
|
-
}
|
|
12
|
-
return 'wxss';
|
|
13
|
-
}
|
|
14
|
-
exports.getCssSuffixName = getCssSuffixName;
|
|
15
|
-
function getPrefixName() {
|
|
16
|
-
return process.env.__platform;
|
|
17
|
-
}
|
|
18
|
-
exports.getPrefixName = getPrefixName;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare const formatPath: (pathStr?: string) => string;
|
|
2
|
-
export declare const getShortPath: (projectMiniprogramPath: string, rootContext: string) => string;
|
|
3
|
-
/**
|
|
4
|
-
* 根据是否分包获取资源路径
|
|
5
|
-
*/
|
|
6
|
-
export declare const getResourceUris: (options: {
|
|
7
|
-
appCssExist: boolean;
|
|
8
|
-
enableLazyCodeLoading: boolean;
|
|
9
|
-
subPackage: any;
|
|
10
|
-
}) => string[];
|
|
11
|
-
/**
|
|
12
|
-
* @NOTE
|
|
13
|
-
* Create a request and handle the conversion of esModule modules
|
|
14
|
-
* */
|
|
15
|
-
export declare function createRequire(modulePath: string): string;
|
|
@@ -1,59 +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.createRequire = exports.getResourceUris = exports.getShortPath = exports.formatPath = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const common_1 = require("./common");
|
|
9
|
-
const getSuffixName_1 = require("./getSuffixName");
|
|
10
|
-
const formatPath = (pathStr = '') => pathStr.split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
11
|
-
exports.formatPath = formatPath;
|
|
12
|
-
const getShortPath = (projectMiniprogramPath, rootContext) => {
|
|
13
|
-
const suffix = (0, getSuffixName_1.getMlSuffixName)();
|
|
14
|
-
const reg = new RegExp(`.${suffix}$`, 'g');
|
|
15
|
-
projectMiniprogramPath = (0, common_1.toUnixPath)(projectMiniprogramPath);
|
|
16
|
-
projectMiniprogramPath = projectMiniprogramPath.endsWith('/')
|
|
17
|
-
? projectMiniprogramPath
|
|
18
|
-
: `${projectMiniprogramPath}/`;
|
|
19
|
-
return (0, common_1.toUnixPath)(rootContext).replace(reg, '').replace(projectMiniprogramPath, '');
|
|
20
|
-
};
|
|
21
|
-
exports.getShortPath = getShortPath;
|
|
22
|
-
/**
|
|
23
|
-
* 根据是否分包获取资源路径
|
|
24
|
-
*/
|
|
25
|
-
const getResourceUris = (options) => {
|
|
26
|
-
const resourceList = [];
|
|
27
|
-
const { appCssExist, enableLazyCodeLoading, subPackage } = options;
|
|
28
|
-
// sjs 无法识别是否引用 所以一律push
|
|
29
|
-
// 加载顺序 app.css 主包sjs 分包sjs 主包components.js 分包components.js
|
|
30
|
-
if (!subPackage) {
|
|
31
|
-
// 主包
|
|
32
|
-
appCssExist && resourceList.push(`app.css`);
|
|
33
|
-
resourceList.push('sjs.js');
|
|
34
|
-
!enableLazyCodeLoading && resourceList.push(`components.js`);
|
|
35
|
-
}
|
|
36
|
-
else if (subPackage === null || subPackage === void 0 ? void 0 : subPackage.independent) {
|
|
37
|
-
// 独立分包, 自己的components.js
|
|
38
|
-
resourceList.push(`${subPackage === null || subPackage === void 0 ? void 0 : subPackage.root}/sjs.js`);
|
|
39
|
-
!enableLazyCodeLoading && resourceList.push(`${subPackage === null || subPackage === void 0 ? void 0 : subPackage.root}/components.js`);
|
|
40
|
-
}
|
|
41
|
-
else if (subPackage) {
|
|
42
|
-
// 普通分包, 自己的components.js,主包components.js app.css
|
|
43
|
-
appCssExist && resourceList.push(`app.css`);
|
|
44
|
-
resourceList.push('sjs.js');
|
|
45
|
-
resourceList.push(`${subPackage === null || subPackage === void 0 ? void 0 : subPackage.root}/sjs.js`);
|
|
46
|
-
!enableLazyCodeLoading && resourceList.push(`components.js`);
|
|
47
|
-
!enableLazyCodeLoading && resourceList.push(`${subPackage === null || subPackage === void 0 ? void 0 : subPackage.root}/components.js`);
|
|
48
|
-
}
|
|
49
|
-
return resourceList;
|
|
50
|
-
};
|
|
51
|
-
exports.getResourceUris = getResourceUris;
|
|
52
|
-
/**
|
|
53
|
-
* @NOTE
|
|
54
|
-
* Create a request and handle the conversion of esModule modules
|
|
55
|
-
* */
|
|
56
|
-
function createRequire(modulePath) {
|
|
57
|
-
return `function() { var obj = require('${modulePath}'); return obj && obj.__esModule ? obj.default : obj; }`;
|
|
58
|
-
}
|
|
59
|
-
exports.createRequire = createRequire;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Root } from 'postcss';
|
|
2
|
-
interface IPostcssRpx2Vw {
|
|
3
|
-
outputUnit?: string;
|
|
4
|
-
baseWidth?: number;
|
|
5
|
-
unitPrecision?: number;
|
|
6
|
-
mediaQuery?: boolean;
|
|
7
|
-
}
|
|
8
|
-
declare const postcssRpx2Vw: ({ outputUnit, baseWidth, unitPrecision, mediaQuery, }: IPostcssRpx2Vw) => {
|
|
9
|
-
postcssPlugin: string;
|
|
10
|
-
Root: (root: Root) => void;
|
|
11
|
-
};
|
|
12
|
-
export default postcssRpx2Vw;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const postcss_1 = require("postcss");
|
|
4
|
-
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
5
|
-
const postcssRpx2Vw = ({ outputUnit = 'vw', baseWidth = 750, unitPrecision = 5, mediaQuery = false, }) => {
|
|
6
|
-
const replacement = (m, $1) => {
|
|
7
|
-
return (0, xhs_mp_compiler_utils_1.calcRpx2Vw)($1, baseWidth, unitPrecision, outputUnit);
|
|
8
|
-
};
|
|
9
|
-
return {
|
|
10
|
-
postcssPlugin: 'postcss-rpx-2-vw',
|
|
11
|
-
// https://astexplorer.net/#/2uBU1BLuJ1
|
|
12
|
-
Root: (root) => {
|
|
13
|
-
root.walkRules(rule => {
|
|
14
|
-
const rpxEntries = [];
|
|
15
|
-
rule.walkDecls(decl => {
|
|
16
|
-
if (!(0, xhs_mp_compiler_utils_1.isRpxValue)(decl.value))
|
|
17
|
-
return;
|
|
18
|
-
rpxEntries.push({ prop: decl.prop, value: decl.value });
|
|
19
|
-
decl.value = decl.value.replace(xhs_mp_compiler_utils_1.RPX_REGEX, replacement);
|
|
20
|
-
});
|
|
21
|
-
rpxEntries.forEach(decl => {
|
|
22
|
-
rule.append(new postcss_1.Declaration({ prop: '--ide-' + decl.prop, value: decl.value }));
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
if (mediaQuery) {
|
|
26
|
-
root.walkAtRules('media', rule => {
|
|
27
|
-
if (!(0, xhs_mp_compiler_utils_1.isRpxValue)(rule.params))
|
|
28
|
-
return;
|
|
29
|
-
rule.params = rule.params.replace(xhs_mp_compiler_utils_1.RPX_REGEX, replacement);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
exports.default = postcssRpx2Vw;
|
package/dist/utils/project.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export interface IZipFactory {
|
|
2
|
-
outputDir: string;
|
|
3
|
-
ignore: string[];
|
|
4
|
-
prefix: string;
|
|
5
|
-
inputDir: string;
|
|
6
|
-
type: "v0" | "v1" | "v2";
|
|
7
|
-
appendFile?: string[];
|
|
8
|
-
appendBuffer?: {
|
|
9
|
-
buffer: Buffer;
|
|
10
|
-
name: string;
|
|
11
|
-
}[];
|
|
12
|
-
meta: {
|
|
13
|
-
root: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export declare const checkSubPackagesLegality: ({ appJsonContent, rootPath, distDir }: {
|
|
17
|
-
appJsonContent: any;
|
|
18
|
-
rootPath: string;
|
|
19
|
-
distDir: string;
|
|
20
|
-
}) => Promise<any[]>;
|
|
21
|
-
export declare const zipFactory: ({ outputDir, ignore, prefix, inputDir, type, appendFile, appendBuffer, meta, }: IZipFactory) => Promise<{
|
|
22
|
-
type: "v2" | "v1" | "v0";
|
|
23
|
-
zipPath: string;
|
|
24
|
-
zipSize: number;
|
|
25
|
-
root: string;
|
|
26
|
-
originSize: number;
|
|
27
|
-
}>;
|
package/dist/utils/project.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.zipFactory = exports.checkSubPackagesLegality = void 0;
|
|
36
|
-
const path = __importStar(require("path"));
|
|
37
|
-
const fs = __importStar(require("fs-extra"));
|
|
38
|
-
const zip_1 = require("./zip");
|
|
39
|
-
const file_1 = require("./file");
|
|
40
|
-
const ignoreFiles = ['!node_modules'];
|
|
41
|
-
const _getFolderSize = (rootPath) => __awaiter(void 0, void 0, void 0, function* () { return yield (0, file_1.getFolderSize)([rootPath, ...ignoreFiles]); });
|
|
42
|
-
const getCheckSizeFlag = (rootPath) => {
|
|
43
|
-
const projectConfig = path.resolve(rootPath, 'project.config.json');
|
|
44
|
-
const content = fs.readJSONSync(projectConfig);
|
|
45
|
-
return content.skipCheckSize;
|
|
46
|
-
};
|
|
47
|
-
// const SUB_PACKAGE_MAX_SIZE = 2 * 1024 * 1024; // 2M
|
|
48
|
-
// const TOTAL_PACKAGE_MAX_SIZE = 20 * 1024 * 1024; // 20M
|
|
49
|
-
/* 整个小程序体积不能超过 20M。 */
|
|
50
|
-
const checkProjectSize = (rootPath, distDir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
51
|
-
const totalSize = yield _getFolderSize(distDir);
|
|
52
|
-
/* 微盟先暂时跳过整包体积校验 */
|
|
53
|
-
if (getCheckSizeFlag(rootPath) === true) {
|
|
54
|
-
return totalSize;
|
|
55
|
-
}
|
|
56
|
-
/* 跳过体积校验 */
|
|
57
|
-
// if (totalSize > TOTAL_PACKAGE_MAX_SIZE) {
|
|
58
|
-
// throw new Error(`源码包大小 ${fileSize(totalSize)} 超过 20MB 上限 `);
|
|
59
|
-
// }
|
|
60
|
-
return totalSize;
|
|
61
|
-
});
|
|
62
|
-
/* 校验subPagee的root */
|
|
63
|
-
const checkSubPackages = (_a) => __awaiter(void 0, [_a], void 0, function* ({ subPackages, distDir }) {
|
|
64
|
-
let subSize = 0;
|
|
65
|
-
const sizeInfo = [];
|
|
66
|
-
for (let i = 0; i < subPackages.length; i++) {
|
|
67
|
-
const item = subPackages[i];
|
|
68
|
-
const fullPath = path.resolve(distDir, item.root);
|
|
69
|
-
const size = yield _getFolderSize(fullPath);
|
|
70
|
-
/* 跳过体积校验 */
|
|
71
|
-
// if (size > SUB_PACKAGE_MAX_SIZE) {
|
|
72
|
-
// throw new Error(`分包 ${item.root} 大小 ${fileSize(size)} 超出 2MB 上限`);
|
|
73
|
-
// }
|
|
74
|
-
const info = {
|
|
75
|
-
originSize: size,
|
|
76
|
-
root: item.root
|
|
77
|
-
};
|
|
78
|
-
sizeInfo.push(info);
|
|
79
|
-
subSize += size;
|
|
80
|
-
}
|
|
81
|
-
return { subSize, sizeInfo };
|
|
82
|
-
});
|
|
83
|
-
/* 主包体积:项目移除分包之后的体积 */
|
|
84
|
-
const checkMainPackages = ({ totalSize, subPkgSize }) => {
|
|
85
|
-
const mainSize = totalSize - subPkgSize;
|
|
86
|
-
/* 跳过体积校验 */
|
|
87
|
-
// if (mainSize > SUB_PACKAGE_MAX_SIZE) {
|
|
88
|
-
// throw new Error(`主包大小 ${fileSize(mainSize)} 超出 2MB 上限`);
|
|
89
|
-
// }
|
|
90
|
-
const sizeInfo = {
|
|
91
|
-
originSize: mainSize,
|
|
92
|
-
root: '/'
|
|
93
|
-
};
|
|
94
|
-
return { mainSize, sizeInfo };
|
|
95
|
-
};
|
|
96
|
-
/* 校验preloadRule的预加载的包 */
|
|
97
|
-
const checkPreloadRule = (_b) => __awaiter(void 0, [_b], void 0, function* ({ preloadRule, subPackages, distDir }) {
|
|
98
|
-
for (const ruleKey in preloadRule) {
|
|
99
|
-
let useSize = 0;
|
|
100
|
-
const rulePackages = preloadRule[ruleKey];
|
|
101
|
-
const packages = rulePackages.packages;
|
|
102
|
-
for (let i = 0; i < packages.length; i++) {
|
|
103
|
-
const pkg = packages[i];
|
|
104
|
-
if (pkg === "__APP__") {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const _pathIten = subPackages.find((v) => pkg === v.name || pkg === v.root);
|
|
108
|
-
if (!_pathIten)
|
|
109
|
-
return;
|
|
110
|
-
const fullPath = path.resolve(distDir, _pathIten.root);
|
|
111
|
-
const size = yield _getFolderSize(fullPath);
|
|
112
|
-
useSize += size;
|
|
113
|
-
/* 跳过体积校验 */
|
|
114
|
-
// if (useSize > SUB_PACKAGE_MAX_SIZE) {
|
|
115
|
-
// throw new Error(
|
|
116
|
-
// `预加载 ${ruleKey} 包大小 ${fileSize(useSize)} 超出 2MB 上限`
|
|
117
|
-
// );
|
|
118
|
-
// }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
/* 校验子包体积 */
|
|
123
|
-
const checkSubPackagesLegality = (_c) => __awaiter(void 0, [_c], void 0, function* ({ appJsonContent, rootPath, distDir }) {
|
|
124
|
-
const subPackages = appJsonContent.subPackages || appJsonContent.subpackages;
|
|
125
|
-
const preloadRule = appJsonContent.preloadRule || {};
|
|
126
|
-
const totalSize = yield checkProjectSize(rootPath, distDir);
|
|
127
|
-
if (!subPackages || subPackages.length === 0) {
|
|
128
|
-
/* 未开启分包 */
|
|
129
|
-
/* 微盟先暂时跳过整包体积校验 */
|
|
130
|
-
if (getCheckSizeFlag(rootPath) === true) {
|
|
131
|
-
return [{ originSize: totalSize, root: '' }];
|
|
132
|
-
}
|
|
133
|
-
checkMainPackages({ totalSize, subPkgSize: 0 }); // 校验主包
|
|
134
|
-
return [{ originSize: totalSize, root: '' }];
|
|
135
|
-
}
|
|
136
|
-
const { subSize, sizeInfo } = yield checkSubPackages({ subPackages, distDir });
|
|
137
|
-
const { sizeInfo: mainSizeInfo } = checkMainPackages({ totalSize, subPkgSize: subSize });
|
|
138
|
-
yield checkPreloadRule({ preloadRule, subPackages, distDir });
|
|
139
|
-
return [mainSizeInfo, ...sizeInfo];
|
|
140
|
-
});
|
|
141
|
-
exports.checkSubPackagesLegality = checkSubPackagesLegality;
|
|
142
|
-
/* zip包的工厂函数 */
|
|
143
|
-
const zipFactory = (_d) => __awaiter(void 0, [_d], void 0, function* ({ outputDir, ignore, prefix, inputDir, type, appendFile = [], appendBuffer = [], meta, }) {
|
|
144
|
-
const zip = new zip_1.Zip({ outputDir });
|
|
145
|
-
/* 添加文件 */
|
|
146
|
-
appendFile.forEach((file) => {
|
|
147
|
-
zip.archive.file(file, {
|
|
148
|
-
name: path.basename(file),
|
|
149
|
-
prefix,
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
/* 添加文件buffer */
|
|
153
|
-
appendBuffer.forEach((item) => {
|
|
154
|
-
zip.archive.append(item.buffer, {
|
|
155
|
-
name: item.name,
|
|
156
|
-
prefix,
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
zip.archive.glob("**/*", { cwd: inputDir, ignore }, { prefix });
|
|
160
|
-
yield zip.finalize();
|
|
161
|
-
const stat = fs.statSync(outputDir);
|
|
162
|
-
return { type, zipPath: outputDir, zipSize: stat.size, root: meta.root, originSize: 0 };
|
|
163
|
-
});
|
|
164
|
-
exports.zipFactory = zipFactory;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getProjectConfig(projectPath: 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(projectPath) {
|
|
10
|
-
const projectJsonPath = path_1.default.join(projectPath, '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,35 +0,0 @@
|
|
|
1
|
-
declare const tagTransformMap: {
|
|
2
|
-
view: string;
|
|
3
|
-
text: string;
|
|
4
|
-
image: string;
|
|
5
|
-
input: string;
|
|
6
|
-
icon: string;
|
|
7
|
-
label: string;
|
|
8
|
-
radio: string;
|
|
9
|
-
'radio-group': string;
|
|
10
|
-
checkbox: string;
|
|
11
|
-
'checkbox-group': string;
|
|
12
|
-
switch: string;
|
|
13
|
-
textarea: string;
|
|
14
|
-
button: string;
|
|
15
|
-
swiper: string;
|
|
16
|
-
'swiper-item': string;
|
|
17
|
-
navigator: string;
|
|
18
|
-
slider: string;
|
|
19
|
-
progress: string;
|
|
20
|
-
'rich-text': string;
|
|
21
|
-
'mf-page': string;
|
|
22
|
-
'scroll-view': string;
|
|
23
|
-
picker: string;
|
|
24
|
-
'picker-view': string;
|
|
25
|
-
'picker-view-column': string;
|
|
26
|
-
form: string;
|
|
27
|
-
'web-view': string;
|
|
28
|
-
video: string;
|
|
29
|
-
map: string;
|
|
30
|
-
editor: string;
|
|
31
|
-
'movable-area': string;
|
|
32
|
-
'movable-view': string;
|
|
33
|
-
canvas: string;
|
|
34
|
-
};
|
|
35
|
-
export default tagTransformMap;
|