Add guide for importing module instead of editing files
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
**Background:** I have a pull request into a repository where the npm module isn't up-to-date with `master`, and I'd like to test out my branch in a module that depends on it through a bunch of different deep dependencies. It seems like patch-package would be a great solution for this.
**Problem:** When I append `.patch` to my GitHub URL it gives me a patch, but when I pass it to `patch -p1` it fails because the diff between my branch and master is not the same as the diff between my branch and the latest published npm module. I tried to instead use the diff between my branch and the corresponding tag, but it turns out that the npm module and the Git tag aren't 100% in sync. My guess is that the "import a diff from a pull request" isn't documented in the readme because all of the solutions are fraught with errors like the ones I've encountered, but it would be great to have a recommendation of how to import code rather than hand-editing files with Vim.
**Proposal:** Let's document how to import an entire module! After trying a bunch of different solutions for a few hours, the best I can come up with is simple [albeit primitive]:
```sh
# Delete the currently installed module.
rm -rf ./node_modules/foo
# Import your code directly into `node_modules`
cp -r ~/src/foo ./node_modules
# Generate a diff for patch-package
patch-package foo
```
This feels wasteful, since Git already provides a diff for us, but since the npm registry is divorced from the Git history it seems like the only robust solution. I'd be very happy to hear improvements to this workflow. Thanks for your work on this module!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.