forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
babel.config.js
105 lines (103 loc) · 3.12 KB
/
babel.config.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const packageJSON = require('./package.json')
const TARGETS_NODE = '12.16'
const TARGETS_BROWSERS = ['defaults', 'not IE 11', 'not IE_Mob 11']
// Warning! Recommended to specify used minor core-js version, like corejs: '3.6',
// instead of corejs: '3', since with '3' it will not be injected modules
// which were added in minor core-js releases.
// https://github.com/zloirock/core-js/blob/master/README.md#babelpreset-env
const CORE_JS_VERSION = '3.6'
// We use the recommended babel configuration for monorepos, which is a base directory
// `babel.config.js` file, but then use a per-project `.babelrc.js` file.
// Learn more: https://babeljs.io/docs/en/config-files#monorepos
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: { node: TARGETS_NODE },
useBuiltIns: 'usage',
corejs: {
version: CORE_JS_VERSION,
// List of supported proposals: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#ecmascript-proposals
proposals: true,
},
},
],
'@babel/preset-react',
'@babel/typescript',
],
plugins: [
[
'babel-plugin-module-resolver',
{
alias: {
src: './src',
},
},
],
/**
* NOTE
* Experimental decorators are used in `@redwoodjs/structure`.
* https://github.com/tc39/proposal-decorators
**/
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'@babel/plugin-transform-runtime',
{
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#core-js-aliasing
// Setting the version here also requires `@babel/runtime-corejs3`
corejs: { version: 3, proposals: true },
// https://babeljs.io/docs/en/babel-plugin-transform-runtime/#version
// Transform-runtime assumes that @babel/[email protected] is installed.
// Specifying the version can result in a smaller bundle size.
version: packageJSON.devDependencies['@babel/runtime-corejs3'],
},
],
],
overrides: [
// ** WEB PACKAGES **
{
test: [
'./packages/router',
'./packages/web/',
'./packages/auth/',
'./packages/forms/',
],
presets: [
[
'@babel/preset-env',
{
targets: {
browsers: TARGETS_BROWSERS,
},
},
],
],
plugins: [
[
'babel-plugin-auto-import',
{
declarations: [
{
// import { React } from 'react'
default: 'React',
path: 'react',
},
{
// import { PropTypes } from 'prop-types'
default: 'PropTypes',
path: 'prop-types',
},
],
},
],
],
},
],
// Ignore test directories when we're not testing
ignore:
process.env.NODE_ENV === 'test'
? []
: [/\.test\.(js|ts)/, '**/__tests__', '**/__mocks__', '**/__snapshots__'],
}