我如何为npm包做贡献? [英] How do I contribute to an npm package?

查看:181
本文介绍了我如何为npm包做贡献?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的项目中使用了 gulp-jade 包。它被添加为dev-dependency,所以我可以运行 npm install 轻松地(与其他人一起)获取它。现在,我需要在 jade 模块中进行一些性能优化,这是 gulp-jade 的依赖关系。



到目前为止,我可以想到以下方法:


  1. gulp-jade
  2. 改变分叉 / em>

  3. 更新我的package.json以使用分叉 gulp-jade

  4. jade

  5. 当/如果接受请求,从npm切换回 gulp-jade

  6. ol>

    尽管这看起来并不简单,尤其是因为我可能不仅需要在 jade 本身中进行更改,而且还需要在其依赖项中进行更改,我将不得不岔开他们。



    有很多分叉!



    有没有简单的方法?


    <虽然如果你希望你的改变/优化被合并到模块的 master 分支中,除了向维护者或fork发送pull请求并在代码更改中维护模块外,没有别的办法,但这里有一个工作流程,我建议您可以减少一些工作量。



    仅更换您希望进行更改的顶层模块,在这种情况下为 gulp-jade 模块。在你的项目中使用你分叉的 gulp-jade 。如果你想修改它的依赖关系,可以在一个单独的分支(每个依赖关系)中进行修改,然后将它合并到主模块分支中,这又是 gulp-jade 模块。

    采用分支命名约定,可以帮助您轻松识别哪个模块在该分支中发生了更改,以及它影响哪个依赖关系树。最后,您将拥有一个分支树,每个模块的更改都很好地坐在自己的分支中。



    从这里开始,简单地分叉相应的模块,添加远程,然后向维护人员发送拉取请求。

    一旦您的所有拉取请求都被接受,您可以切换本地 gulp- jade 模块与远程模块。


    I am using gulp-jade package in my project. It is added as a dev-dependency so I can run npm install to fetch it easily(together with others). Now, I need to do some performance optimization in jade module, which is a dependency of gulp-jade.

    So far I can think of the following way:

    1. fork both jade and gulp-jade,
    2. change forked gulp-jade to use forked jade
    3. update my package.json to use forked gulp-jade
    4. make a pull request for jade
    5. when/if pull request is accepted, switch back to gulp-jade from npm

    It does not seem very simple though, especially because I might need to make changes not only in jade itself, but also in its dependencies, therefore, I would have to fork them also.

    That's lots of forking!

    Is there a simpler way?

    解决方案

    Though if you want your changes/optimisations to be incorporated into the master branch of a module, you have no other way but to send a pull request to the maintainer or fork and maintain the module yourself with your code changes but here is a workflow I suggest that may reduce a bit of effort on your side.

    Fork only the top level module you wish to make changes to which in this case is the gulp-jade module. Use your forked gulp-jade in your project. If you wish to make changes to it's dependencies, do so in a separate branch(per dependency) and then merge it into the main module branch which is again, the gulp-jade module.

    Adopt a branch naming convention that helps you identify easily which module was changed in that branch and which dependency tree it affects. At the end, you will have a branch tree with each module's changes sitting in it's own branch nicely.

    From here on, simply fork the corresponding module, add the remote, upstream the module branch and then send a pull request to the maintainer.

    Once all your pull requests are accepted, you can switch the local gulp-jade module with the remote one.

    这篇关于我如何为npm包做贡献?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