Skip to content

Commit f71867c

Browse files
committedJan 6, 2022
docs: update documentation on importing the library
1 parent 013d60c commit f71867c

File tree

2 files changed

+10
-41
lines changed

2 files changed

+10
-41
lines changed
 

‎changelog.md

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to
77
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [6.0.5](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.5)
10+
11+
### Fixed
12+
13+
- Use named imports for ExpressJS types so users do not need to enable the
14+
`esModuleInterop` flag in their Typescript compiler configuration.
15+
916
## [6.0.4](https://github.com/nfriedly/express-rate-limit/releases/tag/v6.0.4)
1017

1118
### Fixed

‎readme.md

+3-41
Original file line numberDiff line numberDiff line change
@@ -58,57 +58,19 @@ Javascript and Typescript projects.
5858

5959
**This package requires you to use Node 14 or above.**
6060

61-
#### Javascript
62-
63-
Import it in a CommonJS project as follows:
61+
Import it in a CommonJS project (`type: commonjs` or no `type` field in
62+
`package.json`) as follows:
6463

6564
```ts
6665
const rateLimit = require('express-rate-limit')
6766
```
6867

69-
Import it in a ESM project as follows:
70-
71-
```ts
72-
import rateLimit from 'express-rate-limit'
73-
```
74-
75-
#### Typescript
76-
77-
If you are using this library in a Typescript project that outputs CommonJS (no
78-
`type: module` in `package.json` and `module: commonjs` in `tsconfig.json`), set
79-
`esModuleInterop` to `true` in the `compilerOptions` of your `tsconfig.json` and
80-
then import it as follows:
68+
Import it in a ESM project (`type: module` in `package.json`) as follows:
8169

8270
```ts
8371
import rateLimit from 'express-rate-limit'
8472
```
8573

86-
If you cannot set `esModuleInterop` to true, import it as follows instead:
87-
88-
```ts
89-
const rateLimit = require('express-rate-limit')
90-
```
91-
92-
And use the following to import any types if you need to:
93-
94-
```ts
95-
import { Store, IncrementResponse, ... } from 'express-rate-limit'
96-
```
97-
98-
If you are using this library in a Typescript project that outputs ESM
99-
(`type: module` in `package.json` and `module: esnext` in `tsconfig.json`),
100-
import it as follows:
101-
102-
```ts
103-
import rateLimit from 'express-rate-limit'
104-
```
105-
106-
And use the following to import any types if you need to:
107-
108-
```ts
109-
import rateLimit, { Store, IncrementResponse, ... } from 'express-rate-limit'
110-
```
111-
11274
### Examples
11375

11476
To use it in an API-only server where the rate-limiter should be applied to all

0 commit comments

Comments
 (0)
Please sign in to comment.