xhs-mp-compiler-cli 2.0.10 → 2.0.12
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 +0 -4
- package/dist/config/constant.config.js +1 -6
- package/dist/presets/configs/minigame/service/index.js +1 -0
- package/dist/presets/configs/miniprogram/assets/index.js +3 -2
- package/dist/presets/configs/miniprogram/render/index.js +6 -6
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.js +11 -11
- package/dist/presets/configs/miniprogram/service/index.js +1 -0
- package/dist/presets/loaders/mini-style-loader.js +10 -7
- package/dist/presets/loaders/wxss-loader.js +6 -5
- package/dist/utils/apm.js +1 -2
- package/package.json +11 -11
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
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',
|
|
@@ -78,9 +78,4 @@
|
|
|
78
78
|
MPPACK: 'mp-pack',
|
|
79
79
|
WEBPACK: 'webpack'
|
|
80
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$/;
|
|
86
81
|
});
|
|
@@ -7,13 +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", "xhs-mp-compiler-utils", "./assetsEntryPlugin", "../../../../config/constant.config", "../../../plugins/InjectorPlugin", "path", "../../../../utils/cache"], factory);
|
|
10
|
+
define(["require", "exports", "xhs-mp-compiler-utils", "xhs-mp-shared", "./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
16
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
17
|
+
const xhs_mp_shared_1 = require("xhs-mp-shared");
|
|
17
18
|
const assetsEntryPlugin_1 = __importDefault(require("./assetsEntryPlugin"));
|
|
18
19
|
const constant_config_1 = require("../../../../config/constant.config");
|
|
19
20
|
const InjectorPlugin_1 = require("../../../plugins/InjectorPlugin");
|
|
@@ -35,7 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
36
|
} }, (0, cache_1.getCacheConfig)(absCacheDirectory, options)), { module: {
|
|
36
37
|
rule: {
|
|
37
38
|
style: {
|
|
38
|
-
test:
|
|
39
|
+
test: xhs_mp_shared_1.CSS_REG,
|
|
39
40
|
use: {
|
|
40
41
|
"mini-style-loader": {
|
|
41
42
|
loader: "mini-style-loader",
|
|
@@ -7,13 +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", "path", "./sjsEntryPlugin", "./render", "./component", "./sketch", "./renderChunkPlugin", "../../../../types", "../../../plugins/InjectorPlugin", "../../../../utils/cache"
|
|
10
|
+
define(["require", "exports", "path", "xhs-mp-shared", "./sjsEntryPlugin", "./render", "./component", "./sketch", "./renderChunkPlugin", "../../../../types", "../../../plugins/InjectorPlugin", "../../../../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.presetRender = exports.getRenderEntry = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const xhs_mp_shared_1 = require("xhs-mp-shared");
|
|
17
18
|
const sjsEntryPlugin_1 = __importDefault(require("./sjsEntryPlugin"));
|
|
18
19
|
const render_1 = require("./render");
|
|
19
20
|
const component_1 = require("./component");
|
|
@@ -22,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
23
|
const types_1 = require("../../../../types");
|
|
23
24
|
const InjectorPlugin_1 = require("../../../plugins/InjectorPlugin");
|
|
24
25
|
const cache_1 = require("../../../../utils/cache");
|
|
25
|
-
const constant_config_1 = require("../../../../config/constant.config");
|
|
26
26
|
const getRenderEntry = (options) => () => {
|
|
27
27
|
const entries = Object.assign(Object.assign(Object.assign({}, (0, render_1.getRenderEntry)(options)), (0, component_1.getComponentEntry)(options)), (0, sketch_1.getSketchEntry)(options));
|
|
28
28
|
return entries;
|
|
@@ -54,7 +54,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
54
54
|
} }, (0, cache_1.getCacheConfig)(absCacheDirectory, options)), { module: {
|
|
55
55
|
rule: {
|
|
56
56
|
ml: {
|
|
57
|
-
test:
|
|
57
|
+
test: xhs_mp_shared_1.ML_REG,
|
|
58
58
|
use: Object.assign(Object.assign({}, transfomLoader), { 'ml-loader': {
|
|
59
59
|
loader: require.resolve('xhs-mp-ml-loader'),
|
|
60
60
|
options: {
|
|
@@ -63,7 +63,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
63
63
|
} }),
|
|
64
64
|
},
|
|
65
65
|
sketchMl: {
|
|
66
|
-
test:
|
|
66
|
+
test: xhs_mp_shared_1.SKETCH_ML_REG,
|
|
67
67
|
use: Object.assign(Object.assign({}, transfomLoader), { 'sketch-loader': {
|
|
68
68
|
loader: require.resolve('xhs-mp-sketch-loader'),
|
|
69
69
|
options: {
|
|
@@ -72,7 +72,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
72
72
|
} }),
|
|
73
73
|
},
|
|
74
74
|
style: {
|
|
75
|
-
test:
|
|
75
|
+
test: xhs_mp_shared_1.CSS_REG,
|
|
76
76
|
use: {
|
|
77
77
|
"mini-style-loader": {
|
|
78
78
|
loader: "mini-style-loader",
|
|
@@ -91,7 +91,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
91
91
|
}
|
|
92
92
|
},
|
|
93
93
|
sketchStyle: {
|
|
94
|
-
test:
|
|
94
|
+
test: xhs_mp_shared_1.SKETCH_CSS_REG,
|
|
95
95
|
use: {
|
|
96
96
|
"string-loader": {
|
|
97
97
|
loader: "string-loader"
|
|
@@ -21,12 +21,12 @@ globalThis.__XHS_WEBVIEW = (globalThis.localStorage && globalThis.document && gl
|
|
|
21
21
|
${common}
|
|
22
22
|
globalThis.__XHS_ADD_LINK = function(src){
|
|
23
23
|
if (!globalThis.__XHS_WEBVIEW) return;
|
|
24
|
-
const host = globalThis.SmallApp && globalThis.SmallApp.__BOOTSTRAP_HOST__
|
|
25
|
-
const link = document.createElement('link')
|
|
26
|
-
link.href = host +
|
|
27
|
-
link.type = 'text/css'
|
|
28
|
-
link.rel = 'stylesheet'
|
|
29
|
-
link.setAttribute('xhs-p', src)
|
|
24
|
+
const host = globalThis.SmallApp && globalThis.SmallApp.__BOOTSTRAP_HOST__;
|
|
25
|
+
const link = document.createElement('link');
|
|
26
|
+
link.href = host ? (host + '/' + src) : src;
|
|
27
|
+
link.type = 'text/css';
|
|
28
|
+
link.rel = 'stylesheet';
|
|
29
|
+
link.setAttribute('xhs-p', src);
|
|
30
30
|
document.head.appendChild(link);
|
|
31
31
|
};
|
|
32
32
|
`;
|
|
@@ -42,11 +42,11 @@ globalThis.__XHS_ADD_LINK = function(src){
|
|
|
42
42
|
${common}
|
|
43
43
|
globalThis.__XHS_ADD_STYLE = function(style, src){
|
|
44
44
|
if (!globalThis.__XHS_WEBVIEW) return;
|
|
45
|
-
const cssTextNode = document.createTextNode(String(style))
|
|
46
|
-
const styleNode = document.createElement('style')
|
|
47
|
-
styleNode.setAttribute('xhs-p', src)
|
|
48
|
-
styleNode.appendChild(cssTextNode)
|
|
49
|
-
document.head.appendChild(styleNode)
|
|
45
|
+
const cssTextNode = document.createTextNode(String(style));
|
|
46
|
+
const styleNode = document.createElement('style');
|
|
47
|
+
styleNode.setAttribute('xhs-p', src);
|
|
48
|
+
styleNode.appendChild(cssTextNode);
|
|
49
|
+
document.head.appendChild(styleNode);
|
|
50
50
|
};
|
|
51
51
|
`;
|
|
52
52
|
// 注入css跟webpack runtime
|
|
@@ -80,6 +80,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
80
80
|
// dev模式下开启懒编译,不能抽离common chunk
|
|
81
81
|
if (env !== xhs_mp_pack_1.ENV.development) {
|
|
82
82
|
chain.optimization.splitChunks({
|
|
83
|
+
// TODO chunk 合并策略
|
|
83
84
|
chunks: chunk => !chunk.name.startsWith('v0/'),
|
|
84
85
|
minSize: 0,
|
|
85
86
|
name: 'service-common'
|
|
@@ -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", "xhs-mp-compiler-utils", "../../packs", "
|
|
7
|
+
define(["require", "exports", "xhs-mp-compiler-utils", "../../packs", "xhs-mp-shared"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
13
13
|
const packs_1 = require("../../packs");
|
|
14
|
-
const
|
|
14
|
+
const xhs_mp_shared_1 = require("xhs-mp-shared");
|
|
15
15
|
function miniStyleLoader(source) {
|
|
16
16
|
var _a;
|
|
17
17
|
const callback = this.async();
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
const { project } = this._compiler;
|
|
21
21
|
const { independentFile, emitDirs = [] } = this.getOptions();
|
|
22
22
|
const { miniprogramDir } = project;
|
|
23
|
-
const shortPath = (0, xhs_mp_compiler_utils_1.getShortPath)(miniprogramDir, resourcePath).replace(
|
|
23
|
+
const shortPath = (0, xhs_mp_compiler_utils_1.getShortPath)(miniprogramDir, resourcePath).replace(xhs_mp_shared_1.CSS_REG, '.css');
|
|
24
24
|
source = (_a = source === null || source === void 0 ? void 0 : source.trim) === null || _a === void 0 ? void 0 : _a.call(source);
|
|
25
25
|
const emitFiles = (code) => {
|
|
26
26
|
if ((independentFile) && code) {
|
|
@@ -33,14 +33,17 @@
|
|
|
33
33
|
if (!code) {
|
|
34
34
|
return `export default void 0;`;
|
|
35
35
|
}
|
|
36
|
+
const injectCssPath = `const cssPath = ${JSON.stringify(shortPath)};`;
|
|
36
37
|
// 判断浏览器环境,注入css添加逻辑
|
|
37
38
|
if (independentFile) {
|
|
38
|
-
return new packs_1.RawSource(
|
|
39
|
-
`
|
|
39
|
+
return new packs_1.RawSource(injectCssPath +
|
|
40
|
+
`globalThis.__XHS_ADD_LINK(cssPath);` +
|
|
41
|
+
`export default cssPath;`).source();
|
|
40
42
|
}
|
|
41
43
|
else {
|
|
42
|
-
return new packs_1.RawSource(
|
|
43
|
-
`
|
|
44
|
+
return new packs_1.RawSource(injectCssPath +
|
|
45
|
+
`globalThis.__XHS_ADD_STYLE(${JSON.stringify(code)}, cssPath);` +
|
|
46
|
+
`export default cssPath;`).source();
|
|
44
47
|
}
|
|
45
48
|
};
|
|
46
49
|
emitFiles(source);
|
|
@@ -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", "postcss-preset-env", "cssnano", "css-loader/dist/CssSyntaxError", "xhs-mp-ml-parser", "xhs-mp-compiler-utils", "../../utils/postcssRpx2Vw", "../../types", "../../config/constant.config"], factory);
|
|
19
|
+
define(["require", "exports", "postcss", "postcss-import", "postcss-prefix-selector", "postcss-preset-env", "cssnano", "css-loader/dist/CssSyntaxError", "xhs-mp-ml-parser", "xhs-mp-shared", "xhs-mp-compiler-utils", "../../utils/postcssRpx2Vw", "../../types", "../../config/constant.config"], factory);
|
|
20
20
|
}
|
|
21
21
|
})(function (require, exports) {
|
|
22
22
|
"use strict";
|
|
@@ -28,6 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
const cssnano_1 = __importDefault(require("cssnano"));
|
|
29
29
|
const CssSyntaxError_1 = __importDefault(require("css-loader/dist/CssSyntaxError"));
|
|
30
30
|
const xhs_mp_ml_parser_1 = require("xhs-mp-ml-parser");
|
|
31
|
+
const xhs_mp_shared_1 = require("xhs-mp-shared");
|
|
31
32
|
const xhs_mp_compiler_utils_1 = require("xhs-mp-compiler-utils");
|
|
32
33
|
const postcssRpx2Vw_1 = __importDefault(require("../../utils/postcssRpx2Vw"));
|
|
33
34
|
const types_1 = require("../../types");
|
|
@@ -49,15 +50,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
49
50
|
const isProd = packSetting.env === types_1.ENV.production;
|
|
50
51
|
const browsers = isDev ? constant_config_1.DEV_BROWSERSLIST : constant_config_1.PROD_BROWSERSLIST;
|
|
51
52
|
const { appJSON = {}, miniprogramDir = '' } = project || {};
|
|
52
|
-
const shortPath = (0, xhs_mp_compiler_utils_1.getShortPath)(miniprogramDir, this.resourcePath).replace(
|
|
53
|
+
const shortPath = (0, xhs_mp_compiler_utils_1.getShortPath)(miniprogramDir, this.resourcePath).replace(xhs_mp_shared_1.CSS_REG, '');
|
|
53
54
|
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;
|
|
54
55
|
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;
|
|
55
56
|
const selectorIndex = styleIsolation === 'shared' ? 0 : index || 0;
|
|
56
|
-
const isSketchCss = this.resourcePath.match(
|
|
57
|
+
const isSketchCss = this.resourcePath.match(xhs_mp_shared_1.SKETCH_CSS_REG);
|
|
57
58
|
if (!isSketchCss) {
|
|
58
59
|
// js / json 的配置会影响 page 或者 component 样式
|
|
59
|
-
this.addDependency(this.resourcePath.replace(
|
|
60
|
-
this.addDependency(this.resourcePath.replace(
|
|
60
|
+
this.addDependency(this.resourcePath.replace(xhs_mp_shared_1.CSS_REG, '.js'));
|
|
61
|
+
this.addDependency(this.resourcePath.replace(xhs_mp_shared_1.CSS_REG, '.json'));
|
|
61
62
|
}
|
|
62
63
|
const plugins = [
|
|
63
64
|
// 1. 处理 @import
|
package/dist/utils/apm.js
CHANGED
|
@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
const lodash_1 = require("lodash");
|
|
24
24
|
const xhs_mp_shared_1 = require("xhs-mp-shared");
|
|
25
25
|
const fs_extra_1 = require("fs-extra");
|
|
26
|
-
const pkg = require('../../package.json');
|
|
27
26
|
function debug(...data) {
|
|
28
27
|
// return process.send?.(JSON.stringify({ method: 'debugger', data }))
|
|
29
28
|
}
|
|
@@ -147,7 +146,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
147
146
|
if (!app_id || !version) {
|
|
148
147
|
return;
|
|
149
148
|
}
|
|
150
|
-
const apm = new xhs_mp_shared_1.APM(
|
|
149
|
+
const apm = new xhs_mp_shared_1.APM();
|
|
151
150
|
(_b = apm === null || apm === void 0 ? void 0 : apm.setContext) === null || _b === void 0 ? void 0 : _b.call(apm, app_id, {
|
|
152
151
|
app_id,
|
|
153
152
|
app_name: app_id,
|
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.12",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -88,18 +88,18 @@
|
|
|
88
88
|
"webpack-chain": "^6.5.1",
|
|
89
89
|
"webpack-sources": "^3.2.2",
|
|
90
90
|
"xhs-mp-workerpool": "^9.2.0",
|
|
91
|
-
"xhs-mp-ml-loader": "2.0.
|
|
92
|
-
"xhs-mp-compiler-utils": "2.0.
|
|
93
|
-
"xhs-mp-pack": "2.0.
|
|
94
|
-
"xhs-mp-project": "2.0.
|
|
95
|
-
"xhs-mp-shared": "2.0.
|
|
96
|
-
"xhs-mp-shared-fs": "2.0.
|
|
97
|
-
"xhs-mp-sjs-loader": "2.0.
|
|
98
|
-
"xhs-mp-sketch-loader": "2.0.
|
|
91
|
+
"xhs-mp-ml-loader": "2.0.12",
|
|
92
|
+
"xhs-mp-compiler-utils": "2.0.12",
|
|
93
|
+
"xhs-mp-pack": "2.0.12",
|
|
94
|
+
"xhs-mp-project": "2.0.12",
|
|
95
|
+
"xhs-mp-shared": "2.0.12",
|
|
96
|
+
"xhs-mp-shared-fs": "2.0.12",
|
|
97
|
+
"xhs-mp-sjs-loader": "2.0.12",
|
|
98
|
+
"xhs-mp-sketch-loader": "2.0.12",
|
|
99
99
|
"yauzl": "^2.10.0"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
|
-
"xhs-mp-ml-parser": "2.0.
|
|
102
|
+
"xhs-mp-ml-parser": "2.0.12"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@types/babel__generator": "7.6.3",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"typescript": "5.1.6",
|
|
124
124
|
"vue3-jest": "27.0.0-alpha.2",
|
|
125
125
|
"webpack-dev-server": "4.0.0-beta.3",
|
|
126
|
-
"xhs-mp-ml-parser": "2.0.
|
|
126
|
+
"xhs-mp-ml-parser": "2.0.12"
|
|
127
127
|
},
|
|
128
128
|
"scripts": {
|
|
129
129
|
"version": "formula changelog && git add .",
|