You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since our application has a critical business use case on boot, we had to split code using require to speed up our bundle to load, and that worked really well.
To ensure the expected module loaded stays the same, and our colleague does not start pulling unwanted modules, we have used require.getModules() against some allowed lists to spot any new undesired modules.
However, after upgrading to react-native 0.76.7, require.getModules() returns an empty array list. On react-native 0.75.5, it works well.
On react-native 75 it uses metro v0.80.9.
On react-native 76 it uses metro v0.81.1
I looked at metro issues, and nothing was reported there, so I'm more inclined to believe it is react-native related! Let me know, I can move/open an issue in metro, too, if you think it is more metro-related!
Steps to reproduce
Build start any app
In the index.js add a line like console.log('require.getModules()',require.getModules())
We can observe that it returns an empty list
React Native Version
0.76.7
Affected Platforms
Runtime - Android
Output of npx react-native info
info Fetching system and libraries information...
System:
OS: macOS 15.2
CPU: (12) arm64 Apple M2 Pro
Memory: 2.12 GB / 32.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 18.20.4
path: ~/.nvm/versions/node/v18.20.4/bin/node
Yarn:
version: 1.22.22
path: /opt/homebrew/bin/yarn
npm:
version: 10.7.0
path: ~/.nvm/versions/node/v18.20.4/bin/npm
Watchman:
version: 2024.11.04.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.16.2
path: /Users/dprevost/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.2
- iOS 18.2
- macOS 15.2
- tvOS 18.2
- visionOS 2.2
- watchOS 11.2
Android SDK: Not Found
IDEs:
Android Studio: 2024.2 AI-242.23726.103.2422.12816248
Xcode:
version: 16.2/16C5032a
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.13
path: /usr/bin/javac
Ruby:
version: 3.3.3
path: /Users/dprevost/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react: Not Found
react-native:
installed: 0.76.7
wanted: 0.76.7
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: Not found
newArchEnabled: Not found
iOS:
hermesEnabled: true
newArchEnabled: false
Stacktrace or Logs
Below is an example of the loaded module filter on the node_module folder that we would expect to see on 76, but that is empty
dprevost-LMI
changed the title
require.getModules() no longer working under react-native 0.76.7require.getModules()returns empty modules list under react-native 0.76.7
Feb 12, 2025
dprevost-LMI
changed the title
require.getModules()returns empty modules list under react-native 0.76.7require.getModules()returns empty modules list under react-native 76
Feb 12, 2025
Description
Since our application has a critical business use case on boot, we had to split code using
require
to speed up our bundle to load, and that worked really well.To ensure the expected module loaded stays the same, and our colleague does not start pulling unwanted modules, we have used
require.getModules()
against some allowed lists to spot any new undesired modules.However, after upgrading to react-native 0.76.7,
require.getModules()
returns an empty array list. On react-native 0.75.5, it works well.On react-native 75 it uses metro
v0.80.9
.On react-native 76 it uses metro
v0.81.1
I looked at metro issues, and nothing was reported there, so I'm more inclined to believe it is react-native related! Let me know, I can move/open an issue in metro, too, if you think it is more metro-related!
Steps to reproduce
index.js
add a line likeconsole.log('require.getModules()',require.getModules())
React Native Version
0.76.7
Affected Platforms
Runtime - Android
Output of
npx react-native info
Stacktrace or Logs
Below is an example of the loaded module filter on the
node_module
folder that we would expect to see on 76, but that is emptyReproducer
Soon
Screenshots and Videos
Any pointer on how to troubleshoot would be appreciated since I'm clueless about what to look next!
The text was updated successfully, but these errors were encountered: