Skip to content

Commit

Permalink
fix: Fix react-native-reanimated is not installed! error when `inline…
Browse files Browse the repository at this point in the history
…Requires` are enabled (#2953)

* fix: Fix module is not installed error

* chore: Add explanation for inlineRequires

---------

Co-authored-by: Marc Rousavy <me@mrousavy.com>
  • Loading branch information
mgefimov and mrousavy committed Jun 12, 2024
1 parent 183194c commit 573ab81
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions package/src/dependencies/ModuleProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ export const createModuleProxy = <TModule>(getModule: () => ImportType): TModule

const proxy = new Proxy(holder, {
get: (target, property) => {
if (property === '$$typeof') {
// If inlineRequires is enabled, Metro will look up all imports
// with the $$typeof operator. In this case, this will throw the
// `OptionalDependencyNotInstalledError` error because we try to access the module
// even though we are not using it (Metro does it), so instead we return undefined
// to bail out of inlineRequires here.
// See https://github.com/mrousavy/react-native-vision-camera/pull/2953
return undefined
}

if (target.module == null) {
// lazy initialize module via require()
// caller needs to make sure the require() call is wrapped in a try/catch
Expand Down

0 comments on commit 573ab81

Please sign in to comment.