xhs-mp-compiler-cli 1.1.1 → 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 +11 -5
- 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 -7
- package/dist/config/constant.config.js +0 -10
- package/dist/dev-server/index.d.ts +0 -3
- package/dist/dev-server/index.js +0 -64
- 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/index.d.ts +0 -1
- package/dist/index.js +0 -5
- 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/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 -46
- 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 -2
- 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 -70
- 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/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/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 -5
- package/dist/utils/utils.js +0 -37
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;
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tagTransformMap = {
|
|
4
|
-
view: 'xhs-vue-view',
|
|
5
|
-
text: 'xhs-vue-text',
|
|
6
|
-
// block: 'span',
|
|
7
|
-
image: 'xhs-vue-image',
|
|
8
|
-
input: 'xhs-vue-input',
|
|
9
|
-
icon: 'xhs-vue-icon',
|
|
10
|
-
label: 'xhs-vue-label',
|
|
11
|
-
radio: 'xhs-vue-radio',
|
|
12
|
-
'radio-group': 'xhs-vue-radio-group',
|
|
13
|
-
checkbox: 'xhs-vue-checkbox',
|
|
14
|
-
'checkbox-group': 'xhs-vue-checkbox-group',
|
|
15
|
-
switch: 'xhs-vue-switch',
|
|
16
|
-
textarea: 'xhs-vue-textarea',
|
|
17
|
-
button: 'xhs-vue-button',
|
|
18
|
-
swiper: 'xhs-vue-swiper',
|
|
19
|
-
'swiper-item': 'xhs-vue-swiper-item',
|
|
20
|
-
navigator: 'xhs-vue-navigator',
|
|
21
|
-
slider: 'xhs-vue-slider',
|
|
22
|
-
progress: 'xhs-vue-progress',
|
|
23
|
-
'rich-text': 'xhs-vue-rich-text',
|
|
24
|
-
'mf-page': 'div',
|
|
25
|
-
'scroll-view': 'xhs-vue-scroll-view',
|
|
26
|
-
picker: 'xhs-vue-picker',
|
|
27
|
-
'picker-view': 'xhs-vue-picker-view',
|
|
28
|
-
'picker-view-column': 'xhs-vue-picker-view-column',
|
|
29
|
-
form: 'xhs-vue-form',
|
|
30
|
-
'web-view': 'xhs-vue-web-view',
|
|
31
|
-
video: 'xhs-vue-video',
|
|
32
|
-
map: 'xhs-vue-map',
|
|
33
|
-
editor: 'xhs-vue-editor',
|
|
34
|
-
'movable-area': 'xhs-vue-movable-area',
|
|
35
|
-
'movable-view': 'xhs-vue-movable-view',
|
|
36
|
-
canvas: 'xhs-vue-canvas'
|
|
37
|
-
};
|
|
38
|
-
exports.default = tagTransformMap;
|
package/dist/utils/utils.d.ts
DELETED
package/dist/utils/utils.js
DELETED
|
@@ -1,37 +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 path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const hasFile = filepath => {
|
|
10
|
-
try {
|
|
11
|
-
const stat = fs_1.default.statSync(filepath);
|
|
12
|
-
return stat.isFile();
|
|
13
|
-
}
|
|
14
|
-
catch (e) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const getTsconfigPath = config => {
|
|
19
|
-
let res = '';
|
|
20
|
-
// 查询距离最近的 tsconfig.json
|
|
21
|
-
if (config.projectPath) {
|
|
22
|
-
res = path_1.default.resolve(process.cwd(), config.projectPath, 'tsconfig.json');
|
|
23
|
-
if (hasFile(res)) {
|
|
24
|
-
return res;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// 查询 root 的 tsconfig.json
|
|
28
|
-
res = path_1.default.resolve(process.cwd(), 'tsconfig.json');
|
|
29
|
-
if (hasFile(res)) {
|
|
30
|
-
return res;
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
};
|
|
34
|
-
exports.default = {
|
|
35
|
-
hasFile,
|
|
36
|
-
getTsconfigPath,
|
|
37
|
-
};
|