CC 4.0 License
The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.
The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.
Target
The target option describes the environment in which the output code will run. Rspack uses it to determine which platform APIs and ECMAScript syntax the target environment supports, then sets compatible defaults for module resolution conditions, externals presets, and chunk loading. The runtime code generated by Rspack also uses syntax supported by the target environment.
When their own target options are omitted, Rspack's built-in loaders and minimizers can also inherit defaults from target. However, target does not add polyfills for missing APIs.
- Type:
- Default:
browserslistwhen the project includes a standard Browserslist configuration; otherwiseweb
Recommended configurations
Browsers
For browser applications, define the supported browsers in a shared Browserslist configuration (see Browserslist for details):
Use the following configuration:
When the project includes a standard Browserslist configuration, target defaults to browserslist, so the explicit option can be omitted. Keeping it explicit makes the intended runtime policy clearer.
Syntax version
If you do not use Browserslist and want browser output whose runtime uses at most ES2020 syntax, combine the platform and syntax targets (see Target arrays for details):
web selects the platform. es2020 limits the syntax used by the Rspack runtime; built-in transforms that inherit target also use it as their default output target.
Node.js
For a Node.js application, specify the oldest Node.js version used in deployment:
Replace 22 with the version your application supports. A versioned target lets Rspack use runtime features known to be available in that release. An unversioned node target uses more conservative compatibility assumptions.
Web workers
For code that runs in a Web Worker, Shared Worker, or Service Worker, use:
This selects worker globals and chunk-loading behavior instead of browser APIs that depend on document.
Common values
In the patterns below, X and Y are version numbers, and brackets indicate optional parts. For example, node22, node22.12, and electron34-renderer are valid values; the brackets are not typed literally.
- Supported ECMAScript targets are
es3,es5, andes2015throughes2025. - An
esXtarget describes syntax capabilities, not a runtime platform. It should usually be combined with a platform target such aswebornode. - Versions can be specified for Node.js, Electron, and NW.js targets.
Effects
Output defaults
Rspack derives several defaults from the selected target, including:
- module resolution conditions such as
browser,node, andelectron output.environment, chunk format, chunk loading, worker loading, and WebAssembly loading- externals presets, such as keeping Node.js or Electron built-in modules external
- platform globals and capabilities, such as
document,require,global, andimportScripts
These are defaults. You can override the corresponding options when the target preset does not match a specific output requirement.
Source transforms
target directly controls the syntax that Rspack may use in its generated runtime. It does not, by itself, lower the syntax of every application module.
When used without an explicit transform target, the following built-in tools inherit a compatible default from target:
builtin:swc-loaderderivesenv.targetsorjsc.targetbuiltin:lightningcss-loaderderives browser targets when availableSwcJsMinimizerRspackPluginderives its ECMAScript targetLightningCssMinimizerRspackPluginderives browser targets when available
Only code processed by these tools receives their transformations. Code processed by Babel follows Babel's own configuration. Built-in tools may also limit inherited targets to the versions they support.
Target arrays
A target array applies the common subset of features supported by every item to a single compilation. A typical combination adds an ECMAScript constraint to a platform target:
A target array does not create a separate compilation for each environment. Combining conflicting platform targets such as ['web', 'node'] can leave defaults such as the chunk format indeterminate.
When you need separate browser and Node.js artifacts, export multiple configurations instead:
Rspack runs these configurations through MultiCompiler and creates a separate compilation for each one.
Browserslist
The browserslist target uses a Browserslist query to infer both the platform and supported ECMAScript features. Browser queries select a web target, while Node.js queries select a Node.js target with matching runtime capabilities.
Rspack recognizes the following forms:
The nearest configuration can come from a browserslist or .browserslistrc file, or from the browserslist field in package.json. An explicitly selected browserslist target can also use the BROWSERSLIST environment variable. Rspack supports browser and Node.js queries; Electron queries are not supported.
Baseline
Rspack 2.1.9 and later support Baseline queries. For example, the following target includes browsers that support every feature in Baseline Widely Available:
You can also use a year query such as baseline 2024, or a fixed-date query such as baseline widely available on 2025-05-01. See Use Baseline with Browserslist for details.
Limitations
Rspack uses browserslist-rs, which does not yet implement every Browserslist feature. The following queries are currently unsupported:
- custom usage queries, such as
> 0.5% in my stats - coverage queries, such as
cover 99.5% in my stats
Disable target
Set target to false only when you need to replace target inference with custom settings. This disables all target-derived defaults.
The following is a minimal configuration that uses the CommonJS chunk format:
A configuration containing only target: false will fail because Rspack cannot infer output.chunkFormat. Set output.chunkFormat explicitly, then configure other environment-dependent options, such as output.environment, chunk loading, resolution conditions, and externals presets, as needed.
Related options
output.environmentoverrides target-derived runtime syntax capabilities.output.chunkFormatandoutput.chunkLoadingoverride how chunks are emitted and loaded.externalsPresetscontrols which platform built-ins are treated as external.resolve.conditionNamescontrols which conditions in theexportsfield ofpackage.jsonare used during resolution.- Plugin authors can read the resolved target from
compiler.target.

