xhs-mp-compiler-cli 1.3.5 → 1.3.8
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/compiler.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -2
- package/dist/packs/mp-pack/index.js +4 -1
- package/dist/packs/webpack/dev-server/index.js +2 -2
- package/dist/packs/webpack/index.js +3 -0
- package/dist/presets/configs/miniprogram/assets/assetsEntryPlugin.js +2 -2
- package/dist/presets/configs/miniprogram/render/renderChunkPlugin.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/apm/index.js +30 -13
- package/dist/utils/tagTransformMap.d.ts +1 -0
- package/dist/utils/tagTransformMap.js +2 -1
- package/package.json +6 -6
package/dist/compiler.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/// <reference types="node/child_process" />
|
|
2
|
+
/// <reference types=".pnpm/artifactory.devops.xiaohongshu.com+@types+node@20.12.2/node_modules/@types/node/child_process" />
|
|
2
3
|
/// <reference types="node/stream" />
|
|
4
|
+
/// <reference types=".pnpm/artifactory.devops.xiaohongshu.com+@types+node@20.12.2/node_modules/@types/node/stream" />
|
|
3
5
|
/**
|
|
4
6
|
* 在子进程执行编译
|
|
5
7
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node/events" />
|
|
2
|
+
/// <reference types=".pnpm/artifactory.devops.xiaohongshu.com+@types+node@20.12.2/node_modules/@types/node/events" />
|
|
2
3
|
import { COMPILE_ENTRY } from './config/constant.config';
|
|
3
4
|
import { Project } from 'xhs-mp-project';
|
|
4
5
|
import EventEmitter from 'events';
|
package/dist/index.js
CHANGED
|
@@ -189,11 +189,10 @@ class Compiler extends events_1.default {
|
|
|
189
189
|
const distDir = this.getDistDir(entryType);
|
|
190
190
|
const cacheDir = this.getCacheDir(entryType);
|
|
191
191
|
const compilerType = this.getCompilerType(entryType);
|
|
192
|
-
|
|
192
|
+
compilerType === constant_config_1.COMPILER_TYPE.legacy_dev || compilerType === constant_config_1.COMPILER_TYPE.legacy_build
|
|
193
193
|
? 'webpack'
|
|
194
194
|
: 'mp-pack';
|
|
195
195
|
const options = {
|
|
196
|
-
packMode,
|
|
197
196
|
projectPath: this.project.projectPath,
|
|
198
197
|
appMode: this.project.appMode,
|
|
199
198
|
extJsonPath: this.project.extJsonDir,
|
|
@@ -8,12 +8,15 @@ const presets_1 = require("../../presets");
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const xhs_mp_pack_1 = require("xhs-mp-pack");
|
|
10
10
|
const apm_1 = require("../../utils/apm");
|
|
11
|
+
const const_1 = __importDefault(require("../../utils/const"));
|
|
12
|
+
const { PACK_MODE } = const_1.default;
|
|
11
13
|
const createCompiler = (startConfig) => {
|
|
12
|
-
const {
|
|
14
|
+
// const {action, enableDevServer} = startConfig
|
|
13
15
|
const mppack = new xhs_mp_pack_1.MPPack(startConfig);
|
|
14
16
|
const compilerOptions = {
|
|
15
17
|
project: mppack.project,
|
|
16
18
|
packSetting: mppack.packSetting,
|
|
19
|
+
packMode: PACK_MODE.MPPACK,
|
|
17
20
|
// 注入apm模块
|
|
18
21
|
reporter: (0, apm_1.createReporter)(mppack.project, startConfig.mpUploadOptions)
|
|
19
22
|
};
|
|
@@ -19,14 +19,14 @@ const openBrowser_1 = __importDefault(require("./lib/openBrowser"));
|
|
|
19
19
|
const presets_1 = require("../../../presets");
|
|
20
20
|
const devServer = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
const { packSetting } = config;
|
|
22
|
-
const {
|
|
22
|
+
const { distDir } = packSetting;
|
|
23
23
|
const webpackConfigs = (0, presets_1.createConfigs)(config);
|
|
24
24
|
const compiler = (0, webpack_1.default)(webpackConfigs);
|
|
25
25
|
const host = 'localhost';
|
|
26
26
|
const devServerConfig = {
|
|
27
27
|
open: false,
|
|
28
28
|
historyApiFallback: true,
|
|
29
|
-
port:
|
|
29
|
+
port: 1388,
|
|
30
30
|
hot: false,
|
|
31
31
|
static: [
|
|
32
32
|
// emulator entry 地址
|
|
@@ -15,6 +15,8 @@ const xhs_mp_project_1 = require("xhs-mp-project");
|
|
|
15
15
|
const xhs_mp_pack_1 = require("xhs-mp-pack");
|
|
16
16
|
const webpack_1 = require("./webpack");
|
|
17
17
|
const apm_1 = require("../../utils/apm");
|
|
18
|
+
const const_1 = __importDefault(require("../../utils/const"));
|
|
19
|
+
const { PACK_MODE } = const_1.default;
|
|
18
20
|
// 防御编程
|
|
19
21
|
const handleVersion = (startConfig) => {
|
|
20
22
|
let { action, enableV1 = true, enableV2 = false, enableVDom = false } = startConfig;
|
|
@@ -77,6 +79,7 @@ const createCompiler = (startConfig) => {
|
|
|
77
79
|
const compilerOptions = {
|
|
78
80
|
project: project,
|
|
79
81
|
packSetting: mppackSetting,
|
|
82
|
+
packMode: PACK_MODE.WEBPACK,
|
|
80
83
|
// 注入apm模块
|
|
81
84
|
reporter: (0, apm_1.createReporter)(project, startConfig.mpUploadOptions)
|
|
82
85
|
};
|
|
@@ -87,7 +87,7 @@ class XhsAssetsPlugin {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
emitAppJson(compilation, appJSON) {
|
|
90
|
-
const { project, packSetting } = this.options;
|
|
90
|
+
const { project, packSetting, packMode } = this.options;
|
|
91
91
|
const { compilePkgs = [const_1.default.MAIN_PKG] } = packSetting;
|
|
92
92
|
// const { mainPkg, subPkgs } = packSetting.getCompilePkgsForEntries()
|
|
93
93
|
// 先删除,用户配置的默认不生效
|
|
@@ -109,7 +109,7 @@ class XhsAssetsPlugin {
|
|
|
109
109
|
this.emitJson(compilation, 'v1/app.json', appJsonSource);
|
|
110
110
|
}
|
|
111
111
|
// 独立分包的 app.json
|
|
112
|
-
const subPkgs = project.getSubPackages()
|
|
112
|
+
const subPkgs = project.getSubPackages();
|
|
113
113
|
subPkgs.forEach(subPkg => {
|
|
114
114
|
if (subPkg === null || subPkg === void 0 ? void 0 : subPkg.independent) {
|
|
115
115
|
if (packSetting.enableV2) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const packs_1 = require("../../../../packs");
|
|
4
4
|
const injectCSS = `
|
|
5
|
-
globalThis.__XHS_IS_WEBVIEW = (globalThis.localStorage && document && document.querySelectorAll)
|
|
5
|
+
globalThis.__XHS_IS_WEBVIEW = (globalThis.localStorage && globalThis.document && globalThis.document.querySelectorAll)
|
|
6
6
|
globalThis.__XHS_APPEND_CSS = function(cssText){
|
|
7
7
|
if (!globalThis.__XHS_IS_WEBVIEW) return;
|
|
8
8
|
var headTags = document.getElementsByTagName('head')
|
package/dist/types/index.d.ts
CHANGED
package/dist/utils/apm/index.js
CHANGED
|
@@ -5,16 +5,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
12
|
exports.createReporter = void 0;
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
10
14
|
const xhs_mp_utils_1 = require("xhs-mp-utils");
|
|
15
|
+
const fs_extra_1 = require("fs-extra");
|
|
11
16
|
const pkg = require('../../../package.json');
|
|
12
17
|
function debug(...data) {
|
|
13
|
-
return;
|
|
14
18
|
// return process.send?.(JSON.stringify({ method: 'debugger', data }))
|
|
15
19
|
}
|
|
16
20
|
const cacheMap = {};
|
|
17
|
-
function
|
|
21
|
+
function onceByParams(target, key, descriptor) {
|
|
18
22
|
const originalMethod = descriptor.value;
|
|
19
23
|
descriptor.value = function (...args) {
|
|
20
24
|
try {
|
|
@@ -87,22 +91,22 @@ class Reporter {
|
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
__decorate([
|
|
90
|
-
|
|
94
|
+
onceByParams
|
|
91
95
|
], Reporter.prototype, "reportThirdFramework", null);
|
|
92
96
|
__decorate([
|
|
93
|
-
|
|
97
|
+
onceByParams
|
|
94
98
|
], Reporter.prototype, "reportMlFeature", null);
|
|
95
99
|
__decorate([
|
|
96
|
-
|
|
100
|
+
onceByParams
|
|
97
101
|
], Reporter.prototype, "reportMlWebComponent", null);
|
|
98
102
|
__decorate([
|
|
99
|
-
|
|
103
|
+
onceByParams
|
|
100
104
|
], Reporter.prototype, "reportJSONComponent", null);
|
|
101
105
|
__decorate([
|
|
102
|
-
|
|
106
|
+
onceByParams
|
|
103
107
|
], Reporter.prototype, "reportStyleIsolation", null);
|
|
104
108
|
__decorate([
|
|
105
|
-
|
|
109
|
+
onceByParams
|
|
106
110
|
], Reporter.prototype, "reportJSONApp", null);
|
|
107
111
|
function isObject(t) {
|
|
108
112
|
return t != null && typeof t === 'object';
|
|
@@ -120,18 +124,20 @@ function createReporter(project, option) {
|
|
|
120
124
|
var _a, _b, _c;
|
|
121
125
|
try {
|
|
122
126
|
const app_id = option === null || option === void 0 ? void 0 : option.upload_app_id;
|
|
123
|
-
|
|
127
|
+
// 上传时有version
|
|
128
|
+
const version = (_a = option === null || option === void 0 ? void 0 : option.pkgInfo) === null || _a === void 0 ? void 0 : _a.version;
|
|
129
|
+
if (!app_id || !version) {
|
|
124
130
|
return;
|
|
125
131
|
}
|
|
126
132
|
const apm = new xhs_mp_utils_1.APM(`mp-compiler-${pkg.version}`);
|
|
127
|
-
(
|
|
133
|
+
(_b = apm === null || apm === void 0 ? void 0 : apm.setContext) === null || _b === void 0 ? void 0 : _b.call(apm, app_id, {
|
|
128
134
|
app_id,
|
|
129
135
|
app_name: app_id,
|
|
130
136
|
third_name: app_id,
|
|
131
137
|
page_key: '0',
|
|
132
138
|
app_env: 0,
|
|
133
139
|
app_type: 0,
|
|
134
|
-
bundle_version:
|
|
140
|
+
bundle_version: version,
|
|
135
141
|
base_version: ((_c = project.projectJsonContent) === null || _c === void 0 ? void 0 : _c.libVersion) || ''
|
|
136
142
|
});
|
|
137
143
|
const reporter = new Reporter(apm);
|
|
@@ -170,8 +176,19 @@ function createReporter(project, option) {
|
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
}
|
|
173
|
-
|
|
174
|
-
|
|
179
|
+
reportJSON();
|
|
180
|
+
// 统计taro版本
|
|
181
|
+
const vendor = path_1.default.join(project.miniprogramDir, 'vendors.js.LICENSE.txt');
|
|
182
|
+
const taro = path_1.default.join(project.miniprogramDir, 'taro.js');
|
|
183
|
+
if ((0, fs_extra_1.pathExistsSync)(taro) && (0, fs_extra_1.pathExistsSync)(vendor)) {
|
|
184
|
+
const txt = (0, fs_extra_1.readFileSync)(vendor, { encoding: 'utf-8' });
|
|
185
|
+
if (txt.includes('React') || txt.includes('react')) {
|
|
186
|
+
reporter.reportThirdFramework(xhs_mp_utils_1.FeatureReporter.ThirdFramework.taroReact);
|
|
187
|
+
}
|
|
188
|
+
else if (txt.includes('@vue') || txt.includes('Vue')) {
|
|
189
|
+
reporter.reportThirdFramework(xhs_mp_utils_1.FeatureReporter.ThirdFramework.taroVue);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
175
192
|
return reporter;
|
|
176
193
|
}
|
|
177
194
|
catch (error) {
|
|
@@ -33,6 +33,7 @@ const tagTransformMap = {
|
|
|
33
33
|
editor: 'xhs-vue-editor',
|
|
34
34
|
'movable-area': 'xhs-vue-movable-area',
|
|
35
35
|
'movable-view': 'xhs-vue-movable-view',
|
|
36
|
-
canvas: 'xhs-vue-canvas'
|
|
36
|
+
canvas: 'xhs-vue-canvas',
|
|
37
|
+
camera: 'xhs-vue-camera',
|
|
37
38
|
};
|
|
38
39
|
exports.default = tagTransformMap;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xhs-mp-compiler-cli",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "xhs mp command tool.",
|
|
5
5
|
"preferGlobal": true,
|
|
6
6
|
"category": "esm",
|
|
@@ -82,11 +82,11 @@
|
|
|
82
82
|
"webpack-bundle-analyzer": "^4.4.0",
|
|
83
83
|
"webpack-chain": "^6.5.1",
|
|
84
84
|
"webpack-sources": "^3.2.2",
|
|
85
|
-
"xhs-mp-compiler-ml-loader": "1.3.
|
|
86
|
-
"xhs-mp-compiler-utils": "1.
|
|
87
|
-
"xhs-mp-pack": "^1.
|
|
88
|
-
"xhs-mp-project": "^1.
|
|
89
|
-
"xhs-mp-utils": "^1.3.
|
|
85
|
+
"xhs-mp-compiler-ml-loader": "^1.3.8",
|
|
86
|
+
"xhs-mp-compiler-utils": "^1.3.8",
|
|
87
|
+
"xhs-mp-pack": "^1.3.8",
|
|
88
|
+
"xhs-mp-project": "^1.3.8",
|
|
89
|
+
"xhs-mp-utils": "^1.3.8"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@types/babel__generator": "7.6.3",
|