Skip to content

Commit c34c743

Browse files
skogingianschmitz
authored andcommitted
Update dependencies babel preset with recent changes (#6887)
* Update dependencies preset to support browserslist * Loose mode array destructuring for hooks in dependencies
1 parent c80e3fe commit c34c743

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

packages/babel-preset-react-app/dependencies.js

+28-11
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,11 @@ module.exports = function(api, opts) {
8484
// Latest stable ECMAScript features
8585
require('@babel/preset-env').default,
8686
{
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,
9892
// Do not transform modules to CJS
9993
modules: false,
10094
// Exclude transforms that make all code slower
@@ -103,6 +97,29 @@ module.exports = function(api, opts) {
10397
],
10498
].filter(Boolean),
10599
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+
],
106123
// Polyfills the runtime needed for async/await, generators, and friends
107124
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
108125
[

0 commit comments

Comments
 (0)