unstorage
unstorage copied to clipboard
refactor(redis): use named import for `Redis`
๐ Linked issue
โ Type of change
- [ ] ๐ Documentation (updates to the documentation, readme, or JSdoc annotations)
- [ ] ๐ Bug fix (a non-breaking change that fixes an issue)
- [ ] ๐ Enhancement (improving an existing functionality like performance)
- [ ] โจ New feature (a non-breaking change that adds functionality)
- [x] ๐งน Chore (updates to the build process or auxiliary tools and libraries)
- [ ] โ ๏ธ Breaking change (fix or feature that would cause existing functionality to change)
๐ Description
Since a few versions, ioredis supports named imports. This should improve esm compatibility, and maybe at some point enable treeshaking.
๐ Checklist
- [ ] I have linked an issue or discussion.
- [ ] I have updated the documentation accordingly.
Thanks for this PR, but do you think it is an essential change? If ioredis keep supporting default export, it can be safer for projects might have an older version of it.
It's not very essential. I have some troubles with the ioredis import (https://github.com/redis/ioredis/issues/1822, mostly when using vitest) and was hoping this is fixed with this change here. But if you think backwards compatibility is an issue, we can still wait with merging this.
Can you help on preparing a reproduction for vitest issue?
What else we can do, is to use import * from or use dynamic import() to dedefault in runtime to have both backward and forward (vitest, ESM) compatibility.
It's sadly hard to reproduce, only occurring in certain situations (which seem to involve importing ioredis another time in code that is tested after using unstorage). Will append a reproduction to the issue as soon as I have one.
You are the expert of cjs/esm imports, so I'll let you decide what's the best import here. I got confused by how ioredis is doing its exports https://unpkg.com/browse/[email protected]/built/index.js