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

ES6-compliant export for vite support #109

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

Conversation

xela92
Copy link

@xela92 xela92 commented Feb 28, 2023

Hi,

I made this change proposal to be able to support Vite, export = cardValidator is not valid when targeting ES6. This PR fixes it, and as card-validator depends on other old libraries I also needed to do some other changes in order to make it work (I refer to my way of exporting creditCardType).

The downside of this PR is that you can't do default imports anymore (like the one you ship with your documentation, import valid from 'card-validator') but you need to import the single utils. This could be made better, maybe targetting ESNext and starting a fixing chain to the dependent libraries as well.

Also, to avoid naming ambiguity between number function and the primitive, i suggest to remove the number export and use the one I added, cardNumber, instead, but I didn't make it as it's another super-breaking change.

Actually, I published another package that ships with this changes (card-validator-es6), of course if you decide to merge this I will unpublish that to avoid confusion.

If you have better solutions in mind, please share them :-)

Best regards,

Alex

es6 export for vite support

add package-lock again
@hollabaq86
Copy link
Contributor

:wave @xela92 Thanks for the PR! Removing existing functionality is a breaking change which is why I marked this PR a breaking change. That said, We should update the library to have ES6 Support.

We'll take a look and provide feedback.

For internal tracking, issue 2522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants