Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add --ignore-missing flag to continue without error on missing packages #460

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

Open
andyjy wants to merge 4 commits into ds300:master
base: master
Choose a base branch
Loading
from andyjy:master

Conversation

Copy link

@andyjy andyjy commented Apr 1, 2023

Ignores patches for packages that are not present in node_modules.

This is useful when working with monorepos and wanting to install sub-packages
separately from the root package, with pruned dependencies.

Closes #339

karlhorky, smrubin, EinfachHans, VincentDamour, fformigli, attila, and ItsWendell reacted with heart emoji
Copy link

@ds300 what do you think about this one? Would be very useful :)

Copy link
Author

andyjy commented May 16, 2023

@ds300 I saw you approved a CI run that failed all jobs during setup - looks to have been unrelated to my changes; I've just updated against latest master branch which seems should fix the CI workflows (?🤞)

Glad to update this PR with changes if you'd like to accept it conditional on feedback. Thanks!

Copy link
Author

andyjy commented May 29, 2023
edited
Loading

Update 2023年07月03日: PR now updated to support setting env var PATCH_PACKAGE_IGNORE_MISSING=1 so missing packages can easily be ignored during deployment (due to pruned dependencies) but alerted during development (due to updating dependencies without also updating relevant patches).

Original comment:

I realise this feature as-implemented is "dangerous" - within a monorepo, a future update to the package-lock file may relocate a package out from the root node_modules folder into one or more nested node_modules folders under an individual workspace/subpackage.

Currently patch-package will error when this occurs, drawing attention to fact the current patch is now against a "missing" package. This PR will currently switch that behaviour to subtly reporting as missing when the --ignore-missing flag is specified, which is easy to miss and not the desired behaviour for such circumstances.

I suspect a workable approach is to update the support for --ignore-missing to (instead?) be set via an environment variable - this can then be set at deploy time (when some packages may be missing as expected due to deploying with pruned dependencies) but error locally and during CI when we expect all packages to be present.

Copy link

guys, you can do it according to the following in packages.json.

"installConfig": {
"hoistingLimits": "workspaces"
}

Copy link
Author

andyjy commented Jun 19, 2023

guys, you can do it according to the following in packages.json.

"installConfig": { "hoistingLimits": "workspaces" }

thanks, it looks like that's a feature of yarn only - not npm

attila reacted with thumbs up emoji

Copy link
Author

andyjy commented Jul 5, 2023

I realise this feature as-implemented is "dangerous"

PR now updated to support setting the env var PATCH_PACKAGE_IGNORE_MISSING=1 so this can be set at deploy time (when some packages may be missing as expected due to deploying with pruned dependencies) but error during local development and CI when we expect all packages to be present.

I left the CLI option --ignore-missing for now, but could remove that if preferred.

I've published this fork under patch-package-ignore-missing - version 7.0.1-2 is up to date with patch-package @ 0779cba

Copy link

Did this ever get merged?

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

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Should we throw warning instead of error while patched packages not exist

AltStyle によって変換されたページ (->オリジナル) /