Skip to content

Commit

Permalink
[infra] Use npm workspaces instead of lerna (#3112)
Browse files Browse the repository at this point in the history
This PR removes Lerna entirely. Now we just use npm workspaces + wireit.

### Benefits

- No more `npm run bootstrap`, just `npm ci`.
- To upgrade or add a dependency, edit the `package.json` and `npm i` from the root.
- Cuts around 30s off install time in CI.
- Only one `package-lock.json` file for the whole monorepo.

### Tricky parts

- npm workspaces hoists packages to the top-level `node_modules/` folder whenever possible. This is different to Lerna, which always put all the dependencies in each package's own `node_modules/` folder. Only if there is a conflicting version would there now be a `node_modules/` folder inside a workspace package.

  - This required updating various paths to reach further up the file system.
 
  - In a couple of cases, this caused issues with conflicting `@types` packages for TypeScript, because while previously only the local version was available, now multiple versions could be. This is because TypeScript by default ambiently loads all `node_modules/@types/*` packages from _all recursive parent directories_. The solution to these cases are to specify that only the immediate `node_modules/` folder should be consulted through the `typeRoots` setting.

  - This required changing the tachometer server root directory as well, which ended up being more complicated than it should be, because of the way tachometer was treating paths in config files as relative to the current working directory, instead of the config file path. In google/tachometer#237 I changed that behavior, so this also bumps the tachometer version and updates the configs accordingly.

Fixes #3093
  • Loading branch information
aomarks committed Jul 1, 2022
1 parent d705af4 commit fc3155d
Show file tree
Hide file tree
Showing 99 changed files with 58,482 additions and 215,297 deletions.
2 changes: 2 additions & 0 deletions .changeset/few-monkeys-reply.md
@@ -0,0 +1,2 @@
---
---
1 change: 0 additions & 1 deletion .eslintignore
Expand Up @@ -4,7 +4,6 @@
############################################

node_modules/
lerna-debug.log
*.tgz
*.tsbuildinfo
.DS_Store
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/benchmarks.yml
Expand Up @@ -18,16 +18,13 @@ jobs:
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache-dependency-path: package-lock.json

- uses: google/wireit@setup-github-actions-caching/v1

- name: NPM install
run: npm ci

- name: Lerna bootstrap
run: npm run bootstrap

- name: Build
run: npm run build

Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/sauce-ie11.yaml
Expand Up @@ -22,16 +22,13 @@ jobs:
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache-dependency-path: package-lock.json

- uses: google/wireit@setup-github-actions-caching/v1

- name: NPM install
run: npm ci

- name: Lerna bootstrap
run: npm run bootstrap

- name: Build
run: npm run build

Expand All @@ -49,4 +46,4 @@ jobs:
SAUCE_ACCESS_KEY: ${{ secrets.SAUCE_ACCESS_KEY }}
run: |
cd packages/labs/ssr
npm run test:integration
npm run test:integration
5 changes: 1 addition & 4 deletions .github/workflows/sauce.yaml
Expand Up @@ -22,16 +22,13 @@ jobs:
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache-dependency-path: package-lock.json

- uses: google/wireit@setup-github-actions-caching/v1

- name: NPM install
run: npm ci

- name: Lerna bootstrap
run: npm run bootstrap

- name: Build
run: npm run build

Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/tests.yml
Expand Up @@ -17,9 +17,7 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 16
# Note: we do not cache here because we're not running lerna
# bootstrap, so the ~/.npm dir won't have all dependencies, and if
# this job finishes first then we'll only cache root dependencies.
cache-dependency-path: package-lock.json

- name: NPM install
run: |
Expand All @@ -45,7 +43,7 @@ jobs:
with:
node-version: 16
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache-dependency-path: package-lock.json

- uses: google/wireit@setup-github-actions-caching/v1

Expand All @@ -55,9 +53,6 @@ jobs:
- name: NPM install
run: npm ci

- name: Lerna bootstrap
run: npm run bootstrap

- name: Build
run: npm run build

Expand All @@ -79,16 +74,13 @@ jobs:
# TODO(augustinekim) Unpin when latest node installed by action includes fixed npm
node-version: 16.15.0
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
cache-dependency-path: package-lock.json

- uses: google/wireit@setup-github-actions-caching/v1

- name: NPM install
run: npm ci

- name: Lerna bootstrap
run: npm run bootstrap

- name: Test
env:
RUN_BROWSER_TESTS: false
Expand Down
1 change: 0 additions & 1 deletion .gitignore
@@ -1,5 +1,4 @@
node_modules/
lerna-debug.log
*.tgz
*.tsbuildinfo
.DS_Store
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Expand Up @@ -4,7 +4,6 @@
############################################

node_modules/
lerna-debug.log
*.tgz
*.tsbuildinfo
.DS_Store
Expand Down
3 changes: 1 addition & 2 deletions CONTRIBUTING.md
Expand Up @@ -95,8 +95,7 @@ If you've already signed a CLA but are still getting bothered by the awfully ins
```bash
git clone https://github.com/lit/lit.git
cd lit
npm install
npm run bootstrap
npm ci
npm run build
```

Expand Down
9 changes: 0 additions & 9 deletions lerna.json

This file was deleted.

0 comments on commit fc3155d

Please sign in to comment.