-
Notifications
You must be signed in to change notification settings - Fork 3
/
.babelrc.js
49 lines (44 loc) · 1.44 KB
/
.babelrc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict'
/**
* @file Compilation configuration
*
* Library is compiled to two targets before publishing, a CommonJS version and
* an ESModules version. Both are compiled to work across the maximum number of
* active browsers using Browserslist "defaults" target
* (https://github.com/browserslist/browserslist#best-practices).
*
* Polyfills are _not_ included in the compilation: There is no clear guidance
* on whether they should be included and most libraries do not include them.
* This is probably because most current frameworks, like Next.js and Create
* React App, include their own set of sensible polyfills.
*/
const { BABEL_ENV } = process.env
const targets = BABEL_ENV === 'test' ? 'node 16' : 'defaults' // Testing runs in Node
const useESM = BABEL_ENV === 'browser'
module.exports = {
// Base configs are used by ESLint babel parser
presets: [
[
'@babel/preset-env',
{
bugfixes: true,
modules: useESM ? false : 'commonjs',
targets,
exclude: [
'transform-typeof-symbol', // https://github.com/facebook/create-react-app/issues/5277
],
},
],
['@babel/preset-react', { runtime: 'automatic' }],
'@babel/preset-typescript',
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
useESModules: useESM,
version: '^7.17.0', // Default is 7.0, include current version for smaller bundle improvements
},
],
],
}