-
Notifications
You must be signed in to change notification settings - Fork 179
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
Switch to classes and ES6/esmodule TS compilation #62
Switch to classes and ES6/esmodule TS compilation #62
Conversation
@taylorthurlow Thanks for your effort. Your concerns are right but I hope it won't go waste. |
@taylorthurlow updated the base branch - I will review and test it further. |
This reverts commit 8a53256.
Also eliminate an unnecessary Country import.
Thanks for taking a look! I just rewrote the tests and pushed everything up. I have 100% coverage but there is some weirdness with the branch coverage percentage on |
@taylorthurlow your code is already refactored and merged into the develop branch. |
Thanks! Sorry I've been busy. Will get to this sometime next week I think. |
I'm not 100% sure if this PR is welcome - this is obviously a big rewrite/refactor of how this is all structured, and will break every existing app that uses this library. So, no hard feelings if this gets closed, I mostly did this because I'm using this in a web app, and the size of the gzipped bundle when this library is included is WAY too high (2.6mb gzipped).
This is a rewrite which moves the primary Country, State, and City interfaces into their own classes. Each class has appropriate class and instance methods which replicate the existing functionality of the library, but in a way which allows full tree-shaking when one or more classes are not used in the dependent application.
In order to support tree-shaking, I had to change the TypeScript compiler options to generate ES6 compatible modules rather than CommonJS modules, and I'm not really an expert on JS in general, so I don't know what the implications are of that change as far as compatibility. I know that this should be fine for web applications, and I believe newer versions of Node will be fine with ES modules.
I'm still playing around with this, and I haven't updated the tests yet, so I'm marking this as a draft. Let me know if there is any interest in merging this.
Thanks!