Skip to content

Commit 04afbba

Browse files
committed
feat: Support ESM properly
* Build ESM output to dist * Announce ESM exports in package.json * Add exports for lookup-convert, parse-format, data and limited data * Replace `commander` with a hand-coded command-line parsing * Upgrade dev dependencies * Replace npm with pnpm (worked slower) * Replace cpy-cli with cp.js (started to create wrong paths) * Replace eslint with denolint (worked slower) * Replace coveralls with codecov (they cancel accounts) * Replace travis with github actions (more work to maintain) BREAKING CHANGE: The initial ESM support exposed the sources at paths like `src/index.js` and worked only if you used a bundler. **The proper ESM support** has been provided by files built to paths like `dist/index.mjs`, which are mapped to export modules in `package.json`. For example, if you imported the main module like this: import { getZonedTime } from ./node_modules/timezone-support/src/index.js Change it to this: import { getZonedTime } from timezone-support See also sections "Loading" and "Modules" in `API.md`. **Replacing `commander` in `create-timezone-data`** with a hand-coded command-line parsing should not affect anybody, because the command-line format did not change, but there might be some undetected difference. Declaring export modules in `package.json` **works reliably since Node.js 14.8**, but the rest of the source code and loading the files from the `dist` directory directly should work since Node.js 6. The script `create-timezone-data` needs the `fs/promises` implementation, which was introduced in Node.js 14.
1 parent 986ddc4 commit 04afbba

37 files changed

Lines changed: 5015 additions & 12213 deletions

.coveralls.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.denolint.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"tags": ["recommended"]
4+
}
5+
}

.eslintrc.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Test or Release
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
test-or-release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout Sources
12+
uses: actions/checkout@v2
13+
- name: Install Node
14+
uses: actions/setup-node@v2
15+
with:
16+
node-version: 'lts/*'
17+
registry-url: 'https://registry.npmjs.org'
18+
- name: Install PNPM
19+
uses: pnpm/action-setup@v2
20+
with:
21+
version: '>=6'
22+
run_install: |
23+
- args: [--frozen-lockfile, --no-verify-store-integrity]
24+
- name: Test
25+
run: npm test
26+
- name: Examples
27+
run: |
28+
cd examples/nodejs
29+
pnpm i --frozen-lockfile --no-verify-store-integrity
30+
npm test
31+
cd ../browser-separate
32+
pnpm i --frozen-lockfile --no-verify-store-integrity
33+
npm test
34+
cd ../browser-bundled
35+
pnpm i --frozen-lockfile --no-verify-store-integrity
36+
npm test
37+
- name: Coverage
38+
uses: codecov/codecov-action@v2
39+
- name: Publish
40+
uses: cycjimmy/semantic-release-action@v2
41+
with:
42+
semantic_version: 18
43+
branches: master
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ src/lookup/data*.js
77
src/index-*.d.ts
88
src/lookup/data-*.d.ts
99
test/browser
10-
test/typings.test.js
10+
test/types.test.js

.npmignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"search.exclude": {
77
"**/src/lookup/data*.js": true,
88
"**/dist/**": true,
9+
"**/out/**": true,
910
"**/test/browser/**": true,
1011
"**/test/typings.test.js": true
1112
}

