-
Notifications
You must be signed in to change notification settings - Fork 11
/
.babelrc
85 lines (85 loc) · 2.68 KB
/
.babelrc
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
// This file is formatted as JSON5 https://github.com/json5/json5
{
presets: [
// Transforms JSX
'@babel/preset-react',
// Transforms ES6 code and import/export statements
[
'@babel/preset-env',
{
targets: {
electron: '2.0.0',
node: '8',
browsers: ['last 2 versions', 'not ie < 11']
},
// Only use polyfills necessary for target env
useBuiltIns: 'usage',
corejs: 3,
shippedProposals: true
}
]
],
plugins: [
// Reduces bundle size by sharing babel helpers between files
['@babel/plugin-transform-runtime', { corejs: 3 }],
// Allows simpler defineMessages with react-intl
// https://github.com/akameco/babel-plugin-react-intl-auto
['react-intl-auto', { filebase: true, removePrefix: 'src' }],
// Turns flow type annotations into React.PropTypes for runtime
// type checking. Deadcode wraps in NODE_ENV checks
// ['flow-react-proptypes', { deadCode: true }],
// Converts flow annotations into comment syntax
// https://flow.org/en/docs/types/comments/
'@babel/plugin-transform-flow-comments',
// Allows directly declaring props and methods on a class instead of
// binding them to `this` in the constructor
'@babel/plugin-proposal-class-properties',
// Allows short hand of Object.assign({}, a) as {...a}
// useBuiltIns should be fine for our use-case, but could cause un-expected
// results if trying to spread objects with a prototype chains. See
// https://exploringjs.com/es6/ch_oop-besides-classes.html#sec_assigning-vs-defining-properties
[
'@babel/plugin-proposal-object-rest-spread',
{ loose: true, useBuiltIns: true }
]
],
env: {
esm: {
plugins: [
[
'react-intl-auto',
{ filebase: true, extractComments: false, removePrefix: 'src' }
],
// Creates shorter message hashes to reduce bundle size
'react-intl-id-hash'
],
presets: [
[
'@babel/preset-env',
{
targets: {
// Our main target for these modules is the mapeo-desktop electron
// application.
electron: '2.0.0'
},
modules: false,
// Only use polyfills necessary for target env
useBuiltIns: 'usage',
corejs: 3,
shippedProposals: true
}
]
]
},
cjs: {
plugins: [
[
'react-intl-auto',
{ filebase: true, extractComments: false, removePrefix: 'src' }
],
// Creates shorter message hashes to reduce bundle size
'react-intl-id-hash'
]
}
}
}