找到你要的答案

Q:How do I contribute to an npm package?

Q:我如何有助于一个新的包吗?

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?

我用大口玉包在我的项目。这是作为一个开发依赖所以我可以跑NPM安装拿来轻松(与其他人一起)。现在,我需要在玉模块做一些性能优化,这是一种依赖吞玉。

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

  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

它似乎并不很简单,但特别是因为我可能需要作出改变,不仅在玉石本身,而且在其依赖性,因此,我将不得不叉他们也。

这是很多分叉!

有更简单的方法吗?

answer1: 回答1:

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.

但如果你想让你的变化/优化纳入到一个模块的主分支,你没有其他的方式,但送拉要求维护或叉和维护模块自己代码的变化,但这里是一个工作流我建议可以减少一点对你身边的努力。

叉只有顶层模块的你想在这种情况下,做出改变是吞玉模块。在你的项目中使用你的叉口玉。如果你想改变它的依赖,在一个单独的分支这样做(每依赖)然后合并到主模块分这又是补气玉模块。

采用一个分支命名约定,帮助您很容易地识别哪些模块在该分支中被更改,哪些依赖树影响了它。最后,你将有一个分支树,每个模块的变化坐在自己的分支很好。

从这里开始,只是叉相应的模块,添加远程,上游模块分支并发送请求到系拉。

一旦你的请求被接受,你可以与远程的一局部吞玉模块开关。

node.js  github  npm