@@ -31,13 +31,19 @@ import type * as sourceMapStringType from 'metro/private/DeltaBundler/Serializer
3131import type * as bundleToStringType from 'metro/private/lib/bundleToString' ;
3232import type { MetroSerializer } from '../../utils' ;
3333
34- let baseJSBundle : typeof baseJSBundleType ;
34+ let baseJSBundleModule : any ;
3535try {
36- baseJSBundle = require ( 'metro/private/DeltaBundler/Serializers/baseJSBundle' ) ;
37- } catch ( e ) {
38- baseJSBundle = require ( 'metro/src/DeltaBundler/Serializers/baseJSBundle' ) ;
36+ baseJSBundleModule = require ( 'metro/private/DeltaBundler/Serializers/baseJSBundle' ) ;
37+ } catch {
38+ baseJSBundleModule = require ( 'metro/src/DeltaBundler/Serializers/baseJSBundle' ) ;
3939}
4040
41+ const baseJSBundle : typeof baseJSBundleType =
42+ typeof baseJSBundleModule === 'function'
43+ ? baseJSBundleModule
44+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
45+ baseJSBundleModule ?. baseJSBundle ?? baseJSBundleModule ?. default ;
46+
4147let sourceMapString : typeof sourceMapStringType ;
4248try {
4349 // eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -52,13 +58,19 @@ try {
5258 }
5359}
5460
55- let bundleToString : typeof bundleToStringType ;
61+ let bundleToStringModule : any ;
5662try {
57- bundleToString = require ( 'metro/private/lib/bundleToString' ) ;
58- } catch ( e ) {
59- bundleToString = require ( 'metro/src/lib/bundleToString' ) ;
63+ bundleToStringModule = require ( 'metro/private/lib/bundleToString' ) ;
64+ } catch {
65+ bundleToStringModule = require ( 'metro/src/lib/bundleToString' ) ;
6066}
6167
68+ const bundleToString : typeof bundleToStringType =
69+ typeof bundleToStringModule === 'function'
70+ ? bundleToStringModule
71+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
72+ bundleToStringModule ?. bundleToString ?? bundleToStringModule ?. default ;
73+
6274type NewSourceMapStringExport = {
6375 // Since Metro v0.80.10 https://github.com/facebook/metro/compare/v0.80.9...v0.80.10#diff-1b836d1729e527a725305eef0cec22e44605af2700fa413f4c2489ea1a03aebcL28
6476 sourceMapString : typeof sourceMapString ;
0 commit comments