-
Notifications
You must be signed in to change notification settings - Fork 35
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
Consider exporting functions as default
#56
Comments
Yes, actually. This allows code editors to know the name of the export, so for example one could imagine having a keyboard shortcut for importing a new thing and just type in the module path (or part of it) and the editor can handle the rest, including naming. :) Also some of the modules have multiple exports: import { partial, _, ___ } from "trine/function/partial"; |
Sincerely, I don’t think basing a design decision on features of a code editor is the way to go. When you
On Sublime I used to have a snippet for that: https://github.com/tomekwi/sublime-snippets/blob/ae89045999dff04977174fc27a694df17081364c/JS/import.sublime-snippet – no need for named exports there.
No problem: import { default as partial, _, ___ } from "trine/function/partial"; |
It's actually even easier. import partial, { _, ___ } from 'trine/function/partial'; |
Wow, good to know! :) |
Hmm, I'm a bit torn in between on this - I have an ideal nagging in my head that everything should be named, but then again default exports are the most convenient way to use libraries like this that export (mostly) one thing per module. :D I'd love to get more input, but I'm pretty sure you're right about this being the right way forward. |
If editors need named exports and can even provide some GUI to make imports easier, I can live with the extra brackets just fine. So I am a bit surprised about your last comment @jussi-kalliokoski. :) |
My two cents to #46:
When I started using trine it was a surprising discovery that trying to
import map from 'trine/iterable/map'
failed. It cost me some time to find out that I should haveimport
ed{map}
instead.Since I heard that “Default exports are favored” I’ve always tried to only
export default
out of my modules, and I’ve seen others do the same. I’ve grown to expect that of other ES 2015+ libraries as well.Is there any reason why you use named exports instead of
export
ingdefault
? That would make for even simpler syntax:The text was updated successfully, but these errors were encountered: