SuperAPI AI 工具集

metro-bundler

编程与开发

查看项目

更新于 10-15 19:56

技能介绍

用途:面向 React Native 的 Metro 打包器,提供配置、优化、自定义转换器、缓存策略与打包故障排查。主要能力:讲解 Metro 基础概念(Transformer 转换、Resolver 解析、Serializer 序列化、Cache 缓存、Source Map 与 Fast Refresh);编写 metro.config.js,支持 Expo 与 @react-native/metro-config 的 getDefaultConfig/mergeConfig;自定义 babelTransformerPath、assetExts/sourceExts、nodeModulesPaths、platforms、watchFolders、resetCache 与 server.port;内联 require、模块 ID 工厂、资源压缩、按平台解析、resolveRequest 自定义解析;SVG 转换器(npm install react-native-svg react-native-svg-transformer)及多扩展名解析;Monorepo 与 symlink 处理(unstable_enableSymlinks);缓存管理与清理命令。用法:启动使用 npx react-native start,清缓存加 --reset-cache,Expo 用 npx expo start -c;排查可 curl http://localhost:8081/status;分阶段用 source-map-explorer 分析包体。适用场景:配置打包、优化包体积与启动时间、Monorepo、排查 “Unable to resolve module”、端口 8081 冲突、清缓存、Source Map 与自定义资源。限制:部分能力标注为实验或 unstable;资料未提供收费、价格与效果数据,版本兼容等细节暂未提供。