-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add support for Yarn workspaces (PoC for #189) #200
base: master
Are you sure you want to change the base?
Conversation
76f57af
to
332ad7a
Compare
I've fixed some of the issues from the original attempt:
|
332ad7a
to
4d89313
Compare
I've extended the implementation to create symlinks when running node2nix on the workspace Some new obstacles:
|
Hi, Looks like a great first attempt. It seems that you have looked carefully at the structure and followed all my conventions, including using "old fashioned JavaScript" conventions. I have to admit that I have not used Yarn workspaces myself, so in order to help you I need to make myself a bit more familiar with it. A question about this feature: when you look at node2nix from a very high level perspective -- it is essentially a tool that runs Is Yarn workspaces also a feature that is supported by NPM? Or do you need to switch to yarn to get these installed? Running yarn in a derivation is not something node2nix can currently facilitate. |
Yarn workspaces are not supported by npm, no. So some of the obstacles are to be expected. The idea to try Yarn workspaces was to see if it'd highlight similar issues to what we might encounter with other monorepo setups. (Plus I have a bunch of projects using Yarn workspaces myself.) Maybe I'm overthinking goals for #189, though? (No worries, btw. This is all just exploration.) |
Looks like workspaces are supported by npm 7: https://github.com/npm/cli/blob/eedf93e1526f5834d549b68dab9258b6283921de/CHANGELOG.md#some-high-level-changes-and-improvements |
@jtojnar That's corect, so now there's also a reason to add that feature. Maybe you actually want to wait for my |
I'm trying to package the Also are there ways of working around the npm workspace by building the sub-packages individually but sharing the workspace's |
This is a proof of concept for #189 (comment). Suggest we try keep discussion here just about implementation.
The idea is to run node2nix for each package individually, but point
--yarn-workspace
at the workspace top-levelpackage.json
so it can discover interdependencies which use custom derivations assrc
.This code works but is crude, and only does part of the job. It generates a
node-packages.nix
like:Note the extra function parameters at the top, and the
src
attributes for workspace dependencies.Some notes:
--lock
. Doesn't make sense, because npm has no workspaces support. It would make sense if we hadyarn.lock
support. Either way, should probably make this error?CompositionExpression
. I haven't yet thought about what this should look like.workspace:
protocol with path (specified by Yarn), e.g.:workspace:../a
(Using--yarn-workspace
essentially injects those for you behind the scenes.)workspace:
protocol with version specifier (specified by Yarn), e.g.:workspace:^1.2.3
Doesn't supportCollectionExpression
. Doesn't make sense, I think? Should probably error?Now that I'm writing this, I realize it'll always bundle all workspace dependencies, even if the package doesn't use them. Probably need to take another look at this, but still can discuss the overall idea. 🙃