Skip to main content

pnpm 10.28

· 3 min read
Zoltan Kochan
Lead maintainer of pnpm

pnpm 10.28 引入了一个新的 beforePacking 钩子,用于在发布时自定义 package.json,提升了过滤安装的性能,并包含若干错误修复。

🌐 pnpm 10.28 introduces a new beforePacking hook to customize package.json at publish time, improves filtered install performance, and includes several bug fixes.

小幅更改

🌐 Minor Changes

beforePacking 钩子

🌐 beforePacking Hook

增加了对一个名为 beforePacking 的新钩子的支持,该钩子允许你在发布时自定义 package.json 内容 #3816

🌐 Added support for a new hook called beforePacking that allows you to customize the package.json contents at publish time #3816.

这个钩子在运行 pnpm packpnpm publish 时,即在创建归档文件之前调用。它让你有机会修改将包含在发布包中的包清单,而不会影响你本地的 package.json 文件。

🌐 This hook is called just before creating the tarball when running pnpm pack or pnpm publish. It gives you the opportunity to modify the package manifest that will be included in the published package without affecting your local package.json file.

.pnpmfile.cjs 中的示例用法:

🌐 Example usage in .pnpmfile.cjs:

module.exports = {
hooks: {
beforePacking(pkg) {
// Remove development-only fields
delete pkg.devDependencies
delete pkg.scripts
// Add publication metadata
pkg.publishedAt = new Date().toISOString()
return pkg
}
}
}

有关更多详情,请参阅 .pnpmfile.cjs 文档

🌐 See the .pnpmfile.cjs documentation for more details.

筛选安装性能

🌐 Filtered Install Performance

在某些情况下,过滤安装(即 pnpm install --filter ...)比在没有任何过滤参数的情况下运行 pnpm install 更慢。这个性能回退现在已经修复。过滤安装的速度应该与完整安装一样快或更快 #10408

🌐 In some cases, a filtered install (i.e. pnpm install --filter ...) was slower than running pnpm install without any filter arguments. This performance regression is now fixed. Filtered installs should be as fast or faster than a full install #10408.

补丁更改

🌐 Patch Changes

  • Do not add a symlink to the project into the store's project registry if the store is in a subdirectory of the project #10411.

  • It should be possible to declare the requiredScripts setting in pnpm-workspace.yaml #10261.