How do I target a subdirectory of a (Lerna) monorepo when targeting installation of an NPM package by branch?

Viewed 374

Sometimes, it's useful to target a git branch (as in Depend on a branch or tag using a git URL in a package.json? ), with e.g.:

"dependencies": {
  "@my-company-internal-scope/some-package": "git+ssh://git@git.mycompany.internal.example.com:some-package.git#some-branch"
}

(Notably, this is an on-prem git solution, not e.g. github.com or gitlab.com - but I don't see how that affects what I want to do here. I only point it out because I can't direct you to the target repository, I can only describe it, as follows...)

We've switched over to using Lerna and we have some of our modules in a monorepo.

Basically, instead of a root-level package.json and that being the module export, our root-level package.json in this repository looks like:

{
"name": "irrelevantAndIWillAlsoBeOmittingOtherSuperfluousDetails",
// ...
"devDependencies": {
  "lerna": "^3.16.4"
},
"dependencies": {
  "some-module": "file:./packages/some-module",
  "some-other-module": "file:./packages/some-other-module"
},
}

And in packages/some-module, it's the module export (it has its own package.json) with no lerna concept, but notably the repository field in its package.json refers to the monorepo:

  "publishConfig": {
    "registry": "https://artifacts.tools.my-company.example.com/registry"
  },  
  "repository": {
    "type": "git",
    "url": "git@my-company.example.com:department/component-monorepo.git"
  }, 

What I want to do is target some-package inside of the monorepo at #nonstandard-branch. How can I do that?

(just calling out since it's probably not a best practice to rely on these for installs: this is not permanent, this is a temporary workflow. Let's say that we have to deploy something requiring a module-level fix and the team that owns the artifact publishing system is all on holiday. These details should not be relevant to you, I just don't want "yeah just publish the version and make it a prerelease if you're worried" as an answer.)

0 Answers
Related