rnx-kit/packages/bundle-diff
React Native SDK Bot 756ddeba67
RELEASING: Releasing 44 package(s) (#3342)
Releases:
  @rnx-kit/third-party-notices@2.0.0
  @rnx-kit/cli@0.18.0
  @rnx-kit/metro-plugin-cyclic-dependencies-detector@2.0.0
  @rnx-kit/react-native-error-trace-decorator@2.0.0
  @rnx-kit/esbuild-plugin-import-path-remapper@3.0.0
  @rnx-kit/babel-plugin-import-path-remapper@2.0.0
  @rnx-kit/babel-preset-metro-react-native@2.0.0
  @rnx-kit/metro-plugin-duplicates-checker@3.0.0
  @rnx-kit/react-native-test-app-msal@4.0.0
  @rnx-kit/react-native-lazy-index@4.0.0
  @rnx-kit/tools-react-native@2.0.0
  @rnx-kit/typescript-service@2.0.0
  @rnx-kit/commitlint-lite@2.0.0
  @rnx-kit/metro-serializer@2.0.0
  @rnx-kit/tools-language@3.0.0
  @rnx-kit/metro-service@4.0.0
  @rnx-kit/metro-config@2.0.0
  @rnx-kit/bundle-diff@2.0.0
  @rnx-kit/align-deps@3.0.0
  @rnx-kit/tools-node@3.0.0
  @rnx-kit/tsconfig@2.0.0
  @rnx-kit/console@2.0.0
  @react-native-webapis/battery-status@0.2.0
  @react-native-webapis/web-storage@0.3.0
  @rnx-kit/esbuild-bundle-analyzer@0.3.0
  @rnx-kit/metro-serializer-esbuild@0.2.0
  @rnx-kit/rn-changelog-generator@0.5.0
  @rnx-kit/metro-plugin-typescript@0.5.0
  @rnx-kit/metro-resolver-symlinks@0.2.0
  @rnx-kit/react-native-auth@0.3.0
  @rnx-kit/react-native-host@0.5.0
  @rnx-kit/patcher-rnmacos@0.2.0
  @rnx-kit/tools-filesystem@0.1.0
  @rnx-kit/tools-workspaces@0.2.0
  @rnx-kit/eslint-plugin@0.8.0
  @rnx-kit/tools-android@0.2.0
  @rnx-kit/tools-windows@0.2.0
  @rnx-kit/jest-preset@0.2.0
  @rnx-kit/tools-apple@0.2.0
  @rnx-kit/tools-shell@0.2.0
  @rnx-kit/polyfills@0.2.0
  @rnx-kit/config@0.7.0
  @rnx-kit/build@0.7.1
  @rnx-kit/eslint-config@0.0.4

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-11 08:59:50 +02:00
..
src test: migrate more tests to Node test runner (#3252) 2024-07-30 18:45:19 +02:00
test test: migrate more tests to Node test runner (#3252) 2024-07-30 18:45:19 +02:00
CHANGELOG.md RELEASING: Releasing 44 package(s) (#3342) 2024-09-11 08:59:50 +02:00
README.md docs: automate removal of badges from READMEs (#2324) 2023-04-14 08:24:28 +02:00
eslint.config.js chore: migrate to ESLint flat config (#2782) 2023-11-03 14:02:18 +01:00
package.json RELEASING: Releasing 44 package(s) (#3342) 2024-09-11 08:59:50 +02:00
tsconfig.json feat(tsconfig): base TypeScript configs for working with Node (#2886) 2023-12-18 12:05:07 +01:00

README.md

@rnx-kit/bundle-diff

Build npm version

A simple tool for diffing two bundles. Useful for getting an overview of which files are included in one bundle but not the other. For example, comparing a bundle produced by Webpack vs. one produced by Metro.

Usage

rnx-bundle-diff <a.jsbundle.map> <b.jsbundle.map>

Example output:

     +106    added  /~/node_modules/@babel/runtime/helpers/arrayWithHoles.js
      +96    added  /~/node_modules/lodash-es/_realNames.js
      +49    added  /~/node_modules/@babel/runtime/regenerator/index.js
       +1  changed  /~/node_modules/react/index.js
     -127  removed  /~/node_modules/querystring-es3/index.js
     -286  removed  /~/node_modules/react-native/Libraries/Components/Picker/PickerAndroid.ios.js
     -592  removed  /~/node_modules/react-native/Libraries/Components/Sound/SoundManager.js
  unknown    added  /~/packages/awesome-app/lib/index.js

Note that the numbers are in bytes, and based on the unminified code. They are meant to give an idea of how big the file is, but could differ wildly depending on a number of factors, including Babel plugins, Wepback config, TypeScript compilation options, indentation etc.

Troubleshooting

I have a lot of unknown content sizes in my diff

If you're using TypeScript, you need to tell tsc to also include source content in the source map:

// tsconfig.json
{
  "compilerOptions": {
    "inlineSources": true
  }
}

I have a lot of relative paths in my source map

If your project is using TypeScript and Webpack, you may experience that your source maps don't properly map back to the source file. Try using source-map-loader to clean up the paths:

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.(js|(js)?bundle)($|\?)/i,
        enforce: "pre",
        use: ["source-map-loader"],
      },
    ],
  },
};