pnpm patch <pkg>
Prepare un paquete para parchear (inspirado en un comando similar en Yarn).
Este comando hará que se extraiga un paquete en un directorio temporal destinado a ser editable a voluntad.
Once you're done with your changes, run pnpm patch-commit <path> (with <path> being the temporary directory you received) to generate a patchfile and register it into your top-level manifest via the patchedDependencies field.
Uso:
pnpm patch <pkg name>@<version>
If you want to change the dependencies of a package, don't use patching to modify the package.json file of the package. For overriding dependencies, use overrides or a package hook.
Opciones
--edit-dir <dir>
El paquete que debe parchearse se extraerá a este directorio.
--ignore-existing
Ignora los archivos de parches existentes al aplicar parches.
Configuración
patchedDependencies
This field is added/updated automatically when you run pnpm patch-commit. It defines patches for dependencies using a dictionary where:
- Keys: Package names with an exact version, a version range, or just the name.
- Values: Relative paths to patch files.
Ejemplo:
patchedDependencies:
express@4.18.1: patches/express@4.18.1.patch
Dependencies can be patched by version range. The priority order is:
- Exact versions (highest priority)
- Version ranges
- Name-only patches (applies to all versions unless overridden)
A special case: the version range * behaves like a name-only patch but does not ignore patch failures.
Ejemplo:
patchedDependencies:
foo: patches/foo-1.patch
foo@^2.0.0: patches/foo-2.patch
foo@2.1.0: patches/foo-3.patch
patches/foo-3.patchis applied tofoo@2.1.0.patches/foo-2.patchapplies to all foo versions matching^2.0.0, except2.1.0.patches/foo-1.patchapplies to all other foo versions.
Avoid overlapping version ranges. If you need to specialize a sub-range, explicitly exclude it from the broader range.
Ejemplo:
patchedDependencies:
# Specialized sub-range
"foo@2.2.0-2.8.0": patches/foo.2.2.0-2.8.0.patch
# General patch, excluding the sub-range above
"foo@>=2.0.0 <2.2.0 || >2.8.0": patches/foo.gte2.patch
In most cases, defining an exact version is enough to override a broader range.
allowUnusedPatches
Added in: v10.7.0 (Previously named allowNonAppliedPatches)
- Por defecto: false
- Tipo: Boolean
When true, installation won't fail if some of the patches from the patchedDependencies field were not applied.
patchedDependencies:
express@4.18.1: patches/express@4.18.1.patch
allowUnusedPatches: true
ignorePatchFailures
Added in: v10.7.0
- Predeterminado: indefinido
- Type: Boolean, undefined
Controls how patch failures are handled.
Behaviour:
- undefined (default):
- Errors out when a patch with an exact version or version range fails.
- Ignores failures from name-only patches.
- false: Errors out for any patch failure.
- true: Prints a warning instead of failing when any patch cannot be applied.