fix(metro): 取消 withBugCollect 自动链式,避免破坏 Metro 0.84 dev 打包
- common/metro: withXuqmConfig 不再自动链式 withBugCollect(保留 .xuqmconfig 单点同步)。 customSerializer 方式的 sourcemap 上传在 Metro 0.84 下不可靠:覆盖默认 serializer 后 无法经 package exports 取回默认序列化,dev 打包会报 "Cannot read properties of undefined (reading 'code')"。 - bugcollect/metro: 还原 customSerializer 回退实现;该插件仅建议显式包裹在已有 serializer 之上。 - sourcemap 上传后续改为 react-native bundle 后独立脚本上传。 Co-Authored-By: Claude <noreply@anthropic.com>
这个提交包含在:
父节点
d51d3c934d
当前提交
ac7e941744
@ -137,7 +137,9 @@ function withBugCollect(metroConfig) {
|
||||
serializer: {
|
||||
...metroConfig.serializer,
|
||||
customSerializer: async (entryPoint, preModules, graph, options) => {
|
||||
// 调用原始 serializer
|
||||
// 仅在宿主已有 customSerializer 时委托;否则保持 result 未定义并交回 Metro。
|
||||
// 注意:本插件应通过显式包裹在已有 serializer 之上使用(见 README),
|
||||
// 不建议自动链式启用(Metro 默认 serializer 不可经 exports 获取)。
|
||||
const baseSerializer = metroConfig.serializer?.customSerializer
|
||||
const result = baseSerializer
|
||||
? await baseSerializer(entryPoint, preModules, graph, options)
|
||||
|
||||
@ -47,15 +47,10 @@ function findConfigFile(projectRoot) {
|
||||
}
|
||||
|
||||
function applyBugCollect(metroConfig) {
|
||||
// 可选链式:安装了 @xuqm/rn-bugcollect 时,自动启用 Release 包 SourceMap 上传。
|
||||
// 未安装则原样返回(不强制依赖)。
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||
const { withBugCollect } = require('@xuqm/rn-bugcollect/metro');
|
||||
return typeof withBugCollect === 'function' ? withBugCollect(metroConfig) : metroConfig;
|
||||
} catch {
|
||||
return metroConfig;
|
||||
}
|
||||
// 不再自动链式 withBugCollect:基于 customSerializer 的 sourcemap 上传在 Metro 0.84
|
||||
// 下不可靠(exports 限制无法获取默认 serializer,会破坏 dev 打包)。
|
||||
// sourcemap 上传改由独立后处理脚本(react-native bundle 后单独上传)实现。
|
||||
return metroConfig;
|
||||
}
|
||||
|
||||
/** 写入目标文件(仅在缺失或内容不一致时),返回是否发生写入。 */
|
||||
|
||||
正在加载...
在新工单中引用
屏蔽一个用户