Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Clone in Desktop Download ZIP

Loading…

How to use different locales with browserify/npm build? #10

Closed
tume opened this Issue · 4 comments

2 participants

@tume

It seems that the commonjs version always includes its own momentjs so I couldn't find any way to include different locales. Any preferred way for achieving this?

@radubrehar
Owner

Hi Tuomas.

I've just published v1.4.1 to npm, please make sure you update to that, it won't include it's own momentjs any more.

If you want to use a custom locale, simply require the appropriate momentjs locale before require-ing react-date-picker

Example:

//make sure you require this first!
var nl = require('moment/locale/nl')

//and then require the date picker - it will use the locale you previously required
var DatePicker = require('react-date-picker')

(See the updated README at https://www.npmjs.com/package/react-date-picker)

Please do let me know how it goes!

@tume

Even after updating to 1.4.1 I'm seeing the same problem...and it seems still to install its own momentjs?

@radubrehar
Owner

Thanks for the feedback.
The problem was with the momentjs dependency pointing to ~2.8.3. I just created a test app, including momentjs 2.9.0. The bundling process included both the momentjs specified by react-date-picker and the one specified by the app. Updating the dependency in react-date-picker to point to ^2.8.0 (and using npm dedupe) fixed the issue.

So please update to v1.4.2 published to npm.

Also you can refer to https://github.com/radubrehar/react-date-picker-test for a demo on using the date picker with a different locale.
In any case, make sure the resulting bundle (I'm using webpack, but should work pretty much the same with browserify) includes momentjs just once. If you'll have it included twice, the problem will persist

@tume

Seems to work now as advertised, thx.

@tume tume closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.