react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.68k stars 126 forks source link

Add support for explicit, exclusive list of native modules for iOS RCTBridge implementation #353

Open felixSchl opened 3 years ago

felixSchl commented 3 years ago

Introduction

It appears currently impossible to create an RCTBridge instance that specifies an exclusive list of native modules to load. All native modules are registered program-wide via the accompanying macros and loaded every time, unconditionally. This is quite different from the Android implementation where we have total control over everything that gets loaded.

Details

The usecase is loading JS that should run in a restrictive, sandboxed environment with only a small subset of modules loaded which are carefully specified up front. Currently, on iOS, it is only possible to specific additional modules, but not the complete and exclusive list as far as I can tell.

Discussion points

kelset commented 3 years ago

Maybe I'm misunderstanding, but isn't this something that the TurboModules approach fix by definition? https://github.com/react-native-community/discussions-and-proposals/issues/40