{"id":326382,"date":"2022-04-08T06:30:33","date_gmt":"2022-04-07T22:30:33","guid":{"rendered":"https:\/\/www.idc.net\/help\/326382\/"},"modified":"2022-04-08T06:30:33","modified_gmt":"2022-04-07T22:30:33","slug":"%e7%a7%8d%e5%ad%90%e8%bd%ae%e8%9e%8d%e8%b5%84-700-w%ef%bc%8castro-%e7%9a%84%e6%ad%a3%e5%bc%8f%e5%8f%91%e5%b8%83%e7%bb%99%e5%89%8d%e7%ab%af%e7%95%8c%e5%b8%a6%e6%9d%a5%e4%ba%86%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/326382\/","title":{"rendered":"\u79cd\u5b50\u8f6e\u878d\u8d44 700 w\uff0cAstro \u7684\u6b63\u5f0f\u53d1\u5e03\u7ed9\u524d\u7aef\u754c\u5e26\u6765\u4e86\u4ec0\u4e48\uff1f"},"content":{"rendered":"<p style=\"text-align: center\">\n<p>\u5c31\u5728\u4e0a\u5468\uff0cAstro \u56e2\u961f\u53d1\u5e03\u4e86 1.0 \u7684\u6b63\u5f0f\u7248\u672c\u3002<\/p>\n<p>\u4ece\u5e74\u521d\u6211\u5c31\u5f00\u59cb\u5173\u6ce8\u8fd9\u4e2a\u9879\u76ee\u4e86\uff0c\u4f46\u5f53\u65f6\u53ea\u662f\u5b66\u4e60\u4e86\u4e00\u4e0b\u4ed3\u5e93\u7684\u5de5\u7a0b\u5316\u642d\u5efa\u76f8\u5173\u7684\u4e1c\u897f (changesets \u81ea\u52a8\u53d1\u5305\u4e4b\u7c7b)\uff0c\u5e76\u6ca1\u6709\u6df1\u5165\u4e86\u89e3\u5b83\u672c\u8eab\u7684\u529f\u80fd\u3002\u501f\u7740\u6b63\u5f0f\u53d1\u7248\u7684\u673a\u4f1a\uff0c\u8fd9\u51e0\u5929\u719f\u6089\u4e86\u4e00\u4e0b Astro 1.0\uff0c\u53d1\u73b0\u4e86\u5f88\u591a\u6709\u610f\u601d\u7684\u5730\u65b9\uff0c\u4e0b\u6587\u4f1a\u5206\u522b\u4ece<strong>\u56e2\u961f\u80cc\u666f<\/strong>\u3001<strong>\u6846\u67b6\u5b9a\u4f4d<\/strong>\u548c<strong>\u6838\u5fc3\u4f18\u52bf<\/strong>\u51e0\u4e2a\u7ef4\u5ea6\u7ed9\u5927\u5bb6\u5c55\u5f00\u4ecb\u7ecd\uff0c\u6700\u540e\u4e5f\u4f1a\u63a8\u8350\u4e00\u4e9b\u5b66\u4e60\u8d44\u6599\u3002<\/p>\n<h2>\u56e2\u961f\u80cc\u666f<\/h2>\n<p>\u5728\u6b63\u5f0f\u4ecb\u7ecd Astro \u4e4b\u524d\uff0c\u5148\u7ed9\u5927\u5bb6\u804a\u4e00\u804a\u76f8\u5173\u7684\u80cc\u666f\u3002Astro \u7684\u4f5c\u8005\u662f&nbsp;Fred K. Schott\uff0c\u6ca1\u9519\uff0c\u5c31\u662f\u90a3\u4e2a\u5f00\u53d1 Snowpack \u7684\u8001\u54e5\uff0c\u53ef\u4ee5\u8bf4\u662f Unbundle \u6784\u5efa\u5de5\u5177\u7684\u7956\u5e08\u7237\uff1a<\/p>\n<p style=\"text-align: center\">\n<p>\u4f46\u65e0\u5948\u7684\u662f Vite \u53d1\u5c55\u52bf\u5934\u5b9e\u5728\u592a\u731b\uff0c\u800c Snowpack \u6e10\u6e10\u65e5\u8584\u897f\u5c71\uff0c\u4ed6\u672c\u4eba\u4e5f\u5199\u4e86\u6587\u7ae0\u53d1\u51fa\u4e0b\u9762\u7684\u611f\u6168:<\/p>\n<p style=\"text-align: center\"><span style=\"font-size: 14px\"><span style=\"color: #888888\">\u200b<\/span><\/span><\/p>\n<blockquote style=\"margin-top: 5px;margin-bottom: 5px;padding-left: 1em;margin-left: 0px\">\n<p>\u6587\u7ae0\u94fe\u63a5: https:\/\/dev.to\/fredkschott\/5-more-things-i-learned-building-snowpack-to-20-000-stars-5dc9<\/p>\n<\/blockquote>\n<p>\u5927\u610f\u5c31\u662f Snowpack \u524d\u9014\u6e3a\u832b\uff0c\u7528\u6237\u8d8a\u6765\u8d8a\u5c11\uff0c\u611f\u89c9\u8981\u505a\u5230\u5934\u4e86\u5566\uff0c\u800c Vite \u53d1\u5c55\u7684\u975e\u5e38\u597d\uff0c\u90a3\u540e\u9762\u5f00\u53d1\u7684 Astro \u5c31\u57fa\u4e8e Vite \u6765\u505a\u5427\u3002\u73b0\u5728\u8fde Snowpack \u7684\u5b98\u7f51\u90fd\u8868\u793a\u5f03\u5751\u4e86\uff0c\u4e3b\u52a8\u7ed9 Vite \u5f15\u6d41:<\/p>\n<p style=\"text-align: center\">\n<p>\u5f53\u7136\uff0c\u9664\u4e86 Snowpack\uff0cFred K. Schott&nbsp;\u7684\u56e2\u961f(\u53ebPika)\u8fd8\u505a\u4e86\u4e00\u4ef6\u6bd4\u8f83\u77e5\u540d\u7684\u4ea7\u54c1:&nbsp;Skypack\uff0c\u5373 NPM \u5305\u7684 ESM CDN \u670d\u52a1:<\/p>\n<p style=\"text-align: center\">\n<p>\u4e0d\u5e78\u7684\u662f\uff0cSkypack \u4e5f\u5f88\u957f\u65f6\u95f4(\u4e00\u5e74\u591a)\u6ca1\u6709\u7ef4\u62a4\u4e86\uff0c\u53ef\u4ee5\u770b\u51fa\u56e2\u961f\u4e5f\u4e0d\u518d\u60f3\u7ee7\u7eed\u6295\u5165\u8fd9\u4e2a\u9879\u76ee\u4e86\uff0c\u4e2a\u4eba\u611f\u89c9\u4e3b\u8981\u6709\u4e24\u4e2a\u539f\u56e0:<\/p>\n<ul>\n<li>\u7ade\u4e89\u5bf9\u624b\u7684\u5f3a\u5927\u3002\u7ade\u54c1 esm.sh \u4e00\u76f4\u5728\u6301\u7eed\u8fed\u4ee3\u4e14\u5df2\u7ecf\u5f97\u5230\u4e86 Deno \u7684\u5b98\u65b9\u63a8\u8350\u3002<\/li>\n<li>\u65b9\u6848\u843d\u5730\u56f0\u96be\u3002\u6b64\u7c7b ESM CDN \u5e94\u7528\u5230\u5b9e\u9645\u7684\u4e1a\u52a1\u9879\u76ee\u4e2d\u4ecd\u7136\u6709\u8bf8\u591a\u7684\u73b0\u5b9e\u969c\u788d\uff0c\u5982\u8bf7\u6c42\u6570\u91cf\u591a\u3001\u4e0d\u80fd Tree Shaking\u3001\u4e0d\u80fd\u672c\u5730\u8c03\u8bd5\u7b49\u7b49\uff0c\u8981\u843d\u5730\u662f\u4e00\u4e2a\u6bd4\u8f83\u96be\u7684\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u5728\u8fd1\u4e9b\u5e74\u7684\u65f6\u95f4\u91cc\uff0cFred K. Schott&nbsp;\u56e2\u961f\u4e00\u76f4\u5c06\u91cd\u5fc3\u653e\u5728\u4e86\u65b0\u9879\u76ee Astro \u4e0a\u9762\uff0c\u7ecf\u8fc7 16 \u4e2a\u6708\u7684\u6253\u78e8\uff0c Astro \u5728\u5168\u7403\u62e5\u6709\u4e86 30000 \u591a\u4e2a\u7528\u6237\uff0c\u88ab Google\u3001Netlify \u7b49\u5927\u516c\u53f8\u4f7f\u7528\uff0cGithub \u7684 star \u5df2\u7ecf\u8fbe\u5230 15k +\u3002<\/p>\n<p>\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0cFred K. Schott\u200b&nbsp;\u4e3a\u4e86\u8fd9\u4e2a\u9879\u76ee\u4e13\u95e8\u6210\u7acb\u4e86\u4e00\u4e2a\u521b\u4e1a\u516c\u53f8:&nbsp;The Astro Technology Company\u200b\uff0c\u5e76\u4e14\u5df2\u7ecf\u878d\u5230\u4e86&nbsp;700 \u4e07\u7f8e\u5200\u7684\u79cd\u5b50\u8f6e\u6295\u8d44\uff0c\u6253\u7b97\u4e00\u76f4\u4ee5\u5f00\u6e90\u7684\u65b9\u5f0f\u53d1\u5c55\u4e0b\u53bb\u3002\u76f8\u6bd4\u4e8e\u4e00\u4e9b\u77e5\u540d\u5f00\u6e90\u9879\u76ee\u7684\u8d5e\u52a9\u6536\u5165\uff0c\u5982&nbsp;Webpack[1]&nbsp;22 w \u5200\/\u5e74\u3001Babel[2]&nbsp;&nbsp;30 w \u5200\/\u5e74\uff0cAstro \u5728\u7ecf\u6d4e\u65b9\u9762\u6709\u5982\u9c7c\u5f97\u6c34\u7684\u4f18\u52bf\u3002<\/p>\n<h2>\u6846\u67b6\u5b9a\u4f4d<\/h2>\n<p>\u63a5\u4e0b\u6765\u804a\u4e00\u804a Astro \u6846\u67b6\u7684\u5b9a\u4f4d\uff0c\u662f\u50cf Vue\u3001React \u8fd9\u6837\u7684\u5e95\u5c42\u6e32\u67d3\u6846\u67b6\uff0c\u8fd8\u662f\u50cf Next.js \u8fd9\u79cd\u4e0a\u5c42\u7684\u7814\u53d1\u6846\u67b6\uff1f<\/p>\n<p>\u8fd9\u4e00\u70b9\u5176\u5b9e\u633a\u56f0\u6270\u521d\u5b66\u8005\u7684\uff0c\u56e0\u4e3a Astro \u65e2\u81ea\u521b\u4e86\u7c7b\u4f3c\u4e8e.vue\u3001.jsx\u6587\u4ef6\u7684&nbsp;.astro&nbsp;\u8bed\u6cd5\uff0c\u53c8\u63d0\u4f9b\u4e86\u50cf Next.js \u91cc\u9762\u5404\u79cd\u8fd0\u884c\u65f6\u7684\u80fd\u529b\uff0c\u6bd4\u5982\u7ea6\u5b9a\u5f0f\u8def\u7531\u3001\u6784\u5efa\u4f18\u5316\u3001SSR \u7b49\u7b49\u3002<\/p>\n<p>\u4f46\u5b9e\u9645\u4e0a\u5b83\u7ed9\u81ea\u5df1\u7684\u5b9a\u4f4d\u975e\u5e38\u6e05\u6670\uff0c\u5373&nbsp;content-focused&nbsp;\u5e94\u7528\u5f00\u53d1\u6846\u67b6\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u5c31\u662f\u91cd\u5185\u5bb9\u3001\u8f7b\u4ea4\u4e92\u573a\u666f\u4e0b\u7684\u4e0a\u5c42\u7814\u53d1\u6846\u67b6\uff0c\u6bd4\u5982\u5927\u591a\u6570\u7535\u5546\u7f51\u7ad9\u3001\u6587\u6863\u7ad9\u3001\u535a\u5ba2\u7ad9\u3001\u8bc1\u5238\u7f51\u7ad9\u7b49\u7b49\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u5c06 Astro \u7406\u89e3\u4e3a\u4e00\u4e2a\u5782\u76f4\u573a\u666f\u4e0b\u7684Next.js\uff0c\u4f46\u5b83\u53ef\u4ee5\u5728\u5b83\u9002\u7528\u7684\u9886\u57df\u91cc\u9762\u53ef\u4ee5\u80dc\u8fc7\u5176\u5b83\u6240\u6709\u7ade\u54c1(\u5982Next.js\u3001Remix\u3001Vuepress&nbsp;\u7b49)\uff0c\u8fd9\u662f\u5b83\u80fd\u591f\u505a\u8d77\u6765\u7684\u91cd\u8981\u539f\u56e0\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c31\u6765\u770b\u770b Astro \u7684\u4f18\u52bf\u5728\u4e8e\u54ea\u4e9b\u5730\u65b9\u3002<\/p>\n<h2>\u6838\u5fc3\u4f18\u52bf<\/h2>\n<p>Astro \u7684\u4e3b\u8981\u4f18\u52bf\u5305\u62ec\u5982\u4e0b\u51e0\u70b9:<\/p>\n<ul>\n<li>Islands \u67b6\u6784\uff0c\u89e3\u51b3\u4f20\u7edf SSR\/SSG \u6846\u67b6\u7684\u5168\u91cf hydration \u95ee\u9898\uff0c\u505a\u5230\u5c3d\u53ef\u80fd\u5c11\u7684 Client \u7aef JS \u7684\u5f00\u9500\uff0c\u751a\u81f3\u662f 0 JS\u3002<\/li>\n<li>\u5b66\u4e60\u6210\u672c\u4f4e\u3002.astro&nbsp;\u8bed\u6cd5\u548c\u4f20\u7edf\u7684.jsx&nbsp;\u548c.vue&nbsp;\u975e\u5e38\u76f8\u4f3c\uff0c\u5bf9\u4e8e\u65b0\u624b\u524d\u7aef\u6765\u8bf4\u4e5f\u6bd4\u8f83\u5bb9\u6613\u638c\u63e1\u3002<\/li>\n<li>\u4f7f\u7528\u7075\u6d3b\u3002\u5bf9\u4e8e\u9875\u9762\u7684\u5f00\u53d1\uff0c\u4f60\u65e2\u53ef\u4ee5\u4f7f\u7528\u5b98\u65b9\u7684.astro&nbsp;\u8bed\u6cd5\uff0c\u4e5f\u540c\u6837\u53ef\u4ee5\u4f7f\u7528.md\u3001.vue\u3001.jsx&nbsp;\u8bed\u6cd5\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f60\u53ef\u4ee5\u81ea\u7531\u9009\u62e9\u5176\u5b83\u524d\u7aef\u6846\u67b6\u7684\u8bed\u6cd5\u6765\u5f00\u53d1\uff0c\u751a\u81f3\u53ef\u4ee5\u5728\u4e00\u4e2a\u9879\u76ee\u4e2d\u540c\u65f6\u5199 Vue \u7ec4\u4ef6\u548c React \u7ec4\u4ef6\uff01<\/li>\n<li>\u6784\u5efa\u8fc5\u901f\u3002\u5e95\u5c42\u6784\u5efa\u4f53\u7cfb\u57fa\u4e8e Vite \u4ee5\u53ca Esbuild \u5b9e\u73b0\uff0c\u9879\u76ee\u542f\u52a8\u901f\u5ea6\u975e\u5e38\u5feb\u3002<\/li>\n<\/ul>\n<h3>Islands \u67b6\u6784<\/h3>\n<p>\u5728\u5982\u4e0a\u7684\u51e0\u4e2a\u4f18\u70b9\u4e2d\uff0c\u6211\u4eec\u6765\u91cd\u70b9\u8bf4\u4e00\u8bf4 Astro \u7684 Islands \u67b6\u6784\uff0c\u56e0\u4e3a\u8fd9\u662f\u5b83\u9ad8\u6027\u80fd\u6700\u4e3b\u8981\u7684\u539f\u56e0\u3002<\/p>\n<p>Islands \u67b6\u6784\u6a21\u578b\u65e9\u5728 2019 \u5e74\u5c31\u88ab\u63d0\u51fa\u6765\u4e86\uff0c\u5e76\u5728 2011 \u5e74\u88ab Preact \u4f5c\u8005Json Miller&nbsp;\u5728Islnads Architecture[3]&nbsp;\u4e00\u6587\u4e2d\u5f97\u5230\u63a8\u5e7f\u3002\u8fd9\u4e2a\u6a21\u578b\u4e3b\u8981\u7528\u4e8e SSR (\u4e5f\u5305\u62ec SSG) \u5e94\u7528\uff0c\u6211\u4eec\u77e5\u9053\uff0c\u5728\u4f20\u7edf\u7684 SSR \u5e94\u7528\u4e2d\uff0c\u670d\u52a1\u7aef\u4f1a\u7ed9\u6d4f\u89c8\u5668\u54cd\u5e94\u5b8c\u6574\u7684 HTML \u5185\u5bb9\uff0c\u5e76\u5728 HTML \u4e2d\u6ce8\u5165\u4e00\u6bb5\u5b8c\u6574\u7684 JS \u811a\u672c\u7528\u4e8e\u5b8c\u6210\u4e8b\u4ef6\u7684\u7ed1\u5b9a\uff0c\u4e5f\u5c31\u662f\u5b8c\u6210 hydration (\u6ce8\u6c34) \u7684\u8fc7\u7a0b\u3002\u5f53\u6ce8\u6c34\u7684\u8fc7\u7a0b\u5b8c\u6210\u4e4b\u540e\uff0c\u9875\u9762\u4e5f\u624d\u80fd\u771f\u6b63\u5730\u80fd\u591f\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n<p>\u90a3\u4e48\u5f53\u5e94\u7528\u7684\u4f53\u79ef\u9010\u6e10\u589e\u5927\u65f6\uff0c\u9700\u8981\u5728\u5ba2\u6237\u7aef\u6267\u884c\u7684 JS \u811a\u672c\u4e5f\u4f1a\u8d8a\u6765\u8d8a\u591a\uff0c\u8fd9\u4e5f\u610f\u5473\u7740 TTI(\u53ef\u4ea4\u4e92\u65f6\u95f4) \u6307\u6807\u8d8a\u6765\u8d8a\u9ad8:<\/p>\n<p style=\"text-align: center\">\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cIslands \u67b6\u6784\u5c06\u9875\u9762\u62c6\u5206\u4e3a\u5404\u81ea\u72ec\u7acb\u7684\u7ec4\u4ef6\uff0c\u5305\u542b\u9759\u6001\u7ec4\u4ef6\u548c\u53ef\u4ea4\u4e92\u7ec4\u4ef6\uff0c\u5982\u4e0b\u56fe\u7684\u4f8b\u5b50\u6240\u793a\uff1a<\/p>\n<p style=\"text-align: center\">\n<p>\u53ef\u4ee5\u6e05\u695a\u7684\u770b\u5230\uff0c\u4e00\u4e2a\u9875\u9762\u4e2d\u53ea\u6709\u90e8\u5206\u7684\u7ec4\u4ef6\u4ea4\u4e92\uff0c\u90a3\u4e48\u5bf9\u4e8e\u8fd9\u4e9b\u53ef\u4ea4\u4e92\u7684\u7ec4\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u5e76\u884c\u5730\u6267\u884c hydration \u8fc7\u7a0b\uff0c\u56e0\u4e3a\u7ec4\u4ef6\u4e4b\u95f4\u662f\u4e92\u76f8\u72ec\u7acb\u7684\u3002<\/p>\n<p>\u800c\u5bf9\u4e8e\u9759\u6001\u7ec4\u4ef6\uff0c\u5373\u4e0d\u53ef\u4ea4\u4e92\u7684\u7ec4\u4ef6\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba9\u5176\u4e0d\u53c2\u4e0e hydration \u8fc7\u7a0b\uff0c\u76f4\u63a5\u590d\u7528\u670d\u52a1\u7aef\u4e0b\u53d1\u7684 HTML \u5185\u5bb9\u3002<\/p>\n<p>\u53ef\u4ea4\u4e92\u7684\u7ec4\u4ef6\u5c31\u72b9\u5982\u6574\u4e2a\u9875\u9762\u4e2d\u7684\u5b64\u5c9b(Island)\uff0c\u56e0\u6b64\u8fd9\u79cd\u6a21\u5f0f\u53eb\u505a Islands \u67b6\u6784\u3002<\/p>\n<p>\u76f8\u6bd4\u4e8e\u4f20\u7edf SSR \u4e2d\u7684\u5168\u91cf hydration\uff0cIslands \u6a21\u5f0f\u53ef\u4ee5\u5b9e\u73b0\u5c40\u90e8(partial) hydration\uff0c\u4ece\u800c\u4f18\u5316 JS \u7684\u4f53\u79ef\uff0c\u51cf\u5c11\u7f51\u7edc\u4f20\u8f93\u7684\u6210\u672c\u548c JS \u8fd0\u884c\u65f6\u7684\u5f00\u9500\u3002<\/p>\n<p>\u5728 Astro \u4e2d\uff0c\u9ed8\u8ba4\u6240\u6709\u7684\u7ec4\u4ef6\u90fd\u662f\u9759\u6001\u7ec4\u4ef6\uff0c\u6bd4\u5982:<\/p>\n<pre><span style=\"margin: 0px;padding: 0px\">\/\/ index.astro<\/span><br><span style=\"margin: 0px;padding: 0px\">import<\/span> <span style=\"margin: 0px;padding: 0px\">MyReactComponent<\/span> <span style=\"margin: 0px;padding: 0px\">from<\/span> <span style=\"margin: 0px;padding: 0px\">'..\/components\/MyReactComponent.jsx'<\/span>;<br><span style=\"margin: 0px;padding: 0px\">---<\/span><br><span style=\"margin: 0px;padding: 0px\">&lt;<\/span><span style=\"margin: 0px;padding: 0px\">MyReactComponent<\/span> <span style=\"margin: 0px;padding: 0px\">\/&gt;<\/span><\/pre>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0c\u8fd9\u79cd\u5199\u6cd5\u4e0d\u4f1a\u5728\u6d4f\u89c8\u5668\u6dfb\u52a0\u4efb\u4f55\u7684 JS \u4ee3\u7801\u3002\u4f46\u6709\u65f6\u6211\u4eec\u9700\u8981\u5728\u7ec4\u4ef6\u4e2d\u7ed1\u5b9a\u4e00\u4e9b\u4ea4\u4e92\u4e8b\u4ef6\uff0c\u90a3\u4e48\u8fd9\u65f6\u5c31\u9700\u8981\u6fc0\u6d3b\u5b64\u5c9b\u7ec4\u4ef6\u4e86\uff0c\u5728 Astro \u5982\u4f55\u6765\u6fc0\u6d3b\u5462\uff1f\u5176\u5b9e\u5f88\u7b80\u5355\uff0c\u5728\u4f7f\u7528\u7ec4\u4ef6\u65f6\u52a0\u4e0aclient:load\u6307\u4ee4\u5373\u53ef:<\/p>\n<pre><span style=\"margin: 0px;padding: 0px\">\/\/ index.astro<\/span><br><span style=\"margin: 0px;padding: 0px\">---<\/span><br><span style=\"margin: 0px;padding: 0px\">import<\/span> <span style=\"margin: 0px;padding: 0px\">MyReactComponent<\/span> <span style=\"margin: 0px;padding: 0px\">from<\/span> <span style=\"margin: 0px;padding: 0px\">'..\/components\/MyReactComponent.jsx'<\/span>;<br><span style=\"margin: 0px;padding: 0px\">---<\/span><br><span style=\"margin: 0px;padding: 0px\">&lt;<\/span><span style=\"margin: 0px;padding: 0px\">MyReactComponent<\/span> <span style=\"margin: 0px;padding: 0px\">client<\/span>:<span style=\"margin: 0px;padding: 0px\">load<\/span> <span style=\"margin: 0px;padding: 0px\">\/&gt;<\/span><\/pre>\n<p>\u5982\u6b64\u4e00\u6765\uff0cAstro \u4f1a\u7ed9\u6d4f\u89c8\u5668\u4f20\u8f93\u4e00\u90e8\u5206 JS \u4ee3\u7801\u4f9b\u8fd9\u4e2a\u7ec4\u4ef6\u5b8c\u6210 hydration\uff0c\u4ee5\u4fbf\u540e\u7eed\u7684\u4ea4\u4e92\u3002<\/p>\n<h3>\u5bf9\u6bd4 Next.js \u548c Remix<\/h3>\n<p>\u8bfb\u5230\u8fd9\u91cc\uff0c\u4f60\u53ef\u80fd\u4f1a\u8bf4\u4e86\uff0c\u76f8\u6bd4\u4e8e\u5176\u5b83\u7684\u4e1a\u754c\u65b9\u6848\uff0cAstro \u5230\u5e95\u4f18\u52bf\u5728\u54ea\u91cc\u5462\uff1f\u6211\u4eec\u4e0d\u59a8\u6765\u76d8\u70b9\u4e00\u4e0b\u3002<\/p>\n<p>\u9996\u5148\u662f\u5927\u540d\u9f0e\u9f0e\u7684 Next.js\uff0c\u6211\u4eec\u77e5\u9053 Next.js \u662f\u4e00\u4e2a\u975e\u5e38\u7ecf\u5178\u7684 React SSR \u6846\u67b6\uff0c\u4e5f\u662f\u4f7f\u7528\u4f20\u7edf\u7684 SSR\/SSG \u6280\u672f\uff0c\u53ef\u4ee5\u9002\u7528\u4e8e\u51e0\u4e4e\u6240\u6709\u7684 Web \u5f00\u53d1\u573a\u666f\u3002\u800c Astro \u5728\u5176\u9002\u7528\u7684content-focused\u573a\u666f\u4e0b\uff0c\u6027\u80fd\u4f1a\u660e\u663e\u9ad8\u4e8e Next.js\uff0c\u4ee5\u4e0b\u662f\u4e24\u4e2a\u771f\u5b9e\u7684\u8fc1\u79fb\u6848\u4f8b:<\/p>\n<p style=\"text-align: center\">\n<p>\u53ef\u4ee5\u770b\u5230\uff0cAstro \u76f8\u6bd4 Next.js \u53ef\u4ee5\u5927\u5e45\u5ea6\u51cf\u5c11 JS \u4ee3\u7801\u7684\u4f53\u79ef(90% \u4ee5\u4e0a)\uff0c\u540c\u65f6\u9875\u9762\u7684\u8fd0\u884c\u65f6\u6027\u80fd\u4e5f\u63d0\u5347\u4e86 30% \u4ee5\u4e0a\u3002\u9664\u6b64\u4e4b\u5916\uff0cAstro \u4e0d\u4ec5\u652f\u6301\u4f7f\u7528 React \u6846\u67b6\uff0c\u800c\u4e14\u652f\u6301 Vue\u3001Solid \u7b49\u5728\u5185\u7684\u5404\u79cd\u524d\u7aef\u6846\u67b6\uff0c\u7075\u6d3b\u6027\u66f4\u9ad8\u3002<\/p>\n<p>\u5176\u6b21\u662f\u6700\u8fd1\u6bd4\u8f83\u706b\u7684\u65b0\u79c0\u6846\u67b6&nbsp;Remix\uff0c\u5b83\u57fa\u4e8e react-router \u7ba1\u7406\u7ec4\u4ef6\uff0c\u901a\u8fc7 loader \u548c action \u7684\u6982\u5ff5\u5c3d\u53ef\u80fd\u5c06\u903b\u8f91\u4ee3\u7801\u653e\u5230\u670d\u52a1\u7aef\u7684 bundle\uff0c\u4ece\u800c\u51cf\u5c11\u5ba2\u6237\u7aef JS \u7684\u4ee3\u7801\u4f53\u79ef\uff0c\u540c\u6837\u662f\u5d07\u5c1a 0 JS \u7684\u7406\u5ff5\uff0cRemix \u5374\u4ecd\u7136\u9700\u8981\u5168\u91cf hydration\uff0c\u65e0\u6cd5\u5b8c\u6210 partial hydration\u3002\u6b64\u5916\uff0cAstro \u8fd8\u6709\u4e24\u5927\u4f18\u52bf:<\/p>\n<ul>\n<li>\u9664\u4e86 React\uff0c\u4e5f\u652f\u6301\u5176\u5b83\u7684\u4f17\u591a\u524d\u7aef\u6846\u67b6\uff1b<\/li>\n<li>\u540c\u65f6\u652f\u6301 SSR \u548c SSG\uff0c\u800c Remix \u4e0d\u652f\u6301 SSG\u3002<\/li>\n<\/ul>\n<h3>\u5bf9\u6bd4 React 18 \u7684 Selection Hydration \u7279\u6027<\/h3>\n<p>React 18 \u63d0\u4f9b\u4e86&nbsp;renderToPipeableStream&nbsp;API\uff0c\u771f\u6b63\u5b9e\u73b0\u4e86 SSR \u573a\u666f\u4e0b\u7684&nbsp;Selection Hydration\uff0c\u4e3b\u8981\u6709\u5982\u4e0b\u7684\u51e0\u4e2a\u7279\u70b9:<\/p>\n<ul>\n<li>\u5728\u5b8c\u6574\u7684 HTML \u6e32\u67d3\u4e4b\u524d\u5c31\u53ef\u4ee5\u8fdb\u884c\u7ec4\u4ef6\u7684 hydrate\uff0c\u800c\u4e0d\u7528\u7b49\u5f85 HTML \u7684\u5185\u5bb9\u53d1\u9001\u5b8c\u6bd5<\/li>\n<li>hydration \u53ef\u4e2d\u65ad\u3002\u6bd4\u5982\u9875\u9762\u4e2d\u6709\u4e24\u4e2a\u7ec4\u4ef6: Sidebar \u548c Comment\uff0c\u5f53\u8fd9\u4e2a\u90e8\u5206\u7684 HTML \u53d1\u9001\u81f3\u6d4f\u89c8\u5668\u65f6\uff0cReact \u6253\u7b97\u5f00\u59cb\u5bf9 Sidebar \u7ec4\u4ef6\u8fdb\u884c hydrate:<\/li>\n<\/ul>\n<p style=\"text-align: center\">\n<p>\u5982\u679c\u7528\u6237\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u70b9\u51fb\u4e86 Comment \u7ec4\u4ef6\uff0c\u90a3\u4e48 React \u4f1a\u4e2d\u65ad\u5f53\u524d\u5bf9\u4e8e SideBar \u7ec4\u4ef6\u7684 hydrate\uff0c\u4ece\u800c\u53bb\u6267\u884c Comment \u7ec4\u4ef6\u7684 hydrate:<\/p>\n<p style=\"text-align: center\">\n<blockquote style=\"margin-top: 5px;margin-bottom: 5px;padding-left: 1em;margin-left: 0px\">\n<p>\u8be6\u60c5\u53ef\u89c1 React 18 SSR Architecture: https:\/\/github.com\/reactwg\/react-18\/discussions\/37<\/p>\n<\/blockquote>\n<p>\u90a3\u4e48 Astro \u4e2d\u7684 Islands \u67b6\u6784\uff0c\u5373&nbsp;Partial Hydration\uff0c\u548c React \u7684&nbsp;Selection Hydration&nbsp;\u5230\u5e95\u662f\u4e0d\u662f\u4e00\u4e2a\u4e1c\u897f\u5462\uff1f<\/p>\n<p>\u7b54\u6848\u662f\u5426\u5b9a\u7684\u3002\u4e24\u8005\u5b58\u5728\u7740\u975e\u5e38\u5927\u7684\u533a\u522b:<\/p>\n<ul>\n<li>\u4ece\u6e32\u67d3\u6846\u67b6\u4e0a\u6765\u770b\uff0cSelection Hydration&nbsp;\u4f9d\u9644\u4e8e\u5177\u4f53\u6846\u67b6\u7684\u5b9e\u73b0\uff0c\u800cPartial Hydration&nbsp;\u53ef\u4ee5\u505a\u5230\u6846\u67b6\u65e0\u5173\uff0c\u5373\u4f7f\u662f Vue\u3001Solid \u7684\u9879\u76ee\u4e5f\u53ef\u4ee5\u505a\u5230Partial Hydration\u3002<\/li>\n<li>\u4ece\u5ba2\u6237\u7aef\u6267\u884c\u7684 JS \u603b\u91cf\u6765\u770b\uff0cPartial Hydration&nbsp;\u53ef\u4ee5\u505a\u5230\u52a0\u8f7d\u90e8\u5206\u7ec4\u4ef6\u7684 JS \u4ee3\u7801\uff0c\u800cSelection Hydration&nbsp;\u4ecd\u7136\u9700\u8981\u52a0\u8f7d\u548c\u6267\u884c\u5168\u91cf\u7684 JS \u4ee3\u7801\u3002<\/li>\n<li>\u4ece\u670d\u52a1\u7aef\u548c\u5ba2\u6237\u7aef\u7684\u4ea4\u4e92\u6765\u770b\uff0cSelection Hydration&nbsp;\u4e25\u91cd\u4f9d\u8d56\u4e8e\u6d41\u5f0f(Streaming)\u6e32\u67d3\uff0c\u670d\u52a1\u7aef\u9700\u8981\u52a0\u4e0atransfer-encoding: chunked&nbsp;\u7684\u54cd\u5e94\u5934\uff0c\u800cPartial Hydration&nbsp;\u6ca1\u6709\u8fd9\u4e2a\u9650\u5236\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c\u867d\u7136\u4e24\u8005\u90fd\u662f\u5728 Hydration \u4e0a\u505a\u6587\u7ae0\uff0c\u4f46\u5176\u5b9e\u662f\u4e24\u79cd\u5b8c\u5168\u4e0d\u540c\u7684\u65b9\u6848\uff0c\u800c\u4e14&nbsp;Partial Hydration&nbsp;&nbsp;\u66f4\u52a0\u901a\u7528\uff0c\u9650\u5236\u66f4\u5c11\uff0c\u6267\u884c\u7684 JS \u66f4\u5c11\u3002<\/p>\n<h2>\u5c0f\u7ed3<\/h2>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5bf9 Astro \u7684\u4ecb\u7ecd\u548c\u5206\u6790\uff0c\u540e\u9762\u6709\u673a\u4f1a\u7ed9\u5927\u5bb6\u5256\u6790\u4e00\u4e0b\u5185\u90e8\u7684\u6e90\u7801\u5b9e\u73b0\u3002\u6587\u4e2d\u5982\u6709\u4e0d\u59a5\u7684\u5730\u65b9\uff0c\u6b22\u8fce\u5927\u5bb6\u8bc4\u8bba\u548c\u6307\u6b63\u3002\u6700\u540e\u7ed9\u5927\u5bb6\u63a8\u8350\u4e00\u4e9b Astro \u7684\u5b66\u4e60\u8d44\u6599\uff0c\u65b9\u4fbf\u5927\u5bb6\u8bfb\u5b8c\u6587\u7ae0\u8fdb\u4e00\u6b65\u4e86\u89e3:<\/p>\n<ul>\n<li>Astro \u5b98\u65b9\u6587\u6863: https:\/\/astro.build\/\u3002<\/li>\n<li>Astro \u5b9e\u6218\u7cfb\u5217\u6559\u7a0b: https:\/\/aalam.in\/blog\/astro-get-up-and-running\u3002<\/li>\n<\/ul>\n<h4>\u53c2\u8003\u8d44\u6599<\/h4>\n<p><span style=\"font-size: 12px\">[1]<\/span>Webpack:&nbsp;<em>https:\/\/opencollective.com\/webpack\u3002<\/em><\/p>\n<p><span style=\"font-size: 12px\">[2]<\/span>Babel:&nbsp;<em>https:\/\/opencollective.com\/babel\u3002<\/em><\/p>\n<p><span style=\"font-size: 12px\">[3]<\/span>Islnads Architecture:&nbsp;<em>https:\/\/jasonformat.com\/islands-architecture\/\u3002<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5c31\u5728\u4e0a\u5468\uff0cAstro \u56e2\u961f\u53d1\u5e03\u4e86 1.0 \u7684\u6b63\u5f0f\u7248\u672c\u3002 \u4ece\u5e74\u521d\u6211\u5c31\u5f00\u59cb\u5173\u6ce8\u8fd9\u4e2a\u9879\u76ee\u4e86\uff0c\u4f46\u5f53\u65f6\u53ea\u662f\u5b66\u4e60\u4e86\u4e00\u4e0b\u4ed3\u5e93 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":326383,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-326382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-website"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/326382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=326382"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/326382\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/326383"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=326382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=326382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=326382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}