Skip to content

Commit e8b374c

Browse files
committed
Revamp the readme.
1 parent 8de11e2 commit e8b374c

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- Revamped the readme:
2626
- Removed the badges.
2727
- Updated the “Examples” section to reflect the [`graphql-react` examples repo](https://github.com/jaydenseric/graphql-react-examples) migration from [Node.js](https://nodejs.org), [Next.js](https://nextjs.org), and [Vercel](https://vercel.com) to [Deno](https://deno.land), [Ruck](https://ruck.tech), and [Fly.io](https://fly.io).
28+
- Added information about Deno, import maps, TypeScript config, and [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design).
2829

2930
## 18.0.0
3031

readme.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,36 @@ The [exports](#exports) can also be used to custom load, cache and server side r
1313

1414
## Installation
1515

16-
First, polyfill any required globals (see [_**Requirements**_](#requirements)) that are missing in your server and client environments.
16+
> **Note**
17+
>
18+
> For a [Next.js](https://nextjs.org) project, see the [`next-graphql-react`](https://npm.im/next-graphql-react) installation instructions.
1719
18-
### Next.js setup
20+
For [Node.js](https://nodejs.org), to install [`graphql-react`](https://npm.im/graphql-react) and its [`react`](https://npm.im/react) peer dependency with [npm](https://npmjs.com/get-npm), run:
1921

20-
See the [`next-graphql-react`](https://npm.im/next-graphql-react) setup instructions.
21-
22-
### Custom React setup
22+
```sh
23+
npm install graphql-react react
24+
```
2325

24-
To install with [npm](https://npmjs.com/get-npm), run:
26+
For [Deno](https://deno.land) and browsers, an example import map (realistically use 4 import maps, with optimal URLs for server vs client and development vs production):
2527

26-
```sh
27-
npm install graphql-react
28+
```json
29+
{
30+
"imports": {
31+
"extract-files/": "https://unpkg.com/extract-files@12.0.0/",
32+
"graphql-react/": "https://unpkg.com/graphql-react@18.0.0/",
33+
"react": "https://esm.sh/react@18.2.0",
34+
"react-waterfall-render/": "https://unpkg.com/react-waterfall-render@4.0.1/"
35+
}
36+
}
2837
```
2938

39+
These dependencies might not need to be in the import map, depending on what [`graphql-react`](https://npm.im/graphql-react) modules the project imports from:
40+
41+
- [`extract-files`](https://npm.im/extract-files)
42+
- [`react-waterfall-render`](https://npm.im/react-waterfall-render)
43+
44+
Polyfill any required globals (see [_**Requirements**_](#requirements)) that are missing in your server and client environments.
45+
3046
Create a single [`Cache`](#class-cache) instance and use the [`Provider`](#function-dataprovider) component to provide it for your app.
3147

3248
To server side render your app, use the [`waterfallRender`](https://github.com/jaydenseric/react-waterfall-render#function-waterfallrender) function from [`react-waterfall-render`](https://npm.im/react-waterfall-render).
@@ -130,8 +146,11 @@ export default function GitHubRepoStars({ repoId }) {
130146

131147
## Requirements
132148

133-
- [Node.js](https://nodejs.org): `^14.17.0 || ^16.0.0 || >= 18.0.0`
134-
- [Browsers](https://npm.im/browserslist): `> 0.5%, not OperaMini all, not dead`
149+
Supported runtime environments:
150+
151+
- [Node.js](https://nodejs.org) versions `^14.17.0 || ^16.0.0 || >= 18.0.0`.
152+
- [Deno](https://deno.land), importing from a CDN that might require an import map for dependencies.
153+
- Browsers matching the [Browserslist](https://npm.im/browserslist) query `> 0.5%, not OperaMini all, not dead`.
135154

136155
Consider polyfilling:
137156

@@ -143,9 +162,15 @@ Consider polyfilling:
143162
- [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
144163
- [`performance`](https://developer.mozilla.org/en-US/docs/Web/API/Window/performance)
145164

165+
Non [Deno](https://deno.land) projects must configure [TypeScript](https://typescriptlang.org) to use types from the ECMAScript modules that have a `// @ts-check` comment:
166+
167+
- [`compilerOptions.allowJs`](https://typescriptlang.org/tsconfig#allowJs) should be `true`.
168+
- [`compilerOptions.maxNodeModuleJsDepth`](https://typescriptlang.org/tsconfig#maxNodeModuleJsDepth) should be reasonably large, e.g. `10`.
169+
- [`compilerOptions.module`](https://typescriptlang.org/tsconfig#module) should be `"node16"` or `"nodenext"`.
170+
146171
## Exports
147172

148-
These ECMAScript modules are published to [npm](https://npmjs.com) and exported via the [`package.json`](./package.json) `exports` field:
173+
The [npm](https://npmjs.com) package [`graphql-react`](https://npm.im/graphql-react) features [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design). It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the [`package.json`](./package.json) field [`exports`](https://nodejs.org/api/packages.html#exports):
149174

150175
- [`Cache.mjs`](./Cache.mjs)
151176
- [`CacheContext.mjs`](./CacheContext.mjs)

0 commit comments

Comments
 (0)