-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: switch to pnpm #527
*: switch to pnpm #527
Conversation
aaeae2a
to
43296b3
Compare
@@ -13,9 +13,7 @@ | |||
"types": "dist/web/tokens.d.ts", | |||
"scripts": { | |||
"build": "style-dictionary build", | |||
"clean": "style-dictionary clean", | |||
"prepare": "npm run clean && npm run build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something about the "automatically build after running pnpm install
" behavior felt odd, so I removed it 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair. I never could get the right feel for the correct life-cycle script here. I think I had "prepublishOnly" at one point but it may have been deprecated. This becomes a lot less critical with auto-publishing where we don't need lifecycle scripts to help us remember to "build" before we "publish".
"build:typescript": "tsc", | ||
"build:generate:stripfill": "svgr --typescript --icon -d src/components svg/customFill", | ||
"build:generate:preserve": "svgr --typescript --icon --no-runtime-config -d src/components svg/preserveFill", | ||
"build:watch": "tsc --watch", | ||
"build:watch": "tsc --watch --preserveWatchOutput", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, tsc --watch
clears the terminal while other watch tasks don't and it looks weird!
"@cockroachlabs/icons": "workspace:../icons", | ||
"@cockroachlabs/ui-components": "workspace:../ui-components", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hooray workspace:
protocol: https://pnpm.io/workspaces#workspace-protocol-workspace 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge improvement honestly. I haven't gotten there yet, but any idea how this will be handled when building storybook for deployment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouuuuuuuld automatically link everything together :)
"@popperjs/core": "^2.9.2", | ||
"@types/recharts": "^1.8.23", | ||
"lodash": "^4.17.21", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally-missing dependency (previously hoisted from another package)
"@popperjs/core": "^2.9.2", | ||
"@types/recharts": "^1.8.23", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was never a runtime dependency — moved to dev dependencies
@@ -52,6 +52,8 @@ | |||
"@types/node": "16.18.14", | |||
"@types/react": "17.0.53", | |||
"@types/react-lines-ellipsis": "0.15.1", | |||
"@types/recharts": "^1.8.23", | |||
"@types/testing-library__jest-dom": "^5.14.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally-missing dependency (previously provided by @testing-library/jest-dom
as a transitive dependency)
@@ -68,6 +70,7 @@ | |||
"jest-environment-jsdom": "29.4.3", | |||
"jest-runner-eslint": "1.1.0", | |||
"mini-css-extract-plugin": "^2.7.5", | |||
"npm-run-all": "4.1.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidentally missing dependency (got hoisted from another package)
@@ -1,7 +1,6 @@ | |||
/* eslint-disable @typescript-eslint/no-var-requires */ | |||
/* globals module, __dirname */ | |||
const path = require("path"); | |||
const WebpackBar = require("webpackbar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It got in the way of watch task reporting and spewed way too many lines. I can put it back if we want, but 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, this was something I was playing with way back in the beginning. It was only something to clean up the output of watching only ui-components
. I agree it doesn't make sense in the context of file watching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this review looks good, but there's one big catch, and that is that I can't get auto
publishing to work with this setup. Here's my wip branch for reference.
So auto
depends on lerna
to determine what changed and needs to publish. I tried adding lerna
back and configuring for pnpm
(that part might work correctly). But when I run auto
I get an error in pnpm
,
╔═══════════════════════════
║ ui on switch-to-pnpm [⇡] via v16.20.1
╚════ △ pnpm run release
> root@ release /Users/nathanstilwell/code/ui
> auto shipit
⚠ warning lerna notice cli v7.1.1
lerna success found 5 packages
TypeError: Cannot read properties of undefined (reading 'reduce')
at findPackages (/Users/nathanstilwell/code/ui/node_modules/.pnpm/[email protected]/node_modules/get-monorepo-packages/index.js:17:6)
at Object.getPackages [as default] (/Users/nathanstilwell/code/ui/node_modules/.pnpm/[email protected]/node_modules/get-monorepo-packages/index.js:37:14)
at getMonorepoPackage (/Users/nathanstilwell/code/ui/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@auto-it/npm/src/index.ts:158:31)
at /Users/nathanstilwell/code/ui/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@auto-it/npm/src/index.ts:1098:30
at processTicksAndRejections (node:internal/process/task_queues:96:5)
ELIFECYCLE Command failed with exit code 1.
I did not dig in very far here. In my mind we have a couple of options to proceed forward,
- Debug this error and submit a patch for
pnpm
orauto
or whatever to resolve the issue. - Create our own plugin for
auto
. - Drop
auto
entirely and create a solution using only pnpm and Github Actions.
Happy to brainstorm further.
"start": "pnpm run --recursive --parallel start", | ||
"test": "pnpm run --recursive test", | ||
"build": "pnpm run --recursive build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The output for these is actually really nice!
@@ -13,9 +13,7 @@ | |||
"types": "dist/web/tokens.d.ts", | |||
"scripts": { | |||
"build": "style-dictionary build", | |||
"clean": "style-dictionary clean", | |||
"prepare": "npm run clean && npm run build", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair. I never could get the right feel for the correct life-cycle script here. I think I had "prepublishOnly" at one point but it may have been deprecated. This becomes a lot less critical with auto-publishing where we don't need lifecycle scripts to help us remember to "build" before we "publish".
@@ -8,15 +8,14 @@ | |||
"main": "dist/index.js", | |||
"types": "dist/index.d.ts", | |||
"scripts": { | |||
"build": "npm run build:generate:stripfill && npm run build:generate:preserve && npm run build:typescript", | |||
"build": "run-s build:generate:stripfill build:generate:preserve build:typescript", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooo. What is run-s
? Does that come with pnpm
? If it's a dependency-less npm-run-all
then I love it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it's an alias that comes wioth npm-run-all
. I don't think pnpm
supports sequential script targets natively 🤔
"@cockroachlabs/icons": "workspace:../icons", | ||
"@cockroachlabs/ui-components": "workspace:../ui-components", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a huge improvement honestly. I haven't gotten there yet, but any idea how this will be handled when building storybook for deployment?
@@ -1,7 +1,6 @@ | |||
/* eslint-disable @typescript-eslint/no-var-requires */ | |||
/* globals module, __dirname */ | |||
const path = require("path"); | |||
const WebpackBar = require("webpackbar"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nah, this was something I was playing with way back in the beginning. It was only something to clean up the output of watching only ui-components
. I agree it doesn't make sense in the context of file watching.
1a5827e
to
5b98eef
Compare
5b98eef
to
5d8ddd9
Compare
I thiiiink I've got |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we just had to wait until Lerna and pnpm learned to play together. 😄
* // switch to pnpm
We're moving in this direction in other repos due to Bazel's
rules_js
— may as well be consistent.Checklist