Enable and try out some experimental features.
object
boolean
false
Support the new WebAssembly according to the updated specification, it makes a WebAssembly module an async module.
And it is enabled by default when experiments.futureDefaults
is set to true
.
Enable incremental rebuild. true
will try to reuse the results of the last build when rebuild to improve build speed, supports configuration of different stages, the default is enabled.
0.5 removed this options and internally enabled this feature.
boolean | { make?: boolean, emitAsset?: boolean }
true
boolean
true
Once enabled, Rspack will output ECMAScript module syntax whenever possible. For instance, import()
to load chunks, ESM exports to expose chunk data, among others.
boolean
true
Once enabled, Rspack will enable native CSS support, and CSS related parser and generator options.
module.parser["css/auto"]
module.parser.css
module.parser["css/module"]
module.generator["css/auto"]
module.generator.css
module.generator["css/module"]
Note that if you're using style-loader
and css-loader
, you should disable this option because style-loader
and css-loader
will conflict with native CSS.
Use defaults of the next major Rspack and show warnings in any problematic places.
Enable support for top level await, top level await
can only be used in modules with ModuleType is javascript/esm
.
Enabled by default and can be turned off with this configuration.
false
Enable lazy compilation, which can greatly improve the dev startup performance of multi-page applications (MPA) or large single-page applications (SPA). For example, if you have twenty entry points, only the accessed entry points will be built. Or if there are many import()
statements in the project, each module pointed to by import()
will only be built when it is actually accessed.
If set to true, lazy compilation will be applied by default to both entry modules and modules pointed to by import()
. You can decide whether it applies only to entries or only to import()
through a configuration object. The entries
option determines whether it applies to entries, while the import()
option determines whether it applies to import()
.
In addition, you can also configure a test
parameter for more fine-grained control over which modules are lazily compiled. The test
parameter can be a regular expression that matches only those modules that should be lazily compiled. It can also be a function where the input is of type 'Module' and returns a boolean value indicating whether it meets the criteria for lazy compilation logic.
The current lazy compilation aligns with the webpack implementation, and is still in the experimental stage. In some scenarios, lazy compilation might not work as expected, or the performance improvement may be insignificant.
If you do not use Rspack's own dev server and instead use your own server as the dev server, you generally need to add another client modules in the entry configuration to enable capabilities such as HMR. It is best to exclude these client module from lazy compilation by configuring test
.
If not excluded and lazy compilation of entry is enabled, this client will not be compiled when accessing the page for the first time, so an additional refresh is needed to make it take effect.
For example:
Type: object
Default: See options down below for details
Used to control whether to enable Rspack future default options, check out the details here.
Type: boolean
Introduced in Version: v0.3.5
Enabled by Default in Version: v0.4.0
Removed in Version: v0.5.0
Description:
This feature primarily addresses three categories of problems: builtins code transformation features, target, and custom Rule.type.
These configuration items should apply to the selected corresponding modules. Using builtins.(relay|react|emotion|pluginImport|decorator)
is equivalent to enabling them globally. This approach is not recommended, so it will be deprecated.
After enabling disableTransformByDefault
, the aforementioned configuration items will become invalid. For a migration guide, refer to builtin:swc-loader/options.rspackExperiments.
For instance, if we want the emotion
transformation to apply to all jsx
files:
For the decorator configuration, you can find and replace in the SWC code, such as legacyDecorator, decoratorMetadata.
In previous versions, we typically set target: ["web", "es5"]
to produce web-compatible and downgraded code. Now, when the disableTransformByDefault
configuration item is enabled, the target
will only be used to control runtime code (except for user-written code, Rspack generated code within node_modules, like chunk loading, etc.)
This aligns with webpack's plugin-based design philosophy. You can migrate using builtin:swc-loader
's env
or target
, and precisely control the modules that need to be transpiled:
Note: When disableTransformByDefault
is not enabled, the rspack's built-in transpiler will transpile all content under node_modules
. Therefore, after enabling disableTransformByDefault
, with builtin:swc-loader
combined with exclude: /node_modules/
, ensure the code in node_modules
has been downgraded; otherwise, compatibility issues may arise.
These types have been removed:
"typescript"
"jsx"
"tsx"
For JS-related types, only the following will be retained:
"javascript/auto"
"javascript/esm"
"javascript/dynamic"
With disableTransformByDefault
enabled, Rspack will only support input compliant with web standards, aligning with webpack's design philosophy.
After discussions with webpack, both webpack and Rspack will offer more out-of-the-box configurations to support non-standard inputs like TypeScript.
Since files with the extensions jsx
, tsx
, and ts
are implicitly set for transpilation, an error will be prompted when disableTransformByDefault
is enabled. You can migrate like this:
boolean
This feature enables the new resolver implementation.
The new resolver also supports tsconfig project references defined in tsconfig-paths-webpack-plugin. See resolve API for details.
boolean
newTreeshaking has been enabled and cannot go back to the deprecated tree shaking algorithm since version 0.7.0.
This feature enables the new treeshaking implementation the same as webpack, which would generate more efficient and smaller code
boolean
When this feature is not enabled, options.entry
can still make valid changes after compiler.hooks.afterEnvironment
is called.
With this feature turned on, options.entry
will no longer make valid changes after compiler.hooks.afterEnvironment
call. This behavior is consistent with Webpack, so this configuration is unaffected for users developing applications in Rspack, but should be noted by developers of Rspack plugins or upper-level frameworks.
A common scenario is to prepend entries after the Compiler has been created:
Modifications will not take effect when this configuration is turned on, and you need to make the following changes: