2026-06-16 12:20:04 +08:00
|
|
|
|
'use strict'
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-16 17:39:18 +08:00
|
|
|
|
* withBugCollect(metroConfig)
|
2026-06-16 12:20:04 +08:00
|
|
|
|
* 包裹 Metro 配置,打 Release 包时自动上传 SourceMap。
|
|
|
|
|
|
* 当前为存根实现,后续补全 SourceMap 上传逻辑。
|
|
|
|
|
|
*/
|
2026-06-16 17:39:18 +08:00
|
|
|
|
function withBugCollect(metroConfig) {
|
2026-06-16 12:20:04 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...metroConfig,
|
|
|
|
|
|
serializer: {
|
|
|
|
|
|
...metroConfig.serializer,
|
|
|
|
|
|
customSerializer: async (entryPoint, preModules, graph, options) => {
|
|
|
|
|
|
// 调用原始 serializer
|
|
|
|
|
|
const baseSerializer = metroConfig.serializer?.customSerializer
|
|
|
|
|
|
const result = baseSerializer
|
|
|
|
|
|
? await baseSerializer(entryPoint, preModules, graph, options)
|
|
|
|
|
|
: undefined
|
|
|
|
|
|
|
|
|
|
|
|
// 仅 Release 包上传 SourceMap(dev 模式跳过)
|
|
|
|
|
|
if (!options.dev) {
|
|
|
|
|
|
// TODO: 补全 SourceMap 上传逻辑
|
2026-06-16 17:39:18 +08:00
|
|
|
|
// 1. 读取 .xuqmconfig 或 xuqm.config.js 获取 bugCollectApiUrl
|
2026-06-16 12:20:04 +08:00
|
|
|
|
// 2. 读取 sourceMapUrl 对应的 .map 文件
|
2026-06-16 17:39:18 +08:00
|
|
|
|
// 3. 上传到 bugCollectApiUrl/log/v1/sourcemaps/upload
|
2026-06-16 12:20:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-16 17:39:18 +08:00
|
|
|
|
module.exports = { withBugCollect }
|