File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,16 @@ const Server = require('metro/src/Server');
22const { loadConfig } = require ( 'metro-config' ) ;
33const output = require ( 'metro/src/shared/output/bundle' ) ;
44
5+ const getBabelTransformerPath = ( ) => {
6+ try {
7+ // for RN 73+
8+ return require . resolve ( '@react-native/metro-babel-transformer' ) ;
9+ } catch ( e ) {
10+ // to ensure backwards compatibility with old RN versions (RN < 73)
11+ return require . resolve ( 'metro-react-native-babel-transformer' ) ;
12+ }
13+ }
14+
515async function getAssets ( options ) {
616 const args = {
717 entryFile : options . entryFile ,
@@ -22,9 +32,7 @@ async function getAssets(options) {
2232 } ,
2333 transformer : {
2434 allowOptionalDependencies : true ,
25- babelTransformerPath : require . resolve (
26- 'metro-react-native-babel-transformer'
27- ) ,
35+ babelTransformerPath : getBabelTransformerPath ( ) ,
2836 assetRegistryPath : 'react-native/Libraries/Image/AssetRegistry' ,
2937 } ,
3038 }
You can’t perform that action at this time.
0 commit comments