1 | # ECMAScript Modules
|
2 |
|
3 | **date-fns** v2.x provides support for
|
4 | [ECMAScript Modules](http://www.ecma-international.org/ecma-262/6.0/#sec-modules)
|
5 | that enables tree-shaking for bundlers, like [rollup.js](http://rollupjs.org)
|
6 | and [webpack](https://webpack.js.org).
|
7 |
|
8 | If you have tree-shaking enabled in your bundler, just import functions normally:
|
9 |
|
10 | ```javascript
|
11 | import { format, parse } from 'date-fns'
|
12 | import { enUS, eo } from 'date-fns/locale'
|
13 | import { addDays, addHours } from 'date-fns/fp'
|
14 | ```
|
15 |
|
16 | In TypeScript, now you can import individual functions in more idiomatic way:
|
17 |
|
18 | ```typescript
|
19 | // Before
|
20 | import * as format from 'date-fns/format'
|
21 |
|
22 | // Now
|
23 | import format from 'date-fns/format'
|
24 | ```
|