@@ -124,8 +124,8 @@ const getPreset = (src, options) => {
124
124
extraPlugins . push ( [
125
125
require ( '@babel/plugin-transform-named-capturing-groups-regex' ) ,
126
126
] ) ;
127
- // Needed for regenerator for hermes-canary
128
- if ( isHermesCanary ) {
127
+ // Needed for regenerator
128
+ if ( isHermes && options . dev ) {
129
129
extraPlugins . push ( [
130
130
require ( '@babel/plugin-transform-optional-catch-binding' ) ,
131
131
] ) ;
@@ -158,17 +158,15 @@ const getPreset = (src, options) => {
158
158
) {
159
159
extraPlugins . push ( [ require ( '@babel/plugin-transform-react-display-name' ) ] ) ;
160
160
}
161
- // Check !isHermesStable because this is needed for regenerator for
162
- // hermes-canary
163
- if ( ! isHermesStable && ( isNull || src . indexOf ( '?.' ) !== - 1 ) ) {
161
+ // Also check options.dev because this is needed for regenerator
162
+ if ( ( ! isHermes || options . dev ) && ( isNull || src . indexOf ( '?.' ) !== - 1 ) ) {
164
163
extraPlugins . push ( [
165
164
require ( '@babel/plugin-transform-optional-chaining' ) ,
166
165
{ loose : true } ,
167
166
] ) ;
168
167
}
169
- // Check !isHermesStable because this is needed for regenerator for
170
- // hermes-canary
171
- if ( ! isHermesStable && ( isNull || src . indexOf ( '??' ) !== - 1 ) ) {
168
+ // Also check options.dev because this is needed for regenerator
169
+ if ( ( ! isHermes || options . dev ) && ( isNull || src . indexOf ( '??' ) !== - 1 ) ) {
172
170
extraPlugins . push ( [
173
171
require ( '@babel/plugin-transform-nullish-coalescing-operator' ) ,
174
172
{ loose : true } ,
@@ -196,7 +194,7 @@ const getPreset = (src, options) => {
196
194
extraPlugins . push ( [ require ( '@babel/plugin-transform-react-jsx-self' ) ] ) ;
197
195
}
198
196
199
- if ( isHermesCanary ) {
197
+ if ( isHermes && options . dev ) {
200
198
const hasForOf =
201
199
isNull || ( src . indexOf ( 'for' ) !== - 1 && src . indexOf ( 'of' ) !== - 1 ) ;
202
200
if ( hasForOf ) {
@@ -216,11 +214,11 @@ const getPreset = (src, options) => {
216
214
require ( '@babel/plugin-transform-runtime' ) ,
217
215
{
218
216
helpers : true ,
219
- regenerator : ! isHermesStable ,
217
+ regenerator : ! isHermes || options . dev ,
220
218
...( isVersion && { version : options . enableBabelRuntime } ) ,
221
219
} ,
222
220
] ) ;
223
- } else if ( isHermesCanary ) {
221
+ } else if ( isHermes && options . dev ) {
224
222
extraPlugins . push ( [ require ( '@babel/plugin-transform-regenerator' ) ] ) ;
225
223
}
226
224
0 commit comments