patch-package | Fix broken node modules instantly
HTML-код
- Опубликовано: 27 ноя 2024
- patch-package is a tool that has saved me a couple of times when I found a bug in an npm package and needed to fix it ASAP.
Code: github.com/ben...
Links from video:
github.com/ds3...
----
Follow me online: voidpet.com/be...
#benawad
Wow, i was looking for something like this since forever. Thank you Ben for recommending this tool.
I've been using this for a while now in our design system, it's super awesome. Although, be careful of using ^ version installs as the patch doesn't get correctly applied if you get a few patch bumps, happened to me today and app teams had a broken version of a menu drop down... 😬
Thank you, i've been looking for this the whole time, straight to the point!
Yeah patch-package is amazing! I needed it for Typescript conflicts between dependencies 😍
Incredibly useful package for larger NPM packages, especially some with bad coding practices. I needed to use this for MedusaJS (among the worst coding practices I've ever seen) to stop verbose logging of EVERY request made to the API that isn't disabled, even in production.
Yup ... I even used it for my own package recently because it's so much faster :D
Thanks for recommending this tool. I remember watching this video near release data and it's only now I need it. TY.
Dose this help when i want to fix some package per deep version to be compatible to react 18
I've known about this for some time, but haven't used it. Actually, I forgot about it (thanks for the reminder). Love the walk through...super helpful and now it's more likely I'll remember this when I need it. Thanks!
I think yarn 2 will have a "patch" protocol, which you can use to modify files in node modules. But on the other hand, this seems much easier and cleaner than doing it using "yarn patch"..
A helpful VSCode plugin is 'Format Toggler' which enables toggling 'format on save' via single click on the status bar.
I haven't found a use for this until today due to firebase and reactfire. It's doing "import * as firebase from 'firebase/app'" instead of "import firebase from 'firebase/app'". Thanks for this!
Thank you, "postinstall" was what I was missing
this is awesome! thank you for making a tutorial on it. your a rock star!
Thank you Ben. I really enjoyed the way you explained it.
This is a lifesaver. Great video.
Used to replace them with node fs in postinstall pretty similar but patch-package really neat.
Thanks man! I've been thinking of a package like this a month ago!
My god... This is so helpful!! Thank you!!!
Thank you, Ben! Very informative
dev: "cool! what happens if I try to fix node?"
*runs patch-package npm*
*npm removes itself*
dev: it worked!
Thanks I had to do the same and was looking for some experience!
I've used this library before, it's great for fix things fast! But you can also use the fork from the PR if there's any
True, you can just link directly to the github repo in package.json. I did this recently; worked well. Only issue I ran into was that I had to go into the module under the node_modules dir and run `yarn install`, in addition to the `yarn install` at the top-level.
I tried here and it didn't work, I'll try this way. Thanks guys!
You just made my day!
Very useful, thank you!
Thank you very much for this 👌🏽
Super useful man. Thank you!
Dose this help when i want to fix some package per deep version to be compatible to react 18
Thank you Ben!
Thank you. Very helpful.
Hmmm, not sure this is the easiest way to use patch-package. You can just edit the package directly in node_modules and run patch-package name-of-package and it creates a diff file for you without having to search or console log anything.
Yeah that's what I did, but sometimes you don't know which JavaScript file to change in the package
It's good to see such a package. But is it the only use case of this package.
amazzzzing. thank you so much
great video, noticed a peculiar case, if you want to patch a package by installing another package for that specific package. looks like that can't be patched. anyone know how to go around something like that?
alternatively, fork library, apply fix, use git url
What is the autocomplete I just saw on your terminal?
default for fish shell benawad.com/fish
Ben Awad thanks
thanks a lot Ben!
Helpful Video.. Thank You
Much thanks man
Great really handy !
why u removed vim extension bro ?
hehe nice catch, vim plugin dies on large files so I disabled it for this video
I'm wonder if u gonna share your thought about NextJS SSG here on youtube! according to your former interesting contents about JAMStack.
yes, that's coming soon!
THANK YOU!!!!
Ty very nice tool.
thanks!
❤
Great video as always. Add a link to it in an article of mine covering multiple techniques to fix broken packages: medium.com/p/d8f808657d8e/
If patch-package somehow worked with TypeScript and build systems that would be even better. Seems like an easier solution in this case is to use the forked repo in your package.json, or it breaks due to build steps?
Hi Ben, what is your ohmyzsh theme?
gruvbox
1000 like brother
Can’t you just use the git URL as the version in package.json?
yeah if the project is simple, that can sometimes work
Ben Awad Since you decided to patch a known version, knowing that version in package.json is by no means telling the truth anyways.
Instead of spinning off your own fork and publish an npm package, or keeping a local patch, I suggest using the SHA URL of the PR source branch directly in your package.json. That’s less lying and less artefacts to maintain.
Vicary A that will not work when the source is compiled (like typescript).
Felix Leupold Please enlighten me, I am honestly not sure if you can correctly patch a bundled script though.
Please create series of redux in react native with navigation and axios in that
isn't it better to just fork the repo?
Idk man this doean't seems to be viable solution.in my case react spring had really nasty memoryleak so people asked them for fix and they made beta version for that till next LTS release .for other packages shouldn't be diffrent if maintainer is active
this is for when the maintainer is slower
Have you tried using Yalc (github.com/whitecolor/yalc)? I've been using Yalc for this particular use-case but will try using patch-package to see if it's faster. Nice videos - keep them coming :)
I haven't, looks nice though
yeiit
im early af