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', () => {
73
73
noJsonStrings : true ,
74
74
noRuntime : true ,
75
75
} ) ;
76
- expect ( plugins ) . toHaveLength ( 0 ) ;
76
+ expect ( plugins ) . toHaveLength ( 1 ) ;
77
77
} ) ;
78
78
79
79
describe ( 'for @babel/preset-env' , ( ) => {
Original file line number Diff line number Diff line change 22
22
"@babel/plugin-proposal-json-strings" : " ^7.2.0" ,
23
23
"@babel/plugin-syntax-dynamic-import" : " ^7.2.0" ,
24
24
"@babel/plugin-syntax-import-meta" : " ^7.2.0" ,
25
+ "@babel/plugin-transform-destructuring" : " ^7.4.4" ,
25
26
"@babel/plugin-transform-runtime" : " ^7.4.4" ,
26
27
"@babel/preset-env" : " ^7.4.4" ,
27
28
"@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 = {}) => {
101
101
}
102
102
} ) ;
103
103
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
+
104
128
// Return the preset and some of stage-3 plugins
105
129
// We will remove them, once it becomes stage-4, i.e included in preset-env
106
130
return {
You can’t perform that action at this time.
0 commit comments