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

A version without built-in locales? #204

Closed
OrKoN opened this issue Oct 25, 2019 · 3 comments
Closed

A version without built-in locales? #204

OrKoN opened this issue Oct 25, 2019 · 3 comments

Comments

@OrKoN
Copy link
Contributor

OrKoN commented Oct 25, 2019

Hi!

Thanks for working on the lib and a new version. I am wondering if it's possible to exclude built-in locales (en and ch_ZN) from the bundle. In my use case, I generate code bundles per language and I manually register the correct language in the build process. It'd be good to remove the built-in ones when a different language is used, to reduce the bundle size. Anyway, not a big deal, but what do you think?

Best regards,
Alex

@hustcc
Copy link
Owner

hustcc commented Oct 25, 2019

So 3 bundle:

  • timeago.none.min.js
  • timeago.min.js
  • timeago.full.min.js

Also should ensure the commonjs has build-in locales. There seems to be no good way?

@OrKoN
Copy link
Contributor Author

OrKoN commented Oct 25, 2019

I am using ESM so not using the bundles published to npm. Probably, I didn't express it right: I'd like to exclude built-in locales from my bundle not the bundles published by timeago.js to npm. My code is like this:

import currentLocale from 'timeago.js/esm/lang/uk';
import { format, register } from 'timeago.js';
register('currentLocale', currentLocale);

I guess until the built-in locales are imported for the register function https://github.com/hustcc/timeago.js/blob/master/src/locales.ts#L8 my bundler cannot optimize and strip the built-in locales from my bundle.

@hustcc
Copy link
Owner

hustcc commented Oct 25, 2019

If remove build-in locales in locases.ts, the esm / commonjs will contains none build-in locales.

The plan is:

  1. remove build-in locales in locases.ts
  2. add core.ts to export api
  3. export core api, and register build-in locales

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

2 participants