@@ -38,9 +38,6 @@ function isFirstParty(fileName) {
3838// use `this.foo = bar` instead of `this.defineProperty('foo', ...)`
3939const loose = true ;
4040
41- // For Static Hermes testing (experimental), the hermes-canary transformProfile
42- // is used to enable regenerator (and some related lowering passes) because SH
43- // requires more Babel lowering than Hermes temporarily.
4441const getPreset = ( src , options ) => {
4542 const transformProfile =
4643 ( options && options . unstable_transformProfile ) || 'default' ;
@@ -111,8 +108,8 @@ const getPreset = (src, options) => {
111108 extraPlugins . push ( [
112109 require ( '@babel/plugin-transform-named-capturing-groups-regex' ) ,
113110 ] ) ;
114- // Needed for regenerator for hermes-canary
115- if ( isHermesCanary ) {
111+ // Needed for regenerator
112+ if ( isHermes && options . dev ) {
116113 extraPlugins . push ( [
117114 require ( '@babel/plugin-transform-optional-catch-binding' ) ,
118115 ] ) ;
@@ -145,17 +142,15 @@ const getPreset = (src, options) => {
145142 ) {
146143 extraPlugins . push ( [ require ( '@babel/plugin-transform-react-display-name' ) ] ) ;
147144 }
148- // Check !isHermesStable because this is needed for regenerator for
149- // hermes-canary
150- if ( ! isHermesStable && ( isNull || src . indexOf ( '?.' ) !== - 1 ) ) {
145+ // Also check options.dev because this is needed for regenerator
146+ if ( ( ! isHermes || options . dev ) && ( isNull || src . indexOf ( '?.' ) !== - 1 ) ) {
151147 extraPlugins . push ( [
152148 require ( '@babel/plugin-transform-optional-chaining' ) ,
153149 { loose : true } ,
154150 ] ) ;
155151 }
156- // Check !isHermesStable because this is needed for regenerator for
157- // hermes-canary
158- if ( ! isHermesStable && ( isNull || src . indexOf ( '??' ) !== - 1 ) ) {
152+ // Also check options.dev because this is needed for regenerator
153+ if ( ( ! isHermes || options . dev ) && ( isNull || src . indexOf ( '??' ) !== - 1 ) ) {
159154 extraPlugins . push ( [
160155 require ( '@babel/plugin-transform-nullish-coalescing-operator' ) ,
161156 { loose : true } ,
@@ -183,7 +178,7 @@ const getPreset = (src, options) => {
183178 extraPlugins . push ( [ require ( '@babel/plugin-transform-react-jsx-self' ) ] ) ;
184179 }
185180
186- if ( isHermesCanary ) {
181+ if ( isHermes && options . dev ) {
187182 const hasForOf =
188183 isNull || ( src . indexOf ( 'for' ) !== - 1 && src . indexOf ( 'of' ) !== - 1 ) ;
189184 if ( hasForOf ) {
@@ -203,11 +198,11 @@ const getPreset = (src, options) => {
203198 require ( '@babel/plugin-transform-runtime' ) ,
204199 {
205200 helpers : true ,
206- regenerator : ! isHermesStable ,
201+ regenerator : ! isHermes || options . dev ,
207202 ...( isVersion && { version : options . enableBabelRuntime } ) ,
208203 } ,
209204 ] ) ;
210- } else if ( isHermesCanary ) {
205+ } else if ( isHermes && options . dev ) {
211206 extraPlugins . push ( [ require ( '@babel/plugin-transform-regenerator' ) ] ) ;
212207 }
213208
0 commit comments