Re.Pack Documentation
repository·main·Indexed 23 days ago
https://github.com/callstack/repackA toolkit for building React Native applications using Rspack or Webpack instead of the default Metro bundler. Re.Pack enables advanced features like Module Federation for microfrontend architectures and includes tools such as @callstack/repack-dev-server, @callstack/repack-init for automated integration, and specialized plugins for Expo Modules, NativeWind, and react-native-reanimated.
What's inside Re.Pack
- @callstack/repack-dev-server provides the development server capabilities for Repack. It includes namespaces for managing the server lifecycle and various interfaces for handling compiler delegates, HMR (Hot Module Replacement) delegates, and symbolication results.
Overview of Repack plugins
mainRepack provides a variety of plugins categorized into Webpack Plugin Classes and other specialized classes. These plugins allow you to extend the bundling process for specific tasks like code signing, asset resolution, module federation, and development features like React Refresh. Additionally, Repack defines several interfaces and type aliases to ensure type safety when configuring these plugins.Overview of @callstack/repack/client
mainThe@callstack/repack/clientpackage provides the client-side primitives for Repack, specifically focusing on script management, script location, and federation capabilities. It includes namespaces for Federated modules, classes for managing scripts (Script,ScriptManager), and interfaces for resolving and locating scripts within a Webpack-based environment.What is Re.Pack?
mainRe.Pack is a modern toolkit that wraps Rspack and webpack to enable them to work seamlessly with React Native applications. It is designed as a drop-in replacement for Metro, aiming to minimize configuration changes while providing enhanced bundling capabilities.
The toolkit provides:
- React Native-specific plugins and loaders: Handles platform-specific files and assets.
- Integrated development server: Includes Hot Module Replacement (HMR), React Refresh, and debugging support via React Native Devtools.
- Runtime modules: Includes
ScriptManagerfor advanced features like code splitting and Module Federation.
Overview of Re.Pack Node APIs
mainRe.Pack provides a suite of Node.js-side APIs designed to extend Webpack and manage the development lifecycle for React Native applications. These APIs are categorized into Webpack Plugin Classes for build-time transformations, Development Server Classes for HMR and debugging, and various utility functions and interfaces for CLI and build orchestration.What is @callstack/repack-dev-server?
main@callstack/repack-dev-serveris a bundler-agnostic development server designed for React Native applications. It is part of the larger@callstack/repacktoolkit, which provides tools to build React Native applications using Rspack or Webpack.Understand the Re.Pack API structure
mainRe.Pack's API is organized into three main categories based on where they are used in your workflow:
- Bundling and Development Configuration (
@callstack/repack): Use these APIs to configure your build process. This includes Webpack plugins, utilities, and CLI commands. - Client-side Application APIs (
@callstack/repack/client): Use these APIs directly inside your application code. A primary example is theScriptManager. - Development Server (
@callstack/repack-dev-server): A bundler-agnostic development server. Note that this is primarily intended for users integrating bundlers other than Webpack; if you are using Webpack, this API is likely not required.
- Bundling and Development Configuration (
Locate Re.Pack API documentation
mainRe.Pack API documentation is organized into three main categories based on your integration needs:
- Bundling and Development Configuration: Use
@callstack/repackfor Webpack plugins, utilities, and commands used to configure the bundling or development processes. - Application-level (Client) APIs: Use
@callstack/repack/clientfor APIs intended to be used inside your application code, such as theScriptManager. - Development Server: Use
@callstack/repack-dev-serverif you are using a bundler other than Webpack. If you are using Webpack, this API is generally not required.
- Bundling and Development Configuration: Use
DevServer Features
mainRe.Pack 5's dev server supports both Rspack and webpack and includes the following development features:
- Hot Module Reloading: Instantly reflects code changes in the app.
- Source Maps: Enables proper debugging with source code mapping.
- Multiple Platforms: Supports both iOS and Android development.
- Development Tools: Integrated with React Native DevTools.
Understand the Re.Pack API categories
mainRe.Pack's API documentation is organized into two primary categories based on where the code is executed:
- React Native API: Documentation for client-facing APIs that run inside your application code (e.g.,
ChunkManager). - Node API: Documentation for APIs used during the bundling or development process, such as Webpack plugins, utilities, and CLI commands.
- React Native API: Documentation for client-facing APIs that run inside your application code (e.g.,
Explore @callstack/repack API surface
mainThe
@callstack/repackpackage provides a suite of tools for bundling and serving React Native applications using Webpack. The API is organized into several categories:- Namespaces: Core logic for
Federatedmodules andpluginsmanagement. - Webpack Plugin Classes: The primary entry point for integrating Repack into a Webpack configuration is the
RepackPlugin. - CLI command Functions: Programmatic access to the CLI commands
bundleandstart. - Interfaces & Types: Configuration schemas for the plugin (
RepackPluginConfig), dev server (DevServerOptions), and various arguments used during bundling or starting the dev server. - Webpack Utilities: Helper functions for resolving paths, managing assets, and configuring Webpack environments.
- Namespaces: Core logic for
Use the Federated namespace for Module Federation runtime utilities
mainThe
Federatednamespace provides runtime utilities for managing Module Federation. It includes tools for resolving module URLs and dynamically importing modules at runtime. Key components include:createURLResolver: A function to create a custom URL resolver for locating federated modules.importModule: A function to dynamically import a module using the federated runtime.URLResolverConfig: An interface for configuring the URL resolver.URLResolver: A type alias representing the resolver function.