@@ -20,6 +20,10 @@ const EXCLUDED_FIRST_PARTY_PATHS = [
2020 / [ / \\ ] p r i v a t e [ / \\ ] r e a c t - n a t i v e - f a n t o m [ / \\ ] / ,
2121] ;
2222
23+ // customTransformOptions may be strings from URL params, or booleans passed
24+ // programatically. For strings, handle them as Metro does when parsing URLs.
25+ const TRUE_VALS = new Set ( [ true , 'true' , '1' ] ) ;
26+
2327function isTypeScriptSource ( fileName ) {
2428 return ! ! fileName && fileName . endsWith ( '.ts' ) ;
2529}
@@ -50,28 +54,25 @@ const getPreset = (src, options, babel) => {
5054 const transformProfile =
5155 options ?. unstable_transformProfile ?? babel ?. caller ( getTransformProfile ) ;
5256
53- // Hermes V1 (aka Static Hermes) uses more optimised profiles.
54- // There is currently no difference between stable and canary, but canary
55- // may in future be used to test features in pre-prod Hermes versions.
56- const isHermesV1 =
57- transformProfile === 'hermes-stable' ||
58- transformProfile === 'hermes-canary' ;
57+ const isHermesStable = transformProfile === 'hermes-stable' ;
58+ const isHermesCanary = transformProfile === 'hermes-canary' ;
59+ const isHermes = isHermesStable || isHermesCanary ;
5960
6061 // We enable regenerator in dev builds for the time being because
61- // Hermes V1 doesn't yet fully support debugging native generators.
62+ // Static Hermes doesn't yet fully support debugging native generators.
6263 // (e.g. - it's not possible to inspect local variables when paused in a
6364 // generator).
6465 //
6566 // Use native generators in release mode because it has already yielded perf
66- // wins. The next release of Hermes will close this gap, so this won't
67+ // wins. The next release of Static Hermes will close this gap, so this won't
6768 // be permanent.
68- const enableRegenerator = isHermesV1 && options . dev ;
69-
70- // Preserve class syntax and related if we're using Hermes V1.
71- const preserveClasses = isHermesV1 ;
69+ const enableRegenerator = isHermes && options . dev ;
7270
7371 const isNull = src == null ;
7472 const hasClass = isNull || src . indexOf ( 'class' ) !== - 1 ;
73+ const preserveClasses = TRUE_VALS . has (
74+ options ?. customTransformOptions ?. unstable_preserveClasses ,
75+ ) ;
7576
7677 const extraPlugins = [ ] ;
7778 const firstPartyPlugins = [ ] ;
0 commit comments