admin管理员组文章数量:1432205
I have a very simple monorepo using a pnpm workspace with an api folder and a packages folder. My packages folder contains a "common" package, which has been added to the api project. The dist folder in common looks good, but when I look in /api/node_modules/common, I expected to see the contents of my common/dist folder. Instead I see EVERYTHING from inside my common folder.
Am I mistaken to expect to only see the contents of the dist folder in the consuming app's node_modules? I thought having the following in my common/package.json would cause only the dist folder to be included... "files": [ "dist" ],
Here is a snapshot...
I have a very simple monorepo using a pnpm workspace with an api folder and a packages folder. My packages folder contains a "common" package, which has been added to the api project. The dist folder in common looks good, but when I look in /api/node_modules/common, I expected to see the contents of my common/dist folder. Instead I see EVERYTHING from inside my common folder.
Am I mistaken to expect to only see the contents of the dist folder in the consuming app's node_modules? I thought having the following in my common/package.json would cause only the dist folder to be included... "files": [ "dist" ],
Here is a snapshot...
Share Improve this question asked Nov 19, 2024 at 0:04 Tim HardyTim Hardy 1,7671 gold badge19 silver badges44 bronze badges1 Answer
Reset to default 0As I've learned more about pnpm, I believe it uses symlinks for local/monorepo references, which would mean it's simply a link to the folder within the monorepo.
I really wish pnpm's documentation would publicize this better. The main problem with it is that a developer could very easily import something as follows...
import {CustomError} from 'common/src/errors/custom.error';
...even if that file is not exposed in the public api for the module - really no better than relative pathing. If the module were then to be published as an actual npm package, all that code would break.
I would have liked it if pnpm would honor the public api of a module, even when used locally in a monorepo, or at least honor the "files" property in package.json. This would promote good, modular coding. Perhaps it's impossible. If anyone knows of a workaround to honor a library's public api in a pnpm monorepo, I'd love to hear about it.
本文标签: monorepopnpm locally referenced modules contain more than just dist folder contentsStack Overflow
版权声明:本文标题:monorepo - pnpm locally referenced modules contain more than just dist folder contents - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745588596a2665061.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论