Installing EmberJS v2 addons from GitHub forks using PNPM
Michal Bryxí

Michal Bryxí @michalbryxi

About: Cycle 🚴 , climb 🗻 , run 🏃 , travel 🌍 , enjoy life ♥. IT guy with the need to live fully.

Location:
Interlaken, Switzerland
Joined:
Feb 1, 2018

Installing EmberJS v2 addons from GitHub forks using PNPM

Publish Date: Sep 16 '24
1 0

The problem

If you're using PNPM as a package manager for your EmberJS project and you find yourself in a need to install a v2 addon from git(hub) fork (because you have a branch with patched version), then you might find that GitHub URLs in package.json tricks don't work for you.

The analysis

Reason for this is because v2 addons are a monorepo and we're still in the phase where pretty much every tool out there lacks good support/DX for monorepos.

There are different possible solutions for different cases:

  • gitpkg.vercel.app - Using sub folders of a repo as yarn/npm dependencies made easy.
  • pnpm patch - Prepare a package for patching
  • patch-package - Lets app authors instantly make and keep fixes to npm dependencies.

But if you happen to use PNPM in your project you might get away with providing a customised git URL.

The solution

Let's assume I have a patch branch of ember-highcharts that has latest commit of SHA: 7995a3e7d2203ce174c39e186acc9257d883bf61. The web URL is:

https://github.com/MichalBryxi/ember-highcharts/tree/7995a3e7d2203ce174c39e186acc9257d883bf61
Enter fullscreen mode Exit fullscreen mode

I can add this patched fork to my project as follows:

pnpm add -D 'github:MichalBryxi/ember-highcharts#7995a3e7d2203ce174c39e186acc9257d883bf61&path:ember-highcharts'
Enter fullscreen mode Exit fullscreen mode

Where:

  • github: Shorthand for pnpm to know where the code is hosted
  • MichalBryxi - My github namespace
  • ember-highcharts - Name of the repo (my fork)
  • 7995a3e7d2203ce174c39e186acc9257d883bf61 - respective commit that contains the patch I'm interested in
  • path:ember-highcharts - In this v2 addon the ember-highcharts subdirectory contains the code for the addon

Conclusion

With PNPM it is possible to install EmberJS v2 addons, or any other packages living in monorepos, from GitHub forks.

Comments 0 total

    Add comment