File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
packages/babel-preset-base Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ describe('preset in module', () => {
7373 noJsonStrings : true ,
7474 noRuntime : true ,
7575 } ) ;
76- expect ( plugins ) . toHaveLength ( 0 ) ;
76+ expect ( plugins ) . toHaveLength ( 1 ) ;
7777 } ) ;
7878
7979 describe ( 'for @babel/preset-env' , ( ) => {
Original file line number Diff line number Diff line change 2222 "@babel/plugin-proposal-json-strings" : " ^7.2.0" ,
2323 "@babel/plugin-syntax-dynamic-import" : " ^7.2.0" ,
2424 "@babel/plugin-syntax-import-meta" : " ^7.2.0" ,
25+ "@babel/plugin-transform-destructuring" : " ^7.4.4" ,
2526 "@babel/plugin-transform-runtime" : " ^7.4.4" ,
2627 "@babel/preset-env" : " ^7.4.4" ,
2728 "@babel/preset-react" : " ^7.0.0" ,
Original file line number Diff line number Diff line change @@ -101,6 +101,30 @@ export const preset = (opts: PresetOptions | null = {}) => {
101101 }
102102 } ) ;
103103
104+ // Necessary to include regardless of the environment because
105+ // in practice some other transforms (such as object-rest-spread)
106+ // don't work without it: https://github.com/babel/babel/issues/7215
107+ plugins . push ( [
108+ '@babel/plugin-transform-destructuring' ,
109+ {
110+ // Use loose mode for performance:
111+ // https://github.com/facebook/create-react-app/issues/5602
112+ loose : false ,
113+ selectiveLoose : [
114+ 'useState' ,
115+ 'useEffect' ,
116+ 'useContext' ,
117+ 'useReducer' ,
118+ 'useCallback' ,
119+ 'useMemo' ,
120+ 'useRef' ,
121+ 'useImperativeHandle' ,
122+ 'useLayoutEffect' ,
123+ 'useDebugValue' ,
124+ ] ,
125+ } ,
126+ ] ) ;
127+
104128 // Return the preset and some of stage-3 plugins
105129 // We will remove them, once it becomes stage-4, i.e included in preset-env
106130 return {
You can’t perform that action at this time.
0 commit comments