Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest imports of fp-ts-std fail to resolve in 0.12 ("cannot find module") #89

Closed
samhh opened this issue Nov 26, 2021 · 1 comment
Closed

Comments

@samhh
Copy link
Owner

samhh commented Nov 26, 2021

We're now using conditional exports to support both ESM (bundlers) & CJS (Node), but that's unsupported in Jest for now.

You may see an error something like this:

Cannot find module 'fp-ts-std/Array' from 'path/to/file.ts'

Jest should add support soon, but until then the simplest workaround is with moduleNameMapper in your Jest config:

module.exports = {
  ...etc,
  moduleNameMapper: {
    ...etc,
    'fp-ts-std/(.*)': 'fp-ts-std/dist/cjs/$1',
  },
}
@samhh
Copy link
Owner Author

samhh commented Apr 25, 2022

Note that Jest 28+ supports conditional exports, meaning fp-ts-std is supported natively without any config fiddling.

@samhh samhh unpinned this issue Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant