Re.Pack 5 introduces support for Rspack, a high-performance webpack alternative with a highly compatible API. This migration guide focuses solely on migrating from V4 to V5 while continuing to use webpack.
If you're interested in using Rspack (which is encouraged), we recommend first completing the migration to V5 with webpack and then following our separate webpack to Rspack migration guide.
Plugins that are part of RepackPlugin
are considered internal and are not covered by this migration guide.
package.json
The first step is to update the Re.Pack in the devDependencies
section of your package.json
:
You can also remove babel-loader
from your devDependencies
as Re.Pack 5 now includes it by default:
While not necessary, for the best experience with Re.Pack 5,
we recommend updating your webpack
and terser-webpack-plugin
dependencies to their latest versions:
After updating the project dependencies, run the install command of your package manager:
react-native.config.js
Since Re.Pack 5 now supports multiple bundlers (webpack and Rspack),
you need to specify that you want to use webpack commands explicitly.
Update your react-native.config.js
in a following way:
Below are the changes that you need to be aware of when migrating to Re.Pack 5. Most of the changes revolve around reducing the amount of configuration needed.
In V5 we've significantly simplified webpack configuration templates. Many defaults are now configured out of the box, reducing the need for explicit configuration and making your configuration files much cleaner and easier to maintain.
For a comprehensive guide on configuring webpack using Re.Pack 5, including all available options, defaults, and configuration variants, please refer to our Configuration guide.
A strict configuration cascade system was introduced to provide clear and predictable configuration resolution:
CLI arguments now always take the highest precedence and cannot be overridden by config files. This change aligns Re.Pack behavior with other similar CLI tools. Make sure to update your configuration with this in mind.
For more details about the configuration system and available options and their defaults, see our Configuration guide.
devtool
option is now used to configure sourcemapsWe've changed how sourcemaps are configured to align better with webpack's native configuration. The devtool
option is now used to control the behavior of generated sourcemaps, replacing the previous RepackPlugin
configuration. Please make sure to remove any devtool: false
from your configuration to keep sourcemaps enabled.
devtool: 'source-map'
is now the default value in V5.
The sourcemap handling is now managed by a dedicated internal SourceMapPlugin
that's included in the RepackPlugin
by default - you don't need to add it separately.
getInitializationEntries
was removedThe getInitializationEntries
helper function was removed as initialization entries are now configured automatically.
You can now simplify your entry configuration:
reactRefreshLoader
We've changed how the React Refresh transformation is handled to make it compatible with both Rspack and webpack. The transformation now relies on @rspack/plugin-react-refresh
which is shipped with Re.Pack and is configured automatically in the RepackPlugin
.
You can simplify your babel-loader
rule by removing the react-refresh/babel
plugin from options:
We've significantly reduced the required RepackPlugin
configuration. Several options have been removed as they were redundant, and others have become optional as they can be inferred from your webpack configuration.
The following options have been removed:
The following options are now optional:
The plugin configuration object is now entirely optional. In most cases, you can use the minimal setup:
For available options and their defaults, see the RepackPlugin API documentation.
Since output-related configuration options have been removed from RepackPlugin
, the following properties: bundleFilename
, sourceMapFilename
, assetsPath
are now controlled exclusively through their respective CLI flags - see bundle command documentation.
assets-loader
configurationThe assets-loader
configuration has been simplified:
devServerEnabled
was removed, it's now inferred automatically from configurationplatform
was made optional and by default is inferred from configurationscalableAssetExtensions
is now optional and defaults to Repack.SCALABLE_ASSETS
You can now simplify your assets loader configuration:
JavaScriptLooseModePlugin
was removedThe JavascriptLooseMode
plugin has been removed as it was no longer relevant. @react-native/babel-preset
is now the exclusive handler for loose mode configuration.
getPublicPath
utility function is now deprecatedThe getPublicPath
utility function has been deprecated and now acts as a functional no-op. The default values are now configured out of the box, removing need for this utility. You can safely remove any usage of this utility:
Legacy remote debugging support has been removed in favor of the new React Native DevTools, which is now enabled by default. The new debugger provides a better debugging experience specifically tailored for React Native applications and will be the only supported debugger going forward.
--silent
flag from start commandThe --silent
CLI flag has been removed from the start command. To silence the output, you can use shell redirection instead:
--reverse-port
to--no-reverse-port
in start commandThe --reverse-port
CLI option has been replaced with --no-reverse-port
. This change makes it clearer that port reversing is enabled by default and the flag is used to disable it.
--webpackConfig
in favor of--config
The --webpackConfig
CLI option has been deprecated in favor of the new --config
option. This change aligns the option name with other bundler configurations. While --webpackConfig
will continue to work for now, we recommend updating your scripts to use --config
instead: