@@ -64,15 +64,19 @@ function getInlinePlatform(caller) {
6464const loose = true ;
6565
6666const getPreset = ( src , options , babel ) => {
67+ options = options ?? { } ;
68+
6769 const transformProfile =
68- options ?. unstable_transformProfile ?? babel ?. caller ( getTransformProfile ) ;
70+ options . unstable_transformProfile ??
71+ babel ?. caller ( getTransformProfile ) ??
72+ 'hermes-stable' ;
6973
70- const dev = options ? .dev ?? babel ?. env ( 'development' ) ?? false ;
74+ const dev = options . dev ?? babel ?. env ( 'development' ) ?? false ;
7175
72- const platform = options ? .platform ?? babel ?. caller ( getPlatform ) ;
76+ const platform = options . platform ?? babel ?. caller ( getPlatform ) ;
7377
7478 const inlinePlatform =
75- options ? .inlinePlatform ?? babel ?. caller ( getInlinePlatform ) ?? false ;
79+ options . inlinePlatform ?? babel ?. caller ( getInlinePlatform ) ?? false ;
7680
7781 // Hermes V1 uses more optimised transform profiles. There is currently no
7882 // difference between stable and canary, but canary may in future be used to
@@ -96,22 +100,22 @@ const getPreset = (src, options, babel) => {
96100
97101 // Preserve private class fields and methods if the experiment is enabled.
98102 const preserveClassPrivate = TRUE_VALS . has (
99- options ? .customTransformOptions ?. unstable_preserveClassPrivate ,
103+ options . customTransformOptions ?. unstable_preserveClassPrivate ,
100104 ) ;
101105
102106 // Preserve async/await syntax if the experiment is enabled.
103107 const preserveAsync = TRUE_VALS . has (
104- options ? .customTransformOptions ?. unstable_preserveAsync ,
108+ options . customTransformOptions ?. unstable_preserveAsync ,
105109 ) ;
106110
107111 // Preserve block scoping (let/const) if the experiment is enabled.
108112 const preserveBlockScoping = TRUE_VALS . has (
109- options ? .customTransformOptions ?. unstable_preserveBlockScoping ,
113+ options . customTransformOptions ?. unstable_preserveBlockScoping ,
110114 ) ;
111115
112116 // Preserve destructuring syntax if the experiment is enabled.
113117 const preserveDestructuring = TRUE_VALS . has (
114- options ? .customTransformOptions ?. unstable_preserveDestructuring ,
118+ options . customTransformOptions ?. unstable_preserveDestructuring ,
115119 ) ;
116120
117121 const isNull = src == null ;
@@ -144,7 +148,7 @@ const getPreset = (src, options, babel) => {
144148 extraPlugins . push ( [ require ( '@react-native/babel-plugin-codegen' ) ] ) ;
145149 }
146150
147- if ( ! options || ! options . disableImportExportTransform ) {
151+ if ( ! options . disableImportExportTransform ) {
148152 extraPlugins . push (
149153 [ require ( '@babel/plugin-proposal-export-default-from' ) ] ,
150154 [
@@ -153,7 +157,7 @@ const getPreset = (src, options, babel) => {
153157 strict : false ,
154158 strictMode : false , // prevent "use strict" injections
155159 lazy :
156- options && options . lazyImportExportTransform != null
160+ options . lazyImportExportTransform != null
157161 ? options . lazyImportExportTransform
158162 : importSpecifier => lazyImports . has ( importSpecifier ) ,
159163 allowTopLevelThis : true , // dont rewrite global `this` -> `undefined`
@@ -210,11 +214,11 @@ const getPreset = (src, options, babel) => {
210214 ] ) ;
211215 }
212216
213- if ( options && dev && ! options . disableDeepImportWarnings ) {
217+ if ( dev && ! options . disableDeepImportWarnings ) {
214218 firstPartyPlugins . push ( [ require ( '../plugin-warn-on-deep-imports.js' ) ] ) ;
215219 }
216220
217- if ( options && dev && ! options . useTransformReactJSXExperimental ) {
221+ if ( dev && ! options . useTransformReactJSXExperimental ) {
218222 extraPlugins . push ( [ require ( '@babel/plugin-transform-react-jsx-source' ) ] ) ;
219223 extraPlugins . push ( [ require ( '@babel/plugin-transform-react-jsx-self' ) ] ) ;
220224 }
@@ -230,9 +234,9 @@ const getPreset = (src, options, babel) => {
230234 ] ) ;
231235 }
232236
233- if ( ! options || options . enableBabelRuntime !== false ) {
237+ if ( options . enableBabelRuntime !== false ) {
234238 // Allows configuring a specific runtime version to optimize output
235- const isVersion = typeof options ? .enableBabelRuntime === 'string' ;
239+ const isVersion = typeof options . enableBabelRuntime === 'string' ;
236240
237241 extraPlugins . push ( [
238242 require ( '@babel/plugin-transform-runtime' ) ,
0 commit comments