Skip to content

Commit

Permalink
feat: integrate Yarn workspaces with Lerna for smoother DX without fa…
Browse files Browse the repository at this point in the history
…lse positive type errors (#752)

* feat: use yarn workspaces

* chore: update CI scripts

* feat: move example folder to the root

* chore: this is in fact, not needed

* feat: remove manual pin and use lerna instead

* chore: docs were misleading
  • Loading branch information
grabbou authored Feb 8, 2023
1 parent 88a5e0f commit b52f668
Show file tree
Hide file tree
Showing 53 changed files with 661 additions and 11,390 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ jobs:
cache: 'yarn'

- run: yarn
- run: yarn bootstrap

- run: yarn build

- run: yarn lint
- run: yarn test

- run: yarn lerna exec 'yarn next build' --scope=example-next
- run: yarn lerna exec 'yarn react-scripts build' --scope=example-cra
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
packages/*/dist/
packages/example-next/.next/
example/.next/
.env.local
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ This is a hosted version of [packages/example-next](packages/example-next).
## Get Started

- `yarn`
- `yarn bootstrap`
- `yarn start`

In addition to compiling each package in watch mode, this will also spin up [packages/example-next](packages/example-next) on [localhost:3000](http://localhost:3000/). (It will also spin up [packages/example-cra](packages/example-cra) on [localhost:3001](http://localhost:3001/), but this is just a skeleton app for testing compatibility.)
Expand All @@ -38,23 +37,9 @@ In addition to compiling each package in watch mode, this will also spin up [pac
- `yarn build`
- `yarn test --watch`

## Add a Dependency

- `yarn lerna add <DEPENDENCY> --scope <PACKAGE>`

## Remove a Dependency

- Delete the relevant `package.json` entry

Because of a [lerna bug](https://github.com/lerna/lerna/issues/1883), it's not possible to prune `yarn.lock` programmatically, so regenerate it manually:

- `yarn lerna exec "rm -f yarn.lock" --scope <SUBPACKAGE>`
- `yarn clean --scope <SUBPACKAGE>`
- `yarn bootstrap`

## Publish

- `yarn lerna publish [--dist-tag]`
- `yarn lerna publish [--dist-tag] `

## Documentation

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/example-next/package.json → example/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"private": true,
"version": "0.0.0",
"name": "example-next",
"scripts": {
"start": "next dev",
"pin": "sh -c '{ for X in {coinbase-wallet,core,eip1193,empty,gnosis-safe,metamask,network,types,url,walletconnect}; do lerna add @web3-react/$X --exact --no-bootstrap --scope=example-next; done }'"
"start": "next dev"
},
"dependencies": {
"@ethersproject/bignumber": "^5.6.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"version": "independent",
"packages": [
"packages/*"
"packages/*",
"example"
],
"npmClient": "yarn",
"ignoreChanges": ["**/*.md", "**/*.spec.ts"]
"ignoreChanges": ["**/*.md", "**/*.spec.ts"],
"useWorkspaces": true
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
"node": "^14 || ^16"
},
"scripts": {
"bootstrap": "lerna bootstrap",
"clean": "lerna clean --yes",
"lint": "yarn run eslint --ext .ts,.tsx .",
"test": "jest",
"build": "lerna run build",
"prestart": "yarn build",
"start": "lerna run start --parallel",
"pin": "lerna run pin && yarn bootstrap",
"version": "yarn pin && git add packages/example-{next,cra}/package.json",
"prepack": "yarn build"
},
"workspaces": [
"packages/*",
"example"
],
"devDependencies": {
"@coinbase/wallet-sdk": "^3.3.0",
"@testing-library/react-hooks": "^8.0.0",
Expand Down
296 changes: 0 additions & 296 deletions packages/core/yarn.lock

This file was deleted.

Loading

0 comments on commit b52f668

Please sign in to comment.