Skip to content

Commit 55ec91b

Browse files
authored
docs: rework Introduction (#1236)
1 parent c695ae3 commit 55ec91b

1 file changed

Lines changed: 27 additions & 35 deletions

File tree

website/src/latest/docs/getting-started/introduction.md

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,47 @@
22

33
Before diving deep into Re.Pack and introducing it into project, it's important to understand when and why to use Re.Pack and how does it compare with alternatives.
44

5-
## What Re.Pack actually is?
5+
## About Re.Pack
66

7-
React Native environment and Browser environment have differences. React Native needs to run additional JS setup/init code so that it's usable at all. There's a great discrepancy between available APIs. In React Native we also have platform specific files — e.g.: `.ios.js`, `.android.js` and so on.
7+
Re.Pack is a modern toolkit that wraps Rspack and webpack to make them work seamlessly with React Native applications.
88

9-
Putting all the above together, makes webpack **unable to produce bundle** at all due to build errors and then the **bundle produced by webpack is unusable** by default.
9+
The toolkit includes:
1010

11-
Therefore, we need to make changes to webpack configuration and change how and what webpack puts into the final bundle. All these necessary changes are encapsulated inside Re.Pack in form of webpack plugins.
11+
- **React Native-specific plugins and loaders** that handle platform differences (platform specific files, assets, etc.)
12+
- **Integrated development server** with Hot Module Replacement (HMR) + React Refresh, and debugging capabilities through React Native Devtools
13+
- **Runtime modules** like ScriptManager for advanced features like code splitting and Module Federation
1214

13-
So to answer the question:
14-
15-
:::info Re.Pack is what makes webpack and webpack-produced bundle usable in React Native application.
16-
:::
17-
18-
## Why & when
19-
20-
The main feature of Re.Pack is webpack and its ecosystem of: loaders, plugins and support for various features like symlinks, aliases etc.
21-
22-
However, because Re.Pack is based on webpack, **it is targeted towards advanced users who already know how to use webpack** and want to leverage webpack ecosystem.
23-
24-
:::tip
15+
## Design goals
2516

26-
If you're just starting with React Native, it's better to stick with the default solution — Metro, since you probably won't benefit much from switching to webpack and Re.Pack.
17+
Re.Pack is designed to be a **drop-in replacement for Metro** with the primary goal of making migration as easy as possible. The toolkit aims to:
2718

28-
:::
19+
- Provide seamless integration with existing React Native projects
20+
- Maintain compatibility with Metro's expected behavior while offering enhanced capabilities
21+
- Minimize configuration changes needed during migration
22+
- Offer a smooth transition path from Metro to advanced bundling features
2923

30-
## Design goals
24+
This approach ensures teams can adopt Re.Pack incrementally, starting with basic Metro replacement and gradually leveraging advanced features like Module Federation and custom webpack configurations as needed.
3125

32-
1. Re.Pack was design for the advanced users, as such it exposes _low-level API_ in form of webpack plugins and utilities, meaning we only give you the tools you need to build React Native application, but the actual configuration and maintenance of said config is on your shoulders.
33-
2. To support wide variety of use cases and give you as much control as possible, Re.Pack is written to allow you to bundle and run development server directly from webpack CLI as well by using React Native CLI. While it's recommended to stick with React Native CLI, you can pick one you want to go with.
34-
3. Based on our experience with [Haul](https://github.com/callstack/haul), we shift as much responsibility onto you as possible, so that we can develop features, move at reasonable pace and reduce maintenance cost. Therefore, Re.Pack should be used by seasoned React Native developers with at least basic experience with webpack.
26+
## Why & when
3527

36-
## Re.Pack vs Metro
28+
Re.Pack is particularly valuable in these scenarios:
3729

38-
Both Metro and Re.Pack have different approaches for the similar problem — bundling JavaScript code for your React Native application.
30+
### 1. **Microfrontends with Module Federation**
31+
Re.Pack provides first-class support for Module Federation, enabling you to build microfrontend architectures where different teams can develop and deploy parts of your mobile app independently.
3932

40-
The main distinction is that, Metro is custom-built solution and Re.Pack uses webpack. As a result there few differences that you should consider when deciding the solution to use:
33+
### 2. **Advanced Tree Shaking**
34+
Leverage state-of-the-art tree shaking capabilities that can significantly reduce bundle size by eliminating unused code more effectively than Metro, helping you save valuable bytes in your final application bundle.
4135

42-
- Metro is slightly faster - it has less overhead compared to webpack. Metro trades configurability for performance, whereas with webpack it's the other way around.
43-
- Webpack configuration options and ecosystem allows for much greater control and support for advanced use-cases.
36+
### 3. **High Customizability**
37+
Access to the full Rspack/webpack ecosystem means extensive customization options through loaders, plugins, and advanced configuration. You can implement complex build requirements that aren't possible with Metro.
4438

45-
## Re.Pack vs Haul
39+
### 4. **Build Performance**
40+
Rspack's Rust-based architecture provides significant performance improvements for large codebases, especially when combined with advanced caching strategies.
4641

47-
Re.Pack is a direct successor to [Haul](https://github.com/callstack/haul). Therefore we took the experience we gained with Haul while making rather major changes in the approach:
42+
Re.Pack is designed for teams that need these advanced capabilities and have developers willing to familiarize themselves with alternative bundling tools.
4843

49-
- Re.Pack has smaller footprint and allows for greater level of customization, since you have direct access to the webpack config.
50-
- Re.Pack supports Hot Module Replacement + React Refresh, whereas Haul does not.
51-
- Haul supports legacy implementation of multi-bundling (though it requires to alter React Native source code, so we don't recommend that), whereas Re.Pack supports [Code Splitting](/docs/features/code-splitting), including [Module Federation](/docs/features/module-federation).
52-
- Re.Pack delivers better Developer Experience by providing you with more meaningful logs, easier usage and more customizability.
44+
:::tip Don't drop Metro just yet!
5345

54-
## Re.Pack vs `@callstack/nativepack`
46+
If you're just starting with React Native, consider sticking with Metro - the default bundler for React Native applications. Re.Pack shines when you have specific requirements that Metro cannot address but is not compatible with tools that assume Metro as a bundler present in the project setup.
5547

56-
Re.Pack is a rebranded version of `@callstack/nativepack`, which was a temporary name to avoid infringing on webpack trademark. They are both the same projects.
48+
:::

0 commit comments

Comments
 (0)