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
use "export default as" syntax for easier ES6 imports and tree shaking purposes #683
Comments
PRs are welcome! If you can do it in a backwards-compatible way then I'd be happy to accept the change. |
For someone who is still looking for this ES6 import format, I have tried this in an Angular project with
And then, use it like below
|
4 years later, still a nice to have feature |
Do we still need to make imports/exports backwards-compatible? Does major version update (to Or does anyone have any idea, how to accomplish this behavior? Tell me and I will make my best to create PR |
Currently, you can only use the
import isEmail from 'validator/lib/isEmail'
syntax to only grab the validators you want, and you have to repeat this for every validator you need in your file.Easier would be
import { isEmail, isNumeric } from 'validator'
.Using
export { default as isEmail } from './lib/isEmail'
within theindex.js
file and exporting everything withexport default { isEmail, ... }
, would allow us an easier way to grab the validators we want, and remove some repetitive code.This would still work with tree-shaking as you can see here.
The text was updated successfully, but these errors were encountered: