@@ -84,17 +84,11 @@ module.exports = function(api, opts) {
84
84
// Latest stable ECMAScript features
85
85
require ( '@babel/preset-env' ) . default ,
86
86
{
87
- // We want Create React App to be IE 9 compatible until React itself
88
- // no longer works with IE 9
89
- targets : {
90
- ie : 9 ,
91
- } ,
92
- // Users cannot override this behavior because this Babel
93
- // configuration is highly tuned for ES5 support
94
- ignoreBrowserslistConfig : true ,
95
- // If users import all core-js they're probably not concerned with
96
- // bundle size. We shouldn't rely on magic to try and shrink it.
97
- useBuiltIns : false ,
87
+ // Allow importing core-js in entrypoint and use browserlist to select polyfills
88
+ useBuiltIns : 'entry' ,
89
+ // Set the corejs version we are using to avoid warnings in console
90
+ // This will need to change once we upgrade to corejs@3
91
+ corejs : 3 ,
98
92
// Do not transform modules to CJS
99
93
modules : false ,
100
94
// Exclude transforms that make all code slower
@@ -103,6 +97,29 @@ module.exports = function(api, opts) {
103
97
] ,
104
98
] . filter ( Boolean ) ,
105
99
plugins : [
100
+ // Necessary to include regardless of the environment because
101
+ // in practice some other transforms (such as object-rest-spread)
102
+ // don't work without it: https://github.com/babel/babel/issues/7215
103
+ [
104
+ require ( '@babel/plugin-transform-destructuring' ) . default ,
105
+ {
106
+ // Use loose mode for performance:
107
+ // https://github.com/facebook/create-react-app/issues/5602
108
+ loose : false ,
109
+ selectiveLoose : [
110
+ 'useState' ,
111
+ 'useEffect' ,
112
+ 'useContext' ,
113
+ 'useReducer' ,
114
+ 'useCallback' ,
115
+ 'useMemo' ,
116
+ 'useRef' ,
117
+ 'useImperativeHandle' ,
118
+ 'useLayoutEffect' ,
119
+ 'useDebugValue' ,
120
+ ] ,
121
+ } ,
122
+ ] ,
106
123
// Polyfills the runtime needed for async/await, generators, and friends
107
124
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
108
125
[
0 commit comments