feat(lib/modules/metro/utils): improve perf on bad module exports check
This commit is contained in:
parent
2f21be2c52
commit
6a6a67e78f
1 changed files with 7 additions and 7 deletions
|
|
@ -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)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue