Skip to content

feat: support multiple node versions in workspaces#6724

Closed
mark-omarov wants to merge 4 commits intopnpm:mainfrom
mark-omarov:feat/support-multiple-node-versions
Closed

feat: support multiple node versions in workspaces#6724
mark-omarov wants to merge 4 commits intopnpm:mainfrom
mark-omarov:feat/support-multiple-node-versions

Conversation

@mark-omarov
Copy link
Copy Markdown
Contributor

@mark-omarov mark-omarov commented Jun 27, 2023

Close #6720

This PR implements the support for specifying multiple Node.js versions in a workspace environment for multiple packages. This feature is handy in multi-package workspace environments, enabling seamless version switching for each package - more details in the linked issue.

The version for each package can be specified using the pnpm config in the package.json of each project in a workspace.

Notes

I kept use-node-version support for .npmrc for backward compatibility. Only root-level is supported, and if set - it will be applied to all packages. The per-package version must be assigned in the package.json's pnpm config of the desired package. I can see a case when .npmrc already exists with use-node-version set to default for all packages, but some might opt-in to use the pnpm config to select another version to use.

I tested it with multiple configurations, including nested calls.

It would be easier to implement if the pnpm/src/main.ts were executed on every script separately with the correct path to each package, but I am unsure of complications that will occur, and it's too much of a change.

@mark-omarov mark-omarov requested a review from zkochan as a code owner June 27, 2023 09:41
@zkochan
Copy link
Copy Markdown
Member

zkochan commented Jun 28, 2023

I guess the implementation would become easier with the setting placed inside package.json?

Maybe we could place useNodeVersion there instead

{
  "pnpm": {
    "useNodeVersion": "18.0.0"
  }
}

If we decide to proceed with .npmrc, I think we already read it for some settings, so no need to read it again. Like here:

https://github.com/pnpm/pnpm/blob/8920dbce383f6b50942f23c7d029da5f807af5ce/pkg-manager/plugin-commands-installation/src/recursive.ts#L187C10-L187C10

@mark-omarov
Copy link
Copy Markdown
Contributor Author

Thanks @zkochan

Manifests are available in the selectedProjectsGraph, I agree it's easier to pull it from there. Maybe that's what I should do for the first iteration.
But, ultimately, it'd be great to support both.

Memoization of the readLocalConfig happens in the same place it's consumed and I kinda need it in a different place. I'll see what I can do with it, but for the moment will focus on pnpm settings in the package.json.

@mark-omarov mark-omarov force-pushed the feat/support-multiple-node-versions branch from 29de498 to 07b9b4d Compare July 15, 2023 13:01
@zkochan
Copy link
Copy Markdown
Member

zkochan commented Jul 21, 2023

Tests are needed.

Also, what about running install scripts of projects on pnpm install?

@mark-omarov
Copy link
Copy Markdown
Contributor Author

Tests are needed.

Also, what about running install scripts of projects on pnpm install?

Thanks @zkochan !

It's not complete yet. I still need to figure out tests randomly failing on CI (likely timeout related). I'll try to add some tests as well.

As pnpm install isn't recursive - either default or specified on the root-level version will be used. I see now that's incorrect, dependencies for those projects needs to be installed with the version they require.

Just a note - I can only work on this a few a week tops. Next month I might get more time for this, I really look forward getting it done though.

@mark-omarov mark-omarov marked this pull request as draft August 11, 2023 18:17
@mark-omarov
Copy link
Copy Markdown
Contributor Author

Sorry, not happening anytime soon. Closing to declutter for now.

@zkochan zkochan mentioned this pull request Jul 4, 2024
3 tasks
@mark-omarov mark-omarov deleted the feat/support-multiple-node-versions branch July 13, 2024 22:56
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.

support per-package node version specification in workspaces

2 participants