Open wojtekmaj opened 1 year ago
Or, perhaps, it works for
exports
only.
resolve.conditions
only works for exports
field. If you need top level field, use resolve.mainFields
(but it will only work for dependencies imported in inlined code)
Is there anything stopping us from defining it as
mainFields: ['react-native', 'browser', 'module', 'jsnext:main', 'jsnext'],
in this plugin?
Don't forget that mainFields
is only applied to imports in your source code. We would need to implement our own resolution for require
. Conditions are supported out of the box. And I don't have the energy and interest to implement and support this myself.
When importing
recoil
package, which clearly has a specifiedreact-native
entry point, the following error appears:By adding the following to the config:
everything works again.
Looking at https://vitejs.dev/config/shared-options.html#resolve-conditions docs, it seems like this would extend the list of conditions, so
react-native
would still not be prioritized. Or, perhaps, it works forexports
only.