{"id":52898,"date":"2024-12-03T17:33:15","date_gmt":"2024-12-03T09:33:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52898\/"},"modified":"2024-12-03T17:33:15","modified_gmt":"2024-12-03T09:33:15","slug":"%e4%bd%bf%e7%94%a8pnpm%e7%ae%a1%e7%90%86monorepo%e6%97%b6%e5%a6%82%e4%bd%95%e5%85%8b%e6%9c%8d%e7%9b%ae%e5%bd%95%e7%bb%93%e6%9e%84%e9%99%90%e5%88%b6%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52898\/","title":{"rendered":"\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f<\/h1>\n<p>\u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241124\/17324339776742d839ced51.jpg\" class=\"aligncenter\" title=\"\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f\u63d2\u56fe\" alt=\"\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>monorepo \u4e0d\u53d7\u56fa\u6709\u76ee\u5f55\u7ed3\u6784\u9650\u5236<\/strong><\/p>\n<p>\u60a8\u5728\u4f7f\u7528 pnpm \u5b9e\u73b0 monorepo \u65f6\u9047\u5230\u7684\u76ee\u5f55\u7ed3\u6784\u9650\u5236\u5e76\u975e\u4e0d\u53ef\u514b\u670d\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<ol>\n<li><strong>\u9075\u5b88 monorepo \u539f\u5219\uff1a<\/strong><br \/>monorepo \u7684\u76ee\u7684\u662f\u5c06\u591a\u4e2a\u9879\u76ee\u5b58\u50a8\u5728\u5355\u4e2a\u4ee3\u7801\u5e93\u4e2d\u3002\u56e0\u6b64\uff0c\u60a8\u9700\u8981\u5c06\u60a8\u7684\u9879\u76ee\u7ec4\u7ec7\u6210\u5355\u4e2a\u5b58\u50a8\u5e93\uff0c\u5176\u4e2d\u6bcf\u4e2a\u9879\u76ee\u90fd\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5305\u3002\u9075\u5faa\u9884\u5b9a\u4e49\u7684\u76ee\u5f55\u7ed3\u6784\uff08\u5982\u5c06\u5305\u653e\u5728 packages\/ \u76ee\u5f55\u4e0b\uff09\u662f\u5173\u952e\u3002<\/li>\n<li><strong>\u4f7f\u7528 IDE \u7684\u5de5\u4f5c\u533a\u529f\u80fd\uff1a<\/strong><br \/>\u60a8\u4e0d\u5fc5\u5728\u4e0d\u540c\u7684\u7a97\u53e3\u4e2d\u6253\u5f00\u6bcf\u4e2a\u9879\u76ee\u3002\u5927\u591a\u6570 IDE\uff08\u5305\u62ec VSCode\uff09\u90fd\u652f\u6301\u5de5\u4f5c\u533a\uff0c\u5141\u8bb8\u60a8\u5728\u4e00\u4e2a\u7a97\u53e3\u4e2d\u540c\u65f6\u6253\u5f00\u591a\u4e2a\u9879\u76ee\u3002\u8fd9\u6837\uff0c\u60a8\u53ef\u4ee5\u5728\u6839\u76ee\u5f55\u6253\u5f00 monorepo\uff0c\u4ece\u800c\u8bbf\u95ee\u6240\u6709\u9879\u76ee\u3002<\/li>\n<li>\n<p><strong>\u5171\u4eab\u7ec4\u4ef6\uff1a<\/strong><br \/>\u8981\u5171\u4eab react-demo-09 \u4e2d\u7684\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u4e4b\u4e00\uff1a<\/p>\n<ul>\n<li>\u590d\u5236\u7ec4\u4ef6\u5230\u516c\u5171 components\/ \u76ee\u5f55\u4e2d\u3002<\/li>\n<li>\u4f7f\u7528 npm \u94fe\u63a5\uff08\u8f6f\u94fe\u63a5\uff09\u5728 react-demo-08 \u4e2d\u76f4\u63a5\u5f15\u7528 react-demo-09 \u7684\u7ec4\u4ef6\u5305\u3002<\/li>\n<li>\u5b89\u88c5 react-demo-09 \u7684\u7ec4\u4ef6\u5305\u4f5c\u4e3a react-demo-08 \u7684\u4f9d\u8d56\u9879\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5546\u54c1\u5206\u7c7b\u5220\u9664\u65f6\uff0c\u5982\u4f55\u5904\u7406\u5173\u8054\u5546\u54c1\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f \u5bf9\u4e8e\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u8005\u6765\u8bf4\uff0c\u7262\u56fa\u624e\u5b9e\u7684\u57fa\u7840\u662f\u5341\u5206\u91cd\u8981\u7684\uff0c\u7c73\u4e91\u5c31\u6765\u5e26\u5927\u5bb6\u4e00\u70b9\u70b9\u7684\u638c\u63e1\u57fa\u7840\u77e5\u8bc6\u70b9\u3002\u4eca\u5929\u672c\u7bc7\u6587\u7ae0\u5e26\u5927\u5bb6\u4e86\u89e3\u300a\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f\u300b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e86\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u5feb\u70b9\u6536\u85cf\u8d77\u6765\u5427\uff0c\u5426\u5219\u9700\u8981\u65f6\u5c31\u627e\u4e0d\u5230\u4e86\uff01 monorepo \u4e0d\u53d7\u56fa\u6709\u76ee\u5f55\u7ed3\u6784\u9650\u5236 \u60a8\u5728\u4f7f\u7528 pnpm \u5b9e\u73b0 monorepo \u65f6\u9047\u5230\u7684\u76ee\u5f55\u7ed3\u6784\u9650\u5236\u5e76\u975e\u4e0d\u53ef\u514b\u670d\u3002 \u89e3\u51b3\u65b9\u6848\uff1a \u9075\u5b88 monorepo \u539f\u5219\uff1amonorepo \u7684\u76ee\u7684\u662f\u5c06\u591a\u4e2a\u9879\u76ee\u5b58\u50a8\u5728\u5355\u4e2a\u4ee3\u7801\u5e93\u4e2d\u3002\u56e0\u6b64\uff0c\u60a8\u9700\u8981\u5c06\u60a8\u7684\u9879\u76ee\u7ec4\u7ec7\u6210\u5355\u4e2a\u5b58\u50a8\u5e93\uff0c\u5176\u4e2d\u6bcf\u4e2a\u9879\u76ee\u90fd\u662f\u4e00\u4e2a\u5355\u72ec\u7684\u5305\u3002\u9075\u5faa\u9884\u5b9a\u4e49\u7684\u76ee\u5f55\u7ed3\u6784\uff08\u5982\u5c06\u5305\u653e\u5728 packages\/ \u76ee\u5f55\u4e0b\uff09\u662f\u5173\u952e\u3002 \u4f7f\u7528 IDE \u7684\u5de5\u4f5c\u533a\u529f\u80fd\uff1a\u60a8\u4e0d\u5fc5\u5728\u4e0d\u540c\u7684\u7a97\u53e3\u4e2d\u6253\u5f00\u6bcf\u4e2a\u9879\u76ee\u3002\u5927\u591a\u6570 IDE\uff08\u5305\u62ec VSCode\uff09\u90fd\u652f\u6301\u5de5\u4f5c\u533a\uff0c\u5141\u8bb8\u60a8\u5728\u4e00\u4e2a\u7a97\u53e3\u4e2d\u540c\u65f6\u6253\u5f00\u591a\u4e2a\u9879\u76ee\u3002\u8fd9\u6837\uff0c\u60a8\u53ef\u4ee5\u5728\u6839\u76ee\u5f55\u6253\u5f00 monorepo\uff0c\u4ece\u800c\u8bbf\u95ee\u6240\u6709\u9879\u76ee\u3002 \u5171\u4eab\u7ec4\u4ef6\uff1a\u8981\u5171\u4eab react-demo-09 \u4e2d\u7684\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u4e4b\u4e00\uff1a \u590d\u5236\u7ec4\u4ef6\u5230\u516c\u5171 components\/ \u76ee\u5f55\u4e2d\u3002 \u4f7f\u7528 npm \u94fe\u63a5\uff08\u8f6f\u94fe\u63a5\uff09\u5728 react-demo-08 \u4e2d\u76f4\u63a5\u5f15\u7528 react-demo-09 \u7684\u7ec4\u4ef6\u5305\u3002 \u5b89\u88c5 react-demo-09 \u7684\u7ec4\u4ef6\u5305\u4f5c\u4e3a react-demo-08 \u7684\u4f9d\u8d56\u9879\u3002 \u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300a\u4f7f\u7528pnpm\u7ba1\u7406monorepo\u65f6\u5982\u4f55\u514b\u670d\u76ee\u5f55\u7ed3\u6784\u9650\u5236\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01 \u5546\u54c1\u5206\u7c7b\u5220\u9664\u65f6\uff0c\u5982\u4f55\u5904\u7406\u5173\u8054\u5546\u54c1\uff1f<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-52898","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52898","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52898"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52898\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52898"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52898"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52898"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}