samhh / fp-ts-std

The missing pseudo-standard library for fp-ts.
https://samhh.github.io/fp-ts-std/
MIT License
207 stars 27 forks source link

Unable to import fp-ts-std #198

Closed sahilsehwag closed 11 months ago

sahilsehwag commented 11 months ago

Error: Cannot find module 'fp-ts-std/Function' or its corresponding type declarations.

I have tried all the solutions mentioned in different comments across different issues relating to this. But I am unable to use fp-ts-std. I am using this library in a chrome extension I am building using react and webpack.

samhh commented 11 months ago

Probably related to this in the README:

fp-ts-std is published with both ESM and CJS modules. The import paths in either case needn't change and the appropriate module resolution should be picked up by Node and your bundler, however if your environment doesn't support conditional exports you'll need to import directly from a dist/(cjs|esm)/ subdirectory. Given ESM modules the library should tree shake well.

What versions of Webpack and TypeScript are you using?

sahilsehwag commented 11 months ago

webpack: 4.44.2 typescript: ^5.0.2

samhh commented 11 months ago

I may be wrong but I think only Webpack 5 supports conditional exports. You'll need to upgrade or import from the relevant subdirectory directly.

Mati365 commented 11 months ago

In my setup eslint is failing with the same error.

samhh commented 11 months ago

@Mati365 Is that eslint-plugin-import?: https://github.com/import-js/eslint-plugin-import/issues/1810

Mati365 commented 11 months ago

@samhh yep