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

Depend on Intl.RelativeTimeFormat directly instead of loading 'relative-time-format' library. #21

Open
andrejpavlovic opened this issue Sep 5, 2019 · 6 comments

Comments

@andrejpavlovic
Copy link

Would it be possible to use this library without relative-time-format being a required dependency? I would like to load "relative-time-format" as a polyfill only where necessary, and rely on browser native Intl.RelativeTimeFormat when it is available.

@catamphetamine
Copy link
Owner

@andrejpavlovic Yes, there's currently a rewrite pending that will allow optional importing of the polyfill.
Maybe somewhere in October.

@dandv
Copy link

dandv commented Oct 25, 2019

The RelativeTimeFormat API just got popular on Twitter :)

@catamphetamine
Copy link
Owner

catamphetamine commented Oct 25, 2019

@dandv Woow, that's where all those recent stars came from...
I figured someone popular has shared it somewhere on social media.
Cool )

As an update to this issue, I still haven't started it yet (have had some other things to do).
I was planning to move this package into relative-time-format as a subpackage.
Maybe something like relative-time-format/advanced (or a better name).
I also thought whether I should move the present relative-time-format into relative-time-format/polyfill instead, and then the default export of relative-time-format would be this package's API.
I guess it depends on which package is more popular.
We'll see...

@stof
Copy link

stof commented Jul 27, 2020

is there any news on this rewrite ?

@catamphetamine
Copy link
Owner

@stof I guess I should.
Maybe in August or September.

@catamphetamine
Copy link
Owner

In version javascript-time-ago@2.2.0 I've added the ability to use native Intl.RelativeTimeFormat and Intl.PluralRules instead of the polyfills: in this case, pass polyfill: false option when creating a TimeAgo instance.

The polyfill: false option still doesn't skip importing the polyfill, so it won't affect the bundle size.
It's of no concern though, because the polyfill is 3.5 kB in size which is small enough.
https://github.com/tc39/proposal-intl-relative-time#polyfills

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

No branches or pull requests

4 participants