Skip to content

Commit 1236b6b

Browse files
robhoganmeta-codesync[bot]
authored andcommitted
Revert D89724839: Disable JS class transforms for Hermes V1 (use SH-native class support)
Differential Revision: D89724839 Original commit changeset: c25d0080ddac Original Phabricator Diff: D89724839 fbshipit-source-id: af32de790f3f591826a57352d90629ce278ab14d
1 parent 74b8dde commit 1236b6b

File tree

1 file changed

+13
-12
lines changed
  • packages/react-native-babel-preset/src/configs

1 file changed

+13
-12
lines changed

packages/react-native-babel-preset/src/configs/main.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ const EXCLUDED_FIRST_PARTY_PATHS = [
2020
/[/\\]private[/\\]react-native-fantom[/\\]/,
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+
2327
function 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

Comments
 (0)