Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to apply a patch from a package dependency #7599

Open
1 task
alfaproject opened this issue Jan 31, 2024 · 1 comment
Open
1 task

Allow to apply a patch from a package dependency #7599

alfaproject opened this issue Jan 31, 2024 · 1 comment

Comments

@alfaproject
Copy link

Contribution

Describe the user story

We have some patches that we share across multiple projects so we decided to move them to a shared 'infra' dependency which we then add as part of everyone of our projects.

We are now migrating from Yarn to pnpm and we used to use patch-package to apply our patches, and we could do this postinstall command:

"postinstall": "patch-package --error-on-warn && patch-package --error-on-warn --patch-dir=./node_modules/@the-mill/infra-serverless/patches"

That would then apply the local packages and the shared ones from the infra dependency but that isn't possible anymore with pnpm native patch mechanism due to the fact that it doesn't even let install dependencies before applying the patches )':

Describe the solution you'd like

Basically allow to install project dependencies before applying patches and allow to patch local dependencies from a patch folder from a dependency (or some other mechanism that allows for that without having to fork projects)

Describe the drawbacks of your solution

I'm not sure there are any without having to fork some projects and maintain said fork

Describe alternatives you've considered

Forking

@zkochan
Copy link
Member

zkochan commented Jan 31, 2024

I don't think this is possible to implement unless we come up with a new dependency type that is installed before the rest.

You can create a package in a subdirectory. Add your package with patches as a dependency there. In your main package you can add a pnpm:devPreinstall script that will install the dependencies in the subpackage. Then reference the patches from the node_modules of the subpackage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants