@@ -124,8 +124,8 @@ const getPreset = (src, options) => {
124124 extraPlugins . push ( [
125125 require ( '@babel/plugin-transform-named-capturing-groups-regex' ) ,
126126 ] ) ;
127- // Needed for regenerator for hermes-canary
128- if ( isHermesCanary ) {
127+ // Needed for regenerator
128+ if ( isHermes && options . dev ) {
129129 extraPlugins . push ( [
130130 require ( '@babel/plugin-transform-optional-catch-binding' ) ,
131131 ] ) ;
@@ -158,17 +158,15 @@ const getPreset = (src, options) => {
158158 ) {
159159 extraPlugins . push ( [ require ( '@babel/plugin-transform-react-display-name' ) ] ) ;
160160 }
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 ) ) {
164163 extraPlugins . push ( [
165164 require ( '@babel/plugin-transform-optional-chaining' ) ,
166165 { loose : true } ,
167166 ] ) ;
168167 }
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 ) ) {
172170 extraPlugins . push ( [
173171 require ( '@babel/plugin-transform-nullish-coalescing-operator' ) ,
174172 { loose : true } ,
@@ -196,7 +194,7 @@ const getPreset = (src, options) => {
196194 extraPlugins . push ( [ require ( '@babel/plugin-transform-react-jsx-self' ) ] ) ;
197195 }
198196
199- if ( isHermesCanary ) {
197+ if ( isHermes && options . dev ) {
200198 const hasForOf =
201199 isNull || ( src . indexOf ( 'for' ) !== - 1 && src . indexOf ( 'of' ) !== - 1 ) ;
202200 if ( hasForOf ) {
@@ -216,11 +214,11 @@ const getPreset = (src, options) => {
216214 require ( '@babel/plugin-transform-runtime' ) ,
217215 {
218216 helpers : true ,
219- regenerator : ! isHermesStable ,
217+ regenerator : ! isHermes || options . dev ,
220218 ...( isVersion && { version : options . enableBabelRuntime } ) ,
221219 } ,
222220 ] ) ;
223- } else if ( isHermesCanary ) {
221+ } else if ( isHermes && options . dev ) {
224222 extraPlugins . push ( [ require ( '@babel/plugin-transform-regenerator' ) ] ) ;
225223 }
226224
0 commit comments