@babel/preset-env.
How it works
swc’senv configuration block controls core-js integration. You specify:
targets— a browserslist query describing the environments you need to support.mode— how polyfills are injected (entryorusage).coreJs— the exact version of core-js you have installed.
core-js-compat to determine which modules each target environment requires.
Configuration
Add anenv block to your .swcrc file:
.swcrc
Injection modes
- entry mode
- usage mode
In swc rewrites it to import only the modules missing from your targets.
entry mode, swc replaces your top-level core-js import with the specific modules required for your target environments — the same behaviour as @babel/preset-env with useBuiltIns: 'entry'.Place a single import in your application entry point:.swcrc
Choosing a core-js version
SetcoreJs to the exact minor version installed in your project. swc uses this value to look up which modules were available at that version and avoid injecting modules that did not yet exist.
.swcrc
Comparison with Babel
| Feature | swc | Babel (@babel/preset-env) |
|---|---|---|
entry mode | yes | yes |
usage mode | partial | yes (full) |
| Proposal support | via core-js/proposals/* | via proposals: true |
| Speed | faster (Rust) | slower (JS) |
| Accuracy | good | excellent |