Re.Pack Documentation

repository·main·Indexed 23 days ago

https://github.com/callstack/repack

A 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.

Tokens
158.2K
Snippets
319
Records
988
Agent score
82%

What's inside Re.Pack

  1. Overview of Repack plugins

    main
    Repack 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.
  2. Overview of @callstack/repack/client

    main
    The @callstack/repack/client package 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.
  3. What is Re.Pack?

    main

    Re.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 ScriptManager for advanced features like code splitting and Module Federation.
  4. Overview of Re.Pack Node APIs

    main
    Re.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.
  5. Understand the Re.Pack API structure

    main

    Re.Pack's API is organized into three main categories based on where they are used in your workflow:

    1. Bundling and Development Configuration (@callstack/repack): Use these APIs to configure your build process. This includes Webpack plugins, utilities, and CLI commands.
    2. Client-side Application APIs (@callstack/repack/client): Use these APIs directly inside your application code. A primary example is the ScriptManager.
    3. 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.
  6. Locate Re.Pack API documentation

    main

    Re.Pack API documentation is organized into three main categories based on your integration needs:

    1. Bundling and Development Configuration: Use @callstack/repack for Webpack plugins, utilities, and commands used to configure the bundling or development processes.
    2. Application-level (Client) APIs: Use @callstack/repack/client for APIs intended to be used inside your application code, such as the ScriptManager.
    3. Development Server: Use @callstack/repack-dev-server if you are using a bundler other than Webpack. If you are using Webpack, this API is generally not required.
  7. DevServer Features

    main

    Re.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.
  8. Understand the Re.Pack API categories

    main

    Re.Pack's API documentation is organized into two primary categories based on where the code is executed:

    1. React Native API: Documentation for client-facing APIs that run inside your application code (e.g., ChunkManager).
    2. Node API: Documentation for APIs used during the bundling or development process, such as Webpack plugins, utilities, and CLI commands.
  9. Explore @callstack/repack API surface

    main

    The @callstack/repack package 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 Federated modules and plugins management.
    • 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 bundle and start.
    • 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.
  10. Use the Federated namespace for Module Federation runtime utilities

    main

    The Federated namespace 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.