zholmes1
zholmes1

Reputation: 609

How do I exclude modules from metro bundler?

I have a dependency in my React Native project that dynamically requires react-native-fs. The depdency expects me to install and configure it on my own. I don't need the function that calls this require. I'd like to not have to install and configure react-native-fs, since I don't need the function that uses it.

When I try to run my app, I get an error saying that the module could not be resolved.

In metro.config.js, I found an option resolver.blockList, but I can't seem to figure out a way to make it ignore react-native-fs.

Any ideas?

Upvotes: 0

Views: 941

Answers (1)

zholmes1
zholmes1

Reputation: 609

I was thinking about it incorrectly. Metro bundler isn't looking for modules to be blacklisted, it's looking for files. By blacklisting the file containing the function doing the dynamic require, I was able to stop the dynamic import from ever happening.

Upvotes: 1

Related Questions