梗概

  • 定义了一个patch,在安装对应版本的依赖的时候,会自动安装该patch,以此来修改第三方库

适用范围

  • 亲自临时修复第三方库的package
    • 等待package更新版本

定义patch

The active selection from the package.json file is a configuration specific to pnpm, a fast, disk space efficient package manager for JavaScript and Node.js projects. This configuration is used to apply patches to dependencies directly within your project. The patchedDependencies object under the pnpm key is where you define these patches.

In this specific example, a patch is defined for the vite-plugin-ssr package, version 0.4.52. The key vite-plugin-ssr@0.4.52 specifies the package name and its version, and the value patches/vite-plugin-ssr@0.4.52.patch points to the patch file within the project directory. This means that when pnpm installs the vite-plugin-ssr package at version 0.4.52, it will automatically apply the modifications described in the vite-plugin-ssr@0.4.52.patch file located in the patches directory.

实例

diff --git a/dist/cjs/node/renderPage.js b/dist/cjs/node/renderPage.js
index bb7746bfe163aab8f8ee074fe57e09ae71411c15..58f3b0feab0d6812032a431ca59daa05a63f69c3 100644
--- a/dist/cjs/node/renderPage.js
+++ b/dist/cjs/node/renderPage.js
@@ -188,7 +188,8 @@ async function renderErrorPage(pageContextInit, errOriginal, pageContextOfOrigin
         is404: false,
         _pageId: null,
         errorWhileRendering: errOriginal,
-        routeParams: {}
+        routeParams: {},
+        pageContextOriginal: pageContextOfOriginalError
     });
     if ((0, RenderErrorPage_1.isRenderErrorPageException)(pageContext.errorWhileRendering)) {
         (0, utils_1.objectAssign)(pageContext, { is404: true });