Skip to content

Commit f3984c7

Browse files
authored
Improve monorepo setup and include examples in pipeline
* Add contribution guide. * Hoist devDependencies up to root and clean up the root dependencies. * Prettier v1.17.1 is incompatible with prettier-vscode. * Setup relative-deps for the examples. * Setup a test:examples script and include it in CI. * Fix nextjs build. * Specify relative-deps in each example, to hopefully make Travis happy. * Travis apparently doesn't support 'yarn workspaces'.
1 parent 15422e4 commit f3984c7

File tree

14 files changed

+1204
-3104
lines changed

14 files changed

+1204
-3104
lines changed

CONTRIBUTING.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Contributing to React Async
2+
3+
Thanks for your interest in improving React Async! Contributions of any kind are welcome. Please refer to this guide before opening an issue or pull request.
4+
5+
This repo relies on Yarn workspaces, so you should [install](https://yarnpkg.com/en/docs/install) and use `[email protected]` or higher as the package manager for this project.
6+
7+
## Development guide
8+
9+
Please have the **_latest_** stable versions of the following on your machine
10+
11+
- node
12+
- yarn
13+
14+
### Initial setup
15+
16+
To start working on React Async, clone the repo and bootstrap the project:
17+
18+
```sh
19+
git clone https://github.com/ghengeveld/react-async.git
20+
cd react-async
21+
yarn && yarn bootstrap && yarn test
22+
```
23+
24+
### Working with Storybook
25+
26+
We use Storybook as a development environment, particularly for the DevTools. Spin it up using:
27+
28+
```sh
29+
yarn storybook
30+
```
31+
32+
This should open up Storybook in a browser at http://localhost:6006/
33+
Run it side-by-side with `yarn test --watch` during development. See [Testing](#testing).
34+
35+
### Linting
36+
37+
Use `yarn lint` to verify your code style before committing. It's highly recommended to install the Prettier and ESLint plugins for your IDE. Travis CI will fail your build on lint errors. Configure VS Code with the following settings:
38+
39+
```plaintext
40+
"eslint.autoFixOnSave": true,
41+
"eslint.packageManager": "yarn",
42+
"eslint.options": {
43+
"cache": true,
44+
"cacheLocation": ".cache/eslint",
45+
"extensions": [".js", ".jsx", ".mjs", ".json", ".ts", ".tsx"]
46+
},
47+
"eslint.validate": [
48+
"javascript",
49+
"javascriptreact",
50+
{"language": "typescript", "autoFix": true },
51+
{"language": "typescriptreact", "autoFix": true }
52+
],
53+
"eslint.alwaysShowStatus": true
54+
```
55+
56+
This should enable auto-fix for all source files, and give linting warnings and errors within your editor.
57+
58+
### Testing
59+
60+
Use the following command to test all packages in watch mode. Refer to the [Jest CLI options](https://jestjs.io/docs/en/cli#options) for details.
61+
62+
```sh
63+
yarn test --watch
64+
```
65+
66+
In general, this is sufficient during development. Travis CI will apply a more rigorous set of tests.
67+
68+
#### Testing for compatibility
69+
70+
```sh
71+
yarn test:compat
72+
```
73+
74+
This runs all tests using various versions of `react` and `react-dom`, to check for compatibility with older/newer versions of React. This is what Travis runs.
75+
76+
### Working with the examples
77+
78+
In the `examples` folder, you will find sample React applications that use React Async in various ways with various other libraries. Please add a new example when introducing a major new feature.

examples/basic-fetch/package.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,29 @@
22
"name": "basic-fetch",
33
"version": "1.0.0",
44
"private": true,
5+
"scripts": {
6+
"postinstall": "relative-deps",
7+
"prestart": "relative-deps",
8+
"prebuild": "relative-deps",
9+
"pretest": "relative-deps",
10+
"start": "react-scripts start",
11+
"build": "react-scripts build",
12+
"test": "react-scripts test",
13+
"now-build": "npm run build && mv build dist"
14+
},
515
"dependencies": {
616
"react": "^16.8.6",
7-
"react-async": "latest",
8-
"react-async-devtools": "latest",
17+
"react-async": "^7.0.4",
18+
"react-async-devtools": "^1.0.2",
919
"react-dom": "^16.8.6",
1020
"react-scripts": "^3.0.1"
1121
},
12-
"scripts": {
13-
"start": "react-scripts start",
14-
"build": "react-scripts build",
15-
"now-build": "npm run build && mv build dist"
22+
"devDependencies": {
23+
"relative-deps": "^0.1.2"
24+
},
25+
"relativeDependencies": {
26+
"react-async": "../../packages/react-async/pkg",
27+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
1628
},
1729
"eslintConfig": {
1830
"extends": "react-app"

examples/basic-hook/package.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22
"name": "basic-hook",
33
"version": "1.0.1",
44
"private": true,
5-
"dependencies": {
6-
"react": "16.8.5",
7-
"react-async": "latest",
8-
"react-async-devtools": "latest",
9-
"react-dom": "16.8.5",
10-
"react-scripts": "2.1.8"
11-
},
125
"scripts": {
6+
"postinstall": "relative-deps",
7+
"prestart": "relative-deps",
8+
"prebuild": "relative-deps",
9+
"pretest": "relative-deps",
1310
"start": "react-scripts start",
1411
"build": "react-scripts build",
12+
"test": "react-scripts test",
1513
"now-build": "npm run build && mv build dist"
1614
},
15+
"dependencies": {
16+
"react": "^16.8.6",
17+
"react-async": "^7.0.4",
18+
"react-async-devtools": "^1.0.2",
19+
"react-dom": "^16.8.6",
20+
"react-scripts": "^3.0.1"
21+
},
22+
"devDependencies": {
23+
"relative-deps": "^0.1.2"
24+
},
25+
"relativeDependencies": {
26+
"react-async": "../../packages/react-async/pkg",
27+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
28+
},
1729
"eslintConfig": {
1830
"extends": "react-app"
1931
},

examples/custom-instance/package.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22
"name": "custom-instance",
33
"version": "1.0.0",
44
"private": true,
5-
"dependencies": {
6-
"react": "^16.8.5",
7-
"react-async": "latest",
8-
"react-async-devtools": "latest",
9-
"react-dom": "^16.8.5",
10-
"react-scripts": "2.1.8"
11-
},
125
"scripts": {
6+
"postinstall": "relative-deps",
7+
"prestart": "relative-deps",
8+
"prebuild": "relative-deps",
9+
"pretest": "relative-deps",
1310
"start": "react-scripts start",
1411
"build": "react-scripts build",
12+
"test": "react-scripts test",
1513
"now-build": "npm run build && mv build dist"
1614
},
15+
"dependencies": {
16+
"react": "^16.8.6",
17+
"react-async": "^7.0.4",
18+
"react-async-devtools": "^1.0.2",
19+
"react-dom": "^16.8.6",
20+
"react-scripts": "^3.0.1"
21+
},
22+
"devDependencies": {
23+
"relative-deps": "^0.1.2"
24+
},
25+
"relativeDependencies": {
26+
"react-async": "../../packages/react-async/pkg",
27+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
28+
},
1729
"eslintConfig": {
1830
"extends": "react-app"
1931
},

examples/movie-app/package.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22
"name": "movie-app",
33
"version": "1.0.1",
44
"private": true,
5-
"dependencies": {
6-
"react": "^16.8.5",
7-
"react-async": "latest",
8-
"react-async-devtools": "latest",
9-
"react-dom": "^16.8.5",
10-
"react-scripts": "2.1.8"
11-
},
125
"scripts": {
6+
"postinstall": "relative-deps",
7+
"prestart": "relative-deps",
8+
"prebuild": "relative-deps",
9+
"pretest": "relative-deps",
1310
"start": "react-scripts start",
1411
"build": "react-scripts build",
12+
"test": "react-scripts test",
1513
"now-build": "npm run build && mv build dist"
1614
},
15+
"dependencies": {
16+
"react": "^16.8.6",
17+
"react-async": "^7.0.4",
18+
"react-async-devtools": "^1.0.2",
19+
"react-dom": "^16.8.6",
20+
"react-scripts": "^3.0.1"
21+
},
22+
"devDependencies": {
23+
"relative-deps": "^0.1.2"
24+
},
25+
"relativeDependencies": {
26+
"react-async": "../../packages/react-async/pkg",
27+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
28+
},
1729
"eslintConfig": {
1830
"extends": "react-app"
1931
},

examples/with-abortcontroller/package.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@
22
"name": "with-abortcontroller",
33
"version": "1.0.0",
44
"private": true,
5-
"dependencies": {
6-
"react": "16.8.5",
7-
"react-async": "latest",
8-
"react-async-devtools": "latest",
9-
"react-dom": "16.8.5",
10-
"react-scripts": "2.1.8"
11-
},
125
"scripts": {
6+
"postinstall": "relative-deps",
7+
"prestart": "relative-deps",
8+
"prebuild": "relative-deps",
9+
"pretest": "relative-deps",
1310
"start": "react-scripts start",
1411
"build": "react-scripts build",
12+
"test": "react-scripts test",
1513
"now-build": "npm run build && mv build dist"
1614
},
15+
"dependencies": {
16+
"react": "^16.8.6",
17+
"react-async": "^7.0.4",
18+
"react-async-devtools": "^1.0.2",
19+
"react-dom": "^16.8.6",
20+
"react-scripts": "^3.0.1"
21+
},
22+
"devDependencies": {
23+
"relative-deps": "^0.1.2"
24+
},
25+
"relativeDependencies": {
26+
"react-async": "../../packages/react-async/pkg",
27+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
28+
},
1729
"eslintConfig": {
1830
"extends": "react-app"
1931
},

examples/with-nextjs/next.config.js

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

examples/with-nextjs/package.json

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,31 @@
22
"name": "with-nextjs",
33
"version": "1.0.2",
44
"private": true,
5-
"description": "",
65
"main": "index.js",
76
"scripts": {
7+
"postinstall": "relative-deps",
8+
"predev": "relative-deps",
9+
"prebuild": "relative-deps",
10+
"prestart": "relative-deps",
11+
"pretest": "relative-deps",
812
"dev": "next",
913
"build": "next build",
10-
"start": "next start"
14+
"start": "next start",
15+
"test": "true"
1116
},
12-
"keywords": [],
13-
"author": "",
14-
"license": "ISC",
1517
"dependencies": {
16-
"@weco/next-plugin-transpile-modules": "^2.2.1",
17-
"isomorphic-fetch": "2.2.1",
18-
"next": "8.0.3",
19-
"react": "16.8.5",
20-
"react-async": "latest",
21-
"react-async-devtools": "latest",
22-
"react-dom": "16.8.5"
18+
"isomorphic-fetch": "^2.2.1",
19+
"next": "^8.0.3",
20+
"react": "^16.8.6",
21+
"react-async": "^7.0.4",
22+
"react-async-devtools": "^1.0.2",
23+
"react-dom": "^16.8.6"
24+
},
25+
"devDependencies": {
26+
"relative-deps": "^0.1.2"
27+
},
28+
"relativeDependencies": {
29+
"react-async": "../../packages/react-async/pkg",
30+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
2331
}
2432
}

examples/with-react-router/package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@
44
"private": true,
55
"main": "index.js",
66
"scripts": {
7-
"start": "parcel index.html"
7+
"postinstall": "relative-deps",
8+
"prestart": "relative-deps",
9+
"pretest": "relative-deps",
10+
"start": "parcel index.html",
11+
"test": "true"
812
},
913
"dependencies": {
1014
"@babel/preset-react": "^7.0.0",
1115
"parcel-bundler": "^1.12.3",
12-
"react": "^16.8.5",
13-
"react-async": "latest",
14-
"react-async-devtools": "latest",
15-
"react-dom": "^16.8.5",
16+
"react": "^16.8.6",
17+
"react-async": "^7.0.4",
18+
"react-async-devtools": "^1.0.2",
19+
"react-dom": "^16.8.6",
1620
"react-router-dom": "^5.0.0"
1721
},
1822
"devDependencies": {
19-
"@babel/core": "^7.4.0"
23+
"relative-deps": "^0.1.2"
24+
},
25+
"relativeDependencies": {
26+
"react-async": "../../packages/react-async/pkg",
27+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
2028
}
2129
}

examples/with-typescript/package.json

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,32 @@
22
"name": "with-typescript",
33
"version": "1.0.1",
44
"private": true,
5+
"scripts": {
6+
"postinstall": "relative-deps",
7+
"prestart": "relative-deps",
8+
"prebuild": "relative-deps",
9+
"pretest": "relative-deps",
10+
"start": "react-scripts start",
11+
"build": "react-scripts build",
12+
"test": "react-scripts test"
13+
},
514
"dependencies": {
615
"@types/node": "^12.0.8",
716
"@types/react": "^16.8.19",
817
"@types/react-dom": "^16.8.4",
918
"react": "^16.8.6",
10-
"react-async": "latest",
11-
"react-async-devtools": "latest",
19+
"react-async": "^7.0.4",
20+
"react-async-devtools": "^1.0.2",
1221
"react-dom": "^16.8.6",
1322
"react-scripts": "^3.0.1",
1423
"typescript": "^3.5.1"
1524
},
16-
"scripts": {
17-
"start": "react-scripts start",
18-
"build": "react-scripts build",
19-
"test": "react-scripts test",
20-
"eject": "react-scripts eject"
25+
"devDependencies": {
26+
"relative-deps": "^0.1.2"
27+
},
28+
"relativeDependencies": {
29+
"react-async": "../../packages/react-async/pkg",
30+
"react-async-devtools": "../../packages/react-async-devtools/pkg"
2131
},
2232
"eslintConfig": {
2333
"extends": "react-app"

0 commit comments

Comments
 (0)