Using v.number or number? #515
Replies: 2 comments
-
I prefer to use wildcard imports. They are also tree-shakable and provide better DX in my option. For the guides in our docs I use wildcard imports, but for the API reference I used the function names directly and added no import statements to keep the code examples focused on the API. There is an info in our installation guide but most people probably overlook it: https://valibot.dev/guides/installation/ |
Beta Was this translation helpful? Give feedback.
-
Thanks for reminding me it's called wildcard imports. I will leave the discussion title as it, that way someone else who has bad JS terminology like me might still find it. |
Beta Was this translation helpful? Give feedback.
-
I noticed that the recent blog post from @fabian-hiller (about
pipe
) had examples wherevalibot
was importedas v
.Previously I haven't seen this, and my understanding was that this imports the entire module so all the advantages of being more tree shakable goes out the window. Maybe that's wrong?
But I was more interested in which way should be the preferred way in documentation and examples. I find the sheer number of imports from
valibot
in some of my code to be a little daunting - and having it all come off thev
namespace might make it more accessible tozod
users. However, I am generally not a big fan of named imports in examples because it needs to be manually entered into the editor which creates some unnecessary friction.Would be interested in hearing people's thoughts on this!
Beta Was this translation helpful? Give feedback.
All reactions