Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mkYarnModules: only run
yarn install
inside a workspace-structure i…
…f needed It's known that using workspaces usually produces a slightly different `node_modules/`[1]. While this used to be no big deal for us, we actually triggered a case where "dependency hoisting" — the process of moving dependencies of workspaces up in the final `node_modules/`-tree — becomes a problem, basically issue 5705[2]. The problem was triggered by the following - simplified - dependency tree: <root> |- commander (6.1) |- mocha (3) | `- commander (2.9) `- sql-generate (1.5) `- commander (2.9) `yarn2nix` created a workspace of the package `root` with `node_modules/` containing `mocha`/`sql-generate`. In the `yarn install` operation these are all placed into a single `node_modules/` in `$out`, however `commander` from 2.9 is preferred over 6.1: $ yarn why commander [...] => Found "[email protected]" info Has been hoisted to "commander" info Reasons this module exists - "workspace-aggregator-dc20c757-df45-41d7-bdba-927d267212a3" depends on it - Hoisted from "_project_#root#mocha#commander" - Hoisted from "_project_#root#sql-generate#commander" => Found "root#[email protected]" info This module exists because "_project_#root" depends on it. Even specifying `nohoist` for both dependencies inside the temporary `package.json` that's built by `yarn2nix` doesn't solve the problem since `yarn` still doesn't put the newer `[email protected]` into `$out/node_modules/`, I don't really know why, could be a `yarn`-bug though. Anyways, we're not even using the workspace feature and since it's known to produce different results, it's IMHO easier to just disable the entire feature if no `workspaces` are defined in `package.json`. [1] https://classic.yarnpkg.com/lang/en/docs/workspaces/#toc-limitations-caveats [2] yarnpkg/yarn#5705
- Loading branch information