diff --git a/lib/modules/src/metro/utils.ts b/lib/modules/src/metro/utils.ts index aaf5c44..9e9aa47 100644 --- a/lib/modules/src/metro/utils.ts +++ b/lib/modules/src/metro/utils.ts @@ -78,17 +78,17 @@ export function isModuleExportBad( */ export function isModuleExportsBad(exports: Metro.ModuleExports): boolean { return ( + // Can't run isProxy() on this because this isn't your typical proxy: + // https://github.com/facebook/react-native/blob/master/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp + exports === nativeModuleProxy || // Nullish? exports == null || // Isn't an object or function? // - Number exports are not useful, usually just an asset ID // - String, Boolean, Symbol, BigInt exports are not useful (who would do `module.exports = ...`?) - !(typeof exports === 'object' || typeof exports === 'function') || - // Checking if the object is empty - (exports.__proto__ === Object.prototype && - !Reflect.ownKeys(exports).length) || - // Can't run isProxy() on this because this isn't your typical proxy: - // https://github.com/facebook/react-native/blob/master/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.cpp - exports === nativeModuleProxy + !( + exports.__proto__ === Function.prototype || + (typeof exports === 'object' && Reflect.ownKeys(exports).length) + ) ) }