-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser.js
35 lines (35 loc) · 964 Bytes
/
browser.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
/**
* Babel preset for libraries that will run in the browser, but aren’t
* explicitly using the NextJS preset. Does include `@babel/preset-react`
* however.
*
* Automatically imports core-js polyfills by specifying `'usage'` to
* `@babel/preset-env`. Uses `@babel/plugin-transform-runtime` so that runtime
* support is `require`d in, keeping us from duplicating it in applications that
* import this package.
*
* If this is run with BABEL_ENV=esm, generates ES modules. This is important
* for making packages that can be tree-shook by Webpack.
*/
module.exports = api => ({
presets: [
[
require('@babel/preset-env'),
{
useBuiltIns: 'usage',
corejs: 2,
modules: api.env('esm') ? false : undefined,
},
],
require('@babel/preset-react'),
],
plugins: [
[
require('@babel/plugin-transform-runtime'),
{
helpers: true,
regenerator: true,
},
],
],
});