-
-
Notifications
You must be signed in to change notification settings - Fork 551
feat: add "/http" and "/graphql" export paths #2004
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Let's have this released in the next minor version. Just don't merge this yet, I'd like to release a few bug fixes before the next version bump. Thanks.
@thepassle, how do you recommend us mention these exports in the docs? I still think that importing from the root should be the default. I wonder where these export paths would be proper to mention.
The annoying thing is that autocompletion will most likely favor the shortest path, and I don't think there's a way to tell it otherwise. What I generally end up doing is set up eslint's no-restricted-imports rule with a custom message to reroute users to the right import. Not the most user-friendly approach, though. Something along the lines of: "rules": {
"no-restricted-imports": [
"error",
{
"paths": [
{
"name": "msw",
"importNames": ["graphql"],
"message": "Please import 'graphql' from 'msw/graphql' instead."
},
]
}
]
} |
@pleunv, autocomplete right now is pretty broken for me anyways. VS Code always tries to import things where their type definitions are, not what the export says in package.json. For example, when I autoimport import { http } from 'msw/lib/http' Which is incorrect; you shouldn't be importing things from |
Of all the TypeScript issues I've ever run into, fortunately that's not one of them 😄. That would honestly drive me mad. Did you override any of the "Import Module" settings? |
@pleunv, no, that's the default behavior. |
Okidoki, any idea on when the next minor will be released?
Not really sure why you wouldnt change this: I hardly think this impacts DX for the largest usecase, even if you use both graphql and http, but I'm also not really interested in discussing that any longer; I think the perf difference outweighs DX, but it seems I haven't been able to convince you of that, so with peace and love, I won't go into that any further and leave it at this :)
Ill leave that up to your discretion |
I'm releasing next 2 bug fixes related to React Native, and then it's the minor release time!
You are omitting the experience implications here. All the tutorials, videos, and articles feature That's why performance improvements like these deserve a separate page, I think. Before (and if) we drop the root-level export altogether, I won't recommend this by default for one simple reason: nobody has reported performance issues due to barrel imports in the past, so nobody had performance issues due to barrel imports, it's as simple as that. Those who need this fix should be able to find it.
You've convinced me. From my side, I'm trying to show you the area of effect this change has on the end developer. I will not discard educational experience and simplicity of use. The |
I have one piece of feedback. The format we have now is What do you think about |
Released: v2.2.0 🎉This has been released in v2.2.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
… file