Migration v3 to v4
This guide covers breaking changes when migrating from chayns-toolkit v3 to v4.
Breaking Changes​
Internal Rsbuild Environments​
The toolkit now uses Rsbuild's native environments system internally. This may affect custom webpack configurations:
- The default config structure has changed due to Rsbuild's environments approach
- Custom webpack modifications via the
webpackfunction intoolkit.config.tsmay behave differently - The
targetparameter is no longer passed to the webpack function
Migration: If you previously used the target parameter to conditionally configure webpack, you
now need to work with Rsbuild's environments. Target-specific adjustments that were previously made
with if (target === 'server') should now be applied to the node environment in the generated
Rsbuild config.
Alternatively, you can now specify a target property ("web" | "node" | "web-worker") per
entry point in output.entryPoints, which simplifies configuration for scenarios like service
workers:
// toolkit.config.ts
export default {
output: {
entryPoints: {
app: {
pathIndex: "./src/index.js",
pathHtml: "./src/index.html",
target: "web",
},
sw: {
pathIndex: "./src/service-worker.js",
target: "web-worker",
},
},
},
}
Test your custom webpack functions thoroughly and adjust them to work with the new config structure.
Test Command Removed​
The test command has been removed from the toolkit. This command was used to run tests with
Jest.
Migration: Use Vitest directly in your project instead. Vitest is the recommended alternative and offers better performance and modern features.
Webpack Public Path for SSR Projects​
Projects with Server-Side Rendering (SSR) enabled will experience a change in the
__webpack_public_path__:
- Previously,
clientwas part of the root directory and included in the publicPath - Now,
clientis no longer part of the publicPath
Migration: If you have SSR enabled and reference remote entries, update paths like:
- ${__webpack_public_path__}v2.remoteEntry
+ ${__webpack_public_path__}client/v2.remoteEntry
This only affects projects with output.serverSideRendering enabled.
SingleBundle Option Removed​
The singleBundle option has been removed completely. This option was already non-functional
since v3.0.0.
Migration: Remove any singleBundle configuration from your toolkit.config.ts.
Development Ports Option Removed​
The development.ports option has been removed from the toolkit configuration.
Migration: Remove any development.ports configuration from your toolkit.config.ts.
New Features​
Version 4 adds support for modern tooling and configurations:
- Linaria - Zero-runtime CSS-in-JS support (automatically enabled when installed)
- React Compiler - Automatic React optimization (automatically enabled when installed, can be
disabled via
output.reactCompiler: false) - Entry Point Targets - Specify
targetper entry point inoutput.entryPoints(e.g., for service workers) - JSX Runtime - Configure React runtime mode (e.g.,
"automatic") - React Required Versions - Override required React versions for Module Federation shared
dependencies via
output.reactRequiredVersions
See the configuration documentation for details on these features.
Summary Checklist​
- Test custom webpack functions (if used) -
targetparameter removed - Migrate from
toolkit testto Vitest - Update remote entry paths if using SSR
- Remove
singleBundleconfig if present - Remove
development.portsconfig if present