xhs-mp-compiler-cli 2.0.24 → 2.0.25
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/presets/common.js +28 -3
- package/dist/presets/index.js +1 -18
- package/package.json +13 -13
package/dist/presets/common.js
CHANGED
|
@@ -7,27 +7,52 @@ 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"], factory);
|
|
10
|
+
define(["require", "exports", "path", "fs"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const path_1 = __importDefault(require("path"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
const pkg = require('../../package.json');
|
|
16
18
|
const presetCommon = (chain, options) => {
|
|
19
|
+
var _a;
|
|
17
20
|
const { packSetting, project } = options;
|
|
18
21
|
const { action, enableSourcemap, tsConfigPath } = packSetting;
|
|
22
|
+
let babelRunTimePaths = [];
|
|
23
|
+
try {
|
|
24
|
+
const cliNpmPath = require.resolve(pkg.name);
|
|
25
|
+
const cliNpmRootPath = (_a = cliNpmPath.split('node_modules')) === null || _a === void 0 ? void 0 : _a[0];
|
|
26
|
+
if (cliNpmRootPath) {
|
|
27
|
+
const cliNpmHumanPath = path_1.default.join(cliNpmRootPath, 'node_modules', pkg.name);
|
|
28
|
+
if (fs_1.default.existsSync(cliNpmHumanPath)) {
|
|
29
|
+
// 用于寻找 @babel/runtime 等编译时依赖的包
|
|
30
|
+
babelRunTimePaths.push(path_1.default.join(cliNpmHumanPath, 'node_modules'));
|
|
31
|
+
babelRunTimePaths.push(path_1.default.join(cliNpmRootPath, 'node_modules'));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
// noop
|
|
37
|
+
}
|
|
38
|
+
// 兜底
|
|
39
|
+
if (babelRunTimePaths.length === 0) {
|
|
40
|
+
babelRunTimePaths.push(path_1.default.join(__dirname, '../../node_modules/'));
|
|
41
|
+
}
|
|
19
42
|
chain.merge({
|
|
20
43
|
stats: 'errors-only',
|
|
21
44
|
output: {
|
|
22
45
|
pathinfo: false,
|
|
23
46
|
},
|
|
24
47
|
resolve: {
|
|
48
|
+
// 支持 import xx from '/xxx/ 绝对路径导入
|
|
25
49
|
roots: [project.miniprogramDir],
|
|
26
50
|
extensions: ['.js', '.ts'],
|
|
27
51
|
modules: [
|
|
52
|
+
path_1.default.join(project.miniprogramDir, 'node_modules'),
|
|
53
|
+
project.miniprogramDir,
|
|
28
54
|
path_1.default.join(project.projectPath, 'node_modules'),
|
|
29
|
-
|
|
30
|
-
path_1.default.join(__dirname, '../../node_modules/')
|
|
55
|
+
...babelRunTimePaths,
|
|
31
56
|
],
|
|
32
57
|
},
|
|
33
58
|
resolveLoader: {
|
package/dist/presets/index.js
CHANGED
|
@@ -7,14 +7,13 @@ 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-pack", "
|
|
10
|
+
define(["require", "exports", "xhs-mp-pack", "./common", "./dev", "./prod", "./configs/miniprogram/assets", "./configs/miniprogram/service", "./configs/miniprogram/render", "./configs/minigame/assets", "./configs/minigame/service"], factory);
|
|
11
11
|
}
|
|
12
12
|
})(function (require, exports) {
|
|
13
13
|
"use strict";
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.createConfigs = void 0;
|
|
16
16
|
const xhs_mp_pack_1 = require("xhs-mp-pack");
|
|
17
|
-
const path_1 = __importDefault(require("path"));
|
|
18
17
|
const common_1 = __importDefault(require("./common"));
|
|
19
18
|
const dev_1 = require("./dev");
|
|
20
19
|
const prod_1 = require("./prod");
|
|
@@ -54,14 +53,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
54
53
|
serviceConfig.entry = (0, service_1.getServiceEntry)(options);
|
|
55
54
|
renderConfig.entry = (0, render_1.getRenderEntry)(options);
|
|
56
55
|
let configs = [renderConfig, serviceConfig, assetsConfig];
|
|
57
|
-
configs = configs.map(options => {
|
|
58
|
-
var _a, _b, _c, _d;
|
|
59
|
-
// 查找ide根目录下的node_modules
|
|
60
|
-
(_b = (_a = options.resolve) === null || _a === void 0 ? void 0 : _a.modules) === null || _b === void 0 ? void 0 : _b.push(path_1.default.resolve(__dirname, '../../../../../'));
|
|
61
|
-
// cli的node_modules路径
|
|
62
|
-
(_d = (_c = options.resolve) === null || _c === void 0 ? void 0 : _c.modules) === null || _d === void 0 ? void 0 : _d.push(path_1.default.resolve(__dirname, '../../../../'));
|
|
63
|
-
return options;
|
|
64
|
-
});
|
|
65
56
|
return configs;
|
|
66
57
|
};
|
|
67
58
|
/**
|
|
@@ -88,14 +79,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
88
79
|
assetsConfig.entry = {};
|
|
89
80
|
serviceConfig.entry = {};
|
|
90
81
|
let configs = [serviceConfig, assetsConfig];
|
|
91
|
-
configs = configs.map(options => {
|
|
92
|
-
var _a, _b, _c, _d;
|
|
93
|
-
// 查找ide根目录下的node_modules
|
|
94
|
-
(_b = (_a = options.resolve) === null || _a === void 0 ? void 0 : _a.modules) === null || _b === void 0 ? void 0 : _b.push(path_1.default.resolve(__dirname, '../../../../../'));
|
|
95
|
-
// cli的node_modules路径
|
|
96
|
-
(_d = (_c = options.resolve) === null || _c === void 0 ? void 0 : _c.modules) === null || _d === void 0 ? void 0 : _d.push(path_1.default.resolve(__dirname, '../../../../'));
|
|
97
|
-
return options;
|
|
98
|
-
});
|
|
99
82
|
return configs;
|
|
100
83
|
};
|
|
101
84
|
// 获取编译配置
|
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.25",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@babel/runtime": "^7.26.0",
|
|
44
44
|
"@babel/traverse": "^7.26.0",
|
|
45
45
|
"@babel/types": "^7.26.0",
|
|
46
|
-
"@swc/core": "
|
|
47
|
-
"@swc/helpers": "
|
|
46
|
+
"@swc/core": "~1.3.99",
|
|
47
|
+
"@swc/helpers": "~0.5.11",
|
|
48
48
|
"archiver": "^7.0.1",
|
|
49
49
|
"babel-loader": "^10.0.0",
|
|
50
50
|
"babel-plugin-istanbul": "^6.0.0",
|
|
@@ -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.25",
|
|
92
|
+
"xhs-mp-compiler-utils": "2.0.25",
|
|
93
|
+
"xhs-mp-pack": "2.0.25",
|
|
94
|
+
"xhs-mp-project": "2.0.25",
|
|
95
|
+
"xhs-mp-shared": "2.0.25",
|
|
96
|
+
"xhs-mp-shared-fs": "2.0.25",
|
|
97
|
+
"xhs-mp-sjs-loader": "2.0.25",
|
|
98
|
+
"xhs-mp-sketch-loader": "2.0.25",
|
|
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.25"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@types/babel__generator": "7.6.3",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"@types/node": "14",
|
|
123
123
|
"typescript": "5.1.6",
|
|
124
124
|
"webpack-dev-server": "4.0.0-beta.3",
|
|
125
|
-
"xhs-mp-ml-parser": "2.0.
|
|
125
|
+
"xhs-mp-ml-parser": "2.0.25"
|
|
126
126
|
},
|
|
127
127
|
"scripts": {
|
|
128
128
|
"version": "formula changelog && git add .",
|