I am using react-dates in my next.js project. Right now I am working on localisation. As I am very keen on having a good performance I don't want to import moment.js synchronous as it is very heavy according to bundlephobia and my own experience (https://bundlephobia.com/result?p=moment@2.29.1). I want to load moment asynchronous (dynamic import in next.js).
This code works synchronous (normal import statement) in the render function but of course it doesn't work if I load moment dynamic.
import moment from 'moment';
...
render () {
...
moment.updateLocale('en', {
week: {
dow: 1,
},
})
...
}
So how can I load moment dynamically and update the locale? Is there a way?
Thank you!