@@ -51,9 +51,6 @@ const defaultPlugins = [
51
51
[ require ( '@babel/plugin-transform-unicode-regex' ) ] ,
52
52
] ;
53
53
54
- // For Static Hermes testing (experimental), the hermes-canary transformProfile
55
- // is used to enable regenerator (and some related lowering passes) because SH
56
- // requires more Babel lowering than Hermes temporarily.
57
54
const getPreset = ( src , options ) => {
58
55
const transformProfile =
59
56
( options && options . unstable_transformProfile ) || 'default' ;
@@ -124,8 +121,8 @@ const getPreset = (src, options) => {
124
121
extraPlugins . push ( [
125
122
require ( '@babel/plugin-transform-named-capturing-groups-regex' ) ,
126
123
] ) ;
127
- // Needed for regenerator for hermes-canary
128
- if ( isHermesCanary ) {
124
+ // Needed for regenerator
125
+ if ( isHermes && options . dev ) {
129
126
extraPlugins . push ( [
130
127
require ( '@babel/plugin-transform-optional-catch-binding' ) ,
131
128
] ) ;
@@ -158,17 +155,15 @@ const getPreset = (src, options) => {
158
155
) {
159
156
extraPlugins . push ( [ require ( '@babel/plugin-transform-react-display-name' ) ] ) ;
160
157
}
161
- // Check !isHermesStable because this is needed for regenerator for
162
- // hermes-canary
163
- if ( ! isHermesStable && ( isNull || src . indexOf ( '?.' ) !== - 1 ) ) {
158
+ // Also check options.dev because this is needed for regenerator
159
+ if ( ( ! isHermes || options . dev ) && ( isNull || src . indexOf ( '?.' ) !== - 1 ) ) {
164
160
extraPlugins . push ( [
165
161
require ( '@babel/plugin-transform-optional-chaining' ) ,
166
162
{ loose : true } ,
167
163
] ) ;
168
164
}
169
- // Check !isHermesStable because this is needed for regenerator for
170
- // hermes-canary
171
- if ( ! isHermesStable && ( isNull || src . indexOf ( '??' ) !== - 1 ) ) {
165
+ // Also check options.dev because this is needed for regenerator
166
+ if ( ( ! isHermes || options . dev ) && ( isNull || src . indexOf ( '??' ) !== - 1 ) ) {
172
167
extraPlugins . push ( [
173
168
require ( '@babel/plugin-transform-nullish-coalescing-operator' ) ,
174
169
{ loose : true } ,
@@ -196,7 +191,7 @@ const getPreset = (src, options) => {
196
191
extraPlugins . push ( [ require ( '@babel/plugin-transform-react-jsx-self' ) ] ) ;
197
192
}
198
193
199
- if ( isHermesCanary ) {
194
+ if ( isHermes && options . dev ) {
200
195
const hasForOf =
201
196
isNull || ( src . indexOf ( 'for' ) !== - 1 && src . indexOf ( 'of' ) !== - 1 ) ;
202
197
if ( hasForOf ) {
@@ -216,11 +211,11 @@ const getPreset = (src, options) => {
216
211
require ( '@babel/plugin-transform-runtime' ) ,
217
212
{
218
213
helpers : true ,
219
- regenerator : ! isHermesStable ,
214
+ regenerator : ! isHermes || options . dev ,
220
215
...( isVersion && { version : options . enableBabelRuntime } ) ,
221
216
} ,
222
217
] ) ;
223
- } else if ( isHermesCanary ) {
218
+ } else if ( isHermes && options . dev ) {
224
219
extraPlugins . push ( [ require ( '@babel/plugin-transform-regenerator' ) ] ) ;
225
220
}
226
221
0 commit comments