Gatsby: How to properly fork a gatsby package?

Created on 19 Dec 2019  路  3Comments  路  Source: gatsbyjs/gatsby

Summary

I am currently "forking" gatsby-plugin-netlify-cms here. What I am literally doing is cloning the gatsby repo, copy/pasting the gatsby/packages/gatsby-plugin-netlify-cms/ into my own repo like a scribe from the 14th century, running npm run build, tracking the built assets, and publishing this repo and referencing it in my project's package.json as

...
gatsby-plugin-netlify-cms: vai0/gatsby-plugin-netlify-cms#40938f6
...

As a result, maintaining this and keeping my "forked" version up-to-date has been a real pain.

I am not familiar with forking monorepos, and referencing a package within the monorepo in my package.json. Any pointers or help assisting with how to do this the "proper" way would be greatly appreciated!

Happy holidays! :santa:

question or discussion

Most helpful comment

For local development, we have gatsby-dev-cli, which copies data sources from gatsby repo into your project. For more info check out our documentation https://www.gatsbyjs.org/contributing/setting-up-your-local-dev-environment/

To use your forked package in an external environment is always going to be a bit tricky/extra work. What I suggest is publishing it from the monorepo, so you don't have to copy and paste anything. How would that work?
1) you change the package.json with your prefix "vai0/gatsby-plugin-netlify-cms".
2) You cd into the folder cd packages/gatsby-plugin-netlify-cms.
3) Run yarn build.
4) Run npm publish.

Your publish should have succeeded under your namespace, and you can now install it through npm by referring your forked npm package. You could also have a look at patch-package to help you without publishing your changes.

All 3 comments

For local development, we have gatsby-dev-cli, which copies data sources from gatsby repo into your project. For more info check out our documentation https://www.gatsbyjs.org/contributing/setting-up-your-local-dev-environment/

To use your forked package in an external environment is always going to be a bit tricky/extra work. What I suggest is publishing it from the monorepo, so you don't have to copy and paste anything. How would that work?
1) you change the package.json with your prefix "vai0/gatsby-plugin-netlify-cms".
2) You cd into the folder cd packages/gatsby-plugin-netlify-cms.
3) Run yarn build.
4) Run npm publish.

Your publish should have succeeded under your namespace, and you can now install it through npm by referring your forked npm package. You could also have a look at patch-package to help you without publishing your changes.

Also the easiest way to maintain a fork is to get your changes merged back upstream! Then everyone helps maintain it! :-D

Marking this as answered and closing! Thanks! 馃檶馃徏

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  路  3Comments

rossPatton picture rossPatton  路  3Comments

magicly picture magicly  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

hobochild picture hobochild  路  3Comments