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

All locale files bundled? #6

Closed
theseushu opened this issue Apr 13, 2017 · 4 comments
Closed

All locale files bundled? #6

theseushu opened this issue Apr 13, 2017 · 4 comments

Comments

@theseushu
Copy link

theseushu commented Apr 13, 2017

I haven't tested yet, but seems
require('timeago.js/locales/' + this.props.locale));
will cause webpack to bundle all files under timeago.js/locales. (webpack has noway to know what value 'this.props.locale' could be, so it just includes all files in that folder)

Cannot find original docs, see this comment
webpack/webpack#38 (comment)

So code like this

  componentDidMount() {
    if (this.props.locale !== 'en' && this.props.locale !== 'zh_CN')
      timeago.register(this.props.locale, require('timeago.js/locales/' + this.props.locale));
      this.renderTimeAgo();
    },

is pretty much the same as require every thing statically.

The easiest solution shall be drop these lines, let user load locale files they need and pass to this component.

@theseushu
Copy link
Author

@hustcc
Copy link
Owner

hustcc commented Apr 13, 2017

The easiest solution shall be drop these lines, let user load locale files they need and pass to this component.

Agree with this practice.

@hustcc
Copy link
Owner

hustcc commented May 27, 2017

I think remove the code below can solve it:

timeago.register(this.props.locale, require('timeago.js/locales/' + this.props.locale));

and developers register locales out of the component, this will modify the usage, so new big version will be release.

So can help to give us a pr ?

@hustcc hustcc closed this as completed in 4ac9b5d Aug 9, 2017
@hustcc
Copy link
Owner

hustcc commented Aug 9, 2017

@theseushu The commit 4ac9b5d can solve this issue.

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