README.md

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
# Time Zone Support
2-
[![NPM version](https://badge.fury.io/js/timezone-support.png)](http://badge.fury.io/js/timezone-support)
3-
[![Build Status](https://travis-ci.org/prantlf/timezone-support.png)](https://travis-ci.org/prantlf/timezone-support)
4-
[![Coverage Status](https://coveralls.io/repos/github/prantlf/timezone-support/badge.svg?branch=master)](https://coveralls.io/github/prantlf/timezone-support?branch=master)
2+
3+
[![Latest version](https://img.shields.io/npm/v/timezone-support)
4+
![Dependency status](https://img.shields.io/librariesio/release/npm/timezone-support)
5+
](https://www.npmjs.com/package/timezone-support)
6+
[![Coverage](https://codecov.io/gh/prantlf/timezone-support/branch/master/graph/badge.svg)](https://codecov.io/gh/prantlf/timezone-support)
57
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/9f1034029c0747a980cd49f64f16338b)](https://www.codacy.com/app/prantlf/timezone-support?utm_source=github.com&utm_medium=referral&utm_content=prantlf/timezone-support&utm_campaign=Badge_Grade)
6-
[![Dependency Status](https://david-dm.org/prantlf/timezone-support.svg)](https://david-dm.org/prantlf/timezone-support)
7-
[![devDependency Status](https://david-dm.org/prantlf/timezone-support/dev-status.svg)](https://david-dm.org/prantlf/timezone-support#info=devDependencies)
8-
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
98

10-
[![NPM Downloads](https://nodei.co/npm/timezone-support.png?downloads=true&stars=true)](https://www.npmjs.com/package/timezone-support)
119

1210
Lightweight time zone listing and date converting. Intended for adding time zone support to high-level date libraries, but also for direct application usage.
1311

1412
* Tiny code base - 4.6 KB minified, 1.7 KB gzipped. Do not pack unnecessary weight in your application.
1513
* Packed time zone data - 924 KB minified, 33.6 KB gzipped. Single time zones are unpacked on demand.
1614
* Smaller bundles of code with limited data - 1900-2050 (206 kB minified, 25.4 kB gzipped), 1970-2038 (141 kB minified, 15.8 kB gzipped) and 2012-2022 (31.3 KB minified, 8.25 kB gzipped).
17-
* Generated from the official time zone database version 2019a. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
15+
* Generated from the official time zone database version 2022f. Canonical time zone names, aliases, UTC offsets, and daylight-saving time changes.
16+
* ESM, UMD and CJS module formats provided.
1817
* Minimal interface for time zone lookup and conversions. Parsing, formatting and manipulating dates is usually the task for a higher-level date library.
1918

2019
**Attention**: exported identifiers in vanilla browser modules changed in the version 2.0.0. See the [migration guide] for more information.
@@ -56,13 +55,11 @@ const nativeDate = new Date(getUnixTime(berlinTime, berlin))
5655

5756
## Installation and Getting Started
5857

59-
This module can be installed in your project using [NPM] or [Yarn]. Make sure, that you use [Node.js] version 6 or newer.
60-
61-
```sh
62-
$ npm i timezone-support --save
63-
```
58+
This module can be installed in your project using [NPM], [PNPM] or [Yarn]. Make sure, that you use [Node.js] version 14.8 or newer.
6459

6560
```sh
61+
$ npm i timezone-support
62+
$ pnpm i timezone-support
6663
$ yarn add timezone-support
6764
```
6865

@@ -72,7 +69,7 @@ Functions are exposed as named exports from the package modules, for example:
7269
const { findTimeZone, getZonedTime } = require('timezone-support')
7370
```
7471

75-
You can read more about the [module loading](./docs/API.md#loading) in other environments, like with ES6 or in web browsers. [Usage scenarios](./docs/usage.md#usage-scenarios) demonstrate applications of this library in typical real-world scenarios. [Design concepts](./docs/design.md#design-concepts) explain the approach to time zone handling taken by tni library and types of values used ion the interface. [Generating custom time zone data](./docs/usage.md#generate-custom-time-zone-data) will allow you to save the overall package size by limiting the supported year span. Finally, the [API reference](./docs/API.md#api-reference) lists all functions with a description of their functionality.
72+
You can read more about the [module loading] in other environments, like with ES6 or in web browsers. [Usage scenarios] demonstrate applications of this library in typical real-world scenarios. [Design concepts] explain the approach to time zone handling taken by tni library and types of values used ion the interface. [Generating custom time zone data] will allow you to save the overall package size by limiting the supported year span. Finally, the [API reference] lists all functions with a description of their functionality.
7673

7774
You can see [complete sample applications] too, which can help you start with integration of this library.
7875

@@ -85,34 +82,24 @@ You can see [complete sample applications] too, which can help you start with in
8582

8683
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
8784

88-
## Release History
89-
90-
* 2018-06-11 v2.0.2 Upgrade the time zone database to the version 2019a.
91-
* 2018-06-11 v2.0.1 Default to midnight, if the time part of a date is missing.
92-
* 2018-06-10 v2.0.0 Use proper identifiers in vanilla browser modules.
93-
* 2018-11-17 v1.8.0 Include time zone data for years 1970-2038.
94-
* 2018-11-17 v1.7.0 Include full time zone data separately loadable.
95-
* 2018-11-06 v1.6.0 Upgrade the time zone database to the version 2018g.
96-
* 2018-10-08 v1.5.5 Fix compatibility with IE. Thanks, [Andrii](https://github.com/AndriiDidkivsky)!
97-
* 2018-10-06 v1.5.0 Add TypeScript export declarations.
98-
* 2018-09-30 v1.4.0 Add limited data for just the current decade - years 2012-2022.
99-
* 2018-09-18 v1.3.0 Maintain the property dayOfWeek in the time object.
100-
* 2018-09-16 v1.2.0 Add a new getUTCOffset method for more lightweight integrations.
101-
* 2018-09-03 v1.1.0 Set the property epoch to the time object.
102-
* 2018-09-02 v1.0.0 Initial release
103-
10485
## License
10586

106-
Copyright (c) 2018-2019 Ferdinand Prantl
87+
Copyright (c) 2018-2022 Ferdinand Prantl
10788

10889
Licensed under the MIT license.
10990

11091
[Node.js]: http://nodejs.org/
11192
[NPM]: https://www.npmjs.com/
112-
[RequireJS]: https://requirejs.org/
93+
[PNPM]: https://pnpm.io/
94+
[Yarn]: https://yarnpkg.com/
11395
[Day.js]: https://github.com/iamkun/dayjs
11496
[date-fns]: https://github.com/date-fns/date-fns
11597
[timeZone plugin]: https://github.com/prantlf/dayjs/blob/combined/docs/en/Plugin.md#timezone
11698
[date-fns-timezone]: https://github.com/prantlf/date-fns-timezone
11799
[migration guide]: docs/migration.md#migration-from-1x-to-2x
118100
[complete sample applications]: examples#readme
101+
[module loading]: ./docs/API.md#loading
102+
[Usage scenarios]: ./docs/usage.md#usage-scenarios
103+
[Design concepts]: ./docs/design.md#design-concepts
104+
[Generating custom time zone data]: ./docs/usage.md#generate-custom-time-zone-data
105+
[API reference]: ./docs/API.md#api-reference

bin/create-timezone-data

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)