Skip to content

resolve.conditions doesn't seem to do the trick #11

@wojtekmaj

Description

@wojtekmaj

When importing recoil package, which clearly has a specified react-native entry point, the following error appears:

Error: Cannot find module 'react-dom'
Require stack:
- /Users/wmaj/Projekty/Rewardo/app-native/node_modules/recoil/cjs/index.js
 ❯ node_modules/recoil/cjs/index.js:8:32
      6| 
      7| var react = _interopDefault(require('react'));
      8| var reactDom = _interopDefault(require('react-dom'));
       |                                ^
      9| 
     10| /**

By adding the following to the config:

  resolve: {
    alias: [{ find: 'recoil', replacement: 'recoil/native/index.js' }],
  },
  test: {
    deps: {
      inline: ['recoil'],
    },
  },

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 for exports only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions