Skip to content

Commit 31f2e66

Browse files
committed
Change development scripts
Switch to npm-workspaces monorepo task management.
1 parent 50e267b commit 31f2e66

File tree

12 files changed

+87
-102
lines changed

12 files changed

+87
-102
lines changed

.github/CONTRIBUTING.md

+28-46
Original file line numberDiff line numberDiff line change
@@ -14,94 +14,76 @@ Fork, then clone the repo:
1414
git clone https://github.com/your-username/react-native-web.git
1515
```
1616

17-
Install dependencies (requires [yarn](https://yarnpkg.com/en/docs/install)):
17+
Install dependencies (requires Node.js >= 14.0):
1818

1919
```
20-
yarn
20+
npm install
2121
```
2222

23-
## Automated tests
23+
## Build
2424

25-
To run the linter:
25+
Build a specific package:
2626

2727
```
28-
yarn lint
28+
npm run build -w <package-name>
2929
```
3030

31-
To run flow:
31+
For example, this will build `react-native-web`:
3232

3333
```
34-
yarn flow
34+
npm run build -w react-native-web
3535
```
3636

37-
To run the unit tests:
37+
Build all packages that can be built:
3838

3939
```
40-
yarn jest
40+
npm run build
4141
```
4242

43-
…in watch mode:
43+
## Develop
4444

45-
```
46-
yarn jest --watch
47-
```
48-
49-
To run all these automated tests:
50-
51-
```
52-
yarn test
53-
```
54-
55-
## Compile and build
56-
57-
To compile the `react-native-web` source code:
45+
Develop a specific package:
5846

5947
```
60-
yarn compile
48+
npm run dev -w <package-name>
6149
```
6250

63-
…in watch mode:
51+
For example, this command will watch and rebuild the `react-native-web` package:
6452

6553
```
66-
yarn compile --watch
54+
npm run dev -w react-native-web
6755
```
6856

69-
## Documentation
70-
71-
To run the documentation website:
57+
And this command will watch and rebuild the `react-native-web-examples` package:
7258

7359
```
74-
yarn docs
60+
npm run dev -w react-native-web-examples
7561
```
7662

77-
## Examples
63+
## Test
7864

79-
To run the examples app:
65+
Run the monorepo linter:
8066

8167
```
82-
yarn examples
68+
npm run lint
8369
```
8470

85-
When you're also making changes to the 'react-native-web' source files, run this command in another process:
71+
Run the monorepo type checker:
8672

8773
```
88-
yarn compile --watch
74+
npm run flow
8975
```
9076

91-
## Benchmarks
92-
93-
To run the benchmarks locally:
77+
Run the monorepo unit tests:
9478

9579
```
96-
yarn benchmarks
97-
open ./packages/benchmarks/dist/index.html
80+
npm run unit
9881
```
9982

100-
To develop against these benchmarks:
83+
Run all the automated tests:
10184

10285
```
103-
yarn compile --watch
104-
yarn benchmarks --watch
86+
npm run test
10587
```
10688

10789
### New Features
@@ -115,7 +97,7 @@ Please open an issue with a proposal for a new feature or refactoring before sta
11597
1. Fork the repository and create your branch from `master`.
11698
2. If you've added code that should be tested, add tests!
11799
3. If you've changed APIs, update the documentation.
118-
4. Ensure the tests pass (`yarn test`).
100+
4. Ensure the tests pass (`npm run test`).
119101

120102
You should see a pre-commit hook run before each commit. If it does not, you may need to reset you Git hookspath:
121103

@@ -136,11 +118,11 @@ Thank you for contributing!
136118
To commit, publish, and push a final version:
137119

138120
```
139-
yarn release <version>
121+
npm run release -- <version>
140122
```
141123

142124
Release candidates or versions that you'd like to publish to npm, but do not want to produce a commit and push it to GitHub:
143125

144126
```
145-
yarn release <version> --skip-git
127+
npm run release -- <version> --skip-git
146128
```

.github/workflows/performance.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
- uses: actions/checkout@v2
1010
- uses: necolas/compressed-size-action@master
1111
with:
12-
build-script: "compile"
12+
build-script: "build -w react-native-web"
1313
exclude: "./packages/react-native-web/dist/cjs/{index.js,**/*.js}"
1414
pattern: "./packages/react-native-web/dist/{index.js,**/*.js}"
1515
repo-token: "${{ secrets.GITHUB_TOKEN }}"

.github/workflows/react-integration.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ jobs:
1313
- uses: actions/setup-node@v1
1414
with:
1515
node-version: '14.x'
16-
- run: npm install -g yarn
17-
- run: yarn install
16+
- run: npm install
1817
# Install next-tagged versions
19-
- run: yarn upgrade react@next react-dom@next -W --dev
18+
- run: npm update react@next react-dom@next
2019
# Only run the unit tests
21-
- run: yarn jest
20+
- run: npm run unit

.github/workflows/tests.yml

+8-12
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ jobs:
1515
- uses: actions/setup-node@v1
1616
with:
1717
node-version: '14.x'
18-
- run: npm install -g yarn
19-
- run: yarn install
20-
- run: yarn fmt:report
18+
- run: npm install
19+
- run: npm run format
2120

2221
type-check:
2322
runs-on: ubuntu-latest
@@ -26,9 +25,8 @@ jobs:
2625
- uses: actions/setup-node@v1
2726
with:
2827
node-version: '14.x'
29-
- run: npm install -g yarn
30-
- run: yarn install
31-
- run: yarn flow
28+
- run: npm install
29+
- run: npm run flow
3230

3331
lint:
3432
runs-on: ubuntu-latest
@@ -37,9 +35,8 @@ jobs:
3735
- uses: actions/setup-node@v1
3836
with:
3937
node-version: '14.x'
40-
- run: npm install -g yarn
41-
- run: yarn install
42-
- run: yarn lint:report
38+
- run: npm install
39+
- run: npm run lint
4340

4441
unit-test:
4542
runs-on: ubuntu-latest
@@ -48,6 +45,5 @@ jobs:
4845
- uses: actions/setup-node@v1
4946
with:
5047
node-version: '14.x'
51-
- run: npm install -g yarn
52-
- run: yarn install
53-
- run: yarn jest
48+
- run: npm install
49+
- run: npm run unit

.watchmanconfig

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
1313
* `scripts`
1414
* Contains Node.js scripts for miscellaneous tasks.
1515

16+
## Tasks
17+
18+
* `build`
19+
* Use `npm run build` to run the build script in every package.
20+
* Use `npm run build -w <package-name>` to run the build script for a specific package.
21+
* `dev`
22+
* Use `npm run dev` to run the dev script in every package.
23+
* Use `npm run dev -w <package-name>` to run the dev script for a specific package.
24+
* `test`
25+
* Use `npm run test` to run tests for every package.
26+
* Use `npm run test` to run tests for every package.
27+
1628
## Contributing
1729

1830
Development happens in the open on GitHub and we are grateful for contributions including bugfixes, improvements, and ideas.

package.json

+18-26
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,25 @@
11
{
22
"private": true,
33
"version": "0.0.0",
4-
"name": "monorepo",
4+
"name": "react-ui-monorepo",
55
"scripts": {
66
"clean": "del-cli ./packages/*/dist",
7-
"compile": "npm-run-all clean -p \"compile:* {@}\" --",
8-
"compile:commonjs": "cd packages/react-native-web && cross-env BABEL_ENV=commonjs babel --config-file ../../configs/babel.config.js src --out-dir dist/cjs --ignore \"**/__tests__\"",
9-
"compile:es": "cd packages/react-native-web && babel --config-file ../../configs/babel.config.js src --out-dir dist --ignore \"**/__tests__\"",
10-
"compile:flow": "gen-flow-files packages/react-native-web/src --out-dir packages/react-native-web/dist",
11-
"benchmarks": "cd packages/benchmarks && yarn dev",
12-
"benchmarks:build": "cd packages/benchmarks && yarn build",
13-
"benchmarks:release": "yarn benchmarks:build && git checkout gh-pages && rm -rf ./docs/benchmarks && mv packages/benchmarks/dist ./docs/benchmarks && git add -A && git commit -m \"Deploy benchmarks\" && git push origin gh-pages && git checkout -",
14-
"docs": "cd packages/react-native-web-docs && yarn dev",
15-
"docs:build": "cd packages/react-native-web-docs && yarn build",
16-
"docs:release": "yarn docs:build && git checkout gh-pages && rm -rf ./docs && mv packages/react-native-web-docs/dist ./docs && git add ./docs && git commit -m \"Deploy documentation\" && git push origin gh-pages && git checkout -",
17-
"examples": "cd packages/react-native-web-examples && yarn dev",
18-
"examples:build": "cd packages/react-native-web-examples && yarn build",
7+
"build": "npm run clean && npm run build --workspaces --if-present",
8+
"dev": "npm run dev --workspaces --if-present",
199
"flow": "flow --flowconfig-name ./configs/.flowconfig",
20-
"fmt": "prettier --write \"**/*.js\" --ignore-path ./configs/.prettierignore",
21-
"fmt:report": "prettier --check --ignore-path ./configs/.prettierignore \"**/*.js\"",
22-
"jest": "npm-run-all \"jest:* {@}\" --",
23-
"jest:dom": "jest --config ./configs/jest.config.js",
24-
"jest:node": "jest --config ./configs/jest.config.node.js",
25-
"lint": "yarn lint:report --fix",
26-
"lint:report": "eslint configs packages scripts --config ./configs/.eslintrc",
27-
"prerelease": "yarn test && yarn compile",
10+
"format": "prettier --check --ignore-path ./configs/.prettierignore \"**/*.js\"",
11+
"format:fix": "prettier --write \"**/*.js\" --ignore-path ./configs/.prettierignore",
12+
"lint": "eslint configs packages scripts --config ./configs/.eslintrc",
13+
"lint:fix": "npm run lint --fix",
14+
"prerelease": "npm run test && npm run build",
2815
"release": "node ./scripts/releaseReactNativeWebPackages.js",
29-
"postrelease": "yarn docs:release && yarn benchmarks:release",
30-
"test": "yarn flow && yarn fmt:report && yarn lint:report && yarn jest --runInBand"
16+
"release:benchmarks": "git checkout gh-pages && rm -rf ./docs/benchmarks && mv packages/benchmarks/dist ./docs/benchmarks && git add -A && git commit -m \"Deploy benchmarks\" && git push origin gh-pages && git checkout -",
17+
"release:react-native-web-docs": "git checkout gh-pages && rm -rf ./docs && mv packages/react-native-web-docs/dist ./docs && git add ./docs && git commit -m \"Deploy documentation\" && git push origin gh-pages && git checkout -",
18+
"postrelease": "npm run release:react-native-web-docs && npm run release:benchmarks",
19+
"test": "npm run flow && npm run format && npm run lint && npm run unit --runInBand",
20+
"unit": "npm-run-all \"unit:* {@}\" --",
21+
"unit:dom": "jest --config ./configs/jest.config.js",
22+
"unit:node": "jest --config ./configs/jest.config.node.js"
3123
},
3224
"devDependencies": {
3325
"@babel/cli": "^7.12.13",
@@ -83,9 +75,9 @@
8375
"git add ./packages/babel-plugin-react-native-web/src/moduleMap.js"
8476
],
8577
"**/*.js": [
86-
"prettier --write --ignore-path ./configs/.prettierignore",
87-
"git update-index --again",
88-
"yarn lint"
78+
"npm run format:fix",
79+
"npm run lint:fix",
80+
"git update-index --again"
8981
]
9082
},
9183
"prettier": {

packages/babel-plugin-react-native-web/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ import View from 'react-native-web/dist/exports/View';
4949
```
5050

5151
[package-badge]: https://img.shields.io/npm/v/babel-plugin-react-native-web.svg?style=flat
52-
[package-url]: https://yarnpkg.com/en/package/babel-plugin-react-native-web
52+
[package-url]: https://www.npmjs.com/package/babel-plugin-react-native-web

packages/benchmarks/README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22

33
Try the [benchmarks app](https://necolas.github.io/react-native-web/benchmarks) online.
44

5-
To run the benchmarks locally from monorepo root:
5+
To work on the benchmarks locally from monorepo root:
66

77
```
8-
yarn benchmarks
8+
npm run dev -w react-native-web
9+
npm run build -w benchmarks
910
open ./packages/benchmarks/dist/index.html
1011
```
1112

12-
Develop against these benchmarks from monorepo root:
13-
14-
```
15-
yarn compile --watch
16-
yarn benchmarks --watch
17-
```
18-
1913
## Notes
2014

2115
These benchmarks are approximations of extreme cases that libraries may

packages/benchmarks/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"name": "benchmarks",
44
"version": "0.0.0",
55
"scripts": {
6-
"dev": "mkdir -p dist && cp -f index.html dist/index.html && ./node_modules/.bin/webpack-cli --config ./webpack.config.js",
7-
"build": "NODE_ENV=production yarn dev"
6+
"clean": "del-cli ./dist",
7+
"build": "NODE_ENV=production npm run dev",
8+
"dev": "npm run clean && mkdir -p dist && cp -f index.html dist/index.html && ./node_modules/.bin/webpack-cli --config ./webpack.config.js"
89
},
910
"dependencies": {
1011
"classnames": "^2.3.1",

packages/react-native-web-examples/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"name": "react-native-web-examples",
44
"version": "0.18.3",
55
"scripts": {
6-
"dev": "next",
76
"build": "next build",
7+
"dev": "next",
88
"start": "next start"
99
},
1010
"dependencies": {

packages/react-native-web/package.json

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
"src",
1414
"!**/__tests__"
1515
],
16+
"scripts": {
17+
"clean": "del-cli ./dist",
18+
"build": "npm-run-all clean -p \"build:* {@}\" --",
19+
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --config-file ../../configs/babel.config.js --out-dir dist/cjs --ignore \"**/__tests__\"",
20+
"build:es": "babel src --config-file ../../configs/babel.config.js --out-dir dist --ignore \"**/__tests__\"",
21+
"build:flow": "gen-flow-files ./src --out-dir ./dist",
22+
"dev": "npm-run-all clean -p \"build:* {@} -- --watch\""
23+
},
1624
"dependencies": {
1725
"@babel/runtime": "^7.18.6",
1826
"create-react-class": "^15.7.0",

0 commit comments

Comments
 (0)