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

refactor(redis): use named import for Redis #306

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tobiasdiez
Copy link

πŸ”— 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)
  • 🧹 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.

[Since a few versions](https://github.com/redis/ioredis/blob/ec42c82ceab1957db00c5175dfe37348f1856a93/CHANGELOG.md?plain=1#L35-L42), ioredis supports named imports. This should improve esm compatibility, and maybe at some point enable treeshaking.
@pi0
Copy link
Member

pi0 commented Sep 28, 2023

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.

@tobiasdiez
Copy link
Author

It's not very essential. I have some troubles with the ioredis import (redis/ioredis#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.

@pi0
Copy link
Member

pi0 commented Sep 29, 2023

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.

@tobiasdiez
Copy link
Author

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

@pi0 pi0 changed the title chore: use named import for ioredis refactor(redis): use named import for Redis May 1, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants