@gedegas/反应-本土-捆绑-可视化器
看看你的内在反应

目的
有时, 导入一个单一的 Javascript 库可以大大地增加你的捆绑大小 。 这个软件包可以帮助您识别这样一个库,这样您就可以保持捆绑大小的低和加载时间快.
使用量
确保 npx 数据 在工程根中安装并运行以下命令
npx @gedeagas/react-native-bundle-visualizer
或安装为非依赖性
yarn add --dev @gedeagas/react-native-bundle-visualizer
运行它:
yarn run react-native-bundle-visualizer
使用 npm 时 :
npm install --save-dev @gedeagas/react-native-bundle-visualizer
npx react-native-bundle-visualizer
CI/CD 使用量
对于 CI/CD 环境,需要只捕捉到捆绑大小进行比较或监测,请使用 --bundle-size-only 选项(输出小数位数为3):
# Output only the bundle size in megabytes (e.g., "2.450MB")
npx @gedeagas/react-native-bundle-visualizer --bundle-size-only
# Example: Capture bundle size in a variable
BUNDLE_SIZE=$(npx @gedeagas/react-native-bundle-visualizer --bundle-size-only)
echo "Bundle size: $BUNDLE_SIZE"
# Example: Compare bundle sizes in CI
PREV_SIZE=$(cat .bundle-size-cache 2>/dev/null || echo "0MB")
CURRENT_SIZE=$(npx @gedeagas/react-native-bundle-visualizer --bundle-size-only)
echo $CURRENT_SIZE > .bundle-size-cache
# Extract numeric values for comparison (removes "MB" suffix)
PREV_NUM=$(echo $PREV_SIZE | sed 's/MB//')
CURRENT_NUM=$(echo $CURRENT_SIZE | sed 's/MB//')
if (( $(echo "$CURRENT_NUM > $PREV_NUM" | bc -l) )); then
echo "⚠️ Bundle size increased from $PREV_SIZE to $CURRENT_SIZE"
exit 1
else
echo "✅ Bundle size is $CURRENT_SIZE (was $PREV_SIZE)"
fi
命令行参数
所有命令行参数都是可选的 。 默认情况下,将为 ios 平台.
| 选项 | 说明 | 示例 |
|---|---|---|
platform | 要构建的平台( 默认为 欧斯(中文(简体) ) | --platform ios |
dev | 开发或生产构建( 默认为 虚假(中文(简体) ) | --dev false |
entry-file | 条目文件( 当省略试图自动解析时) | --entry-file ./index.ios.js |
bundle-output | 输出捆绑文件( 默认为 tmp 调制(中文(简体) ) | --bundle-output ./myapp.bundle |
format | 输出格式 (简体中文), (中文(简体) ), 乔森 或者说 tsv 数据 (默认为 (简体中文)) (见 源图探索选项(中文(简体) ) | --format json |
only-mapped | 从输出中排除“ 未映射” 字节( 默认为 虚假) (中文(简体) ). 这将导致总数低于文件大小 . | --only-mapped |
verbose | 向控制台倾倒额外输出( 默认为 虚假(中文(简体) ) | --verbose |
reset-cache | 删除已缓存的反应内在文件( 默认为 虚假(中文(简体) ) | --reset-cache |
--expo | 根据是否使用 expo 设定为真/ 假 。 对于eg, 设置 --expo true 当使用博览会。 无需通过此反应- 亲和 Cli 。 (默认为 虚假(中文(简体) ) | --expo false |
--no-border-checks | 把同一面旗子传到下面 source-map-explorer 以禁用无效的映射列/行检查. | --no-border-checks |
--bundle-size-only | 只输出有"MB"后缀的平方兆字节的捆绑大小(3个小数位,如"2.450MB")(对CI/CD环境有用). 这将压制所有其他输出, 只返回格式大小 . | --bundle-size-only |
使用 反应- 内置- 捆绑- 视觉器@ 2 当瞄准 Expo SDK 40或更低.
版本兼容性
| 版本 | 评论 |
|---|---|
| 3.x 运算 | 兼容 React-Native CLI 靴子化项目和博览会SDK 41或更高. |
| 2.x 数据 | 兼容 React-Native CLI roottraped projects 和 Expo SDK 40 或更早. |
| 1.x 运算 | 使用 散装弹炮 而不是地铁的输出. |