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
This is particularly useful for library authors, and would have been helpful during the "lean core" efforts (react-native-community/discussions-and-proposals#120) but will continue to be useful in environments where libraries want to either: a) support multiple implementations of some primitive and automatically switch between them depending on which one the developer uses b) provide some behavior in their library that works if the developer has installed an optional peer dependency or fallback to something else and/or provide some warning otherwise.
Possible Implementations
We would just need to add allowOptionalDependencies: true to the default transformer config in
This should not break any existing apps, but libraries that adopt optional imports will only work on newer versions of Metro/this CLI that use this config.
one more question - do you think it would be possible to backport this and a version bump to depend on metro@0.59 (the first release that includes this feature - it shipped in March of last year) to a CLI version that is compatible with react-native@0.63? we're hoping to leverage this functionality to move away from .expo.js extensions
Describe the Feature
facebook/metro#511 added support for
allowOptionalDependencies
to Metro. This allows us write code like this:This is particularly useful for library authors, and would have been helpful during the "lean core" efforts (react-native-community/discussions-and-proposals#120) but will continue to be useful in environments where libraries want to either: a) support multiple implementations of some primitive and automatically switch between them depending on which one the developer uses b) provide some behavior in their library that works if the developer has installed an optional peer dependency or fallback to something else and/or provide some warning otherwise.
Possible Implementations
We would just need to add
allowOptionalDependencies: true
to the defaulttransformer
config incli/packages/cli/src/tools/loadMetroConfig.ts
Lines 108 to 116 in 22a3c25
This should not break any existing apps, but libraries that adopt optional imports will only work on newer versions of Metro/this CLI that use this config.
Related Issues
The text was updated successfully, but these errors were encountered: