Skip to content
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

Merged
merged 1 commit into from
Sep 12, 2023
Merged

*: switch to pnpm #527

merged 1 commit into from
Sep 12, 2023

Conversation

sjbarag
Copy link
Contributor

@sjbarag sjbarag commented Jun 30, 2023

* // switch to pnpm

We're moving in this direction in other repos due to Bazel's rules_js — may as well be consistent.

Checklist

  • I have written or updated test for the changes I made
  • I have updated the README of the package I'm working in to reflect my changes
  • I have added or updated Storybook if appropriate for my changes

@sjbarag sjbarag force-pushed the switch-to-pnpm branch 2 times, most recently from aaeae2a to 43296b3 Compare June 30, 2023 22:40
@@ -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",
Copy link
Contributor Author

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 😄

Copy link
Contributor

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",
Copy link
Contributor Author

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!

Comment on lines +21 to +22
"@cockroachlabs/icons": "workspace:../icons",
"@cockroachlabs/ui-components": "workspace:../ui-components",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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?

Copy link
Contributor Author

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",
Copy link
Contributor Author

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",
Copy link
Contributor Author

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",
Copy link
Contributor Author

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",
Copy link
Contributor Author

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");
Copy link
Contributor Author

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 🤷

Copy link
Contributor

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.

@sjbarag sjbarag marked this pull request as ready for review June 30, 2023 22:47
@sjbarag sjbarag requested a review from a team as a code owner June 30, 2023 22:47
Copy link
Contributor

@nathanstilwell nathanstilwell left a 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,

  1. Debug this error and submit a patch for pnpm or auto or whatever to resolve the issue.
  2. Create our own plugin for auto.
  3. Drop auto entirely and create a solution using only pnpm and Github Actions.

Happy to brainstorm further.

Comment on lines +8 to +11
"start": "pnpm run --recursive --parallel start",
"test": "pnpm run --recursive test",
"build": "pnpm run --recursive build",
Copy link
Contributor

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",
Copy link
Contributor

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",
Copy link
Contributor

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.

Copy link
Contributor Author

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 🤔

Comment on lines +21 to +22
"@cockroachlabs/icons": "workspace:../icons",
"@cockroachlabs/ui-components": "workspace:../ui-components",
Copy link
Contributor

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");
Copy link
Contributor

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.

@sjbarag
Copy link
Contributor Author

sjbarag commented Sep 12, 2023

I thiiiink I've got auto working now! Had to upgrade to 11.x and lerna 7.x, but everything seems good. Note that auto shipit --dry-run doesn't work due to intuit/auto#2129. Something's just weird with --dry-run 🤷

Copy link
Contributor

@nathanstilwell nathanstilwell left a 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. 😄

@sjbarag sjbarag merged commit 559cdaa into cockroachdb:master Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants