Moment-timezone: Provide example on how to import moment-timezone without data using npm

Created on 13 May 2019  路  4Comments  路  Source: moment/moment-timezone

When moment-timezone is istalled as npm package:

npm install moment-timezone --save

and imported like this:

import * as moment from 'moment-timezone';

it imports also all data.

In the documentation, provide an example, how to import it without data

Most helpful comment

Here's how I do it:
import moment from 'moment-timezone/moment-timezone';

It's not the official way (I couldn't find it in the docs either), so there is no guarantee it'll work in a future release of the library.

All 4 comments

Here's how I do it:
import moment from 'moment-timezone/moment-timezone';

It's not the official way (I couldn't find it in the docs either), so there is no guarantee it'll work in a future release of the library.

... would love to know how to tackle this. Is there some other package from npm that has just the +- 5 year data, like is available via CDN?

You can also you moment-timezone-data-webpack-plugin to specify exact year ranges and timezones - webpack will take care of the rest :)

How do we do that in react-native? We don't use webpack there.. :/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ciaoben picture ciaoben  路  3Comments

guidsen picture guidsen  路  4Comments

mj1856 picture mj1856  路  5Comments

garryyao picture garryyao  路  4Comments

palindrom615 picture palindrom615  路  4Comments