arrow icon

Bob — The React Native library builder

Download your copy of the
Ultimate Guide to React Native Optimization

blog content

Need help with Performance Optimization? 
hire us
Need help with Super app development
hire us
Need help with React Native?
hire us
Need help with migration to React Native?
hire us
Our React Native EU Conference is back
register nowlearn more

It’s a common practice to publish React Native libraries as source code without building them. Metro handles compiling JavaScript and TypeScript files by default, so it mostly works.

But there are many reasons you should compile your JavaScript and TypeScript code when publishing.

  • Jest doesn’t compile code under node_modules by default, so it’s extra work for users to configure Jest when testing.
  • It’s common to exclude node_modules when compiling for bundlers such as webpack. If your library is cross-platform and supports web, it should have first-class support for other bundlers.
  • If your library supports web, you should pre-compile it so that the user can import it in Node for SSR.

The main reason many people don’t compile the code when publishing is because it’s not straightforward. We need to take care of many things, for example, different entry points and babel configuration for different targets. If we use a static type checker such as Flow or TypeScript, we also need to take care of generating and publishing the type definitions.

We built Bob to simplify this and take care of it automatically. All the scripts and Babel config are abstracted away. It can also automatically configure your project to use it just by running yarn bob init.

Currently, it handles the following targets,

  • Generic CommonJS build
  • ES modules build for bundlers such as webpack
  • Flow definitions (copies .js files to .flow files)
  • TypeScript definitions (uses tsc to generate declaration files)

Bob’s goal is to standardize these build scripts across the React Native libraries in the community. We plan to implement more things in the future, including a watch mode.

For installation and usage instructions, check out the repo. If you face any issues with version, please report them on our issue tracker, and don’t forget to star it 🌟.

Satyajit Sahoo
React Native and Web developer who specializes in JavaScript, TypeScript, and all things frontend related. Satya has created and maintained many open source libraries for React Native & Web such as React Navigation, React Native Paper, React Native Builder Bob, Linaria etc. Creator of React Navigation 5 and Linaria. When not coding, Satya loves cooking or playing video games.
arrow icon
MORE posts from this author

Bundle React Native apps using Webpack features

Discover Re.Pack – a Webpack-based toolkit that allows you to build a React Native app with the full support of the Webpack ecosystem.

learn more

More posts from this category

Ensure your React components perform as intended as your app grows

Discover Reassure - our open-source library that allows you to run performance tests measuring the average rendering time of the in-app components.

business benefits

Performance Optimization

To stay competitive, you need a high-performing app. Improving React Native performance can bring your company many business and tech benefits. To learn more about it, check the page entirely dedicated to React Native Performance Optimization. Discover a real-life example of React Native optimization we performed for Aaqua, a Singaporean platform that enables global users to share their passion through groups.

Bundle React Native apps using Webpack features

Discover Re.Pack – a Webpack-based toolkit that allows you to build a React Native app with the full support of the Webpack ecosystem.

business benefits

Why React Native?

Building an all-in-one platform can bring your company a lot of business and tech benefits like seamless UX experience, global reach, brand growth just to name a few. To learn more about the benefits of using React Native to develop super apps, check out the MoMo case study. Where we helped improve app's performance by migrating architecture to Re.Pack.

stay tuned

Subscribe to our newsletter

You may unsubscribe from these communications at any time. For details see the Privacy Policy.