Supported Browsers
Starting with v1.1.10, you can now use browserslist to automaticallly configure supported browsers.
Usage
First, install browserslist. Then, update your .swcrc:
{
"env": {
"targets": {
"chrome": "79"
},
"mode": "entry",
"coreJs": 3
}
}Options
browserslist
If you want to use browserlists with SWC, omit targets in your .swcrc:
{
"env": {
"coreJs": 3
}
}browserlists can be configured in multiple ways:
.browserslistrcbrowserslistfield in package.json
You can use path to specify a custom path to load these configuration files.
targets
string | Array<string> | { [string]: string }, defaults to {}.
Describes the environments you support/target for your project. This can either be a browserslist-compatible query:
{
"env": {
"targets": "> 0.25%, not dead"
}
}Or an object of minimum environment versions to support:
{
"env": {
"targets": {
"chrome": "58",
"ie": "11"
}
}
}Example environments:
chromeoperaedgefirefoxsafariieiosandroidnodeelectron
If targets is not specified, SWC uses browserslist to get target information.
path
string, defaults to current directory.pathspecifies the directory to load thebrowserslistmodule and any browserslist configuration files. For example,.browserslistrcorbrowserslistfield in package.json. This can be useful if your build system isn't in the root of your project.
mode
string, defaults toundefined.- Possible values:
usage,entry,undefined(this matchesuseBuiltInsfrom Babel)
The usage mode is currently not as efficient as Babel, yet.
skip
Define ES features to skip to reduce bundle size. For example, your .swcrc could be:
{
"env": {
"skip": ["core-js/modules/foo"]
}
}Additional Options
debug: (boolean) defaults tofalse.dynamicImport: (boolean) defaults tofalse.loose: (boolean) defaults tofalse. Enable loose transformations for any plugins that allow them.include: (string[]) can be acore-jsmodule (es.math.sign) or an SWC pass (transform-spread).exclude: (string[]) can be acore-jsmodule (es.math.sign) or an SWC pass (transform-spread).coreJs: (string) defaults toundefined. The version ofcore-jsto use.shippedProposals: (boolean) defaults tofalse.forceAllTransforms: (boolean) defaults tofalse. Enable all possible transforms.