Top Related Projects
🚇 The JavaScript bundler for React Native
The React Framework
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
The zero configuration build tool for the web. 📦🚀
Next-generation ES module bundler
Quick Overview
Haul is a command-line tool for developing and bundling React Native applications. It aims to provide a more flexible and customizable alternative to the built-in Metro bundler, offering features like webpack configuration, hot module replacement, and better support for web-based development.
Pros
- Offers greater flexibility and customization options compared to Metro bundler
- Supports webpack configuration, allowing developers to leverage its ecosystem
- Provides hot module replacement for faster development cycles
- Better integration with web-based development workflows
Cons
- May have a steeper learning curve for developers familiar with Metro bundler
- Potentially less stable or well-maintained compared to the official Metro bundler
- Could introduce compatibility issues with some React Native libraries or plugins
- Requires additional setup and configuration compared to the default bundler
Code Examples
- Basic Haul configuration (webpack.haul.js):
module.exports = ({ platform }) => ({
entry: `./index.${platform}.js`,
resolve: {
extensions: [`.${platform}.js`, '.js'],
},
});
- Custom loader configuration:
module.exports = ({ platform }) => ({
module: {
rules: [
{
test: /\.custom$/,
use: 'custom-loader',
},
],
},
});
- Enabling Hot Module Replacement:
const webpack = require('webpack');
module.exports = ({ platform }) => ({
plugins: [
new webpack.HotModuleReplacementPlugin(),
],
});
Getting Started
-
Install Haul globally:
npm install -g @haul-bundler/cli
-
Initialize Haul in your React Native project:
haul init
-
Start the development server:
haul start
-
Run your React Native app with Haul:
react-native run-android --bundle-url http://localhost:8081/index.bundle
Competitor Comparisons
🚇 The JavaScript bundler for React Native
Pros of Metro
- Faster build times and more efficient bundling, especially for large projects
- Better integration with React Native and other Facebook tools
- More active development and community support
Cons of Metro
- Less flexible configuration options compared to Haul
- Can be more complex to set up and customize for non-standard projects
- Limited support for non-React Native projects
Code Comparison
Metro configuration:
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
Haul configuration:
export default {
entry: './index.js',
platforms: ['ios', 'android'],
transformer: {
babelTransformerPath: require.resolve('react-native-typescript-transformer'),
},
};
Both Metro and Haul serve as bundlers for React Native projects, but they have different approaches and trade-offs. Metro is the default bundler for React Native and offers better performance and integration with the React Native ecosystem. Haul, on the other hand, provides more flexibility and customization options, making it suitable for projects with unique requirements or those using non-standard setups.
The React Framework
Pros of Next.js
- Larger ecosystem and community support
- Built-in server-side rendering and static site generation
- Seamless integration with Vercel's deployment platform
Cons of Next.js
- Steeper learning curve for developers new to React
- More opinionated structure, which may limit flexibility in some cases
Code Comparison
Next.js:
// pages/index.js
export default function Home() {
return <h1>Welcome to Next.js!</h1>
}
Haul:
// App.js
import React from 'react';
import { Text, View } from 'react-native';
export default function App() {
return (
<View>
<Text>Welcome to Haul!</Text>
</View>
);
}
Key Differences
- Next.js is primarily for web applications, while Haul focuses on React Native
- Haul is a build tool for React Native, whereas Next.js is a full-fledged framework
- Next.js offers more built-in features and optimizations out of the box
Use Cases
- Choose Next.js for web applications with server-side rendering requirements
- Opt for Haul when building React Native applications and need a customizable build process
Community and Support
Next.js has a larger and more active community, with frequent updates and extensive documentation. Haul, while useful for React Native development, has a smaller community and less frequent updates.
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
Pros of webpack
- Larger ecosystem with more plugins and loaders
- Better documentation and community support
- More flexible and customizable for complex build configurations
Cons of webpack
- Steeper learning curve, especially for beginners
- Can be slower for large projects without proper optimization
- Configuration can become complex and hard to maintain
Code Comparison
webpack configuration:
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{ test: /\.js$/, use: 'babel-loader' },
],
},
};
Haul configuration:
export default {
entry: './index.js',
platforms: ['ios', 'android'],
transformer: {
getTransformOptions: async () => ({
transform: { experimentalImportSupport: false },
}),
},
};
The code comparison shows that Haul's configuration is more focused on React Native specifics, with platform targeting and transformer options. webpack's configuration is more general-purpose, allowing for greater customization but requiring more setup for specific use cases.
Haul is designed specifically for React Native projects, offering a simpler setup process and better out-of-the-box performance for mobile development. However, it has a smaller ecosystem and less flexibility compared to webpack, which can be used for a wider range of web and mobile projects.
The zero configuration build tool for the web. 📦🚀
Pros of Parcel
- Zero configuration out of the box, making it easier to set up and use
- Supports a wider range of file types and assets beyond just JavaScript
- Faster build times due to its multi-core architecture and caching
Cons of Parcel
- Less customizable than Haul for specific React Native requirements
- May require additional setup for certain React Native features
- Larger bundle sizes in some cases compared to Haul
Code Comparison
Haul configuration:
module.exports = {
entry: './index.js',
resolve: {
extensions: ['.js', '.jsx', '.json'],
},
};
Parcel usage (no configuration required):
parcel index.html
Summary
Parcel offers a simpler setup process and broader asset support, making it attractive for general web development. However, Haul is specifically tailored for React Native, providing better integration with its ecosystem. While Parcel boasts faster build times, Haul offers more fine-grained control over the bundling process for React Native projects. The choice between the two depends on the specific needs of the project and the developer's preference for configuration versus convenience.
Next-generation ES module bundler
Pros of Rollup
- More mature and widely adopted in the JavaScript ecosystem
- Excellent tree-shaking capabilities for smaller bundle sizes
- Supports a wide range of output formats (ES modules, CommonJS, UMD, etc.)
Cons of Rollup
- Less focused on React Native specific optimizations
- May require additional configuration for complex React Native projects
- Limited built-in support for code splitting compared to Haul
Code Comparison
Rollup configuration:
export default {
input: 'src/main.js',
output: {
file: 'bundle.js',
format: 'cjs'
}
};
Haul configuration:
export default {
entry: './index.js',
platforms: ['ios', 'android'],
bundles: {
index: {
entry: './index.js',
},
},
};
While both tools serve as bundlers, Rollup is more general-purpose and focuses on efficient bundling for various JavaScript projects. Haul, on the other hand, is specifically designed for React Native applications, offering features tailored to mobile development workflows. Rollup excels in tree-shaking and producing smaller bundles, while Haul provides out-of-the-box support for React Native-specific optimizations and platform-specific configurations.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
A command line tool for developing React Native apps
Notice
We're actively working on a Haul successor, which would provide long awaited features like Hot Module Replacement + React Refresh and better feature-parity with Metro. The version 1.0.0
is already released!
If you're investigating using Haul, we highly recommend giving a Re.pack a go.
If you're already using Haul, we recommend migrating to Re.pack for better developer experience and feature set. The migration process is fairly straighforward, since you now have full access to webpack.config.js
.
Haul is a drop-in replacement for react-native
CLI built on open tools like Webpack. It can act as a development server or bundle your React Native app for production.
@haul-bundler/cli
and other packages under @haul-bundler
scope are a overhaul of haul
package and support only React Native 0.59.0 and above. If you need to support older versions, please check legacy
branch.
@haul-bundler/cli
and other packages requires Node 10 to be installed. If you're running older version, please upgrade to Node 10 LTS or newer.
Features
- Replaces React Native packager to bundle your app
- Access to full webpack ecosystem, using additional loaders and plugins is simple
- Doesn't need watchman, symlinks work nicely
- Helpful and easy to understand error messages
Packages
Getting started
Start by adding Haul as a dependency to your React Native project (use react-native init MyProject
to create one if you don't have a project):
yarn add --dev @haul-bundler/cli
# Traditionalist? No problem:
npm install --save-dev @haul-bundler/cli
To configure your project to use haul, run the following:
yarn haul init
# npm >= 5.2.0 :
npx haul init
# npm < 5.2.0 :
npm install -g npx
npx haul init
This will automatically add the configuration needed to make Haul work with your app, e.g. add haul.config.js
to your project, which you can customize to add more functionality.
Next, you're ready to start the development server:
yarn haul start
# Or:
npx haul start
Finally, reload your app to update the bundle or run your app just like you normally would:
react-native run-ios
Documentation
Check out the docs to learn more about available commands and tips on customizing the webpack configuration.
Limitations
Haul uses a completely different architecture from React Native packager, which means there are some things which don't work quite the same.
- Delta Bundles (RN 0.52+) have minimal support
- Existing
react-native
commands - No support for Hot Module Replacement
The following features are unlikely to be supported in the future:
- Haste module system: use something like babel-plugin-module-resolver instead
- Transpile files under
node_modules
: transpile your modules before publishing, or configure webpack not to ignore them
Made with â¤ï¸ at Callstack
Haul is an open source project and will always remain free to use. If you think it's cool, please star it ð. Callstack is a group of React and React Native geeks, contact us at hello@callstack.com if you need any help with these or just want to say hi!
Like the project? âï¸ Join the team who does amazing stuff for clients and drives React Native Open Source! ð¥
Top Related Projects
🚇 The JavaScript bundler for React Native
The React Framework
A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
The zero configuration build tool for the web. 📦🚀
Next-generation ES module bundler
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot