Skip to content

Commit

Permalink
docs: documented how to opt out of @babel-preset-env
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Nov 17, 2021
1 parent 845e54f commit c791d88
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Tooling in the JavaScript ecosystem can often be complex, and this is very much
- [Combining Typescript with a Browserslist](#combining-typescript-with-a-browserslist)
- [Using the plugin with Typescript, but without Browserslists](#using-the-plugin-with-typescript-but-without-browserslists)
- [Combining Typescript with Babel](#combining-typescript-with-babel)
- [`@babel/preset-env` behavior (and how to opt out)](#babelpreset-env-behavior-and-how-to-opt-out)
- [Special handling for minification plugins/presets](#special-handling-for-minification-pluginspresets)
- [`@babel/runtime` and external helpers](#babelruntime-and-external-helpers)
- [`@babel/runtime` and polyfills](#babelruntime-and-polyfills)
Expand Down Expand Up @@ -331,6 +332,19 @@ Don't worry if you don't, `rollup-plugin-ts` will warn you about exactly which d
Once you're done installing peer dependencies, that's it! The plugin will attempt to locate a `babel.config.js` file or a `.babelrc` file and use the options, plugins, and presets found there.
By default, some combination of presets and plugins will be applied depending on the config options you provide, while others will be forced at all times for interoperability reasons. See [this section](#default-babel-plugins) for more details.

#### `@babel/preset-env` behavior (and how to opt out)

By default, when using Babel as the transpiler, `@babel/preset-env` will be used as a preset that respects the browserslist that was either provided directly as a plugin option, or was resolved inside the root of your project, or was computed based on your `tsconfig.json` file.

If you don't want this behavior, simply pass the `browserslist: false` option to the plugin. Doing so will never apply `@babel/preset-env` and not apply any additional syntax transformations:

```javascript
ts({
transpiler: "babel",
browserslist: false
});
```

#### Special handling for minification plugins/presets

This plugin will apply syntax transformations from Babel presets and plugins on a file-by-file basis. However, if a minification-related plugin or preset such as [babel-preset-minify](https://github.com/babel/minify/tree/master/packages/babel-preset-minify) is found within the Babel options,
Expand Down

0 comments on commit c791d88

Please sign in to comment.