将 next.js 添加到组件库中以使用 Next.js 功能

Adding next.js into a component library to make use of Next.js features

我正在制作一个将在 Next.js 项目中使用的 React 组件库。我想将 Next.js 的功能添加到我的组件中。

在组件库中简单地添加 Next.js 作为开发依赖就足够了吗?

如果您打算将组件发布为包,则需要将 next.js 添加到 peerDependencies。这样做表明您的项目依赖于 next.js 中的东西,但它不包含在您的包中,应该安装在实际项目本身上。

详情请看这里:https://classic.yarnpkg.com/en/docs/dependency-types/#toc-peerdependencies