tc39 / proposal-temporal

Provides standard objects and functions for working with dates and times.
https://tc39.es/proposal-temporal/docs/
Other
3.35k stars 153 forks source link

new lightweight temporal polyfill #2060

Closed arshaw closed 2 years ago

arshaw commented 2 years ago

Hello! Thank you so much for this proposal, all the wonderful tests, and for the existing polyfill.

I've made a new Temporal polyfill that has slightly different goals than @js-temporal/polyfill. It targets more modern browsers that have BigInt support. It attempts to have smaller filesize, at the expense of strictness. Nonetheless, it is (or soon will be) spec-compliant, with all tests passing.

README: https://github.com/fullcalendar/temporal/blob/main/packages/temporal-polyfill/README.md NPM: https://www.npmjs.com/package/temporal-polyfill

It should be considered 'alpha' and requires a bit more work, but wanted to give you a heads up!

ptomato commented 2 years ago

Thanks for the info! Would you like to open a PR to add yours to the table in https://github.com/tc39/proposal-temporal#polyfills?

arshaw commented 2 years ago

I will do that! Thank you

justingrant commented 2 years ago

@arshaw this is great! So exciting to see more polyfills. Was this based on an earlier date library that was adapted to fit the Temporal API, or was it written from scratch to be a Temporal polyfill?

re: passing tests, does your polyfill also pass Test262? There are almost 4000 Temporal tests in test262. The demitasse tests (the jest-like ones you're using in your polyfill repo) are gradually being migrated over to Test262. When they're migrated they're removed from this repo which makes it easy for us to track which ones have been migrated. So if you're only copying tests from this repo then you're missing a bunch of 'em.

In addition to running your polyfill against Test262, you can also try copying tests from the @js-temporal/temporal-polyfill repo instead of this one. The demitasse tests in @js-temporal/temporal-polyfill should include almost all of the original demitasse tests from this repo, before thousands of them were migrated over to Test262.

justingrant commented 2 years ago

I'm excited to try out your new polyfill! <15K is really impressive and will be very welcome in the community.

@arshaw, you may want to coordinate with @12wrigja who's working on @js-temporal/temporal-polyfill which is what Google will be using internally. There may be an opportunity to collaborate.

re: passing tests, does your polyfill also pass Test262?

I filed https://github.com/fullcalendar/temporal/issues/3 to track this.

The demitasse tests in @js-temporal/temporal-polyfill should include almost all of the original demitasse tests from this repo, before thousands of them were migrated over to Test262.

Looks like you're only missing about 300 demitasse tests. I filed https://github.com/fullcalendar/temporal/issues/2 to track.

arshaw commented 2 years ago

@justingrant, thanks for the kind reception. My project did indeed start out as a completely different date library, then morphed into a spec-compliant Temporal implementation over time. Though, once we decided on that direction, it essentially required a rewrite. It has been an incredible amount of work.

I've commented on the demitasse test situation and the tests262 situation in the other tickets! Thank you for the pointers. I will need to get both of those systems passing before declaring victory.

@12wrigja, what are your upcoming plans for the js-temporal/temporal-polyfill repo? Mostly optimizations? (seems like it's the only item missing from the roadmap)

12wrigja commented 2 years ago

I've filed https://github.com/js-temporal/temporal-polyfill/issues/138 to capture all my thoughts on roadmaps in the right repo, feel free to comment. I'm definitely interested in persuing how you've achieved <15K and seeing if there's learnings I can apply to the js-temporal/temporal-polyfill codebase, but I'm currently very busy with other work and don't think I'll find the time for a couple weeks or so.

MohsenAlyafei commented 2 years ago

Is this polyfill available on cdn.jsdelivr for immediate access?

arshaw commented 2 years ago

@MohsenAlyafei I posted a CDN link on the package's README.

Please post future questions/comments on the project's issue tracker

ptomato commented 2 years ago

Thanks for letting us know about the polyfill! It's displayed on the front page of the repo now, so I'll close this.