Typefully

Patching a third-party dependency with style

Avatar

Share

ย โ€ขย 

4 years ago

ย โ€ขย 

View on X

Ever wanted to change something in third-party dependency of your Node project but forking it would be too much hassle โ€“ or you were rather bending something which wouldn't make sense to contribute back at all? ๐Ÿงถ Yarn 2+ has "patch" command to help you do exactly that.
And as you guessed correctly, in that case, you need to make sure those patches are versioned with the rest of your code so it gets correctly patched in every environment you ran the code, similarly to "yarn.lock". yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
Also a little small tip โ€“ if you don't want yarn binary (which should be versioned in ".yarn/releases" โ€“ jukben.codes/one-yarn-to-rule-them-all) to skew your Github stats you can override it in ".gitattributes" like this. ๐Ÿ˜Ž
Btw does this all sound familiar? In the past I used npmjs.com/package/patch-package but it's nice to have it built-in, isn't it. ๐Ÿค“ Happy hacking!
Avatar

Jakub Benes

@jukben

Chronological order of tweets which I consider carrying some value โ€“ mostly for my own reference.