-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Tooling: Add volta versions #48734
Tooling: Add volta versions #48734
Conversation
Test live: https://calypso.live/?branch=add/volta-pin |
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
2f396d1
to
a380a0b
Compare
Caution: This PR affects files in the Editing Toolkit Plugin on WordPress.com D55743-code has been created so you can easily test it on your sandbox. See this FieldGuide page about developing the Editing Toolkit Plugin for more info: PCYsg-ly5-p2 |
a380a0b
to
b4180d3
Compare
b4180d3
to
0c1c093
Compare
Looks like renovate should support: renovatebot/renovate#4262 |
0c1c093
to
acff2fb
Compare
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 did a bit of testing with nvm
+ volta
, and it looks like if NVM is configured in .the zshrc file, then it overrides volta. nvm use
sets to 12.x, and that persists when changing to other directories. (e.g. the volta version is not used)
When nvm
is not set in .zshrc, it works as expected:
It appears that nvm
still works fine with volta config available. So in other words, this shouldn't break anything for existing users :)
I'm all for this, as I've been getting frustrated by NVM. For example, if I try to do a git commit or push via Visual Studio Code's GUI, the precommit hooks will utilize the "default" node version rather than the local nvm
node version, which sucks when different projects use different node versions.
After trying out the precommit hooks with volta, it looks like that problem is finally solved! My editor is using the node version for the project without any intervention. (Tried with both wp-calypso and gutenberg using your branches.)
package.json
Outdated
}, | ||
"volta": { | ||
"node": "12.20.1", | ||
"yarn": "1.22.10" |
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.
How does this interact with the version set in .yarnrc
?
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.
Part of the yarn
executable's behavior is to get the correct version via .yarnrc
, isn't it? I did a test by pinning [email protected]
for volta. You can see that although volta will invoke it's [email protected] binary, yarn reports its version is 1.22.10
. I think everything will work smoothly and ultimately .yarnrc
determines the version like I'd expect.
# volta list
⚡️ Currently active tools:
Node: v12.20.1 (current @ …/calypso/package.json)
Yarn: v1.21.1 (current @ …/calypso/package.json)
Tool binaries available:
wp-env (default)
neovim-node-host (default)
stryker (default)
tsc, tsserver (current @ …/calypso/package.json)
yarn-deduplicate (default)
See options for more detailed reports by running `volta list --help`.
# yarn --version
1.22.10
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.
Seems weird and confusing to have a yarn version defined in two places. Do we really need to tell volta
about yarn
version?
What's the dev experience if we drop the version in .yarnrc
and we want to update yarn
?
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.
If we go all-in with volta, I believe we could safely drop either one.
What's the dev experience if we drop the version in .yarnrc and we want to update yarn?
I don't understand the question. Updating yarn via volta means running volta pin yarn@latest
in the repo root.
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.
Let's say we drop .yarnrc
and we pin yarn using volta
to a specific version (1.22.10
).
How do update the version? I guess it is only a change in package.json
, right?
What happens when a dev checks out a branch that points to a version they don't have locally? Does volta automatically downloads the new 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.
How do update the version? I guess it is only a change in package.json, right?
Yep.
What happens when a dev checks out a branch that points to a version they don't have locally? Does volta automatically downloads the new version?
Yes.
It is great that we are looking for alternatives to NVM if NVM is causing problems. Could you expand on the problems we are trying to solve with In any case, I think that we should only have one tool to do one thing. In other words, if we go ahead with this change, it should be a migration from |
I found @noahtallen’s comment on the related Gutenberg PR helpful in this regard. With volta, you no longer need to Dropping |
a781074
to
40ba97a
Compare
FYI, I'm proposing the same change in Jetpack: Automattic/jetpack#19705 |
I do like the ergonomics of Volta a lot, and have been using it exclusively recently, even without these changes. I wonder what our next steps should be? Do we need to commit to nvm or volta, or can we support both at the same time? (I don't see supporting volta as having a high cost, since it just involves bumping the version in the root package.json whenever we update node.) Relatedly... I really, really wish they had not gone with this approach for monorepos. It seems to be the largest source of concern for project adoption since it increases the surface area by so much. |
I still think we should draft a plan to do a full transition from NVM to Volta. IMO, at the very least we need (in no particular order):
Nice to have:
|
That all seems good to me. Note that I still have nvm installed and volta seems to take precedence when running shell commands for which version of node and any npm installed binaries are used. |
I can draft or help with a p2 post. I'd recommend upgrading to Node 16 first (p7H4VZ-31V-p2) so everyone gets native Node binaries with Volta. |
This PR has been marked as stale due to lack of activity within the last 30 days. |
Link to Calypso live: https://calypso.live?image=registry.a8c.com/calypso/app:build-16074 |
This is very stale, I'll close it now. If there's interest and a desire to move forward with this I'd be happy to get this ready again. |
Totally. I really wish they would just support reading from a higher-level .json file! I also looked into manual pinning -- like if I could achieve automatic version switching via a file I could add to .gitignore, but that also isn't supported :( So I'm back to nvm for now, just because both Gutenberg and Calypso use it. |
For the record, they kind of do, with |
Oh hey! Hope things are going great :D That's what this PR was exploring originally |
I'm following this issue in the volta repo, but there hasn't been much movement: volta-cli/volta#282 |
Changes proposed in this Pull Request
https://volta.sh/
This prepares the environment for use with Volta, a potential replacement for
nvm
(but more).It sets a
volta
property in the root package.json. It also points all the other package.json in the repo to extend that root config. This is under the assumption that all tooling should use the version in the root.It was a little annoying to add a volta property to every package.json, but that should be a one-time thing and doesn't seem like it should have any negative impact. That seems to be the way to do things in Volta at the moment. See volta-cli/volta#906 and the Workspaces docs.
Testing instructions
You'll need to set your system up for Volta. I have no idea if that will play well with nvm. I've removed nvm from my system completely.
From an arbitrary location like
~
, install some volta tools (that don't correspond to the versions in Calypso). For example:volta install node@latest
volta install typescript@beta
Check the versions with
volta list
:move to Calypso and check the versions:
Repeat from another directory with a package.json such as
packages/*/
orapps/editing-toolkit
orclient
.