-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 JS package manager to pnpm #44167
Conversation
It also removes resolutions that are no longer relevant.
`jest-styled-components` package is no longer global, so `toHaveStyleRule` matchers is not recognized by TS. We use them only in three places, so it's simpler to convert them to `toHaveStyle`.
I don't think anyone uses the debug configuration for electron (and we don't have `start-electron` script for a long time).
.pnpmfile.cjs
Outdated
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.
Today I realized that pnpm adds an entry for each workspace to the lockfile, including e/web/teleport
😢 (so we will get a different lockfile when e
is not cloned).
The only workaround I've found is to manually modify the lockfile using pnpm hooks. I know it's ugly, but I can't think of anything better.
To simplify this hook, I removed all dependencies from the e/web/teleport/package.json
.
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 think it's a pretty elegant solution actually.
@@ -1643,15 +1643,15 @@ backport: | |||
.PHONY: ensure-js-deps | |||
ensure-js-deps: | |||
@if [[ "${WEBASSETS_SKIP_BUILD}" -eq 1 ]]; then mkdir -p webassets/teleport && touch webassets/teleport/index.html; \ | |||
else yarn install --ignore-scripts; fi |
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.
--ignore-scripts
was causing Connect on Linux not to have pty-node
(I don't know why it worked with yarn).
@gzdunek - this PR will require admin approval to merge due to its size. Consider breaking it up into a series smaller changes. |
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
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.
👏
Should we add |
# Conflicts: # build.assets/Dockerfile # web/packages/design/package.json # yarn.lock
I think it's a good idea to prevent it from being reintroduced by accident, added. |
BUILD_macos.md
Outdated
* `brew install node yarn` | ||
* Currently, [`yarn`](https://classic.yarnpkg.com/en/docs/install) (< 2.0.0) is required | ||
* `brew install node` | ||
* `corepack enable` |
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.
* `corepack enable` | |
* `corepack enable pnpm` |
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.
Though pnpm docs say this:
If you installed Node.js using Homebrew, you'll need to install corepack separately:
brew install corepack
This will automatically install pnpm on your system.
Should it just say brew install node corepack
then?
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.
Uh that's correct, I just tried a fresh installation :/
I suppose it didn't work that way in the past, because I didn't install corepack with brew.
Changed to brew install node corepack
.
BUILD_macos.md
Outdated
* `brew install node yarn` | ||
* Currently, [`yarn`](https://classic.yarnpkg.com/en/docs/install) (< 2.0.0) is required | ||
* `brew install node` | ||
* `corepack enable` |
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.
Similar to the corepack enable pnpm
thread (#44167 (comment)), do you have any opinions/advice on using pnpm to manage the node install?
Ie:
brew install pnpm
export PNPM_HOME=~/Library/pnpm
pnpm env use --global 20 # or whatever version
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 have never tried this before, but it seems really convenient.
We could even provide a specific version in .npmrc
, which would be installed automatically for our project when we run any pnpm command:
#.npmrc
use-node-version=20.15.0
grzegorz@mbp teleport % pnpm node -v
Fetching Node.js 20.15.0 ...
v20.15.0
But I believe this change should also done for CI to have a single way of installing Node.js and the package manager. However, I think it would be too much for this PR, but we can go back to this idea in the future.
What do you think?
# Conflicts: # package.json
Okay, let's merge this! |
* Adjust `package.json`s to pnpm * Convert resolutions (pnpm doesn't support `**/` syntax) It also removes resolutions that are no longer relevant. * Convert `yarn.lock` to `pnpm-lock.yaml` with `pnpm import` * Always add `e/web/teleport` workspace to the lockfile * Adjust `jest` to new node_modules structure * Adjust `storybook` to new node_modules structure * Replace `toHaveStyleRule` with `toHaveStyle` `jest-styled-components` package is no longer global, so `toHaveStyleRule` matchers is not recognized by TS. We use them only in three places, so it's simpler to convert them to `toHaveStyle`. * Adjust README files * Adjust GHA workflows * Adjust build assets * Remove remaining `yarn` mentions I don't think anyone uses the debug configuration for electron (and we don't have `start-electron` script for a long time). * `corepack enable` -> `corepack enable pnpm` * Automatically enable pnpm when running `make build/teleport` * Run `pnpm import` again * Run `pnpm dedupe` * Add `yarn.lock` to .gitignore * Link to pnpm installation docs * Add a better comment for `transformIgnorePatterns` * Make pattern for `shared` stories more specific * Change `corepack enable pnpm` in readmes * Run `pnpm import && pnpm dedupe` again (cherry picked from commit 620c0a0)
* Switch JS package manager to pnpm (#44167) * Adjust `package.json`s to pnpm * Convert resolutions (pnpm doesn't support `**/` syntax) It also removes resolutions that are no longer relevant. * Convert `yarn.lock` to `pnpm-lock.yaml` with `pnpm import` * Always add `e/web/teleport` workspace to the lockfile * Adjust `jest` to new node_modules structure * Adjust `storybook` to new node_modules structure * Replace `toHaveStyleRule` with `toHaveStyle` `jest-styled-components` package is no longer global, so `toHaveStyleRule` matchers is not recognized by TS. We use them only in three places, so it's simpler to convert them to `toHaveStyle`. * Adjust README files * Adjust GHA workflows * Adjust build assets * Remove remaining `yarn` mentions I don't think anyone uses the debug configuration for electron (and we don't have `start-electron` script for a long time). * `corepack enable` -> `corepack enable pnpm` * Automatically enable pnpm when running `make build/teleport` * Run `pnpm import` again * Run `pnpm dedupe` * Add `yarn.lock` to .gitignore * Link to pnpm installation docs * Add a better comment for `transformIgnorePatterns` * Make pattern for `shared` stories more specific * Change `corepack enable pnpm` in readmes * Run `pnpm import && pnpm dedupe` again (cherry picked from commit 620c0a0) * Run `pnpm import && pnpm dedupe` * Remove `yarn.lock` * make ensure-js-package-manager: Do not prompt before installing pnpm --------- Co-authored-by: Rafał Cieślak <[email protected]>
Implements RFD 177 - Upgrade JS package manager.
Closes #33356
e counterpart https://github.com/gravitational/teleport.e/pull/4652
Best to review commit-by-commit.
I quickly tested Connect (Windows, macOS and Linux builds) and Web UI (macOS), I didn't see any problems.
Test builds: 17.0.0-dev.gzdunek.14 (17.0.0-dev.gzdunek.13 for macOS artifacts).
I will backport it to v16, on v15 and v14 we will stay with yarn. I will add
"packageManager": "[email protected]"
to them.Note
To use pnpm, enable Corepack (if you haven't already done it) with
corepack enable
.All commands stayed the same, you only need to change
yarn
topnpm
, e.g.pnpm start-teleport
.The only important difference is dependencies installation, previously you could type
yarn
now it'spnpm install
(orpnpm i
).Warning
After switching back to a branch that uses Yarn, I recommend running
make clean-ui
beforeyarn install
, otherwise the dependency installation will fail.