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
Generate smaller bundle options with limited timezone data #73
Conversation
}; | ||
|
||
const writeData = (suffix, startYear = 0, endYear = 9999) => { | ||
const packedData = moment.tz.filterLinkPack(tzdbLatest, startYear, endYear); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: this is the same way that moment-timezone
produces its smaller bundles.
i'm no expert in the relevant details, but this looks exactly like what I was wanting 😸 |
Hello @jkillian, thanks a lot for using js-joda and contributing. Your PR is looking great, i probably would have done it very similar. What would be nice to have, is a To your questions:
|
Amazing! Thanks for the merge @pithu. Let me know when you release and we'll pick up the new version in our codebase.
Agreed! For a later PR perhaps.
I think this is the correct behavior, sounds good! Also, I'd love to be able to make some space-savings over in js-joda-locale also! Let me know over in that thread if you have any ideas for improvements. |
Fixes #67.
Changes
This PR changes the build process such that three new dev/prod bundles are produced:
js-joda-timezone-10-year-range.js
which includes timezone data for +- five years from the current version's releasejs-joda-timezone-1970-2030.js
which includes timezone data for covers from 1970 to 2030js-joda-timezone-2012-2022.js
which includes timezone data for covers from 2012 to 2022These bundles intentionally echo what moment-timezone provides.
Users can choose to use these bundles in their code by simply importing them:
Here are the file sizes of the new bundles compared to the current bundle:
Minified bundle sizes:
Build Steps
latest.json
should be copied over todata/unpacked/latest.json
.2018h.json
, can be copied over todata/packed/<name>
if it isn't yet.npm run transform-data
to generate all thedata/packed/latest*.json
files. (Note that CI doesn't have to run this step since I checked the generated files in.)npm run build-dist
to build all the.js
bundles based on thelatest*.json
files available.A few caveats / questions for maintainers:
npm
was acting strangely for me and modifying much too mock of thepackage-lock.json
file so I had to manuallyadd -p
it and it's possible things went wrong. Feel free to change it or make any other changes to this PR also, or comment and I'm happy to make changes.js-joda-timezone-10-year-range.js
and you have aZonedDateTime
outside of that range, is the behavior graceful?data/packed/2018h.json
throughdata/packed/2019a.json
while I was modifying things, but happy to remove them if that's too orthogonal to this PR.