xhs-mp-compiler-cli 2.0.3 → 2.0.4-beta.1
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/config/constant.config.d.ts +4 -1
- package/dist/config/constant.config.js +6 -2
- package/dist/packs/webpack/index.js +4 -3
- package/dist/presets/configs/minigame/assets/assetsEntryPlugin.js +3 -3
- package/dist/presets/configs/minigame/service/serviceChunkPlugin.js +4 -4
- package/dist/presets/configs/minigame/service/serviceEntryPlugin.js +3 -2
- package/dist/presets/configs/miniprogram/assets/index.js +20 -7
- package/dist/presets/configs/miniprogram/render/index.js +58 -29
- package/dist/presets/configs/miniprogram/render/sjsEntryPlugin.js +7 -7
- package/dist/presets/configs/miniprogram/render/sketch.d.ts +3 -0
- package/dist/presets/configs/miniprogram/render/sketch.js +45 -0
- package/dist/presets/loaders/mg-entry-loader.js +3 -3
- package/dist/presets/loaders/mini-style-loader.js +14 -60
- package/dist/presets/loaders/mp-entry-loader.js +49 -46
- package/dist/presets/loaders/string-loader.d.ts +0 -0
- package/dist/presets/loaders/string-loader.js +6 -0
- package/dist/presets/loaders/wxss-loader.js +63 -42
- package/dist/utils/common.d.ts +0 -4
- package/dist/utils/common.js +2 -18
- package/dist/utils/loader-utils.d.ts +0 -2
- package/dist/utils/loader-utils.js +2 -20
- package/dist/utils/postcssRpx2Vw.d.ts +2 -1
- package/dist/utils/postcssRpx2Vw.js +7 -4
- package/package.json +16 -22
- package/dist/utils/css.d.ts +0 -2
- package/dist/utils/css.js +0 -49
|
@@ -35,7 +35,6 @@ export declare const PROD_TARGETS: {
|
|
|
35
35
|
ios: string;
|
|
36
36
|
};
|
|
37
37
|
export declare const ENTRY_CSS_NAME = "app";
|
|
38
|
-
export declare const FULL_PKG = "xhs-full";
|
|
39
38
|
export declare const MAIN_PKG = "xhs-main";
|
|
40
39
|
export declare const SUB_PKG = "xhs-sub";
|
|
41
40
|
export declare const BUILD_REASON: {
|
|
@@ -49,3 +48,7 @@ export declare const PACK_MODE: {
|
|
|
49
48
|
MPPACK: string;
|
|
50
49
|
WEBPACK: string;
|
|
51
50
|
};
|
|
51
|
+
export declare const CSS_REG: RegExp;
|
|
52
|
+
export declare const SKETCH_CSS_REG: RegExp;
|
|
53
|
+
export declare const ML_REG: RegExp;
|
|
54
|
+
export declare const SKETCH_ML_REG: RegExp;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.PACK_MODE = exports.ASSETS_EXTS = exports.BUILD_REASON = exports.SUB_PKG = exports.MAIN_PKG = exports.
|
|
12
|
+
exports.SKETCH_ML_REG = exports.ML_REG = exports.SKETCH_CSS_REG = exports.CSS_REG = exports.PACK_MODE = exports.ASSETS_EXTS = exports.BUILD_REASON = exports.SUB_PKG = exports.MAIN_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
13
|
exports.MAIN_PKG_ROOT = 'xhs-main';
|
|
14
14
|
exports.COMPILER_TYPE = {
|
|
15
15
|
dev: 'dev',
|
|
@@ -47,7 +47,6 @@
|
|
|
47
47
|
ios: '10'
|
|
48
48
|
};
|
|
49
49
|
exports.ENTRY_CSS_NAME = 'app';
|
|
50
|
-
exports.FULL_PKG = 'xhs-full';
|
|
51
50
|
exports.MAIN_PKG = 'xhs-main';
|
|
52
51
|
exports.SUB_PKG = 'xhs-sub';
|
|
53
52
|
exports.BUILD_REASON = {
|
|
@@ -79,4 +78,9 @@
|
|
|
79
78
|
MPPACK: 'mp-pack',
|
|
80
79
|
WEBPACK: 'webpack'
|
|
81
80
|
};
|
|
81
|
+
// loader 规则使用下面变量
|
|
82
|
+
exports.CSS_REG = /(?<!\.skeleton)\.(wxss|css)$/;
|
|
83
|
+
exports.SKETCH_CSS_REG = /\.skeleton\.(wxss|css)$/;
|
|
84
|
+
exports.ML_REG = /(?<!\.skeleton)\.(wx|xhs)ml$/;
|
|
85
|
+
exports.SKETCH_ML_REG = /\.skeleton\.(wx|xhs)ml$/;
|
|
82
86
|
});
|
|
@@ -7,7 +7,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
if (v !== undefined) module.exports = v;
|
|
8
8
|
}
|
|
9
9
|
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports", "path", "fs-extra", "../../utils/projectConfig", "../../utils/common", "../../presets", "xhs-mp-project", "xhs-mp-pack", "./webpack", "../../utils/apm", "../../config/constant.config"], factory);
|
|
10
|
+
define(["require", "exports", "path", "fs-extra", "../../utils/projectConfig", "../../utils/common", "../../presets", "xhs-mp-project", "xhs-mp-pack", "./webpack", "../../utils/apm", "../../config/constant.config", "xhs-mp-compiler-utils"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
@@ -23,6 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
const webpack_1 = require("./webpack");
|
|
24
24
|
const apm_1 = require("../../utils/apm");
|
|
25
25
|
const constant_config_1 = require("../../config/constant.config");
|
|
26
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
26
27
|
// 防御编程
|
|
27
28
|
const handleVersion = (startConfig) => {
|
|
28
29
|
let { action, enableV1 = true, enableV2 = false, enableVDom = false } = startConfig;
|
|
@@ -58,8 +59,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
58
59
|
let miniprogramDir = path_1.default.join(projectPath, projectJson.miniprogramRoot || '');
|
|
59
60
|
miniprogramDir = miniprogramDir.endsWith('/') ? miniprogramDir.slice(0, -1) : miniprogramDir;
|
|
60
61
|
const config = {
|
|
61
|
-
projectPath: (0,
|
|
62
|
-
miniprogramDir: (0,
|
|
62
|
+
projectPath: (0, xhs_mp_compiler_utils_1.toUnixPath)(projectPath),
|
|
63
|
+
miniprogramDir: (0, xhs_mp_compiler_utils_1.toUnixPath)(miniprogramDir).replace(/\/+$/, ''),
|
|
63
64
|
distDir,
|
|
64
65
|
action,
|
|
65
66
|
tsConfigPath: tsConfigPath || (0, common_1.getTsConfigPath)(projectPath),
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../../../packs", "lodash", "
|
|
7
|
+
define(["require", "exports", "../../../../packs", "lodash", "xhs-mp-project", "xhs-mp-compiler-utils"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const packs_1 = require("../../../../packs");
|
|
13
13
|
const lodash_1 = require("lodash");
|
|
14
|
-
const common_1 = require("../../../../utils/common");
|
|
15
14
|
const xhs_mp_project_1 = require("xhs-mp-project");
|
|
15
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
16
16
|
class MpEntryPlugin {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
this.options = options;
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
assets['v1/app.json'] = appJsonSource;
|
|
42
42
|
for (const subpackage of appJSON.subPackages) {
|
|
43
43
|
if (subpackage.independent) {
|
|
44
|
-
assets[(0,
|
|
44
|
+
assets[(0, xhs_mp_compiler_utils_1.unixJoin)("v1", subpackage.dirname, "app.json")] = appJsonSource;
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
return assets;
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "xhs-mp-compiler-utils", "../../../../packs", "../../../../packs"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
12
13
|
const packs_1 = require("../../../../packs");
|
|
13
14
|
const packs_2 = require("../../../../packs");
|
|
14
|
-
const common_1 = require("../../../../utils/common");
|
|
15
15
|
class ServiceChunkPlugin {
|
|
16
16
|
constructor(options) {
|
|
17
17
|
this.options = options;
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
const services = [
|
|
46
46
|
"v1/service.js",
|
|
47
47
|
// @ts-ignore
|
|
48
|
-
...(_a = project.appJSON.subPackages) === null || _a === void 0 ? void 0 : _a.map(i => (0,
|
|
48
|
+
...(_a = project.appJSON.subPackages) === null || _a === void 0 ? void 0 : _a.map(i => (0, xhs_mp_compiler_utils_1.unixJoin)('v1', `${i.entry}.js`))
|
|
49
49
|
];
|
|
50
50
|
services.forEach(servicePath => {
|
|
51
51
|
if (servicePath in assets) {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
const independent = (_a = project.appJSON.subPackages) === null || _a === void 0 ? void 0 : _a.filter(sub => sub.independent);
|
|
64
64
|
const services = [
|
|
65
65
|
"v1/service.js",
|
|
66
|
-
...independent === null || independent === void 0 ? void 0 : independent.map(i => (0,
|
|
66
|
+
...independent === null || independent === void 0 ? void 0 : independent.map(i => (0, xhs_mp_compiler_utils_1.unixJoin)('v1', `${i.entry}.js`))
|
|
67
67
|
];
|
|
68
68
|
services.forEach(servicePath => {
|
|
69
69
|
var _a;
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../../../../packs", "../../../../utils/common"], factory);
|
|
7
|
+
define(["require", "exports", "../../../../packs", "../../../../utils/common", "xhs-mp-compiler-utils"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const packs_1 = require("../../../../packs");
|
|
13
13
|
const common_1 = require("../../../../utils/common");
|
|
14
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
14
15
|
class ServiceEntryPlugin {
|
|
15
16
|
constructor(options) {
|
|
16
17
|
this.options = options;
|
|
@@ -23,7 +24,7 @@
|
|
|
23
24
|
const subPackages = appJSON.subPackages || [];
|
|
24
25
|
this.makeUmdEntry(compiler, 'v1/service.js', `mg-entry-loader?entry=${common_1.DEFAULT_ENTRY}!`, `XHS_SERVICE_${common_1.DEFAULT_ENTRY}`);
|
|
25
26
|
for (const { entry } of subPackages) {
|
|
26
|
-
this.makeUmdEntry(compiler, (0,
|
|
27
|
+
this.makeUmdEntry(compiler, (0, xhs_mp_compiler_utils_1.unixJoin)('v1', `${entry}.js`), `mg-entry-loader?entry=${entry}!`, `XHS_SERVICE_${entry}`);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
makeUmdEntry(compiler, filename, url, libraryName) {
|
|
@@ -7,13 +7,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
if (v !== undefined) module.exports = v;
|
|
8
8
|
}
|
|
9
9
|
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports", "
|
|
10
|
+
define(["require", "exports", "xhs-mp-compiler-utils", "./assetsEntryPlugin", "../../../../config/constant.config", "../../../plugins/InjectorPlugin", "path", "../../../../utils/cache"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.presetAssets = exports.getAssetsEntry = void 0;
|
|
16
|
-
const css_1 = __importDefault(require("../../../../utils/css"));
|
|
17
16
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
18
17
|
const assetsEntryPlugin_1 = __importDefault(require("./assetsEntryPlugin"));
|
|
19
18
|
const constant_config_1 = require("../../../../config/constant.config");
|
|
@@ -28,17 +27,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
27
|
};
|
|
29
28
|
exports.getAssetsEntry = getAssetsEntry;
|
|
30
29
|
const presetAssets = (chain, options) => {
|
|
31
|
-
const { packSetting
|
|
30
|
+
const { packSetting } = options;
|
|
32
31
|
const { distDir, cacheDirectory } = packSetting;
|
|
33
32
|
const absCacheDirectory = path_1.default.join(cacheDirectory, 'assets');
|
|
34
|
-
const cssReg = new RegExp(`.${(0, xhs_mp_compiler_utils_1.getCssSuffixName)()}$`);
|
|
35
33
|
chain.merge(Object.assign(Object.assign({ output: {
|
|
36
34
|
path: distDir
|
|
37
35
|
} }, (0, cache_1.getCacheConfig)(absCacheDirectory, options)), { module: {
|
|
38
36
|
rule: {
|
|
39
|
-
|
|
40
|
-
test:
|
|
41
|
-
use:
|
|
37
|
+
style: {
|
|
38
|
+
test: constant_config_1.CSS_REG,
|
|
39
|
+
use: {
|
|
40
|
+
"mini-style-loader": {
|
|
41
|
+
loader: "mini-style-loader",
|
|
42
|
+
options: {
|
|
43
|
+
// app.css 独立加载
|
|
44
|
+
independentFile: true,
|
|
45
|
+
emitDirs: [
|
|
46
|
+
packSetting.enableV1 && 'v1',
|
|
47
|
+
packSetting.enableV2 && 'v2',
|
|
48
|
+
].filter(Boolean),
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"wxss-loader": {
|
|
52
|
+
loader: "wxss-loader",
|
|
53
|
+
}
|
|
54
|
+
}
|
|
42
55
|
}
|
|
43
56
|
}
|
|
44
57
|
} }));
|
|
@@ -7,35 +7,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
if (v !== undefined) module.exports = v;
|
|
8
8
|
}
|
|
9
9
|
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports", "
|
|
10
|
+
define(["require", "exports", "path", "./sjsEntryPlugin", "./render", "./component", "./sketch", "./renderChunkPlugin", "../../../../types", "../../../plugins/InjectorPlugin", "../../../plugins/SourceMapDevToolPlugin", "../../../../utils/cache", "../../../../config/constant.config"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.presetRender = exports.getRenderEntry = void 0;
|
|
16
|
-
const
|
|
17
|
-
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
18
17
|
const sjsEntryPlugin_1 = __importDefault(require("./sjsEntryPlugin"));
|
|
19
18
|
const render_1 = require("./render");
|
|
20
19
|
const component_1 = require("./component");
|
|
20
|
+
const sketch_1 = require("./sketch");
|
|
21
21
|
const renderChunkPlugin_1 = __importDefault(require("./renderChunkPlugin"));
|
|
22
22
|
const types_1 = require("../../../../types");
|
|
23
23
|
const InjectorPlugin_1 = require("../../../plugins/InjectorPlugin");
|
|
24
24
|
const SourceMapDevToolPlugin_1 = require("../../../plugins/SourceMapDevToolPlugin");
|
|
25
25
|
const cache_1 = require("../../../../utils/cache");
|
|
26
|
-
const
|
|
26
|
+
const constant_config_1 = require("../../../../config/constant.config");
|
|
27
27
|
const getRenderEntry = (options) => () => {
|
|
28
|
-
const entries = Object.assign(Object.assign({}, (0, render_1.getRenderEntry)(options)), (0, component_1.getComponentEntry)(options));
|
|
28
|
+
const entries = Object.assign(Object.assign(Object.assign({}, (0, render_1.getRenderEntry)(options)), (0, component_1.getComponentEntry)(options)), (0, sketch_1.getSketchEntry)(options));
|
|
29
29
|
return entries;
|
|
30
30
|
};
|
|
31
31
|
exports.getRenderEntry = getRenderEntry;
|
|
32
32
|
const presetRender = (chain, options) => {
|
|
33
33
|
const { packSetting } = options;
|
|
34
34
|
const { enableVDom, env, distDir, cacheDirectory, enableSourcemap, appendSourcemapComment } = packSetting;
|
|
35
|
-
const mlReg = new RegExp(`.${(0, xhs_mp_compiler_utils_1.getMlSuffixName)()}$`);
|
|
36
|
-
const cssReg = new RegExp(`.${(0, xhs_mp_compiler_utils_1.getCssSuffixName)()}$`);
|
|
37
35
|
const isProd = env === types_1.ENV.production;
|
|
38
36
|
const absCacheDirectory = path_1.default.join(cacheDirectory, 'render');
|
|
37
|
+
const transfomLoader = isProd ?
|
|
38
|
+
{
|
|
39
|
+
'swc-loader': {
|
|
40
|
+
loader: require.resolve('swc-loader'),
|
|
41
|
+
options: {
|
|
42
|
+
jsc: {
|
|
43
|
+
// ?. ?? 运算符号从 es2020支持
|
|
44
|
+
target: 'es2019',
|
|
45
|
+
externalHelpers: false
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
} : {};
|
|
39
50
|
chain.merge(Object.assign(Object.assign({ externals: { vue: 'vue' }, output: {
|
|
40
51
|
path: distDir,
|
|
41
52
|
globalObject: 'globalThis',
|
|
@@ -44,34 +55,52 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
55
|
} }, (0, cache_1.getCacheConfig)(absCacheDirectory, options)), { module: {
|
|
45
56
|
rule: {
|
|
46
57
|
ml: {
|
|
47
|
-
test:
|
|
48
|
-
use: Object.assign(Object.assign({},
|
|
49
|
-
{
|
|
50
|
-
'swc-loader': {
|
|
51
|
-
loader: require.resolve('swc-loader'),
|
|
52
|
-
options: {
|
|
53
|
-
jsc: {
|
|
54
|
-
// ?. ?? 运算符号从 es2020支持
|
|
55
|
-
target: 'es2019',
|
|
56
|
-
externalHelpers: false
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} : {})), { 'ml-loader': {
|
|
58
|
+
test: constant_config_1.ML_REG,
|
|
59
|
+
use: Object.assign(Object.assign({}, transfomLoader), { 'ml-loader': {
|
|
61
60
|
loader: require.resolve('xhs-mp-ml-loader'),
|
|
62
61
|
options: {
|
|
63
62
|
removeComentNode: isProd,
|
|
64
|
-
vdom: enableVDom,
|
|
65
63
|
},
|
|
66
64
|
} }),
|
|
67
65
|
},
|
|
68
|
-
|
|
69
|
-
test:
|
|
70
|
-
use: (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
sketchMl: {
|
|
67
|
+
test: constant_config_1.SKETCH_ML_REG,
|
|
68
|
+
use: Object.assign(Object.assign({}, transfomLoader), { 'sketch-loader': {
|
|
69
|
+
loader: require.resolve('xhs-mp-sketch-loader'),
|
|
70
|
+
options: {
|
|
71
|
+
removeComentNode: isProd,
|
|
72
|
+
},
|
|
73
|
+
} }),
|
|
74
|
+
},
|
|
75
|
+
style: {
|
|
76
|
+
test: constant_config_1.CSS_REG,
|
|
77
|
+
use: {
|
|
78
|
+
"mini-style-loader": {
|
|
79
|
+
loader: "mini-style-loader",
|
|
80
|
+
options: {
|
|
81
|
+
// vdom 模式下 页面或者组件 css 独立加载
|
|
82
|
+
independentFile: enableVDom,
|
|
83
|
+
emitDirs: [
|
|
84
|
+
packSetting.enableV1 && 'v1',
|
|
85
|
+
packSetting.enableV2 && 'v2',
|
|
86
|
+
].filter(Boolean),
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"wxss-loader": {
|
|
90
|
+
loader: "wxss-loader",
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
sketchStyle: {
|
|
95
|
+
test: constant_config_1.SKETCH_CSS_REG,
|
|
96
|
+
use: {
|
|
97
|
+
"string-loader": {
|
|
98
|
+
loader: "string-loader"
|
|
99
|
+
},
|
|
100
|
+
"wxss-loader": {
|
|
101
|
+
loader: "wxss-loader",
|
|
102
|
+
}
|
|
103
|
+
}
|
|
75
104
|
},
|
|
76
105
|
},
|
|
77
106
|
} }));
|
|
@@ -30,7 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
if (v !== undefined) module.exports = v;
|
|
31
31
|
}
|
|
32
32
|
else if (typeof define === "function" && define.amd) {
|
|
33
|
-
define(["require", "exports", "fs-extra", "glob", "path", "../../../../packs", "xhs-mp-sjs-loader", "
|
|
33
|
+
define(["require", "exports", "fs-extra", "glob", "path", "../../../../packs", "xhs-mp-sjs-loader", "xhs-mp-compiler-utils"], factory);
|
|
34
34
|
}
|
|
35
35
|
})(function (require, exports) {
|
|
36
36
|
"use strict";
|
|
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
const path_1 = __importDefault(require("path"));
|
|
41
41
|
const packs_1 = require("../../../../packs");
|
|
42
42
|
const xhs_mp_sjs_loader_1 = __importStar(require("xhs-mp-sjs-loader"));
|
|
43
|
-
const
|
|
43
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
44
44
|
/**
|
|
45
45
|
* @NOTE 分包中使用 SJS 的规则
|
|
46
46
|
*
|
|
@@ -102,7 +102,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
102
102
|
.concat(glob_1.default.sync('**/*.wxs', { cwd: miniprogramDir }));
|
|
103
103
|
relativePaths.forEach(relativePath => {
|
|
104
104
|
var _a;
|
|
105
|
-
const sjsAbsPath = (0,
|
|
105
|
+
const sjsAbsPath = (0, xhs_mp_compiler_utils_1.unixJoin)(miniprogramDir, relativePath);
|
|
106
106
|
// 如果是主包内的文件
|
|
107
107
|
if (this.isFileInMainPkg(relativePath)) {
|
|
108
108
|
this.mainpkgPaths.push(sjsAbsPath);
|
|
@@ -142,7 +142,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
142
142
|
}
|
|
143
143
|
let sjsAbsPath = '';
|
|
144
144
|
if (/\.(sjs|wxs)$/.test(sjsPath)) {
|
|
145
|
-
sjsAbsPath = (0,
|
|
145
|
+
sjsAbsPath = (0, xhs_mp_compiler_utils_1.toUnixPath)(sjsPath);
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
148
|
this.emitError(this.generateMessage(`文件后缀不正确 ${sjsPath}`));
|
|
@@ -150,8 +150,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
150
150
|
const content = fs_extra_1.default.readFileSync(sjsAbsPath, 'utf8');
|
|
151
151
|
try {
|
|
152
152
|
const result = xhs_mp_sjs_loader_1.default.call(compilation, content, requirePath => {
|
|
153
|
-
const realPath = (0,
|
|
154
|
-
const relativePath = (0,
|
|
153
|
+
const realPath = (0, xhs_mp_compiler_utils_1.unixResolve)(path_1.default.dirname(sjsAbsPath), requirePath);
|
|
154
|
+
const relativePath = (0, xhs_mp_compiler_utils_1.getShortPath)(project.miniprogramDir, realPath);
|
|
155
155
|
/**
|
|
156
156
|
* 不是当前分包的 sjs 文件不处理
|
|
157
157
|
*/
|
|
@@ -172,7 +172,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
172
172
|
if ((_a = result.errors) === null || _a === void 0 ? void 0 : _a.length) {
|
|
173
173
|
this.emitError(this.generateMessage(result.errors.map(i => i.message).join("\n"), sjsAbsPath));
|
|
174
174
|
}
|
|
175
|
-
const moduleName = (0,
|
|
175
|
+
const moduleName = (0, xhs_mp_compiler_utils_1.getShortPath)(project.miniprogramDir, sjsAbsPath);
|
|
176
176
|
// 老版本兼容代码
|
|
177
177
|
sjsModules.push(`"${moduleName}": ${JSON.stringify(result.legacyCode)}`);
|
|
178
178
|
// 模块化代码
|
|
@@ -0,0 +1,45 @@
|
|
|
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", "xhs-mp-pack"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getSketchEntry = void 0;
|
|
13
|
+
const xhs_mp_pack_1 = require("xhs-mp-pack");
|
|
14
|
+
const getSketchEntry = (options) => {
|
|
15
|
+
const entries = {};
|
|
16
|
+
const { packSetting } = options;
|
|
17
|
+
if (packSetting.enableV2) {
|
|
18
|
+
appendSketchEntry(options, entries, 'v2');
|
|
19
|
+
}
|
|
20
|
+
if (packSetting.enableV1) {
|
|
21
|
+
appendSketchEntry(options, entries, 'v1');
|
|
22
|
+
}
|
|
23
|
+
return entries;
|
|
24
|
+
};
|
|
25
|
+
exports.getSketchEntry = getSketchEntry;
|
|
26
|
+
const appendSketchEntry = (options, entries, mode) => {
|
|
27
|
+
const { project, packSetting } = options;
|
|
28
|
+
const { mainPkg, subPkgs } = packSetting.getCompilePkgsForEntries();
|
|
29
|
+
if (mainPkg) {
|
|
30
|
+
const pages = project.getPages();
|
|
31
|
+
for (const { skeleton } of pages) {
|
|
32
|
+
if (skeleton === null || skeleton === void 0 ? void 0 : skeleton.path) {
|
|
33
|
+
entries[`${mode}/${skeleton === null || skeleton === void 0 ? void 0 : skeleton.path}`] = `mp-entry-loader?type=sketch&mode=${mode}&pkg=${xhs_mp_pack_1.CONSTANTS.MAIN_PKG}&path=${skeleton === null || skeleton === void 0 ? void 0 : skeleton.path}!`;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
for (const { pages, root } of subPkgs) {
|
|
38
|
+
for (const { skeleton } of pages) {
|
|
39
|
+
if (skeleton === null || skeleton === void 0 ? void 0 : skeleton.path) {
|
|
40
|
+
entries[`${mode}/${skeleton === null || skeleton === void 0 ? void 0 : skeleton.path}`] = `mp-entry-loader?type=sketch&mode=${mode}&pkg=${xhs_mp_pack_1.CONSTANTS.SUB_PKG}&root=${root}&path=${skeleton === null || skeleton === void 0 ? void 0 : skeleton.path}!`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
@@ -7,20 +7,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
if (v !== undefined) module.exports = v;
|
|
8
8
|
}
|
|
9
9
|
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports", "fs-extra", "
|
|
10
|
+
define(["require", "exports", "fs-extra", "xhs-mp-project", "xhs-mp-compiler-utils"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
16
|
-
const common_1 = require("../../utils/common");
|
|
17
16
|
const xhs_mp_project_1 = require("xhs-mp-project");
|
|
17
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
18
18
|
function entryLoader() {
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
const { appJSON, projectPath } = this._compiler.project;
|
|
21
21
|
const { entry } = this.getOptions();
|
|
22
22
|
const addAppJs = () => {
|
|
23
|
-
const absolutePath = (0,
|
|
23
|
+
const absolutePath = (0, xhs_mp_compiler_utils_1.unixJoin)(projectPath, entry);
|
|
24
24
|
if (fs_extra_1.default.existsSync(`${absolutePath}.js`)) {
|
|
25
25
|
return `require('${absolutePath}.js')`;
|
|
26
26
|
}
|
|
@@ -1,65 +1,32 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
11
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
12
|
-
};
|
|
13
1
|
(function (factory) {
|
|
14
2
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
15
3
|
var v = factory(require, exports);
|
|
16
4
|
if (v !== undefined) module.exports = v;
|
|
17
5
|
}
|
|
18
6
|
else if (typeof define === "function" && define.amd) {
|
|
19
|
-
define(["require", "exports", "
|
|
7
|
+
define(["require", "exports", "xhs-mp-compiler-utils", "../../packs", "../../config/constant.config"], factory);
|
|
20
8
|
}
|
|
21
9
|
})(function (require, exports) {
|
|
22
10
|
"use strict";
|
|
23
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
24
13
|
const packs_1 = require("../../packs");
|
|
25
|
-
const
|
|
26
|
-
const common_1 = require("../../utils/common");
|
|
27
|
-
const CSS_MINIMIZER_OPTIONS = {
|
|
28
|
-
preset: ['default', { normalizeUrl: false, calc: false }]
|
|
29
|
-
};
|
|
30
|
-
const minify = (source, name) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
const postcssOptions = {
|
|
33
|
-
to: name,
|
|
34
|
-
from: name
|
|
35
|
-
};
|
|
36
|
-
try {
|
|
37
|
-
const result = yield cssnano_1.default.process(source, postcssOptions, CSS_MINIMIZER_OPTIONS);
|
|
38
|
-
return {
|
|
39
|
-
code: result.css,
|
|
40
|
-
warnings: (_b = (_a = result.warnings()) === null || _a === void 0 ? void 0 : _a.map) === null || _b === void 0 ? void 0 : _b.call(_a, i => i.toString())
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
return {
|
|
45
|
-
code: source
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
});
|
|
14
|
+
const constant_config_1 = require("../../config/constant.config");
|
|
49
15
|
function miniStyleLoader(source) {
|
|
50
16
|
var _a;
|
|
51
17
|
const callback = this.async();
|
|
52
18
|
const { resourcePath } = this;
|
|
53
|
-
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const { project } = this._compiler;
|
|
21
|
+
const { independentFile, emitDirs = [] } = this.getOptions();
|
|
54
22
|
const { miniprogramDir } = project;
|
|
55
|
-
const
|
|
56
|
-
const shortPath = (0, common_1.getShortPath)(miniprogramDir, resourcePath).replace(/\.wxss$/, '.css');
|
|
23
|
+
const shortPath = (0, xhs_mp_compiler_utils_1.getShortPath)(miniprogramDir, resourcePath).replace(constant_config_1.CSS_REG, '.css');
|
|
57
24
|
source = (_a = source === null || source === void 0 ? void 0 : source.trim) === null || _a === void 0 ? void 0 : _a.call(source);
|
|
58
25
|
const emitFiles = (code) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
26
|
+
if ((independentFile) && code) {
|
|
27
|
+
emitDirs.forEach((dir) => {
|
|
28
|
+
this.emitFile(`${dir}/${shortPath}`, code);
|
|
29
|
+
});
|
|
63
30
|
}
|
|
64
31
|
};
|
|
65
32
|
const result = (code) => {
|
|
@@ -67,7 +34,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
67
34
|
return `export default void 0;`;
|
|
68
35
|
}
|
|
69
36
|
// 判断浏览器环境,注入css添加逻辑
|
|
70
|
-
if (
|
|
37
|
+
if (independentFile) {
|
|
71
38
|
return new packs_1.RawSource(`globalThis.__XHS_ADD_LINK(${JSON.stringify(shortPath)});` +
|
|
72
39
|
`export default ${JSON.stringify(shortPath)};`).source();
|
|
73
40
|
}
|
|
@@ -76,21 +43,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
76
43
|
`export default ${JSON.stringify(shortPath)};`).source();
|
|
77
44
|
}
|
|
78
45
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
minify(source, shortPath)
|
|
82
|
-
.then(({ code, warnings }) => {
|
|
83
|
-
emitFiles(code);
|
|
84
|
-
callback(null, result(code));
|
|
85
|
-
})
|
|
86
|
-
.catch(error => {
|
|
87
|
-
callback(error);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
emitFiles(source);
|
|
92
|
-
callback(null, result(source));
|
|
93
|
-
}
|
|
46
|
+
emitFiles(source);
|
|
47
|
+
callback(null, result(source));
|
|
94
48
|
}
|
|
95
49
|
module.exports = miniStyleLoader;
|
|
96
50
|
});
|
|
@@ -27,13 +27,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
if (v !== undefined) module.exports = v;
|
|
28
28
|
}
|
|
29
29
|
else if (typeof define === "function" && define.amd) {
|
|
30
|
-
define(["require", "exports", "fs-extra", "
|
|
30
|
+
define(["require", "exports", "fs-extra", "xhs-mp-pack", "../../utils/loader-utils", "xhs-mp-compiler-utils"], factory);
|
|
31
31
|
}
|
|
32
32
|
})(function (require, exports) {
|
|
33
33
|
"use strict";
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
const fs_extra_1 = __importStar(require("fs-extra"));
|
|
36
|
-
const path_1 = __importStar(require("path"));
|
|
37
36
|
const xhs_mp_pack_1 = require("xhs-mp-pack");
|
|
38
37
|
const loader_utils_1 = require("../../utils/loader-utils");
|
|
39
38
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
@@ -53,15 +52,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
53
52
|
if (mode === 'v2') {
|
|
54
53
|
return `
|
|
55
54
|
;(globalThis['${name}'] || (globalThis['${name}'] = { default: {} }))
|
|
56
|
-
;globalThis['${name}'].default['${compPath}'] = () => require('${(0,
|
|
55
|
+
;globalThis['${name}'].default['${compPath}'] = () => require('${(0, xhs_mp_compiler_utils_1.unixJoin)(projectMiniprogramPath, `${compPath}.${(0, xhs_mp_compiler_utils_1.getMlSuffixName)()}`)}')
|
|
57
56
|
`;
|
|
58
57
|
}
|
|
59
|
-
// v1
|
|
58
|
+
// v1
|
|
60
59
|
Object.keys(componentsMap).forEach(compPath => {
|
|
61
|
-
const push = () => entries.push(`;globalThis['${name}'].default['${compPath}'] = () => require('${(0,
|
|
62
|
-
if (pkg === xhs_mp_pack_1.CONSTANTS.FULL_PKG) {
|
|
63
|
-
push();
|
|
64
|
-
}
|
|
60
|
+
const push = () => entries.push(`;globalThis['${name}'].default['${compPath}'] = () => require('${(0, xhs_mp_compiler_utils_1.unixJoin)(projectMiniprogramPath, `${compPath}.${(0, xhs_mp_compiler_utils_1.getMlSuffixName)()}`)}')`);
|
|
65
61
|
if (pkg === xhs_mp_pack_1.CONSTANTS.MAIN_PKG && project.isFileInMainPkg(compPath)) {
|
|
66
62
|
push();
|
|
67
63
|
}
|
|
@@ -76,16 +72,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
76
72
|
}
|
|
77
73
|
const genRenderLoaderScript = (project, context, opts) => {
|
|
78
74
|
const { projectMiniprogramPath, appJSON, jsonDependencies } = project;
|
|
79
|
-
const {
|
|
80
|
-
const isFull = pkg === 'full';
|
|
75
|
+
const { mode } = opts;
|
|
81
76
|
for (const file of jsonDependencies) {
|
|
82
77
|
context.addDependency(file);
|
|
83
78
|
}
|
|
84
|
-
const appCssPath = (0,
|
|
79
|
+
const appCssPath = (0, xhs_mp_compiler_utils_1.unixResolve)(projectMiniprogramPath, 'app.css');
|
|
85
80
|
const appCssExist = (0, fs_extra_1.existsSync)(appCssPath);
|
|
86
|
-
const resourcePath = (0,
|
|
87
|
-
const
|
|
88
|
-
const subPackage = (appJSON.subPackages || []).find(subPack => !!subPack.pages.find(page => page.path ===
|
|
81
|
+
const resourcePath = (0, xhs_mp_compiler_utils_1.toUnixPath)(context.resourcePath);
|
|
82
|
+
const pagePath = (0, xhs_mp_compiler_utils_1.getShortPath)(projectMiniprogramPath, resourcePath);
|
|
83
|
+
const subPackage = (appJSON.subPackages || []).find(subPack => !!subPack.pages.find(page => page.path === pagePath));
|
|
89
84
|
const enableLazyCodeLoading = mode === 'v2';
|
|
90
85
|
// 资源文件
|
|
91
86
|
const resources = (0, loader_utils_1.getResourceUris)({
|
|
@@ -96,7 +91,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
96
91
|
// 开启了按需注入,注入依赖组件
|
|
97
92
|
if (enableLazyCodeLoading) {
|
|
98
93
|
const isIndependent = (subPackage === null || subPackage === void 0 ? void 0 : subPackage.independent) || false;
|
|
99
|
-
const dependsTree = project.getPageDependComponentPaths(
|
|
94
|
+
const dependsTree = project.getPageDependComponentPaths(pagePath, isIndependent);
|
|
100
95
|
const subPackagesPrefix = (appJSON.subPackages || []).map(sub => sub.root);
|
|
101
96
|
const depends = [];
|
|
102
97
|
for (let i = 0; i < dependsTree.length; i++) {
|
|
@@ -109,16 +104,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
109
104
|
}
|
|
110
105
|
return `
|
|
111
106
|
import Component from '${resourcePath}';
|
|
112
|
-
globalThis.__render.mount(Component, '${
|
|
107
|
+
globalThis.__render.mount(Component, '${pagePath}', ${JSON.stringify(resources)}, ${JSON.stringify(depends)})
|
|
113
108
|
`;
|
|
114
109
|
}
|
|
115
110
|
return `
|
|
116
111
|
import Component from '${resourcePath}';
|
|
117
|
-
globalThis.__render.mount(Component, '${
|
|
112
|
+
globalThis.__render.mount(Component, '${pagePath}', ${JSON.stringify(resources)})
|
|
118
113
|
`;
|
|
119
114
|
};
|
|
120
115
|
function genServiceLoderScript(project, context, opts) {
|
|
121
|
-
const { appJSON,
|
|
116
|
+
const { appJSON, projectMiniprogramPath, jsonDependencies } = project;
|
|
122
117
|
const { pkg, root } = opts;
|
|
123
118
|
const modules = [];
|
|
124
119
|
let name = 'XHS_SERVICE';
|
|
@@ -131,43 +126,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
131
126
|
const addAppJs = () => {
|
|
132
127
|
if (fs_extra_1.default.existsSync(`${projectMiniprogramPath}/app.js`) ||
|
|
133
128
|
fs_extra_1.default.existsSync(`${projectMiniprogramPath}/app.ts`)) {
|
|
134
|
-
modules.unshift(`const loadAppJs = () => require('${(0,
|
|
129
|
+
modules.unshift(`const loadAppJs = () => require('${(0, xhs_mp_compiler_utils_1.toUnixPath)(`${projectMiniprogramPath}/app`)}');` +
|
|
135
130
|
`globalThis['${name}'].default['app'] = globalThis.xhsLazyAppJs ? loadAppJs : loadAppJs()`);
|
|
136
131
|
}
|
|
137
132
|
};
|
|
138
|
-
|
|
133
|
+
const addPage = (page) => {
|
|
134
|
+
const resourcePath = (0, xhs_mp_compiler_utils_1.toUnixPath)(`${projectMiniprogramPath}/${page.path}`);
|
|
135
|
+
const content = `;globalThis['${name}'].default['${page.path}'] = () => require('${resourcePath}')`;
|
|
136
|
+
modules.push(content);
|
|
137
|
+
};
|
|
138
|
+
// 主包
|
|
139
|
+
if (pkg === xhs_mp_pack_1.CONSTANTS.MAIN_PKG) {
|
|
139
140
|
addAppJs();
|
|
140
|
-
for (const page of
|
|
141
|
-
|
|
142
|
-
modules.push(`;globalThis['${name}'].default['${page.path}'] = () => require('${resourcePath}')`);
|
|
141
|
+
for (const page of appJSON.pages) {
|
|
142
|
+
addPage(page);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const content = `;globalThis['${name}'].default['${page.path}'] = () => require('${resourcePath}')`;
|
|
152
|
-
if (pkg === xhs_mp_pack_1.CONSTANTS.MAIN_PKG) {
|
|
153
|
-
const subPackageRoots = appJSON.subPackages.map(pkg => pkg.root);
|
|
154
|
-
if (subPackageRoots.every(root => !page.path.startsWith(`${root}/`))) {
|
|
155
|
-
modules.push(content);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (pkg === xhs_mp_pack_1.CONSTANTS.SUB_PKG) {
|
|
159
|
-
if (page.path.startsWith(`${root}/`)) {
|
|
160
|
-
modules.push(content);
|
|
145
|
+
// 分包
|
|
146
|
+
if (pkg === xhs_mp_pack_1.CONSTANTS.SUB_PKG) {
|
|
147
|
+
for (const subPackage of appJSON.subPackages) {
|
|
148
|
+
if (subPackage.root === root) {
|
|
149
|
+
for (const page of subPackage.pages) {
|
|
150
|
+
addPage(page);
|
|
161
151
|
}
|
|
162
152
|
}
|
|
163
153
|
}
|
|
164
154
|
}
|
|
165
155
|
Object.keys(appJSON.componentsMap).forEach(compPath => {
|
|
166
|
-
const resourcePath = (0,
|
|
156
|
+
const resourcePath = (0, xhs_mp_compiler_utils_1.toUnixPath)(`${projectMiniprogramPath}/${compPath}`);
|
|
167
157
|
const content = `;globalThis['${name}'].default['${compPath}'] = () => require('${resourcePath}')`;
|
|
168
|
-
if (pkg === xhs_mp_pack_1.CONSTANTS.FULL_PKG) {
|
|
169
|
-
modules.push(content);
|
|
170
|
-
}
|
|
171
158
|
if (pkg === xhs_mp_pack_1.CONSTANTS.MAIN_PKG) {
|
|
172
159
|
const subPackageRoots = appJSON.subPackages.map(pkg => pkg.root);
|
|
173
160
|
if (subPackageRoots.every(root => !compPath.startsWith(`${root}/`))) {
|
|
@@ -180,12 +167,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
180
167
|
}
|
|
181
168
|
}
|
|
182
169
|
});
|
|
183
|
-
|
|
184
|
-
return `;globalThis['__MP_APP_JSON__'] = ${JSON.stringify(runtimeJSON)};
|
|
170
|
+
return `;globalThis['__MP_APP_JSON__'] = ${JSON.stringify(appJSON)};
|
|
185
171
|
;(globalThis['${name}'] || (globalThis['${name}'] = { default: {} }))
|
|
186
172
|
${modules.join('\n ')}
|
|
187
173
|
`;
|
|
188
174
|
}
|
|
175
|
+
function genSketchLoaderScript(project, context, opts) {
|
|
176
|
+
const { projectMiniprogramPath } = project;
|
|
177
|
+
const { pkg, root, path } = opts;
|
|
178
|
+
const resourcePath = (0, xhs_mp_compiler_utils_1.unixJoin)(projectMiniprogramPath, path);
|
|
179
|
+
const cssPath = `${resourcePath}.${(0, xhs_mp_compiler_utils_1.getCssSuffixName)()}`;
|
|
180
|
+
const mlPath = `${resourcePath}.${(0, xhs_mp_compiler_utils_1.getMlSuffixName)()}`;
|
|
181
|
+
// console.log(pkg, root, mlPath, cssPath)
|
|
182
|
+
if ((0, fs_extra_1.existsSync)(cssPath)) {
|
|
183
|
+
context.addDependency(cssPath);
|
|
184
|
+
return `import skeleton from '${mlPath}';` +
|
|
185
|
+
`import style from '${cssPath}';` +
|
|
186
|
+
`globalThis.XHS_SKETCH = ({ skeleton, style });`;
|
|
187
|
+
}
|
|
188
|
+
return `import skeleton from '${mlPath}';` +
|
|
189
|
+
`globalThis.XHS_SKETCH = ({ skeleton });`;
|
|
190
|
+
}
|
|
189
191
|
function entryLoader() {
|
|
190
192
|
// @ts-ignore
|
|
191
193
|
const options = this.getOptions();
|
|
@@ -193,7 +195,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
193
195
|
const handelrs = {
|
|
194
196
|
render: genRenderLoaderScript,
|
|
195
197
|
component: genComponentLoaderScript,
|
|
196
|
-
service: genServiceLoderScript
|
|
198
|
+
service: genServiceLoderScript,
|
|
199
|
+
sketch: genSketchLoaderScript,
|
|
197
200
|
};
|
|
198
201
|
const handler = handelrs[type];
|
|
199
202
|
if (!handler) {
|
|
File without changes
|
|
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
if (v !== undefined) module.exports = v;
|
|
17
17
|
}
|
|
18
18
|
else if (typeof define === "function" && define.amd) {
|
|
19
|
-
define(["require", "exports", "postcss", "postcss-import", "postcss-prefix-selector", "css-loader/dist/CssSyntaxError", "xhs-mp-ml-parser", "xhs-mp-compiler-utils", "../../utils/
|
|
19
|
+
define(["require", "exports", "postcss", "postcss-import", "postcss-prefix-selector", "postcss-preset-env", "cssnano", "css-loader/dist/CssSyntaxError", "xhs-mp-ml-parser", "xhs-mp-compiler-utils", "../../utils/postcssRpx2Vw", "../../types", "../../config/constant.config"], factory);
|
|
20
20
|
}
|
|
21
21
|
})(function (require, exports) {
|
|
22
22
|
"use strict";
|
|
@@ -24,63 +24,84 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
const postcss_1 = __importDefault(require("postcss"));
|
|
25
25
|
const postcss_import_1 = __importDefault(require("postcss-import"));
|
|
26
26
|
const postcss_prefix_selector_1 = __importDefault(require("postcss-prefix-selector"));
|
|
27
|
+
const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
|
|
28
|
+
const cssnano_1 = __importDefault(require("cssnano"));
|
|
27
29
|
const CssSyntaxError_1 = __importDefault(require("css-loader/dist/CssSyntaxError"));
|
|
28
30
|
const xhs_mp_ml_parser_1 = require("xhs-mp-ml-parser");
|
|
29
31
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
32
|
+
const postcssRpx2Vw_1 = __importDefault(require("../../utils/postcssRpx2Vw"));
|
|
33
|
+
const types_1 = require("../../types");
|
|
34
|
+
const constant_config_1 = require("../../config/constant.config");
|
|
35
|
+
const LABEL_REG = new RegExp(`(^|\\s)(${Object.keys(xhs_mp_ml_parser_1.tagTransformMap).join('|')})`, 'g');
|
|
36
|
+
const CSS_MINIMIZER_OPTIONS = {
|
|
37
|
+
preset: ['default', { normalizeUrl: false, calc: false }]
|
|
38
|
+
};
|
|
34
39
|
function wxssLoader(source) {
|
|
35
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
41
|
var _a, _b, _c, _d, _e;
|
|
37
42
|
const done = this.async();
|
|
38
|
-
const { project } = this._compiler;
|
|
43
|
+
const { project, packSetting } = this._compiler;
|
|
44
|
+
const isDev = packSetting.env === types_1.ENV.development;
|
|
45
|
+
const isProd = packSetting.env === types_1.ENV.production;
|
|
46
|
+
const browsers = isDev ? constant_config_1.DEV_BROWSERSLIST : constant_config_1.PROD_BROWSERSLIST;
|
|
39
47
|
const { appJSON = {}, miniprogramDir = '' } = project || {};
|
|
40
|
-
const shortPath = (0,
|
|
48
|
+
const shortPath = (0, xhs_mp_compiler_utils_1.getShortPath)(miniprogramDir, this.resourcePath).replace(constant_config_1.CSS_REG, '');
|
|
41
49
|
const index = (_c = (_b = (_a = appJSON === null || appJSON === void 0 ? void 0 : appJSON.componentsMap) === null || _a === void 0 ? void 0 : _a[shortPath]) === null || _b === void 0 ? void 0 : _b.index) !== null && _c !== void 0 ? _c : null;
|
|
42
50
|
const styleIsolation = (_e = (_d = appJSON === null || appJSON === void 0 ? void 0 : appJSON.componentsMap) === null || _d === void 0 ? void 0 : _d[shortPath]) === null || _e === void 0 ? void 0 : _e.styleIsolation;
|
|
43
51
|
const selectorIndex = styleIsolation === 'shared' ? 0 : index || 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
52
|
+
const isSketchCss = this.resourcePath.match(constant_config_1.SKETCH_CSS_REG);
|
|
53
|
+
if (!isSketchCss) {
|
|
54
|
+
// js / json 的配置会影响 page 或者 component 样式
|
|
55
|
+
this.addDependency(this.resourcePath.replace(constant_config_1.CSS_REG, '.js'));
|
|
56
|
+
this.addDependency(this.resourcePath.replace(constant_config_1.CSS_REG, '.json'));
|
|
57
|
+
}
|
|
58
|
+
const plugins = [
|
|
59
|
+
// 1. 处理 @import
|
|
60
|
+
(0, postcss_import_1.default)({ root: miniprogramDir }),
|
|
61
|
+
// 2. 处理组件或者页面选择器前缀
|
|
62
|
+
(0, postcss_prefix_selector_1.default)({
|
|
63
|
+
prefix: 'xhs',
|
|
64
|
+
transform(prefix, selector) {
|
|
65
|
+
if (!isSketchCss) {
|
|
66
|
+
// 支持 host 选择器 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/wxml-wxss.html
|
|
67
|
+
if (selector === ':host') {
|
|
68
|
+
return `[is="${shortPath}"]`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 替换所有类选择器,用于做样式隔离 wiki: https://wiki.xiaohongshu.com/pages/viewpage.action?pageId=181017177
|
|
72
|
+
* .app -> .xhs_0_app
|
|
73
|
+
*/
|
|
74
|
+
selector = selector.replace(/\.(\w)/g, `.xhs_${selectorIndex}_$1`);
|
|
75
|
+
}
|
|
76
|
+
// 为内置组件加上 xhs 前缀 view -> xhs-view
|
|
77
|
+
if (selector.match(LABEL_REG)) {
|
|
78
|
+
selector = selector.replace(LABEL_REG, `$1${prefix}-$2`);
|
|
79
|
+
}
|
|
80
|
+
return selector;
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
// 3. 处理rpx单位
|
|
84
|
+
(0, postcssRpx2Vw_1.default)({ baseWidth: 750, isDev, }),
|
|
85
|
+
// 4. 处理浏览器兼容性
|
|
86
|
+
isProd ? (0, postcss_preset_env_1.default)({ browsers }) : undefined,
|
|
87
|
+
// 5. 压缩css
|
|
88
|
+
packSetting.compressCss ? (0, cssnano_1.default)(CSS_MINIMIZER_OPTIONS) : undefined
|
|
89
|
+
].filter(Boolean);
|
|
90
|
+
try {
|
|
91
|
+
const result = yield (0, postcss_1.default)(plugins)
|
|
92
|
+
.process(source, {
|
|
93
|
+
from: this.resourcePath,
|
|
94
|
+
});
|
|
74
95
|
result.messages.forEach(({ file, type }) => {
|
|
75
96
|
if (type === 'dependency') {
|
|
76
97
|
this.addDependency(file);
|
|
77
98
|
}
|
|
78
99
|
});
|
|
79
|
-
done(null, result.css);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
done(error.name === 'CssSyntaxError' ? new CssSyntaxError_1.default(error) : error);
|
|
83
|
-
}
|
|
100
|
+
return done(null, result.css);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
return done(error.name === 'CssSyntaxError' ? new CssSyntaxError_1.default(error) : error);
|
|
104
|
+
}
|
|
84
105
|
});
|
|
85
106
|
}
|
|
86
107
|
module.exports = wxssLoader;
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export declare const getTsConfigPath: (projectPath: string) => string | undefined;
|
|
2
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
3
|
export declare const md5: (str: string) => string;
|
|
8
4
|
export declare const DEFAULT_ENTRY = "game";
|
package/dist/utils/common.js
CHANGED
|
@@ -7,16 +7,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
7
7
|
if (v !== undefined) module.exports = v;
|
|
8
8
|
}
|
|
9
9
|
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports", "fs-extra", "
|
|
10
|
+
define(["require", "exports", "fs-extra", "crypto"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.DEFAULT_ENTRY = exports.md5 = exports.
|
|
15
|
+
exports.DEFAULT_ENTRY = exports.md5 = exports.isString = exports.getTsConfigPath = void 0;
|
|
16
16
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
17
|
const crypto_1 = __importDefault(require("crypto"));
|
|
19
|
-
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
20
18
|
const getTsConfigPath = (projectPath) => {
|
|
21
19
|
if (fs_extra_1.default.existsSync(`${projectPath}/tsconfig.json`)) {
|
|
22
20
|
return `${projectPath}/tsconfig.json`;
|
|
@@ -26,20 +24,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
24
|
exports.getTsConfigPath = getTsConfigPath;
|
|
27
25
|
const isString = (val) => typeof val === 'string';
|
|
28
26
|
exports.isString = isString;
|
|
29
|
-
const toUnixPath = (pathStr = '') => pathStr.split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
30
|
-
exports.toUnixPath = toUnixPath;
|
|
31
|
-
const unixJoin = (...paths) => (0, exports.toUnixPath)(path_1.default.join(...paths));
|
|
32
|
-
exports.unixJoin = unixJoin;
|
|
33
|
-
const unixResolve = (...paths) => (0, exports.toUnixPath)(path_1.default.resolve(...paths));
|
|
34
|
-
exports.unixResolve = unixResolve;
|
|
35
|
-
const getShortPath = (miniprogramDir, rootContext) => {
|
|
36
|
-
const suffix = (0, xhs_mp_compiler_utils_1.getMlSuffixName)();
|
|
37
|
-
miniprogramDir = (0, exports.toUnixPath)(miniprogramDir);
|
|
38
|
-
miniprogramDir = miniprogramDir.endsWith('/') ? miniprogramDir : `${miniprogramDir}/`;
|
|
39
|
-
const reg = new RegExp(`.${suffix}$`, 'g');
|
|
40
|
-
return (0, exports.toUnixPath)(rootContext).replace(reg, '').replace(miniprogramDir, '');
|
|
41
|
-
};
|
|
42
|
-
exports.getShortPath = getShortPath;
|
|
43
27
|
const md5 = (str) => crypto_1.default.createHash('md5').update(str).digest('hex');
|
|
44
28
|
exports.md5 = md5;
|
|
45
29
|
exports.DEFAULT_ENTRY = "game";
|
|
@@ -1,34 +1,16 @@
|
|
|
1
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
-
};
|
|
4
1
|
(function (factory) {
|
|
5
2
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
6
3
|
var v = factory(require, exports);
|
|
7
4
|
if (v !== undefined) module.exports = v;
|
|
8
5
|
}
|
|
9
6
|
else if (typeof define === "function" && define.amd) {
|
|
10
|
-
define(["require", "exports"
|
|
7
|
+
define(["require", "exports"], factory);
|
|
11
8
|
}
|
|
12
9
|
})(function (require, exports) {
|
|
13
10
|
"use strict";
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getResourceUris =
|
|
12
|
+
exports.getResourceUris = void 0;
|
|
16
13
|
exports.createRequire = createRequire;
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
|
-
const common_1 = require("./common");
|
|
19
|
-
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
20
|
-
const formatPath = (pathStr = '') => pathStr.split(path_1.default.sep).join(path_1.default.posix.sep);
|
|
21
|
-
exports.formatPath = formatPath;
|
|
22
|
-
const getShortPath = (projectMiniprogramPath, rootContext) => {
|
|
23
|
-
const suffix = (0, xhs_mp_compiler_utils_1.getMlSuffixName)();
|
|
24
|
-
const reg = new RegExp(`.${suffix}$`, 'g');
|
|
25
|
-
projectMiniprogramPath = (0, common_1.toUnixPath)(projectMiniprogramPath);
|
|
26
|
-
projectMiniprogramPath = projectMiniprogramPath.endsWith('/')
|
|
27
|
-
? projectMiniprogramPath
|
|
28
|
-
: `${projectMiniprogramPath}/`;
|
|
29
|
-
return (0, common_1.toUnixPath)(rootContext).replace(reg, '').replace(projectMiniprogramPath, '');
|
|
30
|
-
};
|
|
31
|
-
exports.getShortPath = getShortPath;
|
|
32
14
|
/**
|
|
33
15
|
* 根据是否分包获取资源路径
|
|
34
16
|
*/
|
|
@@ -4,8 +4,9 @@ interface IPostcssRpx2Vw {
|
|
|
4
4
|
baseWidth?: number;
|
|
5
5
|
unitPrecision?: number;
|
|
6
6
|
mediaQuery?: boolean;
|
|
7
|
+
isDev?: boolean;
|
|
7
8
|
}
|
|
8
|
-
declare const postcssRpx2Vw: ({ outputUnit, baseWidth, unitPrecision, mediaQuery, }: IPostcssRpx2Vw) => {
|
|
9
|
+
declare const postcssRpx2Vw: ({ outputUnit, baseWidth, unitPrecision, mediaQuery, isDev, }: IPostcssRpx2Vw) => {
|
|
9
10
|
postcssPlugin: string;
|
|
10
11
|
Root: (root: Root) => void;
|
|
11
12
|
};
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const postcss_1 = require("postcss");
|
|
13
13
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
14
|
-
const postcssRpx2Vw = ({ outputUnit = 'vw', baseWidth = 750, unitPrecision = 5, mediaQuery = false, }) => {
|
|
14
|
+
const postcssRpx2Vw = ({ outputUnit = 'vw', baseWidth = 750, unitPrecision = 5, mediaQuery = false, isDev = false, }) => {
|
|
15
15
|
const replacement = (m, $1) => {
|
|
16
16
|
return (0, xhs_mp_compiler_utils_1.calcRpx2Vw)($1, baseWidth, unitPrecision, outputUnit);
|
|
17
17
|
};
|
|
@@ -27,9 +27,12 @@
|
|
|
27
27
|
rpxEntries.push({ prop: decl.prop, value: decl.value });
|
|
28
28
|
decl.value = decl.value.replace(xhs_mp_compiler_utils_1.RPX_REGEX, replacement);
|
|
29
29
|
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
// dev 环境下,添加原始 rpx 值
|
|
31
|
+
if (isDev) {
|
|
32
|
+
rpxEntries.forEach(decl => {
|
|
33
|
+
rule.append(new postcss_1.Declaration({ prop: '--ide-' + decl.prop, value: decl.value }));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
33
36
|
});
|
|
34
37
|
if (mediaQuery) {
|
|
35
38
|
root.walkAtRules('media', rule => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xhs-mp-compiler-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4-beta.1",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -45,7 +45,6 @@
|
|
|
45
45
|
"@babel/types": "^7.12.10",
|
|
46
46
|
"@swc/core": "^1.3.74",
|
|
47
47
|
"@swc/helpers": "^0.5.1",
|
|
48
|
-
"@vue/babel-preset-jsx": "^1.2.4",
|
|
49
48
|
"archiver": "^7.0.1",
|
|
50
49
|
"babel-loader": "^8.2.2",
|
|
51
50
|
"babel-plugin-istanbul": "^6.0.0",
|
|
@@ -70,41 +69,37 @@
|
|
|
70
69
|
"module-alias": "^2.2.2",
|
|
71
70
|
"open": "^7.0.4",
|
|
72
71
|
"ora": "^5.4.1",
|
|
73
|
-
"postcss": "^8.2.
|
|
74
|
-
"postcss-import": "^14.0
|
|
75
|
-
"postcss-
|
|
76
|
-
"postcss-
|
|
77
|
-
"
|
|
78
|
-
"postcss-pxtorem": "^5.1.1",
|
|
72
|
+
"postcss": "^8.2.15",
|
|
73
|
+
"postcss-import": "^14.1.0",
|
|
74
|
+
"postcss-prefix-selector": "^1.16.1",
|
|
75
|
+
"postcss-preset-env": "^6.7.2",
|
|
76
|
+
"prettier": "^3.0.3",
|
|
79
77
|
"query-string": "^8.1.0",
|
|
80
78
|
"querystring": "^0.2.1",
|
|
81
79
|
"source-map": "^0.6.1",
|
|
82
80
|
"speed-measure-webpack-plugin": "^1.5.0",
|
|
83
|
-
"style-loader": "^1.2.1",
|
|
84
81
|
"swc-loader": "^0.1.15",
|
|
85
82
|
"tapable": "^2.2.1",
|
|
86
83
|
"terser-webpack-plugin": "^5.2.4",
|
|
87
84
|
"typescript": "^5.1.6",
|
|
88
85
|
"uuid": "^9.0.1",
|
|
89
|
-
"vue": "^3.2.26",
|
|
90
|
-
"vue-loader": "^16.4.1",
|
|
91
|
-
"vue-style-loader": "^4.1.2",
|
|
92
86
|
"webpack": "^5.88.2",
|
|
93
87
|
"webpack-bundle-analyzer": "^4.4.0",
|
|
94
88
|
"webpack-chain": "^6.5.1",
|
|
95
89
|
"webpack-sources": "^3.2.2",
|
|
96
90
|
"xhs-mp-workerpool": "^9.1.3",
|
|
97
|
-
"xhs-mp-ml-loader": "2.0.
|
|
98
|
-
"xhs-mp-compiler-utils": "2.0.
|
|
99
|
-
"xhs-mp-pack": "2.0.
|
|
100
|
-
"xhs-mp-project": "2.0.
|
|
101
|
-
"xhs-mp-shared": "2.0.
|
|
102
|
-
"xhs-mp-shared-fs": "2.0.
|
|
103
|
-
"xhs-mp-sjs-loader": "2.0.
|
|
91
|
+
"xhs-mp-ml-loader": "2.0.4-beta.1",
|
|
92
|
+
"xhs-mp-compiler-utils": "2.0.4-beta.1",
|
|
93
|
+
"xhs-mp-pack": "2.0.4-beta.1",
|
|
94
|
+
"xhs-mp-project": "2.0.4-beta.1",
|
|
95
|
+
"xhs-mp-shared": "2.0.4-beta.1",
|
|
96
|
+
"xhs-mp-shared-fs": "2.0.4-beta.1",
|
|
97
|
+
"xhs-mp-sjs-loader": "2.0.4-beta.1",
|
|
98
|
+
"xhs-mp-sketch-loader": "2.0.4-beta.1",
|
|
104
99
|
"yauzl": "^2.10.0"
|
|
105
100
|
},
|
|
106
101
|
"peerDependencies": {
|
|
107
|
-
"xhs-mp-ml-parser": "2.0.
|
|
102
|
+
"xhs-mp-ml-parser": "2.0.4-beta.1"
|
|
108
103
|
},
|
|
109
104
|
"devDependencies": {
|
|
110
105
|
"@types/babel__generator": "7.6.3",
|
|
@@ -122,14 +117,13 @@
|
|
|
122
117
|
"eslint": "7.27.0",
|
|
123
118
|
"eslint-config-prettier": "8.1.0",
|
|
124
119
|
"jest": "27.0.6",
|
|
125
|
-
"prettier": "~3.0.2",
|
|
126
120
|
"rimraf": "3.0.2",
|
|
127
121
|
"ts-jest": "27.0.3",
|
|
128
122
|
"ts-node": "10.0.0",
|
|
129
123
|
"typescript": "5.1.6",
|
|
130
124
|
"vue3-jest": "27.0.0-alpha.2",
|
|
131
125
|
"webpack-dev-server": "4.0.0-beta.3",
|
|
132
|
-
"xhs-mp-ml-parser": "2.0.
|
|
126
|
+
"xhs-mp-ml-parser": "2.0.4-beta.1"
|
|
133
127
|
},
|
|
134
128
|
"scripts": {
|
|
135
129
|
"version": "formula changelog && git add .",
|
package/dist/utils/css.d.ts
DELETED
package/dist/utils/css.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
2
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3
|
-
};
|
|
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", "postcss-preset-env", "./postcssRpx2Vw", "../types", "../config/constant.config"], factory);
|
|
11
|
-
}
|
|
12
|
-
})(function (require, exports) {
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const postcss_preset_env_1 = __importDefault(require("postcss-preset-env"));
|
|
16
|
-
const postcssRpx2Vw_1 = __importDefault(require("./postcssRpx2Vw"));
|
|
17
|
-
const types_1 = require("../types");
|
|
18
|
-
const constant_config_1 = require("../config/constant.config");
|
|
19
|
-
const getCssConfig = (packSetting, options, presets, independentFile = false) => {
|
|
20
|
-
const isDev = packSetting.env === types_1.ENV.development;
|
|
21
|
-
const browsers = isDev ? constant_config_1.DEV_BROWSERSLIST : constant_config_1.PROD_BROWSERSLIST;
|
|
22
|
-
const loaders = {
|
|
23
|
-
'mini-style-loader': {
|
|
24
|
-
loader: require.resolve('../presets/loaders/mini-style-loader'),
|
|
25
|
-
options: Object.assign(Object.assign({}, options), { independentFile }),
|
|
26
|
-
},
|
|
27
|
-
'postcss-loader': {
|
|
28
|
-
loader: require.resolve('postcss-loader'),
|
|
29
|
-
options: {
|
|
30
|
-
sourceMap: packSetting.env !== types_1.ENV.production,
|
|
31
|
-
postcssOptions: {
|
|
32
|
-
config: false,
|
|
33
|
-
plugins: [(0, postcssRpx2Vw_1.default)({ baseWidth: 750 }), (0, postcss_preset_env_1.default)({ browsers })],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
'wxss-loader': {
|
|
38
|
-
loader: require.resolve('../presets/loaders/wxss-loader'),
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
return presets.flat().reduce((acc, cur) => {
|
|
42
|
-
if (typeof cur === "string" && loaders[cur]) {
|
|
43
|
-
Reflect.set(acc, cur, loaders[cur]);
|
|
44
|
-
}
|
|
45
|
-
return acc;
|
|
46
|
-
}, {});
|
|
47
|
-
};
|
|
48
|
-
exports.default = getCssConfig;
|
|
49
|
-
});
|