-
Notifications
You must be signed in to change notification settings - Fork 26
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
eslint-plugin-import/no-unresolved
error caused by conditional exports
#113
Comments
Actually, this is not just an issue with the linter, our entire build fails on the following error:
|
Regarding the plugin, I'm resistant to patch this library for legacy resolvers. It was a challenge getting things working as they are now, and if memory serves backwards compatibility here complicates the build story to the extent that entire packages have been built to attempt to abstract it away. Bundlers and Node each now support conditional exports. Jest looks set to do so soon and as you've noted is easily patched for the timebeing. Whilst the plugin author's justification for the delay in support is reasonable, I'd nonetheless consider this a bug on their end. In the meantime, this may suffice as a workaround: 'import/no-unresolved': [2, { ignore: ['^fp-ts-std'] }], Regarding your build/runtime, where's that output coming from and with what version(s)? I know the library does/can work with Webpack 5 and Node 16, though of course bundle configuration is always a joy! 😄 |
Hi @samhh , thank you for the quick follow-up. We use Here is how you can easily reproduce the issue.
npm init --yes @svelte-add/kit@latest -- --with typescript sveltekit-fp-ts-std
cd sveltekit-fp-ts-std
npm i fp-ts fp-ts-std
<script lang="ts">
import { invert } from "fp-ts-std/Boolean";
</script>
{invert(false)}
Possible solutionThis SvelteKit issue (see also library issue and library PR) seems equivalent and was solved by:
I tried to apply this changes in my local installation but I wasn't able to get things to work. I know how difficult it is to make code interoperable between ESM, CJS, and the various bundlers and I understand why you are reluctant to complicate things further. Hopefully this gave you some ideas on how this problem could be solved. Thank you! |
Hi, @andreavaccari summoned me. Making packages work with bundlers and node can certainly be a challenge, but I think there's certain improvements can be made as @andreavaccari suggested. Even with conditional exports, the file extension matters too, here's how Nodejs determines what file is considered ESM/CJS. So ideally you can have two ways to fix this in your library:
The |
Thank you so much for your help, @bluwy! |
Thanks for the info and sorry for the delay. I'd be open to patching in ESM support (file extensions and import suffixes) following the call to |
Hi Sam, I'll be unable to help for the next 4 weeks but I'd be happy to working with you on this afterwards. |
@bluwy could you explain why changing EMS extensions to |
Good point about Also I've made https://publint.bjornlu.com/[email protected] recently which might help verify this 🙂 |
Thank you for the quick reply! I've learned a lot from your comments and answers here and in other repos. I used |
If this issue is still relevant, might I ask if |
We have been using Otherwise, the issue is still relevant. bluwy's publint shows that you have resolved most issues in 0.18 compared to 0.17:
|
That one warning is a bug on my end. Should be fixed now (with no warnings) |
Closing, fixed ESM can be tracked at #193. |
Hi @samhh, thank you for your work. I'm aware of the pinned issue that discusses the interaction between
jest
andfp-ts-std
's conditional exports. I'm having a similar issue with the import plugin for eslint. Theimport/no-unresolved
rule complains that it isunable to resolve path to module 'fp-ts-std/Array
.This issue discusses ways to mitigate the problem. Would you consider applying the same recommendations here?
Thank you!
The text was updated successfully, but these errors were encountered: